| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 var __create = Object.create; 2 var __defProp = Object.defineProperty; 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 4 var __getOwnPropNames = Object.getOwnPropertyNames; 5 var __getProtoOf = Object.getPrototypeOf; 6 var __hasOwnProp = Object.prototype.hasOwnProperty; 7 var __commonJS = (cb, mod) => function __require() { 8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 9 }; 10 var __export = (target, all) => { 11 for (var name in all) 12 __defProp(target, name, { get: all[name], enumerable: true }); 13 }; 14 var __copyProps = (to, from, except, desc) => { 15 if (from && typeof from === "object" || typeof from === "function") { 16 for (let key of __getOwnPropNames(from)) 17 if (!__hasOwnProp.call(to, key) && key !== except) 18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 19 } 20 return to; 21 }; 22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 23 // If the importer is in node compatibility mode or this is not an ESM 24 // file that has been converted to a CommonJS file using a Babel- 25 // compatible transform (i.e. "__esModule" has not been set), then set 26 // "default" to the CommonJS "module.exports" for node compatibility. 27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 28 mod 29 )); 30 31 // package-external:@wordpress/i18n 32 var require_i18n = __commonJS({ 33 "package-external:@wordpress/i18n"(exports, module) { 34 module.exports = window.wp.i18n; 35 } 36 }); 37 38 // package-external:@wordpress/element 39 var require_element = __commonJS({ 40 "package-external:@wordpress/element"(exports, module) { 41 module.exports = window.wp.element; 42 } 43 }); 44 45 // vendor-external:react 46 var require_react = __commonJS({ 47 "vendor-external:react"(exports, module) { 48 module.exports = window.React; 49 } 50 }); 51 52 // vendor-external:react/jsx-runtime 53 var require_jsx_runtime = __commonJS({ 54 "vendor-external:react/jsx-runtime"(exports, module) { 55 module.exports = window.ReactJSXRuntime; 56 } 57 }); 58 59 // vendor-external:react-dom 60 var require_react_dom = __commonJS({ 61 "vendor-external:react-dom"(exports, module) { 62 module.exports = window.ReactDOM; 63 } 64 }); 65 66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js 67 var require_use_sync_external_store_shim_development = __commonJS({ 68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) { 69 "use strict"; 70 (function() { 71 function is(x2, y2) { 72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 73 } 74 function useSyncExternalStore$2(subscribe2, getSnapshot) { 75 didWarnOld18Alpha || void 0 === React62.startTransition || (didWarnOld18Alpha = true, console.error( 76 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release." 77 )); 78 var value = getSnapshot(); 79 if (!didWarnUncachedGetSnapshot) { 80 var cachedValue = getSnapshot(); 81 objectIs(value, cachedValue) || (console.error( 82 "The result of getSnapshot should be cached to avoid an infinite loop" 83 ), didWarnUncachedGetSnapshot = true); 84 } 85 cachedValue = useState49({ 86 inst: { value, getSnapshot } 87 }); 88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1]; 89 useLayoutEffect6( 90 function() { 91 inst.value = value; 92 inst.getSnapshot = getSnapshot; 93 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 94 }, 95 [subscribe2, value, getSnapshot] 96 ); 97 useEffect43( 98 function() { 99 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 100 return subscribe2(function() { 101 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 102 }); 103 }, 104 [subscribe2] 105 ); 106 useDebugValue2(value); 107 return value; 108 } 109 function checkIfSnapshotChanged(inst) { 110 var latestGetSnapshot = inst.getSnapshot; 111 inst = inst.value; 112 try { 113 var nextValue = latestGetSnapshot(); 114 return !objectIs(inst, nextValue); 115 } catch (error2) { 116 return true; 117 } 118 } 119 function useSyncExternalStore$1(subscribe2, getSnapshot) { 120 return getSnapshot(); 121 } 122 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 123 var React62 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState49 = React62.useState, useEffect43 = React62.useEffect, useLayoutEffect6 = React62.useLayoutEffect, useDebugValue2 = React62.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2; 124 exports.useSyncExternalStore = void 0 !== React62.useSyncExternalStore ? React62.useSyncExternalStore : shim; 125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 126 })(); 127 } 128 }); 129 130 // node_modules/use-sync-external-store/shim/index.js 131 var require_shim = __commonJS({ 132 "node_modules/use-sync-external-store/shim/index.js"(exports, module) { 133 "use strict"; 134 if (false) { 135 module.exports = null; 136 } else { 137 module.exports = require_use_sync_external_store_shim_development(); 138 } 139 } 140 }); 141 142 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js 143 var require_with_selector_development = __commonJS({ 144 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) { 145 "use strict"; 146 (function() { 147 function is(x2, y2) { 148 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 149 } 150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 151 var React62 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef55 = React62.useRef, useEffect43 = React62.useEffect, useMemo57 = React62.useMemo, useDebugValue2 = React62.useDebugValue; 152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) { 153 var instRef = useRef55(null); 154 if (null === instRef.current) { 155 var inst = { hasValue: false, value: null }; 156 instRef.current = inst; 157 } else inst = instRef.current; 158 instRef = useMemo57( 159 function() { 160 function memoizedSelector(nextSnapshot) { 161 if (!hasMemo) { 162 hasMemo = true; 163 memoizedSnapshot = nextSnapshot; 164 nextSnapshot = selector2(nextSnapshot); 165 if (void 0 !== isEqual && inst.hasValue) { 166 var currentSelection = inst.value; 167 if (isEqual(currentSelection, nextSnapshot)) 168 return memoizedSelection = currentSelection; 169 } 170 return memoizedSelection = nextSnapshot; 171 } 172 currentSelection = memoizedSelection; 173 if (objectIs(memoizedSnapshot, nextSnapshot)) 174 return currentSelection; 175 var nextSelection = selector2(nextSnapshot); 176 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) 177 return memoizedSnapshot = nextSnapshot, currentSelection; 178 memoizedSnapshot = nextSnapshot; 179 return memoizedSelection = nextSelection; 180 } 181 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot; 182 return [ 183 function() { 184 return memoizedSelector(getSnapshot()); 185 }, 186 null === maybeGetServerSnapshot ? void 0 : function() { 187 return memoizedSelector(maybeGetServerSnapshot()); 188 } 189 ]; 190 }, 191 [getSnapshot, getServerSnapshot, selector2, isEqual] 192 ); 193 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]); 194 useEffect43( 195 function() { 196 inst.hasValue = true; 197 inst.value = value; 198 }, 199 [value] 200 ); 201 useDebugValue2(value); 202 return value; 203 }; 204 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 205 })(); 206 } 207 }); 208 209 // node_modules/use-sync-external-store/shim/with-selector.js 210 var require_with_selector = __commonJS({ 211 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) { 212 "use strict"; 213 if (false) { 214 module.exports = null; 215 } else { 216 module.exports = require_with_selector_development(); 217 } 218 } 219 }); 220 221 // package-external:@wordpress/primitives 222 var require_primitives = __commonJS({ 223 "package-external:@wordpress/primitives"(exports, module) { 224 module.exports = window.wp.primitives; 225 } 226 }); 227 228 // package-external:@wordpress/compose 229 var require_compose = __commonJS({ 230 "package-external:@wordpress/compose"(exports, module) { 231 module.exports = window.wp.compose; 232 } 233 }); 234 235 // package-external:@wordpress/theme 236 var require_theme = __commonJS({ 237 "package-external:@wordpress/theme"(exports, module) { 238 module.exports = window.wp.theme; 239 } 240 }); 241 242 // package-external:@wordpress/private-apis 243 var require_private_apis = __commonJS({ 244 "package-external:@wordpress/private-apis"(exports, module) { 245 module.exports = window.wp.privateApis; 246 } 247 }); 248 249 // package-external:@wordpress/components 250 var require_components = __commonJS({ 251 "package-external:@wordpress/components"(exports, module) { 252 module.exports = window.wp.components; 253 } 254 }); 255 256 // package-external:@wordpress/keycodes 257 var require_keycodes = __commonJS({ 258 "package-external:@wordpress/keycodes"(exports, module) { 259 module.exports = window.wp.keycodes; 260 } 261 }); 262 263 // package-external:@wordpress/data 264 var require_data = __commonJS({ 265 "package-external:@wordpress/data"(exports, module) { 266 module.exports = window.wp.data; 267 } 268 }); 269 270 // node_modules/remove-accents/index.js 271 var require_remove_accents = __commonJS({ 272 "node_modules/remove-accents/index.js"(exports, module) { 273 var characterMap = { 274 "\xC0": "A", 275 "\xC1": "A", 276 "\xC2": "A", 277 "\xC3": "A", 278 "\xC4": "A", 279 "\xC5": "A", 280 "\u1EA4": "A", 281 "\u1EAE": "A", 282 "\u1EB2": "A", 283 "\u1EB4": "A", 284 "\u1EB6": "A", 285 "\xC6": "AE", 286 "\u1EA6": "A", 287 "\u1EB0": "A", 288 "\u0202": "A", 289 "\u1EA2": "A", 290 "\u1EA0": "A", 291 "\u1EA8": "A", 292 "\u1EAA": "A", 293 "\u1EAC": "A", 294 "\xC7": "C", 295 "\u1E08": "C", 296 "\xC8": "E", 297 "\xC9": "E", 298 "\xCA": "E", 299 "\xCB": "E", 300 "\u1EBE": "E", 301 "\u1E16": "E", 302 "\u1EC0": "E", 303 "\u1E14": "E", 304 "\u1E1C": "E", 305 "\u0206": "E", 306 "\u1EBA": "E", 307 "\u1EBC": "E", 308 "\u1EB8": "E", 309 "\u1EC2": "E", 310 "\u1EC4": "E", 311 "\u1EC6": "E", 312 "\xCC": "I", 313 "\xCD": "I", 314 "\xCE": "I", 315 "\xCF": "I", 316 "\u1E2E": "I", 317 "\u020A": "I", 318 "\u1EC8": "I", 319 "\u1ECA": "I", 320 "\xD0": "D", 321 "\xD1": "N", 322 "\xD2": "O", 323 "\xD3": "O", 324 "\xD4": "O", 325 "\xD5": "O", 326 "\xD6": "O", 327 "\xD8": "O", 328 "\u1ED0": "O", 329 "\u1E4C": "O", 330 "\u1E52": "O", 331 "\u020E": "O", 332 "\u1ECE": "O", 333 "\u1ECC": "O", 334 "\u1ED4": "O", 335 "\u1ED6": "O", 336 "\u1ED8": "O", 337 "\u1EDC": "O", 338 "\u1EDE": "O", 339 "\u1EE0": "O", 340 "\u1EDA": "O", 341 "\u1EE2": "O", 342 "\xD9": "U", 343 "\xDA": "U", 344 "\xDB": "U", 345 "\xDC": "U", 346 "\u1EE6": "U", 347 "\u1EE4": "U", 348 "\u1EEC": "U", 349 "\u1EEE": "U", 350 "\u1EF0": "U", 351 "\xDD": "Y", 352 "\xE0": "a", 353 "\xE1": "a", 354 "\xE2": "a", 355 "\xE3": "a", 356 "\xE4": "a", 357 "\xE5": "a", 358 "\u1EA5": "a", 359 "\u1EAF": "a", 360 "\u1EB3": "a", 361 "\u1EB5": "a", 362 "\u1EB7": "a", 363 "\xE6": "ae", 364 "\u1EA7": "a", 365 "\u1EB1": "a", 366 "\u0203": "a", 367 "\u1EA3": "a", 368 "\u1EA1": "a", 369 "\u1EA9": "a", 370 "\u1EAB": "a", 371 "\u1EAD": "a", 372 "\xE7": "c", 373 "\u1E09": "c", 374 "\xE8": "e", 375 "\xE9": "e", 376 "\xEA": "e", 377 "\xEB": "e", 378 "\u1EBF": "e", 379 "\u1E17": "e", 380 "\u1EC1": "e", 381 "\u1E15": "e", 382 "\u1E1D": "e", 383 "\u0207": "e", 384 "\u1EBB": "e", 385 "\u1EBD": "e", 386 "\u1EB9": "e", 387 "\u1EC3": "e", 388 "\u1EC5": "e", 389 "\u1EC7": "e", 390 "\xEC": "i", 391 "\xED": "i", 392 "\xEE": "i", 393 "\xEF": "i", 394 "\u1E2F": "i", 395 "\u020B": "i", 396 "\u1EC9": "i", 397 "\u1ECB": "i", 398 "\xF0": "d", 399 "\xF1": "n", 400 "\xF2": "o", 401 "\xF3": "o", 402 "\xF4": "o", 403 "\xF5": "o", 404 "\xF6": "o", 405 "\xF8": "o", 406 "\u1ED1": "o", 407 "\u1E4D": "o", 408 "\u1E53": "o", 409 "\u020F": "o", 410 "\u1ECF": "o", 411 "\u1ECD": "o", 412 "\u1ED5": "o", 413 "\u1ED7": "o", 414 "\u1ED9": "o", 415 "\u1EDD": "o", 416 "\u1EDF": "o", 417 "\u1EE1": "o", 418 "\u1EDB": "o", 419 "\u1EE3": "o", 420 "\xF9": "u", 421 "\xFA": "u", 422 "\xFB": "u", 423 "\xFC": "u", 424 "\u1EE7": "u", 425 "\u1EE5": "u", 426 "\u1EED": "u", 427 "\u1EEF": "u", 428 "\u1EF1": "u", 429 "\xFD": "y", 430 "\xFF": "y", 431 "\u0100": "A", 432 "\u0101": "a", 433 "\u0102": "A", 434 "\u0103": "a", 435 "\u0104": "A", 436 "\u0105": "a", 437 "\u0106": "C", 438 "\u0107": "c", 439 "\u0108": "C", 440 "\u0109": "c", 441 "\u010A": "C", 442 "\u010B": "c", 443 "\u010C": "C", 444 "\u010D": "c", 445 "C\u0306": "C", 446 "c\u0306": "c", 447 "\u010E": "D", 448 "\u010F": "d", 449 "\u0110": "D", 450 "\u0111": "d", 451 "\u0112": "E", 452 "\u0113": "e", 453 "\u0114": "E", 454 "\u0115": "e", 455 "\u0116": "E", 456 "\u0117": "e", 457 "\u0118": "E", 458 "\u0119": "e", 459 "\u011A": "E", 460 "\u011B": "e", 461 "\u011C": "G", 462 "\u01F4": "G", 463 "\u011D": "g", 464 "\u01F5": "g", 465 "\u011E": "G", 466 "\u011F": "g", 467 "\u0120": "G", 468 "\u0121": "g", 469 "\u0122": "G", 470 "\u0123": "g", 471 "\u0124": "H", 472 "\u0125": "h", 473 "\u0126": "H", 474 "\u0127": "h", 475 "\u1E2A": "H", 476 "\u1E2B": "h", 477 "\u0128": "I", 478 "\u0129": "i", 479 "\u012A": "I", 480 "\u012B": "i", 481 "\u012C": "I", 482 "\u012D": "i", 483 "\u012E": "I", 484 "\u012F": "i", 485 "\u0130": "I", 486 "\u0131": "i", 487 "\u0132": "IJ", 488 "\u0133": "ij", 489 "\u0134": "J", 490 "\u0135": "j", 491 "\u0136": "K", 492 "\u0137": "k", 493 "\u1E30": "K", 494 "\u1E31": "k", 495 "K\u0306": "K", 496 "k\u0306": "k", 497 "\u0139": "L", 498 "\u013A": "l", 499 "\u013B": "L", 500 "\u013C": "l", 501 "\u013D": "L", 502 "\u013E": "l", 503 "\u013F": "L", 504 "\u0140": "l", 505 "\u0141": "l", 506 "\u0142": "l", 507 "\u1E3E": "M", 508 "\u1E3F": "m", 509 "M\u0306": "M", 510 "m\u0306": "m", 511 "\u0143": "N", 512 "\u0144": "n", 513 "\u0145": "N", 514 "\u0146": "n", 515 "\u0147": "N", 516 "\u0148": "n", 517 "\u0149": "n", 518 "N\u0306": "N", 519 "n\u0306": "n", 520 "\u014C": "O", 521 "\u014D": "o", 522 "\u014E": "O", 523 "\u014F": "o", 524 "\u0150": "O", 525 "\u0151": "o", 526 "\u0152": "OE", 527 "\u0153": "oe", 528 "P\u0306": "P", 529 "p\u0306": "p", 530 "\u0154": "R", 531 "\u0155": "r", 532 "\u0156": "R", 533 "\u0157": "r", 534 "\u0158": "R", 535 "\u0159": "r", 536 "R\u0306": "R", 537 "r\u0306": "r", 538 "\u0212": "R", 539 "\u0213": "r", 540 "\u015A": "S", 541 "\u015B": "s", 542 "\u015C": "S", 543 "\u015D": "s", 544 "\u015E": "S", 545 "\u0218": "S", 546 "\u0219": "s", 547 "\u015F": "s", 548 "\u0160": "S", 549 "\u0161": "s", 550 "\u0162": "T", 551 "\u0163": "t", 552 "\u021B": "t", 553 "\u021A": "T", 554 "\u0164": "T", 555 "\u0165": "t", 556 "\u0166": "T", 557 "\u0167": "t", 558 "T\u0306": "T", 559 "t\u0306": "t", 560 "\u0168": "U", 561 "\u0169": "u", 562 "\u016A": "U", 563 "\u016B": "u", 564 "\u016C": "U", 565 "\u016D": "u", 566 "\u016E": "U", 567 "\u016F": "u", 568 "\u0170": "U", 569 "\u0171": "u", 570 "\u0172": "U", 571 "\u0173": "u", 572 "\u0216": "U", 573 "\u0217": "u", 574 "V\u0306": "V", 575 "v\u0306": "v", 576 "\u0174": "W", 577 "\u0175": "w", 578 "\u1E82": "W", 579 "\u1E83": "w", 580 "X\u0306": "X", 581 "x\u0306": "x", 582 "\u0176": "Y", 583 "\u0177": "y", 584 "\u0178": "Y", 585 "Y\u0306": "Y", 586 "y\u0306": "y", 587 "\u0179": "Z", 588 "\u017A": "z", 589 "\u017B": "Z", 590 "\u017C": "z", 591 "\u017D": "Z", 592 "\u017E": "z", 593 "\u017F": "s", 594 "\u0192": "f", 595 "\u01A0": "O", 596 "\u01A1": "o", 597 "\u01AF": "U", 598 "\u01B0": "u", 599 "\u01CD": "A", 600 "\u01CE": "a", 601 "\u01CF": "I", 602 "\u01D0": "i", 603 "\u01D1": "O", 604 "\u01D2": "o", 605 "\u01D3": "U", 606 "\u01D4": "u", 607 "\u01D5": "U", 608 "\u01D6": "u", 609 "\u01D7": "U", 610 "\u01D8": "u", 611 "\u01D9": "U", 612 "\u01DA": "u", 613 "\u01DB": "U", 614 "\u01DC": "u", 615 "\u1EE8": "U", 616 "\u1EE9": "u", 617 "\u1E78": "U", 618 "\u1E79": "u", 619 "\u01FA": "A", 620 "\u01FB": "a", 621 "\u01FC": "AE", 622 "\u01FD": "ae", 623 "\u01FE": "O", 624 "\u01FF": "o", 625 "\xDE": "TH", 626 "\xFE": "th", 627 "\u1E54": "P", 628 "\u1E55": "p", 629 "\u1E64": "S", 630 "\u1E65": "s", 631 "X\u0301": "X", 632 "x\u0301": "x", 633 "\u0403": "\u0413", 634 "\u0453": "\u0433", 635 "\u040C": "\u041A", 636 "\u045C": "\u043A", 637 "A\u030B": "A", 638 "a\u030B": "a", 639 "E\u030B": "E", 640 "e\u030B": "e", 641 "I\u030B": "I", 642 "i\u030B": "i", 643 "\u01F8": "N", 644 "\u01F9": "n", 645 "\u1ED2": "O", 646 "\u1ED3": "o", 647 "\u1E50": "O", 648 "\u1E51": "o", 649 "\u1EEA": "U", 650 "\u1EEB": "u", 651 "\u1E80": "W", 652 "\u1E81": "w", 653 "\u1EF2": "Y", 654 "\u1EF3": "y", 655 "\u0200": "A", 656 "\u0201": "a", 657 "\u0204": "E", 658 "\u0205": "e", 659 "\u0208": "I", 660 "\u0209": "i", 661 "\u020C": "O", 662 "\u020D": "o", 663 "\u0210": "R", 664 "\u0211": "r", 665 "\u0214": "U", 666 "\u0215": "u", 667 "B\u030C": "B", 668 "b\u030C": "b", 669 "\u010C\u0323": "C", 670 "\u010D\u0323": "c", 671 "\xCA\u030C": "E", 672 "\xEA\u030C": "e", 673 "F\u030C": "F", 674 "f\u030C": "f", 675 "\u01E6": "G", 676 "\u01E7": "g", 677 "\u021E": "H", 678 "\u021F": "h", 679 "J\u030C": "J", 680 "\u01F0": "j", 681 "\u01E8": "K", 682 "\u01E9": "k", 683 "M\u030C": "M", 684 "m\u030C": "m", 685 "P\u030C": "P", 686 "p\u030C": "p", 687 "Q\u030C": "Q", 688 "q\u030C": "q", 689 "\u0158\u0329": "R", 690 "\u0159\u0329": "r", 691 "\u1E66": "S", 692 "\u1E67": "s", 693 "V\u030C": "V", 694 "v\u030C": "v", 695 "W\u030C": "W", 696 "w\u030C": "w", 697 "X\u030C": "X", 698 "x\u030C": "x", 699 "Y\u030C": "Y", 700 "y\u030C": "y", 701 "A\u0327": "A", 702 "a\u0327": "a", 703 "B\u0327": "B", 704 "b\u0327": "b", 705 "\u1E10": "D", 706 "\u1E11": "d", 707 "\u0228": "E", 708 "\u0229": "e", 709 "\u0190\u0327": "E", 710 "\u025B\u0327": "e", 711 "\u1E28": "H", 712 "\u1E29": "h", 713 "I\u0327": "I", 714 "i\u0327": "i", 715 "\u0197\u0327": "I", 716 "\u0268\u0327": "i", 717 "M\u0327": "M", 718 "m\u0327": "m", 719 "O\u0327": "O", 720 "o\u0327": "o", 721 "Q\u0327": "Q", 722 "q\u0327": "q", 723 "U\u0327": "U", 724 "u\u0327": "u", 725 "X\u0327": "X", 726 "x\u0327": "x", 727 "Z\u0327": "Z", 728 "z\u0327": "z", 729 "\u0439": "\u0438", 730 "\u0419": "\u0418", 731 "\u0451": "\u0435", 732 "\u0401": "\u0415" 733 }; 734 var chars = Object.keys(characterMap).join("|"); 735 var allAccents = new RegExp(chars, "g"); 736 var firstAccent = new RegExp(chars, ""); 737 function matcher(match2) { 738 return characterMap[match2]; 739 } 740 var removeAccents3 = function(string) { 741 return string.replace(allAccents, matcher); 742 }; 743 var hasAccents = function(string) { 744 return !!string.match(firstAccent); 745 }; 746 module.exports = removeAccents3; 747 module.exports.has = hasAccents; 748 module.exports.remove = removeAccents3; 749 } 750 }); 751 752 // node_modules/fast-deep-equal/es6/index.js 753 var require_es6 = __commonJS({ 754 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 755 "use strict"; 756 module.exports = function equal(a2, b2) { 757 if (a2 === b2) return true; 758 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { 759 if (a2.constructor !== b2.constructor) return false; 760 var length, i2, keys; 761 if (Array.isArray(a2)) { 762 length = a2.length; 763 if (length != b2.length) return false; 764 for (i2 = length; i2-- !== 0; ) 765 if (!equal(a2[i2], b2[i2])) return false; 766 return true; 767 } 768 if (a2 instanceof Map && b2 instanceof Map) { 769 if (a2.size !== b2.size) return false; 770 for (i2 of a2.entries()) 771 if (!b2.has(i2[0])) return false; 772 for (i2 of a2.entries()) 773 if (!equal(i2[1], b2.get(i2[0]))) return false; 774 return true; 775 } 776 if (a2 instanceof Set && b2 instanceof Set) { 777 if (a2.size !== b2.size) return false; 778 for (i2 of a2.entries()) 779 if (!b2.has(i2[0])) return false; 780 return true; 781 } 782 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) { 783 length = a2.length; 784 if (length != b2.length) return false; 785 for (i2 = length; i2-- !== 0; ) 786 if (a2[i2] !== b2[i2]) return false; 787 return true; 788 } 789 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags; 790 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf(); 791 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); 792 keys = Object.keys(a2); 793 length = keys.length; 794 if (length !== Object.keys(b2).length) return false; 795 for (i2 = length; i2-- !== 0; ) 796 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false; 797 for (i2 = length; i2-- !== 0; ) { 798 var key = keys[i2]; 799 if (!equal(a2[key], b2[key])) return false; 800 } 801 return true; 802 } 803 return a2 !== a2 && b2 !== b2; 804 }; 805 } 806 }); 807 808 // package-external:@wordpress/date 809 var require_date = __commonJS({ 810 "package-external:@wordpress/date"(exports, module) { 811 module.exports = window.wp.date; 812 } 813 }); 814 815 // package-external:@wordpress/warning 816 var require_warning = __commonJS({ 817 "package-external:@wordpress/warning"(exports, module) { 818 module.exports = window.wp.warning; 819 } 820 }); 821 822 // node_modules/deepmerge/dist/cjs.js 823 var require_cjs = __commonJS({ 824 "node_modules/deepmerge/dist/cjs.js"(exports, module) { 825 "use strict"; 826 var isMergeableObject = function isMergeableObject2(value) { 827 return isNonNullObject(value) && !isSpecial(value); 828 }; 829 function isNonNullObject(value) { 830 return !!value && typeof value === "object"; 831 } 832 function isSpecial(value) { 833 var stringValue = Object.prototype.toString.call(value); 834 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value); 835 } 836 var canUseSymbol = typeof Symbol === "function" && Symbol.for; 837 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103; 838 function isReactElement(value) { 839 return value.$$typeof === REACT_ELEMENT_TYPE; 840 } 841 function emptyTarget(val) { 842 return Array.isArray(val) ? [] : {}; 843 } 844 function cloneUnlessOtherwiseSpecified(value, options) { 845 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value; 846 } 847 function defaultArrayMerge(target, source, options) { 848 return target.concat(source).map(function(element) { 849 return cloneUnlessOtherwiseSpecified(element, options); 850 }); 851 } 852 function getMergeFunction(key, options) { 853 if (!options.customMerge) { 854 return deepmerge; 855 } 856 var customMerge = options.customMerge(key); 857 return typeof customMerge === "function" ? customMerge : deepmerge; 858 } 859 function getEnumerableOwnPropertySymbols(target) { 860 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) { 861 return Object.propertyIsEnumerable.call(target, symbol3); 862 }) : []; 863 } 864 function getKeys2(target) { 865 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)); 866 } 867 function propertyIsOnObject(object, property) { 868 try { 869 return property in object; 870 } catch (_) { 871 return false; 872 } 873 } 874 function propertyIsUnsafe(target, key) { 875 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key)); 876 } 877 function mergeObject(target, source, options) { 878 var destination = {}; 879 if (options.isMergeableObject(target)) { 880 getKeys2(target).forEach(function(key) { 881 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); 882 }); 883 } 884 getKeys2(source).forEach(function(key) { 885 if (propertyIsUnsafe(target, key)) { 886 return; 887 } 888 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { 889 destination[key] = getMergeFunction(key, options)(target[key], source[key], options); 890 } else { 891 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); 892 } 893 }); 894 return destination; 895 } 896 function deepmerge(target, source, options) { 897 options = options || {}; 898 options.arrayMerge = options.arrayMerge || defaultArrayMerge; 899 options.isMergeableObject = options.isMergeableObject || isMergeableObject; 900 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; 901 var sourceIsArray = Array.isArray(source); 902 var targetIsArray = Array.isArray(target); 903 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; 904 if (!sourceAndTargetTypesMatch) { 905 return cloneUnlessOtherwiseSpecified(source, options); 906 } else if (sourceIsArray) { 907 return options.arrayMerge(target, source, options); 908 } else { 909 return mergeObject(target, source, options); 910 } 911 } 912 deepmerge.all = function deepmergeAll(array, options) { 913 if (!Array.isArray(array)) { 914 throw new Error("first argument should be an array"); 915 } 916 return array.reduce(function(prev, next) { 917 return deepmerge(prev, next, options); 918 }, {}); 919 }; 920 var deepmerge_1 = deepmerge; 921 module.exports = deepmerge_1; 922 } 923 }); 924 925 // package-external:@wordpress/deprecated 926 var require_deprecated = __commonJS({ 927 "package-external:@wordpress/deprecated"(exports, module) { 928 module.exports = window.wp.deprecated; 929 } 930 }); 931 932 // package-external:@wordpress/notices 933 var require_notices = __commonJS({ 934 "package-external:@wordpress/notices"(exports, module) { 935 module.exports = window.wp.notices; 936 } 937 }); 938 939 // package-external:@wordpress/api-fetch 940 var require_api_fetch = __commonJS({ 941 "package-external:@wordpress/api-fetch"(exports, module) { 942 module.exports = window.wp.apiFetch; 943 } 944 }); 945 946 // package-external:@wordpress/blob 947 var require_blob = __commonJS({ 948 "package-external:@wordpress/blob"(exports, module) { 949 module.exports = window.wp.blob; 950 } 951 }); 952 953 // package-external:@wordpress/blocks 954 var require_blocks = __commonJS({ 955 "package-external:@wordpress/blocks"(exports, module) { 956 module.exports = window.wp.blocks; 957 } 958 }); 959 960 // node_modules/clsx/dist/clsx.mjs 961 function r(e2) { 962 var t2, f2, n2 = ""; 963 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2; 964 else if ("object" == typeof e2) if (Array.isArray(e2)) { 965 var o2 = e2.length; 966 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2); 967 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2); 968 return n2; 969 } 970 function clsx() { 971 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2); 972 return n2; 973 } 974 var clsx_default = clsx; 975 976 // packages/ui/build-module/badge/badge.mjs 977 var import_element9 = __toESM(require_element(), 1); 978 979 // node_modules/@base-ui/utils/esm/useControlled.js 980 var React2 = __toESM(require_react(), 1); 981 982 // node_modules/@base-ui/utils/esm/error.js 983 var set; 984 if (true) { 985 set = /* @__PURE__ */ new Set(); 986 } 987 function error(...messages) { 988 if (true) { 989 const messageKey = messages.join(" "); 990 if (!set.has(messageKey)) { 991 set.add(messageKey); 992 console.error(`Base UI: $messageKey}`); 993 } 994 } 995 } 996 997 // node_modules/@base-ui/utils/esm/useControlled.js 998 function useControlled({ 999 controlled, 1000 default: defaultProp, 1001 name, 1002 state = "value" 1003 }) { 1004 const { 1005 current: isControlled 1006 } = React2.useRef(controlled !== void 0); 1007 const [valueState, setValue] = React2.useState(defaultProp); 1008 const value = isControlled ? controlled : valueState; 1009 if (true) { 1010 React2.useEffect(() => { 1011 if (isControlled !== (controlled !== void 0)) { 1012 error([`A component is changing the $isControlled ? "" : "un"}controlled $state} state of $name} to be $isControlled ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled $name} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join("\n")); 1013 } 1014 }, [state, name, controlled]); 1015 const { 1016 current: defaultValue2 1017 } = React2.useRef(defaultProp); 1018 React2.useEffect(() => { 1019 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) { 1020 error([`A component is changing the default $state} state of an uncontrolled $name} after being initialized. To suppress this warning opt to use a controlled $name}.`].join("\n")); 1021 } 1022 }, [defaultProp]); 1023 } 1024 const setValueIfUncontrolled = React2.useCallback((newValue) => { 1025 if (!isControlled) { 1026 setValue(newValue); 1027 } 1028 }, []); 1029 return [value, setValueIfUncontrolled]; 1030 } 1031 function serializeToDevModeString(input) { 1032 let nextId = 0; 1033 const seen = /* @__PURE__ */ new WeakMap(); 1034 try { 1035 const result = JSON.stringify(input, function replacer(key, value) { 1036 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) { 1037 return void 0; 1038 } 1039 if (typeof value === "bigint") { 1040 return `__bigint__:$value}`; 1041 } 1042 if (value !== null && typeof value === "object") { 1043 const id = seen.get(value); 1044 if (id !== void 0) { 1045 return `__object__:$id}`; 1046 } 1047 seen.set(value, nextId); 1048 nextId += 1; 1049 } 1050 return value; 1051 }); 1052 return result ?? `__top__:$typeof input}`; 1053 } catch { 1054 return "__unserializable__"; 1055 } 1056 } 1057 1058 // node_modules/@base-ui/utils/esm/useStableCallback.js 1059 var React4 = __toESM(require_react(), 1); 1060 1061 // node_modules/@base-ui/utils/esm/useRefWithInit.js 1062 var React3 = __toESM(require_react(), 1); 1063 var UNINITIALIZED = {}; 1064 function useRefWithInit(init2, initArg) { 1065 const ref = React3.useRef(UNINITIALIZED); 1066 if (ref.current === UNINITIALIZED) { 1067 ref.current = init2(initArg); 1068 } 1069 return ref; 1070 } 1071 1072 // node_modules/@base-ui/utils/esm/useStableCallback.js 1073 var useInsertionEffect = React4[`useInsertionEffect$Math.random().toFixed(1)}`.slice(0, -3)]; 1074 var useSafeInsertionEffect = ( 1075 // React 17 doesn't have useInsertionEffect. 1076 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late. 1077 useInsertionEffect !== React4.useLayoutEffect ? useInsertionEffect : (fn) => fn() 1078 ); 1079 function useStableCallback(callback) { 1080 const stable = useRefWithInit(createStableCallback).current; 1081 stable.next = callback; 1082 useSafeInsertionEffect(stable.effect); 1083 return stable.trampoline; 1084 } 1085 function createStableCallback() { 1086 const stable = { 1087 next: void 0, 1088 callback: assertNotCalled, 1089 trampoline: (...args) => stable.callback?.(...args), 1090 effect: () => { 1091 stable.callback = stable.next; 1092 } 1093 }; 1094 return stable; 1095 } 1096 function assertNotCalled() { 1097 if (true) { 1098 throw ( 1099 /* minify-error-disabled */ 1100 new Error("Base UI: Cannot call an event handler while rendering.") 1101 ); 1102 } 1103 } 1104 1105 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js 1106 var React5 = __toESM(require_react(), 1); 1107 var noop = () => { 1108 }; 1109 var useIsoLayoutEffect = typeof document !== "undefined" ? React5.useLayoutEffect : noop; 1110 1111 // node_modules/@base-ui/utils/esm/warn.js 1112 var set2; 1113 if (true) { 1114 set2 = /* @__PURE__ */ new Set(); 1115 } 1116 function warn(...messages) { 1117 if (true) { 1118 const messageKey = messages.join(" "); 1119 if (!set2.has(messageKey)) { 1120 set2.add(messageKey); 1121 console.warn(`Base UI: $messageKey}`); 1122 } 1123 } 1124 } 1125 1126 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js 1127 var React6 = __toESM(require_react(), 1); 1128 var DirectionContext = /* @__PURE__ */ React6.createContext(void 0); 1129 if (true) DirectionContext.displayName = "DirectionContext"; 1130 function useDirection() { 1131 const context = React6.useContext(DirectionContext); 1132 return context?.direction ?? "ltr"; 1133 } 1134 1135 // node_modules/@base-ui/react/esm/internals/useRenderElement.js 1136 var React9 = __toESM(require_react(), 1); 1137 1138 // node_modules/@base-ui/utils/esm/useMergedRefs.js 1139 function useMergedRefs(a2, b2, c2, d2) { 1140 const forkRef = useRefWithInit(createForkRef).current; 1141 if (didChange(forkRef, a2, b2, c2, d2)) { 1142 update(forkRef, [a2, b2, c2, d2]); 1143 } 1144 return forkRef.callback; 1145 } 1146 function useMergedRefsN(refs) { 1147 const forkRef = useRefWithInit(createForkRef).current; 1148 if (didChangeN(forkRef, refs)) { 1149 update(forkRef, refs); 1150 } 1151 return forkRef.callback; 1152 } 1153 function createForkRef() { 1154 return { 1155 callback: null, 1156 cleanup: null, 1157 refs: [] 1158 }; 1159 } 1160 function didChange(forkRef, a2, b2, c2, d2) { 1161 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2; 1162 } 1163 function didChangeN(forkRef, newRefs) { 1164 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]); 1165 } 1166 function update(forkRef, refs) { 1167 forkRef.refs = refs; 1168 if (refs.every((ref) => ref == null)) { 1169 forkRef.callback = null; 1170 return; 1171 } 1172 forkRef.callback = (instance) => { 1173 if (forkRef.cleanup) { 1174 forkRef.cleanup(); 1175 forkRef.cleanup = null; 1176 } 1177 if (instance != null) { 1178 const cleanupCallbacks = Array(refs.length).fill(null); 1179 for (let i2 = 0; i2 < refs.length; i2 += 1) { 1180 const ref = refs[i2]; 1181 if (ref == null) { 1182 continue; 1183 } 1184 switch (typeof ref) { 1185 case "function": { 1186 const refCleanup = ref(instance); 1187 if (typeof refCleanup === "function") { 1188 cleanupCallbacks[i2] = refCleanup; 1189 } 1190 break; 1191 } 1192 case "object": { 1193 ref.current = instance; 1194 break; 1195 } 1196 default: 1197 } 1198 } 1199 forkRef.cleanup = () => { 1200 for (let i2 = 0; i2 < refs.length; i2 += 1) { 1201 const ref = refs[i2]; 1202 if (ref == null) { 1203 continue; 1204 } 1205 switch (typeof ref) { 1206 case "function": { 1207 const cleanupCallback = cleanupCallbacks[i2]; 1208 if (typeof cleanupCallback === "function") { 1209 cleanupCallback(); 1210 } else { 1211 ref(null); 1212 } 1213 break; 1214 } 1215 case "object": { 1216 ref.current = null; 1217 break; 1218 } 1219 default: 1220 } 1221 } 1222 }; 1223 } 1224 }; 1225 } 1226 1227 // node_modules/@base-ui/utils/esm/getReactElementRef.js 1228 var React8 = __toESM(require_react(), 1); 1229 1230 // node_modules/@base-ui/utils/esm/reactVersion.js 1231 var React7 = __toESM(require_react(), 1); 1232 var majorVersion = parseInt(React7.version, 10); 1233 function isReactVersionAtLeast(reactVersionToCheck) { 1234 return majorVersion >= reactVersionToCheck; 1235 } 1236 1237 // node_modules/@base-ui/utils/esm/getReactElementRef.js 1238 function getReactElementRef(element) { 1239 if (!/* @__PURE__ */ React8.isValidElement(element)) { 1240 return null; 1241 } 1242 const reactElement = element; 1243 const propsWithRef = reactElement.props; 1244 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null; 1245 } 1246 1247 // node_modules/@base-ui/utils/esm/mergeObjects.js 1248 function mergeObjects(a2, b2) { 1249 if (a2 && !b2) { 1250 return a2; 1251 } 1252 if (!a2 && b2) { 1253 return b2; 1254 } 1255 if (a2 || b2) { 1256 return { 1257 ...a2, 1258 ...b2 1259 }; 1260 } 1261 return void 0; 1262 } 1263 1264 // node_modules/@base-ui/utils/esm/empty.js 1265 function NOOP() { 1266 } 1267 var EMPTY_ARRAY = Object.freeze([]); 1268 var EMPTY_OBJECT = Object.freeze({}); 1269 1270 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js 1271 function getStateAttributesProps(state, customMapping) { 1272 const props = {}; 1273 for (const key in state) { 1274 const value = state[key]; 1275 if (customMapping?.hasOwnProperty(key)) { 1276 const customProps = customMapping[key](value); 1277 if (customProps != null) { 1278 Object.assign(props, customProps); 1279 } 1280 continue; 1281 } 1282 if (value === true) { 1283 props[`data-$key.toLowerCase()}`] = ""; 1284 } else if (value) { 1285 props[`data-$key.toLowerCase()}`] = value.toString(); 1286 } 1287 } 1288 return props; 1289 } 1290 1291 // node_modules/@base-ui/react/esm/utils/resolveClassName.js 1292 function resolveClassName(className, state) { 1293 return typeof className === "function" ? className(state) : className; 1294 } 1295 1296 // node_modules/@base-ui/react/esm/utils/resolveStyle.js 1297 function resolveStyle(style, state) { 1298 return typeof style === "function" ? style(state) : style; 1299 } 1300 1301 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js 1302 var EMPTY_PROPS = {}; 1303 function mergeProps(a2, b2, c2, d2, e2) { 1304 if (!c2 && !d2 && !e2 && !a2) { 1305 return createInitialMergedProps(b2); 1306 } 1307 let merged = createInitialMergedProps(a2); 1308 if (b2) { 1309 merged = mergeInto(merged, b2); 1310 } 1311 if (c2) { 1312 merged = mergeInto(merged, c2); 1313 } 1314 if (d2) { 1315 merged = mergeInto(merged, d2); 1316 } 1317 if (e2) { 1318 merged = mergeInto(merged, e2); 1319 } 1320 return merged; 1321 } 1322 function mergePropsN(props) { 1323 if (props.length === 0) { 1324 return EMPTY_PROPS; 1325 } 1326 if (props.length === 1) { 1327 return createInitialMergedProps(props[0]); 1328 } 1329 let merged = createInitialMergedProps(props[0]); 1330 for (let i2 = 1; i2 < props.length; i2 += 1) { 1331 merged = mergeInto(merged, props[i2]); 1332 } 1333 return merged; 1334 } 1335 function createInitialMergedProps(inputProps) { 1336 if (isPropsGetter(inputProps)) { 1337 return { 1338 ...resolvePropsGetter(inputProps, EMPTY_PROPS) 1339 }; 1340 } 1341 return copyInitialProps(inputProps); 1342 } 1343 function mergeInto(merged, inputProps) { 1344 if (isPropsGetter(inputProps)) { 1345 return resolvePropsGetter(inputProps, merged); 1346 } 1347 return mutablyMergeInto(merged, inputProps); 1348 } 1349 function copyInitialProps(inputProps) { 1350 const copiedProps = { 1351 ...inputProps 1352 }; 1353 for (const propName in copiedProps) { 1354 const propValue = copiedProps[propName]; 1355 if (isEventHandler(propName, propValue)) { 1356 copiedProps[propName] = wrapEventHandler(propValue); 1357 } 1358 } 1359 return copiedProps; 1360 } 1361 function mutablyMergeInto(mergedProps, externalProps) { 1362 if (!externalProps) { 1363 return mergedProps; 1364 } 1365 for (const propName in externalProps) { 1366 const externalPropValue = externalProps[propName]; 1367 switch (propName) { 1368 case "style": { 1369 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue); 1370 break; 1371 } 1372 case "className": { 1373 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue); 1374 break; 1375 } 1376 default: { 1377 if (isEventHandler(propName, externalPropValue)) { 1378 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue); 1379 } else { 1380 mergedProps[propName] = externalPropValue; 1381 } 1382 } 1383 } 1384 } 1385 return mergedProps; 1386 } 1387 function isEventHandler(key, value) { 1388 const code0 = key.charCodeAt(0); 1389 const code1 = key.charCodeAt(1); 1390 const code2 = key.charCodeAt(2); 1391 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined"); 1392 } 1393 function isPropsGetter(inputProps) { 1394 return typeof inputProps === "function"; 1395 } 1396 function resolvePropsGetter(inputProps, previousProps) { 1397 if (isPropsGetter(inputProps)) { 1398 return inputProps(previousProps); 1399 } 1400 return inputProps ?? EMPTY_PROPS; 1401 } 1402 function mergeEventHandlers(ourHandler, theirHandler) { 1403 if (!theirHandler) { 1404 return ourHandler; 1405 } 1406 if (!ourHandler) { 1407 return wrapEventHandler(theirHandler); 1408 } 1409 return (...args) => { 1410 const event = args[0]; 1411 if (isSyntheticEvent(event)) { 1412 const baseUIEvent = event; 1413 makeEventPreventable(baseUIEvent); 1414 const result2 = theirHandler(...args); 1415 if (!baseUIEvent.baseUIHandlerPrevented) { 1416 ourHandler?.(...args); 1417 } 1418 return result2; 1419 } 1420 const result = theirHandler(...args); 1421 ourHandler?.(...args); 1422 return result; 1423 }; 1424 } 1425 function wrapEventHandler(handler) { 1426 if (!handler) { 1427 return handler; 1428 } 1429 return (...args) => { 1430 const event = args[0]; 1431 if (isSyntheticEvent(event)) { 1432 makeEventPreventable(event); 1433 } 1434 return handler(...args); 1435 }; 1436 } 1437 function makeEventPreventable(event) { 1438 event.preventBaseUIHandler = () => { 1439 event.baseUIHandlerPrevented = true; 1440 }; 1441 return event; 1442 } 1443 function mergeClassNames(ourClassName, theirClassName) { 1444 if (theirClassName) { 1445 if (ourClassName) { 1446 return theirClassName + " " + ourClassName; 1447 } 1448 return theirClassName; 1449 } 1450 return ourClassName; 1451 } 1452 function isSyntheticEvent(event) { 1453 return event != null && typeof event === "object" && "nativeEvent" in event; 1454 } 1455 1456 // node_modules/@base-ui/react/esm/internals/useRenderElement.js 1457 var import_react = __toESM(require_react(), 1); 1458 function useRenderElement(element, componentProps, params = {}) { 1459 const renderProp = componentProps.render; 1460 const outProps = useRenderElementProps(componentProps, params); 1461 if (params.enabled === false) { 1462 return null; 1463 } 1464 const state = params.state ?? EMPTY_OBJECT; 1465 return evaluateRenderProp(element, renderProp, outProps, state); 1466 } 1467 function useRenderElementProps(componentProps, params = {}) { 1468 const { 1469 className: classNameProp, 1470 style: styleProp, 1471 render: renderProp 1472 } = componentProps; 1473 const { 1474 state = EMPTY_OBJECT, 1475 ref, 1476 props, 1477 stateAttributesMapping: stateAttributesMapping4, 1478 enabled = true 1479 } = params; 1480 const className = enabled ? resolveClassName(classNameProp, state) : void 0; 1481 const style = enabled ? resolveStyle(styleProp, state) : void 0; 1482 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping4) : EMPTY_OBJECT; 1483 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0; 1484 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT; 1485 if (typeof document !== "undefined") { 1486 if (!enabled) { 1487 useMergedRefs(null, null); 1488 } else if (Array.isArray(ref)) { 1489 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]); 1490 } else { 1491 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref); 1492 } 1493 } 1494 if (!enabled) { 1495 return EMPTY_OBJECT; 1496 } 1497 if (className !== void 0) { 1498 outProps.className = mergeClassNames(outProps.className, className); 1499 } 1500 if (style !== void 0) { 1501 outProps.style = mergeObjects(outProps.style, style); 1502 } 1503 return outProps; 1504 } 1505 function resolveRenderFunctionProps(props) { 1506 if (Array.isArray(props)) { 1507 return mergePropsN(props); 1508 } 1509 return mergeProps(void 0, props); 1510 } 1511 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); 1512 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/; 1513 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/; 1514 function evaluateRenderProp(element, render4, props, state) { 1515 if (render4) { 1516 if (typeof render4 === "function") { 1517 if (true) { 1518 warnIfRenderPropLooksLikeComponent(render4); 1519 } 1520 return render4(props, state); 1521 } 1522 const mergedProps = mergeProps(props, render4.props); 1523 mergedProps.ref = props.ref; 1524 let newElement = render4; 1525 if (newElement?.$$typeof === REACT_LAZY_TYPE) { 1526 const children = React9.Children.toArray(render4); 1527 newElement = children[0]; 1528 } 1529 if (true) { 1530 if (!/* @__PURE__ */ React9.isValidElement(newElement)) { 1531 throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n")); 1532 } 1533 } 1534 return /* @__PURE__ */ React9.cloneElement(newElement, mergedProps); 1535 } 1536 if (element) { 1537 if (typeof element === "string") { 1538 return renderTag(element, props); 1539 } 1540 } 1541 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8)); 1542 } 1543 function warnIfRenderPropLooksLikeComponent(renderFn) { 1544 const functionName = renderFn.name; 1545 if (functionName.length === 0) { 1546 return; 1547 } 1548 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) { 1549 return; 1550 } 1551 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) { 1552 return; 1553 } 1554 warn(`The \`render\` prop received a function named \`$functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop"); 1555 } 1556 function renderTag(Tag, props) { 1557 if (Tag === "button") { 1558 return /* @__PURE__ */ (0, import_react.createElement)("button", { 1559 type: "button", 1560 ...props, 1561 key: props.key 1562 }); 1563 } 1564 if (Tag === "img") { 1565 return /* @__PURE__ */ (0, import_react.createElement)("img", { 1566 alt: "", 1567 ...props, 1568 key: props.key 1569 }); 1570 } 1571 return /* @__PURE__ */ React9.createElement(Tag, props); 1572 } 1573 1574 // node_modules/@base-ui/react/esm/internals/reason-parts.js 1575 var reason_parts_exports = {}; 1576 __export(reason_parts_exports, { 1577 cancelOpen: () => cancelOpen, 1578 chipRemovePress: () => chipRemovePress, 1579 clearPress: () => clearPress, 1580 closePress: () => closePress, 1581 closeWatcher: () => closeWatcher, 1582 decrementPress: () => decrementPress, 1583 disabled: () => disabled, 1584 drag: () => drag, 1585 escapeKey: () => escapeKey, 1586 focusOut: () => focusOut, 1587 imperativeAction: () => imperativeAction, 1588 incrementPress: () => incrementPress, 1589 inputBlur: () => inputBlur, 1590 inputChange: () => inputChange, 1591 inputClear: () => inputClear, 1592 inputPaste: () => inputPaste, 1593 inputPress: () => inputPress, 1594 itemPress: () => itemPress, 1595 keyboard: () => keyboard, 1596 linkPress: () => linkPress, 1597 listNavigation: () => listNavigation, 1598 none: () => none, 1599 outsidePress: () => outsidePress, 1600 pointer: () => pointer, 1601 scrub: () => scrub, 1602 siblingOpen: () => siblingOpen, 1603 swipe: () => swipe, 1604 trackPress: () => trackPress, 1605 triggerFocus: () => triggerFocus, 1606 triggerHover: () => triggerHover, 1607 triggerPress: () => triggerPress, 1608 wheel: () => wheel, 1609 windowResize: () => windowResize 1610 }); 1611 var none = "none"; 1612 var triggerPress = "trigger-press"; 1613 var triggerHover = "trigger-hover"; 1614 var triggerFocus = "trigger-focus"; 1615 var outsidePress = "outside-press"; 1616 var itemPress = "item-press"; 1617 var closePress = "close-press"; 1618 var linkPress = "link-press"; 1619 var clearPress = "clear-press"; 1620 var chipRemovePress = "chip-remove-press"; 1621 var trackPress = "track-press"; 1622 var incrementPress = "increment-press"; 1623 var decrementPress = "decrement-press"; 1624 var inputChange = "input-change"; 1625 var inputClear = "input-clear"; 1626 var inputBlur = "input-blur"; 1627 var inputPaste = "input-paste"; 1628 var inputPress = "input-press"; 1629 var focusOut = "focus-out"; 1630 var escapeKey = "escape-key"; 1631 var closeWatcher = "close-watcher"; 1632 var listNavigation = "list-navigation"; 1633 var keyboard = "keyboard"; 1634 var pointer = "pointer"; 1635 var drag = "drag"; 1636 var wheel = "wheel"; 1637 var scrub = "scrub"; 1638 var cancelOpen = "cancel-open"; 1639 var siblingOpen = "sibling-open"; 1640 var disabled = "disabled"; 1641 var imperativeAction = "imperative-action"; 1642 var swipe = "swipe"; 1643 var windowResize = "window-resize"; 1644 1645 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js 1646 function createChangeEventDetails(reason, event, trigger, customProperties) { 1647 let canceled = false; 1648 let allowPropagation = false; 1649 const custom = customProperties ?? EMPTY_OBJECT; 1650 const details = { 1651 reason, 1652 event: event ?? new Event("base-ui"), 1653 cancel() { 1654 canceled = true; 1655 }, 1656 allowPropagation() { 1657 allowPropagation = true; 1658 }, 1659 get isCanceled() { 1660 return canceled; 1661 }, 1662 get isPropagationAllowed() { 1663 return allowPropagation; 1664 }, 1665 trigger, 1666 ...custom 1667 }; 1668 return details; 1669 } 1670 1671 // node_modules/@base-ui/utils/esm/useId.js 1672 var React11 = __toESM(require_react(), 1); 1673 1674 // node_modules/@base-ui/utils/esm/safeReact.js 1675 var React10 = __toESM(require_react(), 1); 1676 var SafeReact = { 1677 ...React10 1678 }; 1679 1680 // node_modules/@base-ui/utils/esm/useId.js 1681 var globalId = 0; 1682 function useGlobalId(idOverride, prefix = "mui") { 1683 const [defaultId, setDefaultId] = React11.useState(idOverride); 1684 const id = idOverride || defaultId; 1685 React11.useEffect(() => { 1686 if (defaultId == null) { 1687 globalId += 1; 1688 setDefaultId(`$prefix}-$globalId}`); 1689 } 1690 }, [defaultId, prefix]); 1691 return id; 1692 } 1693 var maybeReactUseId = SafeReact.useId; 1694 function useId(idOverride, prefix) { 1695 if (maybeReactUseId !== void 0) { 1696 const reactId = maybeReactUseId(); 1697 return idOverride ?? (prefix ? `$prefix}-$reactId}` : reactId); 1698 } 1699 return useGlobalId(idOverride, prefix); 1700 } 1701 1702 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js 1703 function useBaseUiId(idOverride) { 1704 return useId(idOverride, "base-ui"); 1705 } 1706 1707 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js 1708 var React14 = __toESM(require_react(), 1); 1709 1710 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js 1711 var ReactDOM = __toESM(require_react_dom(), 1); 1712 1713 // node_modules/@base-ui/utils/esm/useOnMount.js 1714 var React12 = __toESM(require_react(), 1); 1715 var EMPTY = []; 1716 function useOnMount(fn) { 1717 React12.useEffect(fn, EMPTY); 1718 } 1719 1720 // node_modules/@base-ui/utils/esm/useAnimationFrame.js 1721 var EMPTY2 = null; 1722 var LAST_RAF = globalThis.requestAnimationFrame; 1723 var Scheduler = class { 1724 /* This implementation uses an array as a backing data-structure for frame callbacks. 1725 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it 1726 * never calls the native `cancelAnimationFrame` if there are no frames left. This can 1727 * be much more efficient if there is a call pattern that alterns as 1728 * "request-cancel-request-cancel-…". 1729 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation 1730 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */ 1731 callbacks = []; 1732 callbacksCount = 0; 1733 nextId = 1; 1734 startId = 1; 1735 isScheduled = false; 1736 tick = (timestamp) => { 1737 this.isScheduled = false; 1738 const currentCallbacks = this.callbacks; 1739 const currentCallbacksCount = this.callbacksCount; 1740 this.callbacks = []; 1741 this.callbacksCount = 0; 1742 this.startId = this.nextId; 1743 if (currentCallbacksCount > 0) { 1744 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) { 1745 currentCallbacks[i2]?.(timestamp); 1746 } 1747 } 1748 }; 1749 request(fn) { 1750 const id = this.nextId; 1751 this.nextId += 1; 1752 this.callbacks.push(fn); 1753 this.callbacksCount += 1; 1754 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true); 1755 if (!this.isScheduled || didRAFChange) { 1756 requestAnimationFrame(this.tick); 1757 this.isScheduled = true; 1758 } 1759 return id; 1760 } 1761 cancel(id) { 1762 const index2 = id - this.startId; 1763 if (index2 < 0 || index2 >= this.callbacks.length) { 1764 return; 1765 } 1766 this.callbacks[index2] = null; 1767 this.callbacksCount -= 1; 1768 } 1769 }; 1770 var scheduler = new Scheduler(); 1771 var AnimationFrame = class _AnimationFrame { 1772 static create() { 1773 return new _AnimationFrame(); 1774 } 1775 static request(fn) { 1776 return scheduler.request(fn); 1777 } 1778 static cancel(id) { 1779 return scheduler.cancel(id); 1780 } 1781 currentId = EMPTY2; 1782 /** 1783 * Executes `fn` after `delay`, clearing any previously scheduled call. 1784 */ 1785 request(fn) { 1786 this.cancel(); 1787 this.currentId = scheduler.request(() => { 1788 this.currentId = EMPTY2; 1789 fn(); 1790 }); 1791 } 1792 cancel = () => { 1793 if (this.currentId !== EMPTY2) { 1794 scheduler.cancel(this.currentId); 1795 this.currentId = EMPTY2; 1796 } 1797 }; 1798 disposeEffect = () => { 1799 return this.cancel; 1800 }; 1801 }; 1802 function useAnimationFrame() { 1803 const timeout = useRefWithInit(AnimationFrame.create).current; 1804 useOnMount(timeout.disposeEffect); 1805 return timeout; 1806 } 1807 1808 // node_modules/@base-ui/react/esm/utils/resolveRef.js 1809 function resolveRef(maybeRef) { 1810 if (maybeRef == null) { 1811 return maybeRef; 1812 } 1813 return "current" in maybeRef ? maybeRef.current : maybeRef; 1814 } 1815 1816 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js 1817 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) { 1818 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style"; 1819 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style"; 1820 return TransitionStatusDataAttributes2; 1821 })({}); 1822 var STARTING_HOOK = { 1823 [TransitionStatusDataAttributes.startingStyle]: "" 1824 }; 1825 var ENDING_HOOK = { 1826 [TransitionStatusDataAttributes.endingStyle]: "" 1827 }; 1828 var transitionStatusMapping = { 1829 transitionStatus(value) { 1830 if (value === "starting") { 1831 return STARTING_HOOK; 1832 } 1833 if (value === "ending") { 1834 return ENDING_HOOK; 1835 } 1836 return null; 1837 } 1838 }; 1839 1840 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js 1841 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) { 1842 const frame = useAnimationFrame(); 1843 return useStableCallback((fnToExecute, signal = null) => { 1844 frame.cancel(); 1845 const element = resolveRef(elementOrRef); 1846 if (element == null) { 1847 return; 1848 } 1849 const resolvedElement = element; 1850 const done = () => { 1851 ReactDOM.flushSync(fnToExecute); 1852 }; 1853 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) { 1854 fnToExecute(); 1855 return; 1856 } 1857 function exec() { 1858 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => { 1859 if (!signal?.aborted) { 1860 done(); 1861 } 1862 }).catch(() => { 1863 if (treatAbortedAsFinished) { 1864 if (!signal?.aborted) { 1865 done(); 1866 } 1867 return; 1868 } 1869 const currentAnimations = resolvedElement.getAnimations(); 1870 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) { 1871 exec(); 1872 } 1873 }); 1874 } 1875 if (waitForStartingStyleRemoved) { 1876 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle; 1877 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 1878 frame.request(exec); 1879 return; 1880 } 1881 const attributeObserver = new MutationObserver(() => { 1882 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 1883 attributeObserver.disconnect(); 1884 exec(); 1885 } 1886 }); 1887 attributeObserver.observe(resolvedElement, { 1888 attributes: true, 1889 attributeFilter: [startingStyleAttribute] 1890 }); 1891 signal?.addEventListener("abort", () => attributeObserver.disconnect(), { 1892 once: true 1893 }); 1894 return; 1895 } 1896 frame.request(exec); 1897 }); 1898 } 1899 1900 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js 1901 var React13 = __toESM(require_react(), 1); 1902 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) { 1903 const [transitionStatus, setTransitionStatus] = React13.useState(open && enableIdleState ? "idle" : void 0); 1904 const [mounted, setMounted] = React13.useState(open); 1905 if (open && !mounted) { 1906 setMounted(true); 1907 setTransitionStatus("starting"); 1908 } 1909 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) { 1910 setTransitionStatus("ending"); 1911 } 1912 if (!open && !mounted && transitionStatus === "ending") { 1913 setTransitionStatus(void 0); 1914 } 1915 useIsoLayoutEffect(() => { 1916 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) { 1917 const frame = AnimationFrame.request(() => { 1918 setTransitionStatus("ending"); 1919 }); 1920 return () => { 1921 AnimationFrame.cancel(frame); 1922 }; 1923 } 1924 return void 0; 1925 }, [open, mounted, transitionStatus, deferEndingState]); 1926 useIsoLayoutEffect(() => { 1927 if (!open || enableIdleState) { 1928 return void 0; 1929 } 1930 const frame = AnimationFrame.request(() => { 1931 setTransitionStatus(void 0); 1932 }); 1933 return () => { 1934 AnimationFrame.cancel(frame); 1935 }; 1936 }, [enableIdleState, open]); 1937 useIsoLayoutEffect(() => { 1938 if (!open || !enableIdleState) { 1939 return void 0; 1940 } 1941 if (open && mounted && transitionStatus !== "idle") { 1942 setTransitionStatus("starting"); 1943 } 1944 const frame = AnimationFrame.request(() => { 1945 setTransitionStatus("idle"); 1946 }); 1947 return () => { 1948 AnimationFrame.cancel(frame); 1949 }; 1950 }, [enableIdleState, open, mounted, transitionStatus]); 1951 return { 1952 mounted, 1953 setMounted, 1954 transitionStatus 1955 }; 1956 } 1957 1958 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js 1959 function useCollapsibleRoot(parameters) { 1960 const { 1961 open: openParam, 1962 defaultOpen, 1963 onOpenChange, 1964 disabled: disabled2 1965 } = parameters; 1966 const isControlled = openParam !== void 0; 1967 const [open, setOpen] = useControlled({ 1968 controlled: openParam, 1969 default: defaultOpen, 1970 name: "Collapsible", 1971 state: "open" 1972 }); 1973 const { 1974 mounted, 1975 setMounted, 1976 transitionStatus 1977 } = useTransitionStatus(open, true, true); 1978 const [visible, setVisible] = React14.useState(open); 1979 const [{ 1980 height, 1981 width 1982 }, setDimensions] = React14.useState({ 1983 height: void 0, 1984 width: void 0 1985 }); 1986 const defaultPanelId = useBaseUiId(); 1987 const [panelIdState, setPanelIdState] = React14.useState(); 1988 const panelId = panelIdState ?? defaultPanelId; 1989 const [hiddenUntilFound, setHiddenUntilFound] = React14.useState(false); 1990 const [keepMounted, setKeepMounted] = React14.useState(false); 1991 const abortControllerRef = React14.useRef(null); 1992 const animationTypeRef = React14.useRef(null); 1993 const transitionDimensionRef = React14.useRef(null); 1994 const panelRef = React14.useRef(null); 1995 const runOnceAnimationsFinish = useAnimationsFinished(panelRef, false); 1996 const handleTrigger = useStableCallback((event) => { 1997 const nextOpen = !open; 1998 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent); 1999 onOpenChange(nextOpen, eventDetails); 2000 if (eventDetails.isCanceled) { 2001 return; 2002 } 2003 const panel = panelRef.current; 2004 if (animationTypeRef.current === "css-animation" && panel != null) { 2005 panel.style.removeProperty("animation-name"); 2006 } 2007 if (!hiddenUntilFound && !keepMounted) { 2008 if (animationTypeRef.current != null && animationTypeRef.current !== "css-animation") { 2009 if (!mounted && nextOpen) { 2010 setMounted(true); 2011 } 2012 } 2013 if (animationTypeRef.current === "css-animation") { 2014 if (!visible && nextOpen) { 2015 setVisible(true); 2016 } 2017 if (!mounted && nextOpen) { 2018 setMounted(true); 2019 } 2020 } 2021 } 2022 setOpen(nextOpen); 2023 if (animationTypeRef.current === "none" && mounted && !nextOpen) { 2024 setMounted(false); 2025 } 2026 }); 2027 useIsoLayoutEffect(() => { 2028 if (isControlled && animationTypeRef.current === "none" && !open) { 2029 setMounted(false); 2030 } 2031 }, [isControlled, open, openParam, setMounted]); 2032 return React14.useMemo(() => ({ 2033 abortControllerRef, 2034 animationTypeRef, 2035 disabled: disabled2, 2036 handleTrigger, 2037 height, 2038 mounted, 2039 open, 2040 panelId, 2041 panelRef, 2042 runOnceAnimationsFinish, 2043 setDimensions, 2044 setHiddenUntilFound, 2045 setKeepMounted, 2046 setMounted, 2047 setOpen, 2048 setPanelIdState, 2049 setVisible, 2050 transitionDimensionRef, 2051 transitionStatus, 2052 visible, 2053 width 2054 }), [abortControllerRef, animationTypeRef, disabled2, handleTrigger, height, mounted, open, panelId, panelRef, runOnceAnimationsFinish, setDimensions, setHiddenUntilFound, setKeepMounted, setMounted, setOpen, setVisible, transitionDimensionRef, transitionStatus, visible, width]); 2055 } 2056 2057 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRootContext.js 2058 var React15 = __toESM(require_react(), 1); 2059 var CollapsibleRootContext = /* @__PURE__ */ React15.createContext(void 0); 2060 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext"; 2061 function useCollapsibleRootContext() { 2062 const context = React15.useContext(CollapsibleRootContext); 2063 if (context === void 0) { 2064 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15)); 2065 } 2066 return context; 2067 } 2068 2069 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelDataAttributes.js 2070 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) { 2071 CollapsiblePanelDataAttributes2["open"] = "data-open"; 2072 CollapsiblePanelDataAttributes2["closed"] = "data-closed"; 2073 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; 2074 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; 2075 return CollapsiblePanelDataAttributes2; 2076 })({}); 2077 2078 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTriggerDataAttributes.js 2079 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) { 2080 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open"; 2081 return CollapsibleTriggerDataAttributes2; 2082 })({}); 2083 2084 // node_modules/@base-ui/react/esm/utils/collapsibleOpenStateMapping.js 2085 var PANEL_OPEN_HOOK = { 2086 [CollapsiblePanelDataAttributes.open]: "" 2087 }; 2088 var PANEL_CLOSED_HOOK = { 2089 [CollapsiblePanelDataAttributes.closed]: "" 2090 }; 2091 var triggerOpenStateMapping = { 2092 open(value) { 2093 if (value) { 2094 return { 2095 [CollapsibleTriggerDataAttributes.panelOpen]: "" 2096 }; 2097 } 2098 return null; 2099 } 2100 }; 2101 var collapsibleOpenStateMapping = { 2102 open(value) { 2103 if (value) { 2104 return PANEL_OPEN_HOOK; 2105 } 2106 return PANEL_CLOSED_HOOK; 2107 } 2108 }; 2109 2110 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js 2111 var React18 = __toESM(require_react(), 1); 2112 2113 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs 2114 function hasWindow() { 2115 return typeof window !== "undefined"; 2116 } 2117 function getNodeName(node) { 2118 if (isNode(node)) { 2119 return (node.nodeName || "").toLowerCase(); 2120 } 2121 return "#document"; 2122 } 2123 function getWindow(node) { 2124 var _node$ownerDocument; 2125 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; 2126 } 2127 function getDocumentElement(node) { 2128 var _ref; 2129 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; 2130 } 2131 function isNode(value) { 2132 if (!hasWindow()) { 2133 return false; 2134 } 2135 return value instanceof Node || value instanceof getWindow(value).Node; 2136 } 2137 function isElement(value) { 2138 if (!hasWindow()) { 2139 return false; 2140 } 2141 return value instanceof Element || value instanceof getWindow(value).Element; 2142 } 2143 function isHTMLElement(value) { 2144 if (!hasWindow()) { 2145 return false; 2146 } 2147 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; 2148 } 2149 function isShadowRoot(value) { 2150 if (!hasWindow() || typeof ShadowRoot === "undefined") { 2151 return false; 2152 } 2153 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; 2154 } 2155 function isOverflowElement(element) { 2156 const { 2157 overflow, 2158 overflowX, 2159 overflowY, 2160 display 2161 } = getComputedStyle2(element); 2162 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents"; 2163 } 2164 function isTableElement(element) { 2165 return /^(table|td|th)$/.test(getNodeName(element)); 2166 } 2167 function isTopLayer(element) { 2168 try { 2169 if (element.matches(":popover-open")) { 2170 return true; 2171 } 2172 } catch (_e) { 2173 } 2174 try { 2175 return element.matches(":modal"); 2176 } catch (_e) { 2177 return false; 2178 } 2179 } 2180 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/; 2181 var containRe = /paint|layout|strict|content/; 2182 var isNotNone = (value) => !!value && value !== "none"; 2183 var isWebKitValue; 2184 function isContainingBlock(elementOrCss) { 2185 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss; 2186 return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || ""); 2187 } 2188 function getContainingBlock(element) { 2189 let currentNode = getParentNode(element); 2190 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { 2191 if (isContainingBlock(currentNode)) { 2192 return currentNode; 2193 } else if (isTopLayer(currentNode)) { 2194 return null; 2195 } 2196 currentNode = getParentNode(currentNode); 2197 } 2198 return null; 2199 } 2200 function isWebKit() { 2201 if (isWebKitValue == null) { 2202 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none"); 2203 } 2204 return isWebKitValue; 2205 } 2206 function isLastTraversableNode(node) { 2207 return /^(html|body|#document)$/.test(getNodeName(node)); 2208 } 2209 function getComputedStyle2(element) { 2210 return getWindow(element).getComputedStyle(element); 2211 } 2212 function getNodeScroll(element) { 2213 if (isElement(element)) { 2214 return { 2215 scrollLeft: element.scrollLeft, 2216 scrollTop: element.scrollTop 2217 }; 2218 } 2219 return { 2220 scrollLeft: element.scrollX, 2221 scrollTop: element.scrollY 2222 }; 2223 } 2224 function getParentNode(node) { 2225 if (getNodeName(node) === "html") { 2226 return node; 2227 } 2228 const result = ( 2229 // Step into the shadow DOM of the parent of a slotted node. 2230 node.assignedSlot || // DOM Element detected. 2231 node.parentNode || // ShadowRoot detected. 2232 isShadowRoot(node) && node.host || // Fallback. 2233 getDocumentElement(node) 2234 ); 2235 return isShadowRoot(result) ? result.host : result; 2236 } 2237 function getNearestOverflowAncestor(node) { 2238 const parentNode = getParentNode(node); 2239 if (isLastTraversableNode(parentNode)) { 2240 return node.ownerDocument ? node.ownerDocument.body : node.body; 2241 } 2242 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { 2243 return parentNode; 2244 } 2245 return getNearestOverflowAncestor(parentNode); 2246 } 2247 function getOverflowAncestors(node, list, traverseIframes) { 2248 var _node$ownerDocument2; 2249 if (list === void 0) { 2250 list = []; 2251 } 2252 if (traverseIframes === void 0) { 2253 traverseIframes = true; 2254 } 2255 const scrollableAncestor = getNearestOverflowAncestor(node); 2256 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); 2257 const win = getWindow(scrollableAncestor); 2258 if (isBody) { 2259 const frameElement = getFrameElement(win); 2260 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []); 2261 } else { 2262 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); 2263 } 2264 } 2265 function getFrameElement(win) { 2266 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null; 2267 } 2268 2269 // node_modules/@base-ui/react/esm/internals/composite/root/CompositeRootContext.js 2270 var React16 = __toESM(require_react(), 1); 2271 var CompositeRootContext = /* @__PURE__ */ React16.createContext(void 0); 2272 if (true) CompositeRootContext.displayName = "CompositeRootContext"; 2273 function useCompositeRootContext(optional = false) { 2274 const context = React16.useContext(CompositeRootContext); 2275 if (context === void 0 && !optional) { 2276 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16)); 2277 } 2278 return context; 2279 } 2280 2281 // node_modules/@base-ui/react/esm/utils/useFocusableWhenDisabled.js 2282 var React17 = __toESM(require_react(), 1); 2283 function useFocusableWhenDisabled(parameters) { 2284 const { 2285 focusableWhenDisabled, 2286 disabled: disabled2, 2287 composite = false, 2288 tabIndex: tabIndexProp = 0, 2289 isNativeButton 2290 } = parameters; 2291 const isFocusableComposite = composite && focusableWhenDisabled !== false; 2292 const isNonFocusableComposite = composite && focusableWhenDisabled === false; 2293 const props = React17.useMemo(() => { 2294 const additionalProps = { 2295 // allow Tabbing away from focusableWhenDisabled elements 2296 onKeyDown(event) { 2297 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") { 2298 event.preventDefault(); 2299 } 2300 } 2301 }; 2302 if (!composite) { 2303 additionalProps.tabIndex = tabIndexProp; 2304 if (!isNativeButton && disabled2) { 2305 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1; 2306 } 2307 } 2308 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) { 2309 additionalProps["aria-disabled"] = disabled2; 2310 } 2311 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) { 2312 additionalProps.disabled = disabled2; 2313 } 2314 return additionalProps; 2315 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]); 2316 return { 2317 props 2318 }; 2319 } 2320 2321 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js 2322 function useButton(parameters = {}) { 2323 const { 2324 disabled: disabled2 = false, 2325 focusableWhenDisabled, 2326 tabIndex = 0, 2327 native: isNativeButton = true, 2328 composite: compositeProp 2329 } = parameters; 2330 const elementRef = React18.useRef(null); 2331 const compositeRootContext = useCompositeRootContext(true); 2332 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0; 2333 const { 2334 props: focusableWhenDisabledProps 2335 } = useFocusableWhenDisabled({ 2336 focusableWhenDisabled, 2337 disabled: disabled2, 2338 composite: isCompositeItem, 2339 tabIndex, 2340 isNativeButton 2341 }); 2342 if (true) { 2343 React18.useEffect(() => { 2344 if (!elementRef.current) { 2345 return; 2346 } 2347 const isButtonTag = isButtonElement(elementRef.current); 2348 if (isNativeButton) { 2349 if (!isButtonTag) { 2350 const ownerStackMessage = SafeReact.captureOwnerStack?.() || ""; 2351 const message2 = "A component that acts as a button expected a native <button> because the `nativeButton` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the `render` prop, or set `nativeButton` to `false`."; 2352 error(`$message2}$ownerStackMessage}`); 2353 } 2354 } else if (isButtonTag) { 2355 const ownerStackMessage = SafeReact.captureOwnerStack?.() || ""; 2356 const message2 = "A component that acts as a button expected a non-<button> because the `nativeButton` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as `role` or `aria-disabled`). Use a non-<button> in the `render` prop, or set `nativeButton` to `true`."; 2357 error(`$message2}$ownerStackMessage}`); 2358 } 2359 }, [isNativeButton]); 2360 } 2361 const updateDisabled = React18.useCallback(() => { 2362 const element = elementRef.current; 2363 if (!isButtonElement(element)) { 2364 return; 2365 } 2366 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) { 2367 element.disabled = false; 2368 } 2369 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]); 2370 useIsoLayoutEffect(updateDisabled, [updateDisabled]); 2371 const getButtonProps = React18.useCallback((externalProps = {}) => { 2372 const { 2373 onClick: externalOnClick, 2374 onMouseDown: externalOnMouseDown, 2375 onKeyUp: externalOnKeyUp, 2376 onKeyDown: externalOnKeyDown, 2377 onPointerDown: externalOnPointerDown, 2378 ...otherExternalProps 2379 } = externalProps; 2380 const type = isNativeButton ? "button" : void 0; 2381 return mergeProps({ 2382 type, 2383 onClick(event) { 2384 if (disabled2) { 2385 event.preventDefault(); 2386 return; 2387 } 2388 externalOnClick?.(event); 2389 }, 2390 onMouseDown(event) { 2391 if (!disabled2) { 2392 externalOnMouseDown?.(event); 2393 } 2394 }, 2395 onKeyDown(event) { 2396 if (disabled2) { 2397 return; 2398 } 2399 makeEventPreventable(event); 2400 externalOnKeyDown?.(event); 2401 if (event.baseUIHandlerPrevented) { 2402 return; 2403 } 2404 const isCurrentTarget = event.target === event.currentTarget; 2405 const currentTarget = event.currentTarget; 2406 const isButton2 = isButtonElement(currentTarget); 2407 const isLink = !isNativeButton && isValidLinkElement(currentTarget); 2408 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink); 2409 const isEnterKey = event.key === "Enter"; 2410 const isSpaceKey = event.key === " "; 2411 const role = currentTarget.getAttribute("role"); 2412 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell"; 2413 if (isCurrentTarget && isCompositeItem && isSpaceKey) { 2414 if (event.defaultPrevented && isTextNavigationRole) { 2415 return; 2416 } 2417 event.preventDefault(); 2418 if (isLink || isNativeButton && isButton2) { 2419 currentTarget.click(); 2420 event.preventBaseUIHandler(); 2421 } else if (shouldClick) { 2422 externalOnClick?.(event); 2423 event.preventBaseUIHandler(); 2424 } 2425 return; 2426 } 2427 if (shouldClick) { 2428 if (!isNativeButton && (isSpaceKey || isEnterKey)) { 2429 event.preventDefault(); 2430 } 2431 if (!isNativeButton && isEnterKey) { 2432 externalOnClick?.(event); 2433 } 2434 } 2435 }, 2436 onKeyUp(event) { 2437 if (disabled2) { 2438 return; 2439 } 2440 makeEventPreventable(event); 2441 externalOnKeyUp?.(event); 2442 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") { 2443 event.preventDefault(); 2444 return; 2445 } 2446 if (event.baseUIHandlerPrevented) { 2447 return; 2448 } 2449 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") { 2450 externalOnClick?.(event); 2451 } 2452 }, 2453 onPointerDown(event) { 2454 if (disabled2) { 2455 event.preventDefault(); 2456 return; 2457 } 2458 externalOnPointerDown?.(event); 2459 } 2460 }, !isNativeButton ? { 2461 role: "button" 2462 } : void 0, focusableWhenDisabledProps, otherExternalProps); 2463 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]); 2464 const buttonRef = useStableCallback((element) => { 2465 elementRef.current = element; 2466 updateDisabled(); 2467 }); 2468 return { 2469 getButtonProps, 2470 buttonRef 2471 }; 2472 } 2473 function isButtonElement(elem) { 2474 return isHTMLElement(elem) && elem.tagName === "BUTTON"; 2475 } 2476 function isValidLinkElement(elem) { 2477 return Boolean(elem?.tagName === "A" && elem?.href); 2478 } 2479 2480 // node_modules/@base-ui/utils/esm/detectBrowser.js 2481 var hasNavigator = typeof navigator !== "undefined"; 2482 var nav = getNavigatorData(); 2483 var platform = getPlatform(); 2484 var userAgent = getUserAgent(); 2485 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none"); 2486 var isIOS = ( 2487 // iPads can claim to be MacIntel 2488 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform) 2489 ); 2490 var isFirefox = hasNavigator && /firefox/i.test(userAgent); 2491 var isSafari = hasNavigator && /apple/i.test(navigator.vendor); 2492 var isEdge = hasNavigator && /Edg/i.test(userAgent); 2493 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent); 2494 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints; 2495 var isJSDOM = userAgent.includes("jsdom/"); 2496 function getNavigatorData() { 2497 if (!hasNavigator) { 2498 return { 2499 platform: "", 2500 maxTouchPoints: -1 2501 }; 2502 } 2503 const uaData = navigator.userAgentData; 2504 if (uaData?.platform) { 2505 return { 2506 platform: uaData.platform, 2507 maxTouchPoints: navigator.maxTouchPoints 2508 }; 2509 } 2510 return { 2511 platform: navigator.platform ?? "", 2512 maxTouchPoints: navigator.maxTouchPoints ?? -1 2513 }; 2514 } 2515 function getUserAgent() { 2516 if (!hasNavigator) { 2517 return ""; 2518 } 2519 const uaData = navigator.userAgentData; 2520 if (uaData && Array.isArray(uaData.brands)) { 2521 return uaData.brands.map(({ 2522 brand, 2523 version: version2 2524 }) => `$brand}/$version2}`).join(" "); 2525 } 2526 return navigator.userAgent; 2527 } 2528 function getPlatform() { 2529 if (!hasNavigator) { 2530 return ""; 2531 } 2532 const uaData = navigator.userAgentData; 2533 if (uaData?.platform) { 2534 return uaData.platform; 2535 } 2536 return navigator.platform ?? ""; 2537 } 2538 2539 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js 2540 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable"; 2541 var ACTIVE_KEY = "active"; 2542 var SELECTED_KEY = "selected"; 2543 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"; 2544 2545 // node_modules/@base-ui/react/esm/internals/shadowDom.js 2546 function activeElement(doc) { 2547 let element = doc.activeElement; 2548 while (element?.shadowRoot?.activeElement != null) { 2549 element = element.shadowRoot.activeElement; 2550 } 2551 return element; 2552 } 2553 function contains(parent, child) { 2554 if (!parent || !child) { 2555 return false; 2556 } 2557 const rootNode = child.getRootNode?.(); 2558 if (parent.contains(child)) { 2559 return true; 2560 } 2561 if (rootNode && isShadowRoot(rootNode)) { 2562 let next = child; 2563 while (next) { 2564 if (parent === next) { 2565 return true; 2566 } 2567 next = next.parentNode || next.host; 2568 } 2569 } 2570 return false; 2571 } 2572 function getTarget(event) { 2573 if ("composedPath" in event) { 2574 return event.composedPath()[0]; 2575 } 2576 return event.target; 2577 } 2578 2579 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js 2580 function isTargetInsideEnabledTrigger(target, triggerElements) { 2581 if (!isElement(target)) { 2582 return false; 2583 } 2584 const targetElement = target; 2585 if (triggerElements.hasElement(targetElement)) { 2586 return !targetElement.hasAttribute("data-trigger-disabled"); 2587 } 2588 for (const [, trigger] of triggerElements.entries()) { 2589 if (contains(trigger, targetElement)) { 2590 return !trigger.hasAttribute("data-trigger-disabled"); 2591 } 2592 } 2593 return false; 2594 } 2595 function isEventTargetWithin(event, node) { 2596 if (node == null) { 2597 return false; 2598 } 2599 if ("composedPath" in event) { 2600 return event.composedPath().includes(node); 2601 } 2602 const eventAgain = event; 2603 return eventAgain.target != null && node.contains(eventAgain.target); 2604 } 2605 function isRootElement(element) { 2606 return element.matches("html,body"); 2607 } 2608 function isTypeableElement(element) { 2609 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR); 2610 } 2611 function isInteractiveElement(element) { 2612 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),$TYPEABLE_SELECTOR}`) != null; 2613 } 2614 function matchesFocusVisible(element) { 2615 if (!element || isJSDOM) { 2616 return true; 2617 } 2618 try { 2619 return element.matches(":focus-visible"); 2620 } catch (_e) { 2621 return true; 2622 } 2623 } 2624 2625 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js 2626 function getNodeChildren(nodes, id, onlyOpenChildren = true) { 2627 const directChildren = nodes.filter((node) => node.parentId === id); 2628 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]); 2629 } 2630 2631 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js 2632 function isReactEvent(event) { 2633 return "nativeEvent" in event; 2634 } 2635 function isMouseLikePointerType(pointerType, strict) { 2636 const values = ["mouse", "pen"]; 2637 if (!strict) { 2638 values.push("", void 0); 2639 } 2640 return values.includes(pointerType); 2641 } 2642 function isClickLikeEvent(event) { 2643 const type = event.type; 2644 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup"; 2645 } 2646 2647 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs 2648 var sides = ["top", "right", "bottom", "left"]; 2649 var min = Math.min; 2650 var max = Math.max; 2651 var round = Math.round; 2652 var floor = Math.floor; 2653 var createCoords = (v2) => ({ 2654 x: v2, 2655 y: v2 2656 }); 2657 var oppositeSideMap = { 2658 left: "right", 2659 right: "left", 2660 bottom: "top", 2661 top: "bottom" 2662 }; 2663 function clamp(start, value, end) { 2664 return max(start, min(value, end)); 2665 } 2666 function evaluate(value, param) { 2667 return typeof value === "function" ? value(param) : value; 2668 } 2669 function getSide(placement) { 2670 return placement.split("-")[0]; 2671 } 2672 function getAlignment(placement) { 2673 return placement.split("-")[1]; 2674 } 2675 function getOppositeAxis(axis) { 2676 return axis === "x" ? "y" : "x"; 2677 } 2678 function getAxisLength(axis) { 2679 return axis === "y" ? "height" : "width"; 2680 } 2681 function getSideAxis(placement) { 2682 const firstChar = placement[0]; 2683 return firstChar === "t" || firstChar === "b" ? "y" : "x"; 2684 } 2685 function getAlignmentAxis(placement) { 2686 return getOppositeAxis(getSideAxis(placement)); 2687 } 2688 function getAlignmentSides(placement, rects, rtl) { 2689 if (rtl === void 0) { 2690 rtl = false; 2691 } 2692 const alignment = getAlignment(placement); 2693 const alignmentAxis = getAlignmentAxis(placement); 2694 const length = getAxisLength(alignmentAxis); 2695 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; 2696 if (rects.reference[length] > rects.floating[length]) { 2697 mainAlignmentSide = getOppositePlacement(mainAlignmentSide); 2698 } 2699 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; 2700 } 2701 function getExpandedPlacements(placement) { 2702 const oppositePlacement = getOppositePlacement(placement); 2703 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; 2704 } 2705 function getOppositeAlignmentPlacement(placement) { 2706 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start"); 2707 } 2708 var lrPlacement = ["left", "right"]; 2709 var rlPlacement = ["right", "left"]; 2710 var tbPlacement = ["top", "bottom"]; 2711 var btPlacement = ["bottom", "top"]; 2712 function getSideList(side, isStart, rtl) { 2713 switch (side) { 2714 case "top": 2715 case "bottom": 2716 if (rtl) return isStart ? rlPlacement : lrPlacement; 2717 return isStart ? lrPlacement : rlPlacement; 2718 case "left": 2719 case "right": 2720 return isStart ? tbPlacement : btPlacement; 2721 default: 2722 return []; 2723 } 2724 } 2725 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { 2726 const alignment = getAlignment(placement); 2727 let list = getSideList(getSide(placement), direction === "start", rtl); 2728 if (alignment) { 2729 list = list.map((side) => side + "-" + alignment); 2730 if (flipAlignment) { 2731 list = list.concat(list.map(getOppositeAlignmentPlacement)); 2732 } 2733 } 2734 return list; 2735 } 2736 function getOppositePlacement(placement) { 2737 const side = getSide(placement); 2738 return oppositeSideMap[side] + placement.slice(side.length); 2739 } 2740 function expandPaddingObject(padding) { 2741 return { 2742 top: 0, 2743 right: 0, 2744 bottom: 0, 2745 left: 0, 2746 ...padding 2747 }; 2748 } 2749 function getPaddingObject(padding) { 2750 return typeof padding !== "number" ? expandPaddingObject(padding) : { 2751 top: padding, 2752 right: padding, 2753 bottom: padding, 2754 left: padding 2755 }; 2756 } 2757 function rectToClientRect(rect) { 2758 const { 2759 x: x2, 2760 y: y2, 2761 width, 2762 height 2763 } = rect; 2764 return { 2765 width, 2766 height, 2767 top: y2, 2768 left: x2, 2769 right: x2 + width, 2770 bottom: y2 + height, 2771 x: x2, 2772 y: y2 2773 }; 2774 } 2775 2776 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js 2777 function isHiddenByStyles(styles) { 2778 return styles.visibility === "hidden" || styles.visibility === "collapse"; 2779 } 2780 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) { 2781 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) { 2782 return false; 2783 } 2784 if (typeof element.checkVisibility === "function") { 2785 return element.checkVisibility(); 2786 } 2787 return styles.display !== "none" && styles.display !== "contents"; 2788 } 2789 2790 // node_modules/@base-ui/utils/esm/owner.js 2791 function ownerDocument(node) { 2792 return node?.ownerDocument || document; 2793 } 2794 2795 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js 2796 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]'; 2797 function getParentElement(element) { 2798 const assignedSlot = element.assignedSlot; 2799 if (assignedSlot) { 2800 return assignedSlot; 2801 } 2802 if (element.parentElement) { 2803 return element.parentElement; 2804 } 2805 const rootNode = element.getRootNode(); 2806 return isShadowRoot(rootNode) ? rootNode.host : null; 2807 } 2808 function getDetailsSummary(details) { 2809 for (const child of Array.from(details.children)) { 2810 if (getNodeName(child) === "summary") { 2811 return child; 2812 } 2813 } 2814 return null; 2815 } 2816 function isWithinOpenDetailsSummary(element, details) { 2817 const summary = getDetailsSummary(details); 2818 return !!summary && (element === summary || contains(summary, element)); 2819 } 2820 function isFocusableCandidate(element) { 2821 const nodeName = element ? getNodeName(element) : ""; 2822 return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && getNodeName(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden"); 2823 } 2824 function isFocusableElement(element) { 2825 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) { 2826 return false; 2827 } 2828 for (let current = element; current; current = getParentElement(current)) { 2829 const isAncestor = current !== element; 2830 const isSlot = getNodeName(current) === "slot"; 2831 if (current.hasAttribute("inert")) { 2832 return false; 2833 } 2834 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) { 2835 return false; 2836 } 2837 } 2838 return true; 2839 } 2840 function isVisibleInTabbableTree(element, isAncestor) { 2841 const styles = getComputedStyle2(element); 2842 if (!isAncestor) { 2843 return isElementVisible(element, styles); 2844 } 2845 return styles.display !== "none"; 2846 } 2847 function getTabIndex(element) { 2848 const tabIndex = element.tabIndex; 2849 if (tabIndex < 0) { 2850 const nodeName = getNodeName(element); 2851 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) { 2852 return 0; 2853 } 2854 } 2855 return tabIndex; 2856 } 2857 function getNamedRadioInput(element) { 2858 if (getNodeName(element) !== "input") { 2859 return null; 2860 } 2861 const input = element; 2862 return input.type === "radio" && input.name !== "" ? input : null; 2863 } 2864 function isTabbableRadio(element, candidates) { 2865 const input = getNamedRadioInput(element); 2866 if (!input) { 2867 return true; 2868 } 2869 const checkedRadio = candidates.find((candidate) => { 2870 const radio = getNamedRadioInput(candidate); 2871 return radio?.name === input.name && radio.form === input.form && radio.checked; 2872 }); 2873 if (checkedRadio) { 2874 return checkedRadio === input; 2875 } 2876 return candidates.find((candidate) => { 2877 const radio = getNamedRadioInput(candidate); 2878 return radio?.name === input.name && radio.form === input.form; 2879 }) === input; 2880 } 2881 function getComposedChildren(container) { 2882 if (isHTMLElement(container) && getNodeName(container) === "slot") { 2883 const assignedElements = container.assignedElements({ 2884 flatten: true 2885 }); 2886 if (assignedElements.length > 0) { 2887 return assignedElements; 2888 } 2889 } 2890 if (isHTMLElement(container) && container.shadowRoot) { 2891 return Array.from(container.shadowRoot.children); 2892 } 2893 return Array.from(container.children); 2894 } 2895 function appendCandidates(container, list) { 2896 getComposedChildren(container).forEach((child) => { 2897 if (isFocusableCandidate(child)) { 2898 list.push(child); 2899 } 2900 appendCandidates(child, list); 2901 }); 2902 } 2903 function appendMatchingElements(container, selector2, list) { 2904 getComposedChildren(container).forEach((child) => { 2905 if (isHTMLElement(child) && child.matches(selector2)) { 2906 list.push(child); 2907 } 2908 appendMatchingElements(child, selector2, list); 2909 }); 2910 } 2911 function focusable(container) { 2912 const candidates = []; 2913 appendCandidates(container, candidates); 2914 return candidates.filter(isFocusableElement); 2915 } 2916 function tabbable(container) { 2917 const candidates = focusable(container); 2918 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates)); 2919 } 2920 function getTabbableIn(container, dir) { 2921 const list = tabbable(container); 2922 const len = list.length; 2923 if (len === 0) { 2924 return void 0; 2925 } 2926 const active = activeElement(ownerDocument(container)); 2927 const index2 = list.indexOf(active); 2928 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir; 2929 return list[nextIndex]; 2930 } 2931 function getNextTabbable(referenceElement) { 2932 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement; 2933 } 2934 function getPreviousTabbable(referenceElement) { 2935 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement; 2936 } 2937 function isOutsideEvent(event, container) { 2938 const containerElement = container || event.currentTarget; 2939 const relatedTarget = event.relatedTarget; 2940 return !relatedTarget || !contains(containerElement, relatedTarget); 2941 } 2942 function disableFocusInside(container) { 2943 const tabbableElements = tabbable(container); 2944 tabbableElements.forEach((element) => { 2945 element.dataset.tabindex = element.getAttribute("tabindex") || ""; 2946 element.setAttribute("tabindex", "-1"); 2947 }); 2948 } 2949 function enableFocusInside(container) { 2950 const elements = []; 2951 appendMatchingElements(container, "[data-tabindex]", elements); 2952 elements.forEach((element) => { 2953 const tabindex = element.dataset.tabindex; 2954 delete element.dataset.tabindex; 2955 if (tabindex) { 2956 element.setAttribute("tabindex", tabindex); 2957 } else { 2958 element.removeAttribute("tabindex"); 2959 } 2960 }); 2961 } 2962 2963 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js 2964 var React19 = __toESM(require_react(), 1); 2965 2966 // node_modules/@base-ui/utils/esm/addEventListener.js 2967 function addEventListener(target, type, listener, options) { 2968 target.addEventListener(type, listener, options); 2969 return () => { 2970 target.removeEventListener(type, listener, options); 2971 }; 2972 } 2973 2974 // node_modules/@base-ui/react/esm/accordion/root/AccordionRootDataAttributes.js 2975 var AccordionRootDataAttributes = /* @__PURE__ */ (function(AccordionRootDataAttributes2) { 2976 AccordionRootDataAttributes2["disabled"] = "data-disabled"; 2977 AccordionRootDataAttributes2["orientation"] = "data-orientation"; 2978 return AccordionRootDataAttributes2; 2979 })({}); 2980 2981 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js 2982 function useCollapsiblePanel(parameters) { 2983 const { 2984 abortControllerRef, 2985 animationTypeRef, 2986 externalRef, 2987 height, 2988 hiddenUntilFound, 2989 keepMounted, 2990 id: idParam, 2991 mounted, 2992 onOpenChange, 2993 open, 2994 panelRef, 2995 runOnceAnimationsFinish, 2996 setDimensions, 2997 setMounted, 2998 setOpen, 2999 setVisible, 3000 transitionDimensionRef, 3001 visible, 3002 width 3003 } = parameters; 3004 const isBeforeMatchRef = React19.useRef(false); 3005 const latestAnimationNameRef = React19.useRef(null); 3006 const shouldCancelInitialOpenAnimationRef = React19.useRef(open); 3007 const shouldCancelInitialOpenTransitionRef = React19.useRef(open); 3008 const endingStyleFrame = useAnimationFrame(); 3009 const hidden = React19.useMemo(() => { 3010 if (animationTypeRef.current === "css-animation") { 3011 return !visible; 3012 } 3013 return !open && !mounted; 3014 }, [open, mounted, visible, animationTypeRef]); 3015 const handlePanelRef = useStableCallback((element) => { 3016 if (!element) { 3017 return void 0; 3018 } 3019 if (animationTypeRef.current == null || transitionDimensionRef.current == null) { 3020 const panelStyles = getComputedStyle(element); 3021 const hasAnimation = panelStyles.animationName !== "none" && panelStyles.animationName !== ""; 3022 const hasTransition = panelStyles.transitionDuration !== "0s" && panelStyles.transitionDuration !== ""; 3023 if (hasAnimation && hasTransition) { 3024 if (true) { 3025 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used."); 3026 } 3027 } else if (panelStyles.animationName === "none" && panelStyles.transitionDuration !== "0s") { 3028 animationTypeRef.current = "css-transition"; 3029 } else if (panelStyles.animationName !== "none" && panelStyles.transitionDuration === "0s") { 3030 animationTypeRef.current = "css-animation"; 3031 } else { 3032 animationTypeRef.current = "none"; 3033 } 3034 if (element.getAttribute(AccordionRootDataAttributes.orientation) === "horizontal" || panelStyles.transitionProperty.indexOf("width") > -1) { 3035 transitionDimensionRef.current = "width"; 3036 } else { 3037 transitionDimensionRef.current = "height"; 3038 } 3039 } 3040 if (animationTypeRef.current !== "css-transition") { 3041 return void 0; 3042 } 3043 if (height === void 0 || width === void 0) { 3044 setDimensions({ 3045 height: element.scrollHeight, 3046 width: element.scrollWidth 3047 }); 3048 if (shouldCancelInitialOpenTransitionRef.current) { 3049 element.style.setProperty("transition-duration", "0s"); 3050 } 3051 } 3052 let frame = -1; 3053 let nextFrame = -1; 3054 frame = AnimationFrame.request(() => { 3055 shouldCancelInitialOpenTransitionRef.current = false; 3056 nextFrame = AnimationFrame.request(() => { 3057 setTimeout(() => { 3058 element.style.removeProperty("transition-duration"); 3059 }); 3060 }); 3061 }); 3062 return () => { 3063 AnimationFrame.cancel(frame); 3064 AnimationFrame.cancel(nextFrame); 3065 }; 3066 }); 3067 const mergedPanelRef = useMergedRefs(externalRef, panelRef, handlePanelRef); 3068 useIsoLayoutEffect(() => { 3069 if (animationTypeRef.current !== "css-transition") { 3070 return void 0; 3071 } 3072 const panel = panelRef.current; 3073 if (!panel) { 3074 return void 0; 3075 } 3076 let resizeFrame = -1; 3077 if (abortControllerRef.current != null) { 3078 abortControllerRef.current.abort(); 3079 abortControllerRef.current = null; 3080 } 3081 if (open) { 3082 const originalLayoutStyles = { 3083 "justify-content": panel.style.justifyContent, 3084 "align-items": panel.style.alignItems, 3085 "align-content": panel.style.alignContent, 3086 "justify-items": panel.style.justifyItems 3087 }; 3088 Object.keys(originalLayoutStyles).forEach((key) => { 3089 panel.style.setProperty(key, "initial", "important"); 3090 }); 3091 if (!shouldCancelInitialOpenTransitionRef.current && !keepMounted) { 3092 panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, ""); 3093 } 3094 setDimensions({ 3095 height: panel.scrollHeight, 3096 width: panel.scrollWidth 3097 }); 3098 resizeFrame = AnimationFrame.request(() => { 3099 Object.entries(originalLayoutStyles).forEach(([key, value]) => { 3100 if (value === "") { 3101 panel.style.removeProperty(key); 3102 } else { 3103 panel.style.setProperty(key, value); 3104 } 3105 }); 3106 }); 3107 } else { 3108 if (panel.scrollHeight === 0 && panel.scrollWidth === 0) { 3109 return void 0; 3110 } 3111 setDimensions({ 3112 height: panel.scrollHeight, 3113 width: panel.scrollWidth 3114 }); 3115 const abortController = new AbortController(); 3116 abortControllerRef.current = abortController; 3117 const signal = abortController.signal; 3118 let attributeObserver = null; 3119 const endingStyleAttribute = CollapsiblePanelDataAttributes.endingStyle; 3120 attributeObserver = new MutationObserver((mutationList) => { 3121 const hasEndingStyle = mutationList.some((mutation) => mutation.type === "attributes" && mutation.attributeName === endingStyleAttribute); 3122 if (hasEndingStyle) { 3123 attributeObserver?.disconnect(); 3124 attributeObserver = null; 3125 runOnceAnimationsFinish(() => { 3126 setDimensions({ 3127 height: 0, 3128 width: 0 3129 }); 3130 panel.style.removeProperty("content-visibility"); 3131 setMounted(false); 3132 if (abortControllerRef.current === abortController) { 3133 abortControllerRef.current = null; 3134 } 3135 }, signal); 3136 } 3137 }); 3138 attributeObserver.observe(panel, { 3139 attributes: true, 3140 attributeFilter: [endingStyleAttribute] 3141 }); 3142 return () => { 3143 attributeObserver?.disconnect(); 3144 endingStyleFrame.cancel(); 3145 if (abortControllerRef.current === abortController) { 3146 abortController.abort(); 3147 abortControllerRef.current = null; 3148 } 3149 }; 3150 } 3151 return () => { 3152 AnimationFrame.cancel(resizeFrame); 3153 }; 3154 }, [abortControllerRef, animationTypeRef, endingStyleFrame, hiddenUntilFound, keepMounted, mounted, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted]); 3155 useIsoLayoutEffect(() => { 3156 if (animationTypeRef.current !== "css-animation") { 3157 return; 3158 } 3159 const panel = panelRef.current; 3160 if (!panel) { 3161 return; 3162 } 3163 latestAnimationNameRef.current = panel.style.animationName || latestAnimationNameRef.current; 3164 panel.style.setProperty("animation-name", "none"); 3165 setDimensions({ 3166 height: panel.scrollHeight, 3167 width: panel.scrollWidth 3168 }); 3169 if (!shouldCancelInitialOpenAnimationRef.current && !isBeforeMatchRef.current) { 3170 panel.style.removeProperty("animation-name"); 3171 } 3172 if (open) { 3173 if (abortControllerRef.current != null) { 3174 abortControllerRef.current.abort(); 3175 abortControllerRef.current = null; 3176 } 3177 setMounted(true); 3178 setVisible(true); 3179 } else { 3180 abortControllerRef.current = new AbortController(); 3181 runOnceAnimationsFinish(() => { 3182 setMounted(false); 3183 setVisible(false); 3184 abortControllerRef.current = null; 3185 }, abortControllerRef.current.signal); 3186 } 3187 }, [abortControllerRef, animationTypeRef, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted, setVisible, visible]); 3188 useOnMount(() => { 3189 const frame = AnimationFrame.request(() => { 3190 shouldCancelInitialOpenAnimationRef.current = false; 3191 }); 3192 return () => AnimationFrame.cancel(frame); 3193 }); 3194 useIsoLayoutEffect(() => { 3195 if (!hiddenUntilFound) { 3196 return void 0; 3197 } 3198 const panel = panelRef.current; 3199 if (!panel) { 3200 return void 0; 3201 } 3202 let frame = -1; 3203 let nextFrame = -1; 3204 if (open && isBeforeMatchRef.current) { 3205 panel.style.transitionDuration = "0s"; 3206 setDimensions({ 3207 height: panel.scrollHeight, 3208 width: panel.scrollWidth 3209 }); 3210 frame = AnimationFrame.request(() => { 3211 isBeforeMatchRef.current = false; 3212 nextFrame = AnimationFrame.request(() => { 3213 setTimeout(() => { 3214 panel.style.removeProperty("transition-duration"); 3215 }); 3216 }); 3217 }); 3218 } 3219 return () => { 3220 AnimationFrame.cancel(frame); 3221 AnimationFrame.cancel(nextFrame); 3222 }; 3223 }, [hiddenUntilFound, open, panelRef, setDimensions]); 3224 useIsoLayoutEffect(() => { 3225 const panel = panelRef.current; 3226 if (panel && hiddenUntilFound && hidden) { 3227 panel.setAttribute("hidden", "until-found"); 3228 if (animationTypeRef.current === "css-transition") { 3229 panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, ""); 3230 } 3231 } 3232 }, [hiddenUntilFound, hidden, animationTypeRef, panelRef]); 3233 React19.useEffect(function registerBeforeMatchListener() { 3234 const panel = panelRef.current; 3235 if (!panel) { 3236 return void 0; 3237 } 3238 function handleBeforeMatch(event) { 3239 isBeforeMatchRef.current = true; 3240 setOpen(true); 3241 onOpenChange(true, createChangeEventDetails(reason_parts_exports.none, event)); 3242 } 3243 return addEventListener(panel, "beforematch", handleBeforeMatch); 3244 }, [onOpenChange, panelRef, setOpen]); 3245 return React19.useMemo(() => ({ 3246 props: { 3247 hidden, 3248 id: idParam, 3249 ref: mergedPanelRef 3250 } 3251 }), [hidden, idParam, mergedPanelRef]); 3252 } 3253 3254 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js 3255 var React20 = __toESM(require_react(), 1); 3256 function useOpenChangeComplete(parameters) { 3257 const { 3258 enabled = true, 3259 open, 3260 ref, 3261 onComplete: onCompleteParam 3262 } = parameters; 3263 const onComplete = useStableCallback(onCompleteParam); 3264 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false); 3265 React20.useEffect(() => { 3266 if (!enabled) { 3267 return void 0; 3268 } 3269 const abortController = new AbortController(); 3270 runOnceAnimationsFinish(onComplete, abortController.signal); 3271 return () => { 3272 abortController.abort(); 3273 }; 3274 }, [enabled, open, onComplete, runOnceAnimationsFinish]); 3275 } 3276 3277 // node_modules/@base-ui/utils/esm/useOnFirstRender.js 3278 var React21 = __toESM(require_react(), 1); 3279 function useOnFirstRender(fn) { 3280 const ref = React21.useRef(true); 3281 if (ref.current) { 3282 ref.current = false; 3283 fn(); 3284 } 3285 } 3286 3287 // node_modules/@base-ui/utils/esm/useTimeout.js 3288 var EMPTY3 = 0; 3289 var Timeout = class _Timeout { 3290 static create() { 3291 return new _Timeout(); 3292 } 3293 currentId = EMPTY3; 3294 /** 3295 * Executes `fn` after `delay`, clearing any previously scheduled call. 3296 */ 3297 start(delay, fn) { 3298 this.clear(); 3299 this.currentId = setTimeout(() => { 3300 this.currentId = EMPTY3; 3301 fn(); 3302 }, delay); 3303 } 3304 isStarted() { 3305 return this.currentId !== EMPTY3; 3306 } 3307 clear = () => { 3308 if (this.currentId !== EMPTY3) { 3309 clearTimeout(this.currentId); 3310 this.currentId = EMPTY3; 3311 } 3312 }; 3313 disposeEffect = () => { 3314 return this.clear; 3315 }; 3316 }; 3317 function useTimeout() { 3318 const timeout = useRefWithInit(Timeout.create).current; 3319 useOnMount(timeout.disposeEffect); 3320 return timeout; 3321 } 3322 3323 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js 3324 var React22 = __toESM(require_react(), 1); 3325 3326 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js 3327 function resolveValue(value, pointerType) { 3328 if (pointerType != null && !isMouseLikePointerType(pointerType)) { 3329 return 0; 3330 } 3331 if (typeof value === "function") { 3332 return value(); 3333 } 3334 return value; 3335 } 3336 function getDelay(value, prop, pointerType) { 3337 const result = resolveValue(value, pointerType); 3338 if (typeof result === "number") { 3339 return result; 3340 } 3341 return result?.[prop]; 3342 } 3343 function getRestMs(value) { 3344 if (typeof value === "function") { 3345 return value(); 3346 } 3347 return value; 3348 } 3349 function isClickLikeOpenEvent(openEventType, interactedInside) { 3350 return interactedInside || openEventType === "click" || openEventType === "mousedown"; 3351 } 3352 3353 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js 3354 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 3355 var FloatingDelayGroupContext = /* @__PURE__ */ React22.createContext({ 3356 hasProvider: false, 3357 timeoutMs: 0, 3358 delayRef: { 3359 current: 0 3360 }, 3361 initialDelayRef: { 3362 current: 0 3363 }, 3364 timeout: new Timeout(), 3365 currentIdRef: { 3366 current: null 3367 }, 3368 currentContextRef: { 3369 current: null 3370 } 3371 }); 3372 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext"; 3373 function FloatingDelayGroup(props) { 3374 const { 3375 children, 3376 delay, 3377 timeoutMs = 0 3378 } = props; 3379 const delayRef = React22.useRef(delay); 3380 const initialDelayRef = React22.useRef(delay); 3381 const currentIdRef = React22.useRef(null); 3382 const currentContextRef = React22.useRef(null); 3383 const timeout = useTimeout(); 3384 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, { 3385 value: React22.useMemo(() => ({ 3386 hasProvider: true, 3387 delayRef, 3388 initialDelayRef, 3389 currentIdRef, 3390 timeoutMs, 3391 currentContextRef, 3392 timeout 3393 }), [timeoutMs, timeout]), 3394 children 3395 }); 3396 } 3397 function useDelayGroup(context, options = { 3398 open: false 3399 }) { 3400 const store2 = "rootStore" in context ? context.rootStore : context; 3401 const floatingId = store2.useState("floatingId"); 3402 const { 3403 open 3404 } = options; 3405 const groupContext = React22.useContext(FloatingDelayGroupContext); 3406 const { 3407 currentIdRef, 3408 delayRef, 3409 timeoutMs, 3410 initialDelayRef, 3411 currentContextRef, 3412 hasProvider, 3413 timeout 3414 } = groupContext; 3415 const [isInstantPhase, setIsInstantPhase] = React22.useState(false); 3416 useIsoLayoutEffect(() => { 3417 function unset() { 3418 setIsInstantPhase(false); 3419 currentContextRef.current?.setIsInstantPhase(false); 3420 currentIdRef.current = null; 3421 currentContextRef.current = null; 3422 delayRef.current = initialDelayRef.current; 3423 } 3424 if (!currentIdRef.current) { 3425 return void 0; 3426 } 3427 if (!open && currentIdRef.current === floatingId) { 3428 setIsInstantPhase(false); 3429 if (timeoutMs) { 3430 const closingId = floatingId; 3431 timeout.start(timeoutMs, () => { 3432 if (store2.select("open") || currentIdRef.current && currentIdRef.current !== closingId) { 3433 return; 3434 } 3435 unset(); 3436 }); 3437 return () => { 3438 timeout.clear(); 3439 }; 3440 } 3441 unset(); 3442 } 3443 return void 0; 3444 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store2]); 3445 useIsoLayoutEffect(() => { 3446 if (!open) { 3447 return; 3448 } 3449 const prevContext = currentContextRef.current; 3450 const prevId = currentIdRef.current; 3451 timeout.clear(); 3452 currentContextRef.current = { 3453 onOpenChange: store2.setOpen, 3454 setIsInstantPhase 3455 }; 3456 currentIdRef.current = floatingId; 3457 delayRef.current = { 3458 open: 0, 3459 close: getDelay(initialDelayRef.current, "close") 3460 }; 3461 if (prevId !== null && prevId !== floatingId) { 3462 setIsInstantPhase(true); 3463 prevContext?.setIsInstantPhase(true); 3464 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none)); 3465 } else { 3466 setIsInstantPhase(false); 3467 prevContext?.setIsInstantPhase(false); 3468 } 3469 }, [open, floatingId, store2, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]); 3470 useIsoLayoutEffect(() => { 3471 return () => { 3472 currentContextRef.current = null; 3473 }; 3474 }, [currentContextRef]); 3475 return React22.useMemo(() => ({ 3476 hasProvider, 3477 delayRef, 3478 isInstantPhase 3479 }), [hasProvider, delayRef, isInstantPhase]); 3480 } 3481 3482 // node_modules/@base-ui/utils/esm/mergeCleanups.js 3483 function mergeCleanups(...cleanups) { 3484 return () => { 3485 for (let i2 = 0; i2 < cleanups.length; i2 += 1) { 3486 const cleanup = cleanups[i2]; 3487 if (cleanup) { 3488 cleanup(); 3489 } 3490 } 3491 }; 3492 } 3493 3494 // node_modules/@base-ui/utils/esm/useValueAsRef.js 3495 function useValueAsRef(value) { 3496 const latest = useRefWithInit(createLatestRef, value).current; 3497 latest.next = value; 3498 useIsoLayoutEffect(latest.effect); 3499 return latest; 3500 } 3501 function createLatestRef(value) { 3502 const latest = { 3503 current: value, 3504 next: value, 3505 effect: () => { 3506 latest.current = latest.next; 3507 } 3508 }; 3509 return latest; 3510 } 3511 3512 // node_modules/@base-ui/react/esm/utils/FocusGuard.js 3513 var React23 = __toESM(require_react(), 1); 3514 3515 // node_modules/@base-ui/utils/esm/visuallyHidden.js 3516 var visuallyHiddenBase = { 3517 clipPath: "inset(50%)", 3518 overflow: "hidden", 3519 whiteSpace: "nowrap", 3520 border: 0, 3521 padding: 0, 3522 width: 1, 3523 height: 1, 3524 margin: -1 3525 }; 3526 var visuallyHidden = { 3527 ...visuallyHiddenBase, 3528 position: "fixed", 3529 top: 0, 3530 left: 0 3531 }; 3532 var visuallyHiddenInput = { 3533 ...visuallyHiddenBase, 3534 position: "absolute" 3535 }; 3536 3537 // node_modules/@base-ui/react/esm/utils/FocusGuard.js 3538 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 3539 var FocusGuard = /* @__PURE__ */ React23.forwardRef(function FocusGuard2(props, ref) { 3540 const [role, setRole] = React23.useState(); 3541 useIsoLayoutEffect(() => { 3542 if (isSafari) { 3543 setRole("button"); 3544 } 3545 }, []); 3546 const restProps = { 3547 tabIndex: 0, 3548 // Role is only for VoiceOver 3549 role 3550 }; 3551 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { 3552 ...props, 3553 ref, 3554 style: visuallyHidden, 3555 "aria-hidden": role ? void 0 : true, 3556 ...restProps, 3557 "data-base-ui-focus-guard": "" 3558 }); 3559 }); 3560 if (true) FocusGuard.displayName = "FocusGuard"; 3561 3562 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js 3563 function createAttribute(name) { 3564 return `data-base-ui-$name}`; 3565 } 3566 3567 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js 3568 var React24 = __toESM(require_react(), 1); 3569 var ReactDOM2 = __toESM(require_react_dom(), 1); 3570 3571 // node_modules/@base-ui/react/esm/internals/constants.js 3572 var DISABLED_TRANSITIONS_STYLE = { 3573 style: { 3574 transition: "none" 3575 } 3576 }; 3577 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore"; 3578 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore"; 3579 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[$BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`; 3580 var LEGACY_SWIPE_IGNORE_SELECTOR = `[$LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`; 3581 var POPUP_COLLISION_AVOIDANCE = { 3582 fallbackAxisSide: "end" 3583 }; 3584 var ownerVisuallyHidden = { 3585 clipPath: "inset(50%)", 3586 position: "fixed", 3587 top: 0, 3588 left: 0 3589 }; 3590 3591 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js 3592 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 3593 var PortalContext = /* @__PURE__ */ React24.createContext(null); 3594 if (true) PortalContext.displayName = "PortalContext"; 3595 var usePortalContext = () => React24.useContext(PortalContext); 3596 var attr = createAttribute("portal"); 3597 function useFloatingPortalNode(props = {}) { 3598 const { 3599 ref, 3600 container: containerProp, 3601 componentProps = EMPTY_OBJECT, 3602 elementProps 3603 } = props; 3604 const uniqueId = useId(); 3605 const portalContext = usePortalContext(); 3606 const parentPortalNode = portalContext?.portalNode; 3607 const [containerElement, setContainerElement] = React24.useState(null); 3608 const [portalNode, setPortalNode] = React24.useState(null); 3609 const setPortalNodeRef = useStableCallback((node) => { 3610 if (node !== null) { 3611 setPortalNode(node); 3612 } 3613 }); 3614 const containerRef = React24.useRef(null); 3615 useIsoLayoutEffect(() => { 3616 if (containerProp === null) { 3617 if (containerRef.current) { 3618 containerRef.current = null; 3619 setPortalNode(null); 3620 setContainerElement(null); 3621 } 3622 return; 3623 } 3624 if (uniqueId == null) { 3625 return; 3626 } 3627 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body; 3628 if (resolvedContainer == null) { 3629 if (containerRef.current) { 3630 containerRef.current = null; 3631 setPortalNode(null); 3632 setContainerElement(null); 3633 } 3634 return; 3635 } 3636 if (containerRef.current !== resolvedContainer) { 3637 containerRef.current = resolvedContainer; 3638 setPortalNode(null); 3639 setContainerElement(resolvedContainer); 3640 } 3641 }, [containerProp, parentPortalNode, uniqueId]); 3642 const portalElement = useRenderElement("div", componentProps, { 3643 ref: [ref, setPortalNodeRef], 3644 props: [{ 3645 id: uniqueId, 3646 [attr]: "" 3647 }, elementProps] 3648 }); 3649 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null; 3650 return { 3651 portalNode, 3652 portalSubtree 3653 }; 3654 } 3655 var FloatingPortal = /* @__PURE__ */ React24.forwardRef(function FloatingPortal2(componentProps, forwardedRef) { 3656 const { 3657 children, 3658 container, 3659 className, 3660 render: render4, 3661 renderGuards, 3662 style, 3663 ...elementProps 3664 } = componentProps; 3665 const { 3666 portalNode, 3667 portalSubtree 3668 } = useFloatingPortalNode({ 3669 container, 3670 ref: forwardedRef, 3671 componentProps, 3672 elementProps 3673 }); 3674 const beforeOutsideRef = React24.useRef(null); 3675 const afterOutsideRef = React24.useRef(null); 3676 const beforeInsideRef = React24.useRef(null); 3677 const afterInsideRef = React24.useRef(null); 3678 const [focusManagerState, setFocusManagerState] = React24.useState(null); 3679 const focusInsideDisabledRef = React24.useRef(false); 3680 const modal = focusManagerState?.modal; 3681 const open = focusManagerState?.open; 3682 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode; 3683 React24.useEffect(() => { 3684 if (!portalNode || modal) { 3685 return void 0; 3686 } 3687 function onFocus(event) { 3688 if (portalNode && event.relatedTarget && isOutsideEvent(event)) { 3689 if (event.type === "focusin") { 3690 if (focusInsideDisabledRef.current) { 3691 enableFocusInside(portalNode); 3692 focusInsideDisabledRef.current = false; 3693 } 3694 } else { 3695 disableFocusInside(portalNode); 3696 focusInsideDisabledRef.current = true; 3697 } 3698 } 3699 } 3700 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true)); 3701 }, [portalNode, modal]); 3702 React24.useEffect(() => { 3703 if (!portalNode || open !== false) { 3704 return; 3705 } 3706 enableFocusInside(portalNode); 3707 focusInsideDisabledRef.current = false; 3708 }, [open, portalNode]); 3709 const portalContextValue = React24.useMemo(() => ({ 3710 beforeOutsideRef, 3711 afterOutsideRef, 3712 beforeInsideRef, 3713 afterInsideRef, 3714 portalNode, 3715 setFocusManagerState 3716 }), [portalNode]); 3717 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React24.Fragment, { 3718 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, { 3719 value: portalContextValue, 3720 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { 3721 "data-type": "outside", 3722 ref: beforeOutsideRef, 3723 onFocus: (event) => { 3724 if (isOutsideEvent(event, portalNode)) { 3725 beforeInsideRef.current?.focus(); 3726 } else { 3727 const domReference = focusManagerState ? focusManagerState.domReference : null; 3728 const prevTabbable = getPreviousTabbable(domReference); 3729 prevTabbable?.focus(); 3730 } 3731 } 3732 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { 3733 "aria-owns": portalNode.id, 3734 style: ownerVisuallyHidden 3735 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { 3736 "data-type": "outside", 3737 ref: afterOutsideRef, 3738 onFocus: (event) => { 3739 if (isOutsideEvent(event, portalNode)) { 3740 afterInsideRef.current?.focus(); 3741 } else { 3742 const domReference = focusManagerState ? focusManagerState.domReference : null; 3743 const nextTabbable = getNextTabbable(domReference); 3744 nextTabbable?.focus(); 3745 if (focusManagerState?.closeOnFocusOut) { 3746 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent)); 3747 } 3748 } 3749 } 3750 })] 3751 })] 3752 }); 3753 }); 3754 if (true) FloatingPortal.displayName = "FloatingPortal"; 3755 3756 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js 3757 var React25 = __toESM(require_react(), 1); 3758 3759 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js 3760 function createEventEmitter() { 3761 const map = /* @__PURE__ */ new Map(); 3762 return { 3763 emit(event, data) { 3764 map.get(event)?.forEach((listener) => listener(data)); 3765 }, 3766 on(event, listener) { 3767 if (!map.has(event)) { 3768 map.set(event, /* @__PURE__ */ new Set()); 3769 } 3770 map.get(event).add(listener); 3771 }, 3772 off(event, listener) { 3773 map.get(event)?.delete(listener); 3774 } 3775 }; 3776 } 3777 3778 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js 3779 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); 3780 var FloatingNodeContext = /* @__PURE__ */ React25.createContext(null); 3781 if (true) FloatingNodeContext.displayName = "FloatingNodeContext"; 3782 var FloatingTreeContext = /* @__PURE__ */ React25.createContext(null); 3783 if (true) FloatingTreeContext.displayName = "FloatingTreeContext"; 3784 var useFloatingParentNodeId = () => React25.useContext(FloatingNodeContext)?.id || null; 3785 var useFloatingTree = (externalTree) => { 3786 const contextTree = React25.useContext(FloatingTreeContext); 3787 return externalTree ?? contextTree; 3788 }; 3789 3790 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js 3791 var React26 = __toESM(require_react(), 1); 3792 function createVirtualElement(domElement, data) { 3793 let offsetX = null; 3794 let offsetY = null; 3795 let isAutoUpdateEvent = false; 3796 return { 3797 contextElement: domElement || void 0, 3798 getBoundingClientRect() { 3799 const domRect = domElement?.getBoundingClientRect() || { 3800 width: 0, 3801 height: 0, 3802 x: 0, 3803 y: 0 3804 }; 3805 const isXAxis = data.axis === "x" || data.axis === "both"; 3806 const isYAxis = data.axis === "y" || data.axis === "both"; 3807 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch"; 3808 let width = domRect.width; 3809 let height = domRect.height; 3810 let x2 = domRect.x; 3811 let y2 = domRect.y; 3812 if (offsetX == null && data.x && isXAxis) { 3813 offsetX = domRect.x - data.x; 3814 } 3815 if (offsetY == null && data.y && isYAxis) { 3816 offsetY = domRect.y - data.y; 3817 } 3818 x2 -= offsetX || 0; 3819 y2 -= offsetY || 0; 3820 width = 0; 3821 height = 0; 3822 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) { 3823 width = data.axis === "y" ? domRect.width : 0; 3824 height = data.axis === "x" ? domRect.height : 0; 3825 x2 = isXAxis && data.x != null ? data.x : x2; 3826 y2 = isYAxis && data.y != null ? data.y : y2; 3827 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) { 3828 height = data.axis === "x" ? domRect.height : height; 3829 width = data.axis === "y" ? domRect.width : width; 3830 } 3831 isAutoUpdateEvent = true; 3832 return { 3833 width, 3834 height, 3835 x: x2, 3836 y: y2, 3837 top: y2, 3838 right: x2 + width, 3839 bottom: y2 + height, 3840 left: x2 3841 }; 3842 } 3843 }; 3844 } 3845 function isMouseBasedEvent(event) { 3846 return event != null && event.clientX != null; 3847 } 3848 function useClientPoint(context, props = {}) { 3849 const store2 = "rootStore" in context ? context.rootStore : context; 3850 const open = store2.useState("open"); 3851 const floating = store2.useState("floatingElement"); 3852 const domReference = store2.useState("domReferenceElement"); 3853 const dataRef = store2.context.dataRef; 3854 const { 3855 enabled = true, 3856 axis = "both" 3857 } = props; 3858 const initialRef = React26.useRef(false); 3859 const cleanupListenerRef = React26.useRef(null); 3860 const [pointerType, setPointerType] = React26.useState(); 3861 const [reactive, setReactive] = React26.useState([]); 3862 const setReference = useStableCallback((newX, newY, referenceElement) => { 3863 if (initialRef.current) { 3864 return; 3865 } 3866 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) { 3867 return; 3868 } 3869 store2.set("positionReference", createVirtualElement(referenceElement ?? domReference, { 3870 x: newX, 3871 y: newY, 3872 axis, 3873 dataRef, 3874 pointerType 3875 })); 3876 }); 3877 const handleReferenceEnterOrMove = useStableCallback((event) => { 3878 if (!open) { 3879 setReference(event.clientX, event.clientY, event.currentTarget); 3880 } else if (!cleanupListenerRef.current) { 3881 setReactive([]); 3882 } 3883 }); 3884 const openCheck = isMouseLikePointerType(pointerType) ? floating : open; 3885 const addListener = React26.useCallback(() => { 3886 if (!openCheck || !enabled) { 3887 return void 0; 3888 } 3889 const win = getWindow(floating); 3890 function handleMouseMove(event) { 3891 const target = getTarget(event); 3892 if (!contains(floating, target)) { 3893 setReference(event.clientX, event.clientY); 3894 } else { 3895 cleanupListenerRef.current?.(); 3896 cleanupListenerRef.current = null; 3897 } 3898 } 3899 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) { 3900 const cleanup = () => { 3901 cleanupListenerRef.current?.(); 3902 cleanupListenerRef.current = null; 3903 }; 3904 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove); 3905 return cleanup; 3906 } 3907 store2.set("positionReference", domReference); 3908 return void 0; 3909 }, [openCheck, enabled, floating, dataRef, domReference, store2, setReference]); 3910 React26.useEffect(() => { 3911 return addListener(); 3912 }, [addListener, reactive]); 3913 React26.useEffect(() => { 3914 if (enabled && !floating) { 3915 initialRef.current = false; 3916 } 3917 }, [enabled, floating]); 3918 React26.useEffect(() => { 3919 if (!enabled && open) { 3920 initialRef.current = true; 3921 } 3922 }, [enabled, open]); 3923 const reference = React26.useMemo(() => { 3924 function setPointerTypeRef(event) { 3925 setPointerType(event.pointerType); 3926 } 3927 return { 3928 onPointerDown: setPointerTypeRef, 3929 onPointerEnter: setPointerTypeRef, 3930 onMouseMove: handleReferenceEnterOrMove, 3931 onMouseEnter: handleReferenceEnterOrMove 3932 }; 3933 }, [handleReferenceEnterOrMove]); 3934 return React26.useMemo(() => enabled ? { 3935 reference, 3936 trigger: reference 3937 } : {}, [enabled, reference]); 3938 } 3939 3940 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js 3941 var React27 = __toESM(require_react(), 1); 3942 var bubbleHandlerKeys = { 3943 intentional: "onClick", 3944 sloppy: "onPointerDown" 3945 }; 3946 function alwaysFalse() { 3947 return false; 3948 } 3949 function normalizeProp(normalizable) { 3950 return { 3951 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false, 3952 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true 3953 }; 3954 } 3955 function useDismiss(context, props = {}) { 3956 const store2 = "rootStore" in context ? context.rootStore : context; 3957 const open = store2.useState("open"); 3958 const floatingElement = store2.useState("floatingElement"); 3959 const { 3960 dataRef 3961 } = store2.context; 3962 const { 3963 enabled = true, 3964 escapeKey: escapeKey2 = true, 3965 outsidePress: outsidePressProp = true, 3966 outsidePressEvent = "sloppy", 3967 referencePress = alwaysFalse, 3968 referencePressEvent = "sloppy", 3969 bubbles, 3970 externalTree 3971 } = props; 3972 const tree = useFloatingTree(externalTree); 3973 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false); 3974 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp; 3975 const outsidePressEnabled = outsidePress2 !== false; 3976 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent); 3977 const pressStartedInsideRef = React27.useRef(false); 3978 const pressStartPreventedRef = React27.useRef(false); 3979 const suppressNextOutsideClickRef = React27.useRef(false); 3980 const { 3981 escapeKey: escapeKeyBubbles, 3982 outsidePress: outsidePressBubbles 3983 } = normalizeProp(bubbles); 3984 const touchStateRef = React27.useRef(null); 3985 const cancelDismissOnEndTimeout = useTimeout(); 3986 const clearInsideReactTreeTimeout = useTimeout(); 3987 const clearInsideReactTree = useStableCallback(() => { 3988 clearInsideReactTreeTimeout.clear(); 3989 dataRef.current.insideReactTree = false; 3990 }); 3991 const isComposingRef = React27.useRef(false); 3992 const currentPointerTypeRef = React27.useRef(""); 3993 const isReferencePressEnabled = useStableCallback(referencePress); 3994 const closeOnEscapeKeyDown = useStableCallback((event) => { 3995 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") { 3996 return; 3997 } 3998 if (isComposingRef.current) { 3999 return; 4000 } 4001 const nodeId = dataRef.current.floatingContext?.nodeId; 4002 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : []; 4003 if (!escapeKeyBubbles) { 4004 if (children.length > 0) { 4005 let shouldDismiss = true; 4006 children.forEach((child) => { 4007 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) { 4008 shouldDismiss = false; 4009 } 4010 }); 4011 if (!shouldDismiss) { 4012 return; 4013 } 4014 } 4015 } 4016 const native = isReactEvent(event) ? event.nativeEvent : event; 4017 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native); 4018 store2.setOpen(false, eventDetails); 4019 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) { 4020 event.stopPropagation(); 4021 } 4022 }); 4023 const markInsideReactTree = useStableCallback(() => { 4024 dataRef.current.insideReactTree = true; 4025 clearInsideReactTreeTimeout.start(0, clearInsideReactTree); 4026 }); 4027 React27.useEffect(() => { 4028 if (!open || !enabled) { 4029 return void 0; 4030 } 4031 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles; 4032 dataRef.current.__outsidePressBubbles = outsidePressBubbles; 4033 const compositionTimeout = new Timeout(); 4034 const preventedPressSuppressionTimeout = new Timeout(); 4035 function handleCompositionStart() { 4036 compositionTimeout.clear(); 4037 isComposingRef.current = true; 4038 } 4039 function handleCompositionEnd() { 4040 compositionTimeout.start( 4041 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work. 4042 // Only apply to WebKit for the test to remain 0ms. 4043 isWebKit() ? 5 : 0, 4044 () => { 4045 isComposingRef.current = false; 4046 } 4047 ); 4048 } 4049 function suppressImmediateOutsideClickAfterPreventedStart() { 4050 suppressNextOutsideClickRef.current = true; 4051 preventedPressSuppressionTimeout.start(0, () => { 4052 suppressNextOutsideClickRef.current = false; 4053 }); 4054 } 4055 function resetPressStartState() { 4056 pressStartedInsideRef.current = false; 4057 pressStartPreventedRef.current = false; 4058 } 4059 function getOutsidePressEvent() { 4060 const type = currentPointerTypeRef.current; 4061 const computedType = type === "pen" || !type ? "mouse" : type; 4062 const outsidePressEventValue = getOutsidePressEventProp(); 4063 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue; 4064 if (typeof resolved === "string") { 4065 return resolved; 4066 } 4067 return resolved[computedType]; 4068 } 4069 function shouldIgnoreEvent(event) { 4070 const computedOutsidePressEvent = getOutsidePressEvent(); 4071 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click"; 4072 } 4073 function isEventWithinFloatingTree(event) { 4074 const nodeId = dataRef.current.floatingContext?.nodeId; 4075 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating)); 4076 return isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement")) || targetIsInsideChildren; 4077 } 4078 function closeOnPressOutside(event) { 4079 if (shouldIgnoreEvent(event)) { 4080 clearInsideReactTree(); 4081 return; 4082 } 4083 if (dataRef.current.insideReactTree) { 4084 clearInsideReactTree(); 4085 return; 4086 } 4087 const target = getTarget(event); 4088 const inertSelector = `[$createAttribute("inert")}]`; 4089 const targetRoot = isElement(target) ? target.getRootNode() : null; 4090 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store2.select("floatingElement"))).querySelectorAll(inertSelector)); 4091 const triggers = store2.context.triggerElements; 4092 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) { 4093 return; 4094 } 4095 let targetRootAncestor = isElement(target) ? target : null; 4096 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) { 4097 const nextParent = getParentNode(targetRootAncestor); 4098 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) { 4099 break; 4100 } 4101 targetRootAncestor = nextParent; 4102 } 4103 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay). 4104 !contains(target, store2.select("floatingElement")) && // If the target root element contains none of the markers, then the 4105 // element was injected after the floating element rendered. 4106 markers.every((marker) => !contains(targetRootAncestor, marker))) { 4107 return; 4108 } 4109 if (isHTMLElement(target) && !("touches" in event)) { 4110 const lastTraversableNode = isLastTraversableNode(target); 4111 const style = getComputedStyle2(target); 4112 const scrollRe = /auto|scroll/; 4113 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX); 4114 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY); 4115 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth; 4116 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight; 4117 const isRTL8 = style.direction === "rtl"; 4118 const pressedVerticalScrollbar = canScrollY && (isRTL8 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth); 4119 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight; 4120 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) { 4121 return; 4122 } 4123 } 4124 if (isEventWithinFloatingTree(event)) { 4125 return; 4126 } 4127 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) { 4128 preventedPressSuppressionTimeout.clear(); 4129 suppressNextOutsideClickRef.current = false; 4130 return; 4131 } 4132 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 4133 return; 4134 } 4135 const nodeId = dataRef.current.floatingContext?.nodeId; 4136 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : []; 4137 if (children.length > 0) { 4138 let shouldDismiss = true; 4139 children.forEach((child) => { 4140 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) { 4141 shouldDismiss = false; 4142 } 4143 }); 4144 if (!shouldDismiss) { 4145 return; 4146 } 4147 } 4148 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event)); 4149 clearInsideReactTree(); 4150 } 4151 function handlePointerDown(event) { 4152 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store2.select("open") || !enabled || isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"))) { 4153 return; 4154 } 4155 closeOnPressOutside(event); 4156 } 4157 function handleTouchStart(event) { 4158 if (getOutsidePressEvent() !== "sloppy" || !store2.select("open") || !enabled || isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"))) { 4159 return; 4160 } 4161 const touch = event.touches[0]; 4162 if (touch) { 4163 touchStateRef.current = { 4164 startTime: Date.now(), 4165 startX: touch.clientX, 4166 startY: touch.clientY, 4167 dismissOnTouchEnd: false, 4168 dismissOnMouseDown: true 4169 }; 4170 cancelDismissOnEndTimeout.start(1e3, () => { 4171 if (touchStateRef.current) { 4172 touchStateRef.current.dismissOnTouchEnd = false; 4173 touchStateRef.current.dismissOnMouseDown = false; 4174 } 4175 }); 4176 } 4177 } 4178 function addTargetEventListenerOnce(event, listener) { 4179 const target = getTarget(event); 4180 if (!target) { 4181 return; 4182 } 4183 const unsubscribe2 = addEventListener(target, event.type, () => { 4184 listener(event); 4185 unsubscribe2(); 4186 }); 4187 } 4188 function handleTouchStartCapture(event) { 4189 currentPointerTypeRef.current = "touch"; 4190 addTargetEventListenerOnce(event, handleTouchStart); 4191 } 4192 function closeOnPressOutsideCapture(event) { 4193 cancelDismissOnEndTimeout.clear(); 4194 if (event.type === "pointerdown") { 4195 currentPointerTypeRef.current = event.pointerType; 4196 } 4197 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) { 4198 return; 4199 } 4200 addTargetEventListenerOnce(event, (targetEvent) => { 4201 if (targetEvent.type === "pointerdown") { 4202 handlePointerDown(targetEvent); 4203 } else { 4204 closeOnPressOutside(targetEvent); 4205 } 4206 }); 4207 } 4208 function handlePressEndCapture(event) { 4209 if (!pressStartedInsideRef.current) { 4210 return; 4211 } 4212 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current; 4213 resetPressStartState(); 4214 if (getOutsidePressEvent() !== "intentional") { 4215 return; 4216 } 4217 if (event.type === "pointercancel") { 4218 if (pressStartedInsideDefaultPrevented) { 4219 suppressImmediateOutsideClickAfterPreventedStart(); 4220 } 4221 return; 4222 } 4223 if (isEventWithinFloatingTree(event)) { 4224 return; 4225 } 4226 if (pressStartedInsideDefaultPrevented) { 4227 suppressImmediateOutsideClickAfterPreventedStart(); 4228 return; 4229 } 4230 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 4231 return; 4232 } 4233 preventedPressSuppressionTimeout.clear(); 4234 suppressNextOutsideClickRef.current = true; 4235 clearInsideReactTree(); 4236 } 4237 function handleTouchMove(event) { 4238 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"))) { 4239 return; 4240 } 4241 const touch = event.touches[0]; 4242 if (!touch) { 4243 return; 4244 } 4245 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX); 4246 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY); 4247 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); 4248 if (distance > 5) { 4249 touchStateRef.current.dismissOnTouchEnd = true; 4250 } 4251 if (distance > 10) { 4252 closeOnPressOutside(event); 4253 cancelDismissOnEndTimeout.clear(); 4254 touchStateRef.current = null; 4255 } 4256 } 4257 function handleTouchMoveCapture(event) { 4258 addTargetEventListenerOnce(event, handleTouchMove); 4259 } 4260 function handleTouchEnd(event) { 4261 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"))) { 4262 return; 4263 } 4264 if (touchStateRef.current.dismissOnTouchEnd) { 4265 closeOnPressOutside(event); 4266 } 4267 cancelDismissOnEndTimeout.clear(); 4268 touchStateRef.current = null; 4269 } 4270 function handleTouchEndCapture(event) { 4271 addTargetEventListenerOnce(event, handleTouchEnd); 4272 } 4273 const doc = ownerDocument(floatingElement); 4274 const unsubscribe = mergeCleanups(escapeKey2 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, true), addEventListener(doc, "touchmove", handleTouchMoveCapture, true), addEventListener(doc, "touchend", handleTouchEndCapture, true))); 4275 return () => { 4276 unsubscribe(); 4277 compositionTimeout.clear(); 4278 preventedPressSuppressionTimeout.clear(); 4279 resetPressStartState(); 4280 suppressNextOutsideClickRef.current = false; 4281 }; 4282 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store2, cancelDismissOnEndTimeout]); 4283 React27.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]); 4284 const reference = React27.useMemo(() => ({ 4285 onKeyDown: closeOnEscapeKeyDown, 4286 [bubbleHandlerKeys[referencePressEvent]]: (event) => { 4287 if (!isReferencePressEnabled()) { 4288 return; 4289 } 4290 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent)); 4291 }, 4292 ...referencePressEvent !== "intentional" && { 4293 onClick(event) { 4294 if (!isReferencePressEnabled()) { 4295 return; 4296 } 4297 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent)); 4298 } 4299 } 4300 }), [closeOnEscapeKeyDown, store2, referencePressEvent, isReferencePressEnabled]); 4301 const markPressStartedInsideReactTree = useStableCallback((event) => { 4302 if (!open || !enabled || event.button !== 0) { 4303 return; 4304 } 4305 const target = getTarget(event.nativeEvent); 4306 if (!contains(store2.select("floatingElement"), target)) { 4307 return; 4308 } 4309 if (!pressStartedInsideRef.current) { 4310 pressStartedInsideRef.current = true; 4311 pressStartPreventedRef.current = false; 4312 } 4313 }); 4314 const markInsidePressStartPrevented = useStableCallback((event) => { 4315 if (!open || !enabled) { 4316 return; 4317 } 4318 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) { 4319 return; 4320 } 4321 if (pressStartedInsideRef.current) { 4322 pressStartPreventedRef.current = true; 4323 } 4324 }); 4325 const floating = React27.useMemo(() => ({ 4326 onKeyDown: closeOnEscapeKeyDown, 4327 // `onMouseDown` may be blocked if `event.preventDefault()` is called in 4328 // `onPointerDown`, such as with <NumberField.ScrubArea>. 4329 // See https://github.com/mui/base-ui/pull/3379 4330 onPointerDown: markInsidePressStartPrevented, 4331 onMouseDown: markInsidePressStartPrevented, 4332 onClickCapture: markInsideReactTree, 4333 onMouseDownCapture(event) { 4334 markInsideReactTree(); 4335 markPressStartedInsideReactTree(event); 4336 }, 4337 onPointerDownCapture(event) { 4338 markInsideReactTree(); 4339 markPressStartedInsideReactTree(event); 4340 }, 4341 onMouseUpCapture: markInsideReactTree, 4342 onTouchEndCapture: markInsideReactTree, 4343 onTouchMoveCapture: markInsideReactTree 4344 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]); 4345 return React27.useMemo(() => enabled ? { 4346 reference, 4347 floating, 4348 trigger: reference 4349 } : {}, [enabled, reference, floating]); 4350 } 4351 4352 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js 4353 var React33 = __toESM(require_react(), 1); 4354 4355 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs 4356 function computeCoordsFromPlacement(_ref, placement, rtl) { 4357 let { 4358 reference, 4359 floating 4360 } = _ref; 4361 const sideAxis = getSideAxis(placement); 4362 const alignmentAxis = getAlignmentAxis(placement); 4363 const alignLength = getAxisLength(alignmentAxis); 4364 const side = getSide(placement); 4365 const isVertical = sideAxis === "y"; 4366 const commonX = reference.x + reference.width / 2 - floating.width / 2; 4367 const commonY = reference.y + reference.height / 2 - floating.height / 2; 4368 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; 4369 let coords; 4370 switch (side) { 4371 case "top": 4372 coords = { 4373 x: commonX, 4374 y: reference.y - floating.height 4375 }; 4376 break; 4377 case "bottom": 4378 coords = { 4379 x: commonX, 4380 y: reference.y + reference.height 4381 }; 4382 break; 4383 case "right": 4384 coords = { 4385 x: reference.x + reference.width, 4386 y: commonY 4387 }; 4388 break; 4389 case "left": 4390 coords = { 4391 x: reference.x - floating.width, 4392 y: commonY 4393 }; 4394 break; 4395 default: 4396 coords = { 4397 x: reference.x, 4398 y: reference.y 4399 }; 4400 } 4401 switch (getAlignment(placement)) { 4402 case "start": 4403 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); 4404 break; 4405 case "end": 4406 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); 4407 break; 4408 } 4409 return coords; 4410 } 4411 async function detectOverflow(state, options) { 4412 var _await$platform$isEle; 4413 if (options === void 0) { 4414 options = {}; 4415 } 4416 const { 4417 x: x2, 4418 y: y2, 4419 platform: platform3, 4420 rects, 4421 elements, 4422 strategy 4423 } = state; 4424 const { 4425 boundary = "clippingAncestors", 4426 rootBoundary = "viewport", 4427 elementContext = "floating", 4428 altBoundary = false, 4429 padding = 0 4430 } = evaluate(options, state); 4431 const paddingObject = getPaddingObject(padding); 4432 const altContext = elementContext === "floating" ? "reference" : "floating"; 4433 const element = elements[altBoundary ? altContext : elementContext]; 4434 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({ 4435 element: ((_await$platform$isEle = await (platform3.isElement == null ? void 0 : platform3.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform3.getDocumentElement == null ? void 0 : platform3.getDocumentElement(elements.floating)), 4436 boundary, 4437 rootBoundary, 4438 strategy 4439 })); 4440 const rect = elementContext === "floating" ? { 4441 x: x2, 4442 y: y2, 4443 width: rects.floating.width, 4444 height: rects.floating.height 4445 } : rects.reference; 4446 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating)); 4447 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || { 4448 x: 1, 4449 y: 1 4450 } : { 4451 x: 1, 4452 y: 1 4453 }; 4454 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({ 4455 elements, 4456 rect, 4457 offsetParent, 4458 strategy 4459 }) : rect); 4460 return { 4461 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, 4462 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, 4463 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, 4464 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x 4465 }; 4466 } 4467 var MAX_RESET_COUNT = 50; 4468 var computePosition = async (reference, floating, config) => { 4469 const { 4470 placement = "bottom", 4471 strategy = "absolute", 4472 middleware = [], 4473 platform: platform3 4474 } = config; 4475 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : { 4476 ...platform3, 4477 detectOverflow 4478 }; 4479 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating)); 4480 let rects = await platform3.getElementRects({ 4481 reference, 4482 floating, 4483 strategy 4484 }); 4485 let { 4486 x: x2, 4487 y: y2 4488 } = computeCoordsFromPlacement(rects, placement, rtl); 4489 let statefulPlacement = placement; 4490 let resetCount = 0; 4491 const middlewareData = {}; 4492 for (let i2 = 0; i2 < middleware.length; i2++) { 4493 const currentMiddleware = middleware[i2]; 4494 if (!currentMiddleware) { 4495 continue; 4496 } 4497 const { 4498 name, 4499 fn 4500 } = currentMiddleware; 4501 const { 4502 x: nextX, 4503 y: nextY, 4504 data, 4505 reset 4506 } = await fn({ 4507 x: x2, 4508 y: y2, 4509 initialPlacement: placement, 4510 placement: statefulPlacement, 4511 strategy, 4512 middlewareData, 4513 rects, 4514 platform: platformWithDetectOverflow, 4515 elements: { 4516 reference, 4517 floating 4518 } 4519 }); 4520 x2 = nextX != null ? nextX : x2; 4521 y2 = nextY != null ? nextY : y2; 4522 middlewareData[name] = { 4523 ...middlewareData[name], 4524 ...data 4525 }; 4526 if (reset && resetCount < MAX_RESET_COUNT) { 4527 resetCount++; 4528 if (typeof reset === "object") { 4529 if (reset.placement) { 4530 statefulPlacement = reset.placement; 4531 } 4532 if (reset.rects) { 4533 rects = reset.rects === true ? await platform3.getElementRects({ 4534 reference, 4535 floating, 4536 strategy 4537 }) : reset.rects; 4538 } 4539 ({ 4540 x: x2, 4541 y: y2 4542 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); 4543 } 4544 i2 = -1; 4545 } 4546 } 4547 return { 4548 x: x2, 4549 y: y2, 4550 placement: statefulPlacement, 4551 strategy, 4552 middlewareData 4553 }; 4554 }; 4555 var flip = function(options) { 4556 if (options === void 0) { 4557 options = {}; 4558 } 4559 return { 4560 name: "flip", 4561 options, 4562 async fn(state) { 4563 var _middlewareData$arrow, _middlewareData$flip; 4564 const { 4565 placement, 4566 middlewareData, 4567 rects, 4568 initialPlacement, 4569 platform: platform3, 4570 elements 4571 } = state; 4572 const { 4573 mainAxis: checkMainAxis = true, 4574 crossAxis: checkCrossAxis = true, 4575 fallbackPlacements: specifiedFallbackPlacements, 4576 fallbackStrategy = "bestFit", 4577 fallbackAxisSideDirection = "none", 4578 flipAlignment = true, 4579 ...detectOverflowOptions 4580 } = evaluate(options, state); 4581 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 4582 return {}; 4583 } 4584 const side = getSide(placement); 4585 const initialSideAxis = getSideAxis(initialPlacement); 4586 const isBasePlacement = getSide(initialPlacement) === initialPlacement; 4587 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); 4588 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); 4589 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none"; 4590 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) { 4591 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); 4592 } 4593 const placements2 = [initialPlacement, ...fallbackPlacements]; 4594 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 4595 const overflows = []; 4596 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; 4597 if (checkMainAxis) { 4598 overflows.push(overflow[side]); 4599 } 4600 if (checkCrossAxis) { 4601 const sides2 = getAlignmentSides(placement, rects, rtl); 4602 overflows.push(overflow[sides2[0]], overflow[sides2[1]]); 4603 } 4604 overflowsData = [...overflowsData, { 4605 placement, 4606 overflows 4607 }]; 4608 if (!overflows.every((side2) => side2 <= 0)) { 4609 var _middlewareData$flip2, _overflowsData$filter; 4610 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; 4611 const nextPlacement = placements2[nextIndex]; 4612 if (nextPlacement) { 4613 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false; 4614 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis 4615 // overflows the main axis. 4616 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) { 4617 return { 4618 data: { 4619 index: nextIndex, 4620 overflows: overflowsData 4621 }, 4622 reset: { 4623 placement: nextPlacement 4624 } 4625 }; 4626 } 4627 } 4628 let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a2, b2) => a2.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; 4629 if (!resetPlacement) { 4630 switch (fallbackStrategy) { 4631 case "bestFit": { 4632 var _overflowsData$filter2; 4633 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => { 4634 if (hasFallbackAxisSideDirection) { 4635 const currentSideAxis = getSideAxis(d2.placement); 4636 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal 4637 // reading directions favoring greater width. 4638 currentSideAxis === "y"; 4639 } 4640 return true; 4641 }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0]; 4642 if (placement2) { 4643 resetPlacement = placement2; 4644 } 4645 break; 4646 } 4647 case "initialPlacement": 4648 resetPlacement = initialPlacement; 4649 break; 4650 } 4651 } 4652 if (placement !== resetPlacement) { 4653 return { 4654 reset: { 4655 placement: resetPlacement 4656 } 4657 }; 4658 } 4659 } 4660 return {}; 4661 } 4662 }; 4663 }; 4664 function getSideOffsets(overflow, rect) { 4665 return { 4666 top: overflow.top - rect.height, 4667 right: overflow.right - rect.width, 4668 bottom: overflow.bottom - rect.height, 4669 left: overflow.left - rect.width 4670 }; 4671 } 4672 function isAnySideFullyClipped(overflow) { 4673 return sides.some((side) => overflow[side] >= 0); 4674 } 4675 var hide = function(options) { 4676 if (options === void 0) { 4677 options = {}; 4678 } 4679 return { 4680 name: "hide", 4681 options, 4682 async fn(state) { 4683 const { 4684 rects, 4685 platform: platform3 4686 } = state; 4687 const { 4688 strategy = "referenceHidden", 4689 ...detectOverflowOptions 4690 } = evaluate(options, state); 4691 switch (strategy) { 4692 case "referenceHidden": { 4693 const overflow = await platform3.detectOverflow(state, { 4694 ...detectOverflowOptions, 4695 elementContext: "reference" 4696 }); 4697 const offsets = getSideOffsets(overflow, rects.reference); 4698 return { 4699 data: { 4700 referenceHiddenOffsets: offsets, 4701 referenceHidden: isAnySideFullyClipped(offsets) 4702 } 4703 }; 4704 } 4705 case "escaped": { 4706 const overflow = await platform3.detectOverflow(state, { 4707 ...detectOverflowOptions, 4708 altBoundary: true 4709 }); 4710 const offsets = getSideOffsets(overflow, rects.floating); 4711 return { 4712 data: { 4713 escapedOffsets: offsets, 4714 escaped: isAnySideFullyClipped(offsets) 4715 } 4716 }; 4717 } 4718 default: { 4719 return {}; 4720 } 4721 } 4722 } 4723 }; 4724 }; 4725 var originSides = /* @__PURE__ */ new Set(["left", "top"]); 4726 async function convertValueToCoords(state, options) { 4727 const { 4728 placement, 4729 platform: platform3, 4730 elements 4731 } = state; 4732 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); 4733 const side = getSide(placement); 4734 const alignment = getAlignment(placement); 4735 const isVertical = getSideAxis(placement) === "y"; 4736 const mainAxisMulti = originSides.has(side) ? -1 : 1; 4737 const crossAxisMulti = rtl && isVertical ? -1 : 1; 4738 const rawValue = evaluate(options, state); 4739 let { 4740 mainAxis, 4741 crossAxis, 4742 alignmentAxis 4743 } = typeof rawValue === "number" ? { 4744 mainAxis: rawValue, 4745 crossAxis: 0, 4746 alignmentAxis: null 4747 } : { 4748 mainAxis: rawValue.mainAxis || 0, 4749 crossAxis: rawValue.crossAxis || 0, 4750 alignmentAxis: rawValue.alignmentAxis 4751 }; 4752 if (alignment && typeof alignmentAxis === "number") { 4753 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; 4754 } 4755 return isVertical ? { 4756 x: crossAxis * crossAxisMulti, 4757 y: mainAxis * mainAxisMulti 4758 } : { 4759 x: mainAxis * mainAxisMulti, 4760 y: crossAxis * crossAxisMulti 4761 }; 4762 } 4763 var offset = function(options) { 4764 if (options === void 0) { 4765 options = 0; 4766 } 4767 return { 4768 name: "offset", 4769 options, 4770 async fn(state) { 4771 var _middlewareData$offse, _middlewareData$arrow; 4772 const { 4773 x: x2, 4774 y: y2, 4775 placement, 4776 middlewareData 4777 } = state; 4778 const diffCoords = await convertValueToCoords(state, options); 4779 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 4780 return {}; 4781 } 4782 return { 4783 x: x2 + diffCoords.x, 4784 y: y2 + diffCoords.y, 4785 data: { 4786 ...diffCoords, 4787 placement 4788 } 4789 }; 4790 } 4791 }; 4792 }; 4793 var shift = function(options) { 4794 if (options === void 0) { 4795 options = {}; 4796 } 4797 return { 4798 name: "shift", 4799 options, 4800 async fn(state) { 4801 const { 4802 x: x2, 4803 y: y2, 4804 placement, 4805 platform: platform3 4806 } = state; 4807 const { 4808 mainAxis: checkMainAxis = true, 4809 crossAxis: checkCrossAxis = false, 4810 limiter = { 4811 fn: (_ref) => { 4812 let { 4813 x: x3, 4814 y: y3 4815 } = _ref; 4816 return { 4817 x: x3, 4818 y: y3 4819 }; 4820 } 4821 }, 4822 ...detectOverflowOptions 4823 } = evaluate(options, state); 4824 const coords = { 4825 x: x2, 4826 y: y2 4827 }; 4828 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 4829 const crossAxis = getSideAxis(getSide(placement)); 4830 const mainAxis = getOppositeAxis(crossAxis); 4831 let mainAxisCoord = coords[mainAxis]; 4832 let crossAxisCoord = coords[crossAxis]; 4833 if (checkMainAxis) { 4834 const minSide = mainAxis === "y" ? "top" : "left"; 4835 const maxSide = mainAxis === "y" ? "bottom" : "right"; 4836 const min2 = mainAxisCoord + overflow[minSide]; 4837 const max2 = mainAxisCoord - overflow[maxSide]; 4838 mainAxisCoord = clamp(min2, mainAxisCoord, max2); 4839 } 4840 if (checkCrossAxis) { 4841 const minSide = crossAxis === "y" ? "top" : "left"; 4842 const maxSide = crossAxis === "y" ? "bottom" : "right"; 4843 const min2 = crossAxisCoord + overflow[minSide]; 4844 const max2 = crossAxisCoord - overflow[maxSide]; 4845 crossAxisCoord = clamp(min2, crossAxisCoord, max2); 4846 } 4847 const limitedCoords = limiter.fn({ 4848 ...state, 4849 [mainAxis]: mainAxisCoord, 4850 [crossAxis]: crossAxisCoord 4851 }); 4852 return { 4853 ...limitedCoords, 4854 data: { 4855 x: limitedCoords.x - x2, 4856 y: limitedCoords.y - y2, 4857 enabled: { 4858 [mainAxis]: checkMainAxis, 4859 [crossAxis]: checkCrossAxis 4860 } 4861 } 4862 }; 4863 } 4864 }; 4865 }; 4866 var limitShift = function(options) { 4867 if (options === void 0) { 4868 options = {}; 4869 } 4870 return { 4871 options, 4872 fn(state) { 4873 const { 4874 x: x2, 4875 y: y2, 4876 placement, 4877 rects, 4878 middlewareData 4879 } = state; 4880 const { 4881 offset: offset4 = 0, 4882 mainAxis: checkMainAxis = true, 4883 crossAxis: checkCrossAxis = true 4884 } = evaluate(options, state); 4885 const coords = { 4886 x: x2, 4887 y: y2 4888 }; 4889 const crossAxis = getSideAxis(placement); 4890 const mainAxis = getOppositeAxis(crossAxis); 4891 let mainAxisCoord = coords[mainAxis]; 4892 let crossAxisCoord = coords[crossAxis]; 4893 const rawOffset = evaluate(offset4, state); 4894 const computedOffset = typeof rawOffset === "number" ? { 4895 mainAxis: rawOffset, 4896 crossAxis: 0 4897 } : { 4898 mainAxis: 0, 4899 crossAxis: 0, 4900 ...rawOffset 4901 }; 4902 if (checkMainAxis) { 4903 const len = mainAxis === "y" ? "height" : "width"; 4904 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; 4905 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; 4906 if (mainAxisCoord < limitMin) { 4907 mainAxisCoord = limitMin; 4908 } else if (mainAxisCoord > limitMax) { 4909 mainAxisCoord = limitMax; 4910 } 4911 } 4912 if (checkCrossAxis) { 4913 var _middlewareData$offse, _middlewareData$offse2; 4914 const len = mainAxis === "y" ? "width" : "height"; 4915 const isOriginSide = originSides.has(getSide(placement)); 4916 const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); 4917 const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); 4918 if (crossAxisCoord < limitMin) { 4919 crossAxisCoord = limitMin; 4920 } else if (crossAxisCoord > limitMax) { 4921 crossAxisCoord = limitMax; 4922 } 4923 } 4924 return { 4925 [mainAxis]: mainAxisCoord, 4926 [crossAxis]: crossAxisCoord 4927 }; 4928 } 4929 }; 4930 }; 4931 var size = function(options) { 4932 if (options === void 0) { 4933 options = {}; 4934 } 4935 return { 4936 name: "size", 4937 options, 4938 async fn(state) { 4939 var _state$middlewareData, _state$middlewareData2; 4940 const { 4941 placement, 4942 rects, 4943 platform: platform3, 4944 elements 4945 } = state; 4946 const { 4947 apply = () => { 4948 }, 4949 ...detectOverflowOptions 4950 } = evaluate(options, state); 4951 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 4952 const side = getSide(placement); 4953 const alignment = getAlignment(placement); 4954 const isYAxis = getSideAxis(placement) === "y"; 4955 const { 4956 width, 4957 height 4958 } = rects.floating; 4959 let heightSide; 4960 let widthSide; 4961 if (side === "top" || side === "bottom") { 4962 heightSide = side; 4963 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; 4964 } else { 4965 widthSide = side; 4966 heightSide = alignment === "end" ? "top" : "bottom"; 4967 } 4968 const maximumClippingHeight = height - overflow.top - overflow.bottom; 4969 const maximumClippingWidth = width - overflow.left - overflow.right; 4970 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); 4971 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); 4972 const noShift = !state.middlewareData.shift; 4973 let availableHeight = overflowAvailableHeight; 4974 let availableWidth = overflowAvailableWidth; 4975 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) { 4976 availableWidth = maximumClippingWidth; 4977 } 4978 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) { 4979 availableHeight = maximumClippingHeight; 4980 } 4981 if (noShift && !alignment) { 4982 const xMin = max(overflow.left, 0); 4983 const xMax = max(overflow.right, 0); 4984 const yMin = max(overflow.top, 0); 4985 const yMax = max(overflow.bottom, 0); 4986 if (isYAxis) { 4987 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); 4988 } else { 4989 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); 4990 } 4991 } 4992 await apply({ 4993 ...state, 4994 availableWidth, 4995 availableHeight 4996 }); 4997 const nextDimensions = await platform3.getDimensions(elements.floating); 4998 if (width !== nextDimensions.width || height !== nextDimensions.height) { 4999 return { 5000 reset: { 5001 rects: true 5002 } 5003 }; 5004 } 5005 return {}; 5006 } 5007 }; 5008 }; 5009 5010 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs 5011 function getCssDimensions(element) { 5012 const css = getComputedStyle2(element); 5013 let width = parseFloat(css.width) || 0; 5014 let height = parseFloat(css.height) || 0; 5015 const hasOffset = isHTMLElement(element); 5016 const offsetWidth = hasOffset ? element.offsetWidth : width; 5017 const offsetHeight = hasOffset ? element.offsetHeight : height; 5018 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 5019 if (shouldFallback) { 5020 width = offsetWidth; 5021 height = offsetHeight; 5022 } 5023 return { 5024 width, 5025 height, 5026 $: shouldFallback 5027 }; 5028 } 5029 function unwrapElement(element) { 5030 return !isElement(element) ? element.contextElement : element; 5031 } 5032 function getScale(element) { 5033 const domElement = unwrapElement(element); 5034 if (!isHTMLElement(domElement)) { 5035 return createCoords(1); 5036 } 5037 const rect = domElement.getBoundingClientRect(); 5038 const { 5039 width, 5040 height, 5041 $: $2 5042 } = getCssDimensions(domElement); 5043 let x2 = ($2 ? round(rect.width) : rect.width) / width; 5044 let y2 = ($2 ? round(rect.height) : rect.height) / height; 5045 if (!x2 || !Number.isFinite(x2)) { 5046 x2 = 1; 5047 } 5048 if (!y2 || !Number.isFinite(y2)) { 5049 y2 = 1; 5050 } 5051 return { 5052 x: x2, 5053 y: y2 5054 }; 5055 } 5056 var noOffsets = /* @__PURE__ */ createCoords(0); 5057 function getVisualOffsets(element) { 5058 const win = getWindow(element); 5059 if (!isWebKit() || !win.visualViewport) { 5060 return noOffsets; 5061 } 5062 return { 5063 x: win.visualViewport.offsetLeft, 5064 y: win.visualViewport.offsetTop 5065 }; 5066 } 5067 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { 5068 if (isFixed === void 0) { 5069 isFixed = false; 5070 } 5071 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { 5072 return false; 5073 } 5074 return isFixed; 5075 } 5076 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { 5077 if (includeScale === void 0) { 5078 includeScale = false; 5079 } 5080 if (isFixedStrategy === void 0) { 5081 isFixedStrategy = false; 5082 } 5083 const clientRect = element.getBoundingClientRect(); 5084 const domElement = unwrapElement(element); 5085 let scale = createCoords(1); 5086 if (includeScale) { 5087 if (offsetParent) { 5088 if (isElement(offsetParent)) { 5089 scale = getScale(offsetParent); 5090 } 5091 } else { 5092 scale = getScale(element); 5093 } 5094 } 5095 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); 5096 let x2 = (clientRect.left + visualOffsets.x) / scale.x; 5097 let y2 = (clientRect.top + visualOffsets.y) / scale.y; 5098 let width = clientRect.width / scale.x; 5099 let height = clientRect.height / scale.y; 5100 if (domElement) { 5101 const win = getWindow(domElement); 5102 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; 5103 let currentWin = win; 5104 let currentIFrame = getFrameElement(currentWin); 5105 while (currentIFrame && offsetParent && offsetWin !== currentWin) { 5106 const iframeScale = getScale(currentIFrame); 5107 const iframeRect = currentIFrame.getBoundingClientRect(); 5108 const css = getComputedStyle2(currentIFrame); 5109 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; 5110 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; 5111 x2 *= iframeScale.x; 5112 y2 *= iframeScale.y; 5113 width *= iframeScale.x; 5114 height *= iframeScale.y; 5115 x2 += left; 5116 y2 += top; 5117 currentWin = getWindow(currentIFrame); 5118 currentIFrame = getFrameElement(currentWin); 5119 } 5120 } 5121 return rectToClientRect({ 5122 width, 5123 height, 5124 x: x2, 5125 y: y2 5126 }); 5127 } 5128 function getWindowScrollBarX(element, rect) { 5129 const leftScroll = getNodeScroll(element).scrollLeft; 5130 if (!rect) { 5131 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; 5132 } 5133 return rect.left + leftScroll; 5134 } 5135 function getHTMLOffset(documentElement, scroll) { 5136 const htmlRect = documentElement.getBoundingClientRect(); 5137 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect); 5138 const y2 = htmlRect.top + scroll.scrollTop; 5139 return { 5140 x: x2, 5141 y: y2 5142 }; 5143 } 5144 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { 5145 let { 5146 elements, 5147 rect, 5148 offsetParent, 5149 strategy 5150 } = _ref; 5151 const isFixed = strategy === "fixed"; 5152 const documentElement = getDocumentElement(offsetParent); 5153 const topLayer = elements ? isTopLayer(elements.floating) : false; 5154 if (offsetParent === documentElement || topLayer && isFixed) { 5155 return rect; 5156 } 5157 let scroll = { 5158 scrollLeft: 0, 5159 scrollTop: 0 5160 }; 5161 let scale = createCoords(1); 5162 const offsets = createCoords(0); 5163 const isOffsetParentAnElement = isHTMLElement(offsetParent); 5164 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 5165 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 5166 scroll = getNodeScroll(offsetParent); 5167 } 5168 if (isOffsetParentAnElement) { 5169 const offsetRect = getBoundingClientRect(offsetParent); 5170 scale = getScale(offsetParent); 5171 offsets.x = offsetRect.x + offsetParent.clientLeft; 5172 offsets.y = offsetRect.y + offsetParent.clientTop; 5173 } 5174 } 5175 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 5176 return { 5177 width: rect.width * scale.x, 5178 height: rect.height * scale.y, 5179 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x, 5180 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y 5181 }; 5182 } 5183 function getClientRects(element) { 5184 return Array.from(element.getClientRects()); 5185 } 5186 function getDocumentRect(element) { 5187 const html = getDocumentElement(element); 5188 const scroll = getNodeScroll(element); 5189 const body = element.ownerDocument.body; 5190 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); 5191 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); 5192 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element); 5193 const y2 = -scroll.scrollTop; 5194 if (getComputedStyle2(body).direction === "rtl") { 5195 x2 += max(html.clientWidth, body.clientWidth) - width; 5196 } 5197 return { 5198 width, 5199 height, 5200 x: x2, 5201 y: y2 5202 }; 5203 } 5204 var SCROLLBAR_MAX = 25; 5205 function getViewportRect(element, strategy) { 5206 const win = getWindow(element); 5207 const html = getDocumentElement(element); 5208 const visualViewport = win.visualViewport; 5209 let width = html.clientWidth; 5210 let height = html.clientHeight; 5211 let x2 = 0; 5212 let y2 = 0; 5213 if (visualViewport) { 5214 width = visualViewport.width; 5215 height = visualViewport.height; 5216 const visualViewportBased = isWebKit(); 5217 if (!visualViewportBased || visualViewportBased && strategy === "fixed") { 5218 x2 = visualViewport.offsetLeft; 5219 y2 = visualViewport.offsetTop; 5220 } 5221 } 5222 const windowScrollbarX = getWindowScrollBarX(html); 5223 if (windowScrollbarX <= 0) { 5224 const doc = html.ownerDocument; 5225 const body = doc.body; 5226 const bodyStyles = getComputedStyle(body); 5227 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0; 5228 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline); 5229 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) { 5230 width -= clippingStableScrollbarWidth; 5231 } 5232 } else if (windowScrollbarX <= SCROLLBAR_MAX) { 5233 width += windowScrollbarX; 5234 } 5235 return { 5236 width, 5237 height, 5238 x: x2, 5239 y: y2 5240 }; 5241 } 5242 function getInnerBoundingClientRect(element, strategy) { 5243 const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); 5244 const top = clientRect.top + element.clientTop; 5245 const left = clientRect.left + element.clientLeft; 5246 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1); 5247 const width = element.clientWidth * scale.x; 5248 const height = element.clientHeight * scale.y; 5249 const x2 = left * scale.x; 5250 const y2 = top * scale.y; 5251 return { 5252 width, 5253 height, 5254 x: x2, 5255 y: y2 5256 }; 5257 } 5258 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { 5259 let rect; 5260 if (clippingAncestor === "viewport") { 5261 rect = getViewportRect(element, strategy); 5262 } else if (clippingAncestor === "document") { 5263 rect = getDocumentRect(getDocumentElement(element)); 5264 } else if (isElement(clippingAncestor)) { 5265 rect = getInnerBoundingClientRect(clippingAncestor, strategy); 5266 } else { 5267 const visualOffsets = getVisualOffsets(element); 5268 rect = { 5269 x: clippingAncestor.x - visualOffsets.x, 5270 y: clippingAncestor.y - visualOffsets.y, 5271 width: clippingAncestor.width, 5272 height: clippingAncestor.height 5273 }; 5274 } 5275 return rectToClientRect(rect); 5276 } 5277 function hasFixedPositionAncestor(element, stopNode) { 5278 const parentNode = getParentNode(element); 5279 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { 5280 return false; 5281 } 5282 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); 5283 } 5284 function getClippingElementAncestors(element, cache) { 5285 const cachedResult = cache.get(element); 5286 if (cachedResult) { 5287 return cachedResult; 5288 } 5289 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); 5290 let currentContainingBlockComputedStyle = null; 5291 const elementIsFixed = getComputedStyle2(element).position === "fixed"; 5292 let currentNode = elementIsFixed ? getParentNode(element) : element; 5293 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { 5294 const computedStyle = getComputedStyle2(currentNode); 5295 const currentNodeIsContaining = isContainingBlock(currentNode); 5296 if (!currentNodeIsContaining && computedStyle.position === "fixed") { 5297 currentContainingBlockComputedStyle = null; 5298 } 5299 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); 5300 if (shouldDropCurrentNode) { 5301 result = result.filter((ancestor) => ancestor !== currentNode); 5302 } else { 5303 currentContainingBlockComputedStyle = computedStyle; 5304 } 5305 currentNode = getParentNode(currentNode); 5306 } 5307 cache.set(element, result); 5308 return result; 5309 } 5310 function getClippingRect(_ref) { 5311 let { 5312 element, 5313 boundary, 5314 rootBoundary, 5315 strategy 5316 } = _ref; 5317 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); 5318 const clippingAncestors = [...elementClippingAncestors, rootBoundary]; 5319 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy); 5320 let top = firstRect.top; 5321 let right = firstRect.right; 5322 let bottom = firstRect.bottom; 5323 let left = firstRect.left; 5324 for (let i2 = 1; i2 < clippingAncestors.length; i2++) { 5325 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy); 5326 top = max(rect.top, top); 5327 right = min(rect.right, right); 5328 bottom = min(rect.bottom, bottom); 5329 left = max(rect.left, left); 5330 } 5331 return { 5332 width: right - left, 5333 height: bottom - top, 5334 x: left, 5335 y: top 5336 }; 5337 } 5338 function getDimensions(element) { 5339 const { 5340 width, 5341 height 5342 } = getCssDimensions(element); 5343 return { 5344 width, 5345 height 5346 }; 5347 } 5348 function getRectRelativeToOffsetParent(element, offsetParent, strategy) { 5349 const isOffsetParentAnElement = isHTMLElement(offsetParent); 5350 const documentElement = getDocumentElement(offsetParent); 5351 const isFixed = strategy === "fixed"; 5352 const rect = getBoundingClientRect(element, true, isFixed, offsetParent); 5353 let scroll = { 5354 scrollLeft: 0, 5355 scrollTop: 0 5356 }; 5357 const offsets = createCoords(0); 5358 function setLeftRTLScrollbarOffset() { 5359 offsets.x = getWindowScrollBarX(documentElement); 5360 } 5361 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 5362 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 5363 scroll = getNodeScroll(offsetParent); 5364 } 5365 if (isOffsetParentAnElement) { 5366 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); 5367 offsets.x = offsetRect.x + offsetParent.clientLeft; 5368 offsets.y = offsetRect.y + offsetParent.clientTop; 5369 } else if (documentElement) { 5370 setLeftRTLScrollbarOffset(); 5371 } 5372 } 5373 if (isFixed && !isOffsetParentAnElement && documentElement) { 5374 setLeftRTLScrollbarOffset(); 5375 } 5376 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 5377 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; 5378 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; 5379 return { 5380 x: x2, 5381 y: y2, 5382 width: rect.width, 5383 height: rect.height 5384 }; 5385 } 5386 function isStaticPositioned(element) { 5387 return getComputedStyle2(element).position === "static"; 5388 } 5389 function getTrueOffsetParent(element, polyfill) { 5390 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") { 5391 return null; 5392 } 5393 if (polyfill) { 5394 return polyfill(element); 5395 } 5396 let rawOffsetParent = element.offsetParent; 5397 if (getDocumentElement(element) === rawOffsetParent) { 5398 rawOffsetParent = rawOffsetParent.ownerDocument.body; 5399 } 5400 return rawOffsetParent; 5401 } 5402 function getOffsetParent(element, polyfill) { 5403 const win = getWindow(element); 5404 if (isTopLayer(element)) { 5405 return win; 5406 } 5407 if (!isHTMLElement(element)) { 5408 let svgOffsetParent = getParentNode(element); 5409 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { 5410 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { 5411 return svgOffsetParent; 5412 } 5413 svgOffsetParent = getParentNode(svgOffsetParent); 5414 } 5415 return win; 5416 } 5417 let offsetParent = getTrueOffsetParent(element, polyfill); 5418 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { 5419 offsetParent = getTrueOffsetParent(offsetParent, polyfill); 5420 } 5421 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { 5422 return win; 5423 } 5424 return offsetParent || getContainingBlock(element) || win; 5425 } 5426 var getElementRects = async function(data) { 5427 const getOffsetParentFn = this.getOffsetParent || getOffsetParent; 5428 const getDimensionsFn = this.getDimensions; 5429 const floatingDimensions = await getDimensionsFn(data.floating); 5430 return { 5431 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), 5432 floating: { 5433 x: 0, 5434 y: 0, 5435 width: floatingDimensions.width, 5436 height: floatingDimensions.height 5437 } 5438 }; 5439 }; 5440 function isRTL(element) { 5441 return getComputedStyle2(element).direction === "rtl"; 5442 } 5443 var platform2 = { 5444 convertOffsetParentRelativeRectToViewportRelativeRect, 5445 getDocumentElement, 5446 getClippingRect, 5447 getOffsetParent, 5448 getElementRects, 5449 getClientRects, 5450 getDimensions, 5451 getScale, 5452 isElement, 5453 isRTL 5454 }; 5455 function rectsAreEqual(a2, b2) { 5456 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height; 5457 } 5458 function observeMove(element, onMove) { 5459 let io = null; 5460 let timeoutId; 5461 const root = getDocumentElement(element); 5462 function cleanup() { 5463 var _io; 5464 clearTimeout(timeoutId); 5465 (_io = io) == null || _io.disconnect(); 5466 io = null; 5467 } 5468 function refresh(skip, threshold) { 5469 if (skip === void 0) { 5470 skip = false; 5471 } 5472 if (threshold === void 0) { 5473 threshold = 1; 5474 } 5475 cleanup(); 5476 const elementRectForRootMargin = element.getBoundingClientRect(); 5477 const { 5478 left, 5479 top, 5480 width, 5481 height 5482 } = elementRectForRootMargin; 5483 if (!skip) { 5484 onMove(); 5485 } 5486 if (!width || !height) { 5487 return; 5488 } 5489 const insetTop = floor(top); 5490 const insetRight = floor(root.clientWidth - (left + width)); 5491 const insetBottom = floor(root.clientHeight - (top + height)); 5492 const insetLeft = floor(left); 5493 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; 5494 const options = { 5495 rootMargin, 5496 threshold: max(0, min(1, threshold)) || 1 5497 }; 5498 let isFirstUpdate = true; 5499 function handleObserve(entries) { 5500 const ratio = entries[0].intersectionRatio; 5501 if (ratio !== threshold) { 5502 if (!isFirstUpdate) { 5503 return refresh(); 5504 } 5505 if (!ratio) { 5506 timeoutId = setTimeout(() => { 5507 refresh(false, 1e-7); 5508 }, 1e3); 5509 } else { 5510 refresh(false, ratio); 5511 } 5512 } 5513 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) { 5514 refresh(); 5515 } 5516 isFirstUpdate = false; 5517 } 5518 try { 5519 io = new IntersectionObserver(handleObserve, { 5520 ...options, 5521 // Handle <iframe>s 5522 root: root.ownerDocument 5523 }); 5524 } catch (_e) { 5525 io = new IntersectionObserver(handleObserve, options); 5526 } 5527 io.observe(element); 5528 } 5529 refresh(true); 5530 return cleanup; 5531 } 5532 function autoUpdate(reference, floating, update2, options) { 5533 if (options === void 0) { 5534 options = {}; 5535 } 5536 const { 5537 ancestorScroll = true, 5538 ancestorResize = true, 5539 elementResize = typeof ResizeObserver === "function", 5540 layoutShift = typeof IntersectionObserver === "function", 5541 animationFrame = false 5542 } = options; 5543 const referenceEl = unwrapElement(reference); 5544 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : []; 5545 ancestors.forEach((ancestor) => { 5546 ancestorScroll && ancestor.addEventListener("scroll", update2, { 5547 passive: true 5548 }); 5549 ancestorResize && ancestor.addEventListener("resize", update2); 5550 }); 5551 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null; 5552 let reobserveFrame = -1; 5553 let resizeObserver = null; 5554 if (elementResize) { 5555 resizeObserver = new ResizeObserver((_ref) => { 5556 let [firstEntry] = _ref; 5557 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) { 5558 resizeObserver.unobserve(floating); 5559 cancelAnimationFrame(reobserveFrame); 5560 reobserveFrame = requestAnimationFrame(() => { 5561 var _resizeObserver; 5562 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating); 5563 }); 5564 } 5565 update2(); 5566 }); 5567 if (referenceEl && !animationFrame) { 5568 resizeObserver.observe(referenceEl); 5569 } 5570 if (floating) { 5571 resizeObserver.observe(floating); 5572 } 5573 } 5574 let frameId; 5575 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null; 5576 if (animationFrame) { 5577 frameLoop(); 5578 } 5579 function frameLoop() { 5580 const nextRefRect = getBoundingClientRect(reference); 5581 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) { 5582 update2(); 5583 } 5584 prevRefRect = nextRefRect; 5585 frameId = requestAnimationFrame(frameLoop); 5586 } 5587 update2(); 5588 return () => { 5589 var _resizeObserver2; 5590 ancestors.forEach((ancestor) => { 5591 ancestorScroll && ancestor.removeEventListener("scroll", update2); 5592 ancestorResize && ancestor.removeEventListener("resize", update2); 5593 }); 5594 cleanupIo == null || cleanupIo(); 5595 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect(); 5596 resizeObserver = null; 5597 if (animationFrame) { 5598 cancelAnimationFrame(frameId); 5599 } 5600 }; 5601 } 5602 var offset2 = offset; 5603 var shift2 = shift; 5604 var flip2 = flip; 5605 var size2 = size; 5606 var hide2 = hide; 5607 var limitShift2 = limitShift; 5608 var computePosition2 = (reference, floating, options) => { 5609 const cache = /* @__PURE__ */ new Map(); 5610 const mergedOptions = { 5611 platform: platform2, 5612 ...options 5613 }; 5614 const platformWithCache = { 5615 ...mergedOptions.platform, 5616 _c: cache 5617 }; 5618 return computePosition(reference, floating, { 5619 ...mergedOptions, 5620 platform: platformWithCache 5621 }); 5622 }; 5623 5624 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs 5625 var React28 = __toESM(require_react(), 1); 5626 var import_react2 = __toESM(require_react(), 1); 5627 var ReactDOM3 = __toESM(require_react_dom(), 1); 5628 var isClient = typeof document !== "undefined"; 5629 var noop2 = function noop3() { 5630 }; 5631 var index = isClient ? import_react2.useLayoutEffect : noop2; 5632 function deepEqual(a2, b2) { 5633 if (a2 === b2) { 5634 return true; 5635 } 5636 if (typeof a2 !== typeof b2) { 5637 return false; 5638 } 5639 if (typeof a2 === "function" && a2.toString() === b2.toString()) { 5640 return true; 5641 } 5642 let length; 5643 let i2; 5644 let keys; 5645 if (a2 && b2 && typeof a2 === "object") { 5646 if (Array.isArray(a2)) { 5647 length = a2.length; 5648 if (length !== b2.length) return false; 5649 for (i2 = length; i2-- !== 0; ) { 5650 if (!deepEqual(a2[i2], b2[i2])) { 5651 return false; 5652 } 5653 } 5654 return true; 5655 } 5656 keys = Object.keys(a2); 5657 length = keys.length; 5658 if (length !== Object.keys(b2).length) { 5659 return false; 5660 } 5661 for (i2 = length; i2-- !== 0; ) { 5662 if (!{}.hasOwnProperty.call(b2, keys[i2])) { 5663 return false; 5664 } 5665 } 5666 for (i2 = length; i2-- !== 0; ) { 5667 const key = keys[i2]; 5668 if (key === "_owner" && a2.$$typeof) { 5669 continue; 5670 } 5671 if (!deepEqual(a2[key], b2[key])) { 5672 return false; 5673 } 5674 } 5675 return true; 5676 } 5677 return a2 !== a2 && b2 !== b2; 5678 } 5679 function getDPR(element) { 5680 if (typeof window === "undefined") { 5681 return 1; 5682 } 5683 const win = element.ownerDocument.defaultView || window; 5684 return win.devicePixelRatio || 1; 5685 } 5686 function roundByDPR(element, value) { 5687 const dpr = getDPR(element); 5688 return Math.round(value * dpr) / dpr; 5689 } 5690 function useLatestRef(value) { 5691 const ref = React28.useRef(value); 5692 index(() => { 5693 ref.current = value; 5694 }); 5695 return ref; 5696 } 5697 function useFloating(options) { 5698 if (options === void 0) { 5699 options = {}; 5700 } 5701 const { 5702 placement = "bottom", 5703 strategy = "absolute", 5704 middleware = [], 5705 platform: platform3, 5706 elements: { 5707 reference: externalReference, 5708 floating: externalFloating 5709 } = {}, 5710 transform = true, 5711 whileElementsMounted, 5712 open 5713 } = options; 5714 const [data, setData] = React28.useState({ 5715 x: 0, 5716 y: 0, 5717 strategy, 5718 placement, 5719 middlewareData: {}, 5720 isPositioned: false 5721 }); 5722 const [latestMiddleware, setLatestMiddleware] = React28.useState(middleware); 5723 if (!deepEqual(latestMiddleware, middleware)) { 5724 setLatestMiddleware(middleware); 5725 } 5726 const [_reference, _setReference] = React28.useState(null); 5727 const [_floating, _setFloating] = React28.useState(null); 5728 const setReference = React28.useCallback((node) => { 5729 if (node !== referenceRef.current) { 5730 referenceRef.current = node; 5731 _setReference(node); 5732 } 5733 }, []); 5734 const setFloating = React28.useCallback((node) => { 5735 if (node !== floatingRef.current) { 5736 floatingRef.current = node; 5737 _setFloating(node); 5738 } 5739 }, []); 5740 const referenceEl = externalReference || _reference; 5741 const floatingEl = externalFloating || _floating; 5742 const referenceRef = React28.useRef(null); 5743 const floatingRef = React28.useRef(null); 5744 const dataRef = React28.useRef(data); 5745 const hasWhileElementsMounted = whileElementsMounted != null; 5746 const whileElementsMountedRef = useLatestRef(whileElementsMounted); 5747 const platformRef = useLatestRef(platform3); 5748 const openRef = useLatestRef(open); 5749 const update2 = React28.useCallback(() => { 5750 if (!referenceRef.current || !floatingRef.current) { 5751 return; 5752 } 5753 const config = { 5754 placement, 5755 strategy, 5756 middleware: latestMiddleware 5757 }; 5758 if (platformRef.current) { 5759 config.platform = platformRef.current; 5760 } 5761 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => { 5762 const fullData = { 5763 ...data2, 5764 // The floating element's position may be recomputed while it's closed 5765 // but still mounted (such as when transitioning out). To ensure 5766 // `isPositioned` will be `false` initially on the next open, avoid 5767 // setting it to `true` when `open === false` (must be specified). 5768 isPositioned: openRef.current !== false 5769 }; 5770 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) { 5771 dataRef.current = fullData; 5772 ReactDOM3.flushSync(() => { 5773 setData(fullData); 5774 }); 5775 } 5776 }); 5777 }, [latestMiddleware, placement, strategy, platformRef, openRef]); 5778 index(() => { 5779 if (open === false && dataRef.current.isPositioned) { 5780 dataRef.current.isPositioned = false; 5781 setData((data2) => ({ 5782 ...data2, 5783 isPositioned: false 5784 })); 5785 } 5786 }, [open]); 5787 const isMountedRef = React28.useRef(false); 5788 index(() => { 5789 isMountedRef.current = true; 5790 return () => { 5791 isMountedRef.current = false; 5792 }; 5793 }, []); 5794 index(() => { 5795 if (referenceEl) referenceRef.current = referenceEl; 5796 if (floatingEl) floatingRef.current = floatingEl; 5797 if (referenceEl && floatingEl) { 5798 if (whileElementsMountedRef.current) { 5799 return whileElementsMountedRef.current(referenceEl, floatingEl, update2); 5800 } 5801 update2(); 5802 } 5803 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]); 5804 const refs = React28.useMemo(() => ({ 5805 reference: referenceRef, 5806 floating: floatingRef, 5807 setReference, 5808 setFloating 5809 }), [setReference, setFloating]); 5810 const elements = React28.useMemo(() => ({ 5811 reference: referenceEl, 5812 floating: floatingEl 5813 }), [referenceEl, floatingEl]); 5814 const floatingStyles = React28.useMemo(() => { 5815 const initialStyles = { 5816 position: strategy, 5817 left: 0, 5818 top: 0 5819 }; 5820 if (!elements.floating) { 5821 return initialStyles; 5822 } 5823 const x2 = roundByDPR(elements.floating, data.x); 5824 const y2 = roundByDPR(elements.floating, data.y); 5825 if (transform) { 5826 return { 5827 ...initialStyles, 5828 transform: "translate(" + x2 + "px, " + y2 + "px)", 5829 ...getDPR(elements.floating) >= 1.5 && { 5830 willChange: "transform" 5831 } 5832 }; 5833 } 5834 return { 5835 position: strategy, 5836 left: x2, 5837 top: y2 5838 }; 5839 }, [strategy, transform, elements.floating, data.x, data.y]); 5840 return React28.useMemo(() => ({ 5841 ...data, 5842 update: update2, 5843 refs, 5844 elements, 5845 floatingStyles 5846 }), [data, update2, refs, elements, floatingStyles]); 5847 } 5848 var offset3 = (options, deps) => { 5849 const result = offset2(options); 5850 return { 5851 name: result.name, 5852 fn: result.fn, 5853 options: [options, deps] 5854 }; 5855 }; 5856 var shift3 = (options, deps) => { 5857 const result = shift2(options); 5858 return { 5859 name: result.name, 5860 fn: result.fn, 5861 options: [options, deps] 5862 }; 5863 }; 5864 var limitShift3 = (options, deps) => { 5865 const result = limitShift2(options); 5866 return { 5867 fn: result.fn, 5868 options: [options, deps] 5869 }; 5870 }; 5871 var flip3 = (options, deps) => { 5872 const result = flip2(options); 5873 return { 5874 name: result.name, 5875 fn: result.fn, 5876 options: [options, deps] 5877 }; 5878 }; 5879 var size3 = (options, deps) => { 5880 const result = size2(options); 5881 return { 5882 name: result.name, 5883 fn: result.fn, 5884 options: [options, deps] 5885 }; 5886 }; 5887 var hide3 = (options, deps) => { 5888 const result = hide2(options); 5889 return { 5890 name: result.name, 5891 fn: result.fn, 5892 options: [options, deps] 5893 }; 5894 }; 5895 5896 // node_modules/@base-ui/utils/esm/store/createSelector.js 5897 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => { 5898 if (other.length > 0) { 5899 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1)); 5900 } 5901 let selector2; 5902 if (a2 && b2 && c2 && d2 && e2 && f2) { 5903 selector2 = (state, a1, a22, a3) => { 5904 const va = a2(state, a1, a22, a3); 5905 const vb = b2(state, a1, a22, a3); 5906 const vc = c2(state, a1, a22, a3); 5907 const vd = d2(state, a1, a22, a3); 5908 const ve = e2(state, a1, a22, a3); 5909 return f2(va, vb, vc, vd, ve, a1, a22, a3); 5910 }; 5911 } else if (a2 && b2 && c2 && d2 && e2) { 5912 selector2 = (state, a1, a22, a3) => { 5913 const va = a2(state, a1, a22, a3); 5914 const vb = b2(state, a1, a22, a3); 5915 const vc = c2(state, a1, a22, a3); 5916 const vd = d2(state, a1, a22, a3); 5917 return e2(va, vb, vc, vd, a1, a22, a3); 5918 }; 5919 } else if (a2 && b2 && c2 && d2) { 5920 selector2 = (state, a1, a22, a3) => { 5921 const va = a2(state, a1, a22, a3); 5922 const vb = b2(state, a1, a22, a3); 5923 const vc = c2(state, a1, a22, a3); 5924 return d2(va, vb, vc, a1, a22, a3); 5925 }; 5926 } else if (a2 && b2 && c2) { 5927 selector2 = (state, a1, a22, a3) => { 5928 const va = a2(state, a1, a22, a3); 5929 const vb = b2(state, a1, a22, a3); 5930 return c2(va, vb, a1, a22, a3); 5931 }; 5932 } else if (a2 && b2) { 5933 selector2 = (state, a1, a22, a3) => { 5934 const va = a2(state, a1, a22, a3); 5935 return b2(va, a1, a22, a3); 5936 }; 5937 } else if (a2) { 5938 selector2 = a2; 5939 } else { 5940 throw ( 5941 /* minify-error-disabled */ 5942 new Error("Missing arguments") 5943 ); 5944 } 5945 return selector2; 5946 }; 5947 5948 // node_modules/@base-ui/utils/esm/store/useStore.js 5949 var React30 = __toESM(require_react(), 1); 5950 var import_shim = __toESM(require_shim(), 1); 5951 var import_with_selector = __toESM(require_with_selector(), 1); 5952 5953 // node_modules/@base-ui/utils/esm/fastHooks.js 5954 var React29 = __toESM(require_react(), 1); 5955 var hooks = []; 5956 var currentInstance = void 0; 5957 function getInstance() { 5958 return currentInstance; 5959 } 5960 function register(hook) { 5961 hooks.push(hook); 5962 } 5963 function fastComponent(fn) { 5964 const FastComponent = (props, forwardedRef) => { 5965 const instance = useRefWithInit(createInstance).current; 5966 let result; 5967 try { 5968 currentInstance = instance; 5969 for (const hook of hooks) { 5970 hook.before(instance); 5971 } 5972 result = fn(props, forwardedRef); 5973 for (const hook of hooks) { 5974 hook.after(instance); 5975 } 5976 instance.didInitialize = true; 5977 } finally { 5978 currentInstance = void 0; 5979 } 5980 return result; 5981 }; 5982 FastComponent.displayName = fn.displayName || fn.name; 5983 return FastComponent; 5984 } 5985 function fastComponentRef(fn) { 5986 return /* @__PURE__ */ React29.forwardRef(fastComponent(fn)); 5987 } 5988 function createInstance() { 5989 return { 5990 didInitialize: false 5991 }; 5992 } 5993 5994 // node_modules/@base-ui/utils/esm/store/useStore.js 5995 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19); 5996 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy; 5997 function useStore(store2, selector2, a1, a2, a3) { 5998 return useStoreImplementation(store2, selector2, a1, a2, a3); 5999 } 6000 function useStoreR19(store2, selector2, a1, a2, a3) { 6001 const getSelection = React30.useCallback(() => selector2(store2.getSnapshot(), a1, a2, a3), [store2, selector2, a1, a2, a3]); 6002 return (0, import_shim.useSyncExternalStore)(store2.subscribe, getSelection, getSelection); 6003 } 6004 register({ 6005 before(instance) { 6006 instance.syncIndex = 0; 6007 if (!instance.didInitialize) { 6008 instance.syncTick = 1; 6009 instance.syncHooks = []; 6010 instance.didChangeStore = true; 6011 instance.getSnapshot = () => { 6012 let didChange2 = false; 6013 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) { 6014 const hook = instance.syncHooks[i2]; 6015 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3); 6016 if (hook.didChange || !Object.is(hook.value, value)) { 6017 didChange2 = true; 6018 hook.value = value; 6019 hook.didChange = false; 6020 } 6021 } 6022 if (didChange2) { 6023 instance.syncTick += 1; 6024 } 6025 return instance.syncTick; 6026 }; 6027 } 6028 }, 6029 after(instance) { 6030 if (instance.syncHooks.length > 0) { 6031 if (instance.didChangeStore) { 6032 instance.didChangeStore = false; 6033 instance.subscribe = (onStoreChange) => { 6034 const stores = /* @__PURE__ */ new Set(); 6035 for (const hook of instance.syncHooks) { 6036 stores.add(hook.store); 6037 } 6038 const unsubscribes = []; 6039 for (const store2 of stores) { 6040 unsubscribes.push(store2.subscribe(onStoreChange)); 6041 } 6042 return () => { 6043 for (const unsubscribe of unsubscribes) { 6044 unsubscribe(); 6045 } 6046 }; 6047 }; 6048 } 6049 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot); 6050 } 6051 } 6052 }); 6053 function useStoreFast(store2, selector2, a1, a2, a3) { 6054 const instance = getInstance(); 6055 if (!instance) { 6056 return useStoreR19(store2, selector2, a1, a2, a3); 6057 } 6058 const index2 = instance.syncIndex; 6059 instance.syncIndex += 1; 6060 let hook; 6061 if (!instance.didInitialize) { 6062 hook = { 6063 store: store2, 6064 selector: selector2, 6065 a1, 6066 a2, 6067 a3, 6068 value: selector2(store2.getSnapshot(), a1, a2, a3), 6069 didChange: false 6070 }; 6071 instance.syncHooks.push(hook); 6072 } else { 6073 hook = instance.syncHooks[index2]; 6074 if (hook.store !== store2 || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) { 6075 if (hook.store !== store2) { 6076 instance.didChangeStore = true; 6077 } 6078 hook.store = store2; 6079 hook.selector = selector2; 6080 hook.a1 = a1; 6081 hook.a2 = a2; 6082 hook.a3 = a3; 6083 hook.didChange = true; 6084 } 6085 } 6086 return hook.value; 6087 } 6088 function useStoreLegacy(store2, selector2, a1, a2, a3) { 6089 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store2.subscribe, store2.getSnapshot, store2.getSnapshot, (state) => selector2(state, a1, a2, a3)); 6090 } 6091 6092 // node_modules/@base-ui/utils/esm/store/Store.js 6093 var Store = class { 6094 /** 6095 * The current state of the store. 6096 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}. 6097 * To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState). 6098 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers. 6099 * 6100 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification. 6101 */ 6102 // Internal state to handle recursive `setState()` calls 6103 constructor(state) { 6104 this.state = state; 6105 this.listeners = /* @__PURE__ */ new Set(); 6106 this.updateTick = 0; 6107 } 6108 /** 6109 * Registers a listener that will be called whenever the store's state changes. 6110 * 6111 * @param fn The listener function to be called on state changes. 6112 * @returns A function to unsubscribe the listener. 6113 */ 6114 subscribe = (fn) => { 6115 this.listeners.add(fn); 6116 return () => { 6117 this.listeners.delete(fn); 6118 }; 6119 }; 6120 /** 6121 * Returns the current state of the store. 6122 */ 6123 getSnapshot = () => { 6124 return this.state; 6125 }; 6126 /** 6127 * Updates the entire store's state and notifies all registered listeners. 6128 * 6129 * @param newState The new state to set for the store. 6130 */ 6131 setState(newState) { 6132 if (this.state === newState) { 6133 return; 6134 } 6135 this.state = newState; 6136 this.updateTick += 1; 6137 const currentTick = this.updateTick; 6138 for (const listener of this.listeners) { 6139 if (currentTick !== this.updateTick) { 6140 return; 6141 } 6142 listener(newState); 6143 } 6144 } 6145 /** 6146 * Merges the provided changes into the current state and notifies listeners if there are changes. 6147 * 6148 * @param changes An object containing the changes to apply to the current state. 6149 */ 6150 update(changes) { 6151 for (const key in changes) { 6152 if (!Object.is(this.state[key], changes[key])) { 6153 this.setState({ 6154 ...this.state, 6155 ...changes 6156 }); 6157 return; 6158 } 6159 } 6160 } 6161 /** 6162 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed. 6163 * 6164 * @param key The key in the store's state to update. 6165 * @param value The new value to set for the specified key. 6166 */ 6167 set(key, value) { 6168 if (!Object.is(this.state[key], value)) { 6169 this.setState({ 6170 ...this.state, 6171 [key]: value 6172 }); 6173 } 6174 } 6175 /** 6176 * Gives the state a new reference and updates all registered listeners. 6177 */ 6178 notifyAll() { 6179 const newState = { 6180 ...this.state 6181 }; 6182 this.setState(newState); 6183 } 6184 use(selector2, a1, a2, a3) { 6185 return useStore(this, selector2, a1, a2, a3); 6186 } 6187 }; 6188 6189 // node_modules/@base-ui/utils/esm/store/ReactStore.js 6190 var React31 = __toESM(require_react(), 1); 6191 var ReactStore = class extends Store { 6192 /** 6193 * Creates a new ReactStore instance. 6194 * 6195 * @param state Initial state of the store. 6196 * @param context Non-reactive context values. 6197 * @param selectors Optional selectors for use with `useState`. 6198 */ 6199 constructor(state, context = {}, selectors4) { 6200 super(state); 6201 this.context = context; 6202 this.selectors = selectors4; 6203 } 6204 /** 6205 * Non-reactive values such as refs, callbacks, etc. 6206 */ 6207 /** 6208 * Synchronizes a single external value into the store. 6209 * 6210 * Note that the while the value in `state` is updated immediately, the value returned 6211 * by `useState` is updated before the next render (similarly to React's `useState`). 6212 */ 6213 useSyncedValue(key, value) { 6214 React31.useDebugValue(key); 6215 useIsoLayoutEffect(() => { 6216 if (this.state[key] !== value) { 6217 this.set(key, value); 6218 } 6219 }, [key, value]); 6220 } 6221 /** 6222 * Synchronizes a single external value into the store and 6223 * cleans it up (sets to `undefined`) on unmount. 6224 * 6225 * Note that the while the value in `state` is updated immediately, the value returned 6226 * by `useState` is updated before the next render (similarly to React's `useState`). 6227 */ 6228 useSyncedValueWithCleanup(key, value) { 6229 const store2 = this; 6230 useIsoLayoutEffect(() => { 6231 if (store2.state[key] !== value) { 6232 store2.set(key, value); 6233 } 6234 return () => { 6235 store2.set(key, void 0); 6236 }; 6237 }, [store2, key, value]); 6238 } 6239 /** 6240 * Synchronizes multiple external values into the store. 6241 * 6242 * Note that the while the values in `state` are updated immediately, the values returned 6243 * by `useState` are updated before the next render (similarly to React's `useState`). 6244 */ 6245 useSyncedValues(statePart) { 6246 const store2 = this; 6247 if (true) { 6248 React31.useDebugValue(statePart, (p2) => Object.keys(p2)); 6249 const keys = React31.useRef(Object.keys(statePart)).current; 6250 const nextKeys = Object.keys(statePart); 6251 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) { 6252 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable."); 6253 } 6254 } 6255 const dependencies = Object.values(statePart); 6256 useIsoLayoutEffect(() => { 6257 store2.update(statePart); 6258 }, [store2, ...dependencies]); 6259 } 6260 /** 6261 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled` 6262 * is non-undefined, the store's state at `key` is updated to match `controlled`. 6263 */ 6264 useControlledProp(key, controlled) { 6265 React31.useDebugValue(key); 6266 const isControlled = controlled !== void 0; 6267 useIsoLayoutEffect(() => { 6268 if (isControlled && !Object.is(this.state[key], controlled)) { 6269 super.setState({ 6270 ...this.state, 6271 [key]: controlled 6272 }); 6273 } 6274 }, [key, controlled, isControlled]); 6275 if (true) { 6276 const cache = this.controlledValues ??= /* @__PURE__ */ new Map(); 6277 if (!cache.has(key)) { 6278 cache.set(key, isControlled); 6279 } 6280 const previouslyControlled = cache.get(key); 6281 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) { 6282 console.error(`A component is changing the $isControlled ? "" : "un"}controlled state of $key.toString()} to be $isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`); 6283 } 6284 } 6285 } 6286 /** Gets the current value from the store using a selector with the provided key. 6287 * 6288 * @param key Key of the selector to use. 6289 */ 6290 select(key, a1, a2, a3) { 6291 const selector2 = this.selectors[key]; 6292 return selector2(this.state, a1, a2, a3); 6293 } 6294 /** 6295 * Returns a value from the store's state using a selector function. 6296 * Used to subscribe to specific parts of the state. 6297 * This methods causes a rerender whenever the selected state changes. 6298 * 6299 * @param key Key of the selector to use. 6300 */ 6301 useState(key, a1, a2, a3) { 6302 React31.useDebugValue(key); 6303 return useStore(this, this.selectors[key], a1, a2, a3); 6304 } 6305 /** 6306 * Wraps a function with `useStableCallback` to ensure it has a stable reference 6307 * and assigns it to the context. 6308 * 6309 * @param key Key of the event callback. Must be a function in the context. 6310 * @param fn Function to assign. 6311 */ 6312 useContextCallback(key, fn) { 6313 React31.useDebugValue(key); 6314 const stableFunction = useStableCallback(fn ?? NOOP); 6315 this.context[key] = stableFunction; 6316 } 6317 /** 6318 * Returns a stable setter function for a specific key in the store's state. 6319 * It's commonly used to pass as a ref callback to React elements. 6320 * 6321 * @param key Key of the state to set. 6322 */ 6323 useStateSetter(key) { 6324 const ref = React31.useRef(void 0); 6325 if (ref.current === void 0) { 6326 ref.current = (value) => { 6327 this.set(key, value); 6328 }; 6329 } 6330 return ref.current; 6331 } 6332 /** 6333 * Observes changes derived from the store's selectors and calls the listener when the selected value changes. 6334 * 6335 * @param key Key of the selector to observe. 6336 * @param listener Listener function called when the selector result changes. 6337 */ 6338 observe(selector2, listener) { 6339 let selectFn; 6340 if (typeof selector2 === "function") { 6341 selectFn = selector2; 6342 } else { 6343 selectFn = this.selectors[selector2]; 6344 } 6345 let prevValue = selectFn(this.state); 6346 listener(prevValue, prevValue, this); 6347 return this.subscribe((nextState) => { 6348 const nextValue = selectFn(nextState); 6349 if (!Object.is(prevValue, nextValue)) { 6350 const oldValue = prevValue; 6351 prevValue = nextValue; 6352 listener(nextValue, oldValue, this); 6353 } 6354 }); 6355 } 6356 }; 6357 6358 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js 6359 var selectors = { 6360 open: createSelector((state) => state.open), 6361 transitionStatus: createSelector((state) => state.transitionStatus), 6362 domReferenceElement: createSelector((state) => state.domReferenceElement), 6363 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement), 6364 floatingElement: createSelector((state) => state.floatingElement), 6365 floatingId: createSelector((state) => state.floatingId) 6366 }; 6367 var FloatingRootStore = class extends ReactStore { 6368 constructor(options) { 6369 const { 6370 syncOnly, 6371 nested, 6372 onOpenChange, 6373 triggerElements, 6374 ...initialState 6375 } = options; 6376 super({ 6377 ...initialState, 6378 positionReference: initialState.referenceElement, 6379 domReferenceElement: initialState.referenceElement 6380 }, { 6381 onOpenChange, 6382 dataRef: { 6383 current: {} 6384 }, 6385 events: createEventEmitter(), 6386 nested, 6387 triggerElements 6388 }, selectors); 6389 this.syncOnly = syncOnly; 6390 } 6391 /** 6392 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction. 6393 */ 6394 syncOpenEvent = (newOpen, event) => { 6395 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing 6396 // click events to upgrade a hover-open. 6397 event != null && isClickLikeEvent(event)) { 6398 this.context.dataRef.current.openEvent = newOpen ? event : void 0; 6399 } 6400 }; 6401 /** 6402 * Runs the root-owned side effects for an open state change. 6403 */ 6404 dispatchOpenChange = (newOpen, eventDetails) => { 6405 this.syncOpenEvent(newOpen, eventDetails.event); 6406 const details = { 6407 open: newOpen, 6408 reason: eventDetails.reason, 6409 nativeEvent: eventDetails.event, 6410 nested: this.context.nested, 6411 triggerElement: eventDetails.trigger 6412 }; 6413 this.context.events.emit("openchange", details); 6414 }; 6415 /** 6416 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments. 6417 * 6418 * @param newOpen The new open state. 6419 * @param eventDetails Details about the event that triggered the open state change. 6420 */ 6421 setOpen = (newOpen, eventDetails) => { 6422 if (this.syncOnly) { 6423 this.context.onOpenChange?.(newOpen, eventDetails); 6424 return; 6425 } 6426 this.dispatchOpenChange(newOpen, eventDetails); 6427 this.context.onOpenChange?.(newOpen, eventDetails); 6428 }; 6429 }; 6430 6431 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js 6432 var React32 = __toESM(require_react(), 1); 6433 function useTriggerRegistration(id, store2) { 6434 const registeredElementIdRef = React32.useRef(null); 6435 const registeredElementRef = React32.useRef(null); 6436 return React32.useCallback((element) => { 6437 if (id === void 0) { 6438 return; 6439 } 6440 if (registeredElementIdRef.current !== null) { 6441 const registeredId = registeredElementIdRef.current; 6442 const registeredElement = registeredElementRef.current; 6443 const currentElement = store2.context.triggerElements.getById(registeredId); 6444 if (registeredElement && currentElement === registeredElement) { 6445 store2.context.triggerElements.delete(registeredId); 6446 } 6447 registeredElementIdRef.current = null; 6448 registeredElementRef.current = null; 6449 } 6450 if (element !== null) { 6451 registeredElementIdRef.current = id; 6452 registeredElementRef.current = element; 6453 store2.context.triggerElements.add(id, element); 6454 } 6455 }, [store2, id]); 6456 } 6457 function useTriggerDataForwarding(triggerId, triggerElementRef, store2, stateUpdates) { 6458 const isMountedByThisTrigger = store2.useState("isMountedByTrigger", triggerId); 6459 const baseRegisterTrigger = useTriggerRegistration(triggerId, store2); 6460 const registerTrigger = useStableCallback((element) => { 6461 baseRegisterTrigger(element); 6462 if (!element || !store2.select("open")) { 6463 return; 6464 } 6465 const activeTriggerId = store2.select("activeTriggerId"); 6466 if (activeTriggerId === triggerId) { 6467 store2.update({ 6468 activeTriggerElement: element, 6469 ...stateUpdates 6470 }); 6471 return; 6472 } 6473 if (activeTriggerId == null) { 6474 store2.update({ 6475 activeTriggerId: triggerId, 6476 activeTriggerElement: element, 6477 ...stateUpdates 6478 }); 6479 } 6480 }); 6481 useIsoLayoutEffect(() => { 6482 if (isMountedByThisTrigger) { 6483 store2.update({ 6484 activeTriggerElement: triggerElementRef.current, 6485 ...stateUpdates 6486 }); 6487 } 6488 }, [isMountedByThisTrigger, store2, triggerElementRef, ...Object.values(stateUpdates)]); 6489 return { 6490 registerTrigger, 6491 isMountedByThisTrigger 6492 }; 6493 } 6494 function useImplicitActiveTrigger(store2) { 6495 const open = store2.useState("open"); 6496 useIsoLayoutEffect(() => { 6497 if (open && !store2.select("activeTriggerId") && store2.context.triggerElements.size === 1) { 6498 const iteratorResult = store2.context.triggerElements.entries().next(); 6499 if (!iteratorResult.done) { 6500 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value; 6501 store2.update({ 6502 activeTriggerId: implicitTriggerId, 6503 activeTriggerElement: implicitTriggerElement 6504 }); 6505 } 6506 } 6507 }, [open, store2]); 6508 } 6509 function useOpenStateTransitions(open, store2, onUnmount) { 6510 const { 6511 mounted, 6512 setMounted, 6513 transitionStatus 6514 } = useTransitionStatus(open); 6515 store2.useSyncedValues({ 6516 mounted, 6517 transitionStatus 6518 }); 6519 const forceUnmount = useStableCallback(() => { 6520 setMounted(false); 6521 store2.update({ 6522 activeTriggerId: null, 6523 activeTriggerElement: null, 6524 mounted: false 6525 }); 6526 onUnmount?.(); 6527 store2.context.onOpenChangeComplete?.(false); 6528 }); 6529 const preventUnmountingOnClose = store2.useState("preventUnmountingOnClose"); 6530 useOpenChangeComplete({ 6531 enabled: !preventUnmountingOnClose, 6532 open, 6533 ref: store2.context.popupRef, 6534 onComplete() { 6535 if (!open) { 6536 forceUnmount(); 6537 } 6538 } 6539 }); 6540 return { 6541 forceUnmount, 6542 transitionStatus 6543 }; 6544 } 6545 6546 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js 6547 var PopupTriggerMap = class { 6548 constructor() { 6549 this.elementsSet = /* @__PURE__ */ new Set(); 6550 this.idMap = /* @__PURE__ */ new Map(); 6551 } 6552 /** 6553 * Adds a trigger element with the given ID. 6554 * 6555 * Note: The provided element is assumed to not be registered under multiple IDs. 6556 */ 6557 add(id, element) { 6558 const existingElement = this.idMap.get(id); 6559 if (existingElement === element) { 6560 return; 6561 } 6562 if (existingElement !== void 0) { 6563 this.elementsSet.delete(existingElement); 6564 } 6565 this.elementsSet.add(element); 6566 this.idMap.set(id, element); 6567 if (true) { 6568 if (this.elementsSet.size !== this.idMap.size) { 6569 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap."); 6570 } 6571 } 6572 } 6573 /** 6574 * Removes the trigger element with the given ID. 6575 */ 6576 delete(id) { 6577 const element = this.idMap.get(id); 6578 if (element) { 6579 this.elementsSet.delete(element); 6580 this.idMap.delete(id); 6581 } 6582 } 6583 /** 6584 * Whether the given element is registered as a trigger. 6585 */ 6586 hasElement(element) { 6587 return this.elementsSet.has(element); 6588 } 6589 /** 6590 * Whether there is a registered trigger element matching the given predicate. 6591 */ 6592 hasMatchingElement(predicate) { 6593 for (const element of this.elementsSet) { 6594 if (predicate(element)) { 6595 return true; 6596 } 6597 } 6598 return false; 6599 } 6600 /** 6601 * Returns the trigger element associated with the given ID, or undefined if no such element exists. 6602 */ 6603 getById(id) { 6604 return this.idMap.get(id); 6605 } 6606 /** 6607 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element]. 6608 */ 6609 entries() { 6610 return this.idMap.entries(); 6611 } 6612 /** 6613 * Returns an iterable of all registered trigger elements. 6614 */ 6615 elements() { 6616 return this.elementsSet.values(); 6617 } 6618 /** 6619 * Returns the number of registered trigger elements. 6620 */ 6621 get size() { 6622 return this.idMap.size; 6623 } 6624 }; 6625 6626 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js 6627 function getEmptyRootContext() { 6628 return new FloatingRootStore({ 6629 open: false, 6630 transitionStatus: void 0, 6631 floatingElement: null, 6632 referenceElement: null, 6633 triggerElements: new PopupTriggerMap(), 6634 floatingId: "", 6635 syncOnly: false, 6636 nested: false, 6637 onOpenChange: void 0 6638 }); 6639 } 6640 6641 // node_modules/@base-ui/react/esm/utils/popups/store.js 6642 function createInitialPopupStoreState() { 6643 return { 6644 open: false, 6645 openProp: void 0, 6646 mounted: false, 6647 transitionStatus: void 0, 6648 floatingRootContext: getEmptyRootContext(), 6649 preventUnmountingOnClose: false, 6650 payload: void 0, 6651 activeTriggerId: null, 6652 activeTriggerElement: null, 6653 triggerIdProp: void 0, 6654 popupElement: null, 6655 positionerElement: null, 6656 activeTriggerProps: EMPTY_OBJECT, 6657 inactiveTriggerProps: EMPTY_OBJECT, 6658 popupProps: EMPTY_OBJECT 6659 }; 6660 } 6661 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId); 6662 var popupStoreSelectors = { 6663 open: createSelector((state) => state.openProp ?? state.open), 6664 mounted: createSelector((state) => state.mounted), 6665 transitionStatus: createSelector((state) => state.transitionStatus), 6666 floatingRootContext: createSelector((state) => state.floatingRootContext), 6667 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose), 6668 payload: createSelector((state) => state.payload), 6669 activeTriggerId: activeTriggerIdSelector, 6670 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null), 6671 /** 6672 * Whether the trigger with the given ID was used to open the popup. 6673 */ 6674 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId), 6675 /** 6676 * Whether the popup is open and was activated by a trigger with the given ID. 6677 */ 6678 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open), 6679 /** 6680 * Whether the popup is mounted and was activated by a trigger with the given ID. 6681 */ 6682 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted), 6683 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps), 6684 popupProps: createSelector((state) => state.popupProps), 6685 popupElement: createSelector((state) => state.popupElement), 6686 positionerElement: createSelector((state) => state.positionerElement) 6687 }; 6688 6689 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js 6690 function useFloatingRootContext(options) { 6691 const { 6692 open = false, 6693 onOpenChange, 6694 elements = {} 6695 } = options; 6696 const floatingId = useId(); 6697 const nested = useFloatingParentNodeId() != null; 6698 if (true) { 6699 const optionDomReference = elements.reference; 6700 if (optionDomReference && !isElement(optionDomReference)) { 6701 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead."); 6702 } 6703 } 6704 const store2 = useRefWithInit(() => new FloatingRootStore({ 6705 open, 6706 transitionStatus: void 0, 6707 onOpenChange, 6708 referenceElement: elements.reference ?? null, 6709 floatingElement: elements.floating ?? null, 6710 triggerElements: new PopupTriggerMap(), 6711 floatingId, 6712 syncOnly: false, 6713 nested 6714 })).current; 6715 useIsoLayoutEffect(() => { 6716 const valuesToSync = { 6717 open, 6718 floatingId 6719 }; 6720 if (elements.reference !== void 0) { 6721 valuesToSync.referenceElement = elements.reference; 6722 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null; 6723 } 6724 if (elements.floating !== void 0) { 6725 valuesToSync.floatingElement = elements.floating; 6726 } 6727 store2.update(valuesToSync); 6728 }, [open, floatingId, elements.reference, elements.floating, store2]); 6729 store2.context.onOpenChange = onOpenChange; 6730 store2.context.nested = nested; 6731 return store2; 6732 } 6733 6734 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js 6735 function useFloating2(options = {}) { 6736 const { 6737 nodeId, 6738 externalTree 6739 } = options; 6740 const internalRootStore = useFloatingRootContext(options); 6741 const rootContext = options.rootContext || internalRootStore; 6742 const rootContextElements = { 6743 reference: rootContext.useState("referenceElement"), 6744 floating: rootContext.useState("floatingElement"), 6745 domReference: rootContext.useState("domReferenceElement") 6746 }; 6747 const [positionReference, setPositionReferenceRaw] = React33.useState(null); 6748 const domReferenceRef = React33.useRef(null); 6749 const tree = useFloatingTree(externalTree); 6750 useIsoLayoutEffect(() => { 6751 if (rootContextElements.domReference) { 6752 domReferenceRef.current = rootContextElements.domReference; 6753 } 6754 }, [rootContextElements.domReference]); 6755 const position = useFloating({ 6756 ...options, 6757 elements: { 6758 ...rootContextElements, 6759 ...positionReference && { 6760 reference: positionReference 6761 } 6762 } 6763 }); 6764 const setPositionReference = React33.useCallback((node) => { 6765 const computedPositionReference = isElement(node) ? { 6766 getBoundingClientRect: () => node.getBoundingClientRect(), 6767 getClientRects: () => node.getClientRects(), 6768 contextElement: node 6769 } : node; 6770 setPositionReferenceRaw(computedPositionReference); 6771 position.refs.setReference(computedPositionReference); 6772 }, [position.refs]); 6773 const [localDomReference, setLocalDomReference] = React33.useState(void 0); 6774 const [localFloatingElement, setLocalFloatingElement] = React33.useState(null); 6775 rootContext.useSyncedValue("referenceElement", localDomReference ?? null); 6776 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null; 6777 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement); 6778 rootContext.useSyncedValue("floatingElement", localFloatingElement); 6779 const setReference = React33.useCallback((node) => { 6780 if (isElement(node) || node === null) { 6781 domReferenceRef.current = node; 6782 setLocalDomReference(node); 6783 } 6784 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to 6785 // `null` to support `positionReference` + an unstable `reference` 6786 // callback ref. 6787 node !== null && !isElement(node)) { 6788 position.refs.setReference(node); 6789 } 6790 }, [position.refs, setLocalDomReference]); 6791 const setFloating = React33.useCallback((node) => { 6792 setLocalFloatingElement(node); 6793 position.refs.setFloating(node); 6794 }, [position.refs]); 6795 const refs = React33.useMemo(() => ({ 6796 ...position.refs, 6797 setReference, 6798 setFloating, 6799 setPositionReference, 6800 domReference: domReferenceRef 6801 }), [position.refs, setReference, setFloating, setPositionReference]); 6802 const elements = React33.useMemo(() => ({ 6803 ...position.elements, 6804 domReference: rootContextElements.domReference 6805 }), [position.elements, rootContextElements.domReference]); 6806 const open = rootContext.useState("open"); 6807 const floatingId = rootContext.useState("floatingId"); 6808 const context = React33.useMemo(() => ({ 6809 ...position, 6810 dataRef: rootContext.context.dataRef, 6811 open, 6812 onOpenChange: rootContext.setOpen, 6813 events: rootContext.context.events, 6814 floatingId, 6815 refs, 6816 elements, 6817 nodeId, 6818 rootStore: rootContext 6819 }), [position, refs, elements, nodeId, rootContext, open, floatingId]); 6820 useIsoLayoutEffect(() => { 6821 rootContext.context.dataRef.current.floatingContext = context; 6822 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId); 6823 if (node) { 6824 node.context = context; 6825 } 6826 }); 6827 return React33.useMemo(() => ({ 6828 ...position, 6829 context, 6830 refs, 6831 elements, 6832 rootStore: rootContext 6833 }), [position, refs, elements, context, rootContext]); 6834 } 6835 6836 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js 6837 function useSyncedFloatingRootContext(options) { 6838 const { 6839 popupStore, 6840 treatPopupAsFloatingElement = false, 6841 onOpenChange 6842 } = options; 6843 const floatingId = useId(); 6844 const nested = useFloatingParentNodeId() != null; 6845 const open = popupStore.useState("open"); 6846 const referenceElement = popupStore.useState("activeTriggerElement"); 6847 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement"); 6848 const triggerElements = popupStore.context.triggerElements; 6849 const store2 = useRefWithInit(() => new FloatingRootStore({ 6850 open, 6851 transitionStatus: void 0, 6852 referenceElement, 6853 floatingElement, 6854 triggerElements, 6855 onOpenChange, 6856 floatingId, 6857 syncOnly: true, 6858 nested 6859 })).current; 6860 useIsoLayoutEffect(() => { 6861 const valuesToSync = { 6862 open, 6863 floatingId, 6864 referenceElement, 6865 floatingElement 6866 }; 6867 if (isElement(referenceElement)) { 6868 valuesToSync.domReferenceElement = referenceElement; 6869 } 6870 if (store2.state.positionReference === store2.state.referenceElement) { 6871 valuesToSync.positionReference = referenceElement; 6872 } 6873 store2.update(valuesToSync); 6874 }, [open, floatingId, referenceElement, floatingElement, store2]); 6875 store2.context.onOpenChange = onOpenChange; 6876 store2.context.nested = nested; 6877 return store2; 6878 } 6879 6880 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js 6881 var React34 = __toESM(require_react(), 1); 6882 var isMacSafari = isMac && isSafari; 6883 function useFocus(context, props = {}) { 6884 const store2 = "rootStore" in context ? context.rootStore : context; 6885 const { 6886 events, 6887 dataRef 6888 } = store2.context; 6889 const { 6890 enabled = true, 6891 delay 6892 } = props; 6893 const blockFocusRef = React34.useRef(false); 6894 const blockedReferenceRef = React34.useRef(null); 6895 const timeout = useTimeout(); 6896 const keyboardModalityRef = React34.useRef(true); 6897 React34.useEffect(() => { 6898 const domReference = store2.select("domReferenceElement"); 6899 if (!enabled) { 6900 return void 0; 6901 } 6902 const win = getWindow(domReference); 6903 function onBlur() { 6904 const currentDomReference = store2.select("domReferenceElement"); 6905 if (!store2.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) { 6906 blockFocusRef.current = true; 6907 } 6908 } 6909 function onKeyDown() { 6910 keyboardModalityRef.current = true; 6911 } 6912 function onPointerDown() { 6913 keyboardModalityRef.current = false; 6914 } 6915 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true)); 6916 }, [store2, enabled]); 6917 React34.useEffect(() => { 6918 if (!enabled) { 6919 return void 0; 6920 } 6921 function onOpenChangeLocal(details) { 6922 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) { 6923 const referenceElement = store2.select("domReferenceElement"); 6924 if (isElement(referenceElement)) { 6925 blockedReferenceRef.current = referenceElement; 6926 blockFocusRef.current = true; 6927 } 6928 } 6929 } 6930 events.on("openchange", onOpenChangeLocal); 6931 return () => { 6932 events.off("openchange", onOpenChangeLocal); 6933 }; 6934 }, [events, enabled, store2]); 6935 const reference = React34.useMemo(() => ({ 6936 onMouseLeave() { 6937 blockFocusRef.current = false; 6938 blockedReferenceRef.current = null; 6939 }, 6940 onFocus(event) { 6941 const focusTarget = event.currentTarget; 6942 if (blockFocusRef.current) { 6943 if (blockedReferenceRef.current === focusTarget) { 6944 return; 6945 } 6946 blockFocusRef.current = false; 6947 blockedReferenceRef.current = null; 6948 } 6949 const target = getTarget(event.nativeEvent); 6950 if (isElement(target)) { 6951 if (isMacSafari && !event.relatedTarget) { 6952 if (!keyboardModalityRef.current && !isTypeableElement(target)) { 6953 return; 6954 } 6955 } else if (!matchesFocusVisible(target)) { 6956 return; 6957 } 6958 } 6959 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements); 6960 const { 6961 nativeEvent, 6962 currentTarget 6963 } = event; 6964 const delayValue = typeof delay === "function" ? delay() : delay; 6965 if (store2.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) { 6966 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 6967 return; 6968 } 6969 timeout.start(delayValue, () => { 6970 if (blockFocusRef.current) { 6971 return; 6972 } 6973 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 6974 }); 6975 }, 6976 onBlur(event) { 6977 blockFocusRef.current = false; 6978 blockedReferenceRef.current = null; 6979 const relatedTarget = event.relatedTarget; 6980 const nativeEvent = event.nativeEvent; 6981 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside"; 6982 timeout.start(0, () => { 6983 const domReference = store2.select("domReferenceElement"); 6984 const activeEl = activeElement(ownerDocument(domReference)); 6985 if (!relatedTarget && activeEl === domReference) { 6986 return; 6987 } 6988 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) { 6989 return; 6990 } 6991 const nextFocusedElement = relatedTarget ?? activeEl; 6992 if (isTargetInsideEnabledTrigger(nextFocusedElement, store2.context.triggerElements)) { 6993 return; 6994 } 6995 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent)); 6996 }); 6997 } 6998 }), [dataRef, store2, timeout, delay]); 6999 return React34.useMemo(() => enabled ? { 7000 reference, 7001 trigger: reference 7002 } : {}, [enabled, reference]); 7003 } 7004 7005 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js 7006 var React35 = __toESM(require_react(), 1); 7007 7008 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js 7009 var HoverInteraction = class _HoverInteraction { 7010 constructor() { 7011 this.pointerType = void 0; 7012 this.interactedInside = false; 7013 this.handler = void 0; 7014 this.blockMouseMove = true; 7015 this.performedPointerEventsMutation = false; 7016 this.pointerEventsScopeElement = null; 7017 this.pointerEventsReferenceElement = null; 7018 this.pointerEventsFloatingElement = null; 7019 this.restTimeoutPending = false; 7020 this.openChangeTimeout = new Timeout(); 7021 this.restTimeout = new Timeout(); 7022 this.handleCloseOptions = void 0; 7023 } 7024 static create() { 7025 return new _HoverInteraction(); 7026 } 7027 dispose = () => { 7028 this.openChangeTimeout.clear(); 7029 this.restTimeout.clear(); 7030 }; 7031 disposeEffect = () => { 7032 return this.dispose; 7033 }; 7034 }; 7035 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap(); 7036 function clearSafePolygonPointerEventsMutation(instance) { 7037 if (!instance.performedPointerEventsMutation) { 7038 return; 7039 } 7040 const scopeElement = instance.pointerEventsScopeElement; 7041 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) { 7042 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events"); 7043 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events"); 7044 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events"); 7045 pointerEventsMutationOwnerByScopeElement.delete(scopeElement); 7046 } 7047 instance.performedPointerEventsMutation = false; 7048 instance.pointerEventsScopeElement = null; 7049 instance.pointerEventsReferenceElement = null; 7050 instance.pointerEventsFloatingElement = null; 7051 } 7052 function applySafePolygonPointerEventsMutation(instance, options) { 7053 const { 7054 scopeElement, 7055 referenceElement, 7056 floatingElement 7057 } = options; 7058 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement); 7059 if (existingOwner && existingOwner !== instance) { 7060 clearSafePolygonPointerEventsMutation(existingOwner); 7061 } 7062 clearSafePolygonPointerEventsMutation(instance); 7063 instance.performedPointerEventsMutation = true; 7064 instance.pointerEventsScopeElement = scopeElement; 7065 instance.pointerEventsReferenceElement = referenceElement; 7066 instance.pointerEventsFloatingElement = floatingElement; 7067 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance); 7068 scopeElement.style.pointerEvents = "none"; 7069 referenceElement.style.pointerEvents = "auto"; 7070 floatingElement.style.pointerEvents = "auto"; 7071 } 7072 function useHoverInteractionSharedState(store2) { 7073 const instance = useRefWithInit(HoverInteraction.create).current; 7074 const data = store2.context.dataRef.current; 7075 if (!data.hoverInteractionState) { 7076 data.hoverInteractionState = instance; 7077 } 7078 useOnMount(data.hoverInteractionState.disposeEffect); 7079 return data.hoverInteractionState; 7080 } 7081 7082 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js 7083 function useHoverFloatingInteraction(context, parameters = {}) { 7084 const store2 = "rootStore" in context ? context.rootStore : context; 7085 const open = store2.useState("open"); 7086 const floatingElement = store2.useState("floatingElement"); 7087 const domReferenceElement = store2.useState("domReferenceElement"); 7088 const { 7089 dataRef 7090 } = store2.context; 7091 const { 7092 enabled = true, 7093 closeDelay: closeDelayProp = 0, 7094 nodeId: nodeIdProp 7095 } = parameters; 7096 const instance = useHoverInteractionSharedState(store2); 7097 const tree = useFloatingTree(); 7098 const parentId = useFloatingParentNodeId(); 7099 const isClickLikeOpenEvent2 = useStableCallback(() => { 7100 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 7101 }); 7102 const isHoverOpen = useStableCallback(() => { 7103 const type = dataRef.current.openEvent?.type; 7104 return type?.includes("mouse") && type !== "mousedown"; 7105 }); 7106 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => { 7107 return isTargetInsideEnabledTrigger(target, store2.context.triggerElements); 7108 }); 7109 const closeWithDelay = React35.useCallback((event) => { 7110 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType); 7111 const close = () => { 7112 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 7113 tree?.events.emit("floating.closed", event); 7114 }; 7115 if (closeDelay) { 7116 instance.openChangeTimeout.start(closeDelay, close); 7117 } else { 7118 instance.openChangeTimeout.clear(); 7119 close(); 7120 } 7121 }, [closeDelayProp, store2, instance, tree]); 7122 const clearPointerEvents = useStableCallback(() => { 7123 clearSafePolygonPointerEventsMutation(instance); 7124 }); 7125 const handleInteractInside = useStableCallback((event) => { 7126 const target = getTarget(event); 7127 if (!isInteractiveElement(target)) { 7128 instance.interactedInside = false; 7129 return; 7130 } 7131 instance.interactedInside = target?.closest("[aria-haspopup]") != null; 7132 }); 7133 useIsoLayoutEffect(() => { 7134 if (!open) { 7135 instance.pointerType = void 0; 7136 instance.restTimeoutPending = false; 7137 instance.interactedInside = false; 7138 clearPointerEvents(); 7139 } 7140 }, [open, instance, clearPointerEvents]); 7141 React35.useEffect(() => { 7142 return clearPointerEvents; 7143 }, [clearPointerEvents]); 7144 useIsoLayoutEffect(() => { 7145 if (!enabled) { 7146 return void 0; 7147 } 7148 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) { 7149 const ref = domReferenceElement; 7150 const floatingEl = floatingElement; 7151 const doc = ownerDocument(floatingElement); 7152 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating; 7153 if (parentFloating) { 7154 parentFloating.style.pointerEvents = ""; 7155 } 7156 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body; 7157 applySafePolygonPointerEventsMutation(instance, { 7158 scopeElement, 7159 referenceElement: ref, 7160 floatingElement: floatingEl 7161 }); 7162 return () => { 7163 clearPointerEvents(); 7164 }; 7165 } 7166 return void 0; 7167 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]); 7168 const childClosedTimeout = useTimeout(); 7169 React35.useEffect(() => { 7170 if (!enabled) { 7171 return void 0; 7172 } 7173 function onFloatingMouseEnter() { 7174 instance.openChangeTimeout.clear(); 7175 childClosedTimeout.clear(); 7176 tree?.events.off("floating.closed", onNodeClosed); 7177 clearPointerEvents(); 7178 } 7179 function onFloatingMouseLeave(event) { 7180 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) { 7181 tree.events.on("floating.closed", onNodeClosed); 7182 return; 7183 } 7184 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) { 7185 return; 7186 } 7187 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp; 7188 const relatedTarget = event.relatedTarget; 7189 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget)); 7190 if (isMovingIntoDescendantFloating) { 7191 return; 7192 } 7193 if (instance.handler) { 7194 instance.handler(event); 7195 return; 7196 } 7197 clearPointerEvents(); 7198 if (!isClickLikeOpenEvent2()) { 7199 closeWithDelay(event); 7200 } 7201 } 7202 function onNodeClosed(event) { 7203 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) { 7204 return; 7205 } 7206 childClosedTimeout.start(0, () => { 7207 tree.events.off("floating.closed", onNodeClosed); 7208 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 7209 tree.events.emit("floating.closed", event); 7210 }); 7211 } 7212 const floating = floatingElement; 7213 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => { 7214 tree?.events.off("floating.closed", onNodeClosed); 7215 }); 7216 }, [enabled, floatingElement, store2, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]); 7217 } 7218 7219 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js 7220 var React36 = __toESM(require_react(), 1); 7221 var ReactDOM4 = __toESM(require_react_dom(), 1); 7222 var EMPTY_REF = { 7223 current: null 7224 }; 7225 function useHoverReferenceInteraction(context, props = {}) { 7226 const store2 = "rootStore" in context ? context.rootStore : context; 7227 const { 7228 dataRef, 7229 events 7230 } = store2.context; 7231 const { 7232 enabled = true, 7233 delay = 0, 7234 handleClose = null, 7235 mouseOnly = false, 7236 restMs = 0, 7237 move = true, 7238 triggerElementRef = EMPTY_REF, 7239 externalTree, 7240 isActiveTrigger = true, 7241 getHandleCloseContext, 7242 isClosing 7243 } = props; 7244 const tree = useFloatingTree(externalTree); 7245 const instance = useHoverInteractionSharedState(store2); 7246 const isHoverCloseActiveRef = React36.useRef(false); 7247 const handleCloseRef = useValueAsRef(handleClose); 7248 const delayRef = useValueAsRef(delay); 7249 const restMsRef = useValueAsRef(restMs); 7250 const enabledRef = useValueAsRef(enabled); 7251 const isClosingRef = useValueAsRef(isClosing); 7252 if (isActiveTrigger) { 7253 instance.handleCloseOptions = handleCloseRef.current?.__options; 7254 } 7255 const isClickLikeOpenEvent2 = useStableCallback(() => { 7256 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 7257 }); 7258 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => { 7259 return isTargetInsideEnabledTrigger(target, store2.context.triggerElements); 7260 }); 7261 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => { 7262 const allTriggers = store2.context.triggerElements; 7263 if (allTriggers.hasElement(currentTarget)) { 7264 return !currentDomReference || !contains(currentDomReference, currentTarget); 7265 } 7266 if (!isElement(target)) { 7267 return false; 7268 } 7269 const targetElement = target; 7270 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement)); 7271 }); 7272 const closeWithDelay = useStableCallback((event, runElseBranch = true) => { 7273 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType); 7274 if (closeDelay) { 7275 instance.openChangeTimeout.start(closeDelay, () => { 7276 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 7277 tree?.events.emit("floating.closed", event); 7278 }); 7279 } else if (runElseBranch) { 7280 instance.openChangeTimeout.clear(); 7281 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 7282 tree?.events.emit("floating.closed", event); 7283 } 7284 }); 7285 const cleanupMouseMoveHandler = useStableCallback(() => { 7286 if (!instance.handler) { 7287 return; 7288 } 7289 const doc = ownerDocument(store2.select("domReferenceElement")); 7290 doc.removeEventListener("mousemove", instance.handler); 7291 instance.handler = void 0; 7292 }); 7293 const clearPointerEvents = useStableCallback(() => { 7294 clearSafePolygonPointerEventsMutation(instance); 7295 }); 7296 React36.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]); 7297 React36.useEffect(() => { 7298 if (!enabled) { 7299 return void 0; 7300 } 7301 function onOpenChangeLocal(details) { 7302 if (!details.open) { 7303 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover; 7304 cleanupMouseMoveHandler(); 7305 instance.openChangeTimeout.clear(); 7306 instance.restTimeout.clear(); 7307 instance.blockMouseMove = true; 7308 instance.restTimeoutPending = false; 7309 } else { 7310 isHoverCloseActiveRef.current = false; 7311 } 7312 } 7313 events.on("openchange", onOpenChangeLocal); 7314 return () => { 7315 events.off("openchange", onOpenChangeLocal); 7316 }; 7317 }, [enabled, events, instance, cleanupMouseMoveHandler]); 7318 React36.useEffect(() => { 7319 if (!enabled) { 7320 return void 0; 7321 } 7322 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store2.select("domReferenceElement") : null); 7323 if (!isElement(trigger)) { 7324 return void 0; 7325 } 7326 function onMouseEnter(event) { 7327 instance.openChangeTimeout.clear(); 7328 instance.blockMouseMove = false; 7329 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 7330 return; 7331 } 7332 const restMsValue = getRestMs(restMsRef.current); 7333 const openDelay = getDelay(delayRef.current, "open", instance.pointerType); 7334 const eventTarget = getTarget(event); 7335 const currentTarget = event.currentTarget ?? null; 7336 const currentDomReference = store2.select("domReferenceElement"); 7337 let triggerNode = currentTarget; 7338 if (isElement(eventTarget) && !store2.context.triggerElements.hasElement(eventTarget)) { 7339 for (const triggerElement of store2.context.triggerElements.elements()) { 7340 if (contains(triggerElement, eventTarget)) { 7341 triggerNode = triggerElement; 7342 break; 7343 } 7344 } 7345 } 7346 if (isElement(currentTarget) && isElement(currentDomReference) && !store2.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) { 7347 triggerNode = currentDomReference; 7348 } 7349 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget); 7350 const isOpen = store2.select("open"); 7351 const isInClosingTransition = isClosingRef.current?.() ?? store2.select("transitionStatus") === "ending"; 7352 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current; 7353 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition; 7354 const isRestOnlyDelay = restMsValue > 0 && !openDelay; 7355 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition; 7356 const shouldOpen = !isOpen || isOverInactive; 7357 if (shouldOpenImmediately) { 7358 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 7359 return; 7360 } 7361 if (isRestOnlyDelay) { 7362 return; 7363 } 7364 if (openDelay) { 7365 instance.openChangeTimeout.start(openDelay, () => { 7366 if (shouldOpen) { 7367 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 7368 } 7369 }); 7370 } else if (shouldOpen) { 7371 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 7372 } 7373 } 7374 function onMouseLeave(event) { 7375 if (isClickLikeOpenEvent2()) { 7376 clearPointerEvents(); 7377 return; 7378 } 7379 cleanupMouseMoveHandler(); 7380 const domReferenceElement = store2.select("domReferenceElement"); 7381 const doc = ownerDocument(domReferenceElement); 7382 instance.restTimeout.clear(); 7383 instance.restTimeoutPending = false; 7384 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.(); 7385 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget); 7386 if (ignoreRelatedTargetTrigger) { 7387 return; 7388 } 7389 if (handleCloseRef.current && handleCloseContextBase) { 7390 if (!store2.select("open")) { 7391 instance.openChangeTimeout.clear(); 7392 } 7393 const currentTrigger = triggerElementRef.current; 7394 instance.handler = handleCloseRef.current({ 7395 ...handleCloseContextBase, 7396 tree, 7397 x: event.clientX, 7398 y: event.clientY, 7399 onClose() { 7400 clearPointerEvents(); 7401 cleanupMouseMoveHandler(); 7402 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store2.select("domReferenceElement")) { 7403 closeWithDelay(event, true); 7404 } 7405 } 7406 }); 7407 doc.addEventListener("mousemove", instance.handler); 7408 instance.handler(event); 7409 return; 7410 } 7411 const shouldClose = instance.pointerType === "touch" ? !contains(store2.select("floatingElement"), event.relatedTarget) : true; 7412 if (shouldClose) { 7413 closeWithDelay(event); 7414 } 7415 } 7416 if (move) { 7417 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, { 7418 once: true 7419 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 7420 } 7421 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 7422 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store2, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]); 7423 return React36.useMemo(() => { 7424 if (!enabled) { 7425 return void 0; 7426 } 7427 function setPointerRef(event) { 7428 instance.pointerType = event.pointerType; 7429 } 7430 return { 7431 onPointerDown: setPointerRef, 7432 onPointerEnter: setPointerRef, 7433 onMouseMove(event) { 7434 const { 7435 nativeEvent 7436 } = event; 7437 const trigger = event.currentTarget; 7438 const currentDomReference = store2.select("domReferenceElement"); 7439 const currentOpen = store2.select("open"); 7440 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target); 7441 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 7442 return; 7443 } 7444 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) { 7445 const floatingElement = store2.select("floatingElement"); 7446 if (floatingElement) { 7447 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body; 7448 applySafePolygonPointerEventsMutation(instance, { 7449 scopeElement, 7450 referenceElement: trigger, 7451 floatingElement 7452 }); 7453 } 7454 } 7455 const restMsValue = getRestMs(restMsRef.current); 7456 if (currentOpen && !isOverInactive || restMsValue === 0) { 7457 return; 7458 } 7459 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) { 7460 return; 7461 } 7462 instance.restTimeout.clear(); 7463 function handleMouseMove() { 7464 instance.restTimeoutPending = false; 7465 if (isClickLikeOpenEvent2()) { 7466 return; 7467 } 7468 const latestOpen = store2.select("open"); 7469 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) { 7470 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger)); 7471 } 7472 } 7473 if (instance.pointerType === "touch") { 7474 ReactDOM4.flushSync(() => { 7475 handleMouseMove(); 7476 }); 7477 } else if (isOverInactive && currentOpen) { 7478 handleMouseMove(); 7479 } else { 7480 instance.restTimeoutPending = true; 7481 instance.restTimeout.start(restMsValue, handleMouseMove); 7482 } 7483 } 7484 }; 7485 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store2, restMsRef]); 7486 } 7487 7488 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js 7489 var React37 = __toESM(require_react(), 1); 7490 function useInteractions(propsList = []) { 7491 const referenceDeps = propsList.map((key) => key?.reference); 7492 const floatingDeps = propsList.map((key) => key?.floating); 7493 const itemDeps = propsList.map((key) => key?.item); 7494 const triggerDeps = propsList.map((key) => key?.trigger); 7495 const getReferenceProps = React37.useCallback( 7496 (userProps) => mergeProps2(userProps, propsList, "reference"), 7497 // eslint-disable-next-line react-hooks/exhaustive-deps 7498 referenceDeps 7499 ); 7500 const getFloatingProps = React37.useCallback( 7501 (userProps) => mergeProps2(userProps, propsList, "floating"), 7502 // eslint-disable-next-line react-hooks/exhaustive-deps 7503 floatingDeps 7504 ); 7505 const getItemProps = React37.useCallback( 7506 (userProps) => mergeProps2(userProps, propsList, "item"), 7507 // eslint-disable-next-line react-hooks/exhaustive-deps 7508 itemDeps 7509 ); 7510 const getTriggerProps = React37.useCallback( 7511 (userProps) => mergeProps2(userProps, propsList, "trigger"), 7512 // eslint-disable-next-line react-hooks/exhaustive-deps 7513 triggerDeps 7514 ); 7515 return React37.useMemo(() => ({ 7516 getReferenceProps, 7517 getFloatingProps, 7518 getItemProps, 7519 getTriggerProps 7520 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]); 7521 } 7522 function mergeProps2(userProps, propsList, elementKey) { 7523 const eventHandlers = /* @__PURE__ */ new Map(); 7524 const isItem2 = elementKey === "item"; 7525 const outputProps = {}; 7526 if (elementKey === "floating") { 7527 outputProps.tabIndex = -1; 7528 outputProps[FOCUSABLE_ATTRIBUTE] = ""; 7529 } 7530 for (const key in userProps) { 7531 if (isItem2 && userProps) { 7532 if (key === ACTIVE_KEY || key === SELECTED_KEY) { 7533 continue; 7534 } 7535 } 7536 outputProps[key] = userProps[key]; 7537 } 7538 for (let i2 = 0; i2 < propsList.length; i2 += 1) { 7539 let props; 7540 const propsOrGetProps = propsList[i2]?.[elementKey]; 7541 if (typeof propsOrGetProps === "function") { 7542 props = userProps ? propsOrGetProps(userProps) : null; 7543 } else { 7544 props = propsOrGetProps; 7545 } 7546 if (!props) { 7547 continue; 7548 } 7549 mutablyMergeProps(outputProps, props, isItem2, eventHandlers); 7550 } 7551 mutablyMergeProps(outputProps, userProps, isItem2, eventHandlers); 7552 return outputProps; 7553 } 7554 function mutablyMergeProps(outputProps, props, isItem2, eventHandlers) { 7555 for (const key in props) { 7556 const value = props[key]; 7557 if (isItem2 && (key === ACTIVE_KEY || key === SELECTED_KEY)) { 7558 continue; 7559 } 7560 if (!key.startsWith("on")) { 7561 outputProps[key] = value; 7562 } else { 7563 if (!eventHandlers.has(key)) { 7564 eventHandlers.set(key, []); 7565 } 7566 if (typeof value === "function") { 7567 eventHandlers.get(key)?.push(value); 7568 outputProps[key] = (...args) => { 7569 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0); 7570 }; 7571 } 7572 } 7573 } 7574 } 7575 7576 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js 7577 var CURSOR_SPEED_THRESHOLD = 0.1; 7578 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD; 7579 var POLYGON_BUFFER = 0.5; 7580 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) { 7581 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi; 7582 } 7583 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) { 7584 let isInsideValue = false; 7585 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) { 7586 isInsideValue = !isInsideValue; 7587 } 7588 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) { 7589 isInsideValue = !isInsideValue; 7590 } 7591 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) { 7592 isInsideValue = !isInsideValue; 7593 } 7594 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) { 7595 isInsideValue = !isInsideValue; 7596 } 7597 return isInsideValue; 7598 } 7599 function isInsideRect(pointX, pointY, rect) { 7600 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height; 7601 } 7602 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) { 7603 const minX = Math.min(x1, x2); 7604 const maxX = Math.max(x1, x2); 7605 const minY = Math.min(y1, y2); 7606 const maxY = Math.max(y1, y2); 7607 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY; 7608 } 7609 function safePolygon(options = {}) { 7610 const { 7611 blockPointerEvents = false 7612 } = options; 7613 const timeout = new Timeout(); 7614 const fn = ({ 7615 x: x2, 7616 y: y2, 7617 placement, 7618 elements, 7619 onClose, 7620 nodeId, 7621 tree 7622 }) => { 7623 const side = placement?.split("-")[0]; 7624 let hasLanded = false; 7625 let lastX = null; 7626 let lastY = null; 7627 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0; 7628 function isCursorMovingSlowly(nextX, nextY) { 7629 const currentTime = performance.now(); 7630 const elapsedTime = currentTime - lastCursorTime; 7631 if (lastX === null || lastY === null || elapsedTime === 0) { 7632 lastX = nextX; 7633 lastY = nextY; 7634 lastCursorTime = currentTime; 7635 return false; 7636 } 7637 const deltaX = nextX - lastX; 7638 const deltaY = nextY - lastY; 7639 const distanceSquared = deltaX * deltaX + deltaY * deltaY; 7640 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED; 7641 lastX = nextX; 7642 lastY = nextY; 7643 lastCursorTime = currentTime; 7644 return distanceSquared < thresholdSquared; 7645 } 7646 function close() { 7647 timeout.clear(); 7648 onClose(); 7649 } 7650 return function onMouseMove(event) { 7651 timeout.clear(); 7652 const domReference = elements.domReference; 7653 const floating = elements.floating; 7654 if (!domReference || !floating || side == null || x2 == null || y2 == null) { 7655 return void 0; 7656 } 7657 const { 7658 clientX, 7659 clientY 7660 } = event; 7661 const target = getTarget(event); 7662 const isLeave = event.type === "mouseleave"; 7663 const isOverFloatingEl = contains(floating, target); 7664 const isOverReferenceEl = contains(domReference, target); 7665 if (isOverFloatingEl) { 7666 hasLanded = true; 7667 if (!isLeave) { 7668 return void 0; 7669 } 7670 } 7671 if (isOverReferenceEl) { 7672 hasLanded = false; 7673 if (!isLeave) { 7674 hasLanded = true; 7675 return void 0; 7676 } 7677 } 7678 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) { 7679 return void 0; 7680 } 7681 function hasOpenChildNode() { 7682 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0); 7683 } 7684 function closeIfNoOpenChild() { 7685 if (!hasOpenChildNode()) { 7686 close(); 7687 } 7688 } 7689 if (hasOpenChildNode()) { 7690 return void 0; 7691 } 7692 const refRect = domReference.getBoundingClientRect(); 7693 const rect = floating.getBoundingClientRect(); 7694 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2; 7695 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2; 7696 const isFloatingWider = rect.width > refRect.width; 7697 const isFloatingTaller = rect.height > refRect.height; 7698 const left = (isFloatingWider ? refRect : rect).left; 7699 const right = (isFloatingWider ? refRect : rect).right; 7700 const top = (isFloatingTaller ? refRect : rect).top; 7701 const bottom = (isFloatingTaller ? refRect : rect).bottom; 7702 if (side === "top" && y2 >= refRect.bottom - 1 || side === "bottom" && y2 <= refRect.top + 1 || side === "left" && x2 >= refRect.right - 1 || side === "right" && x2 <= refRect.left + 1) { 7703 closeIfNoOpenChild(); 7704 return void 0; 7705 } 7706 let isInsideTroughRect = false; 7707 switch (side) { 7708 case "top": 7709 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1); 7710 break; 7711 case "bottom": 7712 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1); 7713 break; 7714 case "left": 7715 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top); 7716 break; 7717 case "right": 7718 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top); 7719 break; 7720 default: 7721 } 7722 if (isInsideTroughRect) { 7723 return void 0; 7724 } 7725 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) { 7726 closeIfNoOpenChild(); 7727 return void 0; 7728 } 7729 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) { 7730 closeIfNoOpenChild(); 7731 return void 0; 7732 } 7733 let isInsidePolygon = false; 7734 switch (side) { 7735 case "top": { 7736 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7737 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7738 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7739 const cursorPointY = y2 + POLYGON_BUFFER + 1; 7740 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top; 7741 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER; 7742 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 7743 break; 7744 } 7745 case "bottom": { 7746 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7747 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7748 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7749 const cursorPointY = y2 - POLYGON_BUFFER; 7750 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom; 7751 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER; 7752 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 7753 break; 7754 } 7755 case "left": { 7756 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7757 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7758 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7759 const cursorPointX = x2 + POLYGON_BUFFER + 1; 7760 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left; 7761 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER; 7762 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY); 7763 break; 7764 } 7765 case "right": { 7766 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7767 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7768 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7769 const cursorPointX = x2 - POLYGON_BUFFER; 7770 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right; 7771 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER; 7772 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom); 7773 break; 7774 } 7775 default: 7776 } 7777 if (!isInsidePolygon) { 7778 closeIfNoOpenChild(); 7779 } else if (!hasLanded) { 7780 timeout.start(40, closeIfNoOpenChild); 7781 } 7782 return void 0; 7783 }; 7784 }; 7785 fn.__options = { 7786 ...options, 7787 blockPointerEvents 7788 }; 7789 return fn; 7790 } 7791 7792 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js 7793 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) { 7794 CommonPopupDataAttributes2["open"] = "data-open"; 7795 CommonPopupDataAttributes2["closed"] = "data-closed"; 7796 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; 7797 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; 7798 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden"; 7799 CommonPopupDataAttributes2["side"] = "data-side"; 7800 CommonPopupDataAttributes2["align"] = "data-align"; 7801 return CommonPopupDataAttributes2; 7802 })({}); 7803 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) { 7804 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open"; 7805 CommonTriggerDataAttributes2["pressed"] = "data-pressed"; 7806 return CommonTriggerDataAttributes2; 7807 })({}); 7808 var TRIGGER_HOOK = { 7809 [CommonTriggerDataAttributes.popupOpen]: "" 7810 }; 7811 var PRESSABLE_TRIGGER_HOOK = { 7812 [CommonTriggerDataAttributes.popupOpen]: "", 7813 [CommonTriggerDataAttributes.pressed]: "" 7814 }; 7815 var POPUP_OPEN_HOOK = { 7816 [CommonPopupDataAttributes.open]: "" 7817 }; 7818 var POPUP_CLOSED_HOOK = { 7819 [CommonPopupDataAttributes.closed]: "" 7820 }; 7821 var ANCHOR_HIDDEN_HOOK = { 7822 [CommonPopupDataAttributes.anchorHidden]: "" 7823 }; 7824 var triggerOpenStateMapping2 = { 7825 open(value) { 7826 if (value) { 7827 return TRIGGER_HOOK; 7828 } 7829 return null; 7830 } 7831 }; 7832 var popupStateMapping = { 7833 open(value) { 7834 if (value) { 7835 return POPUP_OPEN_HOOK; 7836 } 7837 return POPUP_CLOSED_HOOK; 7838 }, 7839 anchorHidden(value) { 7840 if (value) { 7841 return ANCHOR_HIDDEN_HOOK; 7842 } 7843 return null; 7844 } 7845 }; 7846 7847 // node_modules/@base-ui/utils/esm/inertValue.js 7848 function inertValue(value) { 7849 if (isReactVersionAtLeast(19)) { 7850 return value; 7851 } 7852 return value ? "true" : void 0; 7853 } 7854 7855 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js 7856 var React38 = __toESM(require_react(), 1); 7857 7858 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js 7859 var baseArrow = (options) => ({ 7860 name: "arrow", 7861 options, 7862 async fn(state) { 7863 const { 7864 x: x2, 7865 y: y2, 7866 placement, 7867 rects, 7868 platform: platform3, 7869 elements, 7870 middlewareData 7871 } = state; 7872 const { 7873 element, 7874 padding = 0, 7875 offsetParent = "real" 7876 } = evaluate(options, state) || {}; 7877 if (element == null) { 7878 return {}; 7879 } 7880 const paddingObject = getPaddingObject(padding); 7881 const coords = { 7882 x: x2, 7883 y: y2 7884 }; 7885 const axis = getAlignmentAxis(placement); 7886 const length = getAxisLength(axis); 7887 const arrowDimensions = await platform3.getDimensions(element); 7888 const isYAxis = axis === "y"; 7889 const minProp = isYAxis ? "top" : "left"; 7890 const maxProp = isYAxis ? "bottom" : "right"; 7891 const clientProp = isYAxis ? "clientHeight" : "clientWidth"; 7892 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; 7893 const startDiff = coords[axis] - rects.reference[axis]; 7894 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating; 7895 let clientSize = elements.floating[clientProp] || rects.floating[length]; 7896 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) { 7897 clientSize = elements.floating[clientProp] || rects.floating[length]; 7898 } 7899 const centerToReference = endDiff / 2 - startDiff / 2; 7900 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; 7901 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding); 7902 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding); 7903 const min2 = minPadding; 7904 const max2 = clientSize - arrowDimensions[length] - maxPadding; 7905 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; 7906 const offset4 = clamp(min2, center, max2); 7907 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; 7908 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0; 7909 return { 7910 [axis]: coords[axis] + alignmentOffset, 7911 data: { 7912 [axis]: offset4, 7913 centerOffset: center - offset4 - alignmentOffset, 7914 ...shouldAddOffset && { 7915 alignmentOffset 7916 } 7917 }, 7918 reset: shouldAddOffset 7919 }; 7920 } 7921 }); 7922 var arrow4 = (options, deps) => ({ 7923 ...baseArrow(options), 7924 options: [options, deps] 7925 }); 7926 7927 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js 7928 var hide4 = { 7929 name: "hide", 7930 async fn(state) { 7931 const { 7932 width, 7933 height, 7934 x: x2, 7935 y: y2 7936 } = state.rects.reference; 7937 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0; 7938 const nativeHideResult = await hide3().fn(state); 7939 return { 7940 data: { 7941 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden 7942 } 7943 }; 7944 } 7945 }; 7946 7947 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js 7948 var DEFAULT_SIDES = { 7949 sideX: "left", 7950 sideY: "top" 7951 }; 7952 var adaptiveOrigin = { 7953 name: "adaptiveOrigin", 7954 async fn(state) { 7955 const { 7956 x: rawX, 7957 y: rawY, 7958 rects: { 7959 floating: floatRect 7960 }, 7961 elements: { 7962 floating 7963 }, 7964 platform: platform3, 7965 strategy, 7966 placement 7967 } = state; 7968 const win = getWindow(floating); 7969 const styles = win.getComputedStyle(floating); 7970 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== ""; 7971 if (!hasTransition) { 7972 return { 7973 x: rawX, 7974 y: rawY, 7975 data: DEFAULT_SIDES 7976 }; 7977 } 7978 const offsetParent = await platform3.getOffsetParent?.(floating); 7979 let offsetDimensions = { 7980 width: 0, 7981 height: 0 7982 }; 7983 if (strategy === "fixed" && win?.visualViewport) { 7984 offsetDimensions = { 7985 width: win.visualViewport.width, 7986 height: win.visualViewport.height 7987 }; 7988 } else if (offsetParent === win) { 7989 const doc = ownerDocument(floating); 7990 offsetDimensions = { 7991 width: doc.documentElement.clientWidth, 7992 height: doc.documentElement.clientHeight 7993 }; 7994 } else if (await platform3.isElement?.(offsetParent)) { 7995 offsetDimensions = await platform3.getDimensions(offsetParent); 7996 } 7997 const currentSide = getSide(placement); 7998 let x2 = rawX; 7999 let y2 = rawY; 8000 if (currentSide === "left") { 8001 x2 = offsetDimensions.width - (rawX + floatRect.width); 8002 } 8003 if (currentSide === "top") { 8004 y2 = offsetDimensions.height - (rawY + floatRect.height); 8005 } 8006 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX; 8007 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY; 8008 return { 8009 x: x2, 8010 y: y2, 8011 data: { 8012 sideX, 8013 sideY 8014 } 8015 }; 8016 } 8017 }; 8018 8019 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js 8020 function getLogicalSide(sideParam, renderedSide, isRtl) { 8021 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end"; 8022 const logicalRight = isRtl ? "inline-start" : "inline-end"; 8023 const logicalLeft = isRtl ? "inline-end" : "inline-start"; 8024 return { 8025 top: "top", 8026 right: isLogicalSideParam ? logicalRight : "right", 8027 bottom: "bottom", 8028 left: isLogicalSideParam ? logicalLeft : "left" 8029 }[renderedSide]; 8030 } 8031 function getOffsetData(state, sideParam, isRtl) { 8032 const { 8033 rects, 8034 placement 8035 } = state; 8036 const data = { 8037 side: getLogicalSide(sideParam, getSide(placement), isRtl), 8038 align: getAlignment(placement) || "center", 8039 anchor: { 8040 width: rects.reference.width, 8041 height: rects.reference.height 8042 }, 8043 positioner: { 8044 width: rects.floating.width, 8045 height: rects.floating.height 8046 } 8047 }; 8048 return data; 8049 } 8050 function useAnchorPositioning(params) { 8051 const { 8052 // Public parameters 8053 anchor, 8054 positionMethod = "absolute", 8055 side: sideParam = "bottom", 8056 sideOffset = 0, 8057 align = "center", 8058 alignOffset = 0, 8059 collisionBoundary, 8060 collisionPadding: collisionPaddingParam = 5, 8061 sticky = false, 8062 arrowPadding = 5, 8063 disableAnchorTracking = false, 8064 // Private parameters 8065 keepMounted = false, 8066 floatingRootContext, 8067 mounted, 8068 collisionAvoidance, 8069 shiftCrossAxis = false, 8070 nodeId, 8071 adaptiveOrigin: adaptiveOrigin2, 8072 lazyFlip = false, 8073 externalTree 8074 } = params; 8075 const [mountSide, setMountSide] = React38.useState(null); 8076 if (!mounted && mountSide !== null) { 8077 setMountSide(null); 8078 } 8079 const collisionAvoidanceSide = collisionAvoidance.side || "flip"; 8080 const collisionAvoidanceAlign = collisionAvoidance.align || "flip"; 8081 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end"; 8082 const anchorFn = typeof anchor === "function" ? anchor : void 0; 8083 const anchorFnCallback = useStableCallback(anchorFn); 8084 const anchorDep = anchorFn ? anchorFnCallback : anchor; 8085 const anchorValueRef = useValueAsRef(anchor); 8086 const mountedRef = useValueAsRef(mounted); 8087 const direction = useDirection(); 8088 const isRtl = direction === "rtl"; 8089 const side = mountSide || { 8090 top: "top", 8091 right: "right", 8092 bottom: "bottom", 8093 left: "left", 8094 "inline-end": isRtl ? "left" : "right", 8095 "inline-start": isRtl ? "right" : "left" 8096 }[sideParam]; 8097 const placement = align === "center" ? side : `$side}-$align}`; 8098 let collisionPadding = collisionPaddingParam; 8099 const bias = 1; 8100 const biasTop = sideParam === "bottom" ? bias : 0; 8101 const biasBottom = sideParam === "top" ? bias : 0; 8102 const biasLeft = sideParam === "right" ? bias : 0; 8103 const biasRight = sideParam === "left" ? bias : 0; 8104 if (typeof collisionPadding === "number") { 8105 collisionPadding = { 8106 top: collisionPadding + biasTop, 8107 right: collisionPadding + biasRight, 8108 bottom: collisionPadding + biasBottom, 8109 left: collisionPadding + biasLeft 8110 }; 8111 } else if (collisionPadding) { 8112 collisionPadding = { 8113 top: (collisionPadding.top || 0) + biasTop, 8114 right: (collisionPadding.right || 0) + biasRight, 8115 bottom: (collisionPadding.bottom || 0) + biasBottom, 8116 left: (collisionPadding.left || 0) + biasLeft 8117 }; 8118 } 8119 const commonCollisionProps = { 8120 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary, 8121 padding: collisionPadding 8122 }; 8123 const arrowRef = React38.useRef(null); 8124 const sideOffsetRef = useValueAsRef(sideOffset); 8125 const alignOffsetRef = useValueAsRef(alignOffset); 8126 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0; 8127 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0; 8128 const middleware = [offset3((state) => { 8129 const data = getOffsetData(state, sideParam, isRtl); 8130 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current; 8131 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current; 8132 return { 8133 mainAxis: sideAxis, 8134 crossAxis: alignAxis, 8135 alignmentAxis: alignAxis 8136 }; 8137 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])]; 8138 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift"; 8139 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift"); 8140 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({ 8141 ...commonCollisionProps, 8142 // Ensure the popup flips if it's been limited by its --available-height and it resizes. 8143 // Since the size() padding is smaller than the flip() padding, flip() will take precedence. 8144 padding: { 8145 top: collisionPadding.top + bias, 8146 right: collisionPadding.right + bias, 8147 bottom: collisionPadding.bottom + bias, 8148 left: collisionPadding.left + bias 8149 }, 8150 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip", 8151 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false, 8152 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide 8153 }); 8154 const shiftMiddleware = shiftDisabled ? null : shift3((data) => { 8155 const html = ownerDocument(data.elements.floating).documentElement; 8156 return { 8157 ...commonCollisionProps, 8158 // Use the Layout Viewport to avoid shifting around when pinch-zooming 8159 // for context menus. 8160 rootBoundary: shiftCrossAxis ? { 8161 x: 0, 8162 y: 0, 8163 width: html.clientWidth, 8164 height: html.clientHeight 8165 } : void 0, 8166 mainAxis: collisionAvoidanceAlign !== "none", 8167 crossAxis: crossAxisShiftEnabled, 8168 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => { 8169 if (!arrowRef.current) { 8170 return {}; 8171 } 8172 const { 8173 width, 8174 height 8175 } = arrowRef.current.getBoundingClientRect(); 8176 const sideAxis = getSideAxis(getSide(limitData.placement)); 8177 const arrowSize = sideAxis === "y" ? width : height; 8178 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom; 8179 return { 8180 offset: arrowSize / 2 + offsetAmount / 2 8181 }; 8182 }) 8183 }; 8184 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]); 8185 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") { 8186 middleware.push(shiftMiddleware, flipMiddleware); 8187 } else { 8188 middleware.push(flipMiddleware, shiftMiddleware); 8189 } 8190 middleware.push(size3({ 8191 ...commonCollisionProps, 8192 apply({ 8193 elements: { 8194 floating 8195 }, 8196 availableWidth, 8197 availableHeight, 8198 rects 8199 }) { 8200 if (!mountedRef.current) { 8201 return; 8202 } 8203 const floatingStyle = floating.style; 8204 floatingStyle.setProperty("--available-width", `$availableWidth}px`); 8205 floatingStyle.setProperty("--available-height", `$availableHeight}px`); 8206 const dpr = getWindow(floating).devicePixelRatio || 1; 8207 const { 8208 x: x3, 8209 y: y3, 8210 width, 8211 height 8212 } = rects.reference; 8213 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr; 8214 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr; 8215 floatingStyle.setProperty("--anchor-width", `$anchorWidth}px`); 8216 floatingStyle.setProperty("--anchor-height", `$anchorHeight}px`); 8217 } 8218 }), arrow4(() => ({ 8219 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set, 8220 // we'll create a fake element. 8221 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"), 8222 padding: arrowPadding, 8223 offsetParent: "floating" 8224 }), [arrowPadding]), { 8225 name: "transformOrigin", 8226 fn(state) { 8227 const { 8228 elements: elements2, 8229 middlewareData: middlewareData2, 8230 placement: renderedPlacement2, 8231 rects, 8232 y: y3 8233 } = state; 8234 const currentRenderedSide = getSide(renderedPlacement2); 8235 const currentRenderedAxis = getSideAxis(currentRenderedSide); 8236 const arrowEl = arrowRef.current; 8237 const arrowX = middlewareData2.arrow?.x || 0; 8238 const arrowY = middlewareData2.arrow?.y || 0; 8239 const arrowWidth = arrowEl?.clientWidth || 0; 8240 const arrowHeight = arrowEl?.clientHeight || 0; 8241 const transformX = arrowX + arrowWidth / 2; 8242 const transformY = arrowY + arrowHeight / 2; 8243 const shiftY = Math.abs(middlewareData2.shift?.y || 0); 8244 const halfAnchorHeight = rects.reference.height / 2; 8245 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset; 8246 const isOverlappingAnchor = shiftY > sideOffsetValue; 8247 const adjacentTransformOrigin = { 8248 top: `$transformX}px calc(100% + $sideOffsetValue}px)`, 8249 bottom: `$transformX}px ${-sideOffsetValue}px`, 8250 left: `calc(100% + $sideOffsetValue}px) $transformY}px`, 8251 right: `${-sideOffsetValue}px $transformY}px` 8252 }[currentRenderedSide]; 8253 const overlapTransformOrigin = `$transformX}px $rects.reference.y + halfAnchorHeight - y3}px`; 8254 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin); 8255 return {}; 8256 } 8257 }, hide4, adaptiveOrigin2); 8258 useIsoLayoutEffect(() => { 8259 if (!mounted && floatingRootContext) { 8260 floatingRootContext.update({ 8261 referenceElement: null, 8262 floatingElement: null, 8263 domReferenceElement: null, 8264 positionReference: null 8265 }); 8266 } 8267 }, [mounted, floatingRootContext]); 8268 const autoUpdateOptions = React38.useMemo(() => ({ 8269 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined", 8270 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined" 8271 }), [disableAnchorTracking]); 8272 const { 8273 refs, 8274 elements, 8275 x: x2, 8276 y: y2, 8277 middlewareData, 8278 update: update2, 8279 placement: renderedPlacement, 8280 context, 8281 isPositioned, 8282 floatingStyles: originalFloatingStyles 8283 } = useFloating2({ 8284 rootContext: floatingRootContext, 8285 open: keepMounted ? mounted : void 0, 8286 placement, 8287 middleware, 8288 strategy: positionMethod, 8289 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions), 8290 nodeId, 8291 externalTree 8292 }); 8293 const { 8294 sideX, 8295 sideY 8296 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES; 8297 const resolvedPosition = isPositioned ? positionMethod : "fixed"; 8298 const floatingStyles = React38.useMemo(() => { 8299 const base = adaptiveOrigin2 ? { 8300 position: resolvedPosition, 8301 [sideX]: x2, 8302 [sideY]: y2 8303 } : { 8304 position: resolvedPosition, 8305 ...originalFloatingStyles 8306 }; 8307 if (!isPositioned) { 8308 base.opacity = 0; 8309 } 8310 return base; 8311 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]); 8312 const registeredPositionReferenceRef = React38.useRef(null); 8313 useIsoLayoutEffect(() => { 8314 if (!mounted) { 8315 return; 8316 } 8317 const anchorValue = anchorValueRef.current; 8318 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue; 8319 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null; 8320 const finalAnchor = unwrappedElement || null; 8321 if (finalAnchor !== registeredPositionReferenceRef.current) { 8322 refs.setPositionReference(finalAnchor); 8323 registeredPositionReferenceRef.current = finalAnchor; 8324 } 8325 }, [mounted, refs, anchorDep, anchorValueRef]); 8326 React38.useEffect(() => { 8327 if (!mounted) { 8328 return; 8329 } 8330 const anchorValue = anchorValueRef.current; 8331 if (typeof anchorValue === "function") { 8332 return; 8333 } 8334 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) { 8335 refs.setPositionReference(anchorValue.current); 8336 registeredPositionReferenceRef.current = anchorValue.current; 8337 } 8338 }, [mounted, refs, anchorDep, anchorValueRef]); 8339 React38.useEffect(() => { 8340 if (keepMounted && mounted && elements.domReference && elements.floating) { 8341 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions); 8342 } 8343 return void 0; 8344 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]); 8345 const renderedSide = getSide(renderedPlacement); 8346 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl); 8347 const renderedAlign = getAlignment(renderedPlacement) || "center"; 8348 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden); 8349 useIsoLayoutEffect(() => { 8350 if (lazyFlip && mounted && isPositioned) { 8351 setMountSide(renderedSide); 8352 } 8353 }, [lazyFlip, mounted, isPositioned, renderedSide]); 8354 const arrowStyles = React38.useMemo(() => ({ 8355 position: "absolute", 8356 top: middlewareData.arrow?.y, 8357 left: middlewareData.arrow?.x 8358 }), [middlewareData.arrow]); 8359 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0; 8360 return React38.useMemo(() => ({ 8361 positionerStyles: floatingStyles, 8362 arrowStyles, 8363 arrowRef, 8364 arrowUncentered, 8365 side: logicalRenderedSide, 8366 align: renderedAlign, 8367 physicalSide: renderedSide, 8368 anchorHidden, 8369 refs, 8370 context, 8371 isPositioned, 8372 update: update2 8373 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]); 8374 } 8375 function isRef(param) { 8376 return param != null && "current" in param; 8377 } 8378 8379 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js 8380 function getDisabledMountTransitionStyles(transitionStatus) { 8381 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT; 8382 } 8383 8384 // node_modules/@base-ui/react/esm/utils/usePositioner.js 8385 function usePositioner(componentProps, state, { 8386 styles, 8387 transitionStatus, 8388 props, 8389 refs, 8390 hidden, 8391 inert = false 8392 }) { 8393 const style = { 8394 ...styles 8395 }; 8396 if (inert) { 8397 style.pointerEvents = "none"; 8398 } 8399 return useRenderElement("div", componentProps, { 8400 state, 8401 ref: refs, 8402 props: [{ 8403 role: "presentation", 8404 hidden, 8405 style 8406 }, getDisabledMountTransitionStyles(transitionStatus), props], 8407 stateAttributesMapping: popupStateMapping 8408 }); 8409 } 8410 8411 // node_modules/@base-ui/react/esm/collapsible/index.parts.js 8412 var index_parts_exports = {}; 8413 __export(index_parts_exports, { 8414 Panel: () => CollapsiblePanel, 8415 Root: () => CollapsibleRoot, 8416 Trigger: () => CollapsibleTrigger 8417 }); 8418 8419 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js 8420 var React39 = __toESM(require_react(), 1); 8421 8422 // node_modules/@base-ui/react/esm/collapsible/root/stateAttributesMapping.js 8423 var collapsibleStateAttributesMapping = { 8424 ...collapsibleOpenStateMapping, 8425 ...transitionStatusMapping 8426 }; 8427 8428 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js 8429 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); 8430 var CollapsibleRoot = /* @__PURE__ */ React39.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) { 8431 const { 8432 render: render4, 8433 className, 8434 defaultOpen = false, 8435 disabled: disabled2 = false, 8436 onOpenChange: onOpenChangeProp, 8437 open, 8438 style, 8439 ...elementProps 8440 } = componentProps; 8441 const onOpenChange = useStableCallback(onOpenChangeProp); 8442 const collapsible = useCollapsibleRoot({ 8443 open, 8444 defaultOpen, 8445 onOpenChange, 8446 disabled: disabled2 8447 }); 8448 const state = React39.useMemo(() => ({ 8449 open: collapsible.open, 8450 disabled: collapsible.disabled, 8451 transitionStatus: collapsible.transitionStatus 8452 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]); 8453 const contextValue = React39.useMemo(() => ({ 8454 ...collapsible, 8455 onOpenChange, 8456 state 8457 }), [collapsible, onOpenChange, state]); 8458 const element = useRenderElement("div", componentProps, { 8459 state, 8460 ref: forwardedRef, 8461 props: elementProps, 8462 stateAttributesMapping: collapsibleStateAttributesMapping 8463 }); 8464 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollapsibleRootContext.Provider, { 8465 value: contextValue, 8466 children: element 8467 }); 8468 }); 8469 if (true) CollapsibleRoot.displayName = "CollapsibleRoot"; 8470 8471 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTrigger.js 8472 var React40 = __toESM(require_react(), 1); 8473 var stateAttributesMapping = { 8474 ...triggerOpenStateMapping, 8475 ...transitionStatusMapping 8476 }; 8477 var CollapsibleTrigger = /* @__PURE__ */ React40.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) { 8478 const { 8479 panelId, 8480 open, 8481 handleTrigger, 8482 state, 8483 disabled: contextDisabled 8484 } = useCollapsibleRootContext(); 8485 const { 8486 className, 8487 disabled: disabled2 = contextDisabled, 8488 id, 8489 render: render4, 8490 nativeButton = true, 8491 style, 8492 ...elementProps 8493 } = componentProps; 8494 const { 8495 getButtonProps, 8496 buttonRef 8497 } = useButton({ 8498 disabled: disabled2, 8499 focusableWhenDisabled: true, 8500 native: nativeButton 8501 }); 8502 const props = React40.useMemo(() => ({ 8503 "aria-controls": open ? panelId : void 0, 8504 "aria-expanded": open, 8505 onClick: handleTrigger 8506 }), [panelId, open, handleTrigger]); 8507 const element = useRenderElement("button", componentProps, { 8508 state, 8509 ref: [forwardedRef, buttonRef], 8510 props: [props, elementProps, getButtonProps], 8511 stateAttributesMapping 8512 }); 8513 return element; 8514 }); 8515 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger"; 8516 8517 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js 8518 var React41 = __toESM(require_react(), 1); 8519 8520 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelCssVars.js 8521 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) { 8522 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height"; 8523 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width"; 8524 return CollapsiblePanelCssVars2; 8525 })({}); 8526 8527 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js 8528 var CollapsiblePanel = /* @__PURE__ */ React41.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) { 8529 const { 8530 className, 8531 hiddenUntilFound: hiddenUntilFoundProp, 8532 keepMounted: keepMountedProp, 8533 render: render4, 8534 id: idProp, 8535 style, 8536 ...elementProps 8537 } = componentProps; 8538 if (true) { 8539 useIsoLayoutEffect(() => { 8540 if (hiddenUntilFoundProp && keepMountedProp === false) { 8541 warn("The `keepMounted={false}` prop on a Collapsible will be ignored when using `hiddenUntilFound` since it requires the Panel to remain mounted even when closed."); 8542 } 8543 }, [hiddenUntilFoundProp, keepMountedProp]); 8544 } 8545 const { 8546 abortControllerRef, 8547 animationTypeRef, 8548 height, 8549 mounted, 8550 onOpenChange, 8551 open, 8552 panelId, 8553 panelRef, 8554 runOnceAnimationsFinish, 8555 setDimensions, 8556 setHiddenUntilFound, 8557 setKeepMounted, 8558 setMounted, 8559 setPanelIdState, 8560 setOpen, 8561 setVisible, 8562 state, 8563 transitionDimensionRef, 8564 visible, 8565 width, 8566 transitionStatus 8567 } = useCollapsibleRootContext(); 8568 const hiddenUntilFound = hiddenUntilFoundProp ?? false; 8569 const keepMounted = keepMountedProp ?? false; 8570 useIsoLayoutEffect(() => { 8571 if (idProp) { 8572 setPanelIdState(idProp); 8573 return () => { 8574 setPanelIdState(void 0); 8575 }; 8576 } 8577 return void 0; 8578 }, [idProp, setPanelIdState]); 8579 useIsoLayoutEffect(() => { 8580 setHiddenUntilFound(hiddenUntilFound); 8581 }, [setHiddenUntilFound, hiddenUntilFound]); 8582 useIsoLayoutEffect(() => { 8583 setKeepMounted(keepMounted); 8584 }, [setKeepMounted, keepMounted]); 8585 const { 8586 props 8587 } = useCollapsiblePanel({ 8588 abortControllerRef, 8589 animationTypeRef, 8590 externalRef: forwardedRef, 8591 height, 8592 hiddenUntilFound, 8593 id: panelId, 8594 keepMounted, 8595 mounted, 8596 onOpenChange, 8597 open, 8598 panelRef, 8599 runOnceAnimationsFinish, 8600 setDimensions, 8601 setMounted, 8602 setOpen, 8603 setVisible, 8604 transitionDimensionRef, 8605 visible, 8606 width 8607 }); 8608 useOpenChangeComplete({ 8609 open: open && transitionStatus === "idle", 8610 ref: panelRef, 8611 onComplete() { 8612 if (!open) { 8613 return; 8614 } 8615 setDimensions({ 8616 height: void 0, 8617 width: void 0 8618 }); 8619 } 8620 }); 8621 const panelState = React41.useMemo(() => ({ 8622 ...state, 8623 transitionStatus 8624 }), [state, transitionStatus]); 8625 const element = useRenderElement("div", componentProps, { 8626 state: panelState, 8627 ref: [forwardedRef, panelRef], 8628 props: [props, { 8629 style: { 8630 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `$height}px`, 8631 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `$width}px` 8632 } 8633 }, elementProps], 8634 stateAttributesMapping: collapsibleStateAttributesMapping 8635 }); 8636 const shouldRender = keepMounted || hiddenUntilFound || mounted; 8637 if (!shouldRender) { 8638 return null; 8639 } 8640 return element; 8641 }); 8642 if (true) CollapsiblePanel.displayName = "CollapsiblePanel"; 8643 8644 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js 8645 var React44 = __toESM(require_react(), 1); 8646 var ReactDOM5 = __toESM(require_react_dom(), 1); 8647 8648 // node_modules/@base-ui/utils/esm/usePreviousValue.js 8649 var React42 = __toESM(require_react(), 1); 8650 function usePreviousValue(value) { 8651 const [state, setState] = React42.useState({ 8652 current: value, 8653 previous: null 8654 }); 8655 if (value !== state.current) { 8656 setState({ 8657 current: value, 8658 previous: state.current 8659 }); 8660 } 8661 return state.previous; 8662 } 8663 8664 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js 8665 var React43 = __toESM(require_react(), 1); 8666 8667 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js 8668 function getCssDimensions2(element) { 8669 const css = getComputedStyle2(element); 8670 let width = parseFloat(css.width) || 0; 8671 let height = parseFloat(css.height) || 0; 8672 const hasOffset = isHTMLElement(element); 8673 const offsetWidth = hasOffset ? element.offsetWidth : width; 8674 const offsetHeight = hasOffset ? element.offsetHeight : height; 8675 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 8676 if (shouldFallback) { 8677 width = offsetWidth; 8678 height = offsetHeight; 8679 } 8680 return { 8681 width, 8682 height 8683 }; 8684 } 8685 8686 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js 8687 var DEFAULT_ENABLED = () => true; 8688 function usePopupAutoResize(parameters) { 8689 const { 8690 popupElement, 8691 positionerElement, 8692 content, 8693 mounted, 8694 enabled = DEFAULT_ENABLED, 8695 onMeasureLayout: onMeasureLayoutParam, 8696 onMeasureLayoutComplete: onMeasureLayoutCompleteParam, 8697 side, 8698 direction 8699 } = parameters; 8700 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false); 8701 const animationFrame = useAnimationFrame(); 8702 const committedDimensionsRef = React43.useRef(null); 8703 const liveDimensionsRef = React43.useRef(null); 8704 const isInitialRenderRef = React43.useRef(true); 8705 const restoreAnchoringStylesRef = React43.useRef(NOOP); 8706 const onMeasureLayout = useStableCallback(onMeasureLayoutParam); 8707 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam); 8708 const anchoringStyles = React43.useMemo(() => { 8709 let isOriginSide = side === "top"; 8710 let isPhysicalLeft = side === "left"; 8711 if (direction === "rtl") { 8712 isOriginSide = isOriginSide || side === "inline-end"; 8713 isPhysicalLeft = isPhysicalLeft || side === "inline-end"; 8714 } else { 8715 isOriginSide = isOriginSide || side === "inline-start"; 8716 isPhysicalLeft = isPhysicalLeft || side === "inline-start"; 8717 } 8718 return isOriginSide ? { 8719 position: "absolute", 8720 [side === "top" ? "bottom" : "top"]: "0", 8721 [isPhysicalLeft ? "right" : "left"]: "0" 8722 } : EMPTY_OBJECT; 8723 }, [side, direction]); 8724 useIsoLayoutEffect(() => { 8725 if (!mounted || !enabled() || typeof ResizeObserver !== "function") { 8726 restoreAnchoringStylesRef.current = NOOP; 8727 isInitialRenderRef.current = true; 8728 committedDimensionsRef.current = null; 8729 liveDimensionsRef.current = null; 8730 return void 0; 8731 } 8732 if (!popupElement || !positionerElement) { 8733 return void 0; 8734 } 8735 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles); 8736 const observer = new ResizeObserver((entries) => { 8737 const entry = entries[0]; 8738 if (entry) { 8739 liveDimensionsRef.current = { 8740 width: Math.ceil(entry.borderBoxSize[0].inlineSize), 8741 height: Math.ceil(entry.borderBoxSize[0].blockSize) 8742 }; 8743 } 8744 }); 8745 observer.observe(popupElement); 8746 setPopupCssSize(popupElement, "auto"); 8747 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static"); 8748 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none"); 8749 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1"); 8750 const restorePositionerAvailableSize = applyElementStyles(positionerElement, { 8751 "--available-width": "max-content", 8752 "--available-height": "max-content" 8753 }); 8754 function restoreMeasurementOverrides() { 8755 restorePopupPosition(); 8756 restorePopupTransform(); 8757 restorePositionerAvailableSize(); 8758 } 8759 function restoreMeasurementOverridesIncludingScale() { 8760 restoreMeasurementOverrides(); 8761 restorePopupScale(); 8762 } 8763 onMeasureLayout?.(); 8764 if (isInitialRenderRef.current || committedDimensionsRef.current === null) { 8765 setPositionerCssSize(positionerElement, "max-content"); 8766 const dimensions = getCssDimensions2(popupElement); 8767 committedDimensionsRef.current = dimensions; 8768 setPositionerCssSize(positionerElement, dimensions); 8769 restoreMeasurementOverridesIncludingScale(); 8770 onMeasureLayoutComplete?.(null, dimensions); 8771 isInitialRenderRef.current = false; 8772 return () => { 8773 observer.disconnect(); 8774 restoreAnchoringStylesRef.current(); 8775 restoreAnchoringStylesRef.current = NOOP; 8776 }; 8777 } 8778 setPopupCssSize(popupElement, "auto"); 8779 setPositionerCssSize(positionerElement, "max-content"); 8780 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current; 8781 const newDimensions = getCssDimensions2(popupElement); 8782 committedDimensionsRef.current = newDimensions; 8783 if (!previousDimensions) { 8784 setPositionerCssSize(positionerElement, newDimensions); 8785 restoreMeasurementOverridesIncludingScale(); 8786 onMeasureLayoutComplete?.(null, newDimensions); 8787 return () => { 8788 observer.disconnect(); 8789 animationFrame.cancel(); 8790 restoreAnchoringStylesRef.current(); 8791 restoreAnchoringStylesRef.current = NOOP; 8792 }; 8793 } 8794 setPopupCssSize(popupElement, previousDimensions); 8795 restoreMeasurementOverridesIncludingScale(); 8796 onMeasureLayoutComplete?.(previousDimensions, newDimensions); 8797 setPositionerCssSize(positionerElement, newDimensions); 8798 const abortController = new AbortController(); 8799 animationFrame.request(() => { 8800 setPopupCssSize(popupElement, newDimensions); 8801 runOnceAnimationsFinish(() => { 8802 popupElement.style.setProperty("--popup-width", "auto"); 8803 popupElement.style.setProperty("--popup-height", "auto"); 8804 }, abortController.signal); 8805 }); 8806 return () => { 8807 observer.disconnect(); 8808 abortController.abort(); 8809 animationFrame.cancel(); 8810 restoreAnchoringStylesRef.current(); 8811 restoreAnchoringStylesRef.current = NOOP; 8812 }; 8813 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]); 8814 } 8815 function overrideElementStyle(element, property, value) { 8816 const originalValue = element.style.getPropertyValue(property); 8817 element.style.setProperty(property, value); 8818 return () => { 8819 element.style.setProperty(property, originalValue); 8820 }; 8821 } 8822 function applyElementStyles(element, styles) { 8823 const restorers = []; 8824 for (const [key, value] of Object.entries(styles)) { 8825 restorers.push(overrideElementStyle(element, key, value)); 8826 } 8827 return restorers.length ? () => { 8828 restorers.forEach((restore) => restore()); 8829 } : NOOP; 8830 } 8831 function setPopupCssSize(popupElement, size4) { 8832 const width = size4 === "auto" ? "auto" : `$size4.width}px`; 8833 const height = size4 === "auto" ? "auto" : `$size4.height}px`; 8834 popupElement.style.setProperty("--popup-width", width); 8835 popupElement.style.setProperty("--popup-height", height); 8836 } 8837 function setPositionerCssSize(positionerElement, size4) { 8838 const width = size4 === "max-content" ? "max-content" : `$size4.width}px`; 8839 const height = size4 === "max-content" ? "max-content" : `$size4.height}px`; 8840 positionerElement.style.setProperty("--positioner-width", width); 8841 positionerElement.style.setProperty("--positioner-height", height); 8842 } 8843 8844 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js 8845 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); 8846 function usePopupViewport(parameters) { 8847 const { 8848 store: store2, 8849 side, 8850 cssVars, 8851 children 8852 } = parameters; 8853 const direction = useDirection(); 8854 const activeTrigger = store2.useState("activeTriggerElement"); 8855 const activeTriggerId = store2.useState("activeTriggerId"); 8856 const open = store2.useState("open"); 8857 const payload = store2.useState("payload"); 8858 const mounted = store2.useState("mounted"); 8859 const popupElement = store2.useState("popupElement"); 8860 const positionerElement = store2.useState("positionerElement"); 8861 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null); 8862 const currentContentKey = usePopupContentKey(activeTriggerId, payload); 8863 const capturedNodeRef = React44.useRef(null); 8864 const [previousContentNode, setPreviousContentNode] = React44.useState(null); 8865 const [newTriggerOffset, setNewTriggerOffset] = React44.useState(null); 8866 const currentContainerRef = React44.useRef(null); 8867 const previousContainerRef = React44.useRef(null); 8868 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false); 8869 const cleanupFrame = useAnimationFrame(); 8870 const [previousContentDimensions, setPreviousContentDimensions] = React44.useState(null); 8871 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React44.useState(false); 8872 useIsoLayoutEffect(() => { 8873 store2.set("hasViewport", true); 8874 return () => { 8875 store2.set("hasViewport", false); 8876 }; 8877 }, [store2]); 8878 const handleMeasureLayout = useStableCallback(() => { 8879 currentContainerRef.current?.style.setProperty("animation", "none"); 8880 currentContainerRef.current?.style.setProperty("transition", "none"); 8881 previousContainerRef.current?.style.setProperty("display", "none"); 8882 }); 8883 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => { 8884 currentContainerRef.current?.style.removeProperty("animation"); 8885 currentContainerRef.current?.style.removeProperty("transition"); 8886 previousContainerRef.current?.style.removeProperty("display"); 8887 if (previousDimensions) { 8888 setPreviousContentDimensions(previousDimensions); 8889 } 8890 }); 8891 const lastHandledTriggerRef = React44.useRef(null); 8892 useIsoLayoutEffect(() => { 8893 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) { 8894 setPreviousContentNode(capturedNodeRef.current); 8895 setShowStartingStyleAttribute(true); 8896 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger); 8897 setNewTriggerOffset(offset4); 8898 cleanupFrame.request(() => { 8899 ReactDOM5.flushSync(() => { 8900 setShowStartingStyleAttribute(false); 8901 }); 8902 onAnimationsFinished(() => { 8903 setPreviousContentNode(null); 8904 setPreviousContentDimensions(null); 8905 capturedNodeRef.current = null; 8906 }); 8907 }); 8908 lastHandledTriggerRef.current = activeTrigger; 8909 } 8910 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]); 8911 useIsoLayoutEffect(() => { 8912 const source = currentContainerRef.current; 8913 if (!source) { 8914 return; 8915 } 8916 const wrapper = ownerDocument(source).createElement("div"); 8917 for (const child of Array.from(source.childNodes)) { 8918 wrapper.appendChild(child.cloneNode(true)); 8919 } 8920 capturedNodeRef.current = wrapper; 8921 }); 8922 const isTransitioning = previousContentNode != null; 8923 let childrenToRender; 8924 if (!isTransitioning) { 8925 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { 8926 "data-current": true, 8927 ref: currentContainerRef, 8928 children 8929 }, currentContentKey); 8930 } else { 8931 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React44.Fragment, { 8932 children: [/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { 8933 "data-previous": true, 8934 inert: inertValue(true), 8935 ref: previousContainerRef, 8936 style: { 8937 ...previousContentDimensions ? { 8938 [cssVars.popupWidth]: `$previousContentDimensions.width}px`, 8939 [cssVars.popupHeight]: `$previousContentDimensions.height}px` 8940 } : null, 8941 position: "absolute" 8942 }, 8943 "data-ending-style": showStartingStyleAttribute ? void 0 : "" 8944 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { 8945 "data-current": true, 8946 ref: currentContainerRef, 8947 "data-starting-style": showStartingStyleAttribute ? "" : void 0, 8948 children 8949 }, currentContentKey)] 8950 }); 8951 } 8952 useIsoLayoutEffect(() => { 8953 const container = previousContainerRef.current; 8954 if (!container || !previousContentNode) { 8955 return; 8956 } 8957 container.replaceChildren(...Array.from(previousContentNode.childNodes)); 8958 }, [previousContentNode]); 8959 usePopupAutoResize({ 8960 popupElement, 8961 positionerElement, 8962 mounted, 8963 content: payload, 8964 onMeasureLayout: handleMeasureLayout, 8965 onMeasureLayoutComplete: handleMeasureLayoutComplete, 8966 side, 8967 direction 8968 }); 8969 const state = { 8970 activationDirection: getActivationDirection(newTriggerOffset), 8971 transitioning: isTransitioning 8972 }; 8973 return { 8974 children: childrenToRender, 8975 state 8976 }; 8977 } 8978 function getActivationDirection(offset4) { 8979 if (!offset4) { 8980 return void 0; 8981 } 8982 return `$getValueWithTolerance(offset4.horizontal, 5, "right", "left")} $getValueWithTolerance(offset4.vertical, 5, "down", "up")}`; 8983 } 8984 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) { 8985 if (value > tolerance) { 8986 return positiveLabel; 8987 } 8988 if (value < -tolerance) { 8989 return negativeLabel; 8990 } 8991 return ""; 8992 } 8993 function calculateRelativePosition(from, to) { 8994 const fromRect = from.getBoundingClientRect(); 8995 const toRect = to.getBoundingClientRect(); 8996 const fromCenter = { 8997 x: fromRect.left + fromRect.width / 2, 8998 y: fromRect.top + fromRect.height / 2 8999 }; 9000 const toCenter = { 9001 x: toRect.left + toRect.width / 2, 9002 y: toRect.top + toRect.height / 2 9003 }; 9004 return { 9005 horizontal: toCenter.x - fromCenter.x, 9006 vertical: toCenter.y - fromCenter.y 9007 }; 9008 } 9009 function usePopupContentKey(activeTriggerId, payload) { 9010 const [contentKey, setContentKey] = React44.useState(0); 9011 const previousActiveTriggerIdRef = React44.useRef(activeTriggerId); 9012 const previousPayloadRef = React44.useRef(payload); 9013 const pendingPayloadUpdateRef = React44.useRef(false); 9014 useIsoLayoutEffect(() => { 9015 const previousActiveTriggerId = previousActiveTriggerIdRef.current; 9016 const previousPayload = previousPayloadRef.current; 9017 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId; 9018 const payloadChanged = payload !== previousPayload; 9019 if (triggerIdChanged) { 9020 setContentKey((value) => value + 1); 9021 pendingPayloadUpdateRef.current = !payloadChanged; 9022 } else if (pendingPayloadUpdateRef.current && payloadChanged) { 9023 setContentKey((value) => value + 1); 9024 pendingPayloadUpdateRef.current = false; 9025 } 9026 previousActiveTriggerIdRef.current = activeTriggerId; 9027 previousPayloadRef.current = payload; 9028 }, [activeTriggerId, payload]); 9029 return `$activeTriggerId ?? "current"}-$contentKey}`; 9030 } 9031 9032 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js 9033 var React45 = __toESM(require_react(), 1); 9034 var ReactDOM6 = __toESM(require_react_dom(), 1); 9035 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); 9036 var FloatingPortalLite = /* @__PURE__ */ React45.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) { 9037 const { 9038 children, 9039 container, 9040 className, 9041 render: render4, 9042 style, 9043 ...elementProps 9044 } = componentProps; 9045 const { 9046 portalNode, 9047 portalSubtree 9048 } = useFloatingPortalNode({ 9049 container, 9050 ref: forwardedRef, 9051 componentProps, 9052 elementProps 9053 }); 9054 if (!portalSubtree && !portalNode) { 9055 return null; 9056 } 9057 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(React45.Fragment, { 9058 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)] 9059 }); 9060 }); 9061 if (true) FloatingPortalLite.displayName = "FloatingPortalLite"; 9062 9063 // node_modules/@base-ui/react/esm/tooltip/index.parts.js 9064 var index_parts_exports2 = {}; 9065 __export(index_parts_exports2, { 9066 Arrow: () => TooltipArrow, 9067 Handle: () => TooltipHandle, 9068 Popup: () => TooltipPopup, 9069 Portal: () => TooltipPortal, 9070 Positioner: () => TooltipPositioner, 9071 Provider: () => TooltipProvider, 9072 Root: () => TooltipRoot, 9073 Trigger: () => TooltipTrigger, 9074 Viewport: () => TooltipViewport, 9075 createHandle: () => createTooltipHandle 9076 }); 9077 9078 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js 9079 var React48 = __toESM(require_react(), 1); 9080 9081 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js 9082 var React46 = __toESM(require_react(), 1); 9083 var TooltipRootContext = /* @__PURE__ */ React46.createContext(void 0); 9084 if (true) TooltipRootContext.displayName = "TooltipRootContext"; 9085 function useTooltipRootContext(optional) { 9086 const context = React46.useContext(TooltipRootContext); 9087 if (context === void 0 && !optional) { 9088 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72)); 9089 } 9090 return context; 9091 } 9092 9093 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js 9094 var React47 = __toESM(require_react(), 1); 9095 var ReactDOM7 = __toESM(require_react_dom(), 1); 9096 var selectors2 = { 9097 ...popupStoreSelectors, 9098 disabled: createSelector((state) => state.disabled), 9099 instantType: createSelector((state) => state.instantType), 9100 isInstantPhase: createSelector((state) => state.isInstantPhase), 9101 trackCursorAxis: createSelector((state) => state.trackCursorAxis), 9102 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup), 9103 lastOpenChangeReason: createSelector((state) => state.openChangeReason), 9104 closeOnClick: createSelector((state) => state.closeOnClick), 9105 closeDelay: createSelector((state) => state.closeDelay), 9106 hasViewport: createSelector((state) => state.hasViewport) 9107 }; 9108 var TooltipStore = class _TooltipStore extends ReactStore { 9109 constructor(initialState) { 9110 super({ 9111 ...createInitialState(), 9112 ...initialState 9113 }, { 9114 popupRef: /* @__PURE__ */ React47.createRef(), 9115 onOpenChange: void 0, 9116 onOpenChangeComplete: void 0, 9117 triggerElements: new PopupTriggerMap() 9118 }, selectors2); 9119 } 9120 setOpen = (nextOpen, eventDetails) => { 9121 const reason = eventDetails.reason; 9122 const isHover = reason === reason_parts_exports.triggerHover; 9123 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus; 9124 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey); 9125 eventDetails.preventUnmountOnClose = () => { 9126 this.set("preventUnmountingOnClose", true); 9127 }; 9128 this.context.onOpenChange?.(nextOpen, eventDetails); 9129 if (eventDetails.isCanceled) { 9130 return; 9131 } 9132 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails); 9133 const changeState = () => { 9134 const updatedState = { 9135 open: nextOpen, 9136 openChangeReason: reason 9137 }; 9138 if (isFocusOpen) { 9139 updatedState.instantType = "focus"; 9140 } else if (isDismissClose) { 9141 updatedState.instantType = "dismiss"; 9142 } else if (reason === reason_parts_exports.triggerHover) { 9143 updatedState.instantType = void 0; 9144 } 9145 const newTriggerId = eventDetails.trigger?.id ?? null; 9146 if (newTriggerId || nextOpen) { 9147 updatedState.activeTriggerId = newTriggerId; 9148 updatedState.activeTriggerElement = eventDetails.trigger ?? null; 9149 } 9150 this.update(updatedState); 9151 }; 9152 if (isHover) { 9153 ReactDOM7.flushSync(changeState); 9154 } else { 9155 changeState(); 9156 } 9157 }; 9158 static useStore(externalStore, initialState) { 9159 const internalStore = useRefWithInit(() => { 9160 return new _TooltipStore(initialState); 9161 }).current; 9162 const store2 = externalStore ?? internalStore; 9163 const floatingRootContext = useSyncedFloatingRootContext({ 9164 popupStore: store2, 9165 onOpenChange: store2.setOpen 9166 }); 9167 store2.state.floatingRootContext = floatingRootContext; 9168 return store2; 9169 } 9170 }; 9171 function createInitialState() { 9172 return { 9173 ...createInitialPopupStoreState(), 9174 disabled: false, 9175 instantType: void 0, 9176 isInstantPhase: false, 9177 trackCursorAxis: "none", 9178 disableHoverablePopup: false, 9179 openChangeReason: null, 9180 closeOnClick: true, 9181 closeDelay: 0, 9182 hasViewport: false 9183 }; 9184 } 9185 9186 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js 9187 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); 9188 var TooltipRoot = fastComponent(function TooltipRoot2(props) { 9189 const { 9190 disabled: disabled2 = false, 9191 defaultOpen = false, 9192 open: openProp, 9193 disableHoverablePopup = false, 9194 trackCursorAxis = "none", 9195 actionsRef, 9196 onOpenChange, 9197 onOpenChangeComplete, 9198 handle, 9199 triggerId: triggerIdProp, 9200 defaultTriggerId: defaultTriggerIdProp = null, 9201 children 9202 } = props; 9203 const store2 = TooltipStore.useStore(handle?.store, { 9204 open: defaultOpen, 9205 openProp, 9206 activeTriggerId: defaultTriggerIdProp, 9207 triggerIdProp 9208 }); 9209 useOnFirstRender(() => { 9210 if (openProp === void 0 && store2.state.open === false && defaultOpen === true) { 9211 store2.update({ 9212 open: true, 9213 activeTriggerId: defaultTriggerIdProp 9214 }); 9215 } 9216 }); 9217 store2.useControlledProp("openProp", openProp); 9218 store2.useControlledProp("triggerIdProp", triggerIdProp); 9219 store2.useContextCallback("onOpenChange", onOpenChange); 9220 store2.useContextCallback("onOpenChangeComplete", onOpenChangeComplete); 9221 const openState = store2.useState("open"); 9222 const open = !disabled2 && openState; 9223 const activeTriggerId = store2.useState("activeTriggerId"); 9224 const payload = store2.useState("payload"); 9225 store2.useSyncedValues({ 9226 trackCursorAxis, 9227 disableHoverablePopup 9228 }); 9229 useIsoLayoutEffect(() => { 9230 if (openState && disabled2) { 9231 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled)); 9232 } 9233 }, [openState, disabled2, store2]); 9234 store2.useSyncedValue("disabled", disabled2); 9235 useImplicitActiveTrigger(store2); 9236 const { 9237 forceUnmount, 9238 transitionStatus 9239 } = useOpenStateTransitions(open, store2); 9240 const floatingRootContext = store2.select("floatingRootContext"); 9241 const isInstantPhase = store2.useState("isInstantPhase"); 9242 const instantType = store2.useState("instantType"); 9243 const lastOpenChangeReason = store2.useState("lastOpenChangeReason"); 9244 const previousInstantTypeRef = React48.useRef(null); 9245 useIsoLayoutEffect(() => { 9246 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) { 9247 if (instantType !== "delay") { 9248 previousInstantTypeRef.current = instantType; 9249 } 9250 store2.set("instantType", "delay"); 9251 } else if (previousInstantTypeRef.current !== null) { 9252 store2.set("instantType", previousInstantTypeRef.current); 9253 previousInstantTypeRef.current = null; 9254 } 9255 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store2]); 9256 useIsoLayoutEffect(() => { 9257 if (open) { 9258 if (activeTriggerId == null) { 9259 store2.set("payload", void 0); 9260 } 9261 } 9262 }, [store2, activeTriggerId, open]); 9263 const handleImperativeClose = React48.useCallback(() => { 9264 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction)); 9265 }, [store2]); 9266 React48.useImperativeHandle(actionsRef, () => ({ 9267 unmount: forceUnmount, 9268 close: handleImperativeClose 9269 }), [forceUnmount, handleImperativeClose]); 9270 const dismiss = useDismiss(floatingRootContext, { 9271 enabled: !disabled2, 9272 referencePress: () => store2.select("closeOnClick") 9273 }); 9274 const clientPoint = useClientPoint(floatingRootContext, { 9275 enabled: !disabled2 && trackCursorAxis !== "none", 9276 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis 9277 }); 9278 const { 9279 getReferenceProps, 9280 getFloatingProps, 9281 getTriggerProps 9282 } = useInteractions([dismiss, clientPoint]); 9283 const activeTriggerProps = React48.useMemo(() => getReferenceProps(), [getReferenceProps]); 9284 const inactiveTriggerProps = React48.useMemo(() => getTriggerProps(), [getTriggerProps]); 9285 const popupProps = React48.useMemo(() => getFloatingProps(), [getFloatingProps]); 9286 store2.useSyncedValues({ 9287 activeTriggerProps, 9288 inactiveTriggerProps, 9289 popupProps 9290 }); 9291 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipRootContext.Provider, { 9292 value: store2, 9293 children: typeof children === "function" ? children({ 9294 payload 9295 }) : children 9296 }); 9297 }); 9298 if (true) TooltipRoot.displayName = "TooltipRoot"; 9299 9300 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js 9301 var React50 = __toESM(require_react(), 1); 9302 9303 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js 9304 var React49 = __toESM(require_react(), 1); 9305 var TooltipProviderContext = /* @__PURE__ */ React49.createContext(void 0); 9306 if (true) TooltipProviderContext.displayName = "TooltipProviderContext"; 9307 function useTooltipProviderContext() { 9308 return React49.useContext(TooltipProviderContext); 9309 } 9310 9311 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js 9312 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) { 9313 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen"; 9314 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled"; 9315 return TooltipTriggerDataAttributes2; 9316 })({}); 9317 9318 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js 9319 var OPEN_DELAY = 600; 9320 9321 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js 9322 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) { 9323 const { 9324 className, 9325 render: render4, 9326 handle, 9327 payload, 9328 disabled: disabledProp, 9329 delay, 9330 closeOnClick = true, 9331 closeDelay, 9332 id: idProp, 9333 style, 9334 ...elementProps 9335 } = componentProps; 9336 const rootContext = useTooltipRootContext(true); 9337 const store2 = handle?.store ?? rootContext; 9338 if (!store2) { 9339 throw new Error(true ? "Base UI: <Tooltip.Trigger> must be either used within a <Tooltip.Root> component or provided with a handle." : formatErrorMessage_default(82)); 9340 } 9341 const thisTriggerId = useBaseUiId(idProp); 9342 const isTriggerActive = store2.useState("isTriggerActive", thisTriggerId); 9343 const isOpenedByThisTrigger = store2.useState("isOpenedByTrigger", thisTriggerId); 9344 const floatingRootContext = store2.useState("floatingRootContext"); 9345 const triggerElementRef = React50.useRef(null); 9346 const delayWithDefault = delay ?? OPEN_DELAY; 9347 const closeDelayWithDefault = closeDelay ?? 0; 9348 const { 9349 registerTrigger, 9350 isMountedByThisTrigger 9351 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store2, { 9352 payload, 9353 closeOnClick, 9354 closeDelay: closeDelayWithDefault 9355 }); 9356 const providerContext = useTooltipProviderContext(); 9357 const { 9358 delayRef, 9359 isInstantPhase, 9360 hasProvider 9361 } = useDelayGroup(floatingRootContext, { 9362 open: isOpenedByThisTrigger 9363 }); 9364 store2.useSyncedValue("isInstantPhase", isInstantPhase); 9365 const rootDisabled = store2.useState("disabled"); 9366 const disabled2 = disabledProp ?? rootDisabled; 9367 const trackCursorAxis = store2.useState("trackCursorAxis"); 9368 const disableHoverablePopup = store2.useState("disableHoverablePopup"); 9369 const hoverProps = useHoverReferenceInteraction(floatingRootContext, { 9370 enabled: !disabled2, 9371 mouseOnly: true, 9372 move: false, 9373 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null, 9374 restMs() { 9375 const providerDelay = providerContext?.delay; 9376 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0; 9377 let computedRestMs = delayWithDefault; 9378 if (hasProvider) { 9379 if (groupOpenValue !== 0) { 9380 computedRestMs = delay ?? providerDelay ?? delayWithDefault; 9381 } else { 9382 computedRestMs = 0; 9383 } 9384 } 9385 return computedRestMs; 9386 }, 9387 delay() { 9388 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0; 9389 let computedCloseDelay = closeDelayWithDefault; 9390 if (closeDelay == null && hasProvider) { 9391 computedCloseDelay = closeValue; 9392 } 9393 return { 9394 close: computedCloseDelay 9395 }; 9396 }, 9397 triggerElementRef, 9398 isActiveTrigger: isTriggerActive, 9399 isClosing: () => store2.select("transitionStatus") === "ending" 9400 }); 9401 const focusProps = useFocus(floatingRootContext, { 9402 enabled: !disabled2 9403 }).reference; 9404 const state = { 9405 open: isOpenedByThisTrigger 9406 }; 9407 const rootTriggerProps = store2.useState("triggerProps", isMountedByThisTrigger); 9408 const element = useRenderElement("button", componentProps, { 9409 state, 9410 ref: [forwardedRef, registerTrigger, triggerElementRef], 9411 props: [hoverProps, focusProps, rootTriggerProps, { 9412 onPointerDown() { 9413 store2.set("closeOnClick", closeOnClick); 9414 }, 9415 id: thisTriggerId, 9416 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0 9417 }, elementProps], 9418 stateAttributesMapping: triggerOpenStateMapping2 9419 }); 9420 return element; 9421 }); 9422 if (true) TooltipTrigger.displayName = "TooltipTrigger"; 9423 9424 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js 9425 var React52 = __toESM(require_react(), 1); 9426 9427 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js 9428 var React51 = __toESM(require_react(), 1); 9429 var TooltipPortalContext = /* @__PURE__ */ React51.createContext(void 0); 9430 if (true) TooltipPortalContext.displayName = "TooltipPortalContext"; 9431 function useTooltipPortalContext() { 9432 const value = React51.useContext(TooltipPortalContext); 9433 if (value === void 0) { 9434 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70)); 9435 } 9436 return value; 9437 } 9438 9439 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js 9440 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); 9441 var TooltipPortal = /* @__PURE__ */ React52.forwardRef(function TooltipPortal2(props, forwardedRef) { 9442 const { 9443 keepMounted = false, 9444 ...portalProps 9445 } = props; 9446 const store2 = useTooltipRootContext(); 9447 const mounted = store2.useState("mounted"); 9448 const shouldRender = mounted || keepMounted; 9449 if (!shouldRender) { 9450 return null; 9451 } 9452 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPortalContext.Provider, { 9453 value: keepMounted, 9454 children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloatingPortalLite, { 9455 ref: forwardedRef, 9456 ...portalProps 9457 }) 9458 }); 9459 }); 9460 if (true) TooltipPortal.displayName = "TooltipPortal"; 9461 9462 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js 9463 var React54 = __toESM(require_react(), 1); 9464 9465 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js 9466 var React53 = __toESM(require_react(), 1); 9467 var TooltipPositionerContext = /* @__PURE__ */ React53.createContext(void 0); 9468 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext"; 9469 function useTooltipPositionerContext() { 9470 const context = React53.useContext(TooltipPositionerContext); 9471 if (context === void 0) { 9472 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71)); 9473 } 9474 return context; 9475 } 9476 9477 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js 9478 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); 9479 var TooltipPositioner = /* @__PURE__ */ React54.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) { 9480 const { 9481 render: render4, 9482 className, 9483 anchor, 9484 positionMethod = "absolute", 9485 side = "top", 9486 align = "center", 9487 sideOffset = 0, 9488 alignOffset = 0, 9489 collisionBoundary = "clipping-ancestors", 9490 collisionPadding = 5, 9491 arrowPadding = 5, 9492 sticky = false, 9493 disableAnchorTracking = false, 9494 collisionAvoidance = POPUP_COLLISION_AVOIDANCE, 9495 style, 9496 ...elementProps 9497 } = componentProps; 9498 const store2 = useTooltipRootContext(); 9499 const keepMounted = useTooltipPortalContext(); 9500 const open = store2.useState("open"); 9501 const mounted = store2.useState("mounted"); 9502 const trackCursorAxis = store2.useState("trackCursorAxis"); 9503 const disableHoverablePopup = store2.useState("disableHoverablePopup"); 9504 const floatingRootContext = store2.useState("floatingRootContext"); 9505 const instantType = store2.useState("instantType"); 9506 const transitionStatus = store2.useState("transitionStatus"); 9507 const hasViewport = store2.useState("hasViewport"); 9508 const positioning = useAnchorPositioning({ 9509 anchor, 9510 positionMethod, 9511 floatingRootContext, 9512 mounted, 9513 side, 9514 sideOffset, 9515 align, 9516 alignOffset, 9517 collisionBoundary, 9518 collisionPadding, 9519 sticky, 9520 arrowPadding, 9521 disableAnchorTracking, 9522 keepMounted, 9523 collisionAvoidance, 9524 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0 9525 }); 9526 const state = React54.useMemo(() => ({ 9527 open, 9528 side: positioning.side, 9529 align: positioning.align, 9530 anchorHidden: positioning.anchorHidden, 9531 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType 9532 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]); 9533 const element = usePositioner(componentProps, state, { 9534 styles: positioning.positionerStyles, 9535 transitionStatus, 9536 props: elementProps, 9537 refs: [forwardedRef, store2.useStateSetter("positionerElement")], 9538 hidden: !mounted, 9539 inert: !open || trackCursorAxis === "both" || disableHoverablePopup 9540 }); 9541 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipPositionerContext.Provider, { 9542 value: positioning, 9543 children: element 9544 }); 9545 }); 9546 if (true) TooltipPositioner.displayName = "TooltipPositioner"; 9547 9548 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js 9549 var React55 = __toESM(require_react(), 1); 9550 var stateAttributesMapping2 = { 9551 ...popupStateMapping, 9552 ...transitionStatusMapping 9553 }; 9554 var TooltipPopup = /* @__PURE__ */ React55.forwardRef(function TooltipPopup2(componentProps, forwardedRef) { 9555 const { 9556 className, 9557 render: render4, 9558 style, 9559 ...elementProps 9560 } = componentProps; 9561 const store2 = useTooltipRootContext(); 9562 const { 9563 side, 9564 align 9565 } = useTooltipPositionerContext(); 9566 const open = store2.useState("open"); 9567 const instantType = store2.useState("instantType"); 9568 const transitionStatus = store2.useState("transitionStatus"); 9569 const popupProps = store2.useState("popupProps"); 9570 const floatingContext = store2.useState("floatingRootContext"); 9571 useOpenChangeComplete({ 9572 open, 9573 ref: store2.context.popupRef, 9574 onComplete() { 9575 if (open) { 9576 store2.context.onOpenChangeComplete?.(true); 9577 } 9578 } 9579 }); 9580 const disabled2 = store2.useState("disabled"); 9581 const closeDelay = store2.useState("closeDelay"); 9582 useHoverFloatingInteraction(floatingContext, { 9583 enabled: !disabled2, 9584 closeDelay 9585 }); 9586 const state = { 9587 open, 9588 side, 9589 align, 9590 instant: instantType, 9591 transitionStatus 9592 }; 9593 const element = useRenderElement("div", componentProps, { 9594 state, 9595 ref: [forwardedRef, store2.context.popupRef, store2.useStateSetter("popupElement")], 9596 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps], 9597 stateAttributesMapping: stateAttributesMapping2 9598 }); 9599 return element; 9600 }); 9601 if (true) TooltipPopup.displayName = "TooltipPopup"; 9602 9603 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js 9604 var React56 = __toESM(require_react(), 1); 9605 var TooltipArrow = /* @__PURE__ */ React56.forwardRef(function TooltipArrow2(componentProps, forwardedRef) { 9606 const { 9607 className, 9608 render: render4, 9609 style, 9610 ...elementProps 9611 } = componentProps; 9612 const store2 = useTooltipRootContext(); 9613 const open = store2.useState("open"); 9614 const instantType = store2.useState("instantType"); 9615 const { 9616 arrowRef, 9617 side, 9618 align, 9619 arrowUncentered, 9620 arrowStyles 9621 } = useTooltipPositionerContext(); 9622 const state = { 9623 open, 9624 side, 9625 align, 9626 uncentered: arrowUncentered, 9627 instant: instantType 9628 }; 9629 const element = useRenderElement("div", componentProps, { 9630 state, 9631 ref: [forwardedRef, arrowRef], 9632 props: [{ 9633 style: arrowStyles, 9634 "aria-hidden": true 9635 }, elementProps], 9636 stateAttributesMapping: popupStateMapping 9637 }); 9638 return element; 9639 }); 9640 if (true) TooltipArrow.displayName = "TooltipArrow"; 9641 9642 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js 9643 var React57 = __toESM(require_react(), 1); 9644 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); 9645 var TooltipProvider = function TooltipProvider2(props) { 9646 const { 9647 delay, 9648 closeDelay, 9649 timeout = 400 9650 } = props; 9651 const contextValue = React57.useMemo(() => ({ 9652 delay, 9653 closeDelay 9654 }), [delay, closeDelay]); 9655 const delayValue = React57.useMemo(() => ({ 9656 open: delay, 9657 close: closeDelay 9658 }), [delay, closeDelay]); 9659 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipProviderContext.Provider, { 9660 value: contextValue, 9661 children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatingDelayGroup, { 9662 delay: delayValue, 9663 timeoutMs: timeout, 9664 children: props.children 9665 }) 9666 }); 9667 }; 9668 if (true) TooltipProvider.displayName = "TooltipProvider"; 9669 9670 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js 9671 var React58 = __toESM(require_react(), 1); 9672 9673 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js 9674 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) { 9675 TooltipViewportCssVars2["popupWidth"] = "--popup-width"; 9676 TooltipViewportCssVars2["popupHeight"] = "--popup-height"; 9677 return TooltipViewportCssVars2; 9678 })({}); 9679 9680 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js 9681 var stateAttributesMapping3 = { 9682 activationDirection: (value) => value ? { 9683 "data-activation-direction": value 9684 } : null 9685 }; 9686 var TooltipViewport = /* @__PURE__ */ React58.forwardRef(function TooltipViewport2(componentProps, forwardedRef) { 9687 const { 9688 render: render4, 9689 className, 9690 style, 9691 children, 9692 ...elementProps 9693 } = componentProps; 9694 const store2 = useTooltipRootContext(); 9695 const positioner = useTooltipPositionerContext(); 9696 const instantType = store2.useState("instantType"); 9697 const { 9698 children: childrenToRender, 9699 state: viewportState 9700 } = usePopupViewport({ 9701 store: store2, 9702 side: positioner.side, 9703 cssVars: TooltipViewportCssVars, 9704 children 9705 }); 9706 const state = { 9707 activationDirection: viewportState.activationDirection, 9708 transitioning: viewportState.transitioning, 9709 instant: instantType 9710 }; 9711 return useRenderElement("div", componentProps, { 9712 state, 9713 ref: forwardedRef, 9714 props: [elementProps, { 9715 children: childrenToRender 9716 }], 9717 stateAttributesMapping: stateAttributesMapping3 9718 }); 9719 }); 9720 if (true) TooltipViewport.displayName = "TooltipViewport"; 9721 9722 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js 9723 var TooltipHandle = class { 9724 /** 9725 * Internal store holding the tooltip state. 9726 * @internal 9727 */ 9728 constructor() { 9729 this.store = new TooltipStore(); 9730 } 9731 /** 9732 * Opens the tooltip and associates it with the trigger with the given ID. 9733 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop. 9734 * 9735 * This method should only be called in an event handler or an effect (not during rendering). 9736 * 9737 * @param triggerId ID of the trigger to associate with the tooltip. 9738 */ 9739 open(triggerId) { 9740 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0; 9741 if (triggerId && !triggerElement) { 9742 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "$triggerId}".` : formatErrorMessage_default(81, triggerId)); 9743 } 9744 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement)); 9745 } 9746 /** 9747 * Closes the tooltip. 9748 */ 9749 close() { 9750 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0)); 9751 } 9752 /** 9753 * Indicates whether the tooltip is currently open. 9754 */ 9755 get isOpen() { 9756 return this.store.state.open; 9757 } 9758 }; 9759 function createTooltipHandle() { 9760 return new TooltipHandle(); 9761 } 9762 9763 // node_modules/@base-ui/react/esm/use-render/useRender.js 9764 function useRender(params) { 9765 return useRenderElement(params.defaultTagName ?? "div", params, params); 9766 } 9767 9768 // packages/ui/build-module/text/text.mjs 9769 var import_element8 = __toESM(require_element(), 1); 9770 var STYLE_HASH_ATTRIBUTE = "data-wp-hash"; 9771 function getRuntime() { 9772 const globalScope = globalThis; 9773 if (globalScope.__wpStyleRuntime) { 9774 return globalScope.__wpStyleRuntime; 9775 } 9776 globalScope.__wpStyleRuntime = { 9777 documents: /* @__PURE__ */ new Map(), 9778 styles: /* @__PURE__ */ new Map(), 9779 injectedStyles: /* @__PURE__ */ new WeakMap() 9780 }; 9781 if (typeof document !== "undefined") { 9782 registerDocument(document); 9783 } 9784 return globalScope.__wpStyleRuntime; 9785 } 9786 function documentContainsStyleHash(targetDocument, hash) { 9787 if (!targetDocument.head) { 9788 return false; 9789 } 9790 for (const style of targetDocument.head.querySelectorAll( 9791 `style[$STYLE_HASH_ATTRIBUTE}]` 9792 )) { 9793 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) { 9794 return true; 9795 } 9796 } 9797 return false; 9798 } 9799 function injectStyle(targetDocument, hash, css) { 9800 if (!targetDocument.head) { 9801 return; 9802 } 9803 const runtime = getRuntime(); 9804 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9805 if (!injectedStyles) { 9806 injectedStyles = /* @__PURE__ */ new Set(); 9807 runtime.injectedStyles.set(targetDocument, injectedStyles); 9808 } 9809 if (injectedStyles.has(hash)) { 9810 return; 9811 } 9812 if (documentContainsStyleHash(targetDocument, hash)) { 9813 injectedStyles.add(hash); 9814 return; 9815 } 9816 const style = targetDocument.createElement("style"); 9817 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash); 9818 style.appendChild(targetDocument.createTextNode(css)); 9819 targetDocument.head.appendChild(style); 9820 injectedStyles.add(hash); 9821 } 9822 function registerDocument(targetDocument) { 9823 const runtime = getRuntime(); 9824 runtime.documents.set( 9825 targetDocument, 9826 (runtime.documents.get(targetDocument) ?? 0) + 1 9827 ); 9828 for (const [hash, css] of runtime.styles) { 9829 injectStyle(targetDocument, hash, css); 9830 } 9831 return () => { 9832 const count = runtime.documents.get(targetDocument); 9833 if (count === void 0) { 9834 return; 9835 } 9836 if (count <= 1) { 9837 runtime.documents.delete(targetDocument); 9838 return; 9839 } 9840 runtime.documents.set(targetDocument, count - 1); 9841 }; 9842 } 9843 function registerStyle(hash, css) { 9844 const runtime = getRuntime(); 9845 runtime.styles.set(hash, css); 9846 for (const targetDocument of runtime.documents.keys()) { 9847 injectStyle(targetDocument, hash, css); 9848 } 9849 } 9850 if (typeof process === "undefined" || true) { 9851 registerStyle("0c8601dd83", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}'); 9852 } 9853 var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" }; 9854 if (typeof process === "undefined" || true) { 9855 registerStyle("1fb29d3a3c", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}"); 9856 } 9857 var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" }; 9858 var Text = (0, import_element8.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) { 9859 const element = useRender({ 9860 render: render4, 9861 defaultTagName: "span", 9862 ref, 9863 props: mergeProps(props, { 9864 className: clsx_default( 9865 style_default.text, 9866 global_css_defense_default.heading, 9867 global_css_defense_default.p, 9868 style_default[variant], 9869 className 9870 ) 9871 }) 9872 }); 9873 return element; 9874 }); 9875 9876 // packages/ui/build-module/badge/badge.mjs 9877 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); 9878 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash"; 9879 function getRuntime2() { 9880 const globalScope = globalThis; 9881 if (globalScope.__wpStyleRuntime) { 9882 return globalScope.__wpStyleRuntime; 9883 } 9884 globalScope.__wpStyleRuntime = { 9885 documents: /* @__PURE__ */ new Map(), 9886 styles: /* @__PURE__ */ new Map(), 9887 injectedStyles: /* @__PURE__ */ new WeakMap() 9888 }; 9889 if (typeof document !== "undefined") { 9890 registerDocument2(document); 9891 } 9892 return globalScope.__wpStyleRuntime; 9893 } 9894 function documentContainsStyleHash2(targetDocument, hash) { 9895 if (!targetDocument.head) { 9896 return false; 9897 } 9898 for (const style of targetDocument.head.querySelectorAll( 9899 `style[$STYLE_HASH_ATTRIBUTE2}]` 9900 )) { 9901 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) { 9902 return true; 9903 } 9904 } 9905 return false; 9906 } 9907 function injectStyle2(targetDocument, hash, css) { 9908 if (!targetDocument.head) { 9909 return; 9910 } 9911 const runtime = getRuntime2(); 9912 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9913 if (!injectedStyles) { 9914 injectedStyles = /* @__PURE__ */ new Set(); 9915 runtime.injectedStyles.set(targetDocument, injectedStyles); 9916 } 9917 if (injectedStyles.has(hash)) { 9918 return; 9919 } 9920 if (documentContainsStyleHash2(targetDocument, hash)) { 9921 injectedStyles.add(hash); 9922 return; 9923 } 9924 const style = targetDocument.createElement("style"); 9925 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash); 9926 style.appendChild(targetDocument.createTextNode(css)); 9927 targetDocument.head.appendChild(style); 9928 injectedStyles.add(hash); 9929 } 9930 function registerDocument2(targetDocument) { 9931 const runtime = getRuntime2(); 9932 runtime.documents.set( 9933 targetDocument, 9934 (runtime.documents.get(targetDocument) ?? 0) + 1 9935 ); 9936 for (const [hash, css] of runtime.styles) { 9937 injectStyle2(targetDocument, hash, css); 9938 } 9939 return () => { 9940 const count = runtime.documents.get(targetDocument); 9941 if (count === void 0) { 9942 return; 9943 } 9944 if (count <= 1) { 9945 runtime.documents.delete(targetDocument); 9946 return; 9947 } 9948 runtime.documents.set(targetDocument, count - 1); 9949 }; 9950 } 9951 function registerStyle2(hash, css) { 9952 const runtime = getRuntime2(); 9953 runtime.styles.set(hash, css); 9954 for (const targetDocument of runtime.documents.keys()) { 9955 injectStyle2(targetDocument, hash, css); 9956 } 9957 } 9958 if (typeof process === "undefined" || true) { 9959 registerStyle2("d6a685e1aa", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-bg-surface-error,#f6e6e3);color:var(--wpds-color-fg-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-bg-surface-warning,#fde6be);color:var(--wpds-color-fg-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-bg-surface-caution,#fee995);color:var(--wpds-color-fg-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-bg-surface-success,#c6f7cd);color:var(--wpds-color-fg-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-bg-surface-info,#deebfa);color:var(--wpds-color-fg-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-fg-content-neutral,#1e1e1e);padding-block:calc(var(--wpds-dimension-padding-xs, 4px) - var(--wpds-border-width-xs, 1px));padding-inline:calc(var(--wpds-dimension-padding-sm, 8px) - var(--wpds-border-width-xs, 1px))}}"); 9960 } 9961 var style_default2 = { "badge": "_96e6251aad1a6136__badge", "is-high-intent": "_99f7158cb520f750__is-high-intent", "is-medium-intent": "c20ebef2365bc8b7__is-medium-intent", "is-low-intent": "_365e1626c6202e52__is-low-intent", "is-stable-intent": "_33f8198127ddf4ef__is-stable-intent", "is-informational-intent": "_04c1aca8fc449412__is-informational-intent", "is-draft-intent": "_90726e69d495ec19__is-draft-intent", "is-none-intent": "_898f4a544993bd39__is-none-intent" }; 9962 var Badge = (0, import_element9.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) { 9963 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 9964 Text, 9965 { 9966 ref, 9967 className: clsx_default( 9968 style_default2.badge, 9969 style_default2[`is-$intent}-intent`], 9970 className 9971 ), 9972 ...props, 9973 variant: "body-sm" 9974 } 9975 ); 9976 }); 9977 9978 // packages/ui/build-module/icon/icon.mjs 9979 var import_element10 = __toESM(require_element(), 1); 9980 var import_primitives = __toESM(require_primitives(), 1); 9981 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); 9982 var Icon = (0, import_element10.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) { 9983 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( 9984 import_primitives.SVG, 9985 { 9986 ref, 9987 fill: "currentColor", 9988 ...icon.props, 9989 ...restProps, 9990 width: size4, 9991 height: size4 9992 } 9993 ); 9994 }); 9995 9996 // packages/ui/build-module/card/index.mjs 9997 var card_exports = {}; 9998 __export(card_exports, { 9999 Content: () => Content, 10000 FullBleed: () => FullBleed, 10001 Header: () => Header, 10002 Root: () => Root, 10003 Title: () => Title 10004 }); 10005 10006 // packages/ui/build-module/card/root.mjs 10007 var import_element11 = __toESM(require_element(), 1); 10008 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash"; 10009 function getRuntime3() { 10010 const globalScope = globalThis; 10011 if (globalScope.__wpStyleRuntime) { 10012 return globalScope.__wpStyleRuntime; 10013 } 10014 globalScope.__wpStyleRuntime = { 10015 documents: /* @__PURE__ */ new Map(), 10016 styles: /* @__PURE__ */ new Map(), 10017 injectedStyles: /* @__PURE__ */ new WeakMap() 10018 }; 10019 if (typeof document !== "undefined") { 10020 registerDocument3(document); 10021 } 10022 return globalScope.__wpStyleRuntime; 10023 } 10024 function documentContainsStyleHash3(targetDocument, hash) { 10025 if (!targetDocument.head) { 10026 return false; 10027 } 10028 for (const style of targetDocument.head.querySelectorAll( 10029 `style[$STYLE_HASH_ATTRIBUTE3}]` 10030 )) { 10031 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) { 10032 return true; 10033 } 10034 } 10035 return false; 10036 } 10037 function injectStyle3(targetDocument, hash, css) { 10038 if (!targetDocument.head) { 10039 return; 10040 } 10041 const runtime = getRuntime3(); 10042 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10043 if (!injectedStyles) { 10044 injectedStyles = /* @__PURE__ */ new Set(); 10045 runtime.injectedStyles.set(targetDocument, injectedStyles); 10046 } 10047 if (injectedStyles.has(hash)) { 10048 return; 10049 } 10050 if (documentContainsStyleHash3(targetDocument, hash)) { 10051 injectedStyles.add(hash); 10052 return; 10053 } 10054 const style = targetDocument.createElement("style"); 10055 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash); 10056 style.appendChild(targetDocument.createTextNode(css)); 10057 targetDocument.head.appendChild(style); 10058 injectedStyles.add(hash); 10059 } 10060 function registerDocument3(targetDocument) { 10061 const runtime = getRuntime3(); 10062 runtime.documents.set( 10063 targetDocument, 10064 (runtime.documents.get(targetDocument) ?? 0) + 1 10065 ); 10066 for (const [hash, css] of runtime.styles) { 10067 injectStyle3(targetDocument, hash, css); 10068 } 10069 return () => { 10070 const count = runtime.documents.get(targetDocument); 10071 if (count === void 0) { 10072 return; 10073 } 10074 if (count <= 1) { 10075 runtime.documents.delete(targetDocument); 10076 return; 10077 } 10078 runtime.documents.set(targetDocument, count - 1); 10079 }; 10080 } 10081 function registerStyle3(hash, css) { 10082 const runtime = getRuntime3(); 10083 runtime.styles.set(hash, css); 10084 for (const targetDocument of runtime.documents.keys()) { 10085 injectStyle3(targetDocument, hash, css); 10086 } 10087 } 10088 if (typeof process === "undefined" || true) { 10089 registerStyle3("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}"); 10090 } 10091 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 10092 if (typeof process === "undefined" || true) { 10093 registerStyle3("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}"); 10094 } 10095 var style_default3 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 10096 var Root = (0, import_element11.forwardRef)(function Card({ render: render4, ...restProps }, ref) { 10097 const mergedClassName = clsx_default(style_default3.root, resets_default["box-sizing"]); 10098 const element = useRender({ 10099 defaultTagName: "div", 10100 render: render4, 10101 ref, 10102 props: mergeProps({ className: mergedClassName }, restProps) 10103 }); 10104 return element; 10105 }); 10106 10107 // packages/ui/build-module/card/header.mjs 10108 var import_element12 = __toESM(require_element(), 1); 10109 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash"; 10110 function getRuntime4() { 10111 const globalScope = globalThis; 10112 if (globalScope.__wpStyleRuntime) { 10113 return globalScope.__wpStyleRuntime; 10114 } 10115 globalScope.__wpStyleRuntime = { 10116 documents: /* @__PURE__ */ new Map(), 10117 styles: /* @__PURE__ */ new Map(), 10118 injectedStyles: /* @__PURE__ */ new WeakMap() 10119 }; 10120 if (typeof document !== "undefined") { 10121 registerDocument4(document); 10122 } 10123 return globalScope.__wpStyleRuntime; 10124 } 10125 function documentContainsStyleHash4(targetDocument, hash) { 10126 if (!targetDocument.head) { 10127 return false; 10128 } 10129 for (const style of targetDocument.head.querySelectorAll( 10130 `style[$STYLE_HASH_ATTRIBUTE4}]` 10131 )) { 10132 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) { 10133 return true; 10134 } 10135 } 10136 return false; 10137 } 10138 function injectStyle4(targetDocument, hash, css) { 10139 if (!targetDocument.head) { 10140 return; 10141 } 10142 const runtime = getRuntime4(); 10143 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10144 if (!injectedStyles) { 10145 injectedStyles = /* @__PURE__ */ new Set(); 10146 runtime.injectedStyles.set(targetDocument, injectedStyles); 10147 } 10148 if (injectedStyles.has(hash)) { 10149 return; 10150 } 10151 if (documentContainsStyleHash4(targetDocument, hash)) { 10152 injectedStyles.add(hash); 10153 return; 10154 } 10155 const style = targetDocument.createElement("style"); 10156 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash); 10157 style.appendChild(targetDocument.createTextNode(css)); 10158 targetDocument.head.appendChild(style); 10159 injectedStyles.add(hash); 10160 } 10161 function registerDocument4(targetDocument) { 10162 const runtime = getRuntime4(); 10163 runtime.documents.set( 10164 targetDocument, 10165 (runtime.documents.get(targetDocument) ?? 0) + 1 10166 ); 10167 for (const [hash, css] of runtime.styles) { 10168 injectStyle4(targetDocument, hash, css); 10169 } 10170 return () => { 10171 const count = runtime.documents.get(targetDocument); 10172 if (count === void 0) { 10173 return; 10174 } 10175 if (count <= 1) { 10176 runtime.documents.delete(targetDocument); 10177 return; 10178 } 10179 runtime.documents.set(targetDocument, count - 1); 10180 }; 10181 } 10182 function registerStyle4(hash, css) { 10183 const runtime = getRuntime4(); 10184 runtime.styles.set(hash, css); 10185 for (const targetDocument of runtime.documents.keys()) { 10186 injectStyle4(targetDocument, hash, css); 10187 } 10188 } 10189 if (typeof process === "undefined" || true) { 10190 registerStyle4("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}"); 10191 } 10192 var style_default4 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 10193 var Header = (0, import_element12.forwardRef)( 10194 function CardHeader({ render: render4, ...props }, ref) { 10195 const element = useRender({ 10196 defaultTagName: "div", 10197 render: render4, 10198 ref, 10199 props: mergeProps({ className: style_default4.header }, props) 10200 }); 10201 return element; 10202 } 10203 ); 10204 10205 // packages/ui/build-module/card/content.mjs 10206 var import_element13 = __toESM(require_element(), 1); 10207 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash"; 10208 function getRuntime5() { 10209 const globalScope = globalThis; 10210 if (globalScope.__wpStyleRuntime) { 10211 return globalScope.__wpStyleRuntime; 10212 } 10213 globalScope.__wpStyleRuntime = { 10214 documents: /* @__PURE__ */ new Map(), 10215 styles: /* @__PURE__ */ new Map(), 10216 injectedStyles: /* @__PURE__ */ new WeakMap() 10217 }; 10218 if (typeof document !== "undefined") { 10219 registerDocument5(document); 10220 } 10221 return globalScope.__wpStyleRuntime; 10222 } 10223 function documentContainsStyleHash5(targetDocument, hash) { 10224 if (!targetDocument.head) { 10225 return false; 10226 } 10227 for (const style of targetDocument.head.querySelectorAll( 10228 `style[$STYLE_HASH_ATTRIBUTE5}]` 10229 )) { 10230 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) { 10231 return true; 10232 } 10233 } 10234 return false; 10235 } 10236 function injectStyle5(targetDocument, hash, css) { 10237 if (!targetDocument.head) { 10238 return; 10239 } 10240 const runtime = getRuntime5(); 10241 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10242 if (!injectedStyles) { 10243 injectedStyles = /* @__PURE__ */ new Set(); 10244 runtime.injectedStyles.set(targetDocument, injectedStyles); 10245 } 10246 if (injectedStyles.has(hash)) { 10247 return; 10248 } 10249 if (documentContainsStyleHash5(targetDocument, hash)) { 10250 injectedStyles.add(hash); 10251 return; 10252 } 10253 const style = targetDocument.createElement("style"); 10254 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash); 10255 style.appendChild(targetDocument.createTextNode(css)); 10256 targetDocument.head.appendChild(style); 10257 injectedStyles.add(hash); 10258 } 10259 function registerDocument5(targetDocument) { 10260 const runtime = getRuntime5(); 10261 runtime.documents.set( 10262 targetDocument, 10263 (runtime.documents.get(targetDocument) ?? 0) + 1 10264 ); 10265 for (const [hash, css] of runtime.styles) { 10266 injectStyle5(targetDocument, hash, css); 10267 } 10268 return () => { 10269 const count = runtime.documents.get(targetDocument); 10270 if (count === void 0) { 10271 return; 10272 } 10273 if (count <= 1) { 10274 runtime.documents.delete(targetDocument); 10275 return; 10276 } 10277 runtime.documents.set(targetDocument, count - 1); 10278 }; 10279 } 10280 function registerStyle5(hash, css) { 10281 const runtime = getRuntime5(); 10282 runtime.styles.set(hash, css); 10283 for (const targetDocument of runtime.documents.keys()) { 10284 injectStyle5(targetDocument, hash, css); 10285 } 10286 } 10287 if (typeof process === "undefined" || true) { 10288 registerStyle5("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}"); 10289 } 10290 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 10291 var Content = (0, import_element13.forwardRef)( 10292 function CardContent({ render: render4, ...props }, ref) { 10293 const element = useRender({ 10294 defaultTagName: "div", 10295 render: render4, 10296 ref, 10297 props: mergeProps({ className: style_default5.content }, props) 10298 }); 10299 return element; 10300 } 10301 ); 10302 10303 // packages/ui/build-module/card/full-bleed.mjs 10304 var import_element14 = __toESM(require_element(), 1); 10305 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash"; 10306 function getRuntime6() { 10307 const globalScope = globalThis; 10308 if (globalScope.__wpStyleRuntime) { 10309 return globalScope.__wpStyleRuntime; 10310 } 10311 globalScope.__wpStyleRuntime = { 10312 documents: /* @__PURE__ */ new Map(), 10313 styles: /* @__PURE__ */ new Map(), 10314 injectedStyles: /* @__PURE__ */ new WeakMap() 10315 }; 10316 if (typeof document !== "undefined") { 10317 registerDocument6(document); 10318 } 10319 return globalScope.__wpStyleRuntime; 10320 } 10321 function documentContainsStyleHash6(targetDocument, hash) { 10322 if (!targetDocument.head) { 10323 return false; 10324 } 10325 for (const style of targetDocument.head.querySelectorAll( 10326 `style[$STYLE_HASH_ATTRIBUTE6}]` 10327 )) { 10328 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) { 10329 return true; 10330 } 10331 } 10332 return false; 10333 } 10334 function injectStyle6(targetDocument, hash, css) { 10335 if (!targetDocument.head) { 10336 return; 10337 } 10338 const runtime = getRuntime6(); 10339 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10340 if (!injectedStyles) { 10341 injectedStyles = /* @__PURE__ */ new Set(); 10342 runtime.injectedStyles.set(targetDocument, injectedStyles); 10343 } 10344 if (injectedStyles.has(hash)) { 10345 return; 10346 } 10347 if (documentContainsStyleHash6(targetDocument, hash)) { 10348 injectedStyles.add(hash); 10349 return; 10350 } 10351 const style = targetDocument.createElement("style"); 10352 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash); 10353 style.appendChild(targetDocument.createTextNode(css)); 10354 targetDocument.head.appendChild(style); 10355 injectedStyles.add(hash); 10356 } 10357 function registerDocument6(targetDocument) { 10358 const runtime = getRuntime6(); 10359 runtime.documents.set( 10360 targetDocument, 10361 (runtime.documents.get(targetDocument) ?? 0) + 1 10362 ); 10363 for (const [hash, css] of runtime.styles) { 10364 injectStyle6(targetDocument, hash, css); 10365 } 10366 return () => { 10367 const count = runtime.documents.get(targetDocument); 10368 if (count === void 0) { 10369 return; 10370 } 10371 if (count <= 1) { 10372 runtime.documents.delete(targetDocument); 10373 return; 10374 } 10375 runtime.documents.set(targetDocument, count - 1); 10376 }; 10377 } 10378 function registerStyle6(hash, css) { 10379 const runtime = getRuntime6(); 10380 runtime.styles.set(hash, css); 10381 for (const targetDocument of runtime.documents.keys()) { 10382 injectStyle6(targetDocument, hash, css); 10383 } 10384 } 10385 if (typeof process === "undefined" || true) { 10386 registerStyle6("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}"); 10387 } 10388 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 10389 var FullBleed = (0, import_element14.forwardRef)( 10390 function CardFullBleed({ render: render4, ...props }, ref) { 10391 const element = useRender({ 10392 defaultTagName: "div", 10393 render: render4, 10394 ref, 10395 props: mergeProps( 10396 { className: style_default6.fullbleed }, 10397 props 10398 ) 10399 }); 10400 return element; 10401 } 10402 ); 10403 10404 // packages/ui/build-module/card/title.mjs 10405 var import_element15 = __toESM(require_element(), 1); 10406 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); 10407 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", {}); 10408 var Title = (0, import_element15.forwardRef)( 10409 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) { 10410 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 10411 Text, 10412 { 10413 ref, 10414 variant: "heading-lg", 10415 render: render4, 10416 ...props, 10417 children 10418 } 10419 ); 10420 } 10421 ); 10422 10423 // packages/ui/build-module/collapsible/panel.mjs 10424 var import_element16 = __toESM(require_element(), 1); 10425 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); 10426 var Panel = (0, import_element16.forwardRef)( 10427 function CollapsiblePanel3(props, forwardedRef) { 10428 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props }); 10429 } 10430 ); 10431 10432 // packages/ui/build-module/collapsible/root.mjs 10433 var import_element17 = __toESM(require_element(), 1); 10434 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); 10435 var Root2 = (0, import_element17.forwardRef)( 10436 function CollapsibleRoot3(props, forwardedRef) { 10437 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props }); 10438 } 10439 ); 10440 10441 // packages/ui/build-module/collapsible/trigger.mjs 10442 var import_element18 = __toESM(require_element(), 1); 10443 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); 10444 var Trigger = (0, import_element18.forwardRef)( 10445 function CollapsibleTrigger3(props, forwardedRef) { 10446 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props }); 10447 } 10448 ); 10449 10450 // packages/ui/build-module/collapsible-card/index.mjs 10451 var collapsible_card_exports = {}; 10452 __export(collapsible_card_exports, { 10453 Content: () => Content2, 10454 Header: () => Header2, 10455 HeaderDescription: () => HeaderDescription, 10456 Root: () => Root3 10457 }); 10458 10459 // packages/ui/build-module/collapsible-card/root.mjs 10460 var import_element19 = __toESM(require_element(), 1); 10461 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); 10462 var Root3 = (0, import_element19.forwardRef)( 10463 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) { 10464 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)( 10465 Root2, 10466 { 10467 ref, 10468 render: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Root, { render: render4 }), 10469 ...restProps 10470 } 10471 ); 10472 } 10473 ); 10474 10475 // packages/ui/build-module/collapsible-card/header.mjs 10476 var import_element21 = __toESM(require_element(), 1); 10477 10478 // packages/icons/build-module/library/arrow-down.mjs 10479 var import_primitives2 = __toESM(require_primitives(), 1); 10480 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); 10481 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives2.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) }); 10482 10483 // packages/icons/build-module/library/arrow-left.mjs 10484 var import_primitives3 = __toESM(require_primitives(), 1); 10485 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); 10486 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) }); 10487 10488 // packages/icons/build-module/library/arrow-right.mjs 10489 var import_primitives4 = __toESM(require_primitives(), 1); 10490 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); 10491 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) }); 10492 10493 // packages/icons/build-module/library/arrow-up.mjs 10494 var import_primitives5 = __toESM(require_primitives(), 1); 10495 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); 10496 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) }); 10497 10498 // packages/icons/build-module/library/block-default.mjs 10499 var import_primitives6 = __toESM(require_primitives(), 1); 10500 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); 10501 var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives6.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) }); 10502 10503 // packages/icons/build-module/library/block-table.mjs 10504 var import_primitives7 = __toESM(require_primitives(), 1); 10505 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); 10506 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives7.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) }); 10507 10508 // packages/icons/build-module/library/category.mjs 10509 var import_primitives8 = __toESM(require_primitives(), 1); 10510 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); 10511 var category_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives8.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) }); 10512 10513 // packages/icons/build-module/library/check.mjs 10514 var import_primitives9 = __toESM(require_primitives(), 1); 10515 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); 10516 var check_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives9.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 10517 10518 // packages/icons/build-module/library/chevron-down.mjs 10519 var import_primitives10 = __toESM(require_primitives(), 1); 10520 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); 10521 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives10.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) }); 10522 10523 // packages/icons/build-module/library/chevron-left.mjs 10524 var import_primitives11 = __toESM(require_primitives(), 1); 10525 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); 10526 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives11.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) }); 10527 10528 // packages/icons/build-module/library/chevron-right.mjs 10529 var import_primitives12 = __toESM(require_primitives(), 1); 10530 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); 10531 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives12.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) }); 10532 10533 // packages/icons/build-module/library/close-small.mjs 10534 var import_primitives13 = __toESM(require_primitives(), 1); 10535 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); 10536 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives13.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) }); 10537 10538 // packages/icons/build-module/library/cog.mjs 10539 var import_primitives14 = __toESM(require_primitives(), 1); 10540 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); 10541 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives14.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z" }) }); 10542 10543 // packages/icons/build-module/library/envelope.mjs 10544 var import_primitives15 = __toESM(require_primitives(), 1); 10545 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1); 10546 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives15.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z" }) }); 10547 10548 // packages/icons/build-module/library/error.mjs 10549 var import_primitives16 = __toESM(require_primitives(), 1); 10550 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1); 10551 var error_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives16.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z" }) }); 10552 10553 // packages/icons/build-module/library/format-list-bullets-rtl.mjs 10554 var import_primitives17 = __toESM(require_primitives(), 1); 10555 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1); 10556 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives17.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) }); 10557 10558 // packages/icons/build-module/library/format-list-bullets.mjs 10559 var import_primitives18 = __toESM(require_primitives(), 1); 10560 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1); 10561 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives18.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) }); 10562 10563 // packages/icons/build-module/library/funnel.mjs 10564 var import_primitives19 = __toESM(require_primitives(), 1); 10565 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1); 10566 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives19.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) }); 10567 10568 // packages/icons/build-module/library/link.mjs 10569 var import_primitives20 = __toESM(require_primitives(), 1); 10570 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1); 10571 var link_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives20.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) }); 10572 10573 // packages/icons/build-module/library/mobile.mjs 10574 var import_primitives21 = __toESM(require_primitives(), 1); 10575 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1); 10576 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives21.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) }); 10577 10578 // packages/icons/build-module/library/more-vertical.mjs 10579 var import_primitives22 = __toESM(require_primitives(), 1); 10580 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1); 10581 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 10582 10583 // packages/icons/build-module/library/next.mjs 10584 var import_primitives23 = __toESM(require_primitives(), 1); 10585 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1); 10586 var next_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives23.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) }); 10587 10588 // packages/icons/build-module/library/pencil.mjs 10589 var import_primitives24 = __toESM(require_primitives(), 1); 10590 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1); 10591 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives24.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) }); 10592 10593 // packages/icons/build-module/library/previous.mjs 10594 var import_primitives25 = __toESM(require_primitives(), 1); 10595 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1); 10596 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives25.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) }); 10597 10598 // packages/icons/build-module/library/scheduled.mjs 10599 var import_primitives26 = __toESM(require_primitives(), 1); 10600 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1); 10601 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives26.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" }) }); 10602 10603 // packages/icons/build-module/library/search.mjs 10604 var import_primitives27 = __toESM(require_primitives(), 1); 10605 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1); 10606 var search_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives27.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) }); 10607 10608 // packages/icons/build-module/library/seen.mjs 10609 var import_primitives28 = __toESM(require_primitives(), 1); 10610 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1); 10611 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives28.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" }) }); 10612 10613 // packages/icons/build-module/library/unseen.mjs 10614 var import_primitives29 = __toESM(require_primitives(), 1); 10615 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1); 10616 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives29.Path, { d: "M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z" }) }); 10617 10618 // packages/ui/build-module/collapsible-card/context.mjs 10619 var import_element20 = __toESM(require_element(), 1); 10620 var HeaderDescriptionIdContext = (0, import_element20.createContext)({ 10621 setDescriptionId: () => { 10622 } 10623 }); 10624 10625 // packages/ui/build-module/collapsible-card/header.mjs 10626 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1); 10627 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash"; 10628 function getRuntime7() { 10629 const globalScope = globalThis; 10630 if (globalScope.__wpStyleRuntime) { 10631 return globalScope.__wpStyleRuntime; 10632 } 10633 globalScope.__wpStyleRuntime = { 10634 documents: /* @__PURE__ */ new Map(), 10635 styles: /* @__PURE__ */ new Map(), 10636 injectedStyles: /* @__PURE__ */ new WeakMap() 10637 }; 10638 if (typeof document !== "undefined") { 10639 registerDocument7(document); 10640 } 10641 return globalScope.__wpStyleRuntime; 10642 } 10643 function documentContainsStyleHash7(targetDocument, hash) { 10644 if (!targetDocument.head) { 10645 return false; 10646 } 10647 for (const style of targetDocument.head.querySelectorAll( 10648 `style[$STYLE_HASH_ATTRIBUTE7}]` 10649 )) { 10650 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) { 10651 return true; 10652 } 10653 } 10654 return false; 10655 } 10656 function injectStyle7(targetDocument, hash, css) { 10657 if (!targetDocument.head) { 10658 return; 10659 } 10660 const runtime = getRuntime7(); 10661 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10662 if (!injectedStyles) { 10663 injectedStyles = /* @__PURE__ */ new Set(); 10664 runtime.injectedStyles.set(targetDocument, injectedStyles); 10665 } 10666 if (injectedStyles.has(hash)) { 10667 return; 10668 } 10669 if (documentContainsStyleHash7(targetDocument, hash)) { 10670 injectedStyles.add(hash); 10671 return; 10672 } 10673 const style = targetDocument.createElement("style"); 10674 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash); 10675 style.appendChild(targetDocument.createTextNode(css)); 10676 targetDocument.head.appendChild(style); 10677 injectedStyles.add(hash); 10678 } 10679 function registerDocument7(targetDocument) { 10680 const runtime = getRuntime7(); 10681 runtime.documents.set( 10682 targetDocument, 10683 (runtime.documents.get(targetDocument) ?? 0) + 1 10684 ); 10685 for (const [hash, css] of runtime.styles) { 10686 injectStyle7(targetDocument, hash, css); 10687 } 10688 return () => { 10689 const count = runtime.documents.get(targetDocument); 10690 if (count === void 0) { 10691 return; 10692 } 10693 if (count <= 1) { 10694 runtime.documents.delete(targetDocument); 10695 return; 10696 } 10697 runtime.documents.set(targetDocument, count - 1); 10698 }; 10699 } 10700 function registerStyle7(hash, css) { 10701 const runtime = getRuntime7(); 10702 runtime.styles.set(hash, css); 10703 for (const targetDocument of runtime.documents.keys()) { 10704 injectStyle7(targetDocument, hash, css); 10705 } 10706 } 10707 if (typeof process === "undefined" || true) { 10708 registerStyle7("f1b9bb6252", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}"); 10709 } 10710 var style_default7 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" }; 10711 if (typeof process === "undefined" || true) { 10712 registerStyle7("1fb29d3a3c", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}"); 10713 } 10714 var global_css_defense_default2 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" }; 10715 if (typeof process === "undefined" || true) { 10716 registerStyle7("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}"); 10717 } 10718 var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible" }; 10719 var Header2 = (0, import_element21.forwardRef)( 10720 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) { 10721 const [descriptionId, setDescriptionId] = (0, import_element21.useState)(); 10722 const contextValue = (0, import_element21.useMemo)( 10723 () => ({ setDescriptionId }), 10724 [setDescriptionId] 10725 ); 10726 return useRender({ 10727 defaultTagName: "div", 10728 render: render4, 10729 ref, 10730 props: mergeProps(restProps, { 10731 className: clsx_default( 10732 global_css_defense_default2.heading, 10733 style_default7["heading-wrapper"], 10734 className 10735 ), 10736 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 10737 Trigger, 10738 { 10739 className: style_default7.header, 10740 render: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Header, {}), 10741 nativeButton: false, 10742 "aria-describedby": descriptionId, 10743 children: [ 10744 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: style_default7["header-content"], children }), 10745 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 10746 "div", 10747 { 10748 className: clsx_default( 10749 style_default7["header-trigger-positioner"] 10750 ), 10751 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 10752 "div", 10753 { 10754 className: clsx_default( 10755 style_default7["header-trigger-wrapper"], 10756 global_css_defense_default2.div, 10757 // While the interactive trigger element is the whole header, 10758 // the focus ring will be displayed only on the icon to visually 10759 // emulate it being the button. 10760 focus_default["outset-ring--focus-parent-visible"] 10761 ), 10762 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 10763 Icon, 10764 { 10765 icon: chevron_down_default, 10766 className: style_default7["header-trigger"] 10767 } 10768 ) 10769 } 10770 ) 10771 } 10772 ) 10773 ] 10774 } 10775 ) }) 10776 }) 10777 }); 10778 } 10779 ); 10780 10781 // packages/ui/build-module/collapsible-card/header-description.mjs 10782 var import_element22 = __toESM(require_element(), 1); 10783 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1); 10784 var HeaderDescription = (0, import_element22.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) { 10785 const descriptionId = (0, import_element22.useId)(); 10786 const { setDescriptionId } = (0, import_element22.useContext)(HeaderDescriptionIdContext); 10787 (0, import_element22.useEffect)(() => { 10788 setDescriptionId(descriptionId); 10789 return () => setDescriptionId(void 0); 10790 }, [descriptionId, setDescriptionId]); 10791 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10792 "div", 10793 { 10794 ref, 10795 id: descriptionId, 10796 "aria-hidden": "true", 10797 className, 10798 ...restProps, 10799 children 10800 } 10801 ); 10802 }); 10803 10804 // packages/ui/build-module/collapsible-card/content.mjs 10805 var import_element23 = __toESM(require_element(), 1); 10806 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1); 10807 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash"; 10808 function getRuntime8() { 10809 const globalScope = globalThis; 10810 if (globalScope.__wpStyleRuntime) { 10811 return globalScope.__wpStyleRuntime; 10812 } 10813 globalScope.__wpStyleRuntime = { 10814 documents: /* @__PURE__ */ new Map(), 10815 styles: /* @__PURE__ */ new Map(), 10816 injectedStyles: /* @__PURE__ */ new WeakMap() 10817 }; 10818 if (typeof document !== "undefined") { 10819 registerDocument8(document); 10820 } 10821 return globalScope.__wpStyleRuntime; 10822 } 10823 function documentContainsStyleHash8(targetDocument, hash) { 10824 if (!targetDocument.head) { 10825 return false; 10826 } 10827 for (const style of targetDocument.head.querySelectorAll( 10828 `style[$STYLE_HASH_ATTRIBUTE8}]` 10829 )) { 10830 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) { 10831 return true; 10832 } 10833 } 10834 return false; 10835 } 10836 function injectStyle8(targetDocument, hash, css) { 10837 if (!targetDocument.head) { 10838 return; 10839 } 10840 const runtime = getRuntime8(); 10841 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10842 if (!injectedStyles) { 10843 injectedStyles = /* @__PURE__ */ new Set(); 10844 runtime.injectedStyles.set(targetDocument, injectedStyles); 10845 } 10846 if (injectedStyles.has(hash)) { 10847 return; 10848 } 10849 if (documentContainsStyleHash8(targetDocument, hash)) { 10850 injectedStyles.add(hash); 10851 return; 10852 } 10853 const style = targetDocument.createElement("style"); 10854 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash); 10855 style.appendChild(targetDocument.createTextNode(css)); 10856 targetDocument.head.appendChild(style); 10857 injectedStyles.add(hash); 10858 } 10859 function registerDocument8(targetDocument) { 10860 const runtime = getRuntime8(); 10861 runtime.documents.set( 10862 targetDocument, 10863 (runtime.documents.get(targetDocument) ?? 0) + 1 10864 ); 10865 for (const [hash, css] of runtime.styles) { 10866 injectStyle8(targetDocument, hash, css); 10867 } 10868 return () => { 10869 const count = runtime.documents.get(targetDocument); 10870 if (count === void 0) { 10871 return; 10872 } 10873 if (count <= 1) { 10874 runtime.documents.delete(targetDocument); 10875 return; 10876 } 10877 runtime.documents.set(targetDocument, count - 1); 10878 }; 10879 } 10880 function registerStyle8(hash, css) { 10881 const runtime = getRuntime8(); 10882 runtime.styles.set(hash, css); 10883 for (const targetDocument of runtime.documents.keys()) { 10884 injectStyle8(targetDocument, hash, css); 10885 } 10886 } 10887 if (typeof process === "undefined" || true) { 10888 registerStyle8("f1b9bb6252", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}"); 10889 } 10890 var style_default8 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" }; 10891 var Content2 = (0, import_element23.forwardRef)( 10892 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) { 10893 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 10894 Panel, 10895 { 10896 ref, 10897 className: (state) => clsx_default( 10898 style_default8.content, 10899 state.open && state.transitionStatus === "idle" && style_default8.overflowVisible, 10900 className 10901 ), 10902 hiddenUntilFound, 10903 ...restProps, 10904 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 10905 Content, 10906 { 10907 className: style_default8["content-inner"], 10908 render: render4, 10909 children 10910 } 10911 ) 10912 } 10913 ); 10914 } 10915 ); 10916 10917 // packages/ui/build-module/utils/render-slot-with-children.mjs 10918 var import_element24 = __toESM(require_element(), 1); 10919 function renderSlotWithChildren(slot, defaultSlot, children) { 10920 return (0, import_element24.cloneElement)( 10921 slot ?? defaultSlot, 10922 { children } 10923 ); 10924 } 10925 10926 // packages/ui/build-module/lock-unlock.mjs 10927 var import_private_apis = __toESM(require_private_apis(), 1); 10928 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 10929 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 10930 "@wordpress/ui" 10931 ); 10932 10933 // packages/ui/build-module/stack/stack.mjs 10934 var import_element25 = __toESM(require_element(), 1); 10935 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash"; 10936 function getRuntime9() { 10937 const globalScope = globalThis; 10938 if (globalScope.__wpStyleRuntime) { 10939 return globalScope.__wpStyleRuntime; 10940 } 10941 globalScope.__wpStyleRuntime = { 10942 documents: /* @__PURE__ */ new Map(), 10943 styles: /* @__PURE__ */ new Map(), 10944 injectedStyles: /* @__PURE__ */ new WeakMap() 10945 }; 10946 if (typeof document !== "undefined") { 10947 registerDocument9(document); 10948 } 10949 return globalScope.__wpStyleRuntime; 10950 } 10951 function documentContainsStyleHash9(targetDocument, hash) { 10952 if (!targetDocument.head) { 10953 return false; 10954 } 10955 for (const style of targetDocument.head.querySelectorAll( 10956 `style[$STYLE_HASH_ATTRIBUTE9}]` 10957 )) { 10958 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) { 10959 return true; 10960 } 10961 } 10962 return false; 10963 } 10964 function injectStyle9(targetDocument, hash, css) { 10965 if (!targetDocument.head) { 10966 return; 10967 } 10968 const runtime = getRuntime9(); 10969 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10970 if (!injectedStyles) { 10971 injectedStyles = /* @__PURE__ */ new Set(); 10972 runtime.injectedStyles.set(targetDocument, injectedStyles); 10973 } 10974 if (injectedStyles.has(hash)) { 10975 return; 10976 } 10977 if (documentContainsStyleHash9(targetDocument, hash)) { 10978 injectedStyles.add(hash); 10979 return; 10980 } 10981 const style = targetDocument.createElement("style"); 10982 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash); 10983 style.appendChild(targetDocument.createTextNode(css)); 10984 targetDocument.head.appendChild(style); 10985 injectedStyles.add(hash); 10986 } 10987 function registerDocument9(targetDocument) { 10988 const runtime = getRuntime9(); 10989 runtime.documents.set( 10990 targetDocument, 10991 (runtime.documents.get(targetDocument) ?? 0) + 1 10992 ); 10993 for (const [hash, css] of runtime.styles) { 10994 injectStyle9(targetDocument, hash, css); 10995 } 10996 return () => { 10997 const count = runtime.documents.get(targetDocument); 10998 if (count === void 0) { 10999 return; 11000 } 11001 if (count <= 1) { 11002 runtime.documents.delete(targetDocument); 11003 return; 11004 } 11005 runtime.documents.set(targetDocument, count - 1); 11006 }; 11007 } 11008 function registerStyle9(hash, css) { 11009 const runtime = getRuntime9(); 11010 runtime.styles.set(hash, css); 11011 for (const targetDocument of runtime.documents.keys()) { 11012 injectStyle9(targetDocument, hash, css); 11013 } 11014 } 11015 if (typeof process === "undefined" || true) { 11016 registerStyle9("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}"); 11017 } 11018 var style_default9 = { "stack": "_19ce0419607e1896__stack" }; 11019 var gapTokens = { 11020 xs: "var(--wpds-dimension-gap-xs, 4px)", 11021 sm: "var(--wpds-dimension-gap-sm, 8px)", 11022 md: "var(--wpds-dimension-gap-md, 12px)", 11023 lg: "var(--wpds-dimension-gap-lg, 16px)", 11024 xl: "var(--wpds-dimension-gap-xl, 24px)", 11025 "2xl": "var(--wpds-dimension-gap-2xl, 32px)", 11026 "3xl": "var(--wpds-dimension-gap-3xl, 40px)" 11027 }; 11028 var Stack = (0, import_element25.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) { 11029 const style = { 11030 gap: gap && gapTokens[gap], 11031 alignItems: align, 11032 justifyContent: justify, 11033 flexDirection: direction, 11034 flexWrap: wrap 11035 }; 11036 const element = useRender({ 11037 render: render4, 11038 ref, 11039 props: mergeProps(props, { style, className: style_default9.stack }) 11040 }); 11041 return element; 11042 }); 11043 11044 // packages/ui/build-module/tooltip/index.mjs 11045 var tooltip_exports = {}; 11046 __export(tooltip_exports, { 11047 Popup: () => Popup, 11048 Portal: () => Portal, 11049 Positioner: () => Positioner, 11050 Provider: () => Provider, 11051 Root: () => Root4, 11052 Trigger: () => Trigger2 11053 }); 11054 11055 // packages/ui/build-module/tooltip/popup.mjs 11056 var import_element28 = __toESM(require_element(), 1); 11057 var import_theme = __toESM(require_theme(), 1); 11058 11059 // packages/ui/build-module/tooltip/portal.mjs 11060 var import_element26 = __toESM(require_element(), 1); 11061 11062 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs 11063 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash"; 11064 function getRuntime10() { 11065 const globalScope = globalThis; 11066 if (globalScope.__wpStyleRuntime) { 11067 return globalScope.__wpStyleRuntime; 11068 } 11069 globalScope.__wpStyleRuntime = { 11070 documents: /* @__PURE__ */ new Map(), 11071 styles: /* @__PURE__ */ new Map(), 11072 injectedStyles: /* @__PURE__ */ new WeakMap() 11073 }; 11074 if (typeof document !== "undefined") { 11075 registerDocument10(document); 11076 } 11077 return globalScope.__wpStyleRuntime; 11078 } 11079 function documentContainsStyleHash10(targetDocument, hash) { 11080 if (!targetDocument.head) { 11081 return false; 11082 } 11083 for (const style of targetDocument.head.querySelectorAll( 11084 `style[$STYLE_HASH_ATTRIBUTE10}]` 11085 )) { 11086 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) { 11087 return true; 11088 } 11089 } 11090 return false; 11091 } 11092 function injectStyle10(targetDocument, hash, css) { 11093 if (!targetDocument.head) { 11094 return; 11095 } 11096 const runtime = getRuntime10(); 11097 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11098 if (!injectedStyles) { 11099 injectedStyles = /* @__PURE__ */ new Set(); 11100 runtime.injectedStyles.set(targetDocument, injectedStyles); 11101 } 11102 if (injectedStyles.has(hash)) { 11103 return; 11104 } 11105 if (documentContainsStyleHash10(targetDocument, hash)) { 11106 injectedStyles.add(hash); 11107 return; 11108 } 11109 const style = targetDocument.createElement("style"); 11110 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash); 11111 style.appendChild(targetDocument.createTextNode(css)); 11112 targetDocument.head.appendChild(style); 11113 injectedStyles.add(hash); 11114 } 11115 function registerDocument10(targetDocument) { 11116 const runtime = getRuntime10(); 11117 runtime.documents.set( 11118 targetDocument, 11119 (runtime.documents.get(targetDocument) ?? 0) + 1 11120 ); 11121 for (const [hash, css] of runtime.styles) { 11122 injectStyle10(targetDocument, hash, css); 11123 } 11124 return () => { 11125 const count = runtime.documents.get(targetDocument); 11126 if (count === void 0) { 11127 return; 11128 } 11129 if (count <= 1) { 11130 runtime.documents.delete(targetDocument); 11131 return; 11132 } 11133 runtime.documents.set(targetDocument, count - 1); 11134 }; 11135 } 11136 function registerStyle10(hash, css) { 11137 const runtime = getRuntime10(); 11138 runtime.styles.set(hash, css); 11139 for (const targetDocument of runtime.documents.keys()) { 11140 injectStyle10(targetDocument, hash, css); 11141 } 11142 } 11143 if (typeof process === "undefined" || true) { 11144 registerStyle10("45eb1fe20f", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui-utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}"); 11145 } 11146 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" }; 11147 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot"; 11148 function resolveOwnerDocument() { 11149 return typeof document === "undefined" ? null : document; 11150 } 11151 function isInWordPressEnvironment() { 11152 let topWp; 11153 try { 11154 topWp = window.top?.wp; 11155 } catch { 11156 } 11157 const wp = topWp ?? window.wp; 11158 return typeof wp?.components === "object" && wp.components !== null; 11159 } 11160 var cachedSlot = null; 11161 function createSlot(ownerDocument2) { 11162 const element = ownerDocument2.createElement("div"); 11163 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, ""); 11164 if (wp_compat_overlay_slot_default.slot) { 11165 element.classList.add(wp_compat_overlay_slot_default.slot); 11166 } 11167 ownerDocument2.body.appendChild(element); 11168 return element; 11169 } 11170 function getWpCompatOverlaySlot() { 11171 if (typeof window === "undefined") { 11172 return void 0; 11173 } 11174 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) { 11175 return void 0; 11176 } 11177 const ownerDocument2 = resolveOwnerDocument(); 11178 if (!ownerDocument2 || !ownerDocument2.body) { 11179 return void 0; 11180 } 11181 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) { 11182 return cachedSlot; 11183 } 11184 const existing = ownerDocument2.querySelector( 11185 `[$WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]` 11186 ); 11187 if (existing instanceof HTMLDivElement) { 11188 cachedSlot = existing; 11189 return existing; 11190 } 11191 if (cachedSlot?.isConnected) { 11192 cachedSlot.remove(); 11193 } 11194 cachedSlot = createSlot(ownerDocument2); 11195 return cachedSlot; 11196 } 11197 11198 // packages/ui/build-module/tooltip/portal.mjs 11199 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1); 11200 var Portal = (0, import_element26.forwardRef)( 11201 function TooltipPortal3({ container, ...restProps }, ref) { 11202 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11203 index_parts_exports2.Portal, 11204 { 11205 container: container ?? getWpCompatOverlaySlot(), 11206 ...restProps, 11207 ref 11208 } 11209 ); 11210 } 11211 ); 11212 11213 // packages/ui/build-module/tooltip/positioner.mjs 11214 var import_element27 = __toESM(require_element(), 1); 11215 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1); 11216 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash"; 11217 function getRuntime11() { 11218 const globalScope = globalThis; 11219 if (globalScope.__wpStyleRuntime) { 11220 return globalScope.__wpStyleRuntime; 11221 } 11222 globalScope.__wpStyleRuntime = { 11223 documents: /* @__PURE__ */ new Map(), 11224 styles: /* @__PURE__ */ new Map(), 11225 injectedStyles: /* @__PURE__ */ new WeakMap() 11226 }; 11227 if (typeof document !== "undefined") { 11228 registerDocument11(document); 11229 } 11230 return globalScope.__wpStyleRuntime; 11231 } 11232 function documentContainsStyleHash11(targetDocument, hash) { 11233 if (!targetDocument.head) { 11234 return false; 11235 } 11236 for (const style of targetDocument.head.querySelectorAll( 11237 `style[$STYLE_HASH_ATTRIBUTE11}]` 11238 )) { 11239 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) { 11240 return true; 11241 } 11242 } 11243 return false; 11244 } 11245 function injectStyle11(targetDocument, hash, css) { 11246 if (!targetDocument.head) { 11247 return; 11248 } 11249 const runtime = getRuntime11(); 11250 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11251 if (!injectedStyles) { 11252 injectedStyles = /* @__PURE__ */ new Set(); 11253 runtime.injectedStyles.set(targetDocument, injectedStyles); 11254 } 11255 if (injectedStyles.has(hash)) { 11256 return; 11257 } 11258 if (documentContainsStyleHash11(targetDocument, hash)) { 11259 injectedStyles.add(hash); 11260 return; 11261 } 11262 const style = targetDocument.createElement("style"); 11263 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash); 11264 style.appendChild(targetDocument.createTextNode(css)); 11265 targetDocument.head.appendChild(style); 11266 injectedStyles.add(hash); 11267 } 11268 function registerDocument11(targetDocument) { 11269 const runtime = getRuntime11(); 11270 runtime.documents.set( 11271 targetDocument, 11272 (runtime.documents.get(targetDocument) ?? 0) + 1 11273 ); 11274 for (const [hash, css] of runtime.styles) { 11275 injectStyle11(targetDocument, hash, css); 11276 } 11277 return () => { 11278 const count = runtime.documents.get(targetDocument); 11279 if (count === void 0) { 11280 return; 11281 } 11282 if (count <= 1) { 11283 runtime.documents.delete(targetDocument); 11284 return; 11285 } 11286 runtime.documents.set(targetDocument, count - 1); 11287 }; 11288 } 11289 function registerStyle11(hash, css) { 11290 const runtime = getRuntime11(); 11291 runtime.styles.set(hash, css); 11292 for (const targetDocument of runtime.documents.keys()) { 11293 injectStyle11(targetDocument, hash, css); 11294 } 11295 } 11296 if (typeof process === "undefined" || true) { 11297 registerStyle11("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}"); 11298 } 11299 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 11300 if (typeof process === "undefined" || true) { 11301 registerStyle11("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}'); 11302 } 11303 var style_default10 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 11304 var Positioner = (0, import_element27.forwardRef)( 11305 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) { 11306 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 11307 index_parts_exports2.Positioner, 11308 { 11309 ref, 11310 align, 11311 side, 11312 sideOffset, 11313 ...props, 11314 className: clsx_default( 11315 resets_default2["box-sizing"], 11316 style_default10.positioner, 11317 className 11318 ) 11319 } 11320 ); 11321 } 11322 ); 11323 11324 // packages/ui/build-module/tooltip/popup.mjs 11325 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1); 11326 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash"; 11327 function getRuntime12() { 11328 const globalScope = globalThis; 11329 if (globalScope.__wpStyleRuntime) { 11330 return globalScope.__wpStyleRuntime; 11331 } 11332 globalScope.__wpStyleRuntime = { 11333 documents: /* @__PURE__ */ new Map(), 11334 styles: /* @__PURE__ */ new Map(), 11335 injectedStyles: /* @__PURE__ */ new WeakMap() 11336 }; 11337 if (typeof document !== "undefined") { 11338 registerDocument12(document); 11339 } 11340 return globalScope.__wpStyleRuntime; 11341 } 11342 function documentContainsStyleHash12(targetDocument, hash) { 11343 if (!targetDocument.head) { 11344 return false; 11345 } 11346 for (const style of targetDocument.head.querySelectorAll( 11347 `style[$STYLE_HASH_ATTRIBUTE12}]` 11348 )) { 11349 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) { 11350 return true; 11351 } 11352 } 11353 return false; 11354 } 11355 function injectStyle12(targetDocument, hash, css) { 11356 if (!targetDocument.head) { 11357 return; 11358 } 11359 const runtime = getRuntime12(); 11360 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11361 if (!injectedStyles) { 11362 injectedStyles = /* @__PURE__ */ new Set(); 11363 runtime.injectedStyles.set(targetDocument, injectedStyles); 11364 } 11365 if (injectedStyles.has(hash)) { 11366 return; 11367 } 11368 if (documentContainsStyleHash12(targetDocument, hash)) { 11369 injectedStyles.add(hash); 11370 return; 11371 } 11372 const style = targetDocument.createElement("style"); 11373 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash); 11374 style.appendChild(targetDocument.createTextNode(css)); 11375 targetDocument.head.appendChild(style); 11376 injectedStyles.add(hash); 11377 } 11378 function registerDocument12(targetDocument) { 11379 const runtime = getRuntime12(); 11380 runtime.documents.set( 11381 targetDocument, 11382 (runtime.documents.get(targetDocument) ?? 0) + 1 11383 ); 11384 for (const [hash, css] of runtime.styles) { 11385 injectStyle12(targetDocument, hash, css); 11386 } 11387 return () => { 11388 const count = runtime.documents.get(targetDocument); 11389 if (count === void 0) { 11390 return; 11391 } 11392 if (count <= 1) { 11393 runtime.documents.delete(targetDocument); 11394 return; 11395 } 11396 runtime.documents.set(targetDocument, count - 1); 11397 }; 11398 } 11399 function registerStyle12(hash, css) { 11400 const runtime = getRuntime12(); 11401 runtime.styles.set(hash, css); 11402 for (const targetDocument of runtime.documents.keys()) { 11403 injectStyle12(targetDocument, hash, css); 11404 } 11405 } 11406 if (typeof process === "undefined" || true) { 11407 registerStyle12("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}'); 11408 } 11409 var style_default11 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 11410 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider; 11411 var Popup = (0, import_element28.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) { 11412 const popupContent = ( 11413 /* This should ideally use whatever dark color makes sense, 11414 * and not be hardcoded to #1e1e1e. The solutions would be to: 11415 * - review the design of the tooltip, in case we want to stop 11416 * hardcoding it to a dark background 11417 * - create new semantic tokens as needed (aliasing either the 11418 * "inverted bg" or "perma-dark bg" private tokens) and have 11419 * Tooltip.Popup use them; 11420 * - remove the hardcoded `bg` setting from the `ThemeProvider` 11421 * below 11422 */ 11423 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)( 11424 index_parts_exports2.Popup, 11425 { 11426 ref, 11427 className: clsx_default(style_default11.popup, className), 11428 ...props, 11429 children 11430 } 11431 ) }) 11432 ); 11433 const positionedPopup = renderSlotWithChildren( 11434 positioner, 11435 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Positioner, {}), 11436 popupContent 11437 ); 11438 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Portal, {}), positionedPopup); 11439 }); 11440 11441 // packages/ui/build-module/tooltip/trigger.mjs 11442 var import_element29 = __toESM(require_element(), 1); 11443 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1); 11444 var Trigger2 = (0, import_element29.forwardRef)( 11445 function TooltipTrigger3(props, ref) { 11446 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(index_parts_exports2.Trigger, { ref, ...props }); 11447 } 11448 ); 11449 11450 // packages/ui/build-module/tooltip/root.mjs 11451 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1); 11452 function Root4(props) { 11453 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(index_parts_exports2.Root, { ...props }); 11454 } 11455 11456 // packages/ui/build-module/tooltip/provider.mjs 11457 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1); 11458 function Provider({ ...props }) { 11459 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(index_parts_exports2.Provider, { ...props }); 11460 } 11461 11462 // packages/ui/build-module/visually-hidden/visually-hidden.mjs 11463 var import_element30 = __toESM(require_element(), 1); 11464 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash"; 11465 function getRuntime13() { 11466 const globalScope = globalThis; 11467 if (globalScope.__wpStyleRuntime) { 11468 return globalScope.__wpStyleRuntime; 11469 } 11470 globalScope.__wpStyleRuntime = { 11471 documents: /* @__PURE__ */ new Map(), 11472 styles: /* @__PURE__ */ new Map(), 11473 injectedStyles: /* @__PURE__ */ new WeakMap() 11474 }; 11475 if (typeof document !== "undefined") { 11476 registerDocument13(document); 11477 } 11478 return globalScope.__wpStyleRuntime; 11479 } 11480 function documentContainsStyleHash13(targetDocument, hash) { 11481 if (!targetDocument.head) { 11482 return false; 11483 } 11484 for (const style of targetDocument.head.querySelectorAll( 11485 `style[$STYLE_HASH_ATTRIBUTE13}]` 11486 )) { 11487 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) { 11488 return true; 11489 } 11490 } 11491 return false; 11492 } 11493 function injectStyle13(targetDocument, hash, css) { 11494 if (!targetDocument.head) { 11495 return; 11496 } 11497 const runtime = getRuntime13(); 11498 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11499 if (!injectedStyles) { 11500 injectedStyles = /* @__PURE__ */ new Set(); 11501 runtime.injectedStyles.set(targetDocument, injectedStyles); 11502 } 11503 if (injectedStyles.has(hash)) { 11504 return; 11505 } 11506 if (documentContainsStyleHash13(targetDocument, hash)) { 11507 injectedStyles.add(hash); 11508 return; 11509 } 11510 const style = targetDocument.createElement("style"); 11511 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash); 11512 style.appendChild(targetDocument.createTextNode(css)); 11513 targetDocument.head.appendChild(style); 11514 injectedStyles.add(hash); 11515 } 11516 function registerDocument13(targetDocument) { 11517 const runtime = getRuntime13(); 11518 runtime.documents.set( 11519 targetDocument, 11520 (runtime.documents.get(targetDocument) ?? 0) + 1 11521 ); 11522 for (const [hash, css] of runtime.styles) { 11523 injectStyle13(targetDocument, hash, css); 11524 } 11525 return () => { 11526 const count = runtime.documents.get(targetDocument); 11527 if (count === void 0) { 11528 return; 11529 } 11530 if (count <= 1) { 11531 runtime.documents.delete(targetDocument); 11532 return; 11533 } 11534 runtime.documents.set(targetDocument, count - 1); 11535 }; 11536 } 11537 function registerStyle13(hash, css) { 11538 const runtime = getRuntime13(); 11539 runtime.styles.set(hash, css); 11540 for (const targetDocument of runtime.documents.keys()) { 11541 injectStyle13(targetDocument, hash, css); 11542 } 11543 } 11544 if (typeof process === "undefined" || true) { 11545 registerStyle13("c46e8cb841", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}"); 11546 } 11547 var style_default12 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" }; 11548 var VisuallyHidden = (0, import_element30.forwardRef)( 11549 function VisuallyHidden2({ render: render4, ...restProps }, ref) { 11550 const element = useRender({ 11551 render: render4, 11552 ref, 11553 props: mergeProps( 11554 { className: style_default12["visually-hidden"] }, 11555 restProps, 11556 { 11557 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it. 11558 "data-visually-hidden": "" 11559 } 11560 ) 11561 }); 11562 return element; 11563 } 11564 ); 11565 11566 // packages/admin-ui/build-module/navigable-region/index.mjs 11567 var import_element31 = __toESM(require_element(), 1); 11568 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1); 11569 var NavigableRegion = (0, import_element31.forwardRef)( 11570 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => { 11571 return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)( 11572 Tag, 11573 { 11574 ref, 11575 className: clsx_default("admin-ui-navigable-region", className), 11576 "aria-label": ariaLabel, 11577 role: "region", 11578 tabIndex: "-1", 11579 ...props, 11580 children 11581 } 11582 ); 11583 } 11584 ); 11585 NavigableRegion.displayName = "NavigableRegion"; 11586 var navigable_region_default = NavigableRegion; 11587 11588 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs 11589 var import_components = __toESM(require_components(), 1); 11590 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle"); 11591 11592 // packages/admin-ui/build-module/page/header.mjs 11593 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1); 11594 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash"; 11595 function getRuntime14() { 11596 const globalScope = globalThis; 11597 if (globalScope.__wpStyleRuntime) { 11598 return globalScope.__wpStyleRuntime; 11599 } 11600 globalScope.__wpStyleRuntime = { 11601 documents: /* @__PURE__ */ new Map(), 11602 styles: /* @__PURE__ */ new Map(), 11603 injectedStyles: /* @__PURE__ */ new WeakMap() 11604 }; 11605 if (typeof document !== "undefined") { 11606 registerDocument14(document); 11607 } 11608 return globalScope.__wpStyleRuntime; 11609 } 11610 function documentContainsStyleHash14(targetDocument, hash) { 11611 if (!targetDocument.head) { 11612 return false; 11613 } 11614 for (const style of targetDocument.head.querySelectorAll( 11615 `style[$STYLE_HASH_ATTRIBUTE14}]` 11616 )) { 11617 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) { 11618 return true; 11619 } 11620 } 11621 return false; 11622 } 11623 function injectStyle14(targetDocument, hash, css) { 11624 if (!targetDocument.head) { 11625 return; 11626 } 11627 const runtime = getRuntime14(); 11628 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11629 if (!injectedStyles) { 11630 injectedStyles = /* @__PURE__ */ new Set(); 11631 runtime.injectedStyles.set(targetDocument, injectedStyles); 11632 } 11633 if (injectedStyles.has(hash)) { 11634 return; 11635 } 11636 if (documentContainsStyleHash14(targetDocument, hash)) { 11637 injectedStyles.add(hash); 11638 return; 11639 } 11640 const style = targetDocument.createElement("style"); 11641 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash); 11642 style.appendChild(targetDocument.createTextNode(css)); 11643 targetDocument.head.appendChild(style); 11644 injectedStyles.add(hash); 11645 } 11646 function registerDocument14(targetDocument) { 11647 const runtime = getRuntime14(); 11648 runtime.documents.set( 11649 targetDocument, 11650 (runtime.documents.get(targetDocument) ?? 0) + 1 11651 ); 11652 for (const [hash, css] of runtime.styles) { 11653 injectStyle14(targetDocument, hash, css); 11654 } 11655 return () => { 11656 const count = runtime.documents.get(targetDocument); 11657 if (count === void 0) { 11658 return; 11659 } 11660 if (count <= 1) { 11661 runtime.documents.delete(targetDocument); 11662 return; 11663 } 11664 runtime.documents.set(targetDocument, count - 1); 11665 }; 11666 } 11667 function registerStyle14(hash, css) { 11668 const runtime = getRuntime14(); 11669 runtime.styles.set(hash, css); 11670 for (const targetDocument of runtime.documents.keys()) { 11671 injectStyle14(targetDocument, hash, css); 11672 } 11673 } 11674 if (typeof process === "undefined" || true) { 11675 registerStyle14("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}"); 11676 } 11677 var style_default13 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" }; 11678 function Header3({ 11679 headingLevel = 1, 11680 breadcrumbs, 11681 badges, 11682 visual, 11683 title, 11684 subTitle, 11685 actions: actions2, 11686 showSidebarToggle = true 11687 }) { 11688 const HeadingTag = `h$headingLevel}`; 11689 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "column", className: style_default13.header, children: [ 11690 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)( 11691 Stack, 11692 { 11693 className: style_default13["header-content"], 11694 direction: "row", 11695 gap: "sm", 11696 justify: "space-between", 11697 children: [ 11698 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [ 11699 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 11700 SidebarToggleSlot, 11701 { 11702 bubblesVirtually: true, 11703 className: style_default13["sidebar-toggle-slot"] 11704 } 11705 ), 11706 visual && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 11707 "div", 11708 { 11709 className: style_default13["header-visual"], 11710 "aria-hidden": "true", 11711 children: visual 11712 } 11713 ), 11714 title && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 11715 Text, 11716 { 11717 className: style_default13["header-title"], 11718 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(HeadingTag, {}), 11719 variant: "heading-lg", 11720 children: title 11721 } 11722 ), 11723 breadcrumbs, 11724 badges 11725 ] }), 11726 actions2 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 11727 Stack, 11728 { 11729 align: "center", 11730 className: style_default13["header-actions"], 11731 direction: "row", 11732 gap: "sm", 11733 children: actions2 11734 } 11735 ) 11736 ] 11737 } 11738 ), 11739 subTitle && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 11740 Text, 11741 { 11742 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("p", {}), 11743 variant: "body-md", 11744 className: style_default13["header-subtitle"], 11745 children: subTitle 11746 } 11747 ) 11748 ] }); 11749 } 11750 11751 // packages/admin-ui/build-module/page/index.mjs 11752 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1); 11753 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash"; 11754 function getRuntime15() { 11755 const globalScope = globalThis; 11756 if (globalScope.__wpStyleRuntime) { 11757 return globalScope.__wpStyleRuntime; 11758 } 11759 globalScope.__wpStyleRuntime = { 11760 documents: /* @__PURE__ */ new Map(), 11761 styles: /* @__PURE__ */ new Map(), 11762 injectedStyles: /* @__PURE__ */ new WeakMap() 11763 }; 11764 if (typeof document !== "undefined") { 11765 registerDocument15(document); 11766 } 11767 return globalScope.__wpStyleRuntime; 11768 } 11769 function documentContainsStyleHash15(targetDocument, hash) { 11770 if (!targetDocument.head) { 11771 return false; 11772 } 11773 for (const style of targetDocument.head.querySelectorAll( 11774 `style[$STYLE_HASH_ATTRIBUTE15}]` 11775 )) { 11776 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) { 11777 return true; 11778 } 11779 } 11780 return false; 11781 } 11782 function injectStyle15(targetDocument, hash, css) { 11783 if (!targetDocument.head) { 11784 return; 11785 } 11786 const runtime = getRuntime15(); 11787 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11788 if (!injectedStyles) { 11789 injectedStyles = /* @__PURE__ */ new Set(); 11790 runtime.injectedStyles.set(targetDocument, injectedStyles); 11791 } 11792 if (injectedStyles.has(hash)) { 11793 return; 11794 } 11795 if (documentContainsStyleHash15(targetDocument, hash)) { 11796 injectedStyles.add(hash); 11797 return; 11798 } 11799 const style = targetDocument.createElement("style"); 11800 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash); 11801 style.appendChild(targetDocument.createTextNode(css)); 11802 targetDocument.head.appendChild(style); 11803 injectedStyles.add(hash); 11804 } 11805 function registerDocument15(targetDocument) { 11806 const runtime = getRuntime15(); 11807 runtime.documents.set( 11808 targetDocument, 11809 (runtime.documents.get(targetDocument) ?? 0) + 1 11810 ); 11811 for (const [hash, css] of runtime.styles) { 11812 injectStyle15(targetDocument, hash, css); 11813 } 11814 return () => { 11815 const count = runtime.documents.get(targetDocument); 11816 if (count === void 0) { 11817 return; 11818 } 11819 if (count <= 1) { 11820 runtime.documents.delete(targetDocument); 11821 return; 11822 } 11823 runtime.documents.set(targetDocument, count - 1); 11824 }; 11825 } 11826 function registerStyle15(hash, css) { 11827 const runtime = getRuntime15(); 11828 runtime.styles.set(hash, css); 11829 for (const targetDocument of runtime.documents.keys()) { 11830 injectStyle15(targetDocument, hash, css); 11831 } 11832 } 11833 if (typeof process === "undefined" || true) { 11834 registerStyle15("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}"); 11835 } 11836 var style_default14 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" }; 11837 function Page({ 11838 headingLevel, 11839 breadcrumbs, 11840 badges, 11841 visual, 11842 title, 11843 subTitle, 11844 children, 11845 className, 11846 actions: actions2, 11847 ariaLabel, 11848 hasPadding = false, 11849 showSidebarToggle = true 11850 }) { 11851 const classes = clsx_default(style_default14.page, className); 11852 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : ""); 11853 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [ 11854 (title || breadcrumbs || badges || actions2 || visual) && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 11855 Header3, 11856 { 11857 headingLevel, 11858 breadcrumbs, 11859 badges, 11860 visual, 11861 title, 11862 subTitle, 11863 actions: actions2, 11864 showSidebarToggle 11865 } 11866 ), 11867 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 11868 "div", 11869 { 11870 className: clsx_default( 11871 style_default14.content, 11872 style_default14["has-padding"] 11873 ), 11874 children 11875 } 11876 ) : children 11877 ] }); 11878 } 11879 Page.SidebarToggleFill = SidebarToggleFill; 11880 var page_default = Page; 11881 11882 // routes/guidelines/stage.tsx 11883 var import_i18n55 = __toESM(require_i18n()); 11884 var import_element105 = __toESM(require_element()); 11885 var import_components59 = __toESM(require_components()); 11886 11887 // routes/guidelines/style.scss 11888 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='08b6feb367']")) { 11889 const style = document.createElement("style"); 11890 style.setAttribute("data-wp-hash", "08b6feb367"); 11891 style.appendChild(document.createTextNode(".guidelines__content{border-radius:8px;margin-top:0;padding:24px}.guidelines__list{display:flex;flex-direction:column;gap:16px;list-style:none;margin:0;padding:0}.guidelines__list-item{margin:0 auto;width:min(680px,100%)}.guidelines__loading{align-items:center;display:flex;justify-content:center;margin-top:16px}.guidelines__revision-history{display:flex;flex-direction:column;gap:16px;padding:24px}.guidelines__revision-history .dataviews-wrapper{margin-inline:-24px}.guidelines__revision-history-back{align-self:flex-start;color:#1e1e1e;font-weight:500;margin-left:-16px}.guidelines__error-description{margin:8px 0 0}.guidelines__revision-description{padding-left:8px}.guidelines__restore-modal-actions{margin-top:24px}")); 11892 document.head.appendChild(style); 11893 } 11894 11895 // routes/guidelines/components/guideline-accordion.tsx 11896 var import_components2 = __toESM(require_components()); 11897 function GuidelineAccordion({ 11898 title, 11899 description, 11900 children 11901 }) { 11902 return /* @__PURE__ */ React.createElement(collapsible_card_exports.Root, null, /* @__PURE__ */ React.createElement(collapsible_card_exports.Header, { render: /* @__PURE__ */ React.createElement("h2", null) }, /* @__PURE__ */ React.createElement(import_components2.__experimentalVStack, { spacing: 1 }, /* @__PURE__ */ React.createElement(card_exports.Title, null, title), /* @__PURE__ */ React.createElement(collapsible_card_exports.HeaderDescription, null, /* @__PURE__ */ React.createElement(import_components2.__experimentalText, { variant: "muted" }, description)))), /* @__PURE__ */ React.createElement(collapsible_card_exports.Content, null, children)); 11903 } 11904 11905 // routes/guidelines/components/guideline-accordion-form.tsx 11906 var import_components53 = __toESM(require_components()); 11907 11908 // packages/dataviews/build-module/dataviews/index.mjs 11909 var import_element87 = __toESM(require_element(), 1); 11910 var import_compose12 = __toESM(require_compose(), 1); 11911 11912 // packages/dataviews/build-module/components/dataviews-context/index.mjs 11913 var import_element32 = __toESM(require_element(), 1); 11914 11915 // packages/dataviews/build-module/constants.mjs 11916 var import_i18n = __toESM(require_i18n(), 1); 11917 var OPERATOR_IS_ANY = "isAny"; 11918 var OPERATOR_IS_NONE = "isNone"; 11919 var OPERATOR_IS_ALL = "isAll"; 11920 var OPERATOR_IS_NOT_ALL = "isNotAll"; 11921 var OPERATOR_BETWEEN = "between"; 11922 var OPERATOR_IN_THE_PAST = "inThePast"; 11923 var OPERATOR_OVER = "over"; 11924 var OPERATOR_IS = "is"; 11925 var OPERATOR_IS_NOT = "isNot"; 11926 var OPERATOR_LESS_THAN = "lessThan"; 11927 var OPERATOR_GREATER_THAN = "greaterThan"; 11928 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual"; 11929 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual"; 11930 var OPERATOR_BEFORE = "before"; 11931 var OPERATOR_AFTER = "after"; 11932 var OPERATOR_BEFORE_INC = "beforeInc"; 11933 var OPERATOR_AFTER_INC = "afterInc"; 11934 var OPERATOR_CONTAINS = "contains"; 11935 var OPERATOR_NOT_CONTAINS = "notContains"; 11936 var OPERATOR_STARTS_WITH = "startsWith"; 11937 var OPERATOR_ON = "on"; 11938 var OPERATOR_NOT_ON = "notOn"; 11939 var SORTING_DIRECTIONS = ["asc", "desc"]; 11940 var sortArrows = { asc: "\u2191", desc: "\u2193" }; 11941 var sortValues = { asc: "ascending", desc: "descending" }; 11942 var sortLabels = { 11943 asc: (0, import_i18n.__)("Sort ascending"), 11944 desc: (0, import_i18n.__)("Sort descending") 11945 }; 11946 var sortIcons = { 11947 asc: arrow_up_default, 11948 desc: arrow_down_default 11949 }; 11950 var LAYOUT_TABLE = "table"; 11951 var LAYOUT_GRID = "grid"; 11952 var LAYOUT_LIST = "list"; 11953 var LAYOUT_ACTIVITY = "activity"; 11954 var LAYOUT_PICKER_GRID = "pickerGrid"; 11955 var LAYOUT_PICKER_TABLE = "pickerTable"; 11956 11957 // packages/dataviews/build-module/components/dataviews-context/index.mjs 11958 var DataViewsContext = (0, import_element32.createContext)({ 11959 view: { type: LAYOUT_TABLE }, 11960 onChangeView: () => { 11961 }, 11962 fields: [], 11963 data: [], 11964 paginationInfo: { 11965 totalItems: 0, 11966 totalPages: 0 11967 }, 11968 selection: [], 11969 onChangeSelection: () => { 11970 }, 11971 setOpenedFilter: () => { 11972 }, 11973 openedFilter: null, 11974 getItemId: (item) => item.id, 11975 isItemClickable: () => true, 11976 renderItemLink: void 0, 11977 containerWidth: 0, 11978 containerRef: (0, import_element32.createRef)(), 11979 resizeObserverRef: () => { 11980 }, 11981 defaultLayouts: { list: {}, grid: {}, table: {} }, 11982 filters: [], 11983 isShowingFilter: false, 11984 setIsShowingFilter: () => { 11985 }, 11986 hasInitiallyLoaded: false, 11987 config: { 11988 perPageSizes: [] 11989 }, 11990 intersectionObserver: null 11991 }); 11992 DataViewsContext.displayName = "DataViewsContext"; 11993 var dataviews_context_default = DataViewsContext; 11994 11995 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs 11996 var import_i18n21 = __toESM(require_i18n(), 1); 11997 11998 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs 11999 var import_i18n9 = __toESM(require_i18n(), 1); 12000 var import_components8 = __toESM(require_components(), 1); 12001 var import_element40 = __toESM(require_element(), 1); 12002 var import_keycodes = __toESM(require_keycodes(), 1); 12003 12004 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs 12005 var import_components3 = __toESM(require_components(), 1); 12006 var import_i18n2 = __toESM(require_i18n(), 1); 12007 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1); 12008 function DataViewsSelectionCheckbox({ 12009 selection, 12010 onChangeSelection, 12011 item, 12012 getItemId, 12013 titleField, 12014 disabled: disabled2, 12015 ...extraProps 12016 }) { 12017 const id = getItemId(item); 12018 const isInSelectionArray = selection.includes(id); 12019 const checked = !disabled2 && isInSelectionArray; 12020 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)"); 12021 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12022 import_components3.CheckboxControl, 12023 { 12024 className: "dataviews-selection-checkbox", 12025 "aria-label": selectionLabel, 12026 "aria-disabled": disabled2, 12027 checked, 12028 onChange: () => { 12029 if (disabled2) { 12030 return; 12031 } 12032 onChangeSelection( 12033 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id] 12034 ); 12035 }, 12036 ...extraProps 12037 } 12038 ); 12039 } 12040 12041 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs 12042 var import_components4 = __toESM(require_components(), 1); 12043 var import_i18n3 = __toESM(require_i18n(), 1); 12044 var import_element33 = __toESM(require_element(), 1); 12045 var import_data = __toESM(require_data(), 1); 12046 var import_compose = __toESM(require_compose(), 1); 12047 12048 // packages/dataviews/build-module/lock-unlock.mjs 12049 var import_private_apis2 = __toESM(require_private_apis(), 1); 12050 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 12051 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 12052 "@wordpress/dataviews" 12053 ); 12054 12055 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs 12056 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1); 12057 var { Menu, kebabCase } = unlock2(import_components4.privateApis); 12058 function ButtonTrigger({ 12059 action, 12060 onClick, 12061 items, 12062 variant 12063 }) { 12064 const label = typeof action.label === "string" ? action.label : action.label(items); 12065 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12066 import_components4.Button, 12067 { 12068 disabled: !!action.disabled, 12069 accessibleWhenDisabled: true, 12070 size: "compact", 12071 variant, 12072 onClick, 12073 children: label 12074 } 12075 ); 12076 } 12077 function MenuItemTrigger({ 12078 action, 12079 onClick, 12080 items 12081 }) { 12082 const label = typeof action.label === "string" ? action.label : action.label(items); 12083 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu.ItemLabel, { children: label }) }); 12084 } 12085 function ActionModal({ 12086 action, 12087 items, 12088 closeModal 12089 }) { 12090 const label = typeof action.label === "string" ? action.label : action.label(items); 12091 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader; 12092 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12093 import_components4.Modal, 12094 { 12095 title: modalHeader || label, 12096 __experimentalHideHeader: !!action.hideModalHeader, 12097 onRequestClose: closeModal, 12098 focusOnMount: action.modalFocusOnMount ?? true, 12099 size: action.modalSize || "medium", 12100 overlayClassName: `dataviews-action-modal dataviews-action-modal__$kebabCase( 12101 action.id 12102 )}`, 12103 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(action.RenderModal, { items, closeModal }) 12104 } 12105 ); 12106 } 12107 function ActionsMenuGroup({ 12108 actions: actions2, 12109 item, 12110 registry, 12111 setActiveModalAction 12112 }) { 12113 const { primaryActions, regularActions } = (0, import_element33.useMemo)(() => { 12114 return actions2.reduce( 12115 (acc, action) => { 12116 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action); 12117 return acc; 12118 }, 12119 { 12120 primaryActions: [], 12121 regularActions: [] 12122 } 12123 ); 12124 }, [actions2]); 12125 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12126 MenuItemTrigger, 12127 { 12128 action, 12129 onClick: () => { 12130 if ("RenderModal" in action) { 12131 setActiveModalAction(action); 12132 return; 12133 } 12134 action.callback([item], { registry }); 12135 }, 12136 items: [item] 12137 }, 12138 action.id 12139 )); 12140 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu.Group, { children: [ 12141 renderActionGroup(primaryActions), 12142 renderActionGroup(regularActions) 12143 ] }); 12144 } 12145 function ItemActions({ 12146 item, 12147 actions: actions2, 12148 isCompact 12149 }) { 12150 const registry = (0, import_data.useRegistry)(); 12151 const { primaryActions, eligibleActions } = (0, import_element33.useMemo)(() => { 12152 const _eligibleActions = actions2.filter( 12153 (action) => !action.isEligible || action.isEligible(item) 12154 ); 12155 const _primaryActions = _eligibleActions.filter( 12156 (action) => action.isPrimary 12157 ); 12158 return { 12159 primaryActions: _primaryActions, 12160 eligibleActions: _eligibleActions 12161 }; 12162 }, [actions2, item]); 12163 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<"); 12164 if (isCompact) { 12165 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12166 CompactItemActions, 12167 { 12168 item, 12169 actions: eligibleActions, 12170 isSmall: true, 12171 registry 12172 } 12173 ); 12174 } 12175 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)( 12176 Stack, 12177 { 12178 direction: "row", 12179 justify: "flex-end", 12180 className: "dataviews-item-actions", 12181 style: { 12182 flexShrink: 0, 12183 width: "auto" 12184 }, 12185 children: [ 12186 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12187 PrimaryActions, 12188 { 12189 item, 12190 actions: primaryActions, 12191 registry 12192 } 12193 ), 12194 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu 12195 // there if there are any actions at all. 12196 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12197 CompactItemActions, 12198 { 12199 item, 12200 actions: eligibleActions, 12201 registry 12202 } 12203 ) 12204 ] 12205 } 12206 ); 12207 } 12208 function CompactItemActions({ 12209 item, 12210 actions: actions2, 12211 isSmall, 12212 registry 12213 }) { 12214 const [activeModalAction, setActiveModalAction] = (0, import_element33.useState)( 12215 null 12216 ); 12217 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [ 12218 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu, { placement: "bottom-end", children: [ 12219 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12220 Menu.TriggerButton, 12221 { 12222 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12223 import_components4.Button, 12224 { 12225 size: isSmall ? "small" : "compact", 12226 icon: more_vertical_default, 12227 label: (0, import_i18n3.__)("Actions"), 12228 accessibleWhenDisabled: true, 12229 disabled: !actions2.length, 12230 className: "dataviews-all-actions-button" 12231 } 12232 ) 12233 } 12234 ), 12235 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12236 ActionsMenuGroup, 12237 { 12238 actions: actions2, 12239 item, 12240 registry, 12241 setActiveModalAction 12242 } 12243 ) }) 12244 ] }), 12245 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12246 ActionModal, 12247 { 12248 action: activeModalAction, 12249 items: [item], 12250 closeModal: () => setActiveModalAction(null) 12251 } 12252 ) 12253 ] }); 12254 } 12255 function PrimaryActions({ 12256 item, 12257 actions: actions2, 12258 registry, 12259 buttonVariant 12260 }) { 12261 const [activeModalAction, setActiveModalAction] = (0, import_element33.useState)(null); 12262 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<"); 12263 if (isMobileViewport) { 12264 return null; 12265 } 12266 if (!Array.isArray(actions2) || actions2.length === 0) { 12267 return null; 12268 } 12269 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [ 12270 actions2.map((action) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12271 ButtonTrigger, 12272 { 12273 action, 12274 onClick: () => { 12275 if ("RenderModal" in action) { 12276 setActiveModalAction(action); 12277 return; 12278 } 12279 action.callback([item], { registry }); 12280 }, 12281 items: [item], 12282 variant: buttonVariant 12283 }, 12284 action.id 12285 )), 12286 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 12287 ActionModal, 12288 { 12289 action: activeModalAction, 12290 items: [item], 12291 closeModal: () => setActiveModalAction(null) 12292 } 12293 ) 12294 ] }); 12295 } 12296 12297 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs 12298 var import_components5 = __toESM(require_components(), 1); 12299 var import_i18n5 = __toESM(require_i18n(), 1); 12300 var import_element34 = __toESM(require_element(), 1); 12301 var import_data2 = __toESM(require_data(), 1); 12302 var import_compose2 = __toESM(require_compose(), 1); 12303 12304 // packages/dataviews/build-module/utils/get-footer-message.mjs 12305 var import_i18n4 = __toESM(require_i18n(), 1); 12306 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) { 12307 if (selectionCount > 0) { 12308 return (0, import_i18n4.sprintf)( 12309 /* translators: %d: number of items. */ 12310 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount), 12311 selectionCount 12312 ); 12313 } 12314 if (onlyTotalCount || totalItems <= itemsCount) { 12315 return (0, import_i18n4.sprintf)( 12316 /* translators: %d: number of items. */ 12317 (0, import_i18n4._n)("%d Item", "%d Items", totalItems), 12318 totalItems 12319 ); 12320 } 12321 return (0, import_i18n4.sprintf)( 12322 /* translators: %1$d: number of items. %2$d: total number of items. */ 12323 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems), 12324 itemsCount, 12325 totalItems 12326 ); 12327 } 12328 12329 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs 12330 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1); 12331 function ActionWithModal({ 12332 action, 12333 items, 12334 ActionTriggerComponent 12335 }) { 12336 const [isModalOpen, setIsModalOpen] = (0, import_element34.useState)(false); 12337 const actionTriggerProps = { 12338 action, 12339 onClick: () => { 12340 setIsModalOpen(true); 12341 }, 12342 items 12343 }; 12344 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, { children: [ 12345 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(ActionTriggerComponent, { ...actionTriggerProps }), 12346 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12347 ActionModal, 12348 { 12349 action, 12350 items, 12351 closeModal: () => setIsModalOpen(false) 12352 } 12353 ) 12354 ] }); 12355 } 12356 function useHasAPossibleBulkAction(actions2, item) { 12357 return (0, import_element34.useMemo)(() => { 12358 return actions2.some((action) => { 12359 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 12360 }); 12361 }, [actions2, item]); 12362 } 12363 function useSomeItemHasAPossibleBulkAction(actions2, data) { 12364 return (0, import_element34.useMemo)(() => { 12365 return data.some((item) => { 12366 return actions2.some((action) => { 12367 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 12368 }); 12369 }); 12370 }, [actions2, data]); 12371 } 12372 function BulkSelectionCheckbox({ 12373 selection, 12374 onChangeSelection, 12375 data, 12376 actions: actions2, 12377 getItemId, 12378 disableSelectAll = false 12379 }) { 12380 const selectableItems = (0, import_element34.useMemo)(() => { 12381 return data.filter((item) => { 12382 return actions2.some( 12383 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item)) 12384 ); 12385 }); 12386 }, [data, actions2]); 12387 const selectedItems = data.filter( 12388 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item) 12389 ); 12390 const hasSelection = selection.length > 0; 12391 const areAllSelected = selectedItems.length === selectableItems.length; 12392 if (disableSelectAll) { 12393 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12394 import_components5.CheckboxControl, 12395 { 12396 className: "dataviews-view-table-selection-checkbox", 12397 checked: hasSelection, 12398 disabled: !hasSelection, 12399 onChange: () => { 12400 onChangeSelection([]); 12401 }, 12402 "aria-label": (0, import_i18n5.__)("Deselect all") 12403 } 12404 ); 12405 } 12406 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12407 import_components5.CheckboxControl, 12408 { 12409 className: "dataviews-view-table-selection-checkbox", 12410 checked: areAllSelected, 12411 indeterminate: !areAllSelected && !!selectedItems.length, 12412 onChange: () => { 12413 if (areAllSelected) { 12414 onChangeSelection([]); 12415 } else { 12416 onChangeSelection( 12417 selectableItems.map((item) => getItemId(item)) 12418 ); 12419 } 12420 }, 12421 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all") 12422 } 12423 ); 12424 } 12425 function ActionTrigger({ 12426 action, 12427 onClick, 12428 isBusy, 12429 items 12430 }) { 12431 const label = typeof action.label === "string" ? action.label : action.label(items); 12432 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<"); 12433 if (isMobile) { 12434 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12435 import_components5.Button, 12436 { 12437 disabled: isBusy, 12438 accessibleWhenDisabled: true, 12439 label, 12440 icon: action.icon, 12441 size: "compact", 12442 onClick, 12443 isBusy 12444 } 12445 ); 12446 } 12447 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12448 import_components5.Button, 12449 { 12450 disabled: isBusy, 12451 accessibleWhenDisabled: true, 12452 size: "compact", 12453 onClick, 12454 isBusy, 12455 children: label 12456 } 12457 ); 12458 } 12459 var EMPTY_ARRAY2 = []; 12460 function ActionButton({ 12461 action, 12462 selectedItems, 12463 actionInProgress, 12464 setActionInProgress 12465 }) { 12466 const registry = (0, import_data2.useRegistry)(); 12467 const selectedEligibleItems = (0, import_element34.useMemo)(() => { 12468 return selectedItems.filter((item) => { 12469 return !action.isEligible || action.isEligible(item); 12470 }); 12471 }, [action, selectedItems]); 12472 if ("RenderModal" in action) { 12473 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12474 ActionWithModal, 12475 { 12476 action, 12477 items: selectedEligibleItems, 12478 ActionTriggerComponent: ActionTrigger 12479 }, 12480 action.id 12481 ); 12482 } 12483 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12484 ActionTrigger, 12485 { 12486 action, 12487 onClick: async () => { 12488 setActionInProgress(action.id); 12489 await action.callback(selectedItems, { 12490 registry 12491 }); 12492 setActionInProgress(null); 12493 }, 12494 items: selectedEligibleItems, 12495 isBusy: actionInProgress === action.id 12496 }, 12497 action.id 12498 ); 12499 } 12500 function renderFooterContent(data, actions2, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) { 12501 const message2 = getFooterMessage( 12502 selection.length, 12503 data.length, 12504 paginationInfo.totalItems, 12505 isInfiniteScroll 12506 ); 12507 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)( 12508 Stack, 12509 { 12510 direction: "row", 12511 className: "dataviews-bulk-actions-footer__container", 12512 gap: "md", 12513 align: "center", 12514 children: [ 12515 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12516 BulkSelectionCheckbox, 12517 { 12518 selection, 12519 onChangeSelection, 12520 data, 12521 actions: actions2, 12522 getItemId, 12523 disableSelectAll: isInfiniteScroll 12524 } 12525 ), 12526 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }), 12527 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)( 12528 Stack, 12529 { 12530 direction: "row", 12531 className: "dataviews-bulk-actions-footer__action-buttons", 12532 gap: "xs", 12533 children: [ 12534 actionsToShow.map((action) => { 12535 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12536 ActionButton, 12537 { 12538 action, 12539 selectedItems, 12540 actionInProgress, 12541 setActionInProgress 12542 }, 12543 action.id 12544 ); 12545 }), 12546 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12547 import_components5.Button, 12548 { 12549 icon: close_small_default, 12550 showTooltip: true, 12551 tooltipPosition: "top", 12552 size: "compact", 12553 label: (0, import_i18n5.__)("Cancel"), 12554 disabled: !!actionInProgress, 12555 accessibleWhenDisabled: false, 12556 onClick: () => { 12557 onChangeSelection(EMPTY_ARRAY2); 12558 } 12559 } 12560 ) 12561 ] 12562 } 12563 ) 12564 ] 12565 } 12566 ); 12567 } 12568 function FooterContent({ 12569 selection, 12570 actions: actions2, 12571 onChangeSelection, 12572 data, 12573 getItemId, 12574 isInfiniteScroll, 12575 paginationInfo 12576 }) { 12577 const [actionInProgress, setActionInProgress] = (0, import_element34.useState)( 12578 null 12579 ); 12580 const footerContentRef = (0, import_element34.useRef)(void 0); 12581 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<"); 12582 const bulkActions = (0, import_element34.useMemo)( 12583 () => actions2.filter((action) => action.supportsBulk), 12584 [actions2] 12585 ); 12586 const selectableItems = (0, import_element34.useMemo)(() => { 12587 return data.filter((item) => { 12588 return bulkActions.some( 12589 (action) => !action.isEligible || action.isEligible(item) 12590 ); 12591 }); 12592 }, [data, bulkActions]); 12593 const selectedItems = (0, import_element34.useMemo)(() => { 12594 return data.filter( 12595 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item) 12596 ); 12597 }, [selection, data, getItemId, selectableItems]); 12598 const actionsToShow = (0, import_element34.useMemo)( 12599 () => actions2.filter((action) => { 12600 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some( 12601 (item) => !action.isEligible || action.isEligible(item) 12602 ); 12603 }), 12604 [actions2, selectedItems, isMobile] 12605 ); 12606 if (!actionInProgress) { 12607 if (footerContentRef.current) { 12608 footerContentRef.current = void 0; 12609 } 12610 return renderFooterContent( 12611 data, 12612 actions2, 12613 getItemId, 12614 isInfiniteScroll, 12615 selection, 12616 actionsToShow, 12617 selectedItems, 12618 actionInProgress, 12619 setActionInProgress, 12620 onChangeSelection, 12621 paginationInfo 12622 ); 12623 } else if (!footerContentRef.current) { 12624 footerContentRef.current = renderFooterContent( 12625 data, 12626 actions2, 12627 getItemId, 12628 isInfiniteScroll, 12629 selection, 12630 actionsToShow, 12631 selectedItems, 12632 actionInProgress, 12633 setActionInProgress, 12634 onChangeSelection, 12635 paginationInfo 12636 ); 12637 } 12638 return footerContentRef.current; 12639 } 12640 function BulkActionsFooter() { 12641 const { 12642 data, 12643 selection, 12644 actions: actions2 = EMPTY_ARRAY2, 12645 onChangeSelection, 12646 getItemId, 12647 paginationInfo, 12648 view 12649 } = (0, import_element34.useContext)(dataviews_context_default); 12650 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 12651 FooterContent, 12652 { 12653 selection, 12654 onChangeSelection, 12655 data, 12656 actions: actions2, 12657 getItemId, 12658 isInfiniteScroll: !!view.infiniteScrollEnabled, 12659 paginationInfo 12660 } 12661 ); 12662 } 12663 12664 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs 12665 var import_i18n6 = __toESM(require_i18n(), 1); 12666 var import_components6 = __toESM(require_components(), 1); 12667 var import_element35 = __toESM(require_element(), 1); 12668 12669 // packages/dataviews/build-module/utils/get-hideable-fields.mjs 12670 function getHideableFields(view, fields2) { 12671 const togglableFields = [ 12672 view?.titleField, 12673 view?.mediaField, 12674 view?.descriptionField 12675 ].filter(Boolean); 12676 return fields2.filter( 12677 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false 12678 ); 12679 } 12680 12681 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs 12682 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1); 12683 var { Menu: Menu2 } = unlock2(import_components6.privateApis); 12684 function WithMenuSeparators({ children }) { 12685 return import_element35.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_element35.Fragment, { children: [ 12686 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.Separator, {}), 12687 child 12688 ] }, i2)); 12689 } 12690 var _HeaderMenu = (0, import_element35.forwardRef)(function HeaderMenu({ 12691 fieldId, 12692 view, 12693 fields: fields2, 12694 onChangeView, 12695 onHide, 12696 setOpenedFilter, 12697 canMove = true, 12698 canInsertLeft = true, 12699 canInsertRight = true 12700 }, ref) { 12701 const visibleFieldIds = view.fields ?? []; 12702 const index2 = visibleFieldIds?.indexOf(fieldId); 12703 const isSorted = view.sort?.field === fieldId; 12704 let isHidable = false; 12705 let isSortable = false; 12706 let canAddFilter = false; 12707 let operators = []; 12708 const field = fields2.find((f2) => f2.id === fieldId); 12709 const { setIsShowingFilter } = (0, import_element35.useContext)(dataviews_context_default); 12710 if (!field) { 12711 return null; 12712 } 12713 isHidable = field.enableHiding !== false; 12714 isSortable = field.enableSorting !== false; 12715 const header = field.header; 12716 operators = !!field.filterBy && field.filterBy?.operators || []; 12717 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary; 12718 if (!isSortable && !canMove && !isHidable && !canAddFilter) { 12719 return header; 12720 } 12721 const hiddenFields = getHideableFields(view, fields2).filter( 12722 (f2) => !visibleFieldIds.includes(f2.id) 12723 ); 12724 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length; 12725 const isRtl = (0, import_i18n6.isRTL)(); 12726 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Menu2, { children: [ 12727 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)( 12728 Menu2.TriggerButton, 12729 { 12730 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 12731 import_components6.Button, 12732 { 12733 size: "compact", 12734 className: "dataviews-view-table-header-button", 12735 ref, 12736 variant: "tertiary" 12737 } 12738 ), 12739 children: [ 12740 header, 12741 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] }) 12742 ] 12743 } 12744 ), 12745 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(WithMenuSeparators, { children: [ 12746 isSortable && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map( 12747 (direction) => { 12748 const isChecked = view.sort && isSorted && view.sort.direction === direction; 12749 const value = `$fieldId}-$direction}`; 12750 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 12751 Menu2.RadioItem, 12752 { 12753 name: "view-table-sorting", 12754 value, 12755 checked: isChecked, 12756 onChange: () => { 12757 onChangeView({ 12758 ...view, 12759 sort: { 12760 field: fieldId, 12761 direction 12762 }, 12763 showLevels: false 12764 }); 12765 }, 12766 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] }) 12767 }, 12768 value 12769 ); 12770 } 12771 ) }), 12772 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 12773 Menu2.Item, 12774 { 12775 prefix: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components6.Icon, { icon: funnel_default }), 12776 onClick: () => { 12777 setOpenedFilter(fieldId); 12778 setIsShowingFilter(true); 12779 onChangeView({ 12780 ...view, 12781 page: 1, 12782 filters: [ 12783 ...view.filters || [], 12784 { 12785 field: fieldId, 12786 value: void 0, 12787 operator: operators[0] 12788 } 12789 ] 12790 }); 12791 }, 12792 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") }) 12793 } 12794 ) }), 12795 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Menu2.Group, { children: [ 12796 canMove && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 12797 Menu2.Item, 12798 { 12799 prefix: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components6.Icon, { icon: arrow_left_default }), 12800 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1, 12801 onClick: () => { 12802 const targetIndex = isRtl ? index2 + 1 : index2 - 1; 12803 const newFields = [ 12804 ...visibleFieldIds 12805 ]; 12806 newFields.splice(index2, 1); 12807 newFields.splice( 12808 targetIndex, 12809 0, 12810 fieldId 12811 ); 12812 onChangeView({ 12813 ...view, 12814 fields: newFields 12815 }); 12816 }, 12817 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") }) 12818 } 12819 ), 12820 canMove && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 12821 Menu2.Item, 12822 { 12823 prefix: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components6.Icon, { icon: arrow_right_default }), 12824 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1, 12825 onClick: () => { 12826 const targetIndex = isRtl ? index2 - 1 : index2 + 1; 12827 const newFields = [ 12828 ...visibleFieldIds 12829 ]; 12830 newFields.splice(index2, 1); 12831 newFields.splice( 12832 targetIndex, 12833 0, 12834 fieldId 12835 ); 12836 onChangeView({ 12837 ...view, 12838 fields: newFields 12839 }); 12840 }, 12841 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") }) 12842 } 12843 ), 12844 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Menu2, { children: [ 12845 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }), 12846 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => { 12847 const insertIndex = isRtl ? index2 + 1 : index2; 12848 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 12849 Menu2.Item, 12850 { 12851 onClick: () => { 12852 onChangeView({ 12853 ...view, 12854 fields: [ 12855 ...visibleFieldIds.slice( 12856 0, 12857 insertIndex 12858 ), 12859 hiddenField.id, 12860 ...visibleFieldIds.slice( 12861 insertIndex 12862 ) 12863 ] 12864 }); 12865 }, 12866 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 12867 }, 12868 hiddenField.id 12869 ); 12870 }) }) 12871 ] }), 12872 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Menu2, { children: [ 12873 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }), 12874 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => { 12875 const insertIndex = isRtl ? index2 : index2 + 1; 12876 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 12877 Menu2.Item, 12878 { 12879 onClick: () => { 12880 onChangeView({ 12881 ...view, 12882 fields: [ 12883 ...visibleFieldIds.slice( 12884 0, 12885 insertIndex 12886 ), 12887 hiddenField.id, 12888 ...visibleFieldIds.slice( 12889 insertIndex 12890 ) 12891 ] 12892 }); 12893 }, 12894 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 12895 }, 12896 hiddenField.id 12897 ); 12898 }) }) 12899 ] }), 12900 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 12901 Menu2.Item, 12902 { 12903 prefix: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components6.Icon, { icon: unseen_default }), 12904 onClick: () => { 12905 onHide(field); 12906 onChangeView({ 12907 ...view, 12908 fields: visibleFieldIds.filter( 12909 (id) => id !== fieldId 12910 ) 12911 }); 12912 }, 12913 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") }) 12914 } 12915 ) 12916 ] }) 12917 ] }) }) 12918 ] }); 12919 }); 12920 var ColumnHeaderMenu = _HeaderMenu; 12921 var column_header_menu_default = ColumnHeaderMenu; 12922 12923 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs 12924 var import_element36 = __toESM(require_element(), 1); 12925 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1); 12926 function getClickableItemProps({ 12927 item, 12928 isItemClickable, 12929 onClickItem, 12930 className 12931 }) { 12932 if (!isItemClickable(item) || !onClickItem) { 12933 return { className }; 12934 } 12935 return { 12936 className: className ? `$className} $className}--clickable` : void 0, 12937 role: "button", 12938 tabIndex: 0, 12939 onClick: (event) => { 12940 event.stopPropagation(); 12941 onClickItem(item); 12942 }, 12943 onKeyDown: (event) => { 12944 if (event.key === "Enter" || event.key === "" || event.key === " ") { 12945 event.stopPropagation(); 12946 onClickItem(item); 12947 } 12948 } 12949 }; 12950 } 12951 function ItemClickWrapper({ 12952 item, 12953 isItemClickable, 12954 onClickItem, 12955 renderItemLink, 12956 className, 12957 children, 12958 ...extraProps 12959 }) { 12960 if (!isItemClickable(item)) { 12961 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className, ...extraProps, children }); 12962 } 12963 if (renderItemLink) { 12964 const renderedElement = renderItemLink({ 12965 item, 12966 className: `$className} $className}--clickable`, 12967 ...extraProps, 12968 children 12969 }); 12970 return (0, import_element36.cloneElement)(renderedElement, { 12971 onClick: (event) => { 12972 event.stopPropagation(); 12973 if (renderedElement.props.onClick) { 12974 renderedElement.props.onClick(event); 12975 } 12976 }, 12977 onKeyDown: (event) => { 12978 if (event.key === "Enter" || event.key === "" || event.key === " ") { 12979 event.stopPropagation(); 12980 if (renderedElement.props.onKeyDown) { 12981 renderedElement.props.onKeyDown(event); 12982 } 12983 } 12984 } 12985 }); 12986 } 12987 const clickProps = getClickableItemProps({ 12988 item, 12989 isItemClickable, 12990 onClickItem, 12991 className 12992 }); 12993 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { ...clickProps, ...extraProps, children }); 12994 } 12995 12996 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs 12997 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1); 12998 function ColumnPrimary({ 12999 item, 13000 level, 13001 titleField, 13002 mediaField, 13003 descriptionField, 13004 onClickItem, 13005 renderItemLink, 13006 isItemClickable 13007 }) { 13008 return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [ 13009 mediaField && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 13010 ItemClickWrapper, 13011 { 13012 item, 13013 isItemClickable, 13014 onClickItem, 13015 renderItemLink, 13016 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media", 13017 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0, 13018 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 13019 mediaField.render, 13020 { 13021 item, 13022 field: mediaField, 13023 config: { sizes: "32px" } 13024 } 13025 ) 13026 } 13027 ), 13028 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)( 13029 Stack, 13030 { 13031 direction: "column", 13032 align: "flex-start", 13033 className: "dataviews-view-table__primary-column-content", 13034 children: [ 13035 titleField && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)( 13036 ItemClickWrapper, 13037 { 13038 item, 13039 isItemClickable, 13040 onClickItem, 13041 renderItemLink, 13042 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field", 13043 children: [ 13044 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("span", { className: "dataviews-view-table__level", children: [ 13045 Array(level).fill("\u2014").join(" "), 13046 "\xA0" 13047 ] }), 13048 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(titleField.render, { item, field: titleField }) 13049 ] 13050 } 13051 ), 13052 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 13053 descriptionField.render, 13054 { 13055 item, 13056 field: descriptionField 13057 } 13058 ) 13059 ] 13060 } 13061 ) 13062 ] }); 13063 } 13064 var column_primary_default = ColumnPrimary; 13065 13066 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs 13067 var import_element37 = __toESM(require_element(), 1); 13068 var import_i18n7 = __toESM(require_i18n(), 1); 13069 var isScrolledToEnd = (element) => { 13070 if ((0, import_i18n7.isRTL)()) { 13071 const scrollLeft = Math.abs(element.scrollLeft); 13072 return scrollLeft <= 1; 13073 } 13074 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1; 13075 }; 13076 function useScrollState({ 13077 scrollContainerRef, 13078 enabledHorizontal = false 13079 }) { 13080 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element37.useState)(false); 13081 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element37.useState)(false); 13082 const handleScroll = (0, import_element37.useCallback)(() => { 13083 const scrollContainer = scrollContainerRef.current; 13084 if (!scrollContainer) { 13085 return; 13086 } 13087 if (enabledHorizontal) { 13088 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer)); 13089 } 13090 setIsVerticallyScrolled(scrollContainer.scrollTop > 0); 13091 }, [scrollContainerRef, enabledHorizontal]); 13092 (0, import_element37.useEffect)(() => { 13093 if (typeof window === "undefined" || !scrollContainerRef.current) { 13094 return () => { 13095 }; 13096 } 13097 const scrollContainer = scrollContainerRef.current; 13098 handleScroll(); 13099 scrollContainer.addEventListener("scroll", handleScroll); 13100 window.addEventListener("resize", handleScroll); 13101 return () => { 13102 scrollContainer.removeEventListener("scroll", handleScroll); 13103 window.removeEventListener("resize", handleScroll); 13104 }; 13105 }, [scrollContainerRef, enabledHorizontal, handleScroll]); 13106 return { isHorizontalScrollEnd, isVerticallyScrolled }; 13107 } 13108 13109 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs 13110 function getDataByGroup(data, groupByField) { 13111 return data.reduce((groups, item) => { 13112 const groupName = groupByField.getValue({ item }); 13113 if (!groups.has(groupName)) { 13114 groups.set(groupName, []); 13115 } 13116 groups.get(groupName)?.push(item); 13117 return groups; 13118 }, /* @__PURE__ */ new Map()); 13119 } 13120 13121 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs 13122 var import_components7 = __toESM(require_components(), 1); 13123 var import_i18n8 = __toESM(require_i18n(), 1); 13124 var import_element38 = __toESM(require_element(), 1); 13125 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1); 13126 function FieldItem({ 13127 field, 13128 isVisible: isVisible2, 13129 onToggleVisibility 13130 }) { 13131 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components7.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [ 13132 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components7.Icon, { icon: check_default }) }), 13133 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "dataviews-view-config__label", children: field.label }) 13134 ] }) }); 13135 } 13136 function isDefined(item) { 13137 return !!item; 13138 } 13139 function PropertiesSection({ 13140 showLabel = true 13141 }) { 13142 const { view, fields: fields2, onChangeView } = (0, import_element38.useContext)(dataviews_context_default); 13143 const regularFields = getHideableFields(view, fields2); 13144 if (!regularFields?.length) { 13145 return null; 13146 } 13147 const titleField = fields2.find((f2) => f2.id === view.titleField); 13148 const previewField = fields2.find((f2) => f2.id === view.mediaField); 13149 const descriptionField = fields2.find( 13150 (f2) => f2.id === view.descriptionField 13151 ); 13152 const lockedFields = [ 13153 { 13154 field: titleField, 13155 isVisibleFlag: "showTitle" 13156 }, 13157 { 13158 field: previewField, 13159 isVisibleFlag: "showMedia" 13160 }, 13161 { 13162 field: descriptionField, 13163 isVisibleFlag: "showDescription" 13164 } 13165 ].filter(({ field }) => isDefined(field)); 13166 const visibleFieldIds = view.fields ?? []; 13167 const visibleRegularFieldsCount = regularFields.filter( 13168 (f2) => visibleFieldIds.includes(f2.id) 13169 ).length; 13170 const visibleLockedFields = lockedFields.filter( 13171 ({ isVisibleFlag }) => ( 13172 // @ts-expect-error 13173 view[isVisibleFlag] ?? true 13174 ) 13175 ); 13176 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount; 13177 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1; 13178 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [ 13179 showLabel && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components7.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }), 13180 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13181 Stack, 13182 { 13183 direction: "column", 13184 className: "dataviews-view-config__properties", 13185 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_components7.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [ 13186 lockedFields.map(({ field, isVisibleFlag }) => { 13187 const isVisible2 = view[isVisibleFlag] ?? true; 13188 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field; 13189 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13190 FieldItem, 13191 { 13192 field: fieldToRender, 13193 isVisible: isVisible2, 13194 onToggleVisibility: () => { 13195 onChangeView({ 13196 ...view, 13197 [isVisibleFlag]: !isVisible2 13198 }); 13199 } 13200 }, 13201 field.id 13202 ); 13203 }), 13204 regularFields.map((field) => { 13205 const isVisible2 = visibleFieldIds.includes(field.id); 13206 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field; 13207 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13208 FieldItem, 13209 { 13210 field: fieldToRender, 13211 isVisible: isVisible2, 13212 onToggleVisibility: () => { 13213 onChangeView({ 13214 ...view, 13215 fields: isVisible2 ? visibleFieldIds.filter( 13216 (fieldId) => fieldId !== field.id 13217 ) : [...visibleFieldIds, field.id] 13218 }); 13219 } 13220 }, 13221 field.id 13222 ); 13223 }) 13224 ] }) 13225 } 13226 ) 13227 ] }); 13228 } 13229 13230 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs 13231 var import_element39 = __toESM(require_element(), 1); 13232 function useDelayedLoading(isLoading, options = { delay: 400 }) { 13233 const [showLoader, setShowLoader] = (0, import_element39.useState)(false); 13234 (0, import_element39.useEffect)(() => { 13235 if (!isLoading) { 13236 return; 13237 } 13238 const timeout = setTimeout(() => { 13239 setShowLoader(true); 13240 }, options.delay); 13241 return () => { 13242 clearTimeout(timeout); 13243 setShowLoader(false); 13244 }; 13245 }, [isLoading, options.delay]); 13246 return showLoader; 13247 } 13248 13249 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs 13250 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1); 13251 function getEffectiveAlign(explicitAlign, fieldType) { 13252 if (explicitAlign) { 13253 return explicitAlign; 13254 } 13255 if (fieldType === "integer" || fieldType === "number") { 13256 return "end"; 13257 } 13258 return void 0; 13259 } 13260 function TableColumnField({ 13261 item, 13262 fields: fields2, 13263 column, 13264 align 13265 }) { 13266 const field = fields2.find((f2) => f2.id === column); 13267 if (!field) { 13268 return null; 13269 } 13270 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 13271 "dataviews-view-table__cell-align-end": align === "end", 13272 "dataviews-view-table__cell-align-center": align === "center" 13273 }); 13274 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(field.render, { item, field }) }); 13275 } 13276 function TableRow({ 13277 hasBulkActions, 13278 item, 13279 level, 13280 actions: actions2, 13281 fields: fields2, 13282 id, 13283 view, 13284 titleField, 13285 mediaField, 13286 descriptionField, 13287 selection, 13288 getItemId, 13289 isItemClickable, 13290 onClickItem, 13291 renderItemLink, 13292 onChangeSelection, 13293 isActionsColumnSticky, 13294 posinset 13295 }) { 13296 const { paginationInfo } = (0, import_element40.useContext)(dataviews_context_default); 13297 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions2, item); 13298 const isSelected2 = hasPossibleBulkAction && selection.includes(id); 13299 const { 13300 showTitle = true, 13301 showMedia = true, 13302 showDescription = true, 13303 infiniteScrollEnabled 13304 } = view; 13305 const isTouchDeviceRef = (0, import_element40.useRef)(false); 13306 const columns = view.fields ?? []; 13307 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 13308 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)( 13309 "tr", 13310 { 13311 className: clsx_default("dataviews-view-table__row", { 13312 "is-selected": hasPossibleBulkAction && isSelected2, 13313 "has-bulk-actions": hasPossibleBulkAction 13314 }), 13315 onTouchStart: () => { 13316 isTouchDeviceRef.current = true; 13317 }, 13318 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 13319 "aria-posinset": posinset, 13320 role: infiniteScrollEnabled ? "article" : void 0, 13321 onMouseDown: (event) => { 13322 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 13323 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) { 13324 event?.preventDefault(); 13325 } 13326 }, 13327 onClick: (event) => { 13328 if (!hasPossibleBulkAction) { 13329 return; 13330 } 13331 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 13332 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") { 13333 onChangeSelection( 13334 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 13335 ); 13336 } 13337 }, 13338 children: [ 13339 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13340 DataViewsSelectionCheckbox, 13341 { 13342 item, 13343 selection, 13344 onChangeSelection, 13345 getItemId, 13346 titleField, 13347 disabled: !hasPossibleBulkAction 13348 } 13349 ) }) }), 13350 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13351 column_primary_default, 13352 { 13353 item, 13354 level, 13355 titleField: showTitle ? titleField : void 0, 13356 mediaField: showMedia ? mediaField : void 0, 13357 descriptionField: showDescription ? descriptionField : void 0, 13358 isItemClickable, 13359 onClickItem, 13360 renderItemLink 13361 } 13362 ) }), 13363 columns.map((column) => { 13364 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 13365 const field = fields2.find((f2) => f2.id === column); 13366 const effectiveAlign = getEffectiveAlign(align, field?.type); 13367 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13368 "td", 13369 { 13370 style: { 13371 width, 13372 maxWidth, 13373 minWidth 13374 }, 13375 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13376 TableColumnField, 13377 { 13378 fields: fields2, 13379 item, 13380 column, 13381 align: effectiveAlign 13382 } 13383 ) 13384 }, 13385 column 13386 ); 13387 }), 13388 !!actions2?.length && // Disable reason: we are not making the element interactive, 13389 // but preventing any click events from bubbling up to the 13390 // table row. This allows us to add a click handler to the row 13391 // itself (to toggle row selection) without erroneously 13392 // intercepting click events from ItemActions. 13393 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13394 "td", 13395 { 13396 className: clsx_default("dataviews-view-table__actions-column", { 13397 "dataviews-view-table__actions-column--sticky": true, 13398 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky 13399 }), 13400 onClick: (e2) => e2.stopPropagation(), 13401 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ItemActions, { item, actions: actions2 }) 13402 } 13403 ) 13404 ] 13405 } 13406 ); 13407 } 13408 function ViewTable({ 13409 actions: actions2, 13410 data, 13411 fields: fields2, 13412 getItemId, 13413 getItemLevel, 13414 isLoading = false, 13415 onChangeView, 13416 onChangeSelection, 13417 selection, 13418 setOpenedFilter, 13419 onClickItem, 13420 isItemClickable, 13421 renderItemLink, 13422 view, 13423 className, 13424 empty 13425 }) { 13426 const { containerRef } = (0, import_element40.useContext)(dataviews_context_default); 13427 const isDelayedLoading = useDelayedLoading(isLoading); 13428 const headerMenuRefs = (0, import_element40.useRef)(/* @__PURE__ */ new Map()); 13429 const headerMenuToFocusRef = (0, import_element40.useRef)(void 0); 13430 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element40.useState)(); 13431 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element40.useState)(null); 13432 (0, import_element40.useEffect)(() => { 13433 if (headerMenuToFocusRef.current) { 13434 headerMenuToFocusRef.current.focus(); 13435 headerMenuToFocusRef.current = void 0; 13436 } 13437 }); 13438 const tableNoticeId = (0, import_element40.useId)(); 13439 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({ 13440 scrollContainerRef: containerRef, 13441 enabledHorizontal: !!actions2?.length 13442 }); 13443 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data); 13444 if (nextHeaderMenuToFocus) { 13445 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 13446 setNextHeaderMenuToFocus(void 0); 13447 return; 13448 } 13449 const onHide = (field) => { 13450 const hidden = headerMenuRefs.current.get(field.id); 13451 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 13452 setNextHeaderMenuToFocus(fallback?.node); 13453 }; 13454 const handleHeaderContextMenu = (event) => { 13455 event.preventDefault(); 13456 event.stopPropagation(); 13457 const virtualAnchor = { 13458 getBoundingClientRect: () => ({ 13459 x: event.clientX, 13460 y: event.clientY, 13461 top: event.clientY, 13462 left: event.clientX, 13463 right: event.clientX, 13464 bottom: event.clientY, 13465 width: 0, 13466 height: 0, 13467 toJSON: () => ({}) 13468 }) 13469 }; 13470 window.requestAnimationFrame(() => { 13471 setContextMenuAnchor(virtualAnchor); 13472 }); 13473 }; 13474 const hasData = !!data?.length; 13475 const titleField = fields2.find((field) => field.id === view.titleField); 13476 const mediaField = fields2.find((field) => field.id === view.mediaField); 13477 const descriptionField = fields2.find( 13478 (field) => field.id === view.descriptionField 13479 ); 13480 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null; 13481 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 13482 const { showTitle = true, showMedia = true, showDescription = true } = view; 13483 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 13484 const columns = view.fields ?? []; 13485 const headerMenuRef = (column, index2) => (node) => { 13486 if (node) { 13487 headerMenuRefs.current.set(column, { 13488 node, 13489 fallback: columns[index2 > 0 ? index2 - 1 : 1] 13490 }); 13491 } else { 13492 headerMenuRefs.current.delete(column); 13493 } 13494 }; 13495 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 13496 const isRtl = (0, import_i18n9.isRTL)(); 13497 if (!hasData) { 13498 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13499 "div", 13500 { 13501 className: clsx_default("dataviews-no-results", { 13502 "is-refreshing": isDelayedLoading 13503 }), 13504 id: tableNoticeId, 13505 children: empty 13506 } 13507 ); 13508 } 13509 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [ 13510 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)( 13511 "table", 13512 { 13513 className: clsx_default("dataviews-view-table", className, { 13514 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 13515 view.layout.density 13516 ), 13517 "has-bulk-actions": hasBulkActions, 13518 "is-refreshing": !isInfiniteScroll && isDelayedLoading 13519 }), 13520 "aria-busy": isLoading, 13521 "aria-describedby": tableNoticeId, 13522 role: isInfiniteScroll ? "feed" : void 0, 13523 inert: !isInfiniteScroll && isLoading ? "true" : void 0, 13524 children: [ 13525 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("colgroup", { children: [ 13526 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("col", { className: "dataviews-view-table__col-checkbox" }), 13527 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("col", { className: "dataviews-view-table__col-first-data" }), 13528 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13529 "col", 13530 { 13531 className: clsx_default( 13532 `dataviews-view-table__col-$column}`, 13533 { 13534 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1 13535 } 13536 ) 13537 }, 13538 `col-$column}` 13539 )), 13540 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("col", { className: "dataviews-view-table__col-actions" }) 13541 ] }), 13542 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13543 import_components8.Popover, 13544 { 13545 anchor: contextMenuAnchor, 13546 onClose: () => setContextMenuAnchor(null), 13547 placement: "bottom-start", 13548 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(PropertiesSection, { showLabel: false }) 13549 } 13550 ), 13551 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13552 "thead", 13553 { 13554 className: clsx_default({ 13555 "dataviews-view-table__thead--stuck": isVerticallyScrolled 13556 }), 13557 onContextMenu: handleHeaderContextMenu, 13558 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("tr", { className: "dataviews-view-table__row", children: [ 13559 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13560 "th", 13561 { 13562 className: "dataviews-view-table__checkbox-column", 13563 scope: "col", 13564 onContextMenu: handleHeaderContextMenu, 13565 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13566 BulkSelectionCheckbox, 13567 { 13568 selection, 13569 onChangeSelection, 13570 data, 13571 actions: actions2, 13572 getItemId 13573 } 13574 ) 13575 } 13576 ), 13577 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13578 column_header_menu_default, 13579 { 13580 ref: headerMenuRef( 13581 titleField.id, 13582 0 13583 ), 13584 fieldId: titleField.id, 13585 view, 13586 fields: fields2, 13587 onChangeView, 13588 onHide, 13589 setOpenedFilter, 13590 canMove: false, 13591 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false, 13592 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true 13593 } 13594 ) }), 13595 columns.map((column, index2) => { 13596 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 13597 const field = fields2.find( 13598 (f2) => f2.id === column 13599 ); 13600 const effectiveAlign = getEffectiveAlign( 13601 align, 13602 field?.type 13603 ); 13604 const canInsertOrMove = view.layout?.enableMoving ?? true; 13605 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13606 "th", 13607 { 13608 style: { 13609 width, 13610 maxWidth, 13611 minWidth, 13612 textAlign: effectiveAlign 13613 }, 13614 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 13615 scope: "col", 13616 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13617 column_header_menu_default, 13618 { 13619 ref: headerMenuRef(column, index2), 13620 fieldId: column, 13621 view, 13622 fields: fields2, 13623 onChangeView, 13624 onHide, 13625 setOpenedFilter, 13626 canMove: canInsertOrMove, 13627 canInsertLeft: canInsertOrMove, 13628 canInsertRight: canInsertOrMove 13629 } 13630 ) 13631 }, 13632 column 13633 ); 13634 }), 13635 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13636 "th", 13637 { 13638 className: clsx_default( 13639 "dataviews-view-table__actions-column", 13640 { 13641 "dataviews-view-table__actions-column--sticky": true, 13642 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd 13643 } 13644 ), 13645 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") }) 13646 } 13647 ) 13648 ] }) 13649 } 13650 ), 13651 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 13652 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("tbody", { children: [ 13653 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13654 "td", 13655 { 13656 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions2?.length ? 1 : 0), 13657 className: "dataviews-view-table__group-header-cell", 13658 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)( 13659 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 13660 (0, import_i18n9.__)("%1$s: %2$s"), 13661 groupField.label, 13662 groupName 13663 ) 13664 } 13665 ) }), 13666 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13667 TableRow, 13668 { 13669 item, 13670 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 13671 hasBulkActions, 13672 actions: actions2, 13673 fields: fields2, 13674 id: getItemId(item) || index2.toString(), 13675 view, 13676 titleField, 13677 mediaField, 13678 descriptionField, 13679 selection, 13680 getItemId, 13681 onChangeSelection, 13682 onClickItem, 13683 renderItemLink, 13684 isItemClickable, 13685 isActionsColumnSticky: !isHorizontalScrollEnd 13686 }, 13687 getItemId(item) 13688 )) 13689 ] }, `group-$groupName}`) 13690 ) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 13691 TableRow, 13692 { 13693 item, 13694 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 13695 hasBulkActions, 13696 actions: actions2, 13697 fields: fields2, 13698 id: getItemId(item) || index2.toString(), 13699 view, 13700 titleField, 13701 mediaField, 13702 descriptionField, 13703 selection, 13704 getItemId, 13705 onChangeSelection, 13706 onClickItem, 13707 renderItemLink, 13708 isItemClickable, 13709 isActionsColumnSticky: !isHorizontalScrollEnd, 13710 posinset: isInfiniteScroll ? index2 + 1 : void 0 13711 }, 13712 getItemId(item) 13713 )) }) 13714 ] 13715 } 13716 ), 13717 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components8.Spinner, {}) }) }) 13718 ] }); 13719 } 13720 var table_default = ViewTable; 13721 13722 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs 13723 var import_components11 = __toESM(require_components(), 1); 13724 var import_i18n12 = __toESM(require_i18n(), 1); 13725 13726 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs 13727 var import_components10 = __toESM(require_components(), 1); 13728 var import_i18n11 = __toESM(require_i18n(), 1); 13729 var import_compose3 = __toESM(require_compose(), 1); 13730 var import_keycodes2 = __toESM(require_keycodes(), 1); 13731 var import_element44 = __toESM(require_element(), 1); 13732 13733 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs 13734 var import_components9 = __toESM(require_components(), 1); 13735 var import_i18n10 = __toESM(require_i18n(), 1); 13736 var import_element41 = __toESM(require_element(), 1); 13737 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1); 13738 var imageSizes = [ 13739 { 13740 value: 120, 13741 breakpoint: 1 13742 }, 13743 { 13744 value: 170, 13745 breakpoint: 1 13746 }, 13747 { 13748 value: 230, 13749 breakpoint: 1 13750 }, 13751 { 13752 value: 290, 13753 breakpoint: 1112 13754 // at minimum image width, 4 images display at this container size 13755 }, 13756 { 13757 value: 350, 13758 breakpoint: 1636 13759 // at minimum image width, 6 images display at this container size 13760 }, 13761 { 13762 value: 430, 13763 breakpoint: 588 13764 // at minimum image width, 2 images display at this container size 13765 } 13766 ]; 13767 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value; 13768 function useGridColumns() { 13769 const context = (0, import_element41.useContext)(dataviews_context_default); 13770 const view = context.view; 13771 return (0, import_element41.useMemo)(() => { 13772 const containerWidth = context.containerWidth; 13773 const gap = 32; 13774 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE; 13775 const columns = Math.floor( 13776 (containerWidth + gap) / (previewSize + gap) 13777 ); 13778 return Math.max(1, columns); 13779 }, [context.containerWidth, view.layout?.previewSize]); 13780 } 13781 13782 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs 13783 var import_element42 = __toESM(require_element(), 1); 13784 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1); 13785 var GridItems = (0, import_element42.forwardRef)(({ className, previewSize, ...props }, ref) => { 13786 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 13787 "div", 13788 { 13789 ref, 13790 className: clsx_default("dataviews-view-grid-items", className), 13791 style: { 13792 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax($previewSize}px, 1fr))` 13793 }, 13794 ...props 13795 } 13796 ); 13797 }); 13798 13799 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs 13800 var import_element43 = __toESM(require_element(), 1); 13801 function useIntersectionObserver(elementRef, posinset) { 13802 const { intersectionObserver } = (0, import_element43.useContext)(dataviews_context_default); 13803 (0, import_element43.useEffect)(() => { 13804 const element = elementRef.current; 13805 if (!element || posinset === void 0 || !intersectionObserver) { 13806 return; 13807 } 13808 intersectionObserver.observe(element); 13809 return () => { 13810 intersectionObserver.unobserve(element); 13811 }; 13812 }, [elementRef, intersectionObserver, posinset]); 13813 } 13814 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) { 13815 const hasData = !!data?.length; 13816 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0; 13817 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0; 13818 } 13819 13820 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs 13821 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1); 13822 var { Badge: WCBadge } = unlock2(import_components10.privateApis); 13823 function chunk(array, size4) { 13824 const chunks = []; 13825 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) { 13826 chunks.push(array.slice(i2, i2 + size4)); 13827 } 13828 return chunks; 13829 } 13830 var GridItem = (0, import_element44.forwardRef)( 13831 function GridItem2({ 13832 view, 13833 selection, 13834 onChangeSelection, 13835 onClickItem, 13836 isItemClickable, 13837 renderItemLink, 13838 getItemId, 13839 item, 13840 actions: actions2, 13841 mediaField, 13842 titleField, 13843 descriptionField, 13844 regularFields, 13845 badgeFields, 13846 hasBulkActions, 13847 config, 13848 posinset, 13849 setsize, 13850 ...props 13851 }, forwardedRef) { 13852 const { 13853 showTitle = true, 13854 showMedia = true, 13855 showDescription = true 13856 } = view; 13857 const hasBulkAction = useHasAPossibleBulkAction(actions2, item); 13858 const id = getItemId(item); 13859 const elementRef = (0, import_element44.useRef)(null); 13860 const setRefs = (0, import_element44.useCallback)( 13861 (node) => { 13862 elementRef.current = node; 13863 if (typeof forwardedRef === "function") { 13864 forwardedRef(node); 13865 } else if (forwardedRef) { 13866 forwardedRef.current = node; 13867 } 13868 }, 13869 [forwardedRef] 13870 ); 13871 useIntersectionObserver(elementRef, posinset); 13872 const instanceId = (0, import_compose3.useInstanceId)(GridItem2); 13873 const isSelected2 = selection.includes(id); 13874 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "dataviews-view-grid__media-placeholder" }); 13875 const rendersMediaField = showMedia && mediaField?.render; 13876 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 13877 mediaField.render, 13878 { 13879 item, 13880 field: mediaField, 13881 config 13882 } 13883 ) : mediaPlaceholder; 13884 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(titleField.render, { item, field: titleField }) : null; 13885 let mediaA11yProps; 13886 let titleA11yProps; 13887 if (isItemClickable(item) && onClickItem) { 13888 if (renderedTitleField) { 13889 mediaA11yProps = { 13890 "aria-labelledby": `dataviews-view-grid__title-field-$instanceId}` 13891 }; 13892 titleA11yProps = { 13893 id: `dataviews-view-grid__title-field-$instanceId}` 13894 }; 13895 } else { 13896 mediaA11yProps = { 13897 "aria-label": (0, import_i18n11.__)("Navigate to item") 13898 }; 13899 } 13900 } 13901 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)( 13902 Stack, 13903 { 13904 direction: "column", 13905 ...props, 13906 ref: setRefs, 13907 "aria-setsize": setsize, 13908 "aria-posinset": posinset, 13909 className: clsx_default( 13910 props.className, 13911 "dataviews-view-grid__row__gridcell", 13912 "dataviews-view-grid__card", 13913 { 13914 "is-selected": hasBulkAction && isSelected2 13915 } 13916 ), 13917 onClickCapture: (event) => { 13918 props.onClickCapture?.(event); 13919 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) { 13920 event.stopPropagation(); 13921 event.preventDefault(); 13922 if (!hasBulkAction) { 13923 return; 13924 } 13925 onChangeSelection( 13926 isSelected2 ? selection.filter( 13927 (itemId) => id !== itemId 13928 ) : [...selection, id] 13929 ); 13930 } 13931 }, 13932 children: [ 13933 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 13934 ItemClickWrapper, 13935 { 13936 item, 13937 isItemClickable, 13938 onClickItem, 13939 renderItemLink, 13940 className: clsx_default("dataviews-view-grid__media", { 13941 "dataviews-view-grid__media--placeholder": !rendersMediaField 13942 }), 13943 ...mediaA11yProps, 13944 children: renderedMediaField 13945 } 13946 ), 13947 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 13948 DataViewsSelectionCheckbox, 13949 { 13950 item, 13951 selection, 13952 onChangeSelection, 13953 getItemId, 13954 titleField, 13955 disabled: !hasBulkAction 13956 } 13957 ), 13958 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 13959 ItemActions, 13960 { 13961 item, 13962 actions: actions2, 13963 isCompact: true 13964 } 13965 ) }), 13966 showTitle && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 13967 ItemClickWrapper, 13968 { 13969 item, 13970 isItemClickable, 13971 onClickItem, 13972 renderItemLink, 13973 className: "dataviews-view-grid__title-field dataviews-title-field", 13974 ...titleA11yProps, 13975 title: titleField?.getValueFormatted({ 13976 item, 13977 field: titleField 13978 }) || void 0, 13979 children: renderedTitleField 13980 } 13981 ) }), 13982 /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(Stack, { direction: "column", gap: "xs", children: [ 13983 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 13984 descriptionField.render, 13985 { 13986 item, 13987 field: descriptionField 13988 } 13989 ), 13990 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 13991 Stack, 13992 { 13993 direction: "row", 13994 className: "dataviews-view-grid__badge-fields", 13995 gap: "sm", 13996 wrap: "wrap", 13997 align: "top", 13998 justify: "flex-start", 13999 children: badgeFields.map((field) => { 14000 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14001 WCBadge, 14002 { 14003 className: "dataviews-view-grid__field-value", 14004 children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14005 field.render, 14006 { 14007 item, 14008 field 14009 } 14010 ) 14011 }, 14012 field.id 14013 ); 14014 }) 14015 } 14016 ), 14017 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14018 Stack, 14019 { 14020 direction: "column", 14021 className: "dataviews-view-grid__fields", 14022 gap: "xs", 14023 children: regularFields.map((field) => { 14024 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14025 import_components10.Flex, 14026 { 14027 className: "dataviews-view-grid__field", 14028 gap: 1, 14029 justify: "flex-start", 14030 expanded: true, 14031 style: { height: "auto" }, 14032 direction: "row", 14033 children: /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [ 14034 /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(tooltip_exports.Root, { children: [ 14035 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14036 tooltip_exports.Trigger, 14037 { 14038 render: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_components10.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) 14039 } 14040 ), 14041 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(tooltip_exports.Popup, { children: field.label }) 14042 ] }), 14043 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14044 import_components10.FlexItem, 14045 { 14046 className: "dataviews-view-grid__field-value", 14047 style: { maxHeight: "none" }, 14048 children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14049 field.render, 14050 { 14051 item, 14052 field 14053 } 14054 ) 14055 } 14056 ) 14057 ] }) 14058 }, 14059 field.id 14060 ); 14061 }) 14062 } 14063 ) 14064 ] }) 14065 ] 14066 } 14067 ); 14068 } 14069 ); 14070 function CompositeGrid({ 14071 data, 14072 isInfiniteScroll, 14073 className, 14074 inert, 14075 isLoading, 14076 view, 14077 fields: fields2, 14078 selection, 14079 onChangeSelection, 14080 onClickItem, 14081 isItemClickable, 14082 renderItemLink, 14083 getItemId, 14084 actions: actions2 14085 }) { 14086 const { paginationInfo, resizeObserverRef } = (0, import_element44.useContext)(dataviews_context_default); 14087 const gridColumns = useGridColumns(); 14088 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data); 14089 const titleField = fields2.find( 14090 (field) => field.id === view?.titleField 14091 ); 14092 const mediaField = fields2.find( 14093 (field) => field.id === view?.mediaField 14094 ); 14095 const descriptionField = fields2.find( 14096 (field) => field.id === view?.descriptionField 14097 ); 14098 const otherFields = view.fields ?? []; 14099 const { regularFields, badgeFields } = otherFields.reduce( 14100 (accumulator, fieldId) => { 14101 const field = fields2.find((f2) => f2.id === fieldId); 14102 if (!field) { 14103 return accumulator; 14104 } 14105 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 14106 accumulator[key].push(field); 14107 return accumulator; 14108 }, 14109 { regularFields: [], badgeFields: [] } 14110 ); 14111 const size4 = "900px"; 14112 const totalRows = Math.ceil(data.length / gridColumns); 14113 const placeholdersNeeded = usePlaceholdersNeeded( 14114 data, 14115 isInfiniteScroll, 14116 gridColumns 14117 ); 14118 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { 14119 // Render infinite scroll layout (no rows, feed semantics) 14120 children: [ 14121 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)( 14122 import_components10.Composite, 14123 { 14124 render: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14125 GridItems, 14126 { 14127 className: clsx_default( 14128 "dataviews-view-grid-infinite-scroll", 14129 className, 14130 { 14131 [`has-$view.layout?.density}-density`]: view.layout?.density && [ 14132 "compact", 14133 "comfortable" 14134 ].includes(view.layout.density) 14135 } 14136 ), 14137 previewSize: view.layout?.previewSize, 14138 "aria-busy": isLoading, 14139 ref: resizeObserverRef 14140 } 14141 ), 14142 role: "feed", 14143 focusWrap: true, 14144 inert, 14145 children: [ 14146 Array.from({ length: placeholdersNeeded }).map( 14147 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14148 import_components10.Composite.Item, 14149 { 14150 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14151 Stack, 14152 { 14153 ...props, 14154 direction: "column", 14155 role: "article", 14156 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder" 14157 } 14158 ), 14159 "aria-hidden": true, 14160 tabIndex: -1 14161 }, 14162 `placeholder-$index2}` 14163 ) 14164 ), 14165 data.map((item) => { 14166 const itemId = getItemId(item); 14167 const stablePosition = item.position; 14168 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14169 import_components10.Composite.Item, 14170 { 14171 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14172 GridItem, 14173 { 14174 ...props, 14175 id: itemId, 14176 role: "article", 14177 view, 14178 selection, 14179 onChangeSelection, 14180 onClickItem, 14181 isItemClickable, 14182 renderItemLink, 14183 getItemId, 14184 item, 14185 actions: actions2, 14186 mediaField, 14187 titleField, 14188 descriptionField, 14189 regularFields, 14190 badgeFields, 14191 hasBulkActions, 14192 posinset: stablePosition, 14193 setsize: paginationInfo.totalItems, 14194 config: { 14195 sizes: size4 14196 } 14197 } 14198 ) 14199 }, 14200 itemId 14201 ); 14202 }) 14203 ] 14204 } 14205 ), 14206 // Render standard grid layout (with rows, grid semantics) 14207 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14208 import_components10.Composite, 14209 { 14210 role: "grid", 14211 className: clsx_default("dataviews-view-grid", className, { 14212 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 14213 view.layout.density 14214 ) 14215 }), 14216 focusWrap: true, 14217 "aria-busy": isLoading, 14218 "aria-rowcount": totalRows, 14219 ref: resizeObserverRef, 14220 inert, 14221 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14222 import_components10.Composite.Row, 14223 { 14224 render: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14225 "div", 14226 { 14227 role: "row", 14228 "aria-rowindex": i2 + 1, 14229 "aria-label": (0, import_i18n11.sprintf)( 14230 /* translators: %d: The row number in the grid */ 14231 (0, import_i18n11.__)("Row %d"), 14232 i2 + 1 14233 ), 14234 className: "dataviews-view-grid__row", 14235 style: { 14236 gridTemplateColumns: `repeat( $gridColumns}, minmax(0, 1fr) )` 14237 } 14238 } 14239 ), 14240 children: row.map((item) => { 14241 const itemId = getItemId(item); 14242 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14243 import_components10.Composite.Item, 14244 { 14245 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14246 GridItem, 14247 { 14248 ...props, 14249 id: itemId, 14250 role: "gridcell", 14251 view, 14252 selection, 14253 onChangeSelection, 14254 onClickItem, 14255 isItemClickable, 14256 renderItemLink, 14257 getItemId, 14258 item, 14259 actions: actions2, 14260 mediaField, 14261 titleField, 14262 descriptionField, 14263 regularFields, 14264 badgeFields, 14265 hasBulkActions, 14266 config: { 14267 sizes: size4 14268 } 14269 } 14270 ) 14271 }, 14272 itemId 14273 ); 14274 }) 14275 }, 14276 i2 14277 )) 14278 } 14279 ) 14280 ] 14281 }); 14282 } 14283 14284 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs 14285 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1); 14286 function ViewGrid({ 14287 actions: actions2, 14288 data, 14289 fields: fields2, 14290 getItemId, 14291 isLoading, 14292 onChangeSelection, 14293 onClickItem, 14294 isItemClickable, 14295 renderItemLink, 14296 selection, 14297 view, 14298 className, 14299 empty 14300 }) { 14301 const isDelayedLoading = useDelayedLoading(!!isLoading); 14302 const hasData = !!data?.length; 14303 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null; 14304 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 14305 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 14306 if (!hasData) { 14307 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 14308 "div", 14309 { 14310 className: clsx_default("dataviews-no-results", { 14311 "is-refreshing": isDelayedLoading 14312 }), 14313 children: empty 14314 } 14315 ); 14316 } 14317 const gridProps = { 14318 className: clsx_default(className, { 14319 "is-refreshing": !isInfiniteScroll && isDelayedLoading 14320 }), 14321 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0, 14322 isLoading, 14323 view, 14324 fields: fields2, 14325 selection, 14326 onChangeSelection, 14327 onClickItem, 14328 isItemClickable, 14329 renderItemLink, 14330 getItemId, 14331 actions: actions2 14332 }; 14333 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { 14334 // Render multiple groups. 14335 children: [ 14336 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map( 14337 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)( 14338 Stack, 14339 { 14340 direction: "column", 14341 gap: "sm", 14342 children: [ 14343 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)( 14344 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 14345 (0, import_i18n12.__)("%1$s: %2$s"), 14346 groupField.label, 14347 groupName 14348 ) }), 14349 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 14350 CompositeGrid, 14351 { 14352 ...gridProps, 14353 data: groupItems, 14354 isInfiniteScroll: false 14355 } 14356 ) 14357 ] 14358 }, 14359 groupName 14360 ) 14361 ) }), 14362 // Render a single grid with all data. 14363 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 14364 CompositeGrid, 14365 { 14366 ...gridProps, 14367 data, 14368 isInfiniteScroll: !!isInfiniteScroll 14369 } 14370 ), 14371 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_components11.Spinner, {}) }) 14372 ] 14373 }); 14374 } 14375 var grid_default = ViewGrid; 14376 14377 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs 14378 var import_compose4 = __toESM(require_compose(), 1); 14379 var import_components12 = __toESM(require_components(), 1); 14380 var import_element45 = __toESM(require_element(), 1); 14381 var import_i18n13 = __toESM(require_i18n(), 1); 14382 var import_data3 = __toESM(require_data(), 1); 14383 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1); 14384 var { Menu: Menu3 } = unlock2(import_components12.privateApis); 14385 function generateItemWrapperCompositeId(idPrefix) { 14386 return `$idPrefix}-item-wrapper`; 14387 } 14388 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) { 14389 return `$idPrefix}-primary-action-$primaryActionId}`; 14390 } 14391 function generateDropdownTriggerCompositeId(idPrefix) { 14392 return `$idPrefix}-dropdown`; 14393 } 14394 function PrimaryActionGridCell({ 14395 idPrefix, 14396 primaryAction, 14397 item 14398 }) { 14399 const registry = (0, import_data3.useRegistry)(); 14400 const [isModalOpen, setIsModalOpen] = (0, import_element45.useState)(false); 14401 const compositeItemId = generatePrimaryActionCompositeId( 14402 idPrefix, 14403 primaryAction.id 14404 ); 14405 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]); 14406 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14407 import_components12.Composite.Item, 14408 { 14409 id: compositeItemId, 14410 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14411 import_components12.Button, 14412 { 14413 disabled: !!primaryAction.disabled, 14414 accessibleWhenDisabled: true, 14415 text: label, 14416 size: "small", 14417 onClick: () => setIsModalOpen(true) 14418 } 14419 ), 14420 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14421 ActionModal, 14422 { 14423 action: primaryAction, 14424 items: [item], 14425 closeModal: () => setIsModalOpen(false) 14426 } 14427 ) 14428 } 14429 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14430 import_components12.Composite.Item, 14431 { 14432 id: compositeItemId, 14433 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14434 import_components12.Button, 14435 { 14436 disabled: !!primaryAction.disabled, 14437 accessibleWhenDisabled: true, 14438 size: "small", 14439 onClick: () => { 14440 primaryAction.callback([item], { registry }); 14441 }, 14442 children: label 14443 } 14444 ) 14445 } 14446 ) }, primaryAction.id); 14447 } 14448 function ListItem({ 14449 view, 14450 actions: actions2, 14451 idPrefix, 14452 isSelected: isSelected2, 14453 item, 14454 titleField, 14455 mediaField, 14456 descriptionField, 14457 onSelect, 14458 otherFields, 14459 onDropdownTriggerKeyDown, 14460 posinset 14461 }) { 14462 const { 14463 showTitle = true, 14464 showMedia = true, 14465 showDescription = true, 14466 infiniteScrollEnabled 14467 } = view; 14468 const itemRef = (0, import_element45.useRef)(null); 14469 const labelId = `$idPrefix}-label`; 14470 const descriptionId = `$idPrefix}-description`; 14471 const registry = (0, import_data3.useRegistry)(); 14472 const [isHovered, setIsHovered] = (0, import_element45.useState)(false); 14473 const [activeModalAction, setActiveModalAction] = (0, import_element45.useState)( 14474 null 14475 ); 14476 const handleHover = ({ type }) => { 14477 const isHover = type === "mouseenter"; 14478 setIsHovered(isHover); 14479 }; 14480 const { paginationInfo } = (0, import_element45.useContext)(dataviews_context_default); 14481 (0, import_element45.useEffect)(() => { 14482 if (isSelected2) { 14483 itemRef.current?.scrollIntoView({ 14484 behavior: "auto", 14485 block: "nearest", 14486 inline: "nearest" 14487 }); 14488 } 14489 }, [isSelected2]); 14490 const { primaryAction, eligibleActions } = (0, import_element45.useMemo)(() => { 14491 const _eligibleActions = actions2.filter( 14492 (action) => !action.isEligible || action.isEligible(item) 14493 ); 14494 const _primaryActions = _eligibleActions.filter( 14495 (action) => action.isPrimary 14496 ); 14497 return { 14498 primaryAction: _primaryActions[0], 14499 eligibleActions: _eligibleActions 14500 }; 14501 }, [actions2, item]); 14502 const hasOnlyOnePrimaryAction = primaryAction && actions2.length === 1; 14503 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14504 mediaField.render, 14505 { 14506 item, 14507 field: mediaField, 14508 config: { sizes: "52px" } 14509 } 14510 ) }) : null; 14511 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(titleField.render, { item, field: titleField }) : null; 14512 const renderDescription = showDescription && descriptionField?.render; 14513 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length; 14514 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)( 14515 Stack, 14516 { 14517 direction: "row", 14518 gap: "md", 14519 className: "dataviews-view-list__item-actions", 14520 children: [ 14521 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14522 PrimaryActionGridCell, 14523 { 14524 idPrefix, 14525 primaryAction, 14526 item 14527 } 14528 ), 14529 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { role: "gridcell", children: [ 14530 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Menu3, { placement: "bottom-end", children: [ 14531 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14532 Menu3.TriggerButton, 14533 { 14534 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14535 import_components12.Composite.Item, 14536 { 14537 id: generateDropdownTriggerCompositeId( 14538 idPrefix 14539 ), 14540 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14541 import_components12.Button, 14542 { 14543 size: "small", 14544 icon: more_vertical_default, 14545 label: (0, import_i18n13.__)("Actions"), 14546 accessibleWhenDisabled: true, 14547 disabled: !actions2.length, 14548 onKeyDown: onDropdownTriggerKeyDown 14549 } 14550 ) 14551 } 14552 ) 14553 } 14554 ), 14555 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14556 ActionsMenuGroup, 14557 { 14558 actions: eligibleActions, 14559 item, 14560 registry, 14561 setActiveModalAction 14562 } 14563 ) }) 14564 ] }), 14565 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14566 ActionModal, 14567 { 14568 action: activeModalAction, 14569 items: [item], 14570 closeModal: () => setActiveModalAction(null) 14571 } 14572 ) 14573 ] }) 14574 ] 14575 } 14576 ); 14577 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14578 import_components12.Composite.Row, 14579 { 14580 ref: itemRef, 14581 render: ( 14582 /* aria-posinset breaks Composite.Row if passed to it directly. */ 14583 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14584 "div", 14585 { 14586 "aria-posinset": posinset, 14587 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0 14588 } 14589 ) 14590 ), 14591 role: infiniteScrollEnabled ? "article" : "row", 14592 className: clsx_default({ 14593 "is-selected": isSelected2, 14594 "is-hovered": isHovered 14595 }), 14596 onMouseEnter: handleHover, 14597 onMouseLeave: handleHover, 14598 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)( 14599 Stack, 14600 { 14601 direction: "row", 14602 className: "dataviews-view-list__item-wrapper", 14603 children: [ 14604 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14605 import_components12.Composite.Item, 14606 { 14607 id: generateItemWrapperCompositeId(idPrefix), 14608 "aria-pressed": isSelected2, 14609 "aria-labelledby": labelId, 14610 "aria-describedby": descriptionId, 14611 className: "dataviews-view-list__item", 14612 onClick: () => onSelect(item) 14613 } 14614 ) }), 14615 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)( 14616 Stack, 14617 { 14618 direction: "row", 14619 gap: "md", 14620 justify: "start", 14621 align: hasOnlyMediaAndTitle ? "center" : "flex-start", 14622 style: { flex: 1, minWidth: 0 }, 14623 children: [ 14624 renderedMediaField, 14625 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)( 14626 Stack, 14627 { 14628 direction: "column", 14629 gap: "xs", 14630 className: "dataviews-view-list__field-wrapper", 14631 children: [ 14632 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Stack, { direction: "row", align: "center", children: [ 14633 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14634 "div", 14635 { 14636 className: "dataviews-title-field dataviews-view-list__title-field", 14637 id: labelId, 14638 children: renderedTitleField 14639 } 14640 ), 14641 usedActions 14642 ] }), 14643 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14644 descriptionField.render, 14645 { 14646 item, 14647 field: descriptionField 14648 } 14649 ) }), 14650 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14651 "div", 14652 { 14653 className: "dataviews-view-list__fields", 14654 id: descriptionId, 14655 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)( 14656 "div", 14657 { 14658 className: "dataviews-view-list__field", 14659 children: [ 14660 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14661 VisuallyHidden, 14662 { 14663 className: "dataviews-view-list__field-label", 14664 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", {}), 14665 children: field.label 14666 } 14667 ), 14668 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14669 field.render, 14670 { 14671 item, 14672 field 14673 } 14674 ) }) 14675 ] 14676 }, 14677 field.id 14678 )) 14679 } 14680 ) 14681 ] 14682 } 14683 ) 14684 ] 14685 } 14686 ) 14687 ] 14688 } 14689 ) 14690 } 14691 ); 14692 } 14693 function isDefined2(item) { 14694 return !!item; 14695 } 14696 function ViewList(props) { 14697 const { 14698 actions: actions2, 14699 data, 14700 fields: fields2, 14701 getItemId, 14702 isLoading, 14703 onChangeSelection, 14704 selection, 14705 view, 14706 className, 14707 empty 14708 } = props; 14709 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list"); 14710 const isDelayedLoading = useDelayedLoading(!!isLoading); 14711 const selectedItem = data?.findLast( 14712 (item) => selection.includes(getItemId(item)) 14713 ); 14714 const titleField = fields2.find((field) => field.id === view.titleField); 14715 const mediaField = fields2.find((field) => field.id === view.mediaField); 14716 const descriptionField = fields2.find( 14717 (field) => field.id === view.descriptionField 14718 ); 14719 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined2); 14720 const onSelect = (item) => onChangeSelection([getItemId(item)]); 14721 const generateCompositeItemIdPrefix = (0, import_element45.useCallback)( 14722 (item) => `$baseId}-$getItemId(item)}`, 14723 [baseId, getItemId] 14724 ); 14725 const isActiveCompositeItem = (0, import_element45.useCallback)( 14726 (item, idToCheck) => { 14727 return idToCheck.startsWith( 14728 generateCompositeItemIdPrefix(item) 14729 ); 14730 }, 14731 [generateCompositeItemIdPrefix] 14732 ); 14733 const [activeCompositeId, setActiveCompositeId] = (0, import_element45.useState)(void 0); 14734 const compositeRef = (0, import_element45.useRef)(null); 14735 (0, import_element45.useEffect)(() => { 14736 if (selectedItem) { 14737 setActiveCompositeId( 14738 generateItemWrapperCompositeId( 14739 generateCompositeItemIdPrefix(selectedItem) 14740 ) 14741 ); 14742 } 14743 }, [selectedItem, generateCompositeItemIdPrefix]); 14744 const activeItemIndex = data.findIndex( 14745 (item) => isActiveCompositeItem(item, activeCompositeId ?? "") 14746 ); 14747 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex); 14748 const isActiveIdInList = activeItemIndex !== -1; 14749 const selectCompositeItem = (0, import_element45.useCallback)( 14750 (targetIndex, generateCompositeId) => { 14751 const clampedIndex = Math.min( 14752 data.length - 1, 14753 Math.max(0, targetIndex) 14754 ); 14755 if (!data[clampedIndex]) { 14756 return; 14757 } 14758 const itemIdPrefix = generateCompositeItemIdPrefix( 14759 data[clampedIndex] 14760 ); 14761 const targetCompositeItemId = generateCompositeId(itemIdPrefix); 14762 setActiveCompositeId(targetCompositeItemId); 14763 if (compositeRef.current?.contains( 14764 compositeRef.current.ownerDocument.activeElement 14765 )) { 14766 document.getElementById(targetCompositeItemId)?.focus(); 14767 } 14768 }, 14769 [data, generateCompositeItemIdPrefix] 14770 ); 14771 (0, import_element45.useEffect)(() => { 14772 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1; 14773 if (!isActiveIdInList && wasActiveIdInList) { 14774 selectCompositeItem( 14775 previousActiveItemIndex, 14776 generateItemWrapperCompositeId 14777 ); 14778 } 14779 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]); 14780 const onDropdownTriggerKeyDown = (0, import_element45.useCallback)( 14781 (event) => { 14782 if (event.key === "ArrowDown") { 14783 event.preventDefault(); 14784 selectCompositeItem( 14785 activeItemIndex + 1, 14786 generateDropdownTriggerCompositeId 14787 ); 14788 } 14789 if (event.key === "ArrowUp") { 14790 event.preventDefault(); 14791 selectCompositeItem( 14792 activeItemIndex - 1, 14793 generateDropdownTriggerCompositeId 14794 ); 14795 } 14796 }, 14797 [selectCompositeItem, activeItemIndex] 14798 ); 14799 const hasData = !!data?.length; 14800 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null; 14801 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null; 14802 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 14803 if (!hasData) { 14804 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14805 "div", 14806 { 14807 className: clsx_default("dataviews-no-results", { 14808 "is-refreshing": isDelayedLoading 14809 }), 14810 children: empty 14811 } 14812 ); 14813 } 14814 if (hasData && groupField && dataByGroup) { 14815 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14816 import_components12.Composite, 14817 { 14818 ref: compositeRef, 14819 id: `$baseId}`, 14820 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", {}), 14821 className: "dataviews-view-list__group", 14822 role: "grid", 14823 activeId: activeCompositeId, 14824 setActiveId: setActiveCompositeId, 14825 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14826 Stack, 14827 { 14828 direction: "column", 14829 gap: "lg", 14830 className: clsx_default("dataviews-view-list", className), 14831 children: Array.from(dataByGroup.entries()).map( 14832 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)( 14833 Stack, 14834 { 14835 direction: "column", 14836 gap: "sm", 14837 children: [ 14838 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)( 14839 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 14840 (0, import_i18n13.__)("%1$s: %2$s"), 14841 groupField.label, 14842 groupName 14843 ) }), 14844 groupItems.map((item) => { 14845 const id = generateCompositeItemIdPrefix(item); 14846 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14847 ListItem, 14848 { 14849 view, 14850 idPrefix: id, 14851 actions: actions2, 14852 item, 14853 isSelected: item === selectedItem, 14854 onSelect, 14855 mediaField, 14856 titleField, 14857 descriptionField, 14858 otherFields, 14859 onDropdownTriggerKeyDown 14860 }, 14861 id 14862 ); 14863 }) 14864 ] 14865 }, 14866 groupName 14867 ) 14868 ) 14869 } 14870 ) 14871 } 14872 ); 14873 } 14874 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [ 14875 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14876 import_components12.Composite, 14877 { 14878 ref: compositeRef, 14879 id: baseId, 14880 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", {}), 14881 className: clsx_default("dataviews-view-list", className, { 14882 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 14883 view.layout.density 14884 ), 14885 "is-refreshing": !isInfiniteScroll && isDelayedLoading 14886 }), 14887 role: view.infiniteScrollEnabled ? "feed" : "grid", 14888 activeId: activeCompositeId, 14889 setActiveId: setActiveCompositeId, 14890 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0, 14891 children: data.map((item, index2) => { 14892 const id = generateCompositeItemIdPrefix(item); 14893 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 14894 ListItem, 14895 { 14896 view, 14897 idPrefix: id, 14898 actions: actions2, 14899 item, 14900 isSelected: item === selectedItem, 14901 onSelect, 14902 mediaField, 14903 titleField, 14904 descriptionField, 14905 otherFields, 14906 onDropdownTriggerKeyDown, 14907 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0 14908 }, 14909 id 14910 ); 14911 }) 14912 } 14913 ), 14914 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components12.Spinner, {}) }) 14915 ] }); 14916 } 14917 14918 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs 14919 var import_components13 = __toESM(require_components(), 1); 14920 14921 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs 14922 var import_i18n14 = __toESM(require_i18n(), 1); 14923 var import_element46 = __toESM(require_element(), 1); 14924 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1); 14925 function ActivityGroup({ 14926 groupName, 14927 groupData, 14928 groupField, 14929 showLabel = true, 14930 children 14931 }) { 14932 const groupHeader = showLabel ? (0, import_element46.createInterpolateElement)( 14933 // translators: %s: The label of the field e.g. "Status". 14934 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(), 14935 { 14936 groupName: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 14937 groupField.render, 14938 { 14939 item: groupData[0], 14940 field: groupField 14941 } 14942 ) 14943 } 14944 ) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(groupField.render, { item: groupData[0], field: groupField }); 14945 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)( 14946 Stack, 14947 { 14948 direction: "column", 14949 className: "dataviews-view-activity__group", 14950 children: [ 14951 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }), 14952 children 14953 ] 14954 }, 14955 groupName 14956 ); 14957 } 14958 14959 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs 14960 var import_element47 = __toESM(require_element(), 1); 14961 var import_data4 = __toESM(require_data(), 1); 14962 var import_compose5 = __toESM(require_compose(), 1); 14963 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1); 14964 function ActivityItem(props) { 14965 const { 14966 view, 14967 actions: actions2, 14968 item, 14969 titleField, 14970 mediaField, 14971 descriptionField, 14972 otherFields, 14973 posinset, 14974 onClickItem, 14975 renderItemLink, 14976 isItemClickable 14977 } = props; 14978 const { 14979 showTitle = true, 14980 showMedia = true, 14981 showDescription = true, 14982 infiniteScrollEnabled 14983 } = view; 14984 const itemRef = (0, import_element47.useRef)(null); 14985 const registry = (0, import_data4.useRegistry)(); 14986 const { paginationInfo } = (0, import_element47.useContext)(dataviews_context_default); 14987 const { primaryActions, eligibleActions } = (0, import_element47.useMemo)(() => { 14988 const _eligibleActions = actions2.filter( 14989 (action) => !action.isEligible || action.isEligible(item) 14990 ); 14991 const _primaryActions = _eligibleActions.filter( 14992 (action) => action.isPrimary 14993 ); 14994 return { 14995 primaryActions: _primaryActions, 14996 eligibleActions: _eligibleActions 14997 }; 14998 }, [actions2, item]); 14999 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<"); 15000 const density = view.layout?.density ?? "balanced"; 15001 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15002 mediaField.render, 15003 { 15004 item, 15005 field: mediaField, 15006 config: { 15007 sizes: density === "comfortable" ? "32px" : "24px" 15008 } 15009 } 15010 ) : null; 15011 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15012 "span", 15013 { 15014 className: "dataviews-view-activity__item-bullet", 15015 "aria-hidden": "true" 15016 } 15017 ) }); 15018 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(titleField.render, { item, field: titleField }) : null; 15019 const verticalGap = (0, import_element47.useMemo)(() => { 15020 switch (density) { 15021 case "comfortable": 15022 return "md"; 15023 default: 15024 return "sm"; 15025 } 15026 }, [density]); 15027 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15028 "div", 15029 { 15030 ref: itemRef, 15031 role: infiniteScrollEnabled ? "article" : void 0, 15032 "aria-posinset": posinset, 15033 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 15034 className: clsx_default( 15035 "dataviews-view-activity__item", 15036 density === "compact" && "is-compact", 15037 density === "balanced" && "is-balanced", 15038 density === "comfortable" && "is-comfortable" 15039 ), 15040 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [ 15041 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15042 Stack, 15043 { 15044 direction: "column", 15045 gap: "xs", 15046 align: "center", 15047 className: "dataviews-view-activity__item-type", 15048 children: renderedMediaField 15049 } 15050 ), 15051 /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)( 15052 Stack, 15053 { 15054 direction: "column", 15055 gap: verticalGap, 15056 align: "flex-start", 15057 className: "dataviews-view-activity__item-content", 15058 children: [ 15059 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15060 ItemClickWrapper, 15061 { 15062 item, 15063 isItemClickable, 15064 onClickItem, 15065 renderItemLink, 15066 className: "dataviews-view-activity__item-title", 15067 children: renderedTitleField 15068 } 15069 ), 15070 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15071 descriptionField.render, 15072 { 15073 item, 15074 field: descriptionField 15075 } 15076 ) }), 15077 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)( 15078 "div", 15079 { 15080 className: "dataviews-view-activity__item-field", 15081 children: [ 15082 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15083 VisuallyHidden, 15084 { 15085 className: "dataviews-view-activity__item-field-label", 15086 render: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", {}), 15087 children: field.label 15088 } 15089 ), 15090 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15091 field.render, 15092 { 15093 item, 15094 field 15095 } 15096 ) }) 15097 ] 15098 }, 15099 field.id 15100 )) }), 15101 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15102 PrimaryActions, 15103 { 15104 item, 15105 actions: primaryActions, 15106 registry, 15107 buttonVariant: "secondary" 15108 } 15109 ) 15110 ] 15111 } 15112 ), 15113 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu 15114 // there if there are any actions at all. 15115 isMobileViewport && // At the same time, only show the menu if there are actions to show. 15116 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15117 ItemActions, 15118 { 15119 item, 15120 actions: eligibleActions, 15121 isCompact: true 15122 } 15123 ) }) 15124 ] }) 15125 } 15126 ); 15127 } 15128 var activity_item_default = ActivityItem; 15129 15130 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs 15131 var import_react11 = __toESM(require_react(), 1); 15132 function isDefined3(item) { 15133 return !!item; 15134 } 15135 function ActivityItems(props) { 15136 const { data, fields: fields2, getItemId, view } = props; 15137 const titleField = fields2.find((field) => field.id === view.titleField); 15138 const mediaField = fields2.find((field) => field.id === view.mediaField); 15139 const descriptionField = fields2.find( 15140 (field) => field.id === view.descriptionField 15141 ); 15142 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined3); 15143 return data.map((item, index2) => { 15144 return /* @__PURE__ */ (0, import_react11.createElement)( 15145 activity_item_default, 15146 { 15147 ...props, 15148 key: getItemId(item), 15149 item, 15150 mediaField, 15151 titleField, 15152 descriptionField, 15153 otherFields, 15154 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0 15155 } 15156 ); 15157 }); 15158 } 15159 15160 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs 15161 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1); 15162 function ViewActivity(props) { 15163 const { empty, data, fields: fields2, isLoading, view, className } = props; 15164 const isDelayedLoading = useDelayedLoading(!!isLoading); 15165 const hasData = !!data?.length; 15166 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null; 15167 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null; 15168 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 15169 if (!hasData) { 15170 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 15171 "div", 15172 { 15173 className: clsx_default("dataviews-no-results", { 15174 "is-refreshing": isDelayedLoading 15175 }), 15176 children: empty 15177 } 15178 ); 15179 } 15180 const isInert = !isInfiniteScroll && !!isLoading; 15181 const wrapperClassName = clsx_default("dataviews-view-activity", className, { 15182 "is-refreshing": !isInfiniteScroll && isDelayedLoading 15183 }); 15184 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : []; 15185 if (hasData && groupField && dataByGroup) { 15186 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 15187 Stack, 15188 { 15189 direction: "column", 15190 gap: "sm", 15191 className: wrapperClassName, 15192 inert: isInert ? "true" : void 0, 15193 children: groupedEntries.map( 15194 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 15195 ActivityGroup, 15196 { 15197 groupName, 15198 groupData, 15199 groupField, 15200 showLabel: view.groupBy?.showLabel !== false, 15201 children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 15202 ActivityItems, 15203 { 15204 ...props, 15205 data: groupData 15206 } 15207 ) 15208 }, 15209 groupName 15210 ) 15211 ) 15212 } 15213 ); 15214 } 15215 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_jsx_runtime74.Fragment, { children: [ 15216 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 15217 "div", 15218 { 15219 className: wrapperClassName, 15220 role: view.infiniteScrollEnabled ? "feed" : void 0, 15221 inert: isInert ? "true" : void 0, 15222 children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(ActivityItems, { ...props }) 15223 } 15224 ), 15225 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components13.Spinner, {}) }) 15226 ] }); 15227 } 15228 15229 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs 15230 var import_components16 = __toESM(require_components(), 1); 15231 var import_i18n17 = __toESM(require_i18n(), 1); 15232 var import_compose6 = __toESM(require_compose(), 1); 15233 var import_element50 = __toESM(require_element(), 1); 15234 15235 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs 15236 var import_components15 = __toESM(require_components(), 1); 15237 var import_data5 = __toESM(require_data(), 1); 15238 var import_element49 = __toESM(require_element(), 1); 15239 var import_i18n16 = __toESM(require_i18n(), 1); 15240 15241 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs 15242 var import_components14 = __toESM(require_components(), 1); 15243 var import_element48 = __toESM(require_element(), 1); 15244 var import_i18n15 = __toESM(require_i18n(), 1); 15245 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1); 15246 function DataViewsPagination() { 15247 const { 15248 view, 15249 onChangeView, 15250 paginationInfo: { totalItems = 0, totalPages } 15251 } = (0, import_element48.useContext)(dataviews_context_default); 15252 if (!totalItems || !totalPages || view.infiniteScrollEnabled) { 15253 return null; 15254 } 15255 const currentPage = view.page ?? 1; 15256 const pageSelectOptions = Array.from(Array(totalPages)).map( 15257 (_, i2) => { 15258 const page = i2 + 1; 15259 return { 15260 value: page.toString(), 15261 label: page.toString(), 15262 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)( 15263 // translators: 1: current page number. 2: total number of pages. 15264 (0, import_i18n15.__)("Page %1$d of %2$d"), 15265 currentPage, 15266 totalPages 15267 ) : page.toString() 15268 }; 15269 } 15270 ); 15271 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)( 15272 Stack, 15273 { 15274 direction: "row", 15275 className: "dataviews-pagination", 15276 justify: "end", 15277 align: "center", 15278 gap: "xl", 15279 children: [ 15280 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 15281 Stack, 15282 { 15283 direction: "row", 15284 justify: "flex-start", 15285 align: "center", 15286 gap: "xs", 15287 className: "dataviews-pagination__page-select", 15288 children: (0, import_element48.createInterpolateElement)( 15289 (0, import_i18n15.sprintf)( 15290 // translators: 1: Current page number, 2: Total number of pages. 15291 (0, import_i18n15._x)( 15292 "<div>Page</div>%1$s<div>of %2$d</div>", 15293 "paging" 15294 ), 15295 "<CurrentPage />", 15296 totalPages 15297 ), 15298 { 15299 div: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { "aria-hidden": true }), 15300 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string. 15301 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 15302 import_components14.SelectControl, 15303 { 15304 "aria-label": (0, import_i18n15.__)("Current page"), 15305 value: currentPage.toString(), 15306 options: pageSelectOptions, 15307 onChange: (newValue) => { 15308 onChangeView({ 15309 ...view, 15310 page: +newValue 15311 }); 15312 }, 15313 size: "small", 15314 variant: "minimal" 15315 } 15316 ) 15317 } 15318 ) 15319 } 15320 ), 15321 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [ 15322 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 15323 import_components14.Button, 15324 { 15325 onClick: () => onChangeView({ 15326 ...view, 15327 page: currentPage - 1 15328 }), 15329 disabled: currentPage === 1, 15330 accessibleWhenDisabled: true, 15331 label: (0, import_i18n15.__)("Previous page"), 15332 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default, 15333 showTooltip: true, 15334 size: "compact", 15335 tooltipPosition: "top" 15336 } 15337 ), 15338 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 15339 import_components14.Button, 15340 { 15341 onClick: () => onChangeView({ ...view, page: currentPage + 1 }), 15342 disabled: currentPage >= totalPages, 15343 accessibleWhenDisabled: true, 15344 label: (0, import_i18n15.__)("Next page"), 15345 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default, 15346 showTooltip: true, 15347 size: "compact", 15348 tooltipPosition: "top" 15349 } 15350 ) 15351 ] }) 15352 ] 15353 } 15354 ); 15355 } 15356 var dataviews_pagination_default = (0, import_element48.memo)(DataViewsPagination); 15357 15358 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs 15359 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1); 15360 function useIsMultiselectPicker(actions2) { 15361 return (0, import_element49.useMemo)(() => { 15362 return actions2?.every((action) => action.supportsBulk); 15363 }, [actions2]); 15364 } 15365 15366 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs 15367 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1); 15368 var { Badge: WCBadge2 } = unlock2(import_components16.privateApis); 15369 function GridItem3({ 15370 view, 15371 multiselect, 15372 selection, 15373 onChangeSelection, 15374 getItemId, 15375 item, 15376 mediaField, 15377 titleField, 15378 descriptionField, 15379 regularFields, 15380 badgeFields, 15381 config, 15382 posinset, 15383 setsize 15384 }) { 15385 const { showTitle = true, showMedia = true, showDescription = true } = view; 15386 const id = getItemId(item); 15387 const elementRef = (0, import_element50.useRef)(null); 15388 const isSelected2 = selection.includes(id); 15389 useIntersectionObserver(elementRef, posinset); 15390 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15391 mediaField.render, 15392 { 15393 item, 15394 field: mediaField, 15395 config 15396 } 15397 ) : null; 15398 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(titleField.render, { item, field: titleField }) : null; 15399 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)( 15400 import_components16.Composite.Item, 15401 { 15402 ref: elementRef, 15403 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0, 15404 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Stack, { direction: "column", children, ...props }), 15405 role: "option", 15406 "aria-posinset": posinset, 15407 "aria-setsize": setsize, 15408 className: clsx_default("dataviews-view-picker-grid__card", { 15409 "is-selected": isSelected2 15410 }), 15411 "aria-selected": isSelected2, 15412 onClick: () => { 15413 if (isSelected2) { 15414 onChangeSelection( 15415 selection.filter((itemId) => id !== itemId) 15416 ); 15417 } else { 15418 const newSelection = multiselect ? [...selection, id] : [id]; 15419 onChangeSelection(newSelection); 15420 } 15421 }, 15422 children: [ 15423 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }), 15424 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15425 DataViewsSelectionCheckbox, 15426 { 15427 item, 15428 selection, 15429 onChangeSelection, 15430 getItemId, 15431 titleField, 15432 disabled: false, 15433 "aria-hidden": true, 15434 tabIndex: -1 15435 } 15436 ), 15437 showTitle && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15438 Stack, 15439 { 15440 direction: "row", 15441 justify: "space-between", 15442 className: "dataviews-view-picker-grid__title-actions", 15443 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField }) 15444 } 15445 ), 15446 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "column", gap: "xs", children: [ 15447 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15448 descriptionField.render, 15449 { 15450 item, 15451 field: descriptionField 15452 } 15453 ), 15454 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15455 Stack, 15456 { 15457 direction: "row", 15458 className: "dataviews-view-picker-grid__badge-fields", 15459 gap: "sm", 15460 wrap: "wrap", 15461 align: "top", 15462 justify: "flex-start", 15463 children: badgeFields.map((field) => { 15464 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15465 WCBadge2, 15466 { 15467 className: "dataviews-view-picker-grid__field-value", 15468 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15469 field.render, 15470 { 15471 item, 15472 field 15473 } 15474 ) 15475 }, 15476 field.id 15477 ); 15478 }) 15479 } 15480 ), 15481 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15482 Stack, 15483 { 15484 direction: "column", 15485 className: "dataviews-view-picker-grid__fields", 15486 gap: "xs", 15487 children: regularFields.map((field) => { 15488 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15489 import_components16.Flex, 15490 { 15491 className: "dataviews-view-picker-grid__field", 15492 gap: 1, 15493 justify: "flex-start", 15494 expanded: true, 15495 style: { height: "auto" }, 15496 direction: "row", 15497 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [ 15498 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components16.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }), 15499 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15500 import_components16.FlexItem, 15501 { 15502 className: "dataviews-view-picker-grid__field-value", 15503 style: { maxHeight: "none" }, 15504 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15505 field.render, 15506 { 15507 item, 15508 field 15509 } 15510 ) 15511 } 15512 ) 15513 ] }) 15514 }, 15515 field.id 15516 ); 15517 }) 15518 } 15519 ) 15520 ] }) 15521 ] 15522 }, 15523 id 15524 ); 15525 } 15526 function GridGroup({ 15527 groupName, 15528 groupField, 15529 showLabel = true, 15530 children 15531 }) { 15532 const headerId = (0, import_compose6.useInstanceId)( 15533 GridGroup, 15534 "dataviews-view-picker-grid-group__header" 15535 ); 15536 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)( 15537 Stack, 15538 { 15539 direction: "column", 15540 gap: "sm", 15541 role: "group", 15542 "aria-labelledby": headerId, 15543 children: [ 15544 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15545 "h3", 15546 { 15547 className: "dataviews-view-picker-grid-group__header", 15548 id: headerId, 15549 children: showLabel ? (0, import_i18n17.sprintf)( 15550 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 15551 (0, import_i18n17.__)("%1$s: %2$s"), 15552 groupField.label, 15553 groupName 15554 ) : groupName 15555 } 15556 ), 15557 children 15558 ] 15559 }, 15560 groupName 15561 ); 15562 } 15563 function ViewPickerGrid({ 15564 actions: actions2, 15565 data, 15566 fields: fields2, 15567 getItemId, 15568 isLoading, 15569 onChangeSelection, 15570 selection, 15571 view, 15572 className, 15573 empty 15574 }) { 15575 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element50.useContext)(dataviews_context_default); 15576 const titleField = fields2.find( 15577 (field) => field.id === view?.titleField 15578 ); 15579 const mediaField = fields2.find( 15580 (field) => field.id === view?.mediaField 15581 ); 15582 const descriptionField = fields2.find( 15583 (field) => field.id === view?.descriptionField 15584 ); 15585 const otherFields = view.fields ?? []; 15586 const { regularFields, badgeFields } = otherFields.reduce( 15587 (accumulator, fieldId) => { 15588 const field = fields2.find((f2) => f2.id === fieldId); 15589 if (!field) { 15590 return accumulator; 15591 } 15592 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 15593 accumulator[key].push(field); 15594 return accumulator; 15595 }, 15596 { regularFields: [], badgeFields: [] } 15597 ); 15598 const hasData = !!data?.length; 15599 const usedPreviewSize = view.layout?.previewSize; 15600 const isMultiselect = useIsMultiselectPicker(actions2); 15601 const size4 = "900px"; 15602 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null; 15603 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 15604 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false; 15605 const currentPage = view?.page ?? 1; 15606 const perPage = view?.perPage ?? 0; 15607 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 15608 const gridColumns = useGridColumns(); 15609 const placeholdersNeeded = usePlaceholdersNeeded( 15610 data, 15611 isInfiniteScroll, 15612 gridColumns 15613 ); 15614 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { 15615 // Render multiple groups. 15616 children: [ 15617 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15618 import_components16.Composite, 15619 { 15620 virtualFocus: true, 15621 orientation: "horizontal", 15622 role: "listbox", 15623 "aria-multiselectable": isMultiselect, 15624 className: clsx_default( 15625 "dataviews-view-picker-grid", 15626 className, 15627 { 15628 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 15629 view.layout.density 15630 ) 15631 } 15632 ), 15633 "aria-label": itemListLabel, 15634 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15635 Stack, 15636 { 15637 direction: "column", 15638 gap: "lg", 15639 children, 15640 ...props 15641 } 15642 ), 15643 children: Array.from(dataByGroup.entries()).map( 15644 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15645 GridGroup, 15646 { 15647 groupName, 15648 groupField, 15649 showLabel: view.groupBy?.showLabel !== false, 15650 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15651 GridItems, 15652 { 15653 previewSize: usedPreviewSize, 15654 style: { 15655 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax($usedPreviewSize}px, 1fr))` 15656 }, 15657 "aria-busy": isLoading, 15658 ref: resizeObserverRef, 15659 children: groupItems.map((item) => { 15660 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1; 15661 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15662 GridItem3, 15663 { 15664 view, 15665 multiselect: isMultiselect, 15666 selection, 15667 onChangeSelection, 15668 getItemId, 15669 item, 15670 mediaField, 15671 titleField, 15672 descriptionField, 15673 regularFields, 15674 badgeFields, 15675 config: { 15676 sizes: size4 15677 }, 15678 posinset: posInSet, 15679 setsize: setSize 15680 }, 15681 getItemId(item) 15682 ); 15683 }) 15684 } 15685 ) 15686 }, 15687 groupName 15688 ) 15689 ) 15690 } 15691 ), 15692 // Render a single grid with all data. 15693 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)( 15694 import_components16.Composite, 15695 { 15696 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15697 GridItems, 15698 { 15699 className: clsx_default( 15700 "dataviews-view-picker-grid", 15701 className, 15702 { 15703 [`has-$view.layout?.density}-density`]: view.layout?.density && [ 15704 "compact", 15705 "comfortable" 15706 ].includes(view.layout.density) 15707 } 15708 ), 15709 previewSize: usedPreviewSize, 15710 "aria-busy": isLoading, 15711 ref: resizeObserverRef 15712 } 15713 ), 15714 virtualFocus: true, 15715 orientation: "horizontal", 15716 role: "listbox", 15717 "aria-multiselectable": isMultiselect, 15718 "aria-label": itemListLabel, 15719 children: [ 15720 Array.from({ length: placeholdersNeeded }).map( 15721 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15722 import_components16.Composite.Item, 15723 { 15724 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15725 Stack, 15726 { 15727 direction: "column", 15728 children, 15729 ...props 15730 } 15731 ), 15732 role: "option", 15733 "aria-hidden": true, 15734 tabIndex: -1, 15735 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder" 15736 }, 15737 `placeholder-$index2}` 15738 ) 15739 ), 15740 data.map((item) => { 15741 const posinset = item.position; 15742 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15743 GridItem3, 15744 { 15745 view, 15746 multiselect: isMultiselect, 15747 selection, 15748 onChangeSelection, 15749 getItemId, 15750 item, 15751 mediaField, 15752 titleField, 15753 descriptionField, 15754 regularFields, 15755 badgeFields, 15756 config: { 15757 sizes: size4 15758 }, 15759 posinset, 15760 setsize: setSize 15761 }, 15762 getItemId(item) 15763 ); 15764 }) 15765 ] 15766 } 15767 ), 15768 // Render empty state. 15769 !hasData && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15770 "div", 15771 { 15772 className: clsx_default({ 15773 "dataviews-loading": isLoading, 15774 "dataviews-no-results": !isLoading 15775 }), 15776 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components16.Spinner, {}) }) : empty 15777 } 15778 ), 15779 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components16.Spinner, {}) }) 15780 ] 15781 }); 15782 } 15783 var picker_grid_default = ViewPickerGrid; 15784 15785 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs 15786 var import_i18n18 = __toESM(require_i18n(), 1); 15787 var import_components17 = __toESM(require_components(), 1); 15788 var import_element51 = __toESM(require_element(), 1); 15789 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1); 15790 function TableColumnField2({ 15791 item, 15792 fields: fields2, 15793 column, 15794 align 15795 }) { 15796 const field = fields2.find((f2) => f2.id === column); 15797 if (!field) { 15798 return null; 15799 } 15800 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 15801 "dataviews-view-table__cell-align-end": align === "end", 15802 "dataviews-view-table__cell-align-center": align === "center" 15803 }); 15804 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(field.render, { item, field }) }); 15805 } 15806 function TableRow2({ 15807 item, 15808 fields: fields2, 15809 id, 15810 view, 15811 titleField, 15812 mediaField, 15813 descriptionField, 15814 selection, 15815 getItemId, 15816 onChangeSelection, 15817 multiselect, 15818 posinset 15819 }) { 15820 const { paginationInfo } = (0, import_element51.useContext)(dataviews_context_default); 15821 const isSelected2 = selection.includes(id); 15822 const [isHovered, setIsHovered] = (0, import_element51.useState)(false); 15823 const elementRef = (0, import_element51.useRef)(null); 15824 useIntersectionObserver(elementRef, posinset); 15825 const { 15826 showTitle = true, 15827 showMedia = true, 15828 showDescription = true, 15829 infiniteScrollEnabled 15830 } = view; 15831 const handleMouseEnter = () => { 15832 setIsHovered(true); 15833 }; 15834 const handleMouseLeave = () => { 15835 setIsHovered(false); 15836 }; 15837 const columns = view.fields ?? []; 15838 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 15839 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)( 15840 import_components17.Composite.Item, 15841 { 15842 ref: elementRef, 15843 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 15844 "tr", 15845 { 15846 className: clsx_default("dataviews-view-table__row", { 15847 "is-selected": isSelected2, 15848 "is-hovered": isHovered 15849 }), 15850 onMouseEnter: handleMouseEnter, 15851 onMouseLeave: handleMouseLeave, 15852 children, 15853 ...props 15854 } 15855 ), 15856 "aria-selected": isSelected2, 15857 "aria-setsize": paginationInfo.totalItems || void 0, 15858 "aria-posinset": posinset, 15859 role: infiniteScrollEnabled ? "article" : "option", 15860 onMouseDown: (event) => { 15861 if (event.button !== 0) { 15862 return; 15863 } 15864 event.currentTarget.parentElement?.focus({ 15865 preventScroll: true 15866 }); 15867 }, 15868 onClick: () => { 15869 if (isSelected2) { 15870 onChangeSelection( 15871 selection.filter((itemId) => id !== itemId) 15872 ); 15873 } else { 15874 const newSelection = multiselect ? [...selection, id] : [id]; 15875 onChangeSelection(newSelection); 15876 } 15877 }, 15878 children: [ 15879 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 15880 "td", 15881 { 15882 className: "dataviews-view-table__checkbox-column", 15883 role: "presentation", 15884 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 15885 DataViewsSelectionCheckbox, 15886 { 15887 item, 15888 selection, 15889 onChangeSelection, 15890 getItemId, 15891 titleField, 15892 disabled: false, 15893 "aria-hidden": true, 15894 tabIndex: -1 15895 } 15896 ) }) 15897 } 15898 ), 15899 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 15900 "td", 15901 { 15902 role: "presentation", 15903 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 15904 column_primary_default, 15905 { 15906 item, 15907 titleField: showTitle ? titleField : void 0, 15908 mediaField: showMedia ? mediaField : void 0, 15909 descriptionField: showDescription ? descriptionField : void 0, 15910 isItemClickable: () => false 15911 } 15912 ) 15913 } 15914 ), 15915 columns.map((column) => { 15916 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 15917 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 15918 "td", 15919 { 15920 style: { 15921 width, 15922 maxWidth, 15923 minWidth 15924 }, 15925 role: "presentation", 15926 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 15927 TableColumnField2, 15928 { 15929 fields: fields2, 15930 item, 15931 column, 15932 align 15933 } 15934 ) 15935 }, 15936 column 15937 ); 15938 }) 15939 ] 15940 }, 15941 id 15942 ); 15943 } 15944 function ViewPickerTable({ 15945 actions: actions2, 15946 data, 15947 fields: fields2, 15948 getItemId, 15949 isLoading = false, 15950 onChangeView, 15951 onChangeSelection, 15952 selection, 15953 setOpenedFilter, 15954 view, 15955 className, 15956 empty 15957 }) { 15958 const headerMenuRefs = (0, import_element51.useRef)(/* @__PURE__ */ new Map()); 15959 const headerMenuToFocusRef = (0, import_element51.useRef)(void 0); 15960 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element51.useState)(); 15961 const isMultiselect = useIsMultiselectPicker(actions2) ?? false; 15962 (0, import_element51.useEffect)(() => { 15963 if (headerMenuToFocusRef.current) { 15964 headerMenuToFocusRef.current.focus(); 15965 headerMenuToFocusRef.current = void 0; 15966 } 15967 }); 15968 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null; 15969 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 15970 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 15971 const tableNoticeId = (0, import_element51.useId)(); 15972 if (nextHeaderMenuToFocus) { 15973 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 15974 setNextHeaderMenuToFocus(void 0); 15975 return; 15976 } 15977 const onHide = (field) => { 15978 const hidden = headerMenuRefs.current.get(field.id); 15979 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 15980 setNextHeaderMenuToFocus(fallback?.node); 15981 }; 15982 const hasData = !!data?.length; 15983 const titleField = fields2.find((field) => field.id === view.titleField); 15984 const mediaField = fields2.find((field) => field.id === view.mediaField); 15985 const descriptionField = fields2.find( 15986 (field) => field.id === view.descriptionField 15987 ); 15988 const { showTitle = true, showMedia = true, showDescription = true } = view; 15989 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 15990 const columns = view.fields ?? []; 15991 const headerMenuRef = (column, index2) => (node) => { 15992 if (node) { 15993 headerMenuRefs.current.set(column, { 15994 node, 15995 fallback: columns[index2 > 0 ? index2 - 1 : 1] 15996 }); 15997 } else { 15998 headerMenuRefs.current.delete(column); 15999 } 16000 }; 16001 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(import_jsx_runtime78.Fragment, { children: [ 16002 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)( 16003 "table", 16004 { 16005 className: clsx_default( 16006 "dataviews-view-table", 16007 "dataviews-view-picker-table", 16008 className, 16009 { 16010 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 16011 view.layout.density 16012 ) 16013 } 16014 ), 16015 "aria-busy": isLoading, 16016 "aria-describedby": tableNoticeId, 16017 role: isInfiniteScroll ? "feed" : "listbox", 16018 children: [ 16019 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)( 16020 "tr", 16021 { 16022 className: "dataviews-view-table__row", 16023 role: "presentation", 16024 children: [ 16025 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16026 BulkSelectionCheckbox, 16027 { 16028 selection, 16029 onChangeSelection, 16030 data, 16031 actions: actions2, 16032 getItemId, 16033 disableSelectAll: isInfiniteScroll 16034 } 16035 ) }), 16036 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16037 column_header_menu_default, 16038 { 16039 ref: headerMenuRef( 16040 titleField.id, 16041 0 16042 ), 16043 fieldId: titleField.id, 16044 view, 16045 fields: fields2, 16046 onChangeView, 16047 onHide, 16048 setOpenedFilter, 16049 canMove: false 16050 } 16051 ) }), 16052 columns.map((column, index2) => { 16053 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 16054 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16055 "th", 16056 { 16057 style: { 16058 width, 16059 maxWidth, 16060 minWidth, 16061 textAlign: align 16062 }, 16063 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 16064 scope: "col", 16065 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16066 column_header_menu_default, 16067 { 16068 ref: headerMenuRef(column, index2), 16069 fieldId: column, 16070 view, 16071 fields: fields2, 16072 onChangeView, 16073 onHide, 16074 setOpenedFilter, 16075 canMove: view.layout?.enableMoving ?? true 16076 } 16077 ) 16078 }, 16079 column 16080 ); 16081 }) 16082 ] 16083 } 16084 ) }), 16085 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 16086 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)( 16087 import_components17.Composite, 16088 { 16089 virtualFocus: true, 16090 orientation: "vertical", 16091 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("tbody", { role: "group" }), 16092 children: [ 16093 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16094 "tr", 16095 { 16096 className: "dataviews-view-table__group-header-row", 16097 role: "presentation", 16098 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16099 "td", 16100 { 16101 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1, 16102 className: "dataviews-view-table__group-header-cell", 16103 role: "presentation", 16104 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)( 16105 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 16106 (0, import_i18n18.__)("%1$s: %2$s"), 16107 groupField.label, 16108 groupName 16109 ) 16110 } 16111 ) 16112 } 16113 ), 16114 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16115 TableRow2, 16116 { 16117 item, 16118 fields: fields2, 16119 id: getItemId(item) || index2.toString(), 16120 view, 16121 titleField, 16122 mediaField, 16123 descriptionField, 16124 selection, 16125 getItemId, 16126 onChangeSelection, 16127 multiselect: isMultiselect 16128 }, 16129 getItemId(item) 16130 )) 16131 ] 16132 }, 16133 `group-$groupName}` 16134 ) 16135 ) : /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16136 import_components17.Composite, 16137 { 16138 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("tbody", { role: "presentation" }), 16139 virtualFocus: true, 16140 orientation: "vertical", 16141 children: hasData && data.map((item, index2) => { 16142 const itemId = getItemId(item); 16143 const posinset = item.position; 16144 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16145 TableRow2, 16146 { 16147 item, 16148 fields: fields2, 16149 id: itemId || index2.toString(), 16150 view, 16151 titleField, 16152 mediaField, 16153 descriptionField, 16154 selection, 16155 getItemId, 16156 onChangeSelection, 16157 multiselect: isMultiselect, 16158 posinset 16159 }, 16160 itemId 16161 ); 16162 }) 16163 } 16164 ) 16165 ] 16166 } 16167 ), 16168 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)( 16169 "div", 16170 { 16171 className: clsx_default({ 16172 "dataviews-loading": isLoading, 16173 "dataviews-no-results": !hasData && !isLoading 16174 }), 16175 id: tableNoticeId, 16176 children: [ 16177 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components17.Spinner, {}) }) : empty), 16178 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components17.Spinner, {}) }) 16179 ] 16180 } 16181 ) 16182 ] }); 16183 } 16184 var picker_table_default = ViewPickerTable; 16185 16186 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs 16187 var import_components18 = __toESM(require_components(), 1); 16188 var import_i18n19 = __toESM(require_i18n(), 1); 16189 var import_element52 = __toESM(require_element(), 1); 16190 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1); 16191 function DensityPicker() { 16192 const context = (0, import_element52.useContext)(dataviews_context_default); 16193 const view = context.view; 16194 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)( 16195 import_components18.__experimentalToggleGroupControl, 16196 { 16197 size: "__unstable-large", 16198 label: (0, import_i18n19.__)("Density"), 16199 value: view.layout?.density || "balanced", 16200 onChange: (value) => { 16201 context.onChangeView({ 16202 ...view, 16203 layout: { 16204 ...view.layout, 16205 density: value 16206 } 16207 }); 16208 }, 16209 isBlock: true, 16210 children: [ 16211 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 16212 import_components18.__experimentalToggleGroupControlOption, 16213 { 16214 value: "comfortable", 16215 label: (0, import_i18n19._x)( 16216 "Comfortable", 16217 "Density option for DataView layout" 16218 ) 16219 }, 16220 "comfortable" 16221 ), 16222 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 16223 import_components18.__experimentalToggleGroupControlOption, 16224 { 16225 value: "balanced", 16226 label: (0, import_i18n19._x)("Balanced", "Density option for DataView layout") 16227 }, 16228 "balanced" 16229 ), 16230 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 16231 import_components18.__experimentalToggleGroupControlOption, 16232 { 16233 value: "compact", 16234 label: (0, import_i18n19._x)("Compact", "Density option for DataView layout") 16235 }, 16236 "compact" 16237 ) 16238 ] 16239 } 16240 ); 16241 } 16242 16243 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs 16244 var import_components19 = __toESM(require_components(), 1); 16245 var import_i18n20 = __toESM(require_i18n(), 1); 16246 var import_element53 = __toESM(require_element(), 1); 16247 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1); 16248 var imageSizes2 = [ 16249 { 16250 value: 120, 16251 breakpoint: 1 16252 }, 16253 { 16254 value: 170, 16255 breakpoint: 1 16256 }, 16257 { 16258 value: 230, 16259 breakpoint: 1 16260 }, 16261 { 16262 value: 290, 16263 breakpoint: 1112 16264 // at minimum image width, 4 images display at this container size 16265 }, 16266 { 16267 value: 350, 16268 breakpoint: 1636 16269 // at minimum image width, 6 images display at this container size 16270 }, 16271 { 16272 value: 430, 16273 breakpoint: 588 16274 // at minimum image width, 2 images display at this container size 16275 } 16276 ]; 16277 function PreviewSizePicker() { 16278 const context = (0, import_element53.useContext)(dataviews_context_default); 16279 const view = context.view; 16280 const breakValues = imageSizes2.filter((size4) => { 16281 return context.containerWidth >= size4.breakpoint; 16282 }); 16283 const layoutPreviewSize = view.layout?.previewSize ?? 230; 16284 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0; 16285 const marks = breakValues.map((size4, index2) => { 16286 return { 16287 value: index2 16288 }; 16289 }); 16290 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 16291 import_components19.RangeControl, 16292 { 16293 __next40pxDefaultSize: true, 16294 showTooltip: false, 16295 label: (0, import_i18n20.__)("Preview size"), 16296 value: previewSizeToUse, 16297 min: 0, 16298 max: breakValues.length - 1, 16299 withInputField: false, 16300 onChange: (value = 0) => { 16301 context.onChangeView({ 16302 ...view, 16303 layout: { 16304 ...view.layout, 16305 previewSize: breakValues[value].value 16306 } 16307 }); 16308 }, 16309 step: 1, 16310 marks 16311 } 16312 ); 16313 } 16314 16315 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs 16316 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1); 16317 function GridConfigOptions() { 16318 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [ 16319 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(DensityPicker, {}), 16320 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(PreviewSizePicker, {}) 16321 ] }); 16322 } 16323 16324 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs 16325 var VIEW_LAYOUTS = [ 16326 { 16327 type: LAYOUT_TABLE, 16328 label: (0, import_i18n21.__)("Table"), 16329 component: table_default, 16330 icon: block_table_default, 16331 viewConfigOptions: DensityPicker 16332 }, 16333 { 16334 type: LAYOUT_GRID, 16335 label: (0, import_i18n21.__)("Grid"), 16336 component: grid_default, 16337 icon: category_default, 16338 viewConfigOptions: GridConfigOptions 16339 }, 16340 { 16341 type: LAYOUT_LIST, 16342 label: (0, import_i18n21.__)("List"), 16343 component: ViewList, 16344 icon: (0, import_i18n21.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default, 16345 viewConfigOptions: DensityPicker 16346 }, 16347 { 16348 type: LAYOUT_ACTIVITY, 16349 label: (0, import_i18n21.__)("Activity"), 16350 component: ViewActivity, 16351 icon: scheduled_default, 16352 viewConfigOptions: DensityPicker 16353 }, 16354 { 16355 type: LAYOUT_PICKER_GRID, 16356 label: (0, import_i18n21.__)("Grid"), 16357 component: picker_grid_default, 16358 icon: category_default, 16359 viewConfigOptions: GridConfigOptions, 16360 isPicker: true 16361 }, 16362 { 16363 type: LAYOUT_PICKER_TABLE, 16364 label: (0, import_i18n21.__)("Table"), 16365 component: picker_table_default, 16366 icon: block_table_default, 16367 viewConfigOptions: DensityPicker, 16368 isPicker: true 16369 } 16370 ]; 16371 16372 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs 16373 var import_element61 = __toESM(require_element(), 1); 16374 16375 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs 16376 var import_components22 = __toESM(require_components(), 1); 16377 var import_i18n24 = __toESM(require_i18n(), 1); 16378 var import_element58 = __toESM(require_element(), 1); 16379 16380 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js 16381 function noop4(..._) { 16382 } 16383 function applyState(argument, currentValue) { 16384 if (isUpdater(argument)) { 16385 const value = isLazyValue(currentValue) ? currentValue() : currentValue; 16386 return argument(value); 16387 } 16388 return argument; 16389 } 16390 function isUpdater(argument) { 16391 return typeof argument === "function"; 16392 } 16393 function isLazyValue(value) { 16394 return typeof value === "function"; 16395 } 16396 function hasOwnProperty(object, prop) { 16397 if (typeof Object.hasOwn === "function") { 16398 return Object.hasOwn(object, prop); 16399 } 16400 return Object.prototype.hasOwnProperty.call(object, prop); 16401 } 16402 function chain(...fns) { 16403 return (...args) => { 16404 for (const fn of fns) { 16405 if (typeof fn === "function") { 16406 fn(...args); 16407 } 16408 } 16409 }; 16410 } 16411 function normalizeString(str) { 16412 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); 16413 } 16414 function omit(object, keys) { 16415 const result = { ...object }; 16416 for (const key of keys) { 16417 if (hasOwnProperty(result, key)) { 16418 delete result[key]; 16419 } 16420 } 16421 return result; 16422 } 16423 function pick(object, paths) { 16424 const result = {}; 16425 for (const key of paths) { 16426 if (hasOwnProperty(object, key)) { 16427 result[key] = object[key]; 16428 } 16429 } 16430 return result; 16431 } 16432 function identity(value) { 16433 return value; 16434 } 16435 function invariant(condition, message2) { 16436 if (condition) return; 16437 if (typeof message2 !== "string") throw new Error("Invariant failed"); 16438 throw new Error(message2); 16439 } 16440 function getKeys(obj) { 16441 return Object.keys(obj); 16442 } 16443 function isFalsyBooleanCallback(booleanOrCallback, ...args) { 16444 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback; 16445 if (result == null) return false; 16446 return !result; 16447 } 16448 function disabledFromProps(props) { 16449 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true"; 16450 } 16451 function removeUndefinedValues(obj) { 16452 const result = {}; 16453 for (const key in obj) { 16454 if (obj[key] !== void 0) { 16455 result[key] = obj[key]; 16456 } 16457 } 16458 return result; 16459 } 16460 function defaultValue(...values) { 16461 for (const value of values) { 16462 if (value !== void 0) return value; 16463 } 16464 return void 0; 16465 } 16466 16467 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js 16468 var import_react12 = __toESM(require_react(), 1); 16469 function setRef(ref, value) { 16470 if (typeof ref === "function") { 16471 ref(value); 16472 } else if (ref) { 16473 ref.current = value; 16474 } 16475 } 16476 function isValidElementWithRef(element) { 16477 if (!element) return false; 16478 if (!(0, import_react12.isValidElement)(element)) return false; 16479 if ("ref" in element.props) return true; 16480 if ("ref" in element) return true; 16481 return false; 16482 } 16483 function getRefProperty(element) { 16484 if (!isValidElementWithRef(element)) return null; 16485 const props = { ...element.props }; 16486 return props.ref || element.ref; 16487 } 16488 function mergeProps3(base, overrides) { 16489 const props = { ...base }; 16490 for (const key in overrides) { 16491 if (!hasOwnProperty(overrides, key)) continue; 16492 if (key === "className") { 16493 const prop = "className"; 16494 props[prop] = base[prop] ? `$base[prop]} $overrides[prop]}` : overrides[prop]; 16495 continue; 16496 } 16497 if (key === "style") { 16498 const prop = "style"; 16499 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop]; 16500 continue; 16501 } 16502 const overrideValue = overrides[key]; 16503 if (typeof overrideValue === "function" && key.startsWith("on")) { 16504 const baseValue = base[key]; 16505 if (typeof baseValue === "function") { 16506 props[key] = (...args) => { 16507 overrideValue(...args); 16508 baseValue(...args); 16509 }; 16510 continue; 16511 } 16512 } 16513 props[key] = overrideValue; 16514 } 16515 return props; 16516 } 16517 16518 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js 16519 var canUseDOM = checkIsBrowser(); 16520 function checkIsBrowser() { 16521 var _a; 16522 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement); 16523 } 16524 function getDocument(node) { 16525 if (!node) return document; 16526 if ("self" in node) return node.document; 16527 return node.ownerDocument || document; 16528 } 16529 function getActiveElement(node, activeDescendant = false) { 16530 var _a; 16531 const { activeElement: activeElement2 } = getDocument(node); 16532 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) { 16533 return null; 16534 } 16535 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) { 16536 return getActiveElement( 16537 activeElement2.contentDocument.body, 16538 activeDescendant 16539 ); 16540 } 16541 if (activeDescendant) { 16542 const id = activeElement2.getAttribute("aria-activedescendant"); 16543 if (id) { 16544 const element = getDocument(activeElement2).getElementById(id); 16545 if (element) { 16546 return element; 16547 } 16548 } 16549 } 16550 return activeElement2; 16551 } 16552 function contains2(parent, child) { 16553 return parent === child || parent.contains(child); 16554 } 16555 function isFrame(element) { 16556 return element.tagName === "IFRAME"; 16557 } 16558 function isButton(element) { 16559 const tagName = element.tagName.toLowerCase(); 16560 if (tagName === "button") return true; 16561 if (tagName === "input" && element.type) { 16562 return buttonInputTypes.indexOf(element.type) !== -1; 16563 } 16564 return false; 16565 } 16566 var buttonInputTypes = [ 16567 "button", 16568 "color", 16569 "file", 16570 "image", 16571 "reset", 16572 "submit" 16573 ]; 16574 function isVisible(element) { 16575 if (typeof element.checkVisibility === "function") { 16576 return element.checkVisibility(); 16577 } 16578 const htmlElement = element; 16579 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0; 16580 } 16581 function isTextField(element) { 16582 try { 16583 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null; 16584 const isTextArea = element.tagName === "TEXTAREA"; 16585 return isTextInput || isTextArea || false; 16586 } catch (_error) { 16587 return false; 16588 } 16589 } 16590 function isTextbox(element) { 16591 return element.isContentEditable || isTextField(element); 16592 } 16593 function getTextboxValue(element) { 16594 if (isTextField(element)) { 16595 return element.value; 16596 } 16597 if (element.isContentEditable) { 16598 const range = getDocument(element).createRange(); 16599 range.selectNodeContents(element); 16600 return range.toString(); 16601 } 16602 return ""; 16603 } 16604 function getTextboxSelection(element) { 16605 let start = 0; 16606 let end = 0; 16607 if (isTextField(element)) { 16608 start = element.selectionStart || 0; 16609 end = element.selectionEnd || 0; 16610 } else if (element.isContentEditable) { 16611 const selection = getDocument(element).getSelection(); 16612 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) { 16613 const range = selection.getRangeAt(0); 16614 const nextRange = range.cloneRange(); 16615 nextRange.selectNodeContents(element); 16616 nextRange.setEnd(range.startContainer, range.startOffset); 16617 start = nextRange.toString().length; 16618 nextRange.setEnd(range.endContainer, range.endOffset); 16619 end = nextRange.toString().length; 16620 } 16621 } 16622 return { start, end }; 16623 } 16624 function getPopupRole(element, fallback) { 16625 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"]; 16626 const role = element == null ? void 0 : element.getAttribute("role"); 16627 if (role && allowedPopupRoles.indexOf(role) !== -1) { 16628 return role; 16629 } 16630 return fallback; 16631 } 16632 function getScrollingElement(element) { 16633 if (!element) return null; 16634 const isScrollableOverflow = (overflow) => { 16635 if (overflow === "auto") return true; 16636 if (overflow === "scroll") return true; 16637 return false; 16638 }; 16639 if (element.clientHeight && element.scrollHeight > element.clientHeight) { 16640 const { overflowY } = getComputedStyle(element); 16641 if (isScrollableOverflow(overflowY)) return element; 16642 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) { 16643 const { overflowX } = getComputedStyle(element); 16644 if (isScrollableOverflow(overflowX)) return element; 16645 } 16646 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body; 16647 } 16648 function setSelectionRange(element, ...args) { 16649 if (/text|search|password|tel|url/i.test(element.type)) { 16650 element.setSelectionRange(...args); 16651 } 16652 } 16653 function sortBasedOnDOMPosition(items, getElement) { 16654 const pairs = items.map((item, index2) => [index2, item]); 16655 let isOrderDifferent = false; 16656 pairs.sort(([indexA, a2], [indexB, b2]) => { 16657 const elementA = getElement(a2); 16658 const elementB = getElement(b2); 16659 if (elementA === elementB) return 0; 16660 if (!elementA || !elementB) return 0; 16661 if (isElementPreceding(elementA, elementB)) { 16662 if (indexA > indexB) { 16663 isOrderDifferent = true; 16664 } 16665 return -1; 16666 } 16667 if (indexA < indexB) { 16668 isOrderDifferent = true; 16669 } 16670 return 1; 16671 }); 16672 if (isOrderDifferent) { 16673 return pairs.map(([_, item]) => item); 16674 } 16675 return items; 16676 } 16677 function isElementPreceding(a2, b2) { 16678 return Boolean( 16679 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING 16680 ); 16681 } 16682 16683 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js 16684 function isTouchDevice() { 16685 return canUseDOM && !!navigator.maxTouchPoints; 16686 } 16687 function isApple() { 16688 if (!canUseDOM) return false; 16689 return /mac|iphone|ipad|ipod/i.test(navigator.platform); 16690 } 16691 function isSafari2() { 16692 return canUseDOM && isApple() && /apple/i.test(navigator.vendor); 16693 } 16694 function isFirefox2() { 16695 return canUseDOM && /firefox\//i.test(navigator.userAgent); 16696 } 16697 16698 // node_modules/@ariakit/core/esm/utils/events.js 16699 function isPortalEvent(event) { 16700 return Boolean( 16701 event.currentTarget && !contains2(event.currentTarget, event.target) 16702 ); 16703 } 16704 function isSelfTarget(event) { 16705 return event.target === event.currentTarget; 16706 } 16707 function isOpeningInNewTab(event) { 16708 const element = event.currentTarget; 16709 if (!element) return false; 16710 const isAppleDevice = isApple(); 16711 if (isAppleDevice && !event.metaKey) return false; 16712 if (!isAppleDevice && !event.ctrlKey) return false; 16713 const tagName = element.tagName.toLowerCase(); 16714 if (tagName === "a") return true; 16715 if (tagName === "button" && element.type === "submit") return true; 16716 if (tagName === "input" && element.type === "submit") return true; 16717 return false; 16718 } 16719 function isDownloading(event) { 16720 const element = event.currentTarget; 16721 if (!element) return false; 16722 const tagName = element.tagName.toLowerCase(); 16723 if (!event.altKey) return false; 16724 if (tagName === "a") return true; 16725 if (tagName === "button" && element.type === "submit") return true; 16726 if (tagName === "input" && element.type === "submit") return true; 16727 return false; 16728 } 16729 function fireBlurEvent(element, eventInit) { 16730 const event = new FocusEvent("blur", eventInit); 16731 const defaultAllowed = element.dispatchEvent(event); 16732 const bubbleInit = { ...eventInit, bubbles: true }; 16733 element.dispatchEvent(new FocusEvent("focusout", bubbleInit)); 16734 return defaultAllowed; 16735 } 16736 function fireKeyboardEvent(element, type, eventInit) { 16737 const event = new KeyboardEvent(type, eventInit); 16738 return element.dispatchEvent(event); 16739 } 16740 function fireClickEvent(element, eventInit) { 16741 const event = new MouseEvent("click", eventInit); 16742 return element.dispatchEvent(event); 16743 } 16744 function isFocusEventOutside(event, container) { 16745 const containerElement = container || event.currentTarget; 16746 const relatedTarget = event.relatedTarget; 16747 return !relatedTarget || !contains2(containerElement, relatedTarget); 16748 } 16749 function queueBeforeEvent(element, type, callback, timeout) { 16750 const createTimer = (callback2) => { 16751 if (timeout) { 16752 const timerId2 = setTimeout(callback2, timeout); 16753 return () => clearTimeout(timerId2); 16754 } 16755 const timerId = requestAnimationFrame(callback2); 16756 return () => cancelAnimationFrame(timerId); 16757 }; 16758 const cancelTimer = createTimer(() => { 16759 element.removeEventListener(type, callSync, true); 16760 callback(); 16761 }); 16762 const callSync = () => { 16763 cancelTimer(); 16764 callback(); 16765 }; 16766 element.addEventListener(type, callSync, { once: true, capture: true }); 16767 return cancelTimer; 16768 } 16769 function addGlobalEventListener(type, listener, options, scope = window) { 16770 const children = []; 16771 try { 16772 scope.document.addEventListener(type, listener, options); 16773 for (const frame of Array.from(scope.frames)) { 16774 children.push(addGlobalEventListener(type, listener, options, frame)); 16775 } 16776 } catch (e2) { 16777 } 16778 const removeEventListener = () => { 16779 try { 16780 scope.document.removeEventListener(type, listener, options); 16781 } catch (e2) { 16782 } 16783 for (const remove of children) { 16784 remove(); 16785 } 16786 }; 16787 return removeEventListener; 16788 } 16789 16790 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js 16791 var React59 = __toESM(require_react(), 1); 16792 var import_react13 = __toESM(require_react(), 1); 16793 var _React = { ...React59 }; 16794 var useReactId = _React.useId; 16795 var useReactDeferredValue = _React.useDeferredValue; 16796 var useReactInsertionEffect = _React.useInsertionEffect; 16797 var useSafeLayoutEffect = canUseDOM ? import_react13.useLayoutEffect : import_react13.useEffect; 16798 function useInitialValue(value) { 16799 const [initialValue] = (0, import_react13.useState)(value); 16800 return initialValue; 16801 } 16802 function useLiveRef(value) { 16803 const ref = (0, import_react13.useRef)(value); 16804 useSafeLayoutEffect(() => { 16805 ref.current = value; 16806 }); 16807 return ref; 16808 } 16809 function useEvent(callback) { 16810 const ref = (0, import_react13.useRef)(() => { 16811 throw new Error("Cannot call an event handler while rendering."); 16812 }); 16813 if (useReactInsertionEffect) { 16814 useReactInsertionEffect(() => { 16815 ref.current = callback; 16816 }); 16817 } else { 16818 ref.current = callback; 16819 } 16820 return (0, import_react13.useCallback)((...args) => { 16821 var _a; 16822 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args); 16823 }, []); 16824 } 16825 function useTransactionState(callback) { 16826 const [state, setState] = (0, import_react13.useState)(null); 16827 useSafeLayoutEffect(() => { 16828 if (state == null) return; 16829 if (!callback) return; 16830 let prevState = null; 16831 callback((prev) => { 16832 prevState = prev; 16833 return state; 16834 }); 16835 return () => { 16836 callback(prevState); 16837 }; 16838 }, [state, callback]); 16839 return [state, setState]; 16840 } 16841 function useMergeRefs(...refs) { 16842 return (0, import_react13.useMemo)(() => { 16843 if (!refs.some(Boolean)) return; 16844 return (value) => { 16845 for (const ref of refs) { 16846 setRef(ref, value); 16847 } 16848 }; 16849 }, refs); 16850 } 16851 function useId5(defaultId) { 16852 if (useReactId) { 16853 const reactId = useReactId(); 16854 if (defaultId) return defaultId; 16855 return reactId; 16856 } 16857 const [id, setId] = (0, import_react13.useState)(defaultId); 16858 useSafeLayoutEffect(() => { 16859 if (defaultId || id) return; 16860 const random = Math.random().toString(36).slice(2, 8); 16861 setId(`id-$random}`); 16862 }, [defaultId, id]); 16863 return defaultId || id; 16864 } 16865 function useTagName(refOrElement, type) { 16866 const stringOrUndefined = (type2) => { 16867 if (typeof type2 !== "string") return; 16868 return type2; 16869 }; 16870 const [tagName, setTagName] = (0, import_react13.useState)(() => stringOrUndefined(type)); 16871 useSafeLayoutEffect(() => { 16872 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 16873 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type)); 16874 }, [refOrElement, type]); 16875 return tagName; 16876 } 16877 function useAttribute(refOrElement, attributeName, defaultValue2) { 16878 const initialValue = useInitialValue(defaultValue2); 16879 const [attribute, setAttribute] = (0, import_react13.useState)(initialValue); 16880 (0, import_react13.useEffect)(() => { 16881 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 16882 if (!element) return; 16883 const callback = () => { 16884 const value = element.getAttribute(attributeName); 16885 setAttribute(value == null ? initialValue : value); 16886 }; 16887 const observer = new MutationObserver(callback); 16888 observer.observe(element, { attributeFilter: [attributeName] }); 16889 callback(); 16890 return () => observer.disconnect(); 16891 }, [refOrElement, attributeName, initialValue]); 16892 return attribute; 16893 } 16894 function useUpdateEffect(effect, deps) { 16895 const mounted = (0, import_react13.useRef)(false); 16896 (0, import_react13.useEffect)(() => { 16897 if (mounted.current) { 16898 return effect(); 16899 } 16900 mounted.current = true; 16901 }, deps); 16902 (0, import_react13.useEffect)( 16903 () => () => { 16904 mounted.current = false; 16905 }, 16906 [] 16907 ); 16908 } 16909 function useUpdateLayoutEffect(effect, deps) { 16910 const mounted = (0, import_react13.useRef)(false); 16911 useSafeLayoutEffect(() => { 16912 if (mounted.current) { 16913 return effect(); 16914 } 16915 mounted.current = true; 16916 }, deps); 16917 useSafeLayoutEffect( 16918 () => () => { 16919 mounted.current = false; 16920 }, 16921 [] 16922 ); 16923 } 16924 function useForceUpdate() { 16925 return (0, import_react13.useReducer)(() => [], []); 16926 } 16927 function useBooleanEvent(booleanOrCallback) { 16928 return useEvent( 16929 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback 16930 ); 16931 } 16932 function useWrapElement(props, callback, deps = []) { 16933 const wrapElement = (0, import_react13.useCallback)( 16934 (element) => { 16935 if (props.wrapElement) { 16936 element = props.wrapElement(element); 16937 } 16938 return callback(element); 16939 }, 16940 [...deps, props.wrapElement] 16941 ); 16942 return { ...props, wrapElement }; 16943 } 16944 function useMetadataProps(props, key, value) { 16945 const parent = props.onLoadedMetadataCapture; 16946 const onLoadedMetadataCapture = (0, import_react13.useMemo)(() => { 16947 return Object.assign(() => { 16948 }, { ...parent, [key]: value }); 16949 }, [parent, key, value]); 16950 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }]; 16951 } 16952 var hasInstalledGlobalEventListeners = false; 16953 function useIsMouseMoving() { 16954 (0, import_react13.useEffect)(() => { 16955 if (hasInstalledGlobalEventListeners) return; 16956 addGlobalEventListener("mousemove", setMouseMoving, true); 16957 addGlobalEventListener("mousedown", resetMouseMoving, true); 16958 addGlobalEventListener("mouseup", resetMouseMoving, true); 16959 addGlobalEventListener("keydown", resetMouseMoving, true); 16960 addGlobalEventListener("scroll", resetMouseMoving, true); 16961 hasInstalledGlobalEventListeners = true; 16962 }, []); 16963 const isMouseMoving = useEvent(() => mouseMoving); 16964 return isMouseMoving; 16965 } 16966 var mouseMoving = false; 16967 var previousScreenX = 0; 16968 var previousScreenY = 0; 16969 function hasMouseMovement(event) { 16970 const movementX = event.movementX || event.screenX - previousScreenX; 16971 const movementY = event.movementY || event.screenY - previousScreenY; 16972 previousScreenX = event.screenX; 16973 previousScreenY = event.screenY; 16974 return movementX || movementY || false; 16975 } 16976 function setMouseMoving(event) { 16977 if (!hasMouseMovement(event)) return; 16978 mouseMoving = true; 16979 } 16980 function resetMouseMoving() { 16981 mouseMoving = false; 16982 } 16983 16984 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js 16985 var React60 = __toESM(require_react(), 1); 16986 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1); 16987 function forwardRef210(render4) { 16988 const Role = React60.forwardRef( 16989 // @ts-ignore Incompatible with React 19 types. Ignore for now. 16990 (props, ref) => render4({ ...props, ref }) 16991 ); 16992 Role.displayName = render4.displayName || render4.name; 16993 return Role; 16994 } 16995 function memo22(Component, propsAreEqual) { 16996 return React60.memo(Component, propsAreEqual); 16997 } 16998 function createElement3(Type, props) { 16999 const { wrapElement, render: render4, ...rest } = props; 17000 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4)); 17001 let element; 17002 if (React60.isValidElement(render4)) { 17003 const renderProps = { 17004 // @ts-ignore Incompatible with React 19 types. Ignore for now. 17005 ...render4.props, 17006 ref: mergedRef 17007 }; 17008 element = React60.cloneElement(render4, mergeProps3(rest, renderProps)); 17009 } else if (render4) { 17010 element = render4(rest); 17011 } else { 17012 element = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Type, { ...rest }); 17013 } 17014 if (wrapElement) { 17015 return wrapElement(element); 17016 } 17017 return element; 17018 } 17019 function createHook(useProps) { 17020 const useRole = (props = {}) => { 17021 return useProps(props); 17022 }; 17023 useRole.displayName = useProps.name; 17024 return useRole; 17025 } 17026 function createStoreContext(providers = [], scopedProviders = []) { 17027 const context = React60.createContext(void 0); 17028 const scopedContext = React60.createContext(void 0); 17029 const useContext210 = () => React60.useContext(context); 17030 const useScopedContext = (onlyScoped = false) => { 17031 const scoped = React60.useContext(scopedContext); 17032 const store2 = useContext210(); 17033 if (onlyScoped) return scoped; 17034 return scoped || store2; 17035 }; 17036 const useProviderContext = () => { 17037 const scoped = React60.useContext(scopedContext); 17038 const store2 = useContext210(); 17039 if (scoped && scoped === store2) return; 17040 return store2; 17041 }; 17042 const ContextProvider = (props) => { 17043 return providers.reduceRight( 17044 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Provider2, { ...props, children }), 17045 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(context.Provider, { ...props }) 17046 ); 17047 }; 17048 const ScopedContextProvider = (props) => { 17049 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight( 17050 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Provider2, { ...props, children }), 17051 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(scopedContext.Provider, { ...props }) 17052 ) }); 17053 }; 17054 return { 17055 context, 17056 scopedContext, 17057 useContext: useContext210, 17058 useScopedContext, 17059 useProviderContext, 17060 ContextProvider, 17061 ScopedContextProvider 17062 }; 17063 } 17064 17065 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js 17066 var ctx = createStoreContext(); 17067 var useCollectionContext = ctx.useContext; 17068 var useCollectionScopedContext = ctx.useScopedContext; 17069 var useCollectionProviderContext = ctx.useProviderContext; 17070 var CollectionContextProvider = ctx.ContextProvider; 17071 var CollectionScopedContextProvider = ctx.ScopedContextProvider; 17072 17073 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js 17074 var import_react14 = __toESM(require_react(), 1); 17075 var ctx2 = createStoreContext( 17076 [CollectionContextProvider], 17077 [CollectionScopedContextProvider] 17078 ); 17079 var useCompositeContext = ctx2.useContext; 17080 var useCompositeScopedContext = ctx2.useScopedContext; 17081 var useCompositeProviderContext = ctx2.useProviderContext; 17082 var CompositeContextProvider = ctx2.ContextProvider; 17083 var CompositeScopedContextProvider = ctx2.ScopedContextProvider; 17084 var CompositeItemContext = (0, import_react14.createContext)( 17085 void 0 17086 ); 17087 var CompositeRowContext = (0, import_react14.createContext)( 17088 void 0 17089 ); 17090 17091 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js 17092 function findFirstEnabledItem(items, excludeId) { 17093 return items.find((item) => { 17094 if (excludeId) { 17095 return !item.disabled && item.id !== excludeId; 17096 } 17097 return !item.disabled; 17098 }); 17099 } 17100 function getEnabledItem(store2, id) { 17101 if (!id) return null; 17102 return store2.item(id) || null; 17103 } 17104 function groupItemsByRows(items) { 17105 const rows = []; 17106 for (const item of items) { 17107 const row = rows.find((currentRow) => { 17108 var _a; 17109 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 17110 }); 17111 if (row) { 17112 row.push(item); 17113 } else { 17114 rows.push([item]); 17115 } 17116 } 17117 return rows; 17118 } 17119 function selectTextField(element, collapseToEnd = false) { 17120 if (isTextField(element)) { 17121 element.setSelectionRange( 17122 collapseToEnd ? element.value.length : 0, 17123 element.value.length 17124 ); 17125 } else if (element.isContentEditable) { 17126 const selection = getDocument(element).getSelection(); 17127 selection == null ? void 0 : selection.selectAllChildren(element); 17128 if (collapseToEnd) { 17129 selection == null ? void 0 : selection.collapseToEnd(); 17130 } 17131 } 17132 } 17133 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY"); 17134 function focusSilently(element) { 17135 element[FOCUS_SILENTLY] = true; 17136 element.focus({ preventScroll: true }); 17137 } 17138 function silentlyFocused(element) { 17139 const isSilentlyFocused = element[FOCUS_SILENTLY]; 17140 delete element[FOCUS_SILENTLY]; 17141 return isSilentlyFocused; 17142 } 17143 function isItem(store2, element, exclude) { 17144 if (!element) return false; 17145 if (element === exclude) return false; 17146 const item = store2.item(element.id); 17147 if (!item) return false; 17148 if (exclude && item.element === exclude) return false; 17149 return true; 17150 } 17151 17152 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js 17153 var import_react15 = __toESM(require_react(), 1); 17154 var TagName = "div"; 17155 var useCollectionItem = createHook( 17156 function useCollectionItem2({ 17157 store: store2, 17158 shouldRegisterItem = true, 17159 getItem = identity, 17160 // @ts-expect-error This prop may come from a collection renderer. 17161 element, 17162 ...props 17163 }) { 17164 const context = useCollectionContext(); 17165 store2 = store2 || context; 17166 const id = useId5(props.id); 17167 const ref = (0, import_react15.useRef)(element); 17168 (0, import_react15.useEffect)(() => { 17169 const element2 = ref.current; 17170 if (!id) return; 17171 if (!element2) return; 17172 if (!shouldRegisterItem) return; 17173 const item = getItem({ id, element: element2 }); 17174 return store2 == null ? void 0 : store2.renderItem(item); 17175 }, [id, shouldRegisterItem, getItem, store2]); 17176 props = { 17177 ...props, 17178 ref: useMergeRefs(ref, props.ref) 17179 }; 17180 return removeUndefinedValues(props); 17181 } 17182 ); 17183 var CollectionItem = forwardRef210(function CollectionItem2(props) { 17184 const htmlProps = useCollectionItem(props); 17185 return createElement3(TagName, htmlProps); 17186 }); 17187 17188 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js 17189 var import_react16 = __toESM(require_react(), 1); 17190 var FocusableContext = (0, import_react16.createContext)(true); 17191 17192 // node_modules/@ariakit/core/esm/utils/focus.js 17193 var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])"; 17194 function isFocusable(element) { 17195 if (!element.matches(selector)) return false; 17196 if (!isVisible(element)) return false; 17197 if (element.closest("[inert]")) return false; 17198 return true; 17199 } 17200 function getClosestFocusable(element) { 17201 while (element && !isFocusable(element)) { 17202 element = element.closest(selector); 17203 } 17204 return element || null; 17205 } 17206 function hasFocus(element) { 17207 const activeElement2 = getActiveElement(element); 17208 if (!activeElement2) return false; 17209 if (activeElement2 === element) return true; 17210 const activeDescendant = activeElement2.getAttribute("aria-activedescendant"); 17211 if (!activeDescendant) return false; 17212 return activeDescendant === element.id; 17213 } 17214 function hasFocusWithin(element) { 17215 const activeElement2 = getActiveElement(element); 17216 if (!activeElement2) return false; 17217 if (contains2(element, activeElement2)) return true; 17218 const activeDescendant = activeElement2.getAttribute("aria-activedescendant"); 17219 if (!activeDescendant) return false; 17220 if (!("id" in element)) return false; 17221 if (activeDescendant === element.id) return true; 17222 return !!element.querySelector(`#$CSS.escape(activeDescendant)}`); 17223 } 17224 function focusIfNeeded(element) { 17225 if (!hasFocusWithin(element) && isFocusable(element)) { 17226 element.focus(); 17227 } 17228 } 17229 function focusIntoView(element, options) { 17230 if (!("scrollIntoView" in element)) { 17231 element.focus(); 17232 } else { 17233 element.focus({ preventScroll: true }); 17234 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options }); 17235 } 17236 } 17237 17238 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js 17239 var import_react17 = __toESM(require_react(), 1); 17240 var TagName2 = "div"; 17241 var isSafariBrowser = isSafari2(); 17242 var alwaysFocusVisibleInputTypes = [ 17243 "text", 17244 "search", 17245 "url", 17246 "tel", 17247 "email", 17248 "password", 17249 "number", 17250 "date", 17251 "month", 17252 "week", 17253 "time", 17254 "datetime", 17255 "datetime-local" 17256 ]; 17257 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor"); 17258 function markSafariFocusAncestor(element, value) { 17259 if (!element) return; 17260 element[safariFocusAncestorSymbol] = value; 17261 } 17262 function isAlwaysFocusVisible(element) { 17263 const { tagName, readOnly, type } = element; 17264 if (tagName === "TEXTAREA" && !readOnly) return true; 17265 if (tagName === "SELECT" && !readOnly) return true; 17266 if (tagName === "INPUT" && !readOnly) { 17267 return alwaysFocusVisibleInputTypes.includes(type); 17268 } 17269 if (element.isContentEditable) return true; 17270 const role = element.getAttribute("role"); 17271 if (role === "combobox" && element.dataset.name) { 17272 return true; 17273 } 17274 return false; 17275 } 17276 function getLabels(element) { 17277 if ("labels" in element) { 17278 return element.labels; 17279 } 17280 return null; 17281 } 17282 function isNativeCheckboxOrRadio(element) { 17283 const tagName = element.tagName.toLowerCase(); 17284 if (tagName === "input" && element.type) { 17285 return element.type === "radio" || element.type === "checkbox"; 17286 } 17287 return false; 17288 } 17289 function isNativeTabbable(tagName) { 17290 if (!tagName) return true; 17291 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a"; 17292 } 17293 function supportsDisabledAttribute(tagName) { 17294 if (!tagName) return true; 17295 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea"; 17296 } 17297 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) { 17298 if (!focusable2) { 17299 return tabIndexProp; 17300 } 17301 if (trulyDisabled) { 17302 if (nativeTabbable && !supportsDisabled) { 17303 return -1; 17304 } 17305 return; 17306 } 17307 if (nativeTabbable) { 17308 return tabIndexProp; 17309 } 17310 return tabIndexProp || 0; 17311 } 17312 function useDisableEvent(onEvent, disabled2) { 17313 return useEvent((event) => { 17314 onEvent == null ? void 0 : onEvent(event); 17315 if (event.defaultPrevented) return; 17316 if (disabled2) { 17317 event.stopPropagation(); 17318 event.preventDefault(); 17319 } 17320 }); 17321 } 17322 var hasInstalledGlobalEventListeners2 = false; 17323 var isKeyboardModality = true; 17324 function onGlobalMouseDown(event) { 17325 const target = event.target; 17326 if (target && "hasAttribute" in target) { 17327 if (!target.hasAttribute("data-focus-visible")) { 17328 isKeyboardModality = false; 17329 } 17330 } 17331 } 17332 function onGlobalKeyDown(event) { 17333 if (event.metaKey) return; 17334 if (event.ctrlKey) return; 17335 if (event.altKey) return; 17336 isKeyboardModality = true; 17337 } 17338 var useFocusable = createHook( 17339 function useFocusable2({ 17340 focusable: focusable2 = true, 17341 accessibleWhenDisabled, 17342 autoFocus, 17343 onFocusVisible, 17344 ...props 17345 }) { 17346 const ref = (0, import_react17.useRef)(null); 17347 (0, import_react17.useEffect)(() => { 17348 if (!focusable2) return; 17349 if (hasInstalledGlobalEventListeners2) return; 17350 addGlobalEventListener("mousedown", onGlobalMouseDown, true); 17351 addGlobalEventListener("keydown", onGlobalKeyDown, true); 17352 hasInstalledGlobalEventListeners2 = true; 17353 }, [focusable2]); 17354 if (isSafariBrowser) { 17355 (0, import_react17.useEffect)(() => { 17356 if (!focusable2) return; 17357 const element = ref.current; 17358 if (!element) return; 17359 if (!isNativeCheckboxOrRadio(element)) return; 17360 const labels = getLabels(element); 17361 if (!labels) return; 17362 const onMouseUp = () => queueMicrotask(() => element.focus()); 17363 for (const label of labels) { 17364 label.addEventListener("mouseup", onMouseUp); 17365 } 17366 return () => { 17367 for (const label of labels) { 17368 label.removeEventListener("mouseup", onMouseUp); 17369 } 17370 }; 17371 }, [focusable2]); 17372 } 17373 const disabled2 = focusable2 && disabledFromProps(props); 17374 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled; 17375 const [focusVisible, setFocusVisible] = (0, import_react17.useState)(false); 17376 (0, import_react17.useEffect)(() => { 17377 if (!focusable2) return; 17378 if (trulyDisabled && focusVisible) { 17379 setFocusVisible(false); 17380 } 17381 }, [focusable2, trulyDisabled, focusVisible]); 17382 (0, import_react17.useEffect)(() => { 17383 if (!focusable2) return; 17384 if (!focusVisible) return; 17385 const element = ref.current; 17386 if (!element) return; 17387 if (typeof IntersectionObserver === "undefined") return; 17388 const observer = new IntersectionObserver(() => { 17389 if (!isFocusable(element)) { 17390 setFocusVisible(false); 17391 } 17392 }); 17393 observer.observe(element); 17394 return () => observer.disconnect(); 17395 }, [focusable2, focusVisible]); 17396 const onKeyPressCapture = useDisableEvent( 17397 props.onKeyPressCapture, 17398 disabled2 17399 ); 17400 const onMouseDownCapture = useDisableEvent( 17401 props.onMouseDownCapture, 17402 disabled2 17403 ); 17404 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2); 17405 const onMouseDownProp = props.onMouseDown; 17406 const onMouseDown = useEvent((event) => { 17407 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 17408 if (event.defaultPrevented) return; 17409 if (!focusable2) return; 17410 const element = event.currentTarget; 17411 if (!isSafariBrowser) return; 17412 if (isPortalEvent(event)) return; 17413 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return; 17414 let receivedFocus = false; 17415 const onFocus = () => { 17416 receivedFocus = true; 17417 }; 17418 const options = { capture: true, once: true }; 17419 element.addEventListener("focusin", onFocus, options); 17420 const focusableContainer = getClosestFocusable(element.parentElement); 17421 markSafariFocusAncestor(focusableContainer, true); 17422 queueBeforeEvent(element, "mouseup", () => { 17423 element.removeEventListener("focusin", onFocus, true); 17424 markSafariFocusAncestor(focusableContainer, false); 17425 if (receivedFocus) return; 17426 focusIfNeeded(element); 17427 }); 17428 }); 17429 const handleFocusVisible = (event, currentTarget) => { 17430 if (currentTarget) { 17431 event.currentTarget = currentTarget; 17432 } 17433 if (!focusable2) return; 17434 const element = event.currentTarget; 17435 if (!element) return; 17436 if (!hasFocus(element)) return; 17437 onFocusVisible == null ? void 0 : onFocusVisible(event); 17438 if (event.defaultPrevented) return; 17439 element.dataset.focusVisible = "true"; 17440 setFocusVisible(true); 17441 }; 17442 const onKeyDownCaptureProp = props.onKeyDownCapture; 17443 const onKeyDownCapture = useEvent((event) => { 17444 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event); 17445 if (event.defaultPrevented) return; 17446 if (!focusable2) return; 17447 if (focusVisible) return; 17448 if (event.metaKey) return; 17449 if (event.altKey) return; 17450 if (event.ctrlKey) return; 17451 if (!isSelfTarget(event)) return; 17452 const element = event.currentTarget; 17453 const applyFocusVisible = () => handleFocusVisible(event, element); 17454 queueBeforeEvent(element, "focusout", applyFocusVisible); 17455 }); 17456 const onFocusCaptureProp = props.onFocusCapture; 17457 const onFocusCapture = useEvent((event) => { 17458 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 17459 if (event.defaultPrevented) return; 17460 if (!focusable2) return; 17461 if (!isSelfTarget(event)) { 17462 setFocusVisible(false); 17463 return; 17464 } 17465 const element = event.currentTarget; 17466 const applyFocusVisible = () => handleFocusVisible(event, element); 17467 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) { 17468 queueBeforeEvent(event.target, "focusout", applyFocusVisible); 17469 } else { 17470 setFocusVisible(false); 17471 } 17472 }); 17473 const onBlurProp = props.onBlur; 17474 const onBlur = useEvent((event) => { 17475 onBlurProp == null ? void 0 : onBlurProp(event); 17476 if (!focusable2) return; 17477 if (!isFocusEventOutside(event)) return; 17478 event.currentTarget.removeAttribute("data-focus-visible"); 17479 setFocusVisible(false); 17480 }); 17481 const autoFocusOnShow = (0, import_react17.useContext)(FocusableContext); 17482 const autoFocusRef = useEvent((element) => { 17483 if (!focusable2) return; 17484 if (!autoFocus) return; 17485 if (!element) return; 17486 if (!autoFocusOnShow) return; 17487 queueMicrotask(() => { 17488 if (hasFocus(element)) return; 17489 if (!isFocusable(element)) return; 17490 element.focus(); 17491 }); 17492 }); 17493 const tagName = useTagName(ref); 17494 const nativeTabbable = focusable2 && isNativeTabbable(tagName); 17495 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName); 17496 const styleProp = props.style; 17497 const style = (0, import_react17.useMemo)(() => { 17498 if (trulyDisabled) { 17499 return { pointerEvents: "none", ...styleProp }; 17500 } 17501 return styleProp; 17502 }, [trulyDisabled, styleProp]); 17503 props = { 17504 "data-focus-visible": focusable2 && focusVisible || void 0, 17505 "data-autofocus": autoFocus || void 0, 17506 "aria-disabled": disabled2 || void 0, 17507 ...props, 17508 ref: useMergeRefs(ref, autoFocusRef, props.ref), 17509 style, 17510 tabIndex: getTabIndex2( 17511 focusable2, 17512 trulyDisabled, 17513 nativeTabbable, 17514 supportsDisabled, 17515 props.tabIndex 17516 ), 17517 disabled: supportsDisabled && trulyDisabled ? true : void 0, 17518 // TODO: Test Focusable contentEditable. 17519 contentEditable: disabled2 ? void 0 : props.contentEditable, 17520 onKeyPressCapture, 17521 onClickCapture, 17522 onMouseDownCapture, 17523 onMouseDown, 17524 onKeyDownCapture, 17525 onFocusCapture, 17526 onBlur 17527 }; 17528 return removeUndefinedValues(props); 17529 } 17530 ); 17531 var Focusable = forwardRef210(function Focusable2(props) { 17532 const htmlProps = useFocusable(props); 17533 return createElement3(TagName2, htmlProps); 17534 }); 17535 17536 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js 17537 var import_react18 = __toESM(require_react(), 1); 17538 var TagName3 = "button"; 17539 function isNativeClick(event) { 17540 if (!event.isTrusted) return false; 17541 const element = event.currentTarget; 17542 if (event.key === "Enter") { 17543 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A"; 17544 } 17545 if (event.key === " ") { 17546 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT"; 17547 } 17548 return false; 17549 } 17550 var symbol = /* @__PURE__ */ Symbol("command"); 17551 var useCommand = createHook( 17552 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) { 17553 const ref = (0, import_react18.useRef)(null); 17554 const [isNativeButton, setIsNativeButton] = (0, import_react18.useState)(false); 17555 (0, import_react18.useEffect)(() => { 17556 if (!ref.current) return; 17557 setIsNativeButton(isButton(ref.current)); 17558 }, []); 17559 const [active, setActive] = (0, import_react18.useState)(false); 17560 const activeRef = (0, import_react18.useRef)(false); 17561 const disabled2 = disabledFromProps(props); 17562 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true); 17563 const onKeyDownProp = props.onKeyDown; 17564 const onKeyDown = useEvent((event) => { 17565 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 17566 const element = event.currentTarget; 17567 if (event.defaultPrevented) return; 17568 if (isDuplicate) return; 17569 if (disabled2) return; 17570 if (!isSelfTarget(event)) return; 17571 if (isTextField(element)) return; 17572 if (element.isContentEditable) return; 17573 const isEnter = clickOnEnter && event.key === "Enter"; 17574 const isSpace = clickOnSpace && event.key === " "; 17575 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter; 17576 const shouldPreventSpace = event.key === " " && !clickOnSpace; 17577 if (shouldPreventEnter || shouldPreventSpace) { 17578 event.preventDefault(); 17579 return; 17580 } 17581 if (isEnter || isSpace) { 17582 const nativeClick = isNativeClick(event); 17583 if (isEnter) { 17584 if (!nativeClick) { 17585 event.preventDefault(); 17586 const { view, ...eventInit } = event; 17587 const click = () => fireClickEvent(element, eventInit); 17588 if (isFirefox2()) { 17589 queueBeforeEvent(element, "keyup", click); 17590 } else { 17591 queueMicrotask(click); 17592 } 17593 } 17594 } else if (isSpace) { 17595 activeRef.current = true; 17596 if (!nativeClick) { 17597 event.preventDefault(); 17598 setActive(true); 17599 } 17600 } 17601 } 17602 }); 17603 const onKeyUpProp = props.onKeyUp; 17604 const onKeyUp = useEvent((event) => { 17605 onKeyUpProp == null ? void 0 : onKeyUpProp(event); 17606 if (event.defaultPrevented) return; 17607 if (isDuplicate) return; 17608 if (disabled2) return; 17609 if (event.metaKey) return; 17610 const isSpace = clickOnSpace && event.key === " "; 17611 if (activeRef.current && isSpace) { 17612 activeRef.current = false; 17613 if (!isNativeClick(event)) { 17614 event.preventDefault(); 17615 setActive(false); 17616 const element = event.currentTarget; 17617 const { view, ...eventInit } = event; 17618 queueMicrotask(() => fireClickEvent(element, eventInit)); 17619 } 17620 } 17621 }); 17622 props = { 17623 "data-active": active || void 0, 17624 type: isNativeButton ? "button" : void 0, 17625 ...metadataProps, 17626 ...props, 17627 ref: useMergeRefs(ref, props.ref), 17628 onKeyDown, 17629 onKeyUp 17630 }; 17631 props = useFocusable(props); 17632 return props; 17633 } 17634 ); 17635 var Command = forwardRef210(function Command2(props) { 17636 const htmlProps = useCommand(props); 17637 return createElement3(TagName3, htmlProps); 17638 }); 17639 17640 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js 17641 function getInternal(store2, key) { 17642 const internals = store2.__unstableInternals; 17643 invariant(internals, "Invalid store"); 17644 return internals[key]; 17645 } 17646 function createStore(initialState, ...stores) { 17647 let state = initialState; 17648 let prevStateBatch = state; 17649 let lastUpdate = /* @__PURE__ */ Symbol(); 17650 let destroy = noop4; 17651 const instances = /* @__PURE__ */ new Set(); 17652 const updatedKeys = /* @__PURE__ */ new Set(); 17653 const setups = /* @__PURE__ */ new Set(); 17654 const listeners = /* @__PURE__ */ new Set(); 17655 const batchListeners = /* @__PURE__ */ new Set(); 17656 const disposables = /* @__PURE__ */ new WeakMap(); 17657 const listenerKeys = /* @__PURE__ */ new WeakMap(); 17658 const storeSetup = (callback) => { 17659 setups.add(callback); 17660 return () => setups.delete(callback); 17661 }; 17662 const storeInit = () => { 17663 const initialized = instances.size; 17664 const instance = /* @__PURE__ */ Symbol(); 17665 instances.add(instance); 17666 const maybeDestroy = () => { 17667 instances.delete(instance); 17668 if (instances.size) return; 17669 destroy(); 17670 }; 17671 if (initialized) return maybeDestroy; 17672 const desyncs = getKeys(state).map( 17673 (key) => chain( 17674 ...stores.map((store2) => { 17675 var _a; 17676 const storeState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2); 17677 if (!storeState) return; 17678 if (!hasOwnProperty(storeState, key)) return; 17679 return sync(store2, [key], (state2) => { 17680 setState( 17681 key, 17682 state2[key], 17683 // @ts-expect-error - Not public API. This is just to prevent 17684 // infinite loops. 17685 true 17686 ); 17687 }); 17688 }) 17689 ) 17690 ); 17691 const teardowns = []; 17692 for (const setup2 of setups) { 17693 teardowns.push(setup2()); 17694 } 17695 const cleanups = stores.map(init); 17696 destroy = chain(...desyncs, ...teardowns, ...cleanups); 17697 return maybeDestroy; 17698 }; 17699 const sub = (keys, listener, set3 = listeners) => { 17700 set3.add(listener); 17701 listenerKeys.set(listener, keys); 17702 return () => { 17703 var _a; 17704 (_a = disposables.get(listener)) == null ? void 0 : _a(); 17705 disposables.delete(listener); 17706 listenerKeys.delete(listener); 17707 set3.delete(listener); 17708 }; 17709 }; 17710 const storeSubscribe = (keys, listener) => sub(keys, listener); 17711 const storeSync = (keys, listener) => { 17712 disposables.set(listener, listener(state, state)); 17713 return sub(keys, listener); 17714 }; 17715 const storeBatch = (keys, listener) => { 17716 disposables.set(listener, listener(state, prevStateBatch)); 17717 return sub(keys, listener, batchListeners); 17718 }; 17719 const storePick = (keys) => createStore(pick(state, keys), finalStore); 17720 const storeOmit = (keys) => createStore(omit(state, keys), finalStore); 17721 const getState = () => state; 17722 const setState = (key, value, fromStores = false) => { 17723 var _a; 17724 if (!hasOwnProperty(state, key)) return; 17725 const nextValue = applyState(value, state[key]); 17726 if (nextValue === state[key]) return; 17727 if (!fromStores) { 17728 for (const store2 of stores) { 17729 (_a = store2 == null ? void 0 : store2.setState) == null ? void 0 : _a.call(store2, key, nextValue); 17730 } 17731 } 17732 const prevState = state; 17733 state = { ...state, [key]: nextValue }; 17734 const thisUpdate = /* @__PURE__ */ Symbol(); 17735 lastUpdate = thisUpdate; 17736 updatedKeys.add(key); 17737 const run = (listener, prev, uKeys) => { 17738 var _a2; 17739 const keys = listenerKeys.get(listener); 17740 const updated = (k) => uKeys ? uKeys.has(k) : k === key; 17741 if (!keys || keys.some(updated)) { 17742 (_a2 = disposables.get(listener)) == null ? void 0 : _a2(); 17743 disposables.set(listener, listener(state, prev)); 17744 } 17745 }; 17746 for (const listener of listeners) { 17747 run(listener, prevState); 17748 } 17749 queueMicrotask(() => { 17750 if (lastUpdate !== thisUpdate) return; 17751 const snapshot = state; 17752 for (const listener of batchListeners) { 17753 run(listener, prevStateBatch, updatedKeys); 17754 } 17755 prevStateBatch = snapshot; 17756 updatedKeys.clear(); 17757 }); 17758 }; 17759 const finalStore = { 17760 getState, 17761 setState, 17762 __unstableInternals: { 17763 setup: storeSetup, 17764 init: storeInit, 17765 subscribe: storeSubscribe, 17766 sync: storeSync, 17767 batch: storeBatch, 17768 pick: storePick, 17769 omit: storeOmit 17770 } 17771 }; 17772 return finalStore; 17773 } 17774 function setup(store2, ...args) { 17775 if (!store2) return; 17776 return getInternal(store2, "setup")(...args); 17777 } 17778 function init(store2, ...args) { 17779 if (!store2) return; 17780 return getInternal(store2, "init")(...args); 17781 } 17782 function subscribe(store2, ...args) { 17783 if (!store2) return; 17784 return getInternal(store2, "subscribe")(...args); 17785 } 17786 function sync(store2, ...args) { 17787 if (!store2) return; 17788 return getInternal(store2, "sync")(...args); 17789 } 17790 function batch(store2, ...args) { 17791 if (!store2) return; 17792 return getInternal(store2, "batch")(...args); 17793 } 17794 function omit2(store2, ...args) { 17795 if (!store2) return; 17796 return getInternal(store2, "omit")(...args); 17797 } 17798 function pick2(store2, ...args) { 17799 if (!store2) return; 17800 return getInternal(store2, "pick")(...args); 17801 } 17802 function mergeStore(...stores) { 17803 var _a; 17804 const initialState = {}; 17805 for (const store22 of stores) { 17806 const nextState = (_a = store22 == null ? void 0 : store22.getState) == null ? void 0 : _a.call(store22); 17807 if (nextState) { 17808 Object.assign(initialState, nextState); 17809 } 17810 } 17811 const store2 = createStore(initialState, ...stores); 17812 return Object.assign({}, ...stores, store2); 17813 } 17814 function throwOnConflictingProps(props, store2) { 17815 if (false) return; 17816 if (!store2) return; 17817 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => { 17818 var _a; 17819 const stateKey = key.replace("default", ""); 17820 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}$stateKey.slice(1)}`; 17821 }); 17822 if (!defaultKeys.length) return; 17823 const storeState = store2.getState(); 17824 const conflictingProps = defaultKeys.filter( 17825 (key) => hasOwnProperty(storeState, key) 17826 ); 17827 if (!conflictingProps.length) return; 17828 throw new Error( 17829 `Passing a store prop in conjunction with a default state is not supported. 17830 17831 const store = useSelectStore(); 17832 <SelectProvider store={store} defaultValue="Apple" /> 17833 ^ ^ 17834 17835 Instead, pass the default state to the topmost store: 17836 17837 const store = useSelectStore({ defaultValue: "Apple" }); 17838 <SelectProvider store={store} /> 17839 17840 See https://github.com/ariakit/ariakit/pull/2745 for more details. 17841 17842 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit 17843 ` 17844 ); 17845 } 17846 17847 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js 17848 var React61 = __toESM(require_react(), 1); 17849 var import_shim2 = __toESM(require_shim(), 1); 17850 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default; 17851 var noopSubscribe = () => () => { 17852 }; 17853 function useStoreState(store2, keyOrSelector = identity) { 17854 const storeSubscribe = React61.useCallback( 17855 (callback) => { 17856 if (!store2) return noopSubscribe(); 17857 return subscribe(store2, null, callback); 17858 }, 17859 [store2] 17860 ); 17861 const getSnapshot = () => { 17862 const key = typeof keyOrSelector === "string" ? keyOrSelector : null; 17863 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null; 17864 const state = store2 == null ? void 0 : store2.getState(); 17865 if (selector2) return selector2(state); 17866 if (!state) return; 17867 if (!key) return; 17868 if (!hasOwnProperty(state, key)) return; 17869 return state[key]; 17870 }; 17871 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot); 17872 } 17873 function useStoreStateObject(store2, object) { 17874 const objRef = React61.useRef( 17875 {} 17876 ); 17877 const storeSubscribe = React61.useCallback( 17878 (callback) => { 17879 if (!store2) return noopSubscribe(); 17880 return subscribe(store2, null, callback); 17881 }, 17882 [store2] 17883 ); 17884 const getSnapshot = () => { 17885 const state = store2 == null ? void 0 : store2.getState(); 17886 let updated = false; 17887 const obj = objRef.current; 17888 for (const prop in object) { 17889 const keyOrSelector = object[prop]; 17890 if (typeof keyOrSelector === "function") { 17891 const value = keyOrSelector(state); 17892 if (value !== obj[prop]) { 17893 obj[prop] = value; 17894 updated = true; 17895 } 17896 } 17897 if (typeof keyOrSelector === "string") { 17898 if (!state) continue; 17899 if (!hasOwnProperty(state, keyOrSelector)) continue; 17900 const value = state[keyOrSelector]; 17901 if (value !== obj[prop]) { 17902 obj[prop] = value; 17903 updated = true; 17904 } 17905 } 17906 } 17907 if (updated) { 17908 objRef.current = { ...obj }; 17909 } 17910 return objRef.current; 17911 }; 17912 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot); 17913 } 17914 function useStoreProps(store2, props, key, setKey) { 17915 const value = hasOwnProperty(props, key) ? props[key] : void 0; 17916 const setValue = setKey ? props[setKey] : void 0; 17917 const propsRef = useLiveRef({ value, setValue }); 17918 useSafeLayoutEffect(() => { 17919 return sync(store2, [key], (state, prev) => { 17920 const { value: value2, setValue: setValue2 } = propsRef.current; 17921 if (!setValue2) return; 17922 if (state[key] === prev[key]) return; 17923 if (state[key] === value2) return; 17924 setValue2(state[key]); 17925 }); 17926 }, [store2, key]); 17927 useSafeLayoutEffect(() => { 17928 if (value === void 0) return; 17929 store2.setState(key, value); 17930 return batch(store2, [key], () => { 17931 if (value === void 0) return; 17932 store2.setState(key, value); 17933 }); 17934 }); 17935 } 17936 function useStore2(createStore2, props) { 17937 const [store2, setStore] = React61.useState(() => createStore2(props)); 17938 useSafeLayoutEffect(() => init(store2), [store2]); 17939 const useState210 = React61.useCallback( 17940 (keyOrSelector) => useStoreState(store2, keyOrSelector), 17941 [store2] 17942 ); 17943 const memoizedStore = React61.useMemo( 17944 () => ({ ...store2, useState: useState210 }), 17945 [store2, useState210] 17946 ); 17947 const updateStore = useEvent(() => { 17948 setStore((store22) => createStore2({ ...props, ...store22.getState() })); 17949 }); 17950 return [memoizedStore, updateStore]; 17951 } 17952 17953 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js 17954 var import_react19 = __toESM(require_react(), 1); 17955 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1); 17956 var TagName4 = "button"; 17957 function isEditableElement(element) { 17958 if (isTextbox(element)) return true; 17959 return element.tagName === "INPUT" && !isButton(element); 17960 } 17961 function getNextPageOffset(scrollingElement, pageUp = false) { 17962 const height = scrollingElement.clientHeight; 17963 const { top } = scrollingElement.getBoundingClientRect(); 17964 const pageSize = Math.max(height * 0.875, height - 40) * 1.5; 17965 const pageOffset = pageUp ? height - pageSize + top : pageSize + top; 17966 if (scrollingElement.tagName === "HTML") { 17967 return pageOffset + scrollingElement.scrollTop; 17968 } 17969 return pageOffset; 17970 } 17971 function getItemOffset(itemElement, pageUp = false) { 17972 const { top } = itemElement.getBoundingClientRect(); 17973 if (pageUp) { 17974 return top + itemElement.clientHeight; 17975 } 17976 return top; 17977 } 17978 function findNextPageItemId(element, store2, next, pageUp = false) { 17979 var _a; 17980 if (!store2) return; 17981 if (!next) return; 17982 const { renderedItems } = store2.getState(); 17983 const scrollingElement = getScrollingElement(element); 17984 if (!scrollingElement) return; 17985 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp); 17986 let id; 17987 let prevDifference; 17988 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) { 17989 const previousId = id; 17990 id = next(i2); 17991 if (!id) break; 17992 if (id === previousId) continue; 17993 const itemElement = (_a = getEnabledItem(store2, id)) == null ? void 0 : _a.element; 17994 if (!itemElement) continue; 17995 const itemOffset = getItemOffset(itemElement, pageUp); 17996 const difference = itemOffset - nextPageOffset; 17997 const absDifference = Math.abs(difference); 17998 if (pageUp && difference <= 0 || !pageUp && difference >= 0) { 17999 if (prevDifference !== void 0 && prevDifference < absDifference) { 18000 id = previousId; 18001 } 18002 break; 18003 } 18004 prevDifference = absDifference; 18005 } 18006 return id; 18007 } 18008 function targetIsAnotherItem(event, store2) { 18009 if (isSelfTarget(event)) return false; 18010 return isItem(store2, event.target); 18011 } 18012 var useCompositeItem = createHook( 18013 function useCompositeItem2({ 18014 store: store2, 18015 rowId: rowIdProp, 18016 preventScrollOnKeyDown = false, 18017 moveOnKeyPress = true, 18018 tabbable: tabbable2 = false, 18019 getItem: getItemProp, 18020 "aria-setsize": ariaSetSizeProp, 18021 "aria-posinset": ariaPosInSetProp, 18022 ...props 18023 }) { 18024 const context = useCompositeContext(); 18025 store2 = store2 || context; 18026 const id = useId5(props.id); 18027 const ref = (0, import_react19.useRef)(null); 18028 const row = (0, import_react19.useContext)(CompositeRowContext); 18029 const disabled2 = disabledFromProps(props); 18030 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled; 18031 const { 18032 rowId, 18033 baseElement, 18034 isActiveItem, 18035 ariaSetSize, 18036 ariaPosInSet, 18037 isTabbable 18038 } = useStoreStateObject(store2, { 18039 rowId(state) { 18040 if (rowIdProp) return rowIdProp; 18041 if (!state) return; 18042 if (!(row == null ? void 0 : row.baseElement)) return; 18043 if (row.baseElement !== state.baseElement) return; 18044 return row.id; 18045 }, 18046 baseElement(state) { 18047 return (state == null ? void 0 : state.baseElement) || void 0; 18048 }, 18049 isActiveItem(state) { 18050 return !!state && state.activeId === id; 18051 }, 18052 ariaSetSize(state) { 18053 if (ariaSetSizeProp != null) return ariaSetSizeProp; 18054 if (!state) return; 18055 if (!(row == null ? void 0 : row.ariaSetSize)) return; 18056 if (row.baseElement !== state.baseElement) return; 18057 return row.ariaSetSize; 18058 }, 18059 ariaPosInSet(state) { 18060 if (ariaPosInSetProp != null) return ariaPosInSetProp; 18061 if (!state) return; 18062 if (!(row == null ? void 0 : row.ariaPosInSet)) return; 18063 if (row.baseElement !== state.baseElement) return; 18064 const itemsInRow = state.renderedItems.filter( 18065 (item) => item.rowId === rowId 18066 ); 18067 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id); 18068 }, 18069 isTabbable(state) { 18070 if (!(state == null ? void 0 : state.renderedItems.length)) return true; 18071 if (state.virtualFocus) return false; 18072 if (tabbable2) return true; 18073 if (state.activeId === null) return false; 18074 const item = store2 == null ? void 0 : store2.item(state.activeId); 18075 if (item == null ? void 0 : item.disabled) return true; 18076 if (!(item == null ? void 0 : item.element)) return true; 18077 return state.activeId === id; 18078 } 18079 }); 18080 const getItem = (0, import_react19.useCallback)( 18081 (item) => { 18082 var _a; 18083 const nextItem = { 18084 ...item, 18085 id: id || item.id, 18086 rowId, 18087 disabled: !!trulyDisabled, 18088 children: (_a = item.element) == null ? void 0 : _a.textContent 18089 }; 18090 if (getItemProp) { 18091 return getItemProp(nextItem); 18092 } 18093 return nextItem; 18094 }, 18095 [id, rowId, trulyDisabled, getItemProp] 18096 ); 18097 const onFocusProp = props.onFocus; 18098 const hasFocusedComposite = (0, import_react19.useRef)(false); 18099 const onFocus = useEvent((event) => { 18100 onFocusProp == null ? void 0 : onFocusProp(event); 18101 if (event.defaultPrevented) return; 18102 if (isPortalEvent(event)) return; 18103 if (!id) return; 18104 if (!store2) return; 18105 if (targetIsAnotherItem(event, store2)) return; 18106 const { virtualFocus, baseElement: baseElement2 } = store2.getState(); 18107 store2.setActiveId(id); 18108 if (isTextbox(event.currentTarget)) { 18109 selectTextField(event.currentTarget); 18110 } 18111 if (!virtualFocus) return; 18112 if (!isSelfTarget(event)) return; 18113 if (isEditableElement(event.currentTarget)) return; 18114 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return; 18115 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) { 18116 event.currentTarget.scrollIntoView({ 18117 block: "nearest", 18118 inline: "nearest" 18119 }); 18120 } 18121 hasFocusedComposite.current = true; 18122 const fromComposite = event.relatedTarget === baseElement2 || isItem(store2, event.relatedTarget); 18123 if (fromComposite) { 18124 focusSilently(baseElement2); 18125 } else { 18126 baseElement2.focus(); 18127 } 18128 }); 18129 const onBlurCaptureProp = props.onBlurCapture; 18130 const onBlurCapture = useEvent((event) => { 18131 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 18132 if (event.defaultPrevented) return; 18133 const state = store2 == null ? void 0 : store2.getState(); 18134 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) { 18135 hasFocusedComposite.current = false; 18136 event.preventDefault(); 18137 event.stopPropagation(); 18138 } 18139 }); 18140 const onKeyDownProp = props.onKeyDown; 18141 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown); 18142 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 18143 const onKeyDown = useEvent((event) => { 18144 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 18145 if (event.defaultPrevented) return; 18146 if (!isSelfTarget(event)) return; 18147 if (!store2) return; 18148 const { currentTarget } = event; 18149 const state = store2.getState(); 18150 const item = store2.item(id); 18151 const isGrid2 = !!(item == null ? void 0 : item.rowId); 18152 const isVertical = state.orientation !== "horizontal"; 18153 const isHorizontal = state.orientation !== "vertical"; 18154 const canHomeEnd = () => { 18155 if (isGrid2) return true; 18156 if (isHorizontal) return true; 18157 if (!state.baseElement) return true; 18158 if (!isTextField(state.baseElement)) return true; 18159 return false; 18160 }; 18161 const keyMap = { 18162 ArrowUp: (isGrid2 || isVertical) && store2.up, 18163 ArrowRight: (isGrid2 || isHorizontal) && store2.next, 18164 ArrowDown: (isGrid2 || isVertical) && store2.down, 18165 ArrowLeft: (isGrid2 || isHorizontal) && store2.previous, 18166 Home: () => { 18167 if (!canHomeEnd()) return; 18168 if (!isGrid2 || event.ctrlKey) { 18169 return store2 == null ? void 0 : store2.first(); 18170 } 18171 return store2 == null ? void 0 : store2.previous(-1); 18172 }, 18173 End: () => { 18174 if (!canHomeEnd()) return; 18175 if (!isGrid2 || event.ctrlKey) { 18176 return store2 == null ? void 0 : store2.last(); 18177 } 18178 return store2 == null ? void 0 : store2.next(-1); 18179 }, 18180 PageUp: () => { 18181 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.up, true); 18182 }, 18183 PageDown: () => { 18184 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.down); 18185 } 18186 }; 18187 const action = keyMap[event.key]; 18188 if (action) { 18189 if (isTextbox(currentTarget)) { 18190 const selection = getTextboxSelection(currentTarget); 18191 const isLeft = isHorizontal && event.key === "ArrowLeft"; 18192 const isRight = isHorizontal && event.key === "ArrowRight"; 18193 const isUp = isVertical && event.key === "ArrowUp"; 18194 const isDown = isVertical && event.key === "ArrowDown"; 18195 if (isRight || isDown) { 18196 const { length: valueLength } = getTextboxValue(currentTarget); 18197 if (selection.end !== valueLength) return; 18198 } else if ((isLeft || isUp) && selection.start !== 0) return; 18199 } 18200 const nextId = action(); 18201 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) { 18202 if (!moveOnKeyPressProp(event)) return; 18203 event.preventDefault(); 18204 store2.move(nextId); 18205 } 18206 } 18207 }); 18208 const providerValue = (0, import_react19.useMemo)( 18209 () => ({ id, baseElement }), 18210 [id, baseElement] 18211 ); 18212 props = useWrapElement( 18213 props, 18214 (element) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }), 18215 [providerValue] 18216 ); 18217 props = { 18218 id, 18219 "data-active-item": isActiveItem || void 0, 18220 ...props, 18221 ref: useMergeRefs(ref, props.ref), 18222 tabIndex: isTabbable ? props.tabIndex : -1, 18223 onFocus, 18224 onBlurCapture, 18225 onKeyDown 18226 }; 18227 props = useCommand(props); 18228 props = useCollectionItem({ 18229 store: store2, 18230 ...props, 18231 getItem, 18232 shouldRegisterItem: id ? props.shouldRegisterItem : false 18233 }); 18234 return removeUndefinedValues({ 18235 ...props, 18236 "aria-setsize": ariaSetSize, 18237 "aria-posinset": ariaPosInSet 18238 }); 18239 } 18240 ); 18241 var CompositeItem = memo22( 18242 forwardRef210(function CompositeItem2(props) { 18243 const htmlProps = useCompositeItem(props); 18244 return createElement3(TagName4, htmlProps); 18245 }) 18246 ); 18247 18248 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js 18249 function toArray(arg) { 18250 if (Array.isArray(arg)) { 18251 return arg; 18252 } 18253 return typeof arg !== "undefined" ? [arg] : []; 18254 } 18255 function flatten2DArray(array) { 18256 const flattened = []; 18257 for (const row of array) { 18258 flattened.push(...row); 18259 } 18260 return flattened; 18261 } 18262 function reverseArray(array) { 18263 return array.slice().reverse(); 18264 } 18265 18266 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js 18267 var import_react20 = __toESM(require_react(), 1); 18268 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1); 18269 var TagName5 = "div"; 18270 function isGrid(items) { 18271 return items.some((item) => !!item.rowId); 18272 } 18273 function isPrintableKey(event) { 18274 const target = event.target; 18275 if (target && !isTextField(target)) return false; 18276 return event.key.length === 1 && !event.ctrlKey && !event.metaKey; 18277 } 18278 function isModifierKey(event) { 18279 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta"; 18280 } 18281 function useKeyboardEventProxy(store2, onKeyboardEvent, previousElementRef) { 18282 return useEvent((event) => { 18283 var _a; 18284 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event); 18285 if (event.defaultPrevented) return; 18286 if (event.isPropagationStopped()) return; 18287 if (!isSelfTarget(event)) return; 18288 if (isModifierKey(event)) return; 18289 if (isPrintableKey(event)) return; 18290 const state = store2.getState(); 18291 const activeElement2 = (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.element; 18292 if (!activeElement2) return; 18293 const { view, ...eventInit } = event; 18294 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current; 18295 if (activeElement2 !== previousElement) { 18296 activeElement2.focus(); 18297 } 18298 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) { 18299 event.preventDefault(); 18300 } 18301 if (event.currentTarget.contains(activeElement2)) { 18302 event.stopPropagation(); 18303 } 18304 }); 18305 } 18306 function findFirstEnabledItemInTheLastRow(items) { 18307 return findFirstEnabledItem( 18308 flatten2DArray(reverseArray(groupItemsByRows(items))) 18309 ); 18310 } 18311 function useScheduleFocus(store2) { 18312 const [scheduled, setScheduled] = (0, import_react20.useState)(false); 18313 const schedule = (0, import_react20.useCallback)(() => setScheduled(true), []); 18314 const activeItem = store2.useState( 18315 (state) => getEnabledItem(store2, state.activeId) 18316 ); 18317 (0, import_react20.useEffect)(() => { 18318 const activeElement2 = activeItem == null ? void 0 : activeItem.element; 18319 if (!scheduled) return; 18320 if (!activeElement2) return; 18321 setScheduled(false); 18322 activeElement2.focus({ preventScroll: true }); 18323 }, [activeItem, scheduled]); 18324 return schedule; 18325 } 18326 var useComposite = createHook( 18327 function useComposite2({ 18328 store: store2, 18329 composite = true, 18330 focusOnMove = composite, 18331 moveOnKeyPress = true, 18332 ...props 18333 }) { 18334 const context = useCompositeProviderContext(); 18335 store2 = store2 || context; 18336 invariant( 18337 store2, 18338 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component." 18339 ); 18340 const ref = (0, import_react20.useRef)(null); 18341 const previousElementRef = (0, import_react20.useRef)(null); 18342 const scheduleFocus = useScheduleFocus(store2); 18343 const moves = store2.useState("moves"); 18344 const [, setBaseElement] = useTransactionState( 18345 composite ? store2.setBaseElement : null 18346 ); 18347 (0, import_react20.useEffect)(() => { 18348 var _a; 18349 if (!store2) return; 18350 if (!moves) return; 18351 if (!composite) return; 18352 if (!focusOnMove) return; 18353 const { activeId: activeId2 } = store2.getState(); 18354 const itemElement = (_a = getEnabledItem(store2, activeId2)) == null ? void 0 : _a.element; 18355 if (!itemElement) return; 18356 focusIntoView(itemElement); 18357 }, [store2, moves, composite, focusOnMove]); 18358 useSafeLayoutEffect(() => { 18359 if (!store2) return; 18360 if (!moves) return; 18361 if (!composite) return; 18362 const { baseElement, activeId: activeId2 } = store2.getState(); 18363 const isSelfAcive = activeId2 === null; 18364 if (!isSelfAcive) return; 18365 if (!baseElement) return; 18366 const previousElement = previousElementRef.current; 18367 previousElementRef.current = null; 18368 if (previousElement) { 18369 fireBlurEvent(previousElement, { relatedTarget: baseElement }); 18370 } 18371 if (!hasFocus(baseElement)) { 18372 baseElement.focus(); 18373 } 18374 }, [store2, moves, composite]); 18375 const activeId = store2.useState("activeId"); 18376 const virtualFocus = store2.useState("virtualFocus"); 18377 useSafeLayoutEffect(() => { 18378 var _a; 18379 if (!store2) return; 18380 if (!composite) return; 18381 if (!virtualFocus) return; 18382 const previousElement = previousElementRef.current; 18383 previousElementRef.current = null; 18384 if (!previousElement) return; 18385 const activeElement2 = (_a = getEnabledItem(store2, activeId)) == null ? void 0 : _a.element; 18386 const relatedTarget = activeElement2 || getActiveElement(previousElement); 18387 if (relatedTarget === previousElement) return; 18388 fireBlurEvent(previousElement, { relatedTarget }); 18389 }, [store2, activeId, virtualFocus, composite]); 18390 const onKeyDownCapture = useKeyboardEventProxy( 18391 store2, 18392 props.onKeyDownCapture, 18393 previousElementRef 18394 ); 18395 const onKeyUpCapture = useKeyboardEventProxy( 18396 store2, 18397 props.onKeyUpCapture, 18398 previousElementRef 18399 ); 18400 const onFocusCaptureProp = props.onFocusCapture; 18401 const onFocusCapture = useEvent((event) => { 18402 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 18403 if (event.defaultPrevented) return; 18404 if (!store2) return; 18405 const { virtualFocus: virtualFocus2 } = store2.getState(); 18406 if (!virtualFocus2) return; 18407 const previousActiveElement = event.relatedTarget; 18408 const isSilentlyFocused = silentlyFocused(event.currentTarget); 18409 if (isSelfTarget(event) && isSilentlyFocused) { 18410 event.stopPropagation(); 18411 previousElementRef.current = previousActiveElement; 18412 } 18413 }); 18414 const onFocusProp = props.onFocus; 18415 const onFocus = useEvent((event) => { 18416 onFocusProp == null ? void 0 : onFocusProp(event); 18417 if (event.defaultPrevented) return; 18418 if (!composite) return; 18419 if (!store2) return; 18420 const { relatedTarget } = event; 18421 const { virtualFocus: virtualFocus2 } = store2.getState(); 18422 if (virtualFocus2) { 18423 if (isSelfTarget(event) && !isItem(store2, relatedTarget)) { 18424 queueMicrotask(scheduleFocus); 18425 } 18426 } else if (isSelfTarget(event)) { 18427 store2.setActiveId(null); 18428 } 18429 }); 18430 const onBlurCaptureProp = props.onBlurCapture; 18431 const onBlurCapture = useEvent((event) => { 18432 var _a; 18433 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 18434 if (event.defaultPrevented) return; 18435 if (!store2) return; 18436 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store2.getState(); 18437 if (!virtualFocus2) return; 18438 const activeElement2 = (_a = getEnabledItem(store2, activeId2)) == null ? void 0 : _a.element; 18439 const nextActiveElement = event.relatedTarget; 18440 const nextActiveElementIsItem = isItem(store2, nextActiveElement); 18441 const previousElement = previousElementRef.current; 18442 previousElementRef.current = null; 18443 if (isSelfTarget(event) && nextActiveElementIsItem) { 18444 if (nextActiveElement === activeElement2) { 18445 if (previousElement && previousElement !== nextActiveElement) { 18446 fireBlurEvent(previousElement, event); 18447 } 18448 } else if (activeElement2) { 18449 fireBlurEvent(activeElement2, event); 18450 } else if (previousElement) { 18451 fireBlurEvent(previousElement, event); 18452 } 18453 event.stopPropagation(); 18454 } else { 18455 const targetIsItem = isItem(store2, event.target); 18456 if (!targetIsItem && activeElement2) { 18457 fireBlurEvent(activeElement2, event); 18458 } 18459 } 18460 }); 18461 const onKeyDownProp = props.onKeyDown; 18462 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 18463 const onKeyDown = useEvent((event) => { 18464 var _a; 18465 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 18466 if (event.nativeEvent.isComposing) return; 18467 if (event.defaultPrevented) return; 18468 if (!store2) return; 18469 if (!isSelfTarget(event)) return; 18470 const { orientation, renderedItems, activeId: activeId2 } = store2.getState(); 18471 const activeItem = getEnabledItem(store2, activeId2); 18472 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return; 18473 const isVertical = orientation !== "horizontal"; 18474 const isHorizontal = orientation !== "vertical"; 18475 const grid = isGrid(renderedItems); 18476 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End"; 18477 if (isHorizontalKey && isTextField(event.currentTarget)) return; 18478 const up = () => { 18479 if (grid) { 18480 const item = findFirstEnabledItemInTheLastRow(renderedItems); 18481 return item == null ? void 0 : item.id; 18482 } 18483 return store2 == null ? void 0 : store2.last(); 18484 }; 18485 const keyMap = { 18486 ArrowUp: (grid || isVertical) && up, 18487 ArrowRight: (grid || isHorizontal) && store2.first, 18488 ArrowDown: (grid || isVertical) && store2.first, 18489 ArrowLeft: (grid || isHorizontal) && store2.last, 18490 Home: store2.first, 18491 End: store2.last, 18492 PageUp: store2.first, 18493 PageDown: store2.last 18494 }; 18495 const action = keyMap[event.key]; 18496 if (action) { 18497 const id = action(); 18498 if (id !== void 0) { 18499 if (!moveOnKeyPressProp(event)) return; 18500 event.preventDefault(); 18501 store2.move(id); 18502 } 18503 } 18504 }); 18505 props = useWrapElement( 18506 props, 18507 (element) => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(CompositeContextProvider, { value: store2, children: element }), 18508 [store2] 18509 ); 18510 const activeDescendant = store2.useState((state) => { 18511 var _a; 18512 if (!store2) return; 18513 if (!composite) return; 18514 if (!state.virtualFocus) return; 18515 return (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.id; 18516 }); 18517 props = { 18518 "aria-activedescendant": activeDescendant, 18519 ...props, 18520 ref: useMergeRefs(ref, setBaseElement, props.ref), 18521 onKeyDownCapture, 18522 onKeyUpCapture, 18523 onFocusCapture, 18524 onFocus, 18525 onBlurCapture, 18526 onKeyDown 18527 }; 18528 const focusable2 = store2.useState( 18529 (state) => composite && (state.virtualFocus || state.activeId === null) 18530 ); 18531 props = useFocusable({ focusable: focusable2, ...props }); 18532 return props; 18533 } 18534 ); 18535 var Composite5 = forwardRef210(function Composite22(props) { 18536 const htmlProps = useComposite(props); 18537 return createElement3(TagName5, htmlProps); 18538 }); 18539 18540 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js 18541 var ctx3 = createStoreContext(); 18542 var useDisclosureContext = ctx3.useContext; 18543 var useDisclosureScopedContext = ctx3.useScopedContext; 18544 var useDisclosureProviderContext = ctx3.useProviderContext; 18545 var DisclosureContextProvider = ctx3.ContextProvider; 18546 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider; 18547 18548 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js 18549 var import_react21 = __toESM(require_react(), 1); 18550 var ctx4 = createStoreContext( 18551 [DisclosureContextProvider], 18552 [DisclosureScopedContextProvider] 18553 ); 18554 var useDialogContext = ctx4.useContext; 18555 var useDialogScopedContext = ctx4.useScopedContext; 18556 var useDialogProviderContext = ctx4.useProviderContext; 18557 var DialogContextProvider = ctx4.ContextProvider; 18558 var DialogScopedContextProvider = ctx4.ScopedContextProvider; 18559 var DialogHeadingContext = (0, import_react21.createContext)(void 0); 18560 var DialogDescriptionContext = (0, import_react21.createContext)(void 0); 18561 18562 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js 18563 var import_react22 = __toESM(require_react(), 1); 18564 var import_react_dom4 = __toESM(require_react_dom(), 1); 18565 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1); 18566 var TagName6 = "div"; 18567 function afterTimeout(timeoutMs, cb) { 18568 const timeoutId = setTimeout(cb, timeoutMs); 18569 return () => clearTimeout(timeoutId); 18570 } 18571 function afterPaint2(cb) { 18572 let raf = requestAnimationFrame(() => { 18573 raf = requestAnimationFrame(cb); 18574 }); 18575 return () => cancelAnimationFrame(raf); 18576 } 18577 function parseCSSTime(...times) { 18578 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => { 18579 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3; 18580 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier; 18581 if (currentTime > longestTime) return currentTime; 18582 return longestTime; 18583 }, 0); 18584 } 18585 function isHidden(mounted, hidden, alwaysVisible) { 18586 return !alwaysVisible && hidden !== false && (!mounted || !!hidden); 18587 } 18588 var useDisclosureContent = createHook(function useDisclosureContent2({ store: store2, alwaysVisible, ...props }) { 18589 const context = useDisclosureProviderContext(); 18590 store2 = store2 || context; 18591 invariant( 18592 store2, 18593 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component." 18594 ); 18595 const ref = (0, import_react22.useRef)(null); 18596 const id = useId5(props.id); 18597 const [transition, setTransition] = (0, import_react22.useState)(null); 18598 const open = store2.useState("open"); 18599 const mounted = store2.useState("mounted"); 18600 const animated = store2.useState("animated"); 18601 const contentElement = store2.useState("contentElement"); 18602 const otherElement = useStoreState(store2.disclosure, "contentElement"); 18603 useSafeLayoutEffect(() => { 18604 if (!ref.current) return; 18605 store2 == null ? void 0 : store2.setContentElement(ref.current); 18606 }, [store2]); 18607 useSafeLayoutEffect(() => { 18608 let previousAnimated; 18609 store2 == null ? void 0 : store2.setState("animated", (animated2) => { 18610 previousAnimated = animated2; 18611 return true; 18612 }); 18613 return () => { 18614 if (previousAnimated === void 0) return; 18615 store2 == null ? void 0 : store2.setState("animated", previousAnimated); 18616 }; 18617 }, [store2]); 18618 useSafeLayoutEffect(() => { 18619 if (!animated) return; 18620 if (!(contentElement == null ? void 0 : contentElement.isConnected)) { 18621 setTransition(null); 18622 return; 18623 } 18624 return afterPaint2(() => { 18625 setTransition(open ? "enter" : mounted ? "leave" : null); 18626 }); 18627 }, [animated, contentElement, open, mounted]); 18628 useSafeLayoutEffect(() => { 18629 if (!store2) return; 18630 if (!animated) return; 18631 if (!transition) return; 18632 if (!contentElement) return; 18633 const stopAnimation = () => store2 == null ? void 0 : store2.setState("animating", false); 18634 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation); 18635 if (transition === "leave" && open) return; 18636 if (transition === "enter" && !open) return; 18637 if (typeof animated === "number") { 18638 const timeout2 = animated; 18639 return afterTimeout(timeout2, stopAnimationSync); 18640 } 18641 const { 18642 transitionDuration, 18643 animationDuration, 18644 transitionDelay, 18645 animationDelay 18646 } = getComputedStyle(contentElement); 18647 const { 18648 transitionDuration: transitionDuration2 = "0", 18649 animationDuration: animationDuration2 = "0", 18650 transitionDelay: transitionDelay2 = "0", 18651 animationDelay: animationDelay2 = "0" 18652 } = otherElement ? getComputedStyle(otherElement) : {}; 18653 const delay = parseCSSTime( 18654 transitionDelay, 18655 animationDelay, 18656 transitionDelay2, 18657 animationDelay2 18658 ); 18659 const duration = parseCSSTime( 18660 transitionDuration, 18661 animationDuration, 18662 transitionDuration2, 18663 animationDuration2 18664 ); 18665 const timeout = delay + duration; 18666 if (!timeout) { 18667 if (transition === "enter") { 18668 store2.setState("animated", false); 18669 } 18670 stopAnimation(); 18671 return; 18672 } 18673 const frameRate = 1e3 / 60; 18674 const maxTimeout = Math.max(timeout - frameRate, 0); 18675 return afterTimeout(maxTimeout, stopAnimationSync); 18676 }, [store2, animated, contentElement, otherElement, open, transition]); 18677 props = useWrapElement( 18678 props, 18679 (element) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(DialogScopedContextProvider, { value: store2, children: element }), 18680 [store2] 18681 ); 18682 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 18683 const styleProp = props.style; 18684 const style = (0, import_react22.useMemo)(() => { 18685 if (hidden) { 18686 return { ...styleProp, display: "none" }; 18687 } 18688 return styleProp; 18689 }, [hidden, styleProp]); 18690 props = { 18691 id, 18692 "data-open": open || void 0, 18693 "data-enter": transition === "enter" || void 0, 18694 "data-leave": transition === "leave" || void 0, 18695 hidden, 18696 ...props, 18697 ref: useMergeRefs(id ? store2.setContentElement : null, ref, props.ref), 18698 style 18699 }; 18700 return removeUndefinedValues(props); 18701 }); 18702 var DisclosureContentImpl = forwardRef210(function DisclosureContentImpl2(props) { 18703 const htmlProps = useDisclosureContent(props); 18704 return createElement3(TagName6, htmlProps); 18705 }); 18706 var DisclosureContent = forwardRef210(function DisclosureContent2({ 18707 unmountOnHide, 18708 ...props 18709 }) { 18710 const context = useDisclosureProviderContext(); 18711 const store2 = props.store || context; 18712 const mounted = useStoreState( 18713 store2, 18714 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted) 18715 ); 18716 if (mounted === false) return null; 18717 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(DisclosureContentImpl, { ...props }); 18718 }); 18719 18720 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js 18721 function createDisclosureStore(props = {}) { 18722 const store2 = mergeStore( 18723 props.store, 18724 omit2(props.disclosure, ["contentElement", "disclosureElement"]) 18725 ); 18726 throwOnConflictingProps(props, store2); 18727 const syncState = store2 == null ? void 0 : store2.getState(); 18728 const open = defaultValue( 18729 props.open, 18730 syncState == null ? void 0 : syncState.open, 18731 props.defaultOpen, 18732 false 18733 ); 18734 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false); 18735 const initialState = { 18736 open, 18737 animated, 18738 animating: !!animated && open, 18739 mounted: open, 18740 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null), 18741 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null) 18742 }; 18743 const disclosure = createStore(initialState, store2); 18744 setup( 18745 disclosure, 18746 () => sync(disclosure, ["animated", "animating"], (state) => { 18747 if (state.animated) return; 18748 disclosure.setState("animating", false); 18749 }) 18750 ); 18751 setup( 18752 disclosure, 18753 () => subscribe(disclosure, ["open"], () => { 18754 if (!disclosure.getState().animated) return; 18755 disclosure.setState("animating", true); 18756 }) 18757 ); 18758 setup( 18759 disclosure, 18760 () => sync(disclosure, ["open", "animating"], (state) => { 18761 disclosure.setState("mounted", state.open || state.animating); 18762 }) 18763 ); 18764 return { 18765 ...disclosure, 18766 disclosure: props.disclosure, 18767 setOpen: (value) => disclosure.setState("open", value), 18768 show: () => disclosure.setState("open", true), 18769 hide: () => disclosure.setState("open", false), 18770 toggle: () => disclosure.setState("open", (open2) => !open2), 18771 stopAnimation: () => disclosure.setState("animating", false), 18772 setContentElement: (value) => disclosure.setState("contentElement", value), 18773 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value) 18774 }; 18775 } 18776 18777 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js 18778 function useDisclosureStoreProps(store2, update2, props) { 18779 useUpdateEffect(update2, [props.store, props.disclosure]); 18780 useStoreProps(store2, props, "open", "setOpen"); 18781 useStoreProps(store2, props, "mounted", "setMounted"); 18782 useStoreProps(store2, props, "animated"); 18783 return Object.assign(store2, { disclosure: props.disclosure }); 18784 } 18785 18786 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js 18787 var ctx5 = createStoreContext( 18788 [DialogContextProvider], 18789 [DialogScopedContextProvider] 18790 ); 18791 var usePopoverContext = ctx5.useContext; 18792 var usePopoverScopedContext = ctx5.useScopedContext; 18793 var usePopoverProviderContext = ctx5.useProviderContext; 18794 var PopoverContextProvider = ctx5.ContextProvider; 18795 var PopoverScopedContextProvider = ctx5.ScopedContextProvider; 18796 18797 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js 18798 function getCommonParent(items) { 18799 var _a; 18800 const firstItem = items.find((item) => !!item.element); 18801 const lastItem = [...items].reverse().find((item) => !!item.element); 18802 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement; 18803 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) { 18804 const parent = parentElement; 18805 if (lastItem && parent.contains(lastItem.element)) { 18806 return parentElement; 18807 } 18808 parentElement = parentElement.parentElement; 18809 } 18810 return getDocument(parentElement).body; 18811 } 18812 function getPrivateStore(store2) { 18813 return store2 == null ? void 0 : store2.__unstablePrivateStore; 18814 } 18815 function createCollectionStore(props = {}) { 18816 var _a; 18817 throwOnConflictingProps(props, props.store); 18818 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 18819 const items = defaultValue( 18820 props.items, 18821 syncState == null ? void 0 : syncState.items, 18822 props.defaultItems, 18823 [] 18824 ); 18825 const itemsMap = new Map(items.map((item) => [item.id, item])); 18826 const initialState = { 18827 items, 18828 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, []) 18829 }; 18830 const syncPrivateStore = getPrivateStore(props.store); 18831 const privateStore = createStore( 18832 { items, renderedItems: initialState.renderedItems }, 18833 syncPrivateStore 18834 ); 18835 const collection = createStore(initialState, props.store); 18836 const sortItems = (renderedItems) => { 18837 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element); 18838 privateStore.setState("renderedItems", sortedItems); 18839 collection.setState("renderedItems", sortedItems); 18840 }; 18841 setup(collection, () => init(privateStore)); 18842 setup(privateStore, () => { 18843 return batch(privateStore, ["items"], (state) => { 18844 collection.setState("items", state.items); 18845 }); 18846 }); 18847 setup(privateStore, () => { 18848 return batch(privateStore, ["renderedItems"], (state) => { 18849 let firstRun = true; 18850 let raf = requestAnimationFrame(() => { 18851 const { renderedItems } = collection.getState(); 18852 if (state.renderedItems === renderedItems) return; 18853 sortItems(state.renderedItems); 18854 }); 18855 if (typeof IntersectionObserver !== "function") { 18856 return () => cancelAnimationFrame(raf); 18857 } 18858 const ioCallback = () => { 18859 if (firstRun) { 18860 firstRun = false; 18861 return; 18862 } 18863 cancelAnimationFrame(raf); 18864 raf = requestAnimationFrame(() => sortItems(state.renderedItems)); 18865 }; 18866 const root = getCommonParent(state.renderedItems); 18867 const observer = new IntersectionObserver(ioCallback, { root }); 18868 for (const item of state.renderedItems) { 18869 if (!item.element) continue; 18870 observer.observe(item.element); 18871 } 18872 return () => { 18873 cancelAnimationFrame(raf); 18874 observer.disconnect(); 18875 }; 18876 }); 18877 }); 18878 const mergeItem = (item, setItems, canDeleteFromMap = false) => { 18879 let prevItem; 18880 setItems((items2) => { 18881 const index2 = items2.findIndex(({ id }) => id === item.id); 18882 const nextItems = items2.slice(); 18883 if (index2 !== -1) { 18884 prevItem = items2[index2]; 18885 const nextItem = { ...prevItem, ...item }; 18886 nextItems[index2] = nextItem; 18887 itemsMap.set(item.id, nextItem); 18888 } else { 18889 nextItems.push(item); 18890 itemsMap.set(item.id, item); 18891 } 18892 return nextItems; 18893 }); 18894 const unmergeItem = () => { 18895 setItems((items2) => { 18896 if (!prevItem) { 18897 if (canDeleteFromMap) { 18898 itemsMap.delete(item.id); 18899 } 18900 return items2.filter(({ id }) => id !== item.id); 18901 } 18902 const index2 = items2.findIndex(({ id }) => id === item.id); 18903 if (index2 === -1) return items2; 18904 const nextItems = items2.slice(); 18905 nextItems[index2] = prevItem; 18906 itemsMap.set(item.id, prevItem); 18907 return nextItems; 18908 }); 18909 }; 18910 return unmergeItem; 18911 }; 18912 const registerItem = (item) => mergeItem( 18913 item, 18914 (getItems) => privateStore.setState("items", getItems), 18915 true 18916 ); 18917 return { 18918 ...collection, 18919 registerItem, 18920 renderItem: (item) => chain( 18921 registerItem(item), 18922 mergeItem( 18923 item, 18924 (getItems) => privateStore.setState("renderedItems", getItems) 18925 ) 18926 ), 18927 item: (id) => { 18928 if (!id) return null; 18929 let item = itemsMap.get(id); 18930 if (!item) { 18931 const { items: items2 } = privateStore.getState(); 18932 item = items2.find((item2) => item2.id === id); 18933 if (item) { 18934 itemsMap.set(id, item); 18935 } 18936 } 18937 return item || null; 18938 }, 18939 // @ts-expect-error Internal 18940 __unstablePrivateStore: privateStore 18941 }; 18942 } 18943 18944 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js 18945 function useCollectionStoreProps(store2, update2, props) { 18946 useUpdateEffect(update2, [props.store]); 18947 useStoreProps(store2, props, "items", "setItems"); 18948 return store2; 18949 } 18950 18951 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js 18952 var NULL_ITEM = { id: null }; 18953 function findFirstEnabledItem2(items, excludeId) { 18954 return items.find((item) => { 18955 if (excludeId) { 18956 return !item.disabled && item.id !== excludeId; 18957 } 18958 return !item.disabled; 18959 }); 18960 } 18961 function getEnabledItems(items, excludeId) { 18962 return items.filter((item) => { 18963 if (excludeId) { 18964 return !item.disabled && item.id !== excludeId; 18965 } 18966 return !item.disabled; 18967 }); 18968 } 18969 function getItemsInRow(items, rowId) { 18970 return items.filter((item) => item.rowId === rowId); 18971 } 18972 function flipItems(items, activeId, shouldInsertNullItem = false) { 18973 const index2 = items.findIndex((item) => item.id === activeId); 18974 return [ 18975 ...items.slice(index2 + 1), 18976 ...shouldInsertNullItem ? [NULL_ITEM] : [], 18977 ...items.slice(0, index2) 18978 ]; 18979 } 18980 function groupItemsByRows2(items) { 18981 const rows = []; 18982 for (const item of items) { 18983 const row = rows.find((currentRow) => { 18984 var _a; 18985 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 18986 }); 18987 if (row) { 18988 row.push(item); 18989 } else { 18990 rows.push([item]); 18991 } 18992 } 18993 return rows; 18994 } 18995 function getMaxRowLength(array) { 18996 let maxLength = 0; 18997 for (const { length } of array) { 18998 if (length > maxLength) { 18999 maxLength = length; 19000 } 19001 } 19002 return maxLength; 19003 } 19004 function createEmptyItem(rowId) { 19005 return { 19006 id: "__EMPTY_ITEM__", 19007 disabled: true, 19008 rowId 19009 }; 19010 } 19011 function normalizeRows(rows, activeId, focusShift) { 19012 const maxLength = getMaxRowLength(rows); 19013 for (const row of rows) { 19014 for (let i2 = 0; i2 < maxLength; i2 += 1) { 19015 const item = row[i2]; 19016 if (!item || focusShift && item.disabled) { 19017 const isFirst = i2 === 0; 19018 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1]; 19019 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId); 19020 } 19021 } 19022 } 19023 return rows; 19024 } 19025 function verticalizeItems(items) { 19026 const rows = groupItemsByRows2(items); 19027 const maxLength = getMaxRowLength(rows); 19028 const verticalized = []; 19029 for (let i2 = 0; i2 < maxLength; i2 += 1) { 19030 for (const row of rows) { 19031 const item = row[i2]; 19032 if (item) { 19033 verticalized.push({ 19034 ...item, 19035 // If there's no rowId, it means that it's not a grid composite, but 19036 // a single row instead. So, instead of verticalizing it, that is, 19037 // assigning a different rowId based on the column index, we keep it 19038 // undefined so they will be part of the same row. This is useful 19039 // when using up/down on one-dimensional composites. 19040 rowId: item.rowId ? `$i2}` : void 0 19041 }); 19042 } 19043 } 19044 } 19045 return verticalized; 19046 } 19047 function createCompositeStore(props = {}) { 19048 var _a; 19049 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 19050 const collection = createCollectionStore(props); 19051 const activeId = defaultValue( 19052 props.activeId, 19053 syncState == null ? void 0 : syncState.activeId, 19054 props.defaultActiveId 19055 ); 19056 const initialState = { 19057 ...collection.getState(), 19058 id: defaultValue( 19059 props.id, 19060 syncState == null ? void 0 : syncState.id, 19061 `id-$Math.random().toString(36).slice(2, 8)}` 19062 ), 19063 activeId, 19064 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null), 19065 includesBaseElement: defaultValue( 19066 props.includesBaseElement, 19067 syncState == null ? void 0 : syncState.includesBaseElement, 19068 activeId === null 19069 ), 19070 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0), 19071 orientation: defaultValue( 19072 props.orientation, 19073 syncState == null ? void 0 : syncState.orientation, 19074 "both" 19075 ), 19076 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false), 19077 virtualFocus: defaultValue( 19078 props.virtualFocus, 19079 syncState == null ? void 0 : syncState.virtualFocus, 19080 false 19081 ), 19082 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false), 19083 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false), 19084 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false) 19085 }; 19086 const composite = createStore(initialState, collection, props.store); 19087 setup( 19088 composite, 19089 () => sync(composite, ["renderedItems", "activeId"], (state) => { 19090 composite.setState("activeId", (activeId2) => { 19091 var _a2; 19092 if (activeId2 !== void 0) return activeId2; 19093 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id; 19094 }); 19095 }) 19096 ); 19097 const getNextId = (direction = "next", options = {}) => { 19098 var _a2, _b; 19099 const defaultState = composite.getState(); 19100 const { 19101 skip = 0, 19102 activeId: activeId2 = defaultState.activeId, 19103 focusShift = defaultState.focusShift, 19104 focusLoop = defaultState.focusLoop, 19105 focusWrap = defaultState.focusWrap, 19106 includesBaseElement = defaultState.includesBaseElement, 19107 renderedItems = defaultState.renderedItems, 19108 rtl = defaultState.rtl 19109 } = options; 19110 const isVerticalDirection = direction === "up" || direction === "down"; 19111 const isNextDirection = direction === "next" || direction === "down"; 19112 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection; 19113 const canShift = focusShift && !skip; 19114 let items = !isVerticalDirection ? renderedItems : flatten2DArray( 19115 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift) 19116 ); 19117 items = canReverse ? reverseArray(items) : items; 19118 items = isVerticalDirection ? verticalizeItems(items) : items; 19119 if (activeId2 == null) { 19120 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id; 19121 } 19122 const activeItem = items.find((item) => item.id === activeId2); 19123 if (!activeItem) { 19124 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id; 19125 } 19126 const isGrid2 = items.some((item) => item.rowId); 19127 const activeIndex = items.indexOf(activeItem); 19128 const nextItems = items.slice(activeIndex + 1); 19129 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId); 19130 if (skip) { 19131 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2); 19132 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one. 19133 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1]; 19134 return nextItem2 == null ? void 0 : nextItem2.id; 19135 } 19136 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"); 19137 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical"); 19138 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false; 19139 if (canLoop) { 19140 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId); 19141 const sortedItems = flipItems(loopItems, activeId2, hasNullItem); 19142 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2); 19143 return nextItem2 == null ? void 0 : nextItem2.id; 19144 } 19145 if (canWrap) { 19146 const nextItem2 = findFirstEnabledItem2( 19147 // We can use nextItems, which contains all the next items, including 19148 // items from other rows, to wrap between rows. However, if there is a 19149 // null item (the composite container), we'll only use the next items in 19150 // the row. So moving next from the last item will focus on the 19151 // composite container. On grid composites, horizontal navigation never 19152 // focuses on the composite container, only vertical. 19153 hasNullItem ? nextItemsInRow : nextItems, 19154 activeId2 19155 ); 19156 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id; 19157 return nextId; 19158 } 19159 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2); 19160 if (!nextItem && hasNullItem) { 19161 return null; 19162 } 19163 return nextItem == null ? void 0 : nextItem.id; 19164 }; 19165 return { 19166 ...collection, 19167 ...composite, 19168 setBaseElement: (element) => composite.setState("baseElement", element), 19169 setActiveId: (id) => composite.setState("activeId", id), 19170 move: (id) => { 19171 if (id === void 0) return; 19172 composite.setState("activeId", id); 19173 composite.setState("moves", (moves) => moves + 1); 19174 }, 19175 first: () => { 19176 var _a2; 19177 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id; 19178 }, 19179 last: () => { 19180 var _a2; 19181 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id; 19182 }, 19183 next: (options) => { 19184 if (options !== void 0 && typeof options === "number") { 19185 options = { skip: options }; 19186 } 19187 return getNextId("next", options); 19188 }, 19189 previous: (options) => { 19190 if (options !== void 0 && typeof options === "number") { 19191 options = { skip: options }; 19192 } 19193 return getNextId("previous", options); 19194 }, 19195 down: (options) => { 19196 if (options !== void 0 && typeof options === "number") { 19197 options = { skip: options }; 19198 } 19199 return getNextId("down", options); 19200 }, 19201 up: (options) => { 19202 if (options !== void 0 && typeof options === "number") { 19203 options = { skip: options }; 19204 } 19205 return getNextId("up", options); 19206 } 19207 }; 19208 } 19209 19210 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js 19211 function useCompositeStoreOptions(props) { 19212 const id = useId5(props.id); 19213 return { id, ...props }; 19214 } 19215 function useCompositeStoreProps(store2, update2, props) { 19216 store2 = useCollectionStoreProps(store2, update2, props); 19217 useStoreProps(store2, props, "activeId", "setActiveId"); 19218 useStoreProps(store2, props, "includesBaseElement"); 19219 useStoreProps(store2, props, "virtualFocus"); 19220 useStoreProps(store2, props, "orientation"); 19221 useStoreProps(store2, props, "rtl"); 19222 useStoreProps(store2, props, "focusLoop"); 19223 useStoreProps(store2, props, "focusWrap"); 19224 useStoreProps(store2, props, "focusShift"); 19225 return store2; 19226 } 19227 19228 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js 19229 var import_react23 = __toESM(require_react(), 1); 19230 var ComboboxListRoleContext = (0, import_react23.createContext)( 19231 void 0 19232 ); 19233 var ctx6 = createStoreContext( 19234 [PopoverContextProvider, CompositeContextProvider], 19235 [PopoverScopedContextProvider, CompositeScopedContextProvider] 19236 ); 19237 var useComboboxContext = ctx6.useContext; 19238 var useComboboxScopedContext = ctx6.useScopedContext; 19239 var useComboboxProviderContext = ctx6.useProviderContext; 19240 var ComboboxContextProvider = ctx6.ContextProvider; 19241 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider; 19242 var ComboboxItemValueContext = (0, import_react23.createContext)( 19243 void 0 19244 ); 19245 var ComboboxItemCheckedContext = (0, import_react23.createContext)(false); 19246 19247 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js 19248 function createDialogStore(props = {}) { 19249 return createDisclosureStore(props); 19250 } 19251 19252 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js 19253 function useDialogStoreProps(store2, update2, props) { 19254 return useDisclosureStoreProps(store2, update2, props); 19255 } 19256 19257 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js 19258 function createPopoverStore({ 19259 popover: otherPopover, 19260 ...props 19261 } = {}) { 19262 const store2 = mergeStore( 19263 props.store, 19264 omit2(otherPopover, [ 19265 "arrowElement", 19266 "anchorElement", 19267 "contentElement", 19268 "popoverElement", 19269 "disclosureElement" 19270 ]) 19271 ); 19272 throwOnConflictingProps(props, store2); 19273 const syncState = store2 == null ? void 0 : store2.getState(); 19274 const dialog = createDialogStore({ ...props, store: store2 }); 19275 const placement = defaultValue( 19276 props.placement, 19277 syncState == null ? void 0 : syncState.placement, 19278 "bottom" 19279 ); 19280 const initialState = { 19281 ...dialog.getState(), 19282 placement, 19283 currentPlacement: placement, 19284 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null), 19285 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null), 19286 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null), 19287 rendered: /* @__PURE__ */ Symbol("rendered") 19288 }; 19289 const popover = createStore(initialState, dialog, store2); 19290 return { 19291 ...dialog, 19292 ...popover, 19293 setAnchorElement: (element) => popover.setState("anchorElement", element), 19294 setPopoverElement: (element) => popover.setState("popoverElement", element), 19295 setArrowElement: (element) => popover.setState("arrowElement", element), 19296 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered")) 19297 }; 19298 } 19299 19300 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js 19301 function usePopoverStoreProps(store2, update2, props) { 19302 useUpdateEffect(update2, [props.popover]); 19303 useStoreProps(store2, props, "placement"); 19304 return useDialogStoreProps(store2, update2, props); 19305 } 19306 19307 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js 19308 var TagName7 = "div"; 19309 var usePopoverAnchor = createHook( 19310 function usePopoverAnchor2({ store: store2, ...props }) { 19311 const context = usePopoverProviderContext(); 19312 store2 = store2 || context; 19313 props = { 19314 ...props, 19315 ref: useMergeRefs(store2 == null ? void 0 : store2.setAnchorElement, props.ref) 19316 }; 19317 return props; 19318 } 19319 ); 19320 var PopoverAnchor = forwardRef210(function PopoverAnchor2(props) { 19321 const htmlProps = usePopoverAnchor(props); 19322 return createElement3(TagName7, htmlProps); 19323 }); 19324 19325 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js 19326 var import_react24 = __toESM(require_react(), 1); 19327 var TagName8 = "div"; 19328 function getMouseDestination(event) { 19329 const relatedTarget = event.relatedTarget; 19330 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) { 19331 return relatedTarget; 19332 } 19333 return null; 19334 } 19335 function hoveringInside(event) { 19336 const nextElement = getMouseDestination(event); 19337 if (!nextElement) return false; 19338 return contains2(event.currentTarget, nextElement); 19339 } 19340 var symbol2 = /* @__PURE__ */ Symbol("composite-hover"); 19341 function movingToAnotherItem(event) { 19342 let dest = getMouseDestination(event); 19343 if (!dest) return false; 19344 do { 19345 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true; 19346 dest = dest.parentElement; 19347 } while (dest); 19348 return false; 19349 } 19350 var useCompositeHover = createHook( 19351 function useCompositeHover2({ 19352 store: store2, 19353 focusOnHover = true, 19354 blurOnHoverEnd = !!focusOnHover, 19355 ...props 19356 }) { 19357 const context = useCompositeContext(); 19358 store2 = store2 || context; 19359 invariant( 19360 store2, 19361 "CompositeHover must be wrapped in a Composite component." 19362 ); 19363 const isMouseMoving = useIsMouseMoving(); 19364 const onMouseMoveProp = props.onMouseMove; 19365 const focusOnHoverProp = useBooleanEvent(focusOnHover); 19366 const onMouseMove = useEvent((event) => { 19367 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event); 19368 if (event.defaultPrevented) return; 19369 if (!isMouseMoving()) return; 19370 if (!focusOnHoverProp(event)) return; 19371 if (!hasFocusWithin(event.currentTarget)) { 19372 const baseElement = store2 == null ? void 0 : store2.getState().baseElement; 19373 if (baseElement && !hasFocus(baseElement)) { 19374 baseElement.focus(); 19375 } 19376 } 19377 store2 == null ? void 0 : store2.setActiveId(event.currentTarget.id); 19378 }); 19379 const onMouseLeaveProp = props.onMouseLeave; 19380 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd); 19381 const onMouseLeave = useEvent((event) => { 19382 var _a; 19383 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event); 19384 if (event.defaultPrevented) return; 19385 if (!isMouseMoving()) return; 19386 if (hoveringInside(event)) return; 19387 if (movingToAnotherItem(event)) return; 19388 if (!focusOnHoverProp(event)) return; 19389 if (!blurOnHoverEndProp(event)) return; 19390 store2 == null ? void 0 : store2.setActiveId(null); 19391 (_a = store2 == null ? void 0 : store2.getState().baseElement) == null ? void 0 : _a.focus(); 19392 }); 19393 const ref = (0, import_react24.useCallback)((element) => { 19394 if (!element) return; 19395 element[symbol2] = true; 19396 }, []); 19397 props = { 19398 ...props, 19399 ref: useMergeRefs(ref, props.ref), 19400 onMouseMove, 19401 onMouseLeave 19402 }; 19403 return removeUndefinedValues(props); 19404 } 19405 ); 19406 var CompositeHover = memo22( 19407 forwardRef210(function CompositeHover2(props) { 19408 const htmlProps = useCompositeHover(props); 19409 return createElement3(TagName8, htmlProps); 19410 }) 19411 ); 19412 19413 // node_modules/@ariakit/react-core/esm/combobox/combobox.js 19414 var import_react25 = __toESM(require_react(), 1); 19415 var TagName9 = "input"; 19416 function isFirstItemAutoSelected(items, activeValue, autoSelect) { 19417 if (!autoSelect) return false; 19418 const firstItem = items.find((item) => !item.disabled && item.value); 19419 return (firstItem == null ? void 0 : firstItem.value) === activeValue; 19420 } 19421 function hasCompletionString(value, activeValue) { 19422 if (!activeValue) return false; 19423 if (value == null) return false; 19424 value = normalizeString(value); 19425 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0; 19426 } 19427 function isInputEvent(event) { 19428 return event.type === "input"; 19429 } 19430 function isAriaAutoCompleteValue(value) { 19431 return value === "inline" || value === "list" || value === "both" || value === "none"; 19432 } 19433 function getDefaultAutoSelectId(items) { 19434 const item = items.find((item2) => { 19435 var _a; 19436 if (item2.disabled) return false; 19437 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab"; 19438 }); 19439 return item == null ? void 0 : item.id; 19440 } 19441 var useCombobox = createHook( 19442 function useCombobox2({ 19443 store: store2, 19444 focusable: focusable2 = true, 19445 autoSelect: autoSelectProp = false, 19446 getAutoSelectId, 19447 setValueOnChange, 19448 showMinLength = 0, 19449 showOnChange, 19450 showOnMouseDown, 19451 showOnClick = showOnMouseDown, 19452 showOnKeyDown, 19453 showOnKeyPress = showOnKeyDown, 19454 blurActiveItemOnClick, 19455 setValueOnClick = true, 19456 moveOnKeyPress = true, 19457 autoComplete = "list", 19458 ...props 19459 }) { 19460 const context = useComboboxProviderContext(); 19461 store2 = store2 || context; 19462 invariant( 19463 store2, 19464 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component." 19465 ); 19466 const ref = (0, import_react25.useRef)(null); 19467 const [valueUpdated, forceValueUpdate] = useForceUpdate(); 19468 const canAutoSelectRef = (0, import_react25.useRef)(false); 19469 const composingRef = (0, import_react25.useRef)(false); 19470 const autoSelect = store2.useState( 19471 (state) => state.virtualFocus && autoSelectProp 19472 ); 19473 const inline4 = autoComplete === "inline" || autoComplete === "both"; 19474 const [canInline, setCanInline] = (0, import_react25.useState)(inline4); 19475 useUpdateLayoutEffect(() => { 19476 if (!inline4) return; 19477 setCanInline(true); 19478 }, [inline4]); 19479 const storeValue = store2.useState("value"); 19480 const prevSelectedValueRef = (0, import_react25.useRef)(void 0); 19481 (0, import_react25.useEffect)(() => { 19482 return sync(store2, ["selectedValue", "activeId"], (_, prev) => { 19483 prevSelectedValueRef.current = prev.selectedValue; 19484 }); 19485 }, []); 19486 const inlineActiveValue = store2.useState((state) => { 19487 var _a; 19488 if (!inline4) return; 19489 if (!canInline) return; 19490 if (state.activeValue && Array.isArray(state.selectedValue)) { 19491 if (state.selectedValue.includes(state.activeValue)) return; 19492 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return; 19493 } 19494 return state.activeValue; 19495 }); 19496 const items = store2.useState("renderedItems"); 19497 const open = store2.useState("open"); 19498 const contentElement = store2.useState("contentElement"); 19499 const value = (0, import_react25.useMemo)(() => { 19500 if (!inline4) return storeValue; 19501 if (!canInline) return storeValue; 19502 const firstItemAutoSelected = isFirstItemAutoSelected( 19503 items, 19504 inlineActiveValue, 19505 autoSelect 19506 ); 19507 if (firstItemAutoSelected) { 19508 if (hasCompletionString(storeValue, inlineActiveValue)) { 19509 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || ""; 19510 return storeValue + slice; 19511 } 19512 return storeValue; 19513 } 19514 return inlineActiveValue || storeValue; 19515 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]); 19516 (0, import_react25.useEffect)(() => { 19517 const element = ref.current; 19518 if (!element) return; 19519 const onCompositeItemMove = () => setCanInline(true); 19520 element.addEventListener("combobox-item-move", onCompositeItemMove); 19521 return () => { 19522 element.removeEventListener("combobox-item-move", onCompositeItemMove); 19523 }; 19524 }, []); 19525 (0, import_react25.useEffect)(() => { 19526 if (!inline4) return; 19527 if (!canInline) return; 19528 if (!inlineActiveValue) return; 19529 const firstItemAutoSelected = isFirstItemAutoSelected( 19530 items, 19531 inlineActiveValue, 19532 autoSelect 19533 ); 19534 if (!firstItemAutoSelected) return; 19535 if (!hasCompletionString(storeValue, inlineActiveValue)) return; 19536 let cleanup = noop4; 19537 queueMicrotask(() => { 19538 const element = ref.current; 19539 if (!element) return; 19540 const { start: prevStart, end: prevEnd } = getTextboxSelection(element); 19541 const nextStart = storeValue.length; 19542 const nextEnd = inlineActiveValue.length; 19543 setSelectionRange(element, nextStart, nextEnd); 19544 cleanup = () => { 19545 if (!hasFocus(element)) return; 19546 const { start, end } = getTextboxSelection(element); 19547 if (start !== nextStart) return; 19548 if (end !== nextEnd) return; 19549 setSelectionRange(element, prevStart, prevEnd); 19550 }; 19551 }); 19552 return () => cleanup(); 19553 }, [ 19554 valueUpdated, 19555 inline4, 19556 canInline, 19557 inlineActiveValue, 19558 items, 19559 autoSelect, 19560 storeValue 19561 ]); 19562 const scrollingElementRef = (0, import_react25.useRef)(null); 19563 const getAutoSelectIdProp = useEvent(getAutoSelectId); 19564 const autoSelectIdRef = (0, import_react25.useRef)(null); 19565 (0, import_react25.useEffect)(() => { 19566 if (!open) return; 19567 if (!contentElement) return; 19568 const scrollingElement = getScrollingElement(contentElement); 19569 if (!scrollingElement) return; 19570 scrollingElementRef.current = scrollingElement; 19571 const onUserScroll = () => { 19572 canAutoSelectRef.current = false; 19573 }; 19574 const onScroll = () => { 19575 if (!store2) return; 19576 if (!canAutoSelectRef.current) return; 19577 const { activeId } = store2.getState(); 19578 if (activeId === null) return; 19579 if (activeId === autoSelectIdRef.current) return; 19580 canAutoSelectRef.current = false; 19581 }; 19582 const options = { passive: true, capture: true }; 19583 scrollingElement.addEventListener("wheel", onUserScroll, options); 19584 scrollingElement.addEventListener("touchmove", onUserScroll, options); 19585 scrollingElement.addEventListener("scroll", onScroll, options); 19586 return () => { 19587 scrollingElement.removeEventListener("wheel", onUserScroll, true); 19588 scrollingElement.removeEventListener("touchmove", onUserScroll, true); 19589 scrollingElement.removeEventListener("scroll", onScroll, true); 19590 }; 19591 }, [open, contentElement, store2]); 19592 useSafeLayoutEffect(() => { 19593 if (!storeValue) return; 19594 if (composingRef.current) return; 19595 canAutoSelectRef.current = true; 19596 }, [storeValue]); 19597 useSafeLayoutEffect(() => { 19598 if (autoSelect !== "always" && open) return; 19599 canAutoSelectRef.current = open; 19600 }, [autoSelect, open]); 19601 const resetValueOnSelect = store2.useState("resetValueOnSelect"); 19602 useUpdateEffect(() => { 19603 var _a, _b; 19604 const canAutoSelect = canAutoSelectRef.current; 19605 if (!store2) return; 19606 if (!open) return; 19607 if (!canAutoSelect && !resetValueOnSelect) return; 19608 const { baseElement, contentElement: contentElement2, activeId } = store2.getState(); 19609 if (baseElement && !hasFocus(baseElement)) return; 19610 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) { 19611 const observer = new MutationObserver(forceValueUpdate); 19612 observer.observe(contentElement2, { attributeFilter: ["data-placing"] }); 19613 return () => observer.disconnect(); 19614 } 19615 if (autoSelect && canAutoSelect) { 19616 const userAutoSelectId = getAutoSelectIdProp(items); 19617 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store2.first(); 19618 autoSelectIdRef.current = autoSelectId; 19619 store2.move(autoSelectId != null ? autoSelectId : null); 19620 } else { 19621 const element = (_b = store2.item(activeId || store2.first())) == null ? void 0 : _b.element; 19622 if (element && "scrollIntoView" in element) { 19623 element.scrollIntoView({ block: "nearest", inline: "nearest" }); 19624 } 19625 } 19626 return; 19627 }, [ 19628 store2, 19629 open, 19630 valueUpdated, 19631 storeValue, 19632 autoSelect, 19633 resetValueOnSelect, 19634 getAutoSelectIdProp, 19635 items 19636 ]); 19637 (0, import_react25.useEffect)(() => { 19638 if (!inline4) return; 19639 const combobox = ref.current; 19640 if (!combobox) return; 19641 const elements = [combobox, contentElement].filter( 19642 (value2) => !!value2 19643 ); 19644 const onBlur2 = (event) => { 19645 if (elements.every((el) => isFocusEventOutside(event, el))) { 19646 store2 == null ? void 0 : store2.setValue(value); 19647 } 19648 }; 19649 for (const element of elements) { 19650 element.addEventListener("focusout", onBlur2); 19651 } 19652 return () => { 19653 for (const element of elements) { 19654 element.removeEventListener("focusout", onBlur2); 19655 } 19656 }; 19657 }, [inline4, contentElement, store2, value]); 19658 const canShow = (event) => { 19659 const currentTarget = event.currentTarget; 19660 return currentTarget.value.length >= showMinLength; 19661 }; 19662 const onChangeProp = props.onChange; 19663 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow); 19664 const setValueOnChangeProp = useBooleanEvent( 19665 // If the combobox is combined with tags, the value will be set by the tag 19666 // input component. 19667 setValueOnChange != null ? setValueOnChange : !store2.tag 19668 ); 19669 const onChange = useEvent((event) => { 19670 onChangeProp == null ? void 0 : onChangeProp(event); 19671 if (event.defaultPrevented) return; 19672 if (!store2) return; 19673 const currentTarget = event.currentTarget; 19674 const { value: value2, selectionStart, selectionEnd } = currentTarget; 19675 const nativeEvent = event.nativeEvent; 19676 canAutoSelectRef.current = true; 19677 if (isInputEvent(nativeEvent)) { 19678 if (nativeEvent.isComposing) { 19679 canAutoSelectRef.current = false; 19680 composingRef.current = true; 19681 } 19682 if (inline4) { 19683 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText"; 19684 const caretAtEnd = selectionStart === value2.length; 19685 setCanInline(textInserted && caretAtEnd); 19686 } 19687 } 19688 if (setValueOnChangeProp(event)) { 19689 const isSameValue = value2 === store2.getState().value; 19690 store2.setValue(value2); 19691 queueMicrotask(() => { 19692 setSelectionRange(currentTarget, selectionStart, selectionEnd); 19693 }); 19694 if (inline4 && autoSelect && isSameValue) { 19695 forceValueUpdate(); 19696 } 19697 } 19698 if (showOnChangeProp(event)) { 19699 store2.show(); 19700 } 19701 if (!autoSelect || !canAutoSelectRef.current) { 19702 store2.setActiveId(null); 19703 } 19704 }); 19705 const onCompositionEndProp = props.onCompositionEnd; 19706 const onCompositionEnd = useEvent((event) => { 19707 canAutoSelectRef.current = true; 19708 composingRef.current = false; 19709 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event); 19710 if (event.defaultPrevented) return; 19711 if (!autoSelect) return; 19712 forceValueUpdate(); 19713 }); 19714 const onMouseDownProp = props.onMouseDown; 19715 const blurActiveItemOnClickProp = useBooleanEvent( 19716 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store2 == null ? void 0 : store2.getState().includesBaseElement)) 19717 ); 19718 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 19719 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow); 19720 const onMouseDown = useEvent((event) => { 19721 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 19722 if (event.defaultPrevented) return; 19723 if (event.button) return; 19724 if (event.ctrlKey) return; 19725 if (!store2) return; 19726 if (blurActiveItemOnClickProp(event)) { 19727 store2.setActiveId(null); 19728 } 19729 if (setValueOnClickProp(event)) { 19730 store2.setValue(value); 19731 } 19732 if (showOnClickProp(event)) { 19733 queueBeforeEvent(event.currentTarget, "mouseup", store2.show); 19734 } 19735 }); 19736 const onKeyDownProp = props.onKeyDown; 19737 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow); 19738 const onKeyDown = useEvent((event) => { 19739 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 19740 if (!event.repeat) { 19741 canAutoSelectRef.current = false; 19742 } 19743 if (event.defaultPrevented) return; 19744 if (event.ctrlKey) return; 19745 if (event.altKey) return; 19746 if (event.shiftKey) return; 19747 if (event.metaKey) return; 19748 if (!store2) return; 19749 const { open: open2 } = store2.getState(); 19750 if (open2) return; 19751 if (event.key === "ArrowUp" || event.key === "ArrowDown") { 19752 if (showOnKeyPressProp(event)) { 19753 event.preventDefault(); 19754 store2.show(); 19755 } 19756 } 19757 }); 19758 const onBlurProp = props.onBlur; 19759 const onBlur = useEvent((event) => { 19760 canAutoSelectRef.current = false; 19761 onBlurProp == null ? void 0 : onBlurProp(event); 19762 if (event.defaultPrevented) return; 19763 }); 19764 const id = useId5(props.id); 19765 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0; 19766 const isActiveItem = store2.useState((state) => state.activeId === null); 19767 props = { 19768 id, 19769 role: "combobox", 19770 "aria-autocomplete": ariaAutoComplete, 19771 "aria-haspopup": getPopupRole(contentElement, "listbox"), 19772 "aria-expanded": open, 19773 "aria-controls": contentElement == null ? void 0 : contentElement.id, 19774 "data-active-item": isActiveItem || void 0, 19775 value, 19776 ...props, 19777 ref: useMergeRefs(ref, props.ref), 19778 onChange, 19779 onCompositionEnd, 19780 onMouseDown, 19781 onKeyDown, 19782 onBlur 19783 }; 19784 props = useComposite({ 19785 store: store2, 19786 focusable: focusable2, 19787 ...props, 19788 // Enable inline autocomplete when the user moves from the combobox input 19789 // to an item. 19790 moveOnKeyPress: (event) => { 19791 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false; 19792 if (inline4) setCanInline(true); 19793 return true; 19794 } 19795 }); 19796 props = usePopoverAnchor({ store: store2, ...props }); 19797 return { autoComplete: "off", ...props }; 19798 } 19799 ); 19800 var Combobox = forwardRef210(function Combobox2(props) { 19801 const htmlProps = useCombobox(props); 19802 return createElement3(TagName9, htmlProps); 19803 }); 19804 19805 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js 19806 var import_react26 = __toESM(require_react(), 1); 19807 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1); 19808 var TagName10 = "div"; 19809 function isSelected(storeValue, itemValue) { 19810 if (itemValue == null) return; 19811 if (storeValue == null) return false; 19812 if (Array.isArray(storeValue)) { 19813 return storeValue.includes(itemValue); 19814 } 19815 return storeValue === itemValue; 19816 } 19817 function getItemRole(popupRole) { 19818 var _a; 19819 const itemRoleByPopupRole = { 19820 menu: "menuitem", 19821 listbox: "option", 19822 tree: "treeitem" 19823 }; 19824 const key = popupRole; 19825 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option"; 19826 } 19827 var useComboboxItem = createHook( 19828 function useComboboxItem2({ 19829 store: store2, 19830 value, 19831 hideOnClick, 19832 setValueOnClick, 19833 selectValueOnClick = true, 19834 resetValueOnSelect, 19835 focusOnHover = false, 19836 moveOnKeyPress = true, 19837 getItem: getItemProp, 19838 ...props 19839 }) { 19840 var _a; 19841 const context = useComboboxScopedContext(); 19842 store2 = store2 || context; 19843 invariant( 19844 store2, 19845 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component." 19846 ); 19847 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store2, { 19848 resetValueOnSelectState: "resetValueOnSelect", 19849 multiSelectable(state) { 19850 return Array.isArray(state.selectedValue); 19851 }, 19852 selected(state) { 19853 return isSelected(state.selectedValue, value); 19854 } 19855 }); 19856 const getItem = (0, import_react26.useCallback)( 19857 (item) => { 19858 const nextItem = { ...item, value }; 19859 if (getItemProp) { 19860 return getItemProp(nextItem); 19861 } 19862 return nextItem; 19863 }, 19864 [value, getItemProp] 19865 ); 19866 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable; 19867 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable; 19868 const onClickProp = props.onClick; 19869 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 19870 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick); 19871 const resetValueOnSelectProp = useBooleanEvent( 19872 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable 19873 ); 19874 const hideOnClickProp = useBooleanEvent(hideOnClick); 19875 const onClick = useEvent((event) => { 19876 onClickProp == null ? void 0 : onClickProp(event); 19877 if (event.defaultPrevented) return; 19878 if (isDownloading(event)) return; 19879 if (isOpeningInNewTab(event)) return; 19880 if (value != null) { 19881 if (selectValueOnClickProp(event)) { 19882 if (resetValueOnSelectProp(event)) { 19883 store2 == null ? void 0 : store2.resetValue(); 19884 } 19885 store2 == null ? void 0 : store2.setSelectedValue((prevValue) => { 19886 if (!Array.isArray(prevValue)) return value; 19887 if (prevValue.includes(value)) { 19888 return prevValue.filter((v2) => v2 !== value); 19889 } 19890 return [...prevValue, value]; 19891 }); 19892 } 19893 if (setValueOnClickProp(event)) { 19894 store2 == null ? void 0 : store2.setValue(value); 19895 } 19896 } 19897 if (hideOnClickProp(event)) { 19898 store2 == null ? void 0 : store2.hide(); 19899 } 19900 }); 19901 const onKeyDownProp = props.onKeyDown; 19902 const onKeyDown = useEvent((event) => { 19903 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 19904 if (event.defaultPrevented) return; 19905 const baseElement = store2 == null ? void 0 : store2.getState().baseElement; 19906 if (!baseElement) return; 19907 if (hasFocus(baseElement)) return; 19908 const printable = event.key.length === 1; 19909 if (printable || event.key === "Backspace" || event.key === "Delete") { 19910 queueMicrotask(() => baseElement.focus()); 19911 if (isTextField(baseElement)) { 19912 store2 == null ? void 0 : store2.setValue(baseElement.value); 19913 } 19914 } 19915 }); 19916 if (multiSelectable && selected != null) { 19917 props = { 19918 "aria-selected": selected, 19919 ...props 19920 }; 19921 } 19922 props = useWrapElement( 19923 props, 19924 (element) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }), 19925 [value, selected] 19926 ); 19927 const popupRole = (0, import_react26.useContext)(ComboboxListRoleContext); 19928 props = { 19929 role: getItemRole(popupRole), 19930 children: value, 19931 ...props, 19932 onClick, 19933 onKeyDown 19934 }; 19935 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 19936 props = useCompositeItem({ 19937 store: store2, 19938 ...props, 19939 getItem, 19940 // Dispatch a custom event on the combobox input when moving to an item 19941 // with the keyboard so the Combobox component can enable inline 19942 // autocompletion. 19943 moveOnKeyPress: (event) => { 19944 if (!moveOnKeyPressProp(event)) return false; 19945 const moveEvent = new Event("combobox-item-move"); 19946 const baseElement = store2 == null ? void 0 : store2.getState().baseElement; 19947 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent); 19948 return true; 19949 } 19950 }); 19951 props = useCompositeHover({ store: store2, focusOnHover, ...props }); 19952 return props; 19953 } 19954 ); 19955 var ComboboxItem = memo22( 19956 forwardRef210(function ComboboxItem2(props) { 19957 const htmlProps = useComboboxItem(props); 19958 return createElement3(TagName10, htmlProps); 19959 }) 19960 ); 19961 19962 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js 19963 var import_react27 = __toESM(require_react(), 1); 19964 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1); 19965 var TagName11 = "span"; 19966 function normalizeValue(value) { 19967 return normalizeString(value).toLowerCase(); 19968 } 19969 function getOffsets(string, values) { 19970 const offsets = []; 19971 for (const value of values) { 19972 let pos = 0; 19973 const length = value.length; 19974 while (string.indexOf(value, pos) !== -1) { 19975 const index2 = string.indexOf(value, pos); 19976 if (index2 !== -1) { 19977 offsets.push([index2, length]); 19978 } 19979 pos = index2 + 1; 19980 } 19981 } 19982 return offsets; 19983 } 19984 function filterOverlappingOffsets(offsets) { 19985 return offsets.filter(([offset4, length], i2, arr) => { 19986 return !arr.some( 19987 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length 19988 ); 19989 }); 19990 } 19991 function sortOffsets(offsets) { 19992 return offsets.sort(([a2], [b2]) => a2 - b2); 19993 } 19994 function splitValue(itemValue, userValue) { 19995 if (!itemValue) return itemValue; 19996 if (!userValue) return itemValue; 19997 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue); 19998 const parts = []; 19999 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 20000 "span", 20001 { 20002 "data-autocomplete-value": autocomplete ? "" : void 0, 20003 "data-user-value": autocomplete ? void 0 : "", 20004 children: value 20005 }, 20006 parts.length 20007 ); 20008 const offsets = sortOffsets( 20009 filterOverlappingOffsets( 20010 // Convert userValues into a set to avoid duplicates 20011 getOffsets(normalizeValue(itemValue), new Set(userValues)) 20012 ) 20013 ); 20014 if (!offsets.length) { 20015 parts.push(span(itemValue, true)); 20016 return parts; 20017 } 20018 const [firstOffset] = offsets[0]; 20019 const values = [ 20020 itemValue.slice(0, firstOffset), 20021 ...offsets.flatMap(([offset4, length], i2) => { 20022 var _a; 20023 const value = itemValue.slice(offset4, offset4 + length); 20024 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0]; 20025 const nextValue = itemValue.slice(offset4 + length, nextOffset); 20026 return [value, nextValue]; 20027 }) 20028 ]; 20029 values.forEach((value, i2) => { 20030 if (!value) return; 20031 parts.push(span(value, i2 % 2 === 0)); 20032 }); 20033 return parts; 20034 } 20035 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store: store2, value, userValue, ...props }) { 20036 const context = useComboboxScopedContext(); 20037 store2 = store2 || context; 20038 const itemContext = (0, import_react27.useContext)(ComboboxItemValueContext); 20039 const itemValue = value != null ? value : itemContext; 20040 const inputValue = useStoreState(store2, (state) => userValue != null ? userValue : state == null ? void 0 : state.value); 20041 const children = (0, import_react27.useMemo)(() => { 20042 if (!itemValue) return; 20043 if (!inputValue) return itemValue; 20044 return splitValue(itemValue, inputValue); 20045 }, [itemValue, inputValue]); 20046 props = { 20047 children, 20048 ...props 20049 }; 20050 return removeUndefinedValues(props); 20051 }); 20052 var ComboboxItemValue = forwardRef210(function ComboboxItemValue2(props) { 20053 const htmlProps = useComboboxItemValue(props); 20054 return createElement3(TagName11, htmlProps); 20055 }); 20056 20057 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js 20058 var TagName12 = "label"; 20059 var useComboboxLabel = createHook( 20060 function useComboboxLabel2({ store: store2, ...props }) { 20061 const context = useComboboxProviderContext(); 20062 store2 = store2 || context; 20063 invariant( 20064 store2, 20065 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component." 20066 ); 20067 const comboboxId = store2.useState((state) => { 20068 var _a; 20069 return (_a = state.baseElement) == null ? void 0 : _a.id; 20070 }); 20071 props = { 20072 htmlFor: comboboxId, 20073 ...props 20074 }; 20075 return removeUndefinedValues(props); 20076 } 20077 ); 20078 var ComboboxLabel = memo22( 20079 forwardRef210(function ComboboxLabel2(props) { 20080 const htmlProps = useComboboxLabel(props); 20081 return createElement3(TagName12, htmlProps); 20082 }) 20083 ); 20084 20085 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js 20086 var import_react28 = __toESM(require_react(), 1); 20087 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1); 20088 var TagName13 = "div"; 20089 var useComboboxList = createHook( 20090 function useComboboxList2({ store: store2, alwaysVisible, ...props }) { 20091 const scopedContext = useComboboxScopedContext(true); 20092 const context = useComboboxContext(); 20093 store2 = store2 || context; 20094 const scopedContextSameStore = !!store2 && store2 === scopedContext; 20095 invariant( 20096 store2, 20097 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component." 20098 ); 20099 const ref = (0, import_react28.useRef)(null); 20100 const id = useId5(props.id); 20101 const mounted = store2.useState("mounted"); 20102 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 20103 const style = hidden ? { ...props.style, display: "none" } : props.style; 20104 const multiSelectable = store2.useState( 20105 (state) => Array.isArray(state.selectedValue) 20106 ); 20107 const role = useAttribute(ref, "role", props.role); 20108 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid"; 20109 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0; 20110 const [hasListboxInside, setHasListboxInside] = (0, import_react28.useState)(false); 20111 const contentElement = store2.useState("contentElement"); 20112 useSafeLayoutEffect(() => { 20113 if (!mounted) return; 20114 const element = ref.current; 20115 if (!element) return; 20116 if (contentElement !== element) return; 20117 const callback = () => { 20118 setHasListboxInside(!!element.querySelector("[role='listbox']")); 20119 }; 20120 const observer = new MutationObserver(callback); 20121 observer.observe(element, { 20122 subtree: true, 20123 childList: true, 20124 attributeFilter: ["role"] 20125 }); 20126 callback(); 20127 return () => observer.disconnect(); 20128 }, [mounted, contentElement]); 20129 if (!hasListboxInside) { 20130 props = { 20131 role: "listbox", 20132 "aria-multiselectable": ariaMultiSelectable, 20133 ...props 20134 }; 20135 } 20136 props = useWrapElement( 20137 props, 20138 (element) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(ComboboxScopedContextProvider, { value: store2, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }), 20139 [store2, role] 20140 ); 20141 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store2.setContentElement : null; 20142 props = { 20143 id, 20144 hidden, 20145 ...props, 20146 ref: useMergeRefs(setContentElement, ref, props.ref), 20147 style 20148 }; 20149 return removeUndefinedValues(props); 20150 } 20151 ); 20152 var ComboboxList = forwardRef210(function ComboboxList2(props) { 20153 const htmlProps = useComboboxList(props); 20154 return createElement3(TagName13, htmlProps); 20155 }); 20156 20157 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js 20158 var import_react29 = __toESM(require_react(), 1); 20159 var TagValueContext = (0, import_react29.createContext)(null); 20160 var TagRemoveIdContext = (0, import_react29.createContext)( 20161 null 20162 ); 20163 var ctx7 = createStoreContext( 20164 [CompositeContextProvider], 20165 [CompositeScopedContextProvider] 20166 ); 20167 var useTagContext = ctx7.useContext; 20168 var useTagScopedContext = ctx7.useScopedContext; 20169 var useTagProviderContext = ctx7.useProviderContext; 20170 var TagContextProvider = ctx7.ContextProvider; 20171 var TagScopedContextProvider = ctx7.ScopedContextProvider; 20172 20173 // node_modules/@ariakit/core/esm/combobox/combobox-store.js 20174 var isTouchSafari = isSafari2() && isTouchDevice(); 20175 function createComboboxStore({ 20176 tag, 20177 ...props 20178 } = {}) { 20179 const store2 = mergeStore(props.store, pick2(tag, ["value", "rtl"])); 20180 throwOnConflictingProps(props, store2); 20181 const tagState = tag == null ? void 0 : tag.getState(); 20182 const syncState = store2 == null ? void 0 : store2.getState(); 20183 const activeId = defaultValue( 20184 props.activeId, 20185 syncState == null ? void 0 : syncState.activeId, 20186 props.defaultActiveId, 20187 null 20188 ); 20189 const composite = createCompositeStore({ 20190 ...props, 20191 activeId, 20192 includesBaseElement: defaultValue( 20193 props.includesBaseElement, 20194 syncState == null ? void 0 : syncState.includesBaseElement, 20195 true 20196 ), 20197 orientation: defaultValue( 20198 props.orientation, 20199 syncState == null ? void 0 : syncState.orientation, 20200 "vertical" 20201 ), 20202 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true), 20203 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true), 20204 virtualFocus: defaultValue( 20205 props.virtualFocus, 20206 syncState == null ? void 0 : syncState.virtualFocus, 20207 true 20208 ) 20209 }); 20210 const popover = createPopoverStore({ 20211 ...props, 20212 placement: defaultValue( 20213 props.placement, 20214 syncState == null ? void 0 : syncState.placement, 20215 "bottom-start" 20216 ) 20217 }); 20218 const value = defaultValue( 20219 props.value, 20220 syncState == null ? void 0 : syncState.value, 20221 props.defaultValue, 20222 "" 20223 ); 20224 const selectedValue = defaultValue( 20225 props.selectedValue, 20226 syncState == null ? void 0 : syncState.selectedValue, 20227 tagState == null ? void 0 : tagState.values, 20228 props.defaultSelectedValue, 20229 "" 20230 ); 20231 const multiSelectable = Array.isArray(selectedValue); 20232 const initialState = { 20233 ...composite.getState(), 20234 ...popover.getState(), 20235 value, 20236 selectedValue, 20237 resetValueOnSelect: defaultValue( 20238 props.resetValueOnSelect, 20239 syncState == null ? void 0 : syncState.resetValueOnSelect, 20240 multiSelectable 20241 ), 20242 resetValueOnHide: defaultValue( 20243 props.resetValueOnHide, 20244 syncState == null ? void 0 : syncState.resetValueOnHide, 20245 multiSelectable && !tag 20246 ), 20247 activeValue: syncState == null ? void 0 : syncState.activeValue 20248 }; 20249 const combobox = createStore(initialState, composite, popover, store2); 20250 if (isTouchSafari) { 20251 setup( 20252 combobox, 20253 () => sync(combobox, ["virtualFocus"], () => { 20254 combobox.setState("virtualFocus", false); 20255 }) 20256 ); 20257 } 20258 setup(combobox, () => { 20259 if (!tag) return; 20260 return chain( 20261 sync(combobox, ["selectedValue"], (state) => { 20262 if (!Array.isArray(state.selectedValue)) return; 20263 tag.setValues(state.selectedValue); 20264 }), 20265 sync(tag, ["values"], (state) => { 20266 combobox.setState("selectedValue", state.values); 20267 }) 20268 ); 20269 }); 20270 setup( 20271 combobox, 20272 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => { 20273 if (!state.resetValueOnHide) return; 20274 if (state.mounted) return; 20275 combobox.setState("value", value); 20276 }) 20277 ); 20278 setup( 20279 combobox, 20280 () => sync(combobox, ["open"], (state) => { 20281 if (state.open) return; 20282 combobox.setState("activeId", activeId); 20283 combobox.setState("moves", 0); 20284 }) 20285 ); 20286 setup( 20287 combobox, 20288 () => sync(combobox, ["moves", "activeId"], (state, prevState) => { 20289 if (state.moves === prevState.moves) { 20290 combobox.setState("activeValue", void 0); 20291 } 20292 }) 20293 ); 20294 setup( 20295 combobox, 20296 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => { 20297 if (state.moves === prev.moves) return; 20298 const { activeId: activeId2 } = combobox.getState(); 20299 const activeItem = composite.item(activeId2); 20300 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value); 20301 }) 20302 ); 20303 return { 20304 ...popover, 20305 ...composite, 20306 ...combobox, 20307 tag, 20308 setValue: (value2) => combobox.setState("value", value2), 20309 resetValue: () => combobox.setState("value", initialState.value), 20310 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2) 20311 }; 20312 } 20313 20314 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js 20315 function useComboboxStoreOptions(props) { 20316 const tag = useTagContext(); 20317 props = { 20318 ...props, 20319 tag: props.tag !== void 0 ? props.tag : tag 20320 }; 20321 return useCompositeStoreOptions(props); 20322 } 20323 function useComboboxStoreProps(store2, update2, props) { 20324 useUpdateEffect(update2, [props.tag]); 20325 useStoreProps(store2, props, "value", "setValue"); 20326 useStoreProps(store2, props, "selectedValue", "setSelectedValue"); 20327 useStoreProps(store2, props, "resetValueOnHide"); 20328 useStoreProps(store2, props, "resetValueOnSelect"); 20329 return Object.assign( 20330 useCompositeStoreProps( 20331 usePopoverStoreProps(store2, update2, props), 20332 update2, 20333 props 20334 ), 20335 { tag: props.tag } 20336 ); 20337 } 20338 function useComboboxStore(props = {}) { 20339 props = useComboboxStoreOptions(props); 20340 const [store2, update2] = useStore2(createComboboxStore, props); 20341 return useComboboxStoreProps(store2, update2, props); 20342 } 20343 20344 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js 20345 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1); 20346 function ComboboxProvider(props = {}) { 20347 const store2 = useComboboxStore(props); 20348 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ComboboxContextProvider, { value: store2, children: props.children }); 20349 } 20350 20351 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs 20352 var import_remove_accents = __toESM(require_remove_accents(), 1); 20353 var import_compose7 = __toESM(require_compose(), 1); 20354 var import_i18n22 = __toESM(require_i18n(), 1); 20355 var import_element55 = __toESM(require_element(), 1); 20356 var import_components20 = __toESM(require_components(), 1); 20357 20358 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs 20359 var EMPTY_ARRAY3 = []; 20360 var getCurrentValue = (filterDefinition, currentFilter) => { 20361 if (filterDefinition.singleSelection) { 20362 return currentFilter?.value; 20363 } 20364 if (Array.isArray(currentFilter?.value)) { 20365 return currentFilter.value; 20366 } 20367 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) { 20368 return [currentFilter.value]; 20369 } 20370 return EMPTY_ARRAY3; 20371 }; 20372 20373 // packages/dataviews/build-module/hooks/use-elements.mjs 20374 var import_element54 = __toESM(require_element(), 1); 20375 var EMPTY_ARRAY4 = []; 20376 function useElements({ 20377 elements, 20378 getElements 20379 }) { 20380 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4; 20381 const [records, setRecords] = (0, import_element54.useState)(staticElements); 20382 const [isLoading, setIsLoading] = (0, import_element54.useState)(false); 20383 (0, import_element54.useEffect)(() => { 20384 if (!getElements) { 20385 setRecords(staticElements); 20386 return; 20387 } 20388 let cancelled = false; 20389 setIsLoading(true); 20390 getElements().then((fetchedElements) => { 20391 if (!cancelled) { 20392 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements; 20393 setRecords(dynamicElements); 20394 } 20395 }).catch(() => { 20396 if (!cancelled) { 20397 setRecords(staticElements); 20398 } 20399 }).finally(() => { 20400 if (!cancelled) { 20401 setIsLoading(false); 20402 } 20403 }); 20404 return () => { 20405 cancelled = true; 20406 }; 20407 }, [getElements, staticElements]); 20408 return { 20409 elements: records, 20410 isLoading 20411 }; 20412 } 20413 20414 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs 20415 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1); 20416 function normalizeSearchInput(input = "") { 20417 return (0, import_remove_accents.default)(input.trim().toLowerCase()); 20418 } 20419 var getNewValue = (filterDefinition, currentFilter, value) => { 20420 if (filterDefinition.singleSelection) { 20421 return value; 20422 } 20423 if (Array.isArray(currentFilter?.value)) { 20424 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value]; 20425 } 20426 return [value]; 20427 }; 20428 function generateFilterElementCompositeItemId(prefix, filterElementValue) { 20429 return `$prefix}-$filterElementValue}`; 20430 } 20431 var MultiSelectionOption = ({ selected }) => { 20432 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20433 "span", 20434 { 20435 className: clsx_default( 20436 "dataviews-filters__search-widget-listitem-multi-selection", 20437 { "is-selected": selected } 20438 ), 20439 children: selected && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components20.Icon, { icon: check_default }) 20440 } 20441 ); 20442 }; 20443 var SingleSelectionOption = ({ selected }) => { 20444 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20445 "span", 20446 { 20447 className: clsx_default( 20448 "dataviews-filters__search-widget-listitem-single-selection", 20449 { "is-selected": selected } 20450 ) 20451 } 20452 ); 20453 }; 20454 function ListBox({ view, filter, onChangeView }) { 20455 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box"); 20456 const [activeCompositeId, setActiveCompositeId] = (0, import_element55.useState)( 20457 // When there are one or less operators, the first item is set as active 20458 // (by setting the initial `activeId` to `undefined`). 20459 // With 2 or more operators, the focus is moved on the operators control 20460 // (by setting the initial `activeId` to `null`), meaning that there won't 20461 // be an active item initially. Focus is then managed via the 20462 // `onFocusVisible` callback. 20463 filter.operators?.length === 1 ? void 0 : null 20464 ); 20465 const currentFilter = view.filters?.find( 20466 (f2) => f2.field === filter.field 20467 ); 20468 const currentValue = getCurrentValue(filter, currentFilter); 20469 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20470 import_components20.Composite, 20471 { 20472 virtualFocus: true, 20473 focusLoop: true, 20474 activeId: activeCompositeId, 20475 setActiveId: setActiveCompositeId, 20476 role: "listbox", 20477 className: "dataviews-filters__search-widget-listbox", 20478 "aria-label": (0, import_i18n22.sprintf)( 20479 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */ 20480 (0, import_i18n22.__)("List of: %1$s"), 20481 filter.name 20482 ), 20483 onFocusVisible: () => { 20484 if (!activeCompositeId && filter.elements.length) { 20485 setActiveCompositeId( 20486 generateFilterElementCompositeItemId( 20487 baseId, 20488 filter.elements[0].value 20489 ) 20490 ); 20491 } 20492 }, 20493 render: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components20.Composite.Typeahead, {}), 20494 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 20495 import_components20.Composite.Hover, 20496 { 20497 render: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20498 import_components20.Composite.Item, 20499 { 20500 id: generateFilterElementCompositeItemId( 20501 baseId, 20502 element.value 20503 ), 20504 render: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20505 "div", 20506 { 20507 "aria-label": element.label, 20508 role: "option", 20509 className: "dataviews-filters__search-widget-listitem" 20510 } 20511 ), 20512 onClick: () => { 20513 const newFilters = currentFilter ? [ 20514 ...(view.filters ?? []).map( 20515 (_filter) => { 20516 if (_filter.field === filter.field) { 20517 return { 20518 ..._filter, 20519 operator: currentFilter.operator || filter.operators[0], 20520 value: getNewValue( 20521 filter, 20522 currentFilter, 20523 element.value 20524 ) 20525 }; 20526 } 20527 return _filter; 20528 } 20529 ) 20530 ] : [ 20531 ...view.filters ?? [], 20532 { 20533 field: filter.field, 20534 operator: filter.operators[0], 20535 value: getNewValue( 20536 filter, 20537 currentFilter, 20538 element.value 20539 ) 20540 } 20541 ]; 20542 onChangeView({ 20543 ...view, 20544 page: 1, 20545 filters: newFilters 20546 }); 20547 } 20548 } 20549 ), 20550 children: [ 20551 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20552 SingleSelectionOption, 20553 { 20554 selected: currentValue === element.value 20555 } 20556 ), 20557 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20558 MultiSelectionOption, 20559 { 20560 selected: currentValue.includes(element.value) 20561 } 20562 ), 20563 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20564 "span", 20565 { 20566 className: "dataviews-filters__search-widget-listitem-value", 20567 title: element.label, 20568 children: element.label 20569 } 20570 ) 20571 ] 20572 }, 20573 element.value 20574 )) 20575 } 20576 ); 20577 } 20578 function ComboboxList22({ view, filter, onChangeView }) { 20579 const [searchValue, setSearchValue] = (0, import_element55.useState)(""); 20580 const deferredSearchValue = (0, import_element55.useDeferredValue)(searchValue); 20581 const currentFilter = view.filters?.find( 20582 (_filter) => _filter.field === filter.field 20583 ); 20584 const currentValue = getCurrentValue(filter, currentFilter); 20585 const matches = (0, import_element55.useMemo)(() => { 20586 const normalizedSearch = normalizeSearchInput(deferredSearchValue); 20587 return filter.elements.filter( 20588 (item) => normalizeSearchInput(item.label).includes(normalizedSearch) 20589 ); 20590 }, [filter.elements, deferredSearchValue]); 20591 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 20592 ComboboxProvider, 20593 { 20594 selectedValue: currentValue, 20595 setSelectedValue: (value) => { 20596 const newFilters = currentFilter ? [ 20597 ...(view.filters ?? []).map((_filter) => { 20598 if (_filter.field === filter.field) { 20599 return { 20600 ..._filter, 20601 operator: currentFilter.operator || filter.operators[0], 20602 value 20603 }; 20604 } 20605 return _filter; 20606 }) 20607 ] : [ 20608 ...view.filters ?? [], 20609 { 20610 field: filter.field, 20611 operator: filter.operators[0], 20612 value 20613 } 20614 ]; 20615 onChangeView({ 20616 ...view, 20617 page: 1, 20618 filters: newFilters 20619 }); 20620 }, 20621 setValue: setSearchValue, 20622 children: [ 20623 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [ 20624 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ComboboxLabel, {}), children: (0, import_i18n22.__)("Search items") }), 20625 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20626 Combobox, 20627 { 20628 autoSelect: "always", 20629 placeholder: (0, import_i18n22.__)("Search"), 20630 className: "dataviews-filters__search-widget-filter-combobox__input" 20631 } 20632 ), 20633 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components20.Icon, { icon: search_default }) }) 20634 ] }), 20635 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 20636 ComboboxList, 20637 { 20638 className: "dataviews-filters__search-widget-filter-combobox-list", 20639 alwaysVisible: true, 20640 children: [ 20641 matches.map((element) => { 20642 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 20643 ComboboxItem, 20644 { 20645 resetValueOnSelect: false, 20646 value: element.value, 20647 className: "dataviews-filters__search-widget-listitem", 20648 hideOnClick: false, 20649 setValueOnClick: false, 20650 focusOnHover: true, 20651 children: [ 20652 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20653 SingleSelectionOption, 20654 { 20655 selected: currentValue === element.value 20656 } 20657 ), 20658 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20659 MultiSelectionOption, 20660 { 20661 selected: currentValue.includes( 20662 element.value 20663 ) 20664 } 20665 ), 20666 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 20667 "span", 20668 { 20669 className: "dataviews-filters__search-widget-listitem-value", 20670 title: element.label, 20671 children: [ 20672 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 20673 ComboboxItemValue, 20674 { 20675 className: "dataviews-filters__search-widget-filter-combobox-item-value", 20676 value: element.label 20677 } 20678 ), 20679 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description }) 20680 ] 20681 } 20682 ) 20683 ] 20684 }, 20685 element.value 20686 ); 20687 }), 20688 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("p", { children: (0, import_i18n22.__)("No results found") }) 20689 ] 20690 } 20691 ) 20692 ] 20693 } 20694 ); 20695 } 20696 function SearchWidget(props) { 20697 const { elements, isLoading } = useElements({ 20698 elements: props.filter.elements, 20699 getElements: props.filter.getElements 20700 }); 20701 if (isLoading) { 20702 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components20.Spinner, {}) }); 20703 } 20704 if (elements.length === 0) { 20705 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n22.__)("No elements found") }); 20706 } 20707 const Widget = elements.length > 10 ? ComboboxList22 : ListBox; 20708 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Widget, { ...props, filter: { ...props.filter, elements } }); 20709 } 20710 20711 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs 20712 var import_es6 = __toESM(require_es6(), 1); 20713 var import_compose8 = __toESM(require_compose(), 1); 20714 var import_element56 = __toESM(require_element(), 1); 20715 var import_components21 = __toESM(require_components(), 1); 20716 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1); 20717 function InputWidget({ 20718 filter, 20719 view, 20720 onChangeView, 20721 fields: fields2 20722 }) { 20723 const currentFilter = view.filters?.find( 20724 (f2) => f2.field === filter.field 20725 ); 20726 const currentValue = getCurrentValue(filter, currentFilter); 20727 const field = (0, import_element56.useMemo)(() => { 20728 const currentField = fields2.find((f2) => f2.id === filter.field); 20729 if (currentField) { 20730 return { 20731 ...currentField, 20732 // Deactivate validation for filters. 20733 isValid: {}, 20734 // Filter controls are always enabled. 20735 isDisabled: () => false, 20736 // Filter controls are always visible. 20737 isVisible: () => true, 20738 // Configure getValue/setValue as if Item was a plain object. 20739 getValue: ({ item }) => item[currentField.id], 20740 setValue: ({ value }) => ({ 20741 [currentField.id]: value 20742 }) 20743 }; 20744 } 20745 return currentField; 20746 }, [fields2, filter.field]); 20747 const data = (0, import_element56.useMemo)(() => { 20748 return (view.filters ?? []).reduce( 20749 (acc, activeFilter) => { 20750 acc[activeFilter.field] = activeFilter.value; 20751 return acc; 20752 }, 20753 {} 20754 ); 20755 }, [view.filters]); 20756 const handleChange = (0, import_compose8.useEvent)((updatedData) => { 20757 if (!field || !currentFilter) { 20758 return; 20759 } 20760 const nextValue = field.getValue({ item: updatedData }); 20761 if ((0, import_es6.default)(nextValue, currentValue)) { 20762 return; 20763 } 20764 onChangeView({ 20765 ...view, 20766 filters: (view.filters ?? []).map( 20767 (_filter) => _filter.field === filter.field ? { 20768 ..._filter, 20769 operator: currentFilter.operator || filter.operators[0], 20770 // Consider empty strings as undefined: 20771 // 20772 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records 20773 // - empty string as value means "search empty string": returns only the records that have an empty string as value 20774 // 20775 // In practice, this means the filter will not be able to find an empty string as the value. 20776 value: nextValue === "" ? void 0 : nextValue 20777 } : _filter 20778 ) 20779 }); 20780 }); 20781 if (!field || !field.Edit || !currentFilter) { 20782 return null; 20783 } 20784 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 20785 import_components21.Flex, 20786 { 20787 className: "dataviews-filters__user-input-widget", 20788 gap: 2.5, 20789 direction: "column", 20790 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 20791 field.Edit, 20792 { 20793 hideLabelFromVision: true, 20794 data, 20795 field, 20796 operator: currentFilter.operator, 20797 onChange: handleChange 20798 } 20799 ) 20800 } 20801 ); 20802 } 20803 20804 // node_modules/date-fns/constants.js 20805 var daysInYear = 365.2425; 20806 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 20807 var minTime = -maxTime; 20808 var millisecondsInWeek = 6048e5; 20809 var millisecondsInDay = 864e5; 20810 var secondsInHour = 3600; 20811 var secondsInDay = secondsInHour * 24; 20812 var secondsInWeek = secondsInDay * 7; 20813 var secondsInYear = secondsInDay * daysInYear; 20814 var secondsInMonth = secondsInYear / 12; 20815 var secondsInQuarter = secondsInMonth * 3; 20816 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom"); 20817 20818 // node_modules/date-fns/constructFrom.js 20819 function constructFrom(date, value) { 20820 if (typeof date === "function") return date(value); 20821 if (date && typeof date === "object" && constructFromSymbol in date) 20822 return date[constructFromSymbol](value); 20823 if (date instanceof Date) return new date.constructor(value); 20824 return new Date(value); 20825 } 20826 20827 // node_modules/date-fns/toDate.js 20828 function toDate(argument, context) { 20829 return constructFrom(context || argument, argument); 20830 } 20831 20832 // node_modules/date-fns/addDays.js 20833 function addDays(date, amount, options) { 20834 const _date = toDate(date, options?.in); 20835 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 20836 if (!amount) return _date; 20837 _date.setDate(_date.getDate() + amount); 20838 return _date; 20839 } 20840 20841 // node_modules/date-fns/addMonths.js 20842 function addMonths(date, amount, options) { 20843 const _date = toDate(date, options?.in); 20844 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 20845 if (!amount) { 20846 return _date; 20847 } 20848 const dayOfMonth = _date.getDate(); 20849 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime()); 20850 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 20851 const daysInMonth = endOfDesiredMonth.getDate(); 20852 if (dayOfMonth >= daysInMonth) { 20853 return endOfDesiredMonth; 20854 } else { 20855 _date.setFullYear( 20856 endOfDesiredMonth.getFullYear(), 20857 endOfDesiredMonth.getMonth(), 20858 dayOfMonth 20859 ); 20860 return _date; 20861 } 20862 } 20863 20864 // node_modules/date-fns/_lib/defaultOptions.js 20865 var defaultOptions = {}; 20866 function getDefaultOptions() { 20867 return defaultOptions; 20868 } 20869 20870 // node_modules/date-fns/startOfWeek.js 20871 function startOfWeek(date, options) { 20872 const defaultOptions2 = getDefaultOptions(); 20873 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 20874 const _date = toDate(date, options?.in); 20875 const day = _date.getDay(); 20876 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; 20877 _date.setDate(_date.getDate() - diff); 20878 _date.setHours(0, 0, 0, 0); 20879 return _date; 20880 } 20881 20882 // node_modules/date-fns/startOfISOWeek.js 20883 function startOfISOWeek(date, options) { 20884 return startOfWeek(date, { ...options, weekStartsOn: 1 }); 20885 } 20886 20887 // node_modules/date-fns/getISOWeekYear.js 20888 function getISOWeekYear(date, options) { 20889 const _date = toDate(date, options?.in); 20890 const year = _date.getFullYear(); 20891 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); 20892 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); 20893 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); 20894 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); 20895 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); 20896 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); 20897 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); 20898 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); 20899 if (_date.getTime() >= startOfNextYear.getTime()) { 20900 return year + 1; 20901 } else if (_date.getTime() >= startOfThisYear.getTime()) { 20902 return year; 20903 } else { 20904 return year - 1; 20905 } 20906 } 20907 20908 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js 20909 function getTimezoneOffsetInMilliseconds(date) { 20910 const _date = toDate(date); 20911 const utcDate = new Date( 20912 Date.UTC( 20913 _date.getFullYear(), 20914 _date.getMonth(), 20915 _date.getDate(), 20916 _date.getHours(), 20917 _date.getMinutes(), 20918 _date.getSeconds(), 20919 _date.getMilliseconds() 20920 ) 20921 ); 20922 utcDate.setUTCFullYear(_date.getFullYear()); 20923 return +date - +utcDate; 20924 } 20925 20926 // node_modules/date-fns/_lib/normalizeDates.js 20927 function normalizeDates(context, ...dates) { 20928 const normalize = constructFrom.bind( 20929 null, 20930 context || dates.find((date) => typeof date === "object") 20931 ); 20932 return dates.map(normalize); 20933 } 20934 20935 // node_modules/date-fns/startOfDay.js 20936 function startOfDay(date, options) { 20937 const _date = toDate(date, options?.in); 20938 _date.setHours(0, 0, 0, 0); 20939 return _date; 20940 } 20941 20942 // node_modules/date-fns/differenceInCalendarDays.js 20943 function differenceInCalendarDays(laterDate, earlierDate, options) { 20944 const [laterDate_, earlierDate_] = normalizeDates( 20945 options?.in, 20946 laterDate, 20947 earlierDate 20948 ); 20949 const laterStartOfDay = startOfDay(laterDate_); 20950 const earlierStartOfDay = startOfDay(earlierDate_); 20951 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); 20952 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); 20953 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); 20954 } 20955 20956 // node_modules/date-fns/startOfISOWeekYear.js 20957 function startOfISOWeekYear(date, options) { 20958 const year = getISOWeekYear(date, options); 20959 const fourthOfJanuary = constructFrom(options?.in || date, 0); 20960 fourthOfJanuary.setFullYear(year, 0, 4); 20961 fourthOfJanuary.setHours(0, 0, 0, 0); 20962 return startOfISOWeek(fourthOfJanuary); 20963 } 20964 20965 // node_modules/date-fns/addWeeks.js 20966 function addWeeks(date, amount, options) { 20967 return addDays(date, amount * 7, options); 20968 } 20969 20970 // node_modules/date-fns/addYears.js 20971 function addYears(date, amount, options) { 20972 return addMonths(date, amount * 12, options); 20973 } 20974 20975 // node_modules/date-fns/isDate.js 20976 function isDate(value) { 20977 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; 20978 } 20979 20980 // node_modules/date-fns/isValid.js 20981 function isValid(date) { 20982 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date))); 20983 } 20984 20985 // node_modules/date-fns/startOfMonth.js 20986 function startOfMonth(date, options) { 20987 const _date = toDate(date, options?.in); 20988 _date.setDate(1); 20989 _date.setHours(0, 0, 0, 0); 20990 return _date; 20991 } 20992 20993 // node_modules/date-fns/startOfYear.js 20994 function startOfYear(date, options) { 20995 const date_ = toDate(date, options?.in); 20996 date_.setFullYear(date_.getFullYear(), 0, 1); 20997 date_.setHours(0, 0, 0, 0); 20998 return date_; 20999 } 21000 21001 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js 21002 var formatDistanceLocale = { 21003 lessThanXSeconds: { 21004 one: "less than a second", 21005 other: "less than {{count}} seconds" 21006 }, 21007 xSeconds: { 21008 one: "1 second", 21009 other: "{{count}} seconds" 21010 }, 21011 halfAMinute: "half a minute", 21012 lessThanXMinutes: { 21013 one: "less than a minute", 21014 other: "less than {{count}} minutes" 21015 }, 21016 xMinutes: { 21017 one: "1 minute", 21018 other: "{{count}} minutes" 21019 }, 21020 aboutXHours: { 21021 one: "about 1 hour", 21022 other: "about {{count}} hours" 21023 }, 21024 xHours: { 21025 one: "1 hour", 21026 other: "{{count}} hours" 21027 }, 21028 xDays: { 21029 one: "1 day", 21030 other: "{{count}} days" 21031 }, 21032 aboutXWeeks: { 21033 one: "about 1 week", 21034 other: "about {{count}} weeks" 21035 }, 21036 xWeeks: { 21037 one: "1 week", 21038 other: "{{count}} weeks" 21039 }, 21040 aboutXMonths: { 21041 one: "about 1 month", 21042 other: "about {{count}} months" 21043 }, 21044 xMonths: { 21045 one: "1 month", 21046 other: "{{count}} months" 21047 }, 21048 aboutXYears: { 21049 one: "about 1 year", 21050 other: "about {{count}} years" 21051 }, 21052 xYears: { 21053 one: "1 year", 21054 other: "{{count}} years" 21055 }, 21056 overXYears: { 21057 one: "over 1 year", 21058 other: "over {{count}} years" 21059 }, 21060 almostXYears: { 21061 one: "almost 1 year", 21062 other: "almost {{count}} years" 21063 } 21064 }; 21065 var formatDistance = (token, count, options) => { 21066 let result; 21067 const tokenValue = formatDistanceLocale[token]; 21068 if (typeof tokenValue === "string") { 21069 result = tokenValue; 21070 } else if (count === 1) { 21071 result = tokenValue.one; 21072 } else { 21073 result = tokenValue.other.replace("{{count}}", count.toString()); 21074 } 21075 if (options?.addSuffix) { 21076 if (options.comparison && options.comparison > 0) { 21077 return "in " + result; 21078 } else { 21079 return result + " ago"; 21080 } 21081 } 21082 return result; 21083 }; 21084 21085 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js 21086 function buildFormatLongFn(args) { 21087 return (options = {}) => { 21088 const width = options.width ? String(options.width) : args.defaultWidth; 21089 const format6 = args.formats[width] || args.formats[args.defaultWidth]; 21090 return format6; 21091 }; 21092 } 21093 21094 // node_modules/date-fns/locale/en-US/_lib/formatLong.js 21095 var dateFormats = { 21096 full: "EEEE, MMMM do, y", 21097 long: "MMMM do, y", 21098 medium: "MMM d, y", 21099 short: "MM/dd/yyyy" 21100 }; 21101 var timeFormats = { 21102 full: "h:mm:ss a zzzz", 21103 long: "h:mm:ss a z", 21104 medium: "h:mm:ss a", 21105 short: "h:mm a" 21106 }; 21107 var dateTimeFormats = { 21108 full: "{{date}} 'at' {{time}}", 21109 long: "{{date}} 'at' {{time}}", 21110 medium: "{{date}}, {{time}}", 21111 short: "{{date}}, {{time}}" 21112 }; 21113 var formatLong = { 21114 date: buildFormatLongFn({ 21115 formats: dateFormats, 21116 defaultWidth: "full" 21117 }), 21118 time: buildFormatLongFn({ 21119 formats: timeFormats, 21120 defaultWidth: "full" 21121 }), 21122 dateTime: buildFormatLongFn({ 21123 formats: dateTimeFormats, 21124 defaultWidth: "full" 21125 }) 21126 }; 21127 21128 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js 21129 var formatRelativeLocale = { 21130 lastWeek: "'last' eeee 'at' p", 21131 yesterday: "'yesterday at' p", 21132 today: "'today at' p", 21133 tomorrow: "'tomorrow at' p", 21134 nextWeek: "eeee 'at' p", 21135 other: "P" 21136 }; 21137 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; 21138 21139 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js 21140 function buildLocalizeFn(args) { 21141 return (value, options) => { 21142 const context = options?.context ? String(options.context) : "standalone"; 21143 let valuesArray; 21144 if (context === "formatting" && args.formattingValues) { 21145 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; 21146 const width = options?.width ? String(options.width) : defaultWidth; 21147 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; 21148 } else { 21149 const defaultWidth = args.defaultWidth; 21150 const width = options?.width ? String(options.width) : args.defaultWidth; 21151 valuesArray = args.values[width] || args.values[defaultWidth]; 21152 } 21153 const index2 = args.argumentCallback ? args.argumentCallback(value) : value; 21154 return valuesArray[index2]; 21155 }; 21156 } 21157 21158 // node_modules/date-fns/locale/en-US/_lib/localize.js 21159 var eraValues = { 21160 narrow: ["B", "A"], 21161 abbreviated: ["BC", "AD"], 21162 wide: ["Before Christ", "Anno Domini"] 21163 }; 21164 var quarterValues = { 21165 narrow: ["1", "2", "3", "4"], 21166 abbreviated: ["Q1", "Q2", "Q3", "Q4"], 21167 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] 21168 }; 21169 var monthValues = { 21170 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], 21171 abbreviated: [ 21172 "Jan", 21173 "Feb", 21174 "Mar", 21175 "Apr", 21176 "May", 21177 "Jun", 21178 "Jul", 21179 "Aug", 21180 "Sep", 21181 "Oct", 21182 "Nov", 21183 "Dec" 21184 ], 21185 wide: [ 21186 "January", 21187 "February", 21188 "March", 21189 "April", 21190 "May", 21191 "June", 21192 "July", 21193 "August", 21194 "September", 21195 "October", 21196 "November", 21197 "December" 21198 ] 21199 }; 21200 var dayValues = { 21201 narrow: ["S", "M", "T", "W", "T", "F", "S"], 21202 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 21203 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 21204 wide: [ 21205 "Sunday", 21206 "Monday", 21207 "Tuesday", 21208 "Wednesday", 21209 "Thursday", 21210 "Friday", 21211 "Saturday" 21212 ] 21213 }; 21214 var dayPeriodValues = { 21215 narrow: { 21216 am: "a", 21217 pm: "p", 21218 midnight: "mi", 21219 noon: "n", 21220 morning: "morning", 21221 afternoon: "afternoon", 21222 evening: "evening", 21223 night: "night" 21224 }, 21225 abbreviated: { 21226 am: "AM", 21227 pm: "PM", 21228 midnight: "midnight", 21229 noon: "noon", 21230 morning: "morning", 21231 afternoon: "afternoon", 21232 evening: "evening", 21233 night: "night" 21234 }, 21235 wide: { 21236 am: "a.m.", 21237 pm: "p.m.", 21238 midnight: "midnight", 21239 noon: "noon", 21240 morning: "morning", 21241 afternoon: "afternoon", 21242 evening: "evening", 21243 night: "night" 21244 } 21245 }; 21246 var formattingDayPeriodValues = { 21247 narrow: { 21248 am: "a", 21249 pm: "p", 21250 midnight: "mi", 21251 noon: "n", 21252 morning: "in the morning", 21253 afternoon: "in the afternoon", 21254 evening: "in the evening", 21255 night: "at night" 21256 }, 21257 abbreviated: { 21258 am: "AM", 21259 pm: "PM", 21260 midnight: "midnight", 21261 noon: "noon", 21262 morning: "in the morning", 21263 afternoon: "in the afternoon", 21264 evening: "in the evening", 21265 night: "at night" 21266 }, 21267 wide: { 21268 am: "a.m.", 21269 pm: "p.m.", 21270 midnight: "midnight", 21271 noon: "noon", 21272 morning: "in the morning", 21273 afternoon: "in the afternoon", 21274 evening: "in the evening", 21275 night: "at night" 21276 } 21277 }; 21278 var ordinalNumber = (dirtyNumber, _options) => { 21279 const number = Number(dirtyNumber); 21280 const rem100 = number % 100; 21281 if (rem100 > 20 || rem100 < 10) { 21282 switch (rem100 % 10) { 21283 case 1: 21284 return number + "st"; 21285 case 2: 21286 return number + "nd"; 21287 case 3: 21288 return number + "rd"; 21289 } 21290 } 21291 return number + "th"; 21292 }; 21293 var localize = { 21294 ordinalNumber, 21295 era: buildLocalizeFn({ 21296 values: eraValues, 21297 defaultWidth: "wide" 21298 }), 21299 quarter: buildLocalizeFn({ 21300 values: quarterValues, 21301 defaultWidth: "wide", 21302 argumentCallback: (quarter) => quarter - 1 21303 }), 21304 month: buildLocalizeFn({ 21305 values: monthValues, 21306 defaultWidth: "wide" 21307 }), 21308 day: buildLocalizeFn({ 21309 values: dayValues, 21310 defaultWidth: "wide" 21311 }), 21312 dayPeriod: buildLocalizeFn({ 21313 values: dayPeriodValues, 21314 defaultWidth: "wide", 21315 formattingValues: formattingDayPeriodValues, 21316 defaultFormattingWidth: "wide" 21317 }) 21318 }; 21319 21320 // node_modules/date-fns/locale/_lib/buildMatchFn.js 21321 function buildMatchFn(args) { 21322 return (string, options = {}) => { 21323 const width = options.width; 21324 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; 21325 const matchResult = string.match(matchPattern); 21326 if (!matchResult) { 21327 return null; 21328 } 21329 const matchedString = matchResult[0]; 21330 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; 21331 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : ( 21332 // [TODO] -- I challenge you to fix the type 21333 findKey(parsePatterns, (pattern) => pattern.test(matchedString)) 21334 ); 21335 let value; 21336 value = args.valueCallback ? args.valueCallback(key) : key; 21337 value = options.valueCallback ? ( 21338 // [TODO] -- I challenge you to fix the type 21339 options.valueCallback(value) 21340 ) : value; 21341 const rest = string.slice(matchedString.length); 21342 return { value, rest }; 21343 }; 21344 } 21345 function findKey(object, predicate) { 21346 for (const key in object) { 21347 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { 21348 return key; 21349 } 21350 } 21351 return void 0; 21352 } 21353 function findIndex(array, predicate) { 21354 for (let key = 0; key < array.length; key++) { 21355 if (predicate(array[key])) { 21356 return key; 21357 } 21358 } 21359 return void 0; 21360 } 21361 21362 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js 21363 function buildMatchPatternFn(args) { 21364 return (string, options = {}) => { 21365 const matchResult = string.match(args.matchPattern); 21366 if (!matchResult) return null; 21367 const matchedString = matchResult[0]; 21368 const parseResult = string.match(args.parsePattern); 21369 if (!parseResult) return null; 21370 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; 21371 value = options.valueCallback ? options.valueCallback(value) : value; 21372 const rest = string.slice(matchedString.length); 21373 return { value, rest }; 21374 }; 21375 } 21376 21377 // node_modules/date-fns/locale/en-US/_lib/match.js 21378 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; 21379 var parseOrdinalNumberPattern = /\d+/i; 21380 var matchEraPatterns = { 21381 narrow: /^(b|a)/i, 21382 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, 21383 wide: /^(before christ|before common era|anno domini|common era)/i 21384 }; 21385 var parseEraPatterns = { 21386 any: [/^b/i, /^(a|c)/i] 21387 }; 21388 var matchQuarterPatterns = { 21389 narrow: /^[1234]/i, 21390 abbreviated: /^q[1234]/i, 21391 wide: /^[1234](th|st|nd|rd)? quarter/i 21392 }; 21393 var parseQuarterPatterns = { 21394 any: [/1/i, /2/i, /3/i, /4/i] 21395 }; 21396 var matchMonthPatterns = { 21397 narrow: /^[jfmasond]/i, 21398 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, 21399 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i 21400 }; 21401 var parseMonthPatterns = { 21402 narrow: [ 21403 /^j/i, 21404 /^f/i, 21405 /^m/i, 21406 /^a/i, 21407 /^m/i, 21408 /^j/i, 21409 /^j/i, 21410 /^a/i, 21411 /^s/i, 21412 /^o/i, 21413 /^n/i, 21414 /^d/i 21415 ], 21416 any: [ 21417 /^ja/i, 21418 /^f/i, 21419 /^mar/i, 21420 /^ap/i, 21421 /^may/i, 21422 /^jun/i, 21423 /^jul/i, 21424 /^au/i, 21425 /^s/i, 21426 /^o/i, 21427 /^n/i, 21428 /^d/i 21429 ] 21430 }; 21431 var matchDayPatterns = { 21432 narrow: /^[smtwf]/i, 21433 short: /^(su|mo|tu|we|th|fr|sa)/i, 21434 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, 21435 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i 21436 }; 21437 var parseDayPatterns = { 21438 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], 21439 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] 21440 }; 21441 var matchDayPeriodPatterns = { 21442 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, 21443 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i 21444 }; 21445 var parseDayPeriodPatterns = { 21446 any: { 21447 am: /^a/i, 21448 pm: /^p/i, 21449 midnight: /^mi/i, 21450 noon: /^no/i, 21451 morning: /morning/i, 21452 afternoon: /afternoon/i, 21453 evening: /evening/i, 21454 night: /night/i 21455 } 21456 }; 21457 var match = { 21458 ordinalNumber: buildMatchPatternFn({ 21459 matchPattern: matchOrdinalNumberPattern, 21460 parsePattern: parseOrdinalNumberPattern, 21461 valueCallback: (value) => parseInt(value, 10) 21462 }), 21463 era: buildMatchFn({ 21464 matchPatterns: matchEraPatterns, 21465 defaultMatchWidth: "wide", 21466 parsePatterns: parseEraPatterns, 21467 defaultParseWidth: "any" 21468 }), 21469 quarter: buildMatchFn({ 21470 matchPatterns: matchQuarterPatterns, 21471 defaultMatchWidth: "wide", 21472 parsePatterns: parseQuarterPatterns, 21473 defaultParseWidth: "any", 21474 valueCallback: (index2) => index2 + 1 21475 }), 21476 month: buildMatchFn({ 21477 matchPatterns: matchMonthPatterns, 21478 defaultMatchWidth: "wide", 21479 parsePatterns: parseMonthPatterns, 21480 defaultParseWidth: "any" 21481 }), 21482 day: buildMatchFn({ 21483 matchPatterns: matchDayPatterns, 21484 defaultMatchWidth: "wide", 21485 parsePatterns: parseDayPatterns, 21486 defaultParseWidth: "any" 21487 }), 21488 dayPeriod: buildMatchFn({ 21489 matchPatterns: matchDayPeriodPatterns, 21490 defaultMatchWidth: "any", 21491 parsePatterns: parseDayPeriodPatterns, 21492 defaultParseWidth: "any" 21493 }) 21494 }; 21495 21496 // node_modules/date-fns/locale/en-US.js 21497 var enUS = { 21498 code: "en-US", 21499 formatDistance, 21500 formatLong, 21501 formatRelative, 21502 localize, 21503 match, 21504 options: { 21505 weekStartsOn: 0, 21506 firstWeekContainsDate: 1 21507 } 21508 }; 21509 21510 // node_modules/date-fns/getDayOfYear.js 21511 function getDayOfYear(date, options) { 21512 const _date = toDate(date, options?.in); 21513 const diff = differenceInCalendarDays(_date, startOfYear(_date)); 21514 const dayOfYear = diff + 1; 21515 return dayOfYear; 21516 } 21517 21518 // node_modules/date-fns/getISOWeek.js 21519 function getISOWeek(date, options) { 21520 const _date = toDate(date, options?.in); 21521 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); 21522 return Math.round(diff / millisecondsInWeek) + 1; 21523 } 21524 21525 // node_modules/date-fns/getWeekYear.js 21526 function getWeekYear(date, options) { 21527 const _date = toDate(date, options?.in); 21528 const year = _date.getFullYear(); 21529 const defaultOptions2 = getDefaultOptions(); 21530 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 21531 const firstWeekOfNextYear = constructFrom(options?.in || date, 0); 21532 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); 21533 firstWeekOfNextYear.setHours(0, 0, 0, 0); 21534 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); 21535 const firstWeekOfThisYear = constructFrom(options?.in || date, 0); 21536 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); 21537 firstWeekOfThisYear.setHours(0, 0, 0, 0); 21538 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); 21539 if (+_date >= +startOfNextYear) { 21540 return year + 1; 21541 } else if (+_date >= +startOfThisYear) { 21542 return year; 21543 } else { 21544 return year - 1; 21545 } 21546 } 21547 21548 // node_modules/date-fns/startOfWeekYear.js 21549 function startOfWeekYear(date, options) { 21550 const defaultOptions2 = getDefaultOptions(); 21551 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 21552 const year = getWeekYear(date, options); 21553 const firstWeek = constructFrom(options?.in || date, 0); 21554 firstWeek.setFullYear(year, 0, firstWeekContainsDate); 21555 firstWeek.setHours(0, 0, 0, 0); 21556 const _date = startOfWeek(firstWeek, options); 21557 return _date; 21558 } 21559 21560 // node_modules/date-fns/getWeek.js 21561 function getWeek(date, options) { 21562 const _date = toDate(date, options?.in); 21563 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); 21564 return Math.round(diff / millisecondsInWeek) + 1; 21565 } 21566 21567 // node_modules/date-fns/_lib/addLeadingZeros.js 21568 function addLeadingZeros(number, targetLength) { 21569 const sign = number < 0 ? "-" : ""; 21570 const output = Math.abs(number).toString().padStart(targetLength, "0"); 21571 return sign + output; 21572 } 21573 21574 // node_modules/date-fns/_lib/format/lightFormatters.js 21575 var lightFormatters = { 21576 // Year 21577 y(date, token) { 21578 const signedYear = date.getFullYear(); 21579 const year = signedYear > 0 ? signedYear : 1 - signedYear; 21580 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); 21581 }, 21582 // Month 21583 M(date, token) { 21584 const month = date.getMonth(); 21585 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); 21586 }, 21587 // Day of the month 21588 d(date, token) { 21589 return addLeadingZeros(date.getDate(), token.length); 21590 }, 21591 // AM or PM 21592 a(date, token) { 21593 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am"; 21594 switch (token) { 21595 case "a": 21596 case "aa": 21597 return dayPeriodEnumValue.toUpperCase(); 21598 case "aaa": 21599 return dayPeriodEnumValue; 21600 case "aaaaa": 21601 return dayPeriodEnumValue[0]; 21602 case "aaaa": 21603 default: 21604 return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; 21605 } 21606 }, 21607 // Hour [1-12] 21608 h(date, token) { 21609 return addLeadingZeros(date.getHours() % 12 || 12, token.length); 21610 }, 21611 // Hour [0-23] 21612 H(date, token) { 21613 return addLeadingZeros(date.getHours(), token.length); 21614 }, 21615 // Minute 21616 m(date, token) { 21617 return addLeadingZeros(date.getMinutes(), token.length); 21618 }, 21619 // Second 21620 s(date, token) { 21621 return addLeadingZeros(date.getSeconds(), token.length); 21622 }, 21623 // Fraction of second 21624 S(date, token) { 21625 const numberOfDigits = token.length; 21626 const milliseconds = date.getMilliseconds(); 21627 const fractionalSeconds = Math.trunc( 21628 milliseconds * Math.pow(10, numberOfDigits - 3) 21629 ); 21630 return addLeadingZeros(fractionalSeconds, token.length); 21631 } 21632 }; 21633 21634 // node_modules/date-fns/_lib/format/formatters.js 21635 var dayPeriodEnum = { 21636 am: "am", 21637 pm: "pm", 21638 midnight: "midnight", 21639 noon: "noon", 21640 morning: "morning", 21641 afternoon: "afternoon", 21642 evening: "evening", 21643 night: "night" 21644 }; 21645 var formatters = { 21646 // Era 21647 G: function(date, token, localize2) { 21648 const era = date.getFullYear() > 0 ? 1 : 0; 21649 switch (token) { 21650 // AD, BC 21651 case "G": 21652 case "GG": 21653 case "GGG": 21654 return localize2.era(era, { width: "abbreviated" }); 21655 // A, B 21656 case "GGGGG": 21657 return localize2.era(era, { width: "narrow" }); 21658 // Anno Domini, Before Christ 21659 case "GGGG": 21660 default: 21661 return localize2.era(era, { width: "wide" }); 21662 } 21663 }, 21664 // Year 21665 y: function(date, token, localize2) { 21666 if (token === "yo") { 21667 const signedYear = date.getFullYear(); 21668 const year = signedYear > 0 ? signedYear : 1 - signedYear; 21669 return localize2.ordinalNumber(year, { unit: "year" }); 21670 } 21671 return lightFormatters.y(date, token); 21672 }, 21673 // Local week-numbering year 21674 Y: function(date, token, localize2, options) { 21675 const signedWeekYear = getWeekYear(date, options); 21676 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; 21677 if (token === "YY") { 21678 const twoDigitYear = weekYear % 100; 21679 return addLeadingZeros(twoDigitYear, 2); 21680 } 21681 if (token === "Yo") { 21682 return localize2.ordinalNumber(weekYear, { unit: "year" }); 21683 } 21684 return addLeadingZeros(weekYear, token.length); 21685 }, 21686 // ISO week-numbering year 21687 R: function(date, token) { 21688 const isoWeekYear = getISOWeekYear(date); 21689 return addLeadingZeros(isoWeekYear, token.length); 21690 }, 21691 // Extended year. This is a single number designating the year of this calendar system. 21692 // The main difference between `y` and `u` localizers are B.C. years: 21693 // | Year | `y` | `u` | 21694 // |------|-----|-----| 21695 // | AC 1 | 1 | 1 | 21696 // | BC 1 | 1 | 0 | 21697 // | BC 2 | 2 | -1 | 21698 // Also `yy` always returns the last two digits of a year, 21699 // while `uu` pads single digit years to 2 characters and returns other years unchanged. 21700 u: function(date, token) { 21701 const year = date.getFullYear(); 21702 return addLeadingZeros(year, token.length); 21703 }, 21704 // Quarter 21705 Q: function(date, token, localize2) { 21706 const quarter = Math.ceil((date.getMonth() + 1) / 3); 21707 switch (token) { 21708 // 1, 2, 3, 4 21709 case "Q": 21710 return String(quarter); 21711 // 01, 02, 03, 04 21712 case "QQ": 21713 return addLeadingZeros(quarter, 2); 21714 // 1st, 2nd, 3rd, 4th 21715 case "Qo": 21716 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 21717 // Q1, Q2, Q3, Q4 21718 case "QQQ": 21719 return localize2.quarter(quarter, { 21720 width: "abbreviated", 21721 context: "formatting" 21722 }); 21723 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 21724 case "QQQQQ": 21725 return localize2.quarter(quarter, { 21726 width: "narrow", 21727 context: "formatting" 21728 }); 21729 // 1st quarter, 2nd quarter, ... 21730 case "QQQQ": 21731 default: 21732 return localize2.quarter(quarter, { 21733 width: "wide", 21734 context: "formatting" 21735 }); 21736 } 21737 }, 21738 // Stand-alone quarter 21739 q: function(date, token, localize2) { 21740 const quarter = Math.ceil((date.getMonth() + 1) / 3); 21741 switch (token) { 21742 // 1, 2, 3, 4 21743 case "q": 21744 return String(quarter); 21745 // 01, 02, 03, 04 21746 case "qq": 21747 return addLeadingZeros(quarter, 2); 21748 // 1st, 2nd, 3rd, 4th 21749 case "qo": 21750 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 21751 // Q1, Q2, Q3, Q4 21752 case "qqq": 21753 return localize2.quarter(quarter, { 21754 width: "abbreviated", 21755 context: "standalone" 21756 }); 21757 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 21758 case "qqqqq": 21759 return localize2.quarter(quarter, { 21760 width: "narrow", 21761 context: "standalone" 21762 }); 21763 // 1st quarter, 2nd quarter, ... 21764 case "qqqq": 21765 default: 21766 return localize2.quarter(quarter, { 21767 width: "wide", 21768 context: "standalone" 21769 }); 21770 } 21771 }, 21772 // Month 21773 M: function(date, token, localize2) { 21774 const month = date.getMonth(); 21775 switch (token) { 21776 case "M": 21777 case "MM": 21778 return lightFormatters.M(date, token); 21779 // 1st, 2nd, ..., 12th 21780 case "Mo": 21781 return localize2.ordinalNumber(month + 1, { unit: "month" }); 21782 // Jan, Feb, ..., Dec 21783 case "MMM": 21784 return localize2.month(month, { 21785 width: "abbreviated", 21786 context: "formatting" 21787 }); 21788 // J, F, ..., D 21789 case "MMMMM": 21790 return localize2.month(month, { 21791 width: "narrow", 21792 context: "formatting" 21793 }); 21794 // January, February, ..., December 21795 case "MMMM": 21796 default: 21797 return localize2.month(month, { width: "wide", context: "formatting" }); 21798 } 21799 }, 21800 // Stand-alone month 21801 L: function(date, token, localize2) { 21802 const month = date.getMonth(); 21803 switch (token) { 21804 // 1, 2, ..., 12 21805 case "L": 21806 return String(month + 1); 21807 // 01, 02, ..., 12 21808 case "LL": 21809 return addLeadingZeros(month + 1, 2); 21810 // 1st, 2nd, ..., 12th 21811 case "Lo": 21812 return localize2.ordinalNumber(month + 1, { unit: "month" }); 21813 // Jan, Feb, ..., Dec 21814 case "LLL": 21815 return localize2.month(month, { 21816 width: "abbreviated", 21817 context: "standalone" 21818 }); 21819 // J, F, ..., D 21820 case "LLLLL": 21821 return localize2.month(month, { 21822 width: "narrow", 21823 context: "standalone" 21824 }); 21825 // January, February, ..., December 21826 case "LLLL": 21827 default: 21828 return localize2.month(month, { width: "wide", context: "standalone" }); 21829 } 21830 }, 21831 // Local week of year 21832 w: function(date, token, localize2, options) { 21833 const week = getWeek(date, options); 21834 if (token === "wo") { 21835 return localize2.ordinalNumber(week, { unit: "week" }); 21836 } 21837 return addLeadingZeros(week, token.length); 21838 }, 21839 // ISO week of year 21840 I: function(date, token, localize2) { 21841 const isoWeek = getISOWeek(date); 21842 if (token === "Io") { 21843 return localize2.ordinalNumber(isoWeek, { unit: "week" }); 21844 } 21845 return addLeadingZeros(isoWeek, token.length); 21846 }, 21847 // Day of the month 21848 d: function(date, token, localize2) { 21849 if (token === "do") { 21850 return localize2.ordinalNumber(date.getDate(), { unit: "date" }); 21851 } 21852 return lightFormatters.d(date, token); 21853 }, 21854 // Day of year 21855 D: function(date, token, localize2) { 21856 const dayOfYear = getDayOfYear(date); 21857 if (token === "Do") { 21858 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); 21859 } 21860 return addLeadingZeros(dayOfYear, token.length); 21861 }, 21862 // Day of week 21863 E: function(date, token, localize2) { 21864 const dayOfWeek = date.getDay(); 21865 switch (token) { 21866 // Tue 21867 case "E": 21868 case "EE": 21869 case "EEE": 21870 return localize2.day(dayOfWeek, { 21871 width: "abbreviated", 21872 context: "formatting" 21873 }); 21874 // T 21875 case "EEEEE": 21876 return localize2.day(dayOfWeek, { 21877 width: "narrow", 21878 context: "formatting" 21879 }); 21880 // Tu 21881 case "EEEEEE": 21882 return localize2.day(dayOfWeek, { 21883 width: "short", 21884 context: "formatting" 21885 }); 21886 // Tuesday 21887 case "EEEE": 21888 default: 21889 return localize2.day(dayOfWeek, { 21890 width: "wide", 21891 context: "formatting" 21892 }); 21893 } 21894 }, 21895 // Local day of week 21896 e: function(date, token, localize2, options) { 21897 const dayOfWeek = date.getDay(); 21898 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 21899 switch (token) { 21900 // Numerical value (Nth day of week with current locale or weekStartsOn) 21901 case "e": 21902 return String(localDayOfWeek); 21903 // Padded numerical value 21904 case "ee": 21905 return addLeadingZeros(localDayOfWeek, 2); 21906 // 1st, 2nd, ..., 7th 21907 case "eo": 21908 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 21909 case "eee": 21910 return localize2.day(dayOfWeek, { 21911 width: "abbreviated", 21912 context: "formatting" 21913 }); 21914 // T 21915 case "eeeee": 21916 return localize2.day(dayOfWeek, { 21917 width: "narrow", 21918 context: "formatting" 21919 }); 21920 // Tu 21921 case "eeeeee": 21922 return localize2.day(dayOfWeek, { 21923 width: "short", 21924 context: "formatting" 21925 }); 21926 // Tuesday 21927 case "eeee": 21928 default: 21929 return localize2.day(dayOfWeek, { 21930 width: "wide", 21931 context: "formatting" 21932 }); 21933 } 21934 }, 21935 // Stand-alone local day of week 21936 c: function(date, token, localize2, options) { 21937 const dayOfWeek = date.getDay(); 21938 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 21939 switch (token) { 21940 // Numerical value (same as in `e`) 21941 case "c": 21942 return String(localDayOfWeek); 21943 // Padded numerical value 21944 case "cc": 21945 return addLeadingZeros(localDayOfWeek, token.length); 21946 // 1st, 2nd, ..., 7th 21947 case "co": 21948 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 21949 case "ccc": 21950 return localize2.day(dayOfWeek, { 21951 width: "abbreviated", 21952 context: "standalone" 21953 }); 21954 // T 21955 case "ccccc": 21956 return localize2.day(dayOfWeek, { 21957 width: "narrow", 21958 context: "standalone" 21959 }); 21960 // Tu 21961 case "cccccc": 21962 return localize2.day(dayOfWeek, { 21963 width: "short", 21964 context: "standalone" 21965 }); 21966 // Tuesday 21967 case "cccc": 21968 default: 21969 return localize2.day(dayOfWeek, { 21970 width: "wide", 21971 context: "standalone" 21972 }); 21973 } 21974 }, 21975 // ISO day of week 21976 i: function(date, token, localize2) { 21977 const dayOfWeek = date.getDay(); 21978 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; 21979 switch (token) { 21980 // 2 21981 case "i": 21982 return String(isoDayOfWeek); 21983 // 02 21984 case "ii": 21985 return addLeadingZeros(isoDayOfWeek, token.length); 21986 // 2nd 21987 case "io": 21988 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); 21989 // Tue 21990 case "iii": 21991 return localize2.day(dayOfWeek, { 21992 width: "abbreviated", 21993 context: "formatting" 21994 }); 21995 // T 21996 case "iiiii": 21997 return localize2.day(dayOfWeek, { 21998 width: "narrow", 21999 context: "formatting" 22000 }); 22001 // Tu 22002 case "iiiiii": 22003 return localize2.day(dayOfWeek, { 22004 width: "short", 22005 context: "formatting" 22006 }); 22007 // Tuesday 22008 case "iiii": 22009 default: 22010 return localize2.day(dayOfWeek, { 22011 width: "wide", 22012 context: "formatting" 22013 }); 22014 } 22015 }, 22016 // AM or PM 22017 a: function(date, token, localize2) { 22018 const hours = date.getHours(); 22019 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 22020 switch (token) { 22021 case "a": 22022 case "aa": 22023 return localize2.dayPeriod(dayPeriodEnumValue, { 22024 width: "abbreviated", 22025 context: "formatting" 22026 }); 22027 case "aaa": 22028 return localize2.dayPeriod(dayPeriodEnumValue, { 22029 width: "abbreviated", 22030 context: "formatting" 22031 }).toLowerCase(); 22032 case "aaaaa": 22033 return localize2.dayPeriod(dayPeriodEnumValue, { 22034 width: "narrow", 22035 context: "formatting" 22036 }); 22037 case "aaaa": 22038 default: 22039 return localize2.dayPeriod(dayPeriodEnumValue, { 22040 width: "wide", 22041 context: "formatting" 22042 }); 22043 } 22044 }, 22045 // AM, PM, midnight, noon 22046 b: function(date, token, localize2) { 22047 const hours = date.getHours(); 22048 let dayPeriodEnumValue; 22049 if (hours === 12) { 22050 dayPeriodEnumValue = dayPeriodEnum.noon; 22051 } else if (hours === 0) { 22052 dayPeriodEnumValue = dayPeriodEnum.midnight; 22053 } else { 22054 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 22055 } 22056 switch (token) { 22057 case "b": 22058 case "bb": 22059 return localize2.dayPeriod(dayPeriodEnumValue, { 22060 width: "abbreviated", 22061 context: "formatting" 22062 }); 22063 case "bbb": 22064 return localize2.dayPeriod(dayPeriodEnumValue, { 22065 width: "abbreviated", 22066 context: "formatting" 22067 }).toLowerCase(); 22068 case "bbbbb": 22069 return localize2.dayPeriod(dayPeriodEnumValue, { 22070 width: "narrow", 22071 context: "formatting" 22072 }); 22073 case "bbbb": 22074 default: 22075 return localize2.dayPeriod(dayPeriodEnumValue, { 22076 width: "wide", 22077 context: "formatting" 22078 }); 22079 } 22080 }, 22081 // in the morning, in the afternoon, in the evening, at night 22082 B: function(date, token, localize2) { 22083 const hours = date.getHours(); 22084 let dayPeriodEnumValue; 22085 if (hours >= 17) { 22086 dayPeriodEnumValue = dayPeriodEnum.evening; 22087 } else if (hours >= 12) { 22088 dayPeriodEnumValue = dayPeriodEnum.afternoon; 22089 } else if (hours >= 4) { 22090 dayPeriodEnumValue = dayPeriodEnum.morning; 22091 } else { 22092 dayPeriodEnumValue = dayPeriodEnum.night; 22093 } 22094 switch (token) { 22095 case "B": 22096 case "BB": 22097 case "BBB": 22098 return localize2.dayPeriod(dayPeriodEnumValue, { 22099 width: "abbreviated", 22100 context: "formatting" 22101 }); 22102 case "BBBBB": 22103 return localize2.dayPeriod(dayPeriodEnumValue, { 22104 width: "narrow", 22105 context: "formatting" 22106 }); 22107 case "BBBB": 22108 default: 22109 return localize2.dayPeriod(dayPeriodEnumValue, { 22110 width: "wide", 22111 context: "formatting" 22112 }); 22113 } 22114 }, 22115 // Hour [1-12] 22116 h: function(date, token, localize2) { 22117 if (token === "ho") { 22118 let hours = date.getHours() % 12; 22119 if (hours === 0) hours = 12; 22120 return localize2.ordinalNumber(hours, { unit: "hour" }); 22121 } 22122 return lightFormatters.h(date, token); 22123 }, 22124 // Hour [0-23] 22125 H: function(date, token, localize2) { 22126 if (token === "Ho") { 22127 return localize2.ordinalNumber(date.getHours(), { unit: "hour" }); 22128 } 22129 return lightFormatters.H(date, token); 22130 }, 22131 // Hour [0-11] 22132 K: function(date, token, localize2) { 22133 const hours = date.getHours() % 12; 22134 if (token === "Ko") { 22135 return localize2.ordinalNumber(hours, { unit: "hour" }); 22136 } 22137 return addLeadingZeros(hours, token.length); 22138 }, 22139 // Hour [1-24] 22140 k: function(date, token, localize2) { 22141 let hours = date.getHours(); 22142 if (hours === 0) hours = 24; 22143 if (token === "ko") { 22144 return localize2.ordinalNumber(hours, { unit: "hour" }); 22145 } 22146 return addLeadingZeros(hours, token.length); 22147 }, 22148 // Minute 22149 m: function(date, token, localize2) { 22150 if (token === "mo") { 22151 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" }); 22152 } 22153 return lightFormatters.m(date, token); 22154 }, 22155 // Second 22156 s: function(date, token, localize2) { 22157 if (token === "so") { 22158 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" }); 22159 } 22160 return lightFormatters.s(date, token); 22161 }, 22162 // Fraction of second 22163 S: function(date, token) { 22164 return lightFormatters.S(date, token); 22165 }, 22166 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) 22167 X: function(date, token, _localize) { 22168 const timezoneOffset = date.getTimezoneOffset(); 22169 if (timezoneOffset === 0) { 22170 return "Z"; 22171 } 22172 switch (token) { 22173 // Hours and optional minutes 22174 case "X": 22175 return formatTimezoneWithOptionalMinutes(timezoneOffset); 22176 // Hours, minutes and optional seconds without `:` delimiter 22177 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 22178 // so this token always has the same output as `XX` 22179 case "XXXX": 22180 case "XX": 22181 return formatTimezone(timezoneOffset); 22182 // Hours, minutes and optional seconds with `:` delimiter 22183 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 22184 // so this token always has the same output as `XXX` 22185 case "XXXXX": 22186 case "XXX": 22187 // Hours and minutes with `:` delimiter 22188 default: 22189 return formatTimezone(timezoneOffset, ":"); 22190 } 22191 }, 22192 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) 22193 x: function(date, token, _localize) { 22194 const timezoneOffset = date.getTimezoneOffset(); 22195 switch (token) { 22196 // Hours and optional minutes 22197 case "x": 22198 return formatTimezoneWithOptionalMinutes(timezoneOffset); 22199 // Hours, minutes and optional seconds without `:` delimiter 22200 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 22201 // so this token always has the same output as `xx` 22202 case "xxxx": 22203 case "xx": 22204 return formatTimezone(timezoneOffset); 22205 // Hours, minutes and optional seconds with `:` delimiter 22206 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 22207 // so this token always has the same output as `xxx` 22208 case "xxxxx": 22209 case "xxx": 22210 // Hours and minutes with `:` delimiter 22211 default: 22212 return formatTimezone(timezoneOffset, ":"); 22213 } 22214 }, 22215 // Timezone (GMT) 22216 O: function(date, token, _localize) { 22217 const timezoneOffset = date.getTimezoneOffset(); 22218 switch (token) { 22219 // Short 22220 case "O": 22221 case "OO": 22222 case "OOO": 22223 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 22224 // Long 22225 case "OOOO": 22226 default: 22227 return "GMT" + formatTimezone(timezoneOffset, ":"); 22228 } 22229 }, 22230 // Timezone (specific non-location) 22231 z: function(date, token, _localize) { 22232 const timezoneOffset = date.getTimezoneOffset(); 22233 switch (token) { 22234 // Short 22235 case "z": 22236 case "zz": 22237 case "zzz": 22238 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 22239 // Long 22240 case "zzzz": 22241 default: 22242 return "GMT" + formatTimezone(timezoneOffset, ":"); 22243 } 22244 }, 22245 // Seconds timestamp 22246 t: function(date, token, _localize) { 22247 const timestamp = Math.trunc(+date / 1e3); 22248 return addLeadingZeros(timestamp, token.length); 22249 }, 22250 // Milliseconds timestamp 22251 T: function(date, token, _localize) { 22252 return addLeadingZeros(+date, token.length); 22253 } 22254 }; 22255 function formatTimezoneShort(offset4, delimiter = "") { 22256 const sign = offset4 > 0 ? "-" : "+"; 22257 const absOffset = Math.abs(offset4); 22258 const hours = Math.trunc(absOffset / 60); 22259 const minutes = absOffset % 60; 22260 if (minutes === 0) { 22261 return sign + String(hours); 22262 } 22263 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); 22264 } 22265 function formatTimezoneWithOptionalMinutes(offset4, delimiter) { 22266 if (offset4 % 60 === 0) { 22267 const sign = offset4 > 0 ? "-" : "+"; 22268 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2); 22269 } 22270 return formatTimezone(offset4, delimiter); 22271 } 22272 function formatTimezone(offset4, delimiter = "") { 22273 const sign = offset4 > 0 ? "-" : "+"; 22274 const absOffset = Math.abs(offset4); 22275 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2); 22276 const minutes = addLeadingZeros(absOffset % 60, 2); 22277 return sign + hours + delimiter + minutes; 22278 } 22279 22280 // node_modules/date-fns/_lib/format/longFormatters.js 22281 var dateLongFormatter = (pattern, formatLong2) => { 22282 switch (pattern) { 22283 case "P": 22284 return formatLong2.date({ width: "short" }); 22285 case "PP": 22286 return formatLong2.date({ width: "medium" }); 22287 case "PPP": 22288 return formatLong2.date({ width: "long" }); 22289 case "PPPP": 22290 default: 22291 return formatLong2.date({ width: "full" }); 22292 } 22293 }; 22294 var timeLongFormatter = (pattern, formatLong2) => { 22295 switch (pattern) { 22296 case "p": 22297 return formatLong2.time({ width: "short" }); 22298 case "pp": 22299 return formatLong2.time({ width: "medium" }); 22300 case "ppp": 22301 return formatLong2.time({ width: "long" }); 22302 case "pppp": 22303 default: 22304 return formatLong2.time({ width: "full" }); 22305 } 22306 }; 22307 var dateTimeLongFormatter = (pattern, formatLong2) => { 22308 const matchResult = pattern.match(/(P+)(p+)?/) || []; 22309 const datePattern = matchResult[1]; 22310 const timePattern = matchResult[2]; 22311 if (!timePattern) { 22312 return dateLongFormatter(pattern, formatLong2); 22313 } 22314 let dateTimeFormat; 22315 switch (datePattern) { 22316 case "P": 22317 dateTimeFormat = formatLong2.dateTime({ width: "short" }); 22318 break; 22319 case "PP": 22320 dateTimeFormat = formatLong2.dateTime({ width: "medium" }); 22321 break; 22322 case "PPP": 22323 dateTimeFormat = formatLong2.dateTime({ width: "long" }); 22324 break; 22325 case "PPPP": 22326 default: 22327 dateTimeFormat = formatLong2.dateTime({ width: "full" }); 22328 break; 22329 } 22330 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); 22331 }; 22332 var longFormatters = { 22333 p: timeLongFormatter, 22334 P: dateTimeLongFormatter 22335 }; 22336 22337 // node_modules/date-fns/_lib/protectedTokens.js 22338 var dayOfYearTokenRE = /^D+$/; 22339 var weekYearTokenRE = /^Y+$/; 22340 var throwTokens = ["D", "DD", "YY", "YYYY"]; 22341 function isProtectedDayOfYearToken(token) { 22342 return dayOfYearTokenRE.test(token); 22343 } 22344 function isProtectedWeekYearToken(token) { 22345 return weekYearTokenRE.test(token); 22346 } 22347 function warnOrThrowProtectedError(token, format6, input) { 22348 const _message = message(token, format6, input); 22349 console.warn(_message); 22350 if (throwTokens.includes(token)) throw new RangeError(_message); 22351 } 22352 function message(token, format6, input) { 22353 const subject = token[0] === "Y" ? "years" : "days of the month"; 22354 return `Use \`$token.toLowerCase()}\` instead of \`$token}\` (in \`$format6}\`) for formatting $subject} to the input \`$input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`; 22355 } 22356 22357 // node_modules/date-fns/format.js 22358 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; 22359 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; 22360 var escapedStringRegExp = /^'([^]*?)'?$/; 22361 var doubleQuoteRegExp = /''/g; 22362 var unescapedLatinCharacterRegExp = /[a-zA-Z]/; 22363 function format(date, formatStr, options) { 22364 const defaultOptions2 = getDefaultOptions(); 22365 const locale = options?.locale ?? defaultOptions2.locale ?? enUS; 22366 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 22367 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 22368 const originalDate = toDate(date, options?.in); 22369 if (!isValid(originalDate)) { 22370 throw new RangeError("Invalid time value"); 22371 } 22372 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { 22373 const firstCharacter = substring[0]; 22374 if (firstCharacter === "p" || firstCharacter === "P") { 22375 const longFormatter = longFormatters[firstCharacter]; 22376 return longFormatter(substring, locale.formatLong); 22377 } 22378 return substring; 22379 }).join("").match(formattingTokensRegExp).map((substring) => { 22380 if (substring === "''") { 22381 return { isToken: false, value: "'" }; 22382 } 22383 const firstCharacter = substring[0]; 22384 if (firstCharacter === "'") { 22385 return { isToken: false, value: cleanEscapedString(substring) }; 22386 } 22387 if (formatters[firstCharacter]) { 22388 return { isToken: true, value: substring }; 22389 } 22390 if (firstCharacter.match(unescapedLatinCharacterRegExp)) { 22391 throw new RangeError( 22392 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" 22393 ); 22394 } 22395 return { isToken: false, value: substring }; 22396 }); 22397 if (locale.localize.preprocessor) { 22398 parts = locale.localize.preprocessor(originalDate, parts); 22399 } 22400 const formatterOptions = { 22401 firstWeekContainsDate, 22402 weekStartsOn, 22403 locale 22404 }; 22405 return parts.map((part) => { 22406 if (!part.isToken) return part.value; 22407 const token = part.value; 22408 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) { 22409 warnOrThrowProtectedError(token, formatStr, String(date)); 22410 } 22411 const formatter = formatters[token[0]]; 22412 return formatter(originalDate, token, locale.localize, formatterOptions); 22413 }).join(""); 22414 } 22415 function cleanEscapedString(input) { 22416 const matched = input.match(escapedStringRegExp); 22417 if (!matched) { 22418 return input; 22419 } 22420 return matched[1].replace(doubleQuoteRegExp, "'"); 22421 } 22422 22423 // node_modules/date-fns/subDays.js 22424 function subDays(date, amount, options) { 22425 return addDays(date, -amount, options); 22426 } 22427 22428 // node_modules/date-fns/subMonths.js 22429 function subMonths(date, amount, options) { 22430 return addMonths(date, -amount, options); 22431 } 22432 22433 // node_modules/date-fns/subWeeks.js 22434 function subWeeks(date, amount, options) { 22435 return addWeeks(date, -amount, options); 22436 } 22437 22438 // node_modules/date-fns/subYears.js 22439 function subYears(date, amount, options) { 22440 return addYears(date, -amount, options); 22441 } 22442 22443 // packages/dataviews/build-module/utils/operators.mjs 22444 var import_i18n23 = __toESM(require_i18n(), 1); 22445 var import_element57 = __toESM(require_element(), 1); 22446 var import_date = __toESM(require_date(), 1); 22447 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1); 22448 var filterTextWrappers = { 22449 Name: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }), 22450 Value: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" }) 22451 }; 22452 function getRelativeDate(value, unit) { 22453 switch (unit) { 22454 case "days": 22455 return subDays(/* @__PURE__ */ new Date(), value); 22456 case "weeks": 22457 return subWeeks(/* @__PURE__ */ new Date(), value); 22458 case "months": 22459 return subMonths(/* @__PURE__ */ new Date(), value); 22460 case "years": 22461 return subYears(/* @__PURE__ */ new Date(), value); 22462 default: 22463 return /* @__PURE__ */ new Date(); 22464 } 22465 } 22466 var isNoneOperatorDefinition = { 22467 /* translators: DataViews operator name */ 22468 label: (0, import_i18n23.__)("Is none of"), 22469 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22470 (0, import_i18n23.sprintf)( 22471 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 22472 (0, import_i18n23.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 22473 filter.name, 22474 activeElements.map((element) => element.label).join(", ") 22475 ), 22476 filterTextWrappers 22477 ), 22478 filter: ((item, field, filterValue) => { 22479 if (!filterValue?.length) { 22480 return true; 22481 } 22482 const fieldValue = field.getValue({ item }); 22483 if (Array.isArray(fieldValue)) { 22484 return !filterValue.some( 22485 (fv) => fieldValue.includes(fv) 22486 ); 22487 } else if (typeof fieldValue === "string") { 22488 return !filterValue.includes(fieldValue); 22489 } 22490 return false; 22491 }), 22492 selection: "multi" 22493 }; 22494 var OPERATORS = [ 22495 { 22496 name: OPERATOR_IS_ANY, 22497 /* translators: DataViews operator name */ 22498 label: (0, import_i18n23.__)("Includes"), 22499 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22500 (0, import_i18n23.sprintf)( 22501 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ 22502 (0, import_i18n23.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"), 22503 filter.name, 22504 activeElements.map((element) => element.label).join(", ") 22505 ), 22506 filterTextWrappers 22507 ), 22508 filter(item, field, filterValue) { 22509 if (!filterValue?.length) { 22510 return true; 22511 } 22512 const fieldValue = field.getValue({ item }); 22513 if (Array.isArray(fieldValue)) { 22514 return filterValue.some( 22515 (fv) => fieldValue.includes(fv) 22516 ); 22517 } else if (typeof fieldValue === "string") { 22518 return filterValue.includes(fieldValue); 22519 } 22520 return false; 22521 }, 22522 selection: "multi" 22523 }, 22524 { 22525 name: OPERATOR_IS_NONE, 22526 ...isNoneOperatorDefinition 22527 }, 22528 { 22529 name: OPERATOR_IS_ALL, 22530 /* translators: DataViews operator name */ 22531 label: (0, import_i18n23.__)("Includes all"), 22532 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22533 (0, import_i18n23.sprintf)( 22534 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ 22535 (0, import_i18n23.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"), 22536 filter.name, 22537 activeElements.map((element) => element.label).join(", ") 22538 ), 22539 filterTextWrappers 22540 ), 22541 filter(item, field, filterValue) { 22542 if (!filterValue?.length) { 22543 return true; 22544 } 22545 return filterValue.every((value) => { 22546 return field.getValue({ item })?.includes(value); 22547 }); 22548 }, 22549 selection: "multi" 22550 }, 22551 { 22552 name: OPERATOR_IS_NOT_ALL, 22553 ...isNoneOperatorDefinition 22554 }, 22555 { 22556 name: OPERATOR_BETWEEN, 22557 /* translators: DataViews operator name */ 22558 label: (0, import_i18n23.__)("Between (inc)"), 22559 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22560 (0, import_i18n23.sprintf)( 22561 /* translators: 1: Filter name (e.g. "Item count"). 2: Filter value min. 3: Filter value max. e.g.: "Item count between (inc): 10 and 180". */ 22562 (0, import_i18n23.__)( 22563 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>" 22564 ), 22565 filter.name, 22566 activeElements[0].label[0], 22567 activeElements[0].label[1] 22568 ), 22569 filterTextWrappers 22570 ), 22571 filter(item, field, filterValue) { 22572 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) { 22573 return true; 22574 } 22575 const fieldValue = field.getValue({ item }); 22576 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") { 22577 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1]; 22578 } 22579 return false; 22580 }, 22581 selection: "custom" 22582 }, 22583 { 22584 name: OPERATOR_IN_THE_PAST, 22585 /* translators: DataViews operator name */ 22586 label: (0, import_i18n23.__)("In the past"), 22587 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22588 (0, import_i18n23.sprintf)( 22589 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ 22590 (0, import_i18n23.__)( 22591 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>" 22592 ), 22593 filter.name, 22594 `$activeElements[0].value.value} $activeElements[0].value.unit}` 22595 ), 22596 filterTextWrappers 22597 ), 22598 filter(item, field, filterValue) { 22599 if (filterValue?.value === void 0 || filterValue?.unit === void 0) { 22600 return true; 22601 } 22602 const targetDate = getRelativeDate( 22603 filterValue.value, 22604 filterValue.unit 22605 ); 22606 const fieldValue = (0, import_date.getDate)(field.getValue({ item })); 22607 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date(); 22608 }, 22609 selection: "custom" 22610 }, 22611 { 22612 name: OPERATOR_OVER, 22613 /* translators: DataViews operator name */ 22614 label: (0, import_i18n23.__)("Over"), 22615 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22616 (0, import_i18n23.sprintf)( 22617 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ 22618 (0, import_i18n23.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"), 22619 filter.name, 22620 `$activeElements[0].value.value} $activeElements[0].value.unit}` 22621 ), 22622 filterTextWrappers 22623 ), 22624 filter(item, field, filterValue) { 22625 if (filterValue?.value === void 0 || filterValue?.unit === void 0) { 22626 return true; 22627 } 22628 const targetDate = getRelativeDate( 22629 filterValue.value, 22630 filterValue.unit 22631 ); 22632 const fieldValue = (0, import_date.getDate)(field.getValue({ item })); 22633 return fieldValue < targetDate; 22634 }, 22635 selection: "custom" 22636 }, 22637 { 22638 name: OPERATOR_IS, 22639 /* translators: DataViews operator name */ 22640 label: (0, import_i18n23.__)("Is"), 22641 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22642 (0, import_i18n23.sprintf)( 22643 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ 22644 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 22645 filter.name, 22646 activeElements[0].label 22647 ), 22648 filterTextWrappers 22649 ), 22650 filter(item, field, filterValue) { 22651 return filterValue === field.getValue({ item }) || filterValue === void 0; 22652 }, 22653 selection: "single" 22654 }, 22655 { 22656 name: OPERATOR_IS_NOT, 22657 /* translators: DataViews operator name */ 22658 label: (0, import_i18n23.__)("Is not"), 22659 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22660 (0, import_i18n23.sprintf)( 22661 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ 22662 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 22663 filter.name, 22664 activeElements[0].label 22665 ), 22666 filterTextWrappers 22667 ), 22668 filter(item, field, filterValue) { 22669 return filterValue !== field.getValue({ item }); 22670 }, 22671 selection: "single" 22672 }, 22673 { 22674 name: OPERATOR_LESS_THAN, 22675 /* translators: DataViews operator name */ 22676 label: (0, import_i18n23.__)("Less than"), 22677 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22678 (0, import_i18n23.sprintf)( 22679 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ 22680 (0, import_i18n23.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"), 22681 filter.name, 22682 activeElements[0].label 22683 ), 22684 filterTextWrappers 22685 ), 22686 filter(item, field, filterValue) { 22687 if (filterValue === void 0) { 22688 return true; 22689 } 22690 const fieldValue = field.getValue({ item }); 22691 return fieldValue < filterValue; 22692 }, 22693 selection: "single" 22694 }, 22695 { 22696 name: OPERATOR_GREATER_THAN, 22697 /* translators: DataViews operator name */ 22698 label: (0, import_i18n23.__)("Greater than"), 22699 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22700 (0, import_i18n23.sprintf)( 22701 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ 22702 (0, import_i18n23.__)( 22703 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>" 22704 ), 22705 filter.name, 22706 activeElements[0].label 22707 ), 22708 filterTextWrappers 22709 ), 22710 filter(item, field, filterValue) { 22711 if (filterValue === void 0) { 22712 return true; 22713 } 22714 const fieldValue = field.getValue({ item }); 22715 return fieldValue > filterValue; 22716 }, 22717 selection: "single" 22718 }, 22719 { 22720 name: OPERATOR_LESS_THAN_OR_EQUAL, 22721 /* translators: DataViews operator name */ 22722 label: (0, import_i18n23.__)("Less than or equal"), 22723 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22724 (0, import_i18n23.sprintf)( 22725 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ 22726 (0, import_i18n23.__)( 22727 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>" 22728 ), 22729 filter.name, 22730 activeElements[0].label 22731 ), 22732 filterTextWrappers 22733 ), 22734 filter(item, field, filterValue) { 22735 if (filterValue === void 0) { 22736 return true; 22737 } 22738 const fieldValue = field.getValue({ item }); 22739 return fieldValue <= filterValue; 22740 }, 22741 selection: "single" 22742 }, 22743 { 22744 name: OPERATOR_GREATER_THAN_OR_EQUAL, 22745 /* translators: DataViews operator name */ 22746 label: (0, import_i18n23.__)("Greater than or equal"), 22747 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22748 (0, import_i18n23.sprintf)( 22749 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ 22750 (0, import_i18n23.__)( 22751 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>" 22752 ), 22753 filter.name, 22754 activeElements[0].label 22755 ), 22756 filterTextWrappers 22757 ), 22758 filter(item, field, filterValue) { 22759 if (filterValue === void 0) { 22760 return true; 22761 } 22762 const fieldValue = field.getValue({ item }); 22763 return fieldValue >= filterValue; 22764 }, 22765 selection: "single" 22766 }, 22767 { 22768 name: OPERATOR_BEFORE, 22769 /* translators: DataViews operator name */ 22770 label: (0, import_i18n23.__)("Before"), 22771 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22772 (0, import_i18n23.sprintf)( 22773 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ 22774 (0, import_i18n23.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"), 22775 filter.name, 22776 activeElements[0].label 22777 ), 22778 filterTextWrappers 22779 ), 22780 filter(item, field, filterValue) { 22781 if (filterValue === void 0) { 22782 return true; 22783 } 22784 const filterDate = (0, import_date.getDate)(filterValue); 22785 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 22786 return fieldDate < filterDate; 22787 }, 22788 selection: "single" 22789 }, 22790 { 22791 name: OPERATOR_AFTER, 22792 /* translators: DataViews operator name */ 22793 label: (0, import_i18n23.__)("After"), 22794 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22795 (0, import_i18n23.sprintf)( 22796 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ 22797 (0, import_i18n23.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"), 22798 filter.name, 22799 activeElements[0].label 22800 ), 22801 filterTextWrappers 22802 ), 22803 filter(item, field, filterValue) { 22804 if (filterValue === void 0) { 22805 return true; 22806 } 22807 const filterDate = (0, import_date.getDate)(filterValue); 22808 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 22809 return fieldDate > filterDate; 22810 }, 22811 selection: "single" 22812 }, 22813 { 22814 name: OPERATOR_BEFORE_INC, 22815 /* translators: DataViews operator name */ 22816 label: (0, import_i18n23.__)("Before (inc)"), 22817 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22818 (0, import_i18n23.sprintf)( 22819 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ 22820 (0, import_i18n23.__)( 22821 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>" 22822 ), 22823 filter.name, 22824 activeElements[0].label 22825 ), 22826 filterTextWrappers 22827 ), 22828 filter(item, field, filterValue) { 22829 if (filterValue === void 0) { 22830 return true; 22831 } 22832 const filterDate = (0, import_date.getDate)(filterValue); 22833 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 22834 return fieldDate <= filterDate; 22835 }, 22836 selection: "single" 22837 }, 22838 { 22839 name: OPERATOR_AFTER_INC, 22840 /* translators: DataViews operator name */ 22841 label: (0, import_i18n23.__)("After (inc)"), 22842 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22843 (0, import_i18n23.sprintf)( 22844 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ 22845 (0, import_i18n23.__)( 22846 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>" 22847 ), 22848 filter.name, 22849 activeElements[0].label 22850 ), 22851 filterTextWrappers 22852 ), 22853 filter(item, field, filterValue) { 22854 if (filterValue === void 0) { 22855 return true; 22856 } 22857 const filterDate = (0, import_date.getDate)(filterValue); 22858 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 22859 return fieldDate >= filterDate; 22860 }, 22861 selection: "single" 22862 }, 22863 { 22864 name: OPERATOR_CONTAINS, 22865 /* translators: DataViews operator name */ 22866 label: (0, import_i18n23.__)("Contains"), 22867 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22868 (0, import_i18n23.sprintf)( 22869 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ 22870 (0, import_i18n23.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"), 22871 filter.name, 22872 activeElements[0].label 22873 ), 22874 filterTextWrappers 22875 ), 22876 filter(item, field, filterValue) { 22877 if (filterValue === void 0) { 22878 return true; 22879 } 22880 const fieldValue = field.getValue({ item }); 22881 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase()); 22882 }, 22883 selection: "single" 22884 }, 22885 { 22886 name: OPERATOR_NOT_CONTAINS, 22887 /* translators: DataViews operator name */ 22888 label: (0, import_i18n23.__)("Doesn't contain"), 22889 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22890 (0, import_i18n23.sprintf)( 22891 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ 22892 (0, import_i18n23.__)( 22893 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>" 22894 ), 22895 filter.name, 22896 activeElements[0].label 22897 ), 22898 filterTextWrappers 22899 ), 22900 filter(item, field, filterValue) { 22901 if (filterValue === void 0) { 22902 return true; 22903 } 22904 const fieldValue = field.getValue({ item }); 22905 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase()); 22906 }, 22907 selection: "single" 22908 }, 22909 { 22910 name: OPERATOR_STARTS_WITH, 22911 /* translators: DataViews operator name */ 22912 label: (0, import_i18n23.__)("Starts with"), 22913 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22914 (0, import_i18n23.sprintf)( 22915 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ 22916 (0, import_i18n23.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"), 22917 filter.name, 22918 activeElements[0].label 22919 ), 22920 filterTextWrappers 22921 ), 22922 filter(item, field, filterValue) { 22923 if (filterValue === void 0) { 22924 return true; 22925 } 22926 const fieldValue = field.getValue({ item }); 22927 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase()); 22928 }, 22929 selection: "single" 22930 }, 22931 { 22932 name: OPERATOR_ON, 22933 /* translators: DataViews operator name */ 22934 label: (0, import_i18n23.__)("On"), 22935 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22936 (0, import_i18n23.sprintf)( 22937 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ 22938 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 22939 filter.name, 22940 activeElements[0].label 22941 ), 22942 filterTextWrappers 22943 ), 22944 filter(item, field, filterValue) { 22945 if (filterValue === void 0) { 22946 return true; 22947 } 22948 const filterDate = (0, import_date.getDate)(filterValue); 22949 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 22950 return filterDate.getTime() === fieldDate.getTime(); 22951 }, 22952 selection: "single" 22953 }, 22954 { 22955 name: OPERATOR_NOT_ON, 22956 /* translators: DataViews operator name */ 22957 label: (0, import_i18n23.__)("Not on"), 22958 filterText: (filter, activeElements) => (0, import_element57.createInterpolateElement)( 22959 (0, import_i18n23.sprintf)( 22960 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ 22961 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 22962 filter.name, 22963 activeElements[0].label 22964 ), 22965 filterTextWrappers 22966 ), 22967 filter(item, field, filterValue) { 22968 if (filterValue === void 0) { 22969 return true; 22970 } 22971 const filterDate = (0, import_date.getDate)(filterValue); 22972 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 22973 return filterDate.getTime() !== fieldDate.getTime(); 22974 }, 22975 selection: "single" 22976 } 22977 ]; 22978 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name); 22979 var getAllOperatorNames = () => OPERATORS.map((op) => op.name); 22980 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some( 22981 (op) => op.name === name 22982 ); 22983 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name); 22984 22985 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs 22986 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1); 22987 var ENTER = "Enter"; 22988 var SPACE = " "; 22989 var FilterText = ({ 22990 activeElements, 22991 filterInView, 22992 filter 22993 }) => { 22994 if (activeElements === void 0 || activeElements.length === 0) { 22995 return filter.name; 22996 } 22997 const operator = getOperatorByName(filterInView?.operator); 22998 if (operator !== void 0) { 22999 return operator.filterText(filter, activeElements); 23000 } 23001 return (0, import_i18n24.sprintf)( 23002 /* translators: 1: Filter name e.g.: "Unknown status for Author". */ 23003 (0, import_i18n24.__)("Unknown status for %1$s"), 23004 filter.name 23005 ); 23006 }; 23007 function OperatorSelector({ 23008 filter, 23009 view, 23010 onChangeView 23011 }) { 23012 const operatorOptions = filter.operators?.map((operator) => ({ 23013 value: operator, 23014 label: getOperatorByName(operator)?.label || operator 23015 })); 23016 const currentFilter = view.filters?.find( 23017 (_filter) => _filter.field === filter.field 23018 ); 23019 const value = currentFilter?.operator || filter.operators[0]; 23020 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)( 23021 Stack, 23022 { 23023 direction: "row", 23024 gap: "sm", 23025 justify: "flex-start", 23026 className: "dataviews-filters__summary-operators-container", 23027 align: "center", 23028 children: [ 23029 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components22.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }), 23030 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 23031 import_components22.SelectControl, 23032 { 23033 className: "dataviews-filters__summary-operators-filter-select", 23034 label: (0, import_i18n24.__)("Conditions"), 23035 value, 23036 options: operatorOptions, 23037 onChange: (newValue) => { 23038 const newOperator = newValue; 23039 const currentOperator = currentFilter?.operator; 23040 const newFilters = currentFilter ? [ 23041 ...(view.filters ?? []).map( 23042 (_filter) => { 23043 if (_filter.field === filter.field) { 23044 const currentOpSelectionModel = getOperatorByName( 23045 currentOperator 23046 )?.selection; 23047 const newOpSelectionModel = getOperatorByName( 23048 newOperator 23049 )?.selection; 23050 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [ 23051 currentOpSelectionModel, 23052 newOpSelectionModel 23053 ].includes("custom"); 23054 return { 23055 ..._filter, 23056 value: shouldResetValue ? void 0 : _filter.value, 23057 operator: newOperator 23058 }; 23059 } 23060 return _filter; 23061 } 23062 ) 23063 ] : [ 23064 ...view.filters ?? [], 23065 { 23066 field: filter.field, 23067 operator: newOperator, 23068 value: void 0 23069 } 23070 ]; 23071 onChangeView({ 23072 ...view, 23073 page: 1, 23074 filters: newFilters 23075 }); 23076 }, 23077 size: "small", 23078 variant: "minimal", 23079 hideLabelFromVision: true 23080 } 23081 ) 23082 ] 23083 } 23084 ); 23085 } 23086 function Filter({ 23087 addFilterRef, 23088 openedFilter, 23089 fields: fields2, 23090 ...commonProps 23091 }) { 23092 const toggleRef = (0, import_element58.useRef)(null); 23093 const { filter, view, onChangeView } = commonProps; 23094 const filterInView = view.filters?.find( 23095 (f2) => f2.field === filter.field 23096 ); 23097 let activeElements = []; 23098 const field = (0, import_element58.useMemo)(() => { 23099 const currentField = fields2.find((f2) => f2.id === filter.field); 23100 if (currentField) { 23101 return { 23102 ...currentField, 23103 // Configure getValue as if Item was a plain object. 23104 // See related input-widget.tsx 23105 getValue: ({ item }) => item[currentField.id] 23106 }; 23107 } 23108 return currentField; 23109 }, [fields2, filter.field]); 23110 const { elements } = useElements({ 23111 elements: filter.elements, 23112 getElements: filter.getElements 23113 }); 23114 if (elements.length > 0) { 23115 activeElements = elements.filter((element) => { 23116 if (filter.singleSelection) { 23117 return element.value === filterInView?.value; 23118 } 23119 return filterInView?.value?.includes(element.value); 23120 }); 23121 } else if (Array.isArray(filterInView?.value)) { 23122 const label = filterInView.value.map((v2) => { 23123 const formattedValue = field?.getValueFormatted({ 23124 item: { [field.id]: v2 }, 23125 field 23126 }); 23127 return formattedValue || String(v2); 23128 }); 23129 activeElements = [ 23130 { 23131 value: filterInView.value, 23132 // @ts-ignore 23133 label 23134 } 23135 ]; 23136 } else if (typeof filterInView?.value === "object") { 23137 activeElements = [ 23138 { value: filterInView.value, label: filterInView.value } 23139 ]; 23140 } else if (filterInView?.value !== void 0) { 23141 const label = field !== void 0 ? field.getValueFormatted({ 23142 item: { [field.id]: filterInView.value }, 23143 field 23144 }) : String(filterInView.value); 23145 activeElements = [ 23146 { 23147 value: filterInView.value, 23148 label 23149 } 23150 ]; 23151 } 23152 const isPrimary = filter.isPrimary; 23153 const isLocked = filterInView?.isLocked; 23154 const hasValues = !isLocked && filterInView?.value !== void 0; 23155 const canResetOrRemove = !isLocked && (!isPrimary || hasValues); 23156 const resetOrRemoveLabel = isPrimary ? (0, import_i18n24.__)("Reset") : (0, import_i18n24.__)("Remove"); 23157 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 23158 import_components22.Dropdown, 23159 { 23160 defaultOpen: openedFilter === filter.field, 23161 contentClassName: "dataviews-filters__summary-popover", 23162 popoverProps: { placement: "bottom-start", role: "dialog" }, 23163 onClose: () => { 23164 toggleRef.current?.focus(); 23165 }, 23166 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [ 23167 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(tooltip_exports.Root, { children: [ 23168 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 23169 tooltip_exports.Trigger, 23170 { 23171 render: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 23172 "div", 23173 { 23174 className: clsx_default( 23175 "dataviews-filters__summary-chip", 23176 { 23177 "has-reset": canResetOrRemove, 23178 "has-values": hasValues, 23179 "is-not-clickable": isLocked 23180 } 23181 ), 23182 role: "button", 23183 tabIndex: isLocked ? -1 : 0, 23184 onClick: () => { 23185 if (!isLocked) { 23186 onToggle(); 23187 } 23188 }, 23189 onKeyDown: (event) => { 23190 if (!isLocked && [ENTER, SPACE].includes( 23191 event.key 23192 )) { 23193 onToggle(); 23194 event.preventDefault(); 23195 } 23196 }, 23197 "aria-disabled": isLocked, 23198 "aria-pressed": isOpen, 23199 "aria-expanded": isOpen, 23200 ref: toggleRef, 23201 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 23202 FilterText, 23203 { 23204 activeElements, 23205 filterInView, 23206 filter 23207 } 23208 ) 23209 } 23210 ) 23211 } 23212 ), 23213 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(tooltip_exports.Popup, { children: (0, import_i18n24.sprintf)( 23214 /* translators: 1: Filter name. */ 23215 (0, import_i18n24.__)("Filter by: %1$s"), 23216 filter.name.toLowerCase() 23217 ) }) 23218 ] }), 23219 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(tooltip_exports.Root, { children: [ 23220 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 23221 tooltip_exports.Trigger, 23222 { 23223 render: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 23224 "button", 23225 { 23226 className: clsx_default( 23227 "dataviews-filters__summary-chip-remove", 23228 { "has-values": hasValues } 23229 ), 23230 "aria-label": resetOrRemoveLabel, 23231 onClick: () => { 23232 onChangeView({ 23233 ...view, 23234 page: 1, 23235 filters: view.filters?.filter( 23236 (_filter) => _filter.field !== filter.field 23237 ) 23238 }); 23239 if (!isPrimary) { 23240 addFilterRef.current?.focus(); 23241 } else { 23242 toggleRef.current?.focus(); 23243 } 23244 }, 23245 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components22.Icon, { icon: close_small_default }) 23246 } 23247 ) 23248 } 23249 ), 23250 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel }) 23251 ] }) 23252 ] }), 23253 renderContent: () => { 23254 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [ 23255 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(OperatorSelector, { ...commonProps }), 23256 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 23257 SearchWidget, 23258 { 23259 ...commonProps, 23260 filter: { 23261 ...commonProps.filter, 23262 elements 23263 } 23264 } 23265 ) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(InputWidget, { ...commonProps, fields: fields2 }) 23266 ] }); 23267 } 23268 } 23269 ); 23270 } 23271 23272 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs 23273 var import_components23 = __toESM(require_components(), 1); 23274 var import_i18n25 = __toESM(require_i18n(), 1); 23275 var import_element59 = __toESM(require_element(), 1); 23276 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1); 23277 var { Menu: Menu4 } = unlock2(import_components23.privateApis); 23278 function AddFilterMenu({ 23279 filters, 23280 view, 23281 onChangeView, 23282 setOpenedFilter, 23283 triggerProps 23284 }) { 23285 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 23286 return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu4, { children: [ 23287 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu4.TriggerButton, { ...triggerProps }), 23288 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => { 23289 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 23290 Menu4.Item, 23291 { 23292 onClick: () => { 23293 setOpenedFilter(filter.field); 23294 onChangeView({ 23295 ...view, 23296 page: 1, 23297 filters: [ 23298 ...view.filters || [], 23299 { 23300 field: filter.field, 23301 value: void 0, 23302 operator: filter.operators[0] 23303 } 23304 ] 23305 }); 23306 }, 23307 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu4.ItemLabel, { children: filter.name }) 23308 }, 23309 filter.field 23310 ); 23311 }) }) 23312 ] }); 23313 } 23314 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) { 23315 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) { 23316 return null; 23317 } 23318 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 23319 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 23320 AddFilterMenu, 23321 { 23322 triggerProps: { 23323 render: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 23324 import_components23.Button, 23325 { 23326 accessibleWhenDisabled: true, 23327 size: "compact", 23328 className: "dataviews-filters-button", 23329 variant: "tertiary", 23330 disabled: !inactiveFilters.length, 23331 ref 23332 } 23333 ), 23334 children: (0, import_i18n25.__)("Add filter") 23335 }, 23336 ...{ filters, view, onChangeView, setOpenedFilter } 23337 } 23338 ); 23339 } 23340 var add_filter_default = (0, import_element59.forwardRef)(AddFilter); 23341 23342 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs 23343 var import_components24 = __toESM(require_components(), 1); 23344 var import_i18n26 = __toESM(require_i18n(), 1); 23345 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1); 23346 function ResetFilter({ 23347 filters, 23348 view, 23349 onChangeView 23350 }) { 23351 const isPrimary = (field) => filters.some( 23352 (_filter) => _filter.field === field && _filter.isPrimary 23353 ); 23354 const isDisabled = !view.search && !view.filters?.some( 23355 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field)) 23356 ); 23357 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23358 import_components24.Button, 23359 { 23360 disabled: isDisabled, 23361 accessibleWhenDisabled: true, 23362 size: "compact", 23363 variant: "tertiary", 23364 className: "dataviews-filters__reset-button", 23365 onClick: () => { 23366 onChangeView({ 23367 ...view, 23368 page: 1, 23369 search: "", 23370 filters: view.filters?.filter((f2) => !!f2.isLocked) || [] 23371 }); 23372 }, 23373 children: (0, import_i18n26.__)("Reset") 23374 } 23375 ); 23376 } 23377 23378 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs 23379 var import_element60 = __toESM(require_element(), 1); 23380 function useFilters(fields2, view) { 23381 return (0, import_element60.useMemo)(() => { 23382 const filters = []; 23383 fields2.forEach((field) => { 23384 if (field.filterBy === false || !field.hasElements && !field.Edit) { 23385 return; 23386 } 23387 const operators = field.filterBy.operators; 23388 const isPrimary = !!field.filterBy?.isPrimary; 23389 const isLocked = view.filters?.some( 23390 (f2) => f2.field === field.id && !!f2.isLocked 23391 ) ?? false; 23392 filters.push({ 23393 field: field.id, 23394 name: field.label, 23395 elements: field.elements, 23396 getElements: field.getElements, 23397 hasElements: field.hasElements, 23398 singleSelection: operators.some( 23399 (op) => isSingleSelectionOperator(op) 23400 ), 23401 operators, 23402 isVisible: isLocked || isPrimary || !!view.filters?.some( 23403 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator) 23404 ), 23405 isPrimary, 23406 isLocked 23407 }); 23408 }); 23409 filters.sort((a2, b2) => { 23410 if (a2.isLocked && !b2.isLocked) { 23411 return -1; 23412 } 23413 if (!a2.isLocked && b2.isLocked) { 23414 return 1; 23415 } 23416 if (a2.isPrimary && !b2.isPrimary) { 23417 return -1; 23418 } 23419 if (!a2.isPrimary && b2.isPrimary) { 23420 return 1; 23421 } 23422 return a2.name.localeCompare(b2.name); 23423 }); 23424 return filters; 23425 }, [fields2, view]); 23426 } 23427 var use_filters_default = useFilters; 23428 23429 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs 23430 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1); 23431 function Filters({ className }) { 23432 const { fields: fields2, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element61.useContext)(dataviews_context_default); 23433 const addFilterRef = (0, import_element61.useRef)(null); 23434 const filters = use_filters_default(fields2, view); 23435 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 23436 add_filter_default, 23437 { 23438 filters, 23439 view, 23440 onChangeView, 23441 ref: addFilterRef, 23442 setOpenedFilter 23443 }, 23444 "add-filter" 23445 ); 23446 const visibleFilters = filters.filter((filter) => filter.isVisible); 23447 if (visibleFilters.length === 0) { 23448 return null; 23449 } 23450 const filterComponents = [ 23451 ...visibleFilters.map((filter) => { 23452 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 23453 Filter, 23454 { 23455 filter, 23456 view, 23457 fields: fields2, 23458 onChangeView, 23459 addFilterRef, 23460 openedFilter 23461 }, 23462 filter.field 23463 ); 23464 }), 23465 addFilter 23466 ]; 23467 filterComponents.push( 23468 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 23469 ResetFilter, 23470 { 23471 filters, 23472 view, 23473 onChangeView 23474 }, 23475 "reset-filters" 23476 ) 23477 ); 23478 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 23479 Stack, 23480 { 23481 direction: "row", 23482 justify: "flex-start", 23483 gap: "sm", 23484 style: { width: "fit-content" }, 23485 wrap: "wrap", 23486 className, 23487 children: filterComponents 23488 } 23489 ); 23490 } 23491 var filters_default = (0, import_element61.memo)(Filters); 23492 23493 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs 23494 var import_element62 = __toESM(require_element(), 1); 23495 var import_components25 = __toESM(require_components(), 1); 23496 var import_i18n27 = __toESM(require_i18n(), 1); 23497 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1); 23498 function FiltersToggle() { 23499 const { 23500 filters, 23501 view, 23502 onChangeView, 23503 setOpenedFilter, 23504 isShowingFilter, 23505 setIsShowingFilter 23506 } = (0, import_element62.useContext)(dataviews_context_default); 23507 const buttonRef = (0, import_element62.useRef)(null); 23508 const onChangeViewWithFilterVisibility = (0, import_element62.useCallback)( 23509 (_view) => { 23510 onChangeView(_view); 23511 setIsShowingFilter(true); 23512 }, 23513 [onChangeView, setIsShowingFilter] 23514 ); 23515 if (filters.length === 0) { 23516 return null; 23517 } 23518 const hasVisibleFilters = filters.some((filter) => filter.isVisible); 23519 const addFilterButtonProps = { 23520 label: (0, import_i18n27.__)("Add filter"), 23521 "aria-expanded": false, 23522 isPressed: false 23523 }; 23524 const toggleFiltersButtonProps = { 23525 label: (0, import_i18n27._x)("Filter", "verb"), 23526 "aria-expanded": isShowingFilter, 23527 isPressed: isShowingFilter, 23528 onClick: () => { 23529 if (!isShowingFilter) { 23530 setOpenedFilter(null); 23531 } 23532 setIsShowingFilter(!isShowingFilter); 23533 } 23534 }; 23535 const hasPrimaryOrLockedFilters = filters.some( 23536 (filter) => filter.isPrimary || filter.isLocked 23537 ); 23538 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 23539 import_components25.Button, 23540 { 23541 ref: buttonRef, 23542 className: "dataviews-filters__visibility-toggle", 23543 size: "compact", 23544 icon: funnel_default, 23545 disabled: hasPrimaryOrLockedFilters, 23546 accessibleWhenDisabled: true, 23547 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps 23548 } 23549 ); 23550 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 23551 AddFilterMenu, 23552 { 23553 filters, 23554 view, 23555 onChangeView: onChangeViewWithFilterVisibility, 23556 setOpenedFilter, 23557 triggerProps: { render: buttonComponent } 23558 } 23559 ) : /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 23560 FilterVisibilityToggle, 23561 { 23562 buttonRef, 23563 filtersCount: view.filters?.length, 23564 children: buttonComponent 23565 } 23566 ) }); 23567 } 23568 function FilterVisibilityToggle({ 23569 buttonRef, 23570 filtersCount, 23571 children 23572 }) { 23573 (0, import_element62.useEffect)( 23574 () => () => { 23575 buttonRef.current?.focus(); 23576 }, 23577 [buttonRef] 23578 ); 23579 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_jsx_runtime97.Fragment, { children: [ 23580 children, 23581 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount }) 23582 ] }); 23583 } 23584 var toggle_default = FiltersToggle; 23585 23586 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs 23587 var import_element63 = __toESM(require_element(), 1); 23588 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1); 23589 function FiltersToggled(props) { 23590 const { isShowingFilter } = (0, import_element63.useContext)(dataviews_context_default); 23591 if (!isShowingFilter) { 23592 return null; 23593 } 23594 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(filters_default, { ...props }); 23595 } 23596 var filters_toggled_default = FiltersToggled; 23597 23598 // packages/dataviews/build-module/components/dataviews-layout/index.mjs 23599 var import_element64 = __toESM(require_element(), 1); 23600 var import_components26 = __toESM(require_components(), 1); 23601 var import_i18n28 = __toESM(require_i18n(), 1); 23602 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1); 23603 function DataViewsLayout({ className }) { 23604 const { 23605 actions: actions2 = [], 23606 data, 23607 fields: fields2, 23608 getItemId, 23609 getItemLevel, 23610 hasInitiallyLoaded, 23611 isLoading, 23612 view, 23613 onChangeView, 23614 selection, 23615 onChangeSelection, 23616 setOpenedFilter, 23617 onClickItem, 23618 isItemClickable, 23619 renderItemLink, 23620 defaultLayouts, 23621 containerRef, 23622 empty = /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("p", { children: (0, import_i18n28.__)("No results") }) 23623 } = (0, import_element64.useContext)(dataviews_context_default); 23624 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, { 23625 delay: 200 23626 }); 23627 if (!hasInitiallyLoaded) { 23628 if (!isDelayedInitialLoading) { 23629 return null; 23630 } 23631 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components26.Spinner, {}) }) }); 23632 } 23633 const ViewComponent = VIEW_LAYOUTS.find( 23634 (v2) => v2.type === view.type && defaultLayouts[v2.type] 23635 )?.component; 23636 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 23637 ViewComponent, 23638 { 23639 className, 23640 actions: actions2, 23641 data, 23642 fields: fields2, 23643 getItemId, 23644 getItemLevel, 23645 isLoading, 23646 onChangeView, 23647 onChangeSelection, 23648 selection, 23649 setOpenedFilter, 23650 onClickItem, 23651 renderItemLink, 23652 isItemClickable, 23653 view, 23654 empty 23655 } 23656 ) }); 23657 } 23658 23659 // packages/dataviews/build-module/components/dataviews-footer/index.mjs 23660 var import_element65 = __toESM(require_element(), 1); 23661 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1); 23662 var EMPTY_ARRAY5 = []; 23663 function DataViewsFooter() { 23664 const { 23665 view, 23666 paginationInfo: { totalItems = 0, totalPages }, 23667 data, 23668 actions: actions2 = EMPTY_ARRAY5, 23669 isLoading, 23670 hasInitiallyLoaded 23671 } = (0, import_element65.useContext)(dataviews_context_default); 23672 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length; 23673 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing); 23674 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type); 23675 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) { 23676 return null; 23677 } 23678 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 23679 "div", 23680 { 23681 className: "dataviews-footer", 23682 inert: isRefreshing ? "true" : void 0, 23683 children: /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)( 23684 Stack, 23685 { 23686 direction: "row", 23687 justify: "end", 23688 align: "center", 23689 className: clsx_default("dataviews-footer__content", { 23690 "is-refreshing": isDelayedRefreshing 23691 }), 23692 gap: "sm", 23693 children: [ 23694 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(BulkActionsFooter, {}), 23695 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(dataviews_pagination_default, {}) 23696 ] 23697 } 23698 ) 23699 } 23700 ); 23701 } 23702 23703 // packages/dataviews/build-module/components/dataviews-search/index.mjs 23704 var import_i18n29 = __toESM(require_i18n(), 1); 23705 var import_element66 = __toESM(require_element(), 1); 23706 var import_components27 = __toESM(require_components(), 1); 23707 var import_compose9 = __toESM(require_compose(), 1); 23708 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1); 23709 var DataViewsSearch = (0, import_element66.memo)(function Search({ label }) { 23710 const { view, onChangeView } = (0, import_element66.useContext)(dataviews_context_default); 23711 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)( 23712 view.search 23713 ); 23714 (0, import_element66.useEffect)(() => { 23715 if (view.search !== debouncedSearch) { 23716 setSearch(view.search ?? ""); 23717 } 23718 }, [view.search, setSearch]); 23719 const onChangeViewRef = (0, import_element66.useRef)(onChangeView); 23720 const viewRef = (0, import_element66.useRef)(view); 23721 (0, import_element66.useEffect)(() => { 23722 onChangeViewRef.current = onChangeView; 23723 viewRef.current = view; 23724 }, [onChangeView, view]); 23725 (0, import_element66.useEffect)(() => { 23726 if (debouncedSearch !== viewRef.current?.search) { 23727 onChangeViewRef.current({ 23728 ...viewRef.current, 23729 page: view.page ? 1 : void 0, 23730 startPosition: view.startPosition ? 1 : void 0, 23731 search: debouncedSearch 23732 }); 23733 } 23734 }, [debouncedSearch]); 23735 const searchLabel = label || (0, import_i18n29.__)("Search"); 23736 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 23737 import_components27.SearchControl, 23738 { 23739 className: "dataviews-search", 23740 onChange: setSearch, 23741 value: search, 23742 label: searchLabel, 23743 placeholder: searchLabel, 23744 size: "compact" 23745 } 23746 ); 23747 }); 23748 var dataviews_search_default = DataViewsSearch; 23749 23750 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs 23751 var import_components28 = __toESM(require_components(), 1); 23752 var import_i18n30 = __toESM(require_i18n(), 1); 23753 var import_element67 = __toESM(require_element(), 1); 23754 var import_warning = __toESM(require_warning(), 1); 23755 var import_compose10 = __toESM(require_compose(), 1); 23756 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1); 23757 var { Menu: Menu5 } = unlock2(import_components28.privateApis); 23758 var DATAVIEWS_CONFIG_POPOVER_PROPS = { 23759 className: "dataviews-config__popover", 23760 placement: "bottom-end", 23761 offset: 9 23762 }; 23763 function ViewTypeMenu() { 23764 const { view, onChangeView, defaultLayouts } = (0, import_element67.useContext)(dataviews_context_default); 23765 const availableLayouts = Object.keys(defaultLayouts); 23766 if (availableLayouts.length <= 1) { 23767 return null; 23768 } 23769 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type); 23770 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(Menu5, { children: [ 23771 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23772 Menu5.TriggerButton, 23773 { 23774 render: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23775 import_components28.Button, 23776 { 23777 size: "compact", 23778 icon: activeView?.icon, 23779 label: (0, import_i18n30.__)("Layout") 23780 } 23781 ) 23782 } 23783 ), 23784 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => { 23785 const config = VIEW_LAYOUTS.find( 23786 (v2) => v2.type === layout 23787 ); 23788 if (!config) { 23789 return null; 23790 } 23791 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23792 Menu5.RadioItem, 23793 { 23794 value: layout, 23795 name: "view-actions-available-view", 23796 checked: layout === view.type, 23797 hideOnClick: true, 23798 onChange: (e2) => { 23799 switch (e2.target.value) { 23800 case "list": 23801 case "grid": 23802 case "table": 23803 case "pickerGrid": 23804 case "pickerTable": 23805 case "activity": 23806 const viewWithoutLayout = { ...view }; 23807 if ("layout" in viewWithoutLayout) { 23808 delete viewWithoutLayout.layout; 23809 } 23810 return onChangeView({ 23811 ...viewWithoutLayout, 23812 type: e2.target.value, 23813 ...defaultLayouts[e2.target.value] 23814 }); 23815 } 23816 (0, import_warning.default)("Invalid dataview"); 23817 }, 23818 children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(Menu5.ItemLabel, { children: config.label }) 23819 }, 23820 layout 23821 ); 23822 }) }) 23823 ] }); 23824 } 23825 function SortFieldControl() { 23826 const { view, fields: fields2, onChangeView } = (0, import_element67.useContext)(dataviews_context_default); 23827 const orderOptions = (0, import_element67.useMemo)(() => { 23828 const sortableFields = fields2.filter( 23829 (field) => field.enableSorting !== false 23830 ); 23831 return sortableFields.map((field) => { 23832 return { 23833 label: field.label, 23834 value: field.id 23835 }; 23836 }); 23837 }, [fields2]); 23838 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23839 import_components28.SelectControl, 23840 { 23841 __next40pxDefaultSize: true, 23842 label: (0, import_i18n30.__)("Sort by"), 23843 value: view.sort?.field, 23844 options: orderOptions, 23845 onChange: (value) => { 23846 onChangeView({ 23847 ...view, 23848 sort: { 23849 direction: view?.sort?.direction || "desc", 23850 field: value 23851 }, 23852 showLevels: false 23853 }); 23854 } 23855 } 23856 ); 23857 } 23858 function SortDirectionControl() { 23859 const { view, fields: fields2, onChangeView } = (0, import_element67.useContext)(dataviews_context_default); 23860 const sortableFields = fields2.filter( 23861 (field) => field.enableSorting !== false 23862 ); 23863 if (sortableFields.length === 0) { 23864 return null; 23865 } 23866 let value = view.sort?.direction; 23867 if (!value && view.sort?.field) { 23868 value = "desc"; 23869 } 23870 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23871 import_components28.__experimentalToggleGroupControl, 23872 { 23873 className: "dataviews-view-config__sort-direction", 23874 __next40pxDefaultSize: true, 23875 isBlock: true, 23876 label: (0, import_i18n30.__)("Order"), 23877 value, 23878 onChange: (newDirection) => { 23879 if (newDirection === "asc" || newDirection === "desc") { 23880 onChangeView({ 23881 ...view, 23882 sort: { 23883 direction: newDirection, 23884 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field. 23885 fields2.find( 23886 (field) => field.enableSorting !== false 23887 )?.id || "" 23888 }, 23889 showLevels: false 23890 }); 23891 return; 23892 } 23893 (0, import_warning.default)("Invalid direction"); 23894 }, 23895 children: SORTING_DIRECTIONS.map((direction) => { 23896 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23897 import_components28.__experimentalToggleGroupControlOptionIcon, 23898 { 23899 value: direction, 23900 icon: sortIcons[direction], 23901 label: sortLabels[direction] 23902 }, 23903 direction 23904 ); 23905 }) 23906 } 23907 ); 23908 } 23909 function ItemsPerPageControl() { 23910 const { view, config, onChangeView } = (0, import_element67.useContext)(dataviews_context_default); 23911 const { infiniteScrollEnabled } = view; 23912 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) { 23913 return null; 23914 } 23915 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23916 import_components28.__experimentalToggleGroupControl, 23917 { 23918 __next40pxDefaultSize: true, 23919 isBlock: true, 23920 label: (0, import_i18n30.__)("Items per page"), 23921 value: view.perPage || 10, 23922 disabled: !view?.sort?.field, 23923 onChange: (newItemsPerPage) => { 23924 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10); 23925 onChangeView({ 23926 ...view, 23927 perPage: newItemsPerPageNumber, 23928 page: 1 23929 }); 23930 }, 23931 children: config.perPageSizes.map((value) => { 23932 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23933 import_components28.__experimentalToggleGroupControlOption, 23934 { 23935 value, 23936 label: value.toString() 23937 }, 23938 value 23939 ); 23940 }) 23941 } 23942 ); 23943 } 23944 function ResetViewButton() { 23945 const { onReset } = (0, import_element67.useContext)(dataviews_context_default); 23946 if (onReset === void 0) { 23947 return null; 23948 } 23949 const isDisabled = onReset === false; 23950 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23951 import_components28.Button, 23952 { 23953 variant: "tertiary", 23954 size: "compact", 23955 disabled: isDisabled, 23956 accessibleWhenDisabled: true, 23957 className: "dataviews-view-config__reset-button", 23958 onClick: () => { 23959 if (typeof onReset === "function") { 23960 onReset(); 23961 } 23962 }, 23963 children: (0, import_i18n30.__)("Reset view") 23964 } 23965 ); 23966 } 23967 function DataviewsViewConfigDropdown() { 23968 const { view, onReset } = (0, import_element67.useContext)(dataviews_context_default); 23969 const popoverId = (0, import_compose10.useInstanceId)( 23970 _DataViewsViewConfig, 23971 "dataviews-view-config-dropdown" 23972 ); 23973 const activeLayout = VIEW_LAYOUTS.find( 23974 (layout) => layout.type === view.type 23975 ); 23976 const isModified = typeof onReset === "function"; 23977 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23978 import_components28.Dropdown, 23979 { 23980 expandOnMobile: true, 23981 popoverProps: { 23982 ...DATAVIEWS_CONFIG_POPOVER_PROPS, 23983 id: popoverId 23984 }, 23985 renderToggle: ({ onToggle, isOpen }) => { 23986 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [ 23987 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23988 import_components28.Button, 23989 { 23990 size: "compact", 23991 icon: cog_default, 23992 label: (0, import_i18n30._x)( 23993 "View options", 23994 "View is used as a noun" 23995 ), 23996 onClick: onToggle, 23997 "aria-expanded": isOpen ? "true" : "false", 23998 "aria-controls": popoverId 23999 } 24000 ), 24001 isModified && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("span", { className: "dataviews-view-config__modified-indicator" }) 24002 ] }); 24003 }, 24004 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 24005 import_components28.__experimentalDropdownContentWrapper, 24006 { 24007 paddingSize: "medium", 24008 className: "dataviews-config__popover-content-wrapper", 24009 children: /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)( 24010 Stack, 24011 { 24012 direction: "column", 24013 className: "dataviews-view-config", 24014 gap: "xl", 24015 children: [ 24016 /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)( 24017 Stack, 24018 { 24019 direction: "row", 24020 justify: "space-between", 24021 align: "center", 24022 className: "dataviews-view-config__header", 24023 children: [ 24024 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 24025 import_components28.__experimentalHeading, 24026 { 24027 level: 2, 24028 className: "dataviews-settings-section__title", 24029 children: (0, import_i18n30.__)("Appearance") 24030 } 24031 ), 24032 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(ResetViewButton, {}) 24033 ] 24034 } 24035 ), 24036 /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 24037 /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)( 24038 Stack, 24039 { 24040 direction: "row", 24041 gap: "sm", 24042 className: "dataviews-view-config__sort-controls", 24043 children: [ 24044 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(SortFieldControl, {}), 24045 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(SortDirectionControl, {}) 24046 ] 24047 } 24048 ), 24049 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(activeLayout.viewConfigOptions, {}), 24050 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(ItemsPerPageControl, {}), 24051 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(PropertiesSection, {}) 24052 ] }) 24053 ] 24054 } 24055 ) 24056 } 24057 ) 24058 } 24059 ); 24060 } 24061 function _DataViewsViewConfig() { 24062 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_jsx_runtime102.Fragment, { children: [ 24063 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(ViewTypeMenu, {}), 24064 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(DataviewsViewConfigDropdown, {}) 24065 ] }); 24066 } 24067 var DataViewsViewConfig = (0, import_element67.memo)(_DataViewsViewConfig); 24068 var dataviews_view_config_default = DataViewsViewConfig; 24069 24070 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs 24071 var import_components29 = __toESM(require_components(), 1); 24072 var import_element68 = __toESM(require_element(), 1); 24073 24074 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs 24075 function getCustomValidity(isValid2, validity) { 24076 let customValidity; 24077 if (isValid2?.required && validity?.required) { 24078 customValidity = validity?.required?.message ? validity.required : void 0; 24079 } else if (isValid2?.pattern && validity?.pattern) { 24080 customValidity = validity.pattern; 24081 } else if (isValid2?.min && validity?.min) { 24082 customValidity = validity.min; 24083 } else if (isValid2?.max && validity?.max) { 24084 customValidity = validity.max; 24085 } else if (isValid2?.minLength && validity?.minLength) { 24086 customValidity = validity.minLength; 24087 } else if (isValid2?.maxLength && validity?.maxLength) { 24088 customValidity = validity.maxLength; 24089 } else if (isValid2?.elements && validity?.elements) { 24090 customValidity = validity.elements; 24091 } else if (validity?.custom) { 24092 customValidity = validity.custom; 24093 } 24094 return customValidity; 24095 } 24096 24097 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs 24098 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1); 24099 var { ValidatedCheckboxControl } = unlock2(import_components29.privateApis); 24100 function Checkbox({ 24101 field, 24102 onChange, 24103 data, 24104 hideLabelFromVision, 24105 markWhenOptional, 24106 validity 24107 }) { 24108 const { getValue, setValue, label, description, isValid: isValid2 } = field; 24109 const disabled2 = field.isDisabled({ item: data, field }); 24110 const onChangeControl = (0, import_element68.useCallback)(() => { 24111 onChange( 24112 setValue({ item: data, value: !getValue({ item: data }) }) 24113 ); 24114 }, [data, getValue, onChange, setValue]); 24115 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 24116 ValidatedCheckboxControl, 24117 { 24118 required: !!field.isValid?.required, 24119 markWhenOptional, 24120 customValidity: getCustomValidity(isValid2, validity), 24121 hidden: hideLabelFromVision, 24122 label, 24123 help: description, 24124 checked: getValue({ item: data }), 24125 onChange: onChangeControl, 24126 disabled: disabled2 24127 } 24128 ); 24129 } 24130 24131 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs 24132 var import_components30 = __toESM(require_components(), 1); 24133 var import_element69 = __toESM(require_element(), 1); 24134 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1); 24135 var { ValidatedComboboxControl } = unlock2(import_components30.privateApis); 24136 function Combobox3({ 24137 data, 24138 field, 24139 onChange, 24140 hideLabelFromVision, 24141 validity 24142 }) { 24143 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field; 24144 const value = getValue({ item: data }) ?? ""; 24145 const onChangeControl = (0, import_element69.useCallback)( 24146 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })), 24147 [data, onChange, setValue] 24148 ); 24149 const { elements, isLoading } = useElements({ 24150 elements: field.elements, 24151 getElements: field.getElements 24152 }); 24153 if (isLoading) { 24154 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components30.Spinner, {}); 24155 } 24156 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 24157 ValidatedComboboxControl, 24158 { 24159 required: !!field.isValid?.required, 24160 customValidity: getCustomValidity(isValid2, validity), 24161 label, 24162 value, 24163 help: description, 24164 placeholder, 24165 options: elements, 24166 onChange: onChangeControl, 24167 hideLabelFromVision, 24168 allowReset: true, 24169 expandOnFocus: true 24170 } 24171 ); 24172 } 24173 24174 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs 24175 var import_components32 = __toESM(require_components(), 1); 24176 var import_element72 = __toESM(require_element(), 1); 24177 var import_i18n32 = __toESM(require_i18n(), 1); 24178 var import_date3 = __toESM(require_date(), 1); 24179 24180 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs 24181 var import_components31 = __toESM(require_components(), 1); 24182 var import_element70 = __toESM(require_element(), 1); 24183 var import_i18n31 = __toESM(require_i18n(), 1); 24184 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1); 24185 var TIME_UNITS_OPTIONS = { 24186 [OPERATOR_IN_THE_PAST]: [ 24187 { value: "days", label: (0, import_i18n31.__)("Days") }, 24188 { value: "weeks", label: (0, import_i18n31.__)("Weeks") }, 24189 { value: "months", label: (0, import_i18n31.__)("Months") }, 24190 { value: "years", label: (0, import_i18n31.__)("Years") } 24191 ], 24192 [OPERATOR_OVER]: [ 24193 { value: "days", label: (0, import_i18n31.__)("Days ago") }, 24194 { value: "weeks", label: (0, import_i18n31.__)("Weeks ago") }, 24195 { value: "months", label: (0, import_i18n31.__)("Months ago") }, 24196 { value: "years", label: (0, import_i18n31.__)("Years ago") } 24197 ] 24198 }; 24199 function RelativeDateControl({ 24200 className, 24201 data, 24202 field, 24203 onChange, 24204 hideLabelFromVision, 24205 operator 24206 }) { 24207 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"]; 24208 const { id, label, description, getValue, setValue } = field; 24209 const disabled2 = field.isDisabled({ item: data, field }); 24210 const fieldValue = getValue({ item: data }); 24211 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {}; 24212 const onChangeValue = (0, import_element70.useCallback)( 24213 (newValue) => onChange( 24214 setValue({ 24215 item: data, 24216 value: { value: Number(newValue), unit } 24217 }) 24218 ), 24219 [onChange, setValue, data, unit] 24220 ); 24221 const onChangeUnit = (0, import_element70.useCallback)( 24222 (newUnit) => onChange( 24223 setValue({ 24224 item: data, 24225 value: { value: relValue, unit: newUnit } 24226 }) 24227 ), 24228 [onChange, setValue, data, relValue] 24229 ); 24230 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 24231 import_components31.BaseControl, 24232 { 24233 id, 24234 className: clsx_default(className, "dataviews-controls__relative-date"), 24235 label, 24236 hideLabelFromVision, 24237 help: description, 24238 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(Stack, { direction: "row", gap: "sm", children: [ 24239 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 24240 import_components31.__experimentalNumberControl, 24241 { 24242 __next40pxDefaultSize: true, 24243 className: "dataviews-controls__relative-date-number", 24244 spinControls: "none", 24245 min: 1, 24246 step: 1, 24247 value: relValue, 24248 onChange: onChangeValue, 24249 disabled: disabled2 24250 } 24251 ), 24252 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 24253 import_components31.SelectControl, 24254 { 24255 className: "dataviews-controls__relative-date-unit", 24256 __next40pxDefaultSize: true, 24257 label: (0, import_i18n31.__)("Unit"), 24258 value: unit, 24259 options, 24260 onChange: onChangeUnit, 24261 hideLabelFromVision: true, 24262 disabled: disabled2 24263 } 24264 ) 24265 ] }) 24266 } 24267 ); 24268 } 24269 24270 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs 24271 var import_element71 = __toESM(require_element(), 1); 24272 function useDisabledDateMatchers(isValid2, parseDateFn) { 24273 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0; 24274 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0; 24275 const disabledMatchers = (0, import_element71.useMemo)(() => { 24276 const matchers = []; 24277 if (minConstraint) { 24278 const minDate = parseDateFn(minConstraint); 24279 if (minDate) { 24280 matchers.push({ before: minDate }); 24281 } 24282 } 24283 if (maxConstraint) { 24284 const maxDate = parseDateFn(maxConstraint); 24285 if (maxDate) { 24286 matchers.push({ after: maxDate }); 24287 } 24288 } 24289 return matchers.length > 0 ? matchers : void 0; 24290 }, [minConstraint, maxConstraint, parseDateFn]); 24291 return { minConstraint, maxConstraint, disabledMatchers }; 24292 } 24293 24294 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs 24295 var import_date2 = __toESM(require_date(), 1); 24296 function parseDateTime(dateTimeString) { 24297 if (!dateTimeString) { 24298 return null; 24299 } 24300 const parsed = (0, import_date2.getDate)(dateTimeString); 24301 return parsed && isValid(parsed) ? parsed : null; 24302 } 24303 24304 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs 24305 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1); 24306 var { DateCalendar, ValidatedInputControl } = unlock2(import_components32.privateApis); 24307 var formatDateTime = (value) => { 24308 if (!value) { 24309 return ""; 24310 } 24311 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value)); 24312 }; 24313 function CalendarDateTimeControl({ 24314 data, 24315 field, 24316 onChange, 24317 hideLabelFromVision, 24318 markWhenOptional, 24319 validity, 24320 config 24321 }) { 24322 const { compact } = config || {}; 24323 const { id, label, description, setValue, getValue, isValid: isValid2 } = field; 24324 const disabled2 = field.isDisabled({ item: data, field }); 24325 const fieldValue = getValue({ item: data }); 24326 const value = typeof fieldValue === "string" ? fieldValue : void 0; 24327 const [calendarMonth, setCalendarMonth] = (0, import_element72.useState)(() => { 24328 const parsedDate = parseDateTime(value); 24329 return parsedDate || /* @__PURE__ */ new Date(); 24330 }); 24331 const inputControlRef = (0, import_element72.useRef)(null); 24332 const validationTimeoutRef = (0, import_element72.useRef)(void 0); 24333 const previousFocusRef = (0, import_element72.useRef)(null); 24334 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime); 24335 const onChangeCallback = (0, import_element72.useCallback)( 24336 (newValue) => onChange(setValue({ item: data, value: newValue })), 24337 [data, onChange, setValue] 24338 ); 24339 (0, import_element72.useEffect)(() => { 24340 return () => { 24341 if (validationTimeoutRef.current) { 24342 clearTimeout(validationTimeoutRef.current); 24343 } 24344 }; 24345 }, []); 24346 const onSelectDate = (0, import_element72.useCallback)( 24347 (newDate) => { 24348 let dateTimeValue; 24349 if (newDate) { 24350 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate); 24351 let wpTime; 24352 if (value) { 24353 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value)); 24354 } else { 24355 wpTime = (0, import_date3.dateI18n)("H:i", newDate); 24356 } 24357 const finalDateTime = (0, import_date3.getDate)(`$wpDate}T$wpTime}`); 24358 dateTimeValue = finalDateTime.toISOString(); 24359 onChangeCallback(dateTimeValue); 24360 if (validationTimeoutRef.current) { 24361 clearTimeout(validationTimeoutRef.current); 24362 } 24363 } else { 24364 onChangeCallback(void 0); 24365 } 24366 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement; 24367 validationTimeoutRef.current = setTimeout(() => { 24368 if (inputControlRef.current) { 24369 inputControlRef.current.focus(); 24370 inputControlRef.current.blur(); 24371 onChangeCallback(dateTimeValue); 24372 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) { 24373 previousFocusRef.current.focus(); 24374 } 24375 } 24376 }, 0); 24377 }, 24378 [onChangeCallback, value] 24379 ); 24380 const handleManualDateTimeChange = (0, import_element72.useCallback)( 24381 (newValue) => { 24382 if (newValue) { 24383 const dateTime = (0, import_date3.getDate)(newValue); 24384 onChangeCallback(dateTime.toISOString()); 24385 const parsedDate = parseDateTime(dateTime.toISOString()); 24386 if (parsedDate) { 24387 setCalendarMonth(parsedDate); 24388 } 24389 } else { 24390 onChangeCallback(void 0); 24391 } 24392 }, 24393 [onChangeCallback] 24394 ); 24395 const { format: fieldFormat } = field; 24396 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 24397 const { 24398 timezone: { string: timezoneString } 24399 } = (0, import_date3.getSettings)(); 24400 let displayLabel = label; 24401 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) { 24402 displayLabel = `$label} (${(0, import_i18n32.__)("Required")})`; 24403 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) { 24404 displayLabel = `$label} (${(0, import_i18n32.__)("Optional")})`; 24405 } 24406 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 24407 import_components32.BaseControl, 24408 { 24409 id, 24410 label: displayLabel, 24411 help: description, 24412 hideLabelFromVision, 24413 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 24414 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 24415 ValidatedInputControl, 24416 { 24417 ref: inputControlRef, 24418 __next40pxDefaultSize: true, 24419 required: !!isValid2?.required, 24420 customValidity: getCustomValidity(isValid2, validity), 24421 type: "datetime-local", 24422 label: (0, import_i18n32.__)("Date time"), 24423 hideLabelFromVision: true, 24424 value: formatDateTime(value), 24425 onChange: handleManualDateTimeChange, 24426 disabled: disabled2, 24427 min: minConstraint ? formatDateTime(minConstraint) : void 0, 24428 max: maxConstraint ? formatDateTime(maxConstraint) : void 0 24429 } 24430 ), 24431 !compact && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 24432 DateCalendar, 24433 { 24434 style: { width: "100%" }, 24435 selected: value ? parseDateTime(value) || void 0 : void 0, 24436 onSelect: onSelectDate, 24437 month: calendarMonth, 24438 onMonthChange: setCalendarMonth, 24439 timeZone: timezoneString || void 0, 24440 weekStartsOn, 24441 disabled: disabled2 || disabledMatchers 24442 } 24443 ) 24444 ] }) 24445 } 24446 ); 24447 } 24448 function DateTime({ 24449 data, 24450 field, 24451 onChange, 24452 hideLabelFromVision, 24453 markWhenOptional, 24454 operator, 24455 validity, 24456 config 24457 }) { 24458 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 24459 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 24460 RelativeDateControl, 24461 { 24462 className: "dataviews-controls__datetime", 24463 data, 24464 field, 24465 onChange, 24466 hideLabelFromVision, 24467 operator 24468 } 24469 ); 24470 } 24471 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 24472 CalendarDateTimeControl, 24473 { 24474 data, 24475 field, 24476 onChange, 24477 hideLabelFromVision, 24478 markWhenOptional, 24479 validity, 24480 config 24481 } 24482 ); 24483 } 24484 24485 // packages/dataviews/build-module/components/dataform-controls/date.mjs 24486 var import_components33 = __toESM(require_components(), 1); 24487 var import_element73 = __toESM(require_element(), 1); 24488 var import_i18n33 = __toESM(require_i18n(), 1); 24489 var import_date4 = __toESM(require_date(), 1); 24490 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1); 24491 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components33.privateApis); 24492 var DATE_PRESETS = [ 24493 { 24494 id: "today", 24495 label: (0, import_i18n33.__)("Today"), 24496 getValue: () => (0, import_date4.getDate)(null) 24497 }, 24498 { 24499 id: "yesterday", 24500 label: (0, import_i18n33.__)("Yesterday"), 24501 getValue: () => { 24502 const today = (0, import_date4.getDate)(null); 24503 return subDays(today, 1); 24504 } 24505 }, 24506 { 24507 id: "past-week", 24508 label: (0, import_i18n33.__)("Past week"), 24509 getValue: () => { 24510 const today = (0, import_date4.getDate)(null); 24511 return subDays(today, 7); 24512 } 24513 }, 24514 { 24515 id: "past-month", 24516 label: (0, import_i18n33.__)("Past month"), 24517 getValue: () => { 24518 const today = (0, import_date4.getDate)(null); 24519 return subMonths(today, 1); 24520 } 24521 } 24522 ]; 24523 var DATE_RANGE_PRESETS = [ 24524 { 24525 id: "last-7-days", 24526 label: (0, import_i18n33.__)("Last 7 days"), 24527 getValue: () => { 24528 const today = (0, import_date4.getDate)(null); 24529 return [subDays(today, 7), today]; 24530 } 24531 }, 24532 { 24533 id: "last-30-days", 24534 label: (0, import_i18n33.__)("Last 30 days"), 24535 getValue: () => { 24536 const today = (0, import_date4.getDate)(null); 24537 return [subDays(today, 30), today]; 24538 } 24539 }, 24540 { 24541 id: "month-to-date", 24542 label: (0, import_i18n33.__)("Month to date"), 24543 getValue: () => { 24544 const today = (0, import_date4.getDate)(null); 24545 return [startOfMonth(today), today]; 24546 } 24547 }, 24548 { 24549 id: "last-year", 24550 label: (0, import_i18n33.__)("Last year"), 24551 getValue: () => { 24552 const today = (0, import_date4.getDate)(null); 24553 return [subYears(today, 1), today]; 24554 } 24555 }, 24556 { 24557 id: "year-to-date", 24558 label: (0, import_i18n33.__)("Year to date"), 24559 getValue: () => { 24560 const today = (0, import_date4.getDate)(null); 24561 return [startOfYear(today), today]; 24562 } 24563 } 24564 ]; 24565 var parseDate = (dateString) => { 24566 if (!dateString) { 24567 return null; 24568 } 24569 const parsed = (0, import_date4.getDate)(dateString); 24570 return parsed && isValid(parsed) ? parsed : null; 24571 }; 24572 var formatDate = (date) => { 24573 if (!date) { 24574 return ""; 24575 } 24576 return typeof date === "string" ? date : format(date, "yyyy-MM-dd"); 24577 }; 24578 function ValidatedDateControl({ 24579 field, 24580 validity, 24581 inputRefs, 24582 isTouched, 24583 setIsTouched, 24584 children 24585 }) { 24586 const { isValid: isValid2 } = field; 24587 const [customValidity, setCustomValidity] = (0, import_element73.useState)(void 0); 24588 const validateRefs = (0, import_element73.useCallback)(() => { 24589 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 24590 for (const ref of refs) { 24591 const input = ref.current; 24592 if (input && !input.validity.valid) { 24593 setCustomValidity({ 24594 type: "invalid", 24595 message: input.validationMessage 24596 }); 24597 return; 24598 } 24599 } 24600 setCustomValidity(void 0); 24601 }, [inputRefs]); 24602 (0, import_element73.useEffect)(() => { 24603 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 24604 const result = validity ? getCustomValidity(isValid2, validity) : void 0; 24605 for (const ref of refs) { 24606 const input = ref.current; 24607 if (input) { 24608 input.setCustomValidity( 24609 result?.type === "invalid" && result.message ? result.message : "" 24610 ); 24611 } 24612 } 24613 }, [inputRefs, isValid2, validity]); 24614 (0, import_element73.useEffect)(() => { 24615 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 24616 const handleInvalid = (event) => { 24617 event.preventDefault(); 24618 setIsTouched(true); 24619 }; 24620 for (const ref of refs) { 24621 ref.current?.addEventListener("invalid", handleInvalid); 24622 } 24623 return () => { 24624 for (const ref of refs) { 24625 ref.current?.removeEventListener("invalid", handleInvalid); 24626 } 24627 }; 24628 }, [inputRefs, setIsTouched]); 24629 (0, import_element73.useEffect)(() => { 24630 if (!isTouched) { 24631 return; 24632 } 24633 const result = validity ? getCustomValidity(isValid2, validity) : void 0; 24634 if (result) { 24635 setCustomValidity(result); 24636 } else { 24637 validateRefs(); 24638 } 24639 }, [isTouched, isValid2, validity, validateRefs]); 24640 const onBlur = (event) => { 24641 if (isTouched) { 24642 return; 24643 } 24644 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 24645 setIsTouched(true); 24646 } 24647 }; 24648 return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)("div", { onBlur, children: [ 24649 children, 24650 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)( 24651 "p", 24652 { 24653 className: clsx_default( 24654 "components-validated-control__indicator", 24655 customValidity.type === "invalid" ? "is-invalid" : void 0 24656 ), 24657 children: [ 24658 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24659 import_components33.Icon, 24660 { 24661 className: "components-validated-control__indicator-icon", 24662 icon: error_default, 24663 size: 16, 24664 fill: "currentColor" 24665 } 24666 ), 24667 customValidity.message 24668 ] 24669 } 24670 ) }) 24671 ] }); 24672 } 24673 function CalendarDateControl({ 24674 data, 24675 field, 24676 onChange, 24677 hideLabelFromVision, 24678 markWhenOptional, 24679 validity 24680 }) { 24681 const { 24682 id, 24683 label, 24684 description, 24685 setValue, 24686 getValue, 24687 isValid: isValid2, 24688 format: fieldFormat 24689 } = field; 24690 const disabled2 = field.isDisabled({ item: data, field }); 24691 const [selectedPresetId, setSelectedPresetId] = (0, import_element73.useState)( 24692 null 24693 ); 24694 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 24695 const fieldValue = getValue({ item: data }); 24696 const value = typeof fieldValue === "string" ? fieldValue : void 0; 24697 const [calendarMonth, setCalendarMonth] = (0, import_element73.useState)(() => { 24698 const parsedDate = parseDate(value); 24699 return parsedDate || /* @__PURE__ */ new Date(); 24700 }); 24701 const [isTouched, setIsTouched] = (0, import_element73.useState)(false); 24702 const validityTargetRef = (0, import_element73.useRef)(null); 24703 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate); 24704 const onChangeCallback = (0, import_element73.useCallback)( 24705 (newValue) => onChange(setValue({ item: data, value: newValue })), 24706 [data, onChange, setValue] 24707 ); 24708 const onSelectDate = (0, import_element73.useCallback)( 24709 (newDate) => { 24710 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0; 24711 onChangeCallback(dateValue); 24712 setSelectedPresetId(null); 24713 setIsTouched(true); 24714 }, 24715 [onChangeCallback] 24716 ); 24717 const handlePresetClick = (0, import_element73.useCallback)( 24718 (preset) => { 24719 const presetDate = preset.getValue(); 24720 const dateValue = formatDate(presetDate); 24721 setCalendarMonth(presetDate); 24722 onChangeCallback(dateValue); 24723 setSelectedPresetId(preset.id); 24724 setIsTouched(true); 24725 }, 24726 [onChangeCallback] 24727 ); 24728 const handleManualDateChange = (0, import_element73.useCallback)( 24729 (newValue) => { 24730 onChangeCallback(newValue); 24731 if (newValue) { 24732 const parsedDate = parseDate(newValue); 24733 if (parsedDate) { 24734 setCalendarMonth(parsedDate); 24735 } 24736 } 24737 setSelectedPresetId(null); 24738 setIsTouched(true); 24739 }, 24740 [onChangeCallback] 24741 ); 24742 const { 24743 timezone: { string: timezoneString } 24744 } = (0, import_date4.getSettings)(); 24745 let displayLabel = label; 24746 if (isValid2?.required && !markWhenOptional) { 24747 displayLabel = `$label} (${(0, import_i18n33.__)("Required")})`; 24748 } else if (!isValid2?.required && markWhenOptional) { 24749 displayLabel = `$label} (${(0, import_i18n33.__)("Optional")})`; 24750 } 24751 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24752 ValidatedDateControl, 24753 { 24754 field, 24755 validity, 24756 inputRefs: validityTargetRef, 24757 isTouched, 24758 setIsTouched, 24759 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24760 import_components33.BaseControl, 24761 { 24762 id, 24763 className: "dataviews-controls__date", 24764 label: displayLabel, 24765 help: description, 24766 hideLabelFromVision, 24767 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 24768 /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)( 24769 Stack, 24770 { 24771 direction: "row", 24772 gap: "sm", 24773 wrap: "wrap", 24774 justify: "flex-start", 24775 children: [ 24776 DATE_PRESETS.map((preset) => { 24777 const isSelected2 = selectedPresetId === preset.id; 24778 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24779 import_components33.Button, 24780 { 24781 className: "dataviews-controls__date-preset", 24782 variant: "tertiary", 24783 isPressed: isSelected2, 24784 size: "small", 24785 disabled: disabled2, 24786 accessibleWhenDisabled: true, 24787 onClick: () => handlePresetClick(preset), 24788 children: preset.label 24789 }, 24790 preset.id 24791 ); 24792 }), 24793 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24794 import_components33.Button, 24795 { 24796 className: "dataviews-controls__date-preset", 24797 variant: "tertiary", 24798 isPressed: !selectedPresetId, 24799 size: "small", 24800 disabled: !!selectedPresetId || disabled2, 24801 accessibleWhenDisabled: true, 24802 children: (0, import_i18n33.__)("Custom") 24803 } 24804 ) 24805 ] 24806 } 24807 ), 24808 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24809 import_components33.__experimentalInputControl, 24810 { 24811 __next40pxDefaultSize: true, 24812 ref: validityTargetRef, 24813 type: "date", 24814 label: (0, import_i18n33.__)("Date"), 24815 hideLabelFromVision: true, 24816 value, 24817 onChange: handleManualDateChange, 24818 required: !!field.isValid?.required, 24819 disabled: disabled2, 24820 min: minConstraint, 24821 max: maxConstraint 24822 } 24823 ), 24824 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24825 DateCalendar2, 24826 { 24827 style: { width: "100%" }, 24828 selected: value ? parseDate(value) || void 0 : void 0, 24829 onSelect: onSelectDate, 24830 month: calendarMonth, 24831 onMonthChange: setCalendarMonth, 24832 timeZone: timezoneString || void 0, 24833 weekStartsOn, 24834 disabled: disabled2 || disabledMatchers, 24835 disableNavigation: disabled2 24836 } 24837 ) 24838 ] }) 24839 } 24840 ) 24841 } 24842 ); 24843 } 24844 function CalendarDateRangeControl({ 24845 data, 24846 field, 24847 onChange, 24848 hideLabelFromVision, 24849 markWhenOptional, 24850 validity 24851 }) { 24852 const { 24853 id, 24854 label, 24855 description, 24856 getValue, 24857 setValue, 24858 isValid: isValid2, 24859 format: fieldFormat 24860 } = field; 24861 const disabled2 = field.isDisabled({ item: data, field }); 24862 let value; 24863 const fieldValue = getValue({ item: data }); 24864 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) { 24865 value = fieldValue; 24866 } 24867 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 24868 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate); 24869 const onChangeCallback = (0, import_element73.useCallback)( 24870 (newValue) => { 24871 onChange( 24872 setValue({ 24873 item: data, 24874 value: newValue 24875 }) 24876 ); 24877 }, 24878 [data, onChange, setValue] 24879 ); 24880 const [selectedPresetId, setSelectedPresetId] = (0, import_element73.useState)( 24881 null 24882 ); 24883 const selectedRange = (0, import_element73.useMemo)(() => { 24884 if (!value) { 24885 return { from: void 0, to: void 0 }; 24886 } 24887 const [from, to] = value; 24888 return { 24889 from: parseDate(from) || void 0, 24890 to: parseDate(to) || void 0 24891 }; 24892 }, [value]); 24893 const [calendarMonth, setCalendarMonth] = (0, import_element73.useState)(() => { 24894 return selectedRange.from || /* @__PURE__ */ new Date(); 24895 }); 24896 const [isTouched, setIsTouched] = (0, import_element73.useState)(false); 24897 const fromInputRef = (0, import_element73.useRef)(null); 24898 const toInputRef = (0, import_element73.useRef)(null); 24899 const updateDateRange = (0, import_element73.useCallback)( 24900 (fromDate, toDate2) => { 24901 if (fromDate && toDate2) { 24902 onChangeCallback([ 24903 formatDate(fromDate), 24904 formatDate(toDate2) 24905 ]); 24906 } else if (!fromDate && !toDate2) { 24907 onChangeCallback(void 0); 24908 } 24909 }, 24910 [onChangeCallback] 24911 ); 24912 const onSelectCalendarRange = (0, import_element73.useCallback)( 24913 (newRange) => { 24914 updateDateRange(newRange?.from, newRange?.to); 24915 setSelectedPresetId(null); 24916 setIsTouched(true); 24917 }, 24918 [updateDateRange] 24919 ); 24920 const handlePresetClick = (0, import_element73.useCallback)( 24921 (preset) => { 24922 const [startDate, endDate] = preset.getValue(); 24923 setCalendarMonth(startDate); 24924 updateDateRange(startDate, endDate); 24925 setSelectedPresetId(preset.id); 24926 setIsTouched(true); 24927 }, 24928 [updateDateRange] 24929 ); 24930 const handleManualDateChange = (0, import_element73.useCallback)( 24931 (fromOrTo, newValue) => { 24932 const [currentFrom, currentTo] = value || [ 24933 void 0, 24934 void 0 24935 ]; 24936 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom; 24937 const updatedTo = fromOrTo === "to" ? newValue : currentTo; 24938 updateDateRange(updatedFrom, updatedTo); 24939 if (newValue) { 24940 const parsedDate = parseDate(newValue); 24941 if (parsedDate) { 24942 setCalendarMonth(parsedDate); 24943 } 24944 } 24945 setSelectedPresetId(null); 24946 setIsTouched(true); 24947 }, 24948 [value, updateDateRange] 24949 ); 24950 const { timezone } = (0, import_date4.getSettings)(); 24951 let displayLabel = label; 24952 if (field.isValid?.required && !markWhenOptional) { 24953 displayLabel = `$label} (${(0, import_i18n33.__)("Required")})`; 24954 } else if (!field.isValid?.required && markWhenOptional) { 24955 displayLabel = `$label} (${(0, import_i18n33.__)("Optional")})`; 24956 } 24957 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24958 ValidatedDateControl, 24959 { 24960 field, 24961 validity, 24962 inputRefs: [fromInputRef, toInputRef], 24963 isTouched, 24964 setIsTouched, 24965 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24966 import_components33.BaseControl, 24967 { 24968 id, 24969 className: "dataviews-controls__date", 24970 label: displayLabel, 24971 help: description, 24972 hideLabelFromVision, 24973 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 24974 /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)( 24975 Stack, 24976 { 24977 direction: "row", 24978 gap: "sm", 24979 wrap: "wrap", 24980 justify: "flex-start", 24981 children: [ 24982 DATE_RANGE_PRESETS.map((preset) => { 24983 const isSelected2 = selectedPresetId === preset.id; 24984 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24985 import_components33.Button, 24986 { 24987 className: "dataviews-controls__date-preset", 24988 variant: "tertiary", 24989 isPressed: isSelected2, 24990 size: "small", 24991 disabled: disabled2, 24992 accessibleWhenDisabled: true, 24993 onClick: () => handlePresetClick(preset), 24994 children: preset.label 24995 }, 24996 preset.id 24997 ); 24998 }), 24999 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 25000 import_components33.Button, 25001 { 25002 className: "dataviews-controls__date-preset", 25003 variant: "tertiary", 25004 isPressed: !selectedPresetId, 25005 size: "small", 25006 accessibleWhenDisabled: true, 25007 disabled: !!selectedPresetId || disabled2, 25008 children: (0, import_i18n33.__)("Custom") 25009 } 25010 ) 25011 ] 25012 } 25013 ), 25014 /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)( 25015 Stack, 25016 { 25017 direction: "row", 25018 gap: "sm", 25019 justify: "space-between", 25020 className: "dataviews-controls__date-range-inputs", 25021 children: [ 25022 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 25023 import_components33.__experimentalInputControl, 25024 { 25025 __next40pxDefaultSize: true, 25026 ref: fromInputRef, 25027 type: "date", 25028 label: (0, import_i18n33.__)("From"), 25029 hideLabelFromVision: true, 25030 value: value?.[0], 25031 onChange: (newValue) => handleManualDateChange("from", newValue), 25032 required: !!field.isValid?.required, 25033 disabled: disabled2, 25034 min: minConstraint, 25035 max: maxConstraint 25036 } 25037 ), 25038 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 25039 import_components33.__experimentalInputControl, 25040 { 25041 __next40pxDefaultSize: true, 25042 ref: toInputRef, 25043 type: "date", 25044 label: (0, import_i18n33.__)("To"), 25045 hideLabelFromVision: true, 25046 value: value?.[1], 25047 onChange: (newValue) => handleManualDateChange("to", newValue), 25048 required: !!field.isValid?.required, 25049 disabled: disabled2, 25050 min: minConstraint, 25051 max: maxConstraint 25052 } 25053 ) 25054 ] 25055 } 25056 ), 25057 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 25058 DateRangeCalendar, 25059 { 25060 style: { width: "100%" }, 25061 selected: selectedRange, 25062 onSelect: onSelectCalendarRange, 25063 month: calendarMonth, 25064 onMonthChange: setCalendarMonth, 25065 timeZone: timezone.string || void 0, 25066 weekStartsOn, 25067 disabled: disabled2 || disabledMatchers 25068 } 25069 ) 25070 ] }) 25071 } 25072 ) 25073 } 25074 ); 25075 } 25076 function DateControl({ 25077 data, 25078 field, 25079 onChange, 25080 hideLabelFromVision, 25081 markWhenOptional, 25082 operator, 25083 validity 25084 }) { 25085 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 25086 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 25087 RelativeDateControl, 25088 { 25089 className: "dataviews-controls__date", 25090 data, 25091 field, 25092 onChange, 25093 hideLabelFromVision, 25094 operator 25095 } 25096 ); 25097 } 25098 if (operator === OPERATOR_BETWEEN) { 25099 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 25100 CalendarDateRangeControl, 25101 { 25102 data, 25103 field, 25104 onChange, 25105 hideLabelFromVision, 25106 markWhenOptional, 25107 validity 25108 } 25109 ); 25110 } 25111 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 25112 CalendarDateControl, 25113 { 25114 data, 25115 field, 25116 onChange, 25117 hideLabelFromVision, 25118 markWhenOptional, 25119 validity 25120 } 25121 ); 25122 } 25123 25124 // packages/dataviews/build-module/components/dataform-controls/select.mjs 25125 var import_components34 = __toESM(require_components(), 1); 25126 var import_element74 = __toESM(require_element(), 1); 25127 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1); 25128 var { ValidatedSelectControl } = unlock2(import_components34.privateApis); 25129 function Select({ 25130 data, 25131 field, 25132 onChange, 25133 hideLabelFromVision, 25134 markWhenOptional, 25135 validity 25136 }) { 25137 const { type, label, description, getValue, setValue, isValid: isValid2 } = field; 25138 const disabled2 = field.isDisabled({ item: data, field }); 25139 const isMultiple = type === "array"; 25140 const value = getValue({ item: data }) ?? (isMultiple ? [] : ""); 25141 const onChangeControl = (0, import_element74.useCallback)( 25142 (newValue) => onChange(setValue({ item: data, value: newValue })), 25143 [data, onChange, setValue] 25144 ); 25145 const { elements, isLoading } = useElements({ 25146 elements: field.elements, 25147 getElements: field.getElements 25148 }); 25149 if (isLoading) { 25150 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components34.Spinner, {}); 25151 } 25152 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 25153 ValidatedSelectControl, 25154 { 25155 required: !!field.isValid?.required, 25156 markWhenOptional, 25157 customValidity: getCustomValidity(isValid2, validity), 25158 label, 25159 value, 25160 help: description, 25161 options: elements, 25162 onChange: onChangeControl, 25163 __next40pxDefaultSize: true, 25164 hideLabelFromVision, 25165 multiple: isMultiple, 25166 disabled: disabled2 25167 } 25168 ); 25169 } 25170 25171 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs 25172 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1); 25173 var ELEMENTS_THRESHOLD = 10; 25174 function AdaptiveSelect(props) { 25175 const { field } = props; 25176 const { elements } = useElements({ 25177 elements: field.elements, 25178 getElements: field.getElements 25179 }); 25180 if (elements.length >= ELEMENTS_THRESHOLD) { 25181 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Combobox3, { ...props }); 25182 } 25183 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Select, { ...props }); 25184 } 25185 25186 // packages/dataviews/build-module/components/dataform-controls/email.mjs 25187 var import_components36 = __toESM(require_components(), 1); 25188 25189 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs 25190 var import_components35 = __toESM(require_components(), 1); 25191 var import_element75 = __toESM(require_element(), 1); 25192 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1); 25193 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components35.privateApis); 25194 function ValidatedText({ 25195 data, 25196 field, 25197 onChange, 25198 hideLabelFromVision, 25199 markWhenOptional, 25200 type, 25201 prefix, 25202 suffix, 25203 validity 25204 }) { 25205 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 25206 const value = getValue({ item: data }); 25207 const disabled2 = field.isDisabled({ item: data, field }); 25208 const onChangeControl = (0, import_element75.useCallback)( 25209 (newValue) => onChange( 25210 setValue({ 25211 item: data, 25212 value: newValue 25213 }) 25214 ), 25215 [data, setValue, onChange] 25216 ); 25217 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 25218 ValidatedInputControl2, 25219 { 25220 required: !!isValid2.required, 25221 markWhenOptional, 25222 customValidity: getCustomValidity(isValid2, validity), 25223 label, 25224 placeholder, 25225 value: value ?? "", 25226 help: description, 25227 onChange: onChangeControl, 25228 hideLabelFromVision, 25229 type, 25230 prefix, 25231 suffix, 25232 disabled: disabled2, 25233 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0, 25234 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 25235 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 25236 __next40pxDefaultSize: true 25237 } 25238 ); 25239 } 25240 25241 // packages/dataviews/build-module/components/dataform-controls/email.mjs 25242 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1); 25243 function Email({ 25244 data, 25245 field, 25246 onChange, 25247 hideLabelFromVision, 25248 markWhenOptional, 25249 validity 25250 }) { 25251 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 25252 ValidatedText, 25253 { 25254 ...{ 25255 data, 25256 field, 25257 onChange, 25258 hideLabelFromVision, 25259 markWhenOptional, 25260 validity, 25261 type: "email", 25262 prefix: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components36.Icon, { icon: envelope_default }) }) 25263 } 25264 } 25265 ); 25266 } 25267 25268 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs 25269 var import_components37 = __toESM(require_components(), 1); 25270 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1); 25271 function Telephone({ 25272 data, 25273 field, 25274 onChange, 25275 hideLabelFromVision, 25276 markWhenOptional, 25277 validity 25278 }) { 25279 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)( 25280 ValidatedText, 25281 { 25282 ...{ 25283 data, 25284 field, 25285 onChange, 25286 hideLabelFromVision, 25287 markWhenOptional, 25288 validity, 25289 type: "tel", 25290 prefix: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components37.Icon, { icon: mobile_default }) }) 25291 } 25292 } 25293 ); 25294 } 25295 25296 // packages/dataviews/build-module/components/dataform-controls/url.mjs 25297 var import_components38 = __toESM(require_components(), 1); 25298 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1); 25299 function Url({ 25300 data, 25301 field, 25302 onChange, 25303 hideLabelFromVision, 25304 markWhenOptional, 25305 validity 25306 }) { 25307 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)( 25308 ValidatedText, 25309 { 25310 ...{ 25311 data, 25312 field, 25313 onChange, 25314 hideLabelFromVision, 25315 markWhenOptional, 25316 validity, 25317 type: "url", 25318 prefix: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components38.Icon, { icon: link_default }) }) 25319 } 25320 } 25321 ); 25322 } 25323 25324 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs 25325 var import_components39 = __toESM(require_components(), 1); 25326 var import_element76 = __toESM(require_element(), 1); 25327 var import_i18n34 = __toESM(require_i18n(), 1); 25328 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1); 25329 var { ValidatedNumberControl } = unlock2(import_components39.privateApis); 25330 function toNumberOrEmpty(value) { 25331 if (value === "" || value === void 0) { 25332 return ""; 25333 } 25334 const number = Number(value); 25335 return Number.isFinite(number) ? number : ""; 25336 } 25337 function BetweenControls({ 25338 value, 25339 onChange, 25340 hideLabelFromVision, 25341 step 25342 }) { 25343 const [min2 = "", max2 = ""] = value; 25344 const onChangeMin = (0, import_element76.useCallback)( 25345 (newValue) => onChange([toNumberOrEmpty(newValue), max2]), 25346 [onChange, max2] 25347 ); 25348 const onChangeMax = (0, import_element76.useCallback)( 25349 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]), 25350 [onChange, min2] 25351 ); 25352 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)( 25353 import_components39.BaseControl, 25354 { 25355 help: (0, import_i18n34.__)("The max. value must be greater than the min. value."), 25356 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_components39.Flex, { direction: "row", gap: 4, children: [ 25357 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)( 25358 import_components39.__experimentalNumberControl, 25359 { 25360 label: (0, import_i18n34.__)("Min."), 25361 value: min2, 25362 max: max2 ? Number(max2) - step : void 0, 25363 onChange: onChangeMin, 25364 __next40pxDefaultSize: true, 25365 hideLabelFromVision, 25366 step 25367 } 25368 ), 25369 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)( 25370 import_components39.__experimentalNumberControl, 25371 { 25372 label: (0, import_i18n34.__)("Max."), 25373 value: max2, 25374 min: min2 ? Number(min2) + step : void 0, 25375 onChange: onChangeMax, 25376 __next40pxDefaultSize: true, 25377 hideLabelFromVision, 25378 step 25379 } 25380 ) 25381 ] }) 25382 } 25383 ); 25384 } 25385 function ValidatedNumber({ 25386 data, 25387 field, 25388 onChange, 25389 hideLabelFromVision, 25390 markWhenOptional, 25391 operator, 25392 validity 25393 }) { 25394 const decimals = field.format?.decimals ?? 0; 25395 const step = Math.pow(10, Math.abs(decimals) * -1); 25396 const { label, description, getValue, setValue, isValid: isValid2 } = field; 25397 const value = getValue({ item: data }) ?? ""; 25398 const disabled2 = field.isDisabled({ item: data, field }); 25399 const onChangeControl = (0, import_element76.useCallback)( 25400 (newValue) => { 25401 onChange( 25402 setValue({ 25403 item: data, 25404 // Do not convert an empty string or undefined to a number, 25405 // otherwise there's a mismatch between the UI control (empty) 25406 // and the data relied by onChange (0). 25407 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue) 25408 }) 25409 ); 25410 }, 25411 [data, onChange, setValue] 25412 ); 25413 const onChangeBetweenControls = (0, import_element76.useCallback)( 25414 (newValue) => { 25415 onChange( 25416 setValue({ 25417 item: data, 25418 value: newValue 25419 }) 25420 ); 25421 }, 25422 [data, onChange, setValue] 25423 ); 25424 if (operator === OPERATOR_BETWEEN) { 25425 let valueBetween = ["", ""]; 25426 if (Array.isArray(value) && value.length === 2 && value.every( 25427 (element) => typeof element === "number" || element === "" 25428 )) { 25429 valueBetween = value; 25430 } 25431 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)( 25432 BetweenControls, 25433 { 25434 value: valueBetween, 25435 onChange: onChangeBetweenControls, 25436 hideLabelFromVision, 25437 step 25438 } 25439 ); 25440 } 25441 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)( 25442 ValidatedNumberControl, 25443 { 25444 required: !!isValid2.required, 25445 markWhenOptional, 25446 customValidity: getCustomValidity(isValid2, validity), 25447 label, 25448 help: description, 25449 value, 25450 onChange: onChangeControl, 25451 __next40pxDefaultSize: true, 25452 hideLabelFromVision, 25453 step, 25454 min: isValid2.min ? isValid2.min.constraint : void 0, 25455 max: isValid2.max ? isValid2.max.constraint : void 0, 25456 disabled: disabled2 25457 } 25458 ); 25459 } 25460 25461 // packages/dataviews/build-module/components/dataform-controls/integer.mjs 25462 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1); 25463 function Integer(props) { 25464 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(ValidatedNumber, { ...props }); 25465 } 25466 25467 // packages/dataviews/build-module/components/dataform-controls/number.mjs 25468 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1); 25469 function Number2(props) { 25470 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(ValidatedNumber, { ...props }); 25471 } 25472 25473 // packages/dataviews/build-module/components/dataform-controls/radio.mjs 25474 var import_components40 = __toESM(require_components(), 1); 25475 var import_element77 = __toESM(require_element(), 1); 25476 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1); 25477 var { ValidatedRadioControl } = unlock2(import_components40.privateApis); 25478 function Radio({ 25479 data, 25480 field, 25481 onChange, 25482 hideLabelFromVision, 25483 markWhenOptional, 25484 validity 25485 }) { 25486 const { label, description, getValue, setValue, isValid: isValid2 } = field; 25487 const disabled2 = field.isDisabled({ item: data, field }); 25488 const { elements, isLoading } = useElements({ 25489 elements: field.elements, 25490 getElements: field.getElements 25491 }); 25492 const value = getValue({ item: data }); 25493 const onChangeControl = (0, import_element77.useCallback)( 25494 (newValue) => onChange(setValue({ item: data, value: newValue })), 25495 [data, onChange, setValue] 25496 ); 25497 if (isLoading) { 25498 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_components40.Spinner, {}); 25499 } 25500 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)( 25501 ValidatedRadioControl, 25502 { 25503 required: !!field.isValid?.required, 25504 markWhenOptional, 25505 customValidity: getCustomValidity(isValid2, validity), 25506 label, 25507 help: description, 25508 onChange: onChangeControl, 25509 options: elements, 25510 selected: value, 25511 hideLabelFromVision, 25512 disabled: disabled2 25513 } 25514 ); 25515 } 25516 25517 // packages/dataviews/build-module/components/dataform-controls/text.mjs 25518 var import_element78 = __toESM(require_element(), 1); 25519 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1); 25520 function Text3({ 25521 data, 25522 field, 25523 onChange, 25524 hideLabelFromVision, 25525 markWhenOptional, 25526 config, 25527 validity 25528 }) { 25529 const { prefix, suffix } = config || {}; 25530 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25531 ValidatedText, 25532 { 25533 ...{ 25534 data, 25535 field, 25536 onChange, 25537 hideLabelFromVision, 25538 markWhenOptional, 25539 validity, 25540 prefix: prefix ? (0, import_element78.createElement)(prefix) : void 0, 25541 suffix: suffix ? (0, import_element78.createElement)(suffix) : void 0 25542 } 25543 } 25544 ); 25545 } 25546 25547 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs 25548 var import_components41 = __toESM(require_components(), 1); 25549 var import_element79 = __toESM(require_element(), 1); 25550 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1); 25551 var { ValidatedToggleControl } = unlock2(import_components41.privateApis); 25552 function Toggle({ 25553 field, 25554 onChange, 25555 data, 25556 hideLabelFromVision, 25557 markWhenOptional, 25558 validity 25559 }) { 25560 const { label, description, getValue, setValue, isValid: isValid2 } = field; 25561 const disabled2 = field.isDisabled({ item: data, field }); 25562 const onChangeControl = (0, import_element79.useCallback)(() => { 25563 onChange( 25564 setValue({ item: data, value: !getValue({ item: data }) }) 25565 ); 25566 }, [onChange, setValue, data, getValue]); 25567 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 25568 ValidatedToggleControl, 25569 { 25570 required: !!isValid2.required, 25571 markWhenOptional, 25572 customValidity: getCustomValidity(isValid2, validity), 25573 hidden: hideLabelFromVision, 25574 label, 25575 help: description, 25576 checked: getValue({ item: data }), 25577 onChange: onChangeControl, 25578 disabled: disabled2 25579 } 25580 ); 25581 } 25582 25583 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs 25584 var import_components42 = __toESM(require_components(), 1); 25585 var import_element80 = __toESM(require_element(), 1); 25586 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1); 25587 var { ValidatedTextareaControl } = unlock2(import_components42.privateApis); 25588 function Textarea({ 25589 data, 25590 field, 25591 onChange, 25592 hideLabelFromVision, 25593 markWhenOptional, 25594 config, 25595 validity 25596 }) { 25597 const { rows = 4 } = config || {}; 25598 const disabled2 = field.isDisabled({ item: data, field }); 25599 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 25600 const value = field.getValue({ item: data }); 25601 const onChangeControl = (0, import_element80.useCallback)( 25602 (newValue) => onChange(setValue({ item: data, value: newValue })), 25603 [data, onChange, setValue] 25604 ); 25605 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)( 25606 ValidatedTextareaControl, 25607 { 25608 required: !!isValid2.required, 25609 markWhenOptional, 25610 customValidity: getCustomValidity(isValid2, validity), 25611 label, 25612 placeholder, 25613 value: value ?? "", 25614 help: description, 25615 onChange: onChangeControl, 25616 rows, 25617 disabled: disabled2, 25618 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 25619 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 25620 __next40pxDefaultSize: true, 25621 hideLabelFromVision 25622 } 25623 ); 25624 } 25625 25626 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs 25627 var import_components43 = __toESM(require_components(), 1); 25628 var import_element81 = __toESM(require_element(), 1); 25629 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1); 25630 var { ValidatedToggleGroupControl } = unlock2(import_components43.privateApis); 25631 function ToggleGroup({ 25632 data, 25633 field, 25634 onChange, 25635 hideLabelFromVision, 25636 markWhenOptional, 25637 validity 25638 }) { 25639 const { getValue, setValue, isValid: isValid2 } = field; 25640 const disabled2 = field.isDisabled({ item: data, field }); 25641 const value = getValue({ item: data }); 25642 const onChangeControl = (0, import_element81.useCallback)( 25643 (newValue) => onChange(setValue({ item: data, value: newValue })), 25644 [data, onChange, setValue] 25645 ); 25646 const { elements, isLoading } = useElements({ 25647 elements: field.elements, 25648 getElements: field.getElements 25649 }); 25650 if (isLoading) { 25651 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(import_components43.Spinner, {}); 25652 } 25653 if (elements.length === 0) { 25654 return null; 25655 } 25656 const selectedOption = elements.find((el) => el.value === value); 25657 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)( 25658 ValidatedToggleGroupControl, 25659 { 25660 required: !!field.isValid?.required, 25661 markWhenOptional, 25662 customValidity: getCustomValidity(isValid2, validity), 25663 __next40pxDefaultSize: true, 25664 isBlock: true, 25665 label: field.label, 25666 help: selectedOption?.description || field.description, 25667 onChange: onChangeControl, 25668 value, 25669 hideLabelFromVision, 25670 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)( 25671 import_components43.__experimentalToggleGroupControlOption, 25672 { 25673 label: el.label, 25674 value: el.value, 25675 disabled: disabled2 25676 }, 25677 el.value 25678 )) 25679 } 25680 ); 25681 } 25682 25683 // packages/dataviews/build-module/components/dataform-controls/array.mjs 25684 var import_components44 = __toESM(require_components(), 1); 25685 var import_element82 = __toESM(require_element(), 1); 25686 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1); 25687 var { ValidatedFormTokenField } = unlock2(import_components44.privateApis); 25688 function ArrayControl({ 25689 data, 25690 field, 25691 onChange, 25692 hideLabelFromVision, 25693 markWhenOptional, 25694 validity 25695 }) { 25696 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 25697 const value = getValue({ item: data }); 25698 const disabled2 = field.isDisabled({ item: data, field }); 25699 const { elements, isLoading } = useElements({ 25700 elements: field.elements, 25701 getElements: field.getElements 25702 }); 25703 const arrayValueAsElements = (0, import_element82.useMemo)( 25704 () => Array.isArray(value) ? value.map((token) => { 25705 const element = elements?.find( 25706 (suggestion) => suggestion.value === token 25707 ); 25708 return element || { value: token, label: token }; 25709 }) : [], 25710 [value, elements] 25711 ); 25712 const onChangeControl = (0, import_element82.useCallback)( 25713 (tokens) => { 25714 const valueTokens = tokens.map((token) => { 25715 if (typeof token === "object" && "value" in token) { 25716 return token.value; 25717 } 25718 return token; 25719 }); 25720 onChange(setValue({ item: data, value: valueTokens })); 25721 }, 25722 [onChange, setValue, data] 25723 ); 25724 if (isLoading) { 25725 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components44.Spinner, {}); 25726 } 25727 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)( 25728 ValidatedFormTokenField, 25729 { 25730 required: !!isValid2?.required, 25731 markWhenOptional, 25732 customValidity: getCustomValidity(isValid2, validity), 25733 label: hideLabelFromVision ? void 0 : label, 25734 value: arrayValueAsElements, 25735 onChange: onChangeControl, 25736 placeholder, 25737 suggestions: elements?.map((element) => element.value), 25738 disabled: disabled2, 25739 __experimentalValidateInput: (token) => { 25740 if (field.isValid?.elements && elements) { 25741 return elements.some( 25742 (element) => element.value === token || element.label === token 25743 ); 25744 } 25745 return true; 25746 }, 25747 __experimentalExpandOnFocus: elements && elements.length > 0, 25748 help: description ?? (field.isValid?.elements ? "" : void 0), 25749 displayTransform: (token) => { 25750 if (typeof token === "object" && "label" in token) { 25751 return token.label; 25752 } 25753 if (typeof token === "string" && elements) { 25754 const element = elements.find( 25755 (el) => el.value === token 25756 ); 25757 return element?.label || token; 25758 } 25759 return token; 25760 }, 25761 __experimentalRenderItem: ({ item }) => { 25762 if (typeof item === "string" && elements) { 25763 const element = elements.find( 25764 (el) => el.value === item 25765 ); 25766 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("span", { children: element?.label || item }); 25767 } 25768 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("span", { children: item }); 25769 } 25770 } 25771 ); 25772 } 25773 25774 // node_modules/colord/index.mjs 25775 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 25776 var t = function(r3) { 25777 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 25778 }; 25779 var n = function(r3, t2, n2) { 25780 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0; 25781 }; 25782 var e = function(r3, t2, n2) { 25783 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2; 25784 }; 25785 var u = function(r3) { 25786 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360; 25787 }; 25788 var a = function(r3) { 25789 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) }; 25790 }; 25791 var o = function(r3) { 25792 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 25793 }; 25794 var i = /^#([0-9a-f]{3,8})$/i; 25795 var s = function(r3) { 25796 var t2 = r3.toString(16); 25797 return t2.length < 2 ? "0" + t2 : t2; 25798 }; 25799 var h = function(r3) { 25800 var t2 = r3.r, n2 = r3.g, e2 = r3.b, u2 = r3.a, a2 = Math.max(t2, n2, e2), o2 = a2 - Math.min(t2, n2, e2), i2 = o2 ? a2 === t2 ? (n2 - e2) / o2 : a2 === n2 ? 2 + (e2 - t2) / o2 : 4 + (t2 - n2) / o2 : 0; 25801 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 25802 }; 25803 var b = function(r3) { 25804 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a; 25805 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100; 25806 var a2 = Math.floor(t2), o2 = e2 * (1 - n2), i2 = e2 * (1 - (t2 - a2) * n2), s2 = e2 * (1 - (1 - t2 + a2) * n2), h2 = a2 % 6; 25807 return { r: 255 * [e2, i2, o2, o2, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o2, o2][h2], b: 255 * [o2, o2, s2, e2, e2, i2][h2], a: u2 }; 25808 }; 25809 var g = function(r3) { 25810 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) }; 25811 }; 25812 var d = function(r3) { 25813 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) }; 25814 }; 25815 var f = function(r3) { 25816 return b((n2 = (t2 = r3).s, { h: t2.h, s: (n2 *= ((e2 = t2.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t2.a })); 25817 var t2, n2, e2; 25818 }; 25819 var c = function(r3) { 25820 return { h: (t2 = h(r3)).h, s: (u2 = (200 - (n2 = t2.s)) * (e2 = t2.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t2.a }; 25821 var t2, n2, e2, u2; 25822 }; 25823 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 25824 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 25825 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 25826 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 25827 var y = { string: [[function(r3) { 25828 var t2 = i.exec(r3); 25829 return t2 ? (r3 = t2[1]).length <= 4 ? { r: parseInt(r3[0] + r3[0], 16), g: parseInt(r3[1] + r3[1], 16), b: parseInt(r3[2] + r3[2], 16), a: 4 === r3.length ? n(parseInt(r3[3] + r3[3], 16) / 255, 2) : 1 } : 6 === r3.length || 8 === r3.length ? { r: parseInt(r3.substr(0, 2), 16), g: parseInt(r3.substr(2, 2), 16), b: parseInt(r3.substr(4, 2), 16), a: 8 === r3.length ? n(parseInt(r3.substr(6, 2), 16) / 255, 2) : 1 } : null : null; 25830 }, "hex"], [function(r3) { 25831 var t2 = v.exec(r3) || m.exec(r3); 25832 return t2 ? t2[2] !== t2[4] || t2[4] !== t2[6] ? null : a({ r: Number(t2[1]) / (t2[2] ? 100 / 255 : 1), g: Number(t2[3]) / (t2[4] ? 100 / 255 : 1), b: Number(t2[5]) / (t2[6] ? 100 / 255 : 1), a: void 0 === t2[7] ? 1 : Number(t2[7]) / (t2[8] ? 100 : 1) }) : null; 25833 }, "rgb"], [function(t2) { 25834 var n2 = l.exec(t2) || p.exec(t2); 25835 if (!n2) return null; 25836 var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r2[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) }); 25837 return f(a2); 25838 }, "hsl"]], object: [[function(r3) { 25839 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2; 25840 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 25841 }, "rgb"], [function(r3) { 25842 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2; 25843 if (!t(n2) || !t(e2) || !t(u2)) return null; 25844 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) }); 25845 return f(i2); 25846 }, "hsl"], [function(r3) { 25847 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2; 25848 if (!t(n2) || !t(a2) || !t(o2)) return null; 25849 var h2 = (function(r4) { 25850 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) }; 25851 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) }); 25852 return b(h2); 25853 }, "hsv"]] }; 25854 var N = function(r3, t2) { 25855 for (var n2 = 0; n2 < t2.length; n2++) { 25856 var e2 = t2[n2][0](r3); 25857 if (e2) return [e2, t2[n2][1]]; 25858 } 25859 return [null, void 0]; 25860 }; 25861 var x = function(r3) { 25862 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0]; 25863 }; 25864 var M = function(r3, t2) { 25865 var n2 = c(r3); 25866 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a }; 25867 }; 25868 var H = function(r3) { 25869 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255; 25870 }; 25871 var $ = function(r3, t2) { 25872 var n2 = c(r3); 25873 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a }; 25874 }; 25875 var j = (function() { 25876 function r3(r4) { 25877 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 25878 } 25879 return r3.prototype.isValid = function() { 25880 return null !== this.parsed; 25881 }, r3.prototype.brightness = function() { 25882 return n(H(this.rgba), 2); 25883 }, r3.prototype.isDark = function() { 25884 return H(this.rgba) < 0.5; 25885 }, r3.prototype.isLight = function() { 25886 return H(this.rgba) >= 0.5; 25887 }, r3.prototype.toHex = function() { 25888 return r4 = o(this.rgba), t2 = r4.r, e2 = r4.g, u2 = r4.b, i2 = (a2 = r4.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t2) + s(e2) + s(u2) + i2; 25889 var r4, t2, e2, u2, a2, i2; 25890 }, r3.prototype.toRgb = function() { 25891 return o(this.rgba); 25892 }, r3.prototype.toRgbString = function() { 25893 return r4 = o(this.rgba), t2 = r4.r, n2 = r4.g, e2 = r4.b, (u2 = r4.a) < 1 ? "rgba(" + t2 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t2 + ", " + n2 + ", " + e2 + ")"; 25894 var r4, t2, n2, e2, u2; 25895 }, r3.prototype.toHsl = function() { 25896 return d(c(this.rgba)); 25897 }, r3.prototype.toHslString = function() { 25898 return r4 = d(c(this.rgba)), t2 = r4.h, n2 = r4.s, e2 = r4.l, (u2 = r4.a) < 1 ? "hsla(" + t2 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t2 + ", " + n2 + "%, " + e2 + "%)"; 25899 var r4, t2, n2, e2, u2; 25900 }, r3.prototype.toHsv = function() { 25901 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) }; 25902 var r4; 25903 }, r3.prototype.invert = function() { 25904 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a }); 25905 var r4; 25906 }, r3.prototype.saturate = function(r4) { 25907 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4)); 25908 }, r3.prototype.desaturate = function(r4) { 25909 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4)); 25910 }, r3.prototype.grayscale = function() { 25911 return w(M(this.rgba, -1)); 25912 }, r3.prototype.lighten = function(r4) { 25913 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4)); 25914 }, r3.prototype.darken = function(r4) { 25915 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4)); 25916 }, r3.prototype.rotate = function(r4) { 25917 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4); 25918 }, r3.prototype.alpha = function(r4) { 25919 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3); 25920 var t2; 25921 }, r3.prototype.hue = function(r4) { 25922 var t2 = c(this.rgba); 25923 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h); 25924 }, r3.prototype.isEqual = function(r4) { 25925 return this.toHex() === w(r4).toHex(); 25926 }, r3; 25927 })(); 25928 var w = function(r3) { 25929 return r3 instanceof j ? r3 : new j(r3); 25930 }; 25931 25932 // packages/dataviews/build-module/components/dataform-controls/color.mjs 25933 var import_components45 = __toESM(require_components(), 1); 25934 var import_element83 = __toESM(require_element(), 1); 25935 var import_i18n35 = __toESM(require_i18n(), 1); 25936 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1); 25937 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components45.privateApis); 25938 var ColorPickerDropdown = ({ 25939 color, 25940 onColorChange, 25941 disabled: disabled2 25942 }) => { 25943 const validColor = color && w(color).isValid() ? color : "#ffffff"; 25944 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25945 import_components45.Dropdown, 25946 { 25947 className: "dataviews-controls__color-picker-dropdown", 25948 popoverProps: { resize: false }, 25949 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25950 import_components45.Button, 25951 { 25952 onClick: onToggle, 25953 "aria-label": (0, import_i18n35.__)("Open color picker"), 25954 size: "small", 25955 disabled: disabled2, 25956 accessibleWhenDisabled: true, 25957 icon: () => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components45.ColorIndicator, { colorValue: validColor }) 25958 } 25959 ), 25960 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25961 import_components45.ColorPicker, 25962 { 25963 color: validColor, 25964 onChange: onColorChange, 25965 enableAlpha: true 25966 } 25967 ) }) 25968 } 25969 ); 25970 }; 25971 function Color({ 25972 data, 25973 field, 25974 onChange, 25975 hideLabelFromVision, 25976 markWhenOptional, 25977 validity 25978 }) { 25979 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 25980 const disabled2 = field.isDisabled({ item: data, field }); 25981 const value = field.getValue({ item: data }) || ""; 25982 const handleColorChange = (0, import_element83.useCallback)( 25983 (newColor) => { 25984 onChange(setValue({ item: data, value: newColor })); 25985 }, 25986 [data, onChange, setValue] 25987 ); 25988 const handleInputChange = (0, import_element83.useCallback)( 25989 (newValue) => { 25990 onChange(setValue({ item: data, value: newValue || "" })); 25991 }, 25992 [data, onChange, setValue] 25993 ); 25994 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25995 ValidatedInputControl3, 25996 { 25997 required: !!field.isValid?.required, 25998 markWhenOptional, 25999 customValidity: getCustomValidity(isValid2, validity), 26000 label, 26001 placeholder, 26002 value, 26003 help: description, 26004 onChange: handleInputChange, 26005 hideLabelFromVision, 26006 type: "text", 26007 disabled: disabled2, 26008 prefix: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 26009 ColorPickerDropdown, 26010 { 26011 color: value, 26012 onColorChange: handleColorChange, 26013 disabled: disabled2 26014 } 26015 ) }) 26016 } 26017 ); 26018 } 26019 26020 // packages/dataviews/build-module/components/dataform-controls/password.mjs 26021 var import_components46 = __toESM(require_components(), 1); 26022 var import_element84 = __toESM(require_element(), 1); 26023 var import_i18n36 = __toESM(require_i18n(), 1); 26024 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1); 26025 function Password({ 26026 data, 26027 field, 26028 onChange, 26029 hideLabelFromVision, 26030 markWhenOptional, 26031 validity 26032 }) { 26033 const [isVisible2, setIsVisible] = (0, import_element84.useState)(false); 26034 const disabled2 = field.isDisabled({ item: data, field }); 26035 const toggleVisibility = (0, import_element84.useCallback)(() => { 26036 setIsVisible((prev) => !prev); 26037 }, []); 26038 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 26039 ValidatedText, 26040 { 26041 ...{ 26042 data, 26043 field, 26044 onChange, 26045 hideLabelFromVision, 26046 markWhenOptional, 26047 validity, 26048 type: isVisible2 ? "text" : "password", 26049 suffix: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 26050 import_components46.Button, 26051 { 26052 icon: isVisible2 ? unseen_default : seen_default, 26053 onClick: toggleVisibility, 26054 size: "small", 26055 label: isVisible2 ? (0, import_i18n36.__)("Hide password") : (0, import_i18n36.__)("Show password"), 26056 disabled: disabled2, 26057 accessibleWhenDisabled: true 26058 } 26059 ) }) 26060 } 26061 } 26062 ); 26063 } 26064 26065 // packages/dataviews/build-module/field-types/utils/has-elements.mjs 26066 function hasElements(field) { 26067 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function"; 26068 } 26069 26070 // packages/dataviews/build-module/components/dataform-controls/index.mjs 26071 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1); 26072 var FORM_CONTROLS = { 26073 adaptiveSelect: AdaptiveSelect, 26074 array: ArrayControl, 26075 checkbox: Checkbox, 26076 color: Color, 26077 combobox: Combobox3, 26078 datetime: DateTime, 26079 date: DateControl, 26080 email: Email, 26081 telephone: Telephone, 26082 url: Url, 26083 integer: Integer, 26084 number: Number2, 26085 password: Password, 26086 radio: Radio, 26087 select: Select, 26088 text: Text3, 26089 toggle: Toggle, 26090 textarea: Textarea, 26091 toggleGroup: ToggleGroup 26092 }; 26093 function isEditConfig(value) { 26094 return value && typeof value === "object" && typeof value.control === "string"; 26095 } 26096 function createConfiguredControl(config) { 26097 const { control, ...controlConfig } = config; 26098 const BaseControlType = getControlByType(control); 26099 if (BaseControlType === null) { 26100 return null; 26101 } 26102 return function ConfiguredControl(props) { 26103 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(BaseControlType, { ...props, config: controlConfig }); 26104 }; 26105 } 26106 function getControl(field, fallback) { 26107 if (typeof field.Edit === "function") { 26108 return field.Edit; 26109 } 26110 if (typeof field.Edit === "string") { 26111 return getControlByType(field.Edit); 26112 } 26113 if (isEditConfig(field.Edit)) { 26114 return createConfiguredControl(field.Edit); 26115 } 26116 if (hasElements(field) && field.type !== "array") { 26117 return getControlByType("adaptiveSelect"); 26118 } 26119 if (fallback === null) { 26120 return null; 26121 } 26122 return getControlByType(fallback); 26123 } 26124 function getControlByType(type) { 26125 if (Object.keys(FORM_CONTROLS).includes(type)) { 26126 return FORM_CONTROLS[type]; 26127 } 26128 return null; 26129 } 26130 26131 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs 26132 function getFilterBy(field, defaultOperators, validOperators) { 26133 if (field.filterBy === false) { 26134 return false; 26135 } 26136 const operators = field.filterBy?.operators?.filter( 26137 (op) => validOperators.includes(op) 26138 ) ?? defaultOperators; 26139 if (operators.length === 0) { 26140 return false; 26141 } 26142 return { 26143 isPrimary: !!field.filterBy?.isPrimary, 26144 operators 26145 }; 26146 } 26147 var get_filter_by_default = getFilterBy; 26148 26149 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs 26150 var getValueFromId = (id) => ({ item }) => { 26151 const path = id.split("."); 26152 let value = item; 26153 for (const segment of path) { 26154 if (value.hasOwnProperty(segment)) { 26155 value = value[segment]; 26156 } else { 26157 value = void 0; 26158 } 26159 } 26160 return value; 26161 }; 26162 var get_value_from_id_default = getValueFromId; 26163 26164 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs 26165 var setValueFromId = (id) => ({ value }) => { 26166 const path = id.split("."); 26167 const result = {}; 26168 let current = result; 26169 for (const segment of path.slice(0, -1)) { 26170 current[segment] = {}; 26171 current = current[segment]; 26172 } 26173 current[path.at(-1)] = value; 26174 return result; 26175 }; 26176 var set_value_from_id_default = setValueFromId; 26177 26178 // packages/dataviews/build-module/field-types/email.mjs 26179 var import_i18n37 = __toESM(require_i18n(), 1); 26180 26181 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs 26182 function RenderFromElements({ 26183 item, 26184 field 26185 }) { 26186 const { elements, isLoading } = useElements({ 26187 elements: field.elements, 26188 getElements: field.getElements 26189 }); 26190 const value = field.getValue({ item }); 26191 if (isLoading) { 26192 return value; 26193 } 26194 if (elements.length === 0) { 26195 return value; 26196 } 26197 return elements?.find((element) => element.value === value)?.label || field.getValue({ item }); 26198 } 26199 26200 // packages/dataviews/build-module/field-types/utils/render-default.mjs 26201 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1); 26202 function render({ 26203 item, 26204 field 26205 }) { 26206 if (field.hasElements) { 26207 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(RenderFromElements, { item, field }); 26208 } 26209 return field.getValueFormatted({ item, field }); 26210 } 26211 26212 // packages/dataviews/build-module/field-types/utils/sort-text.mjs 26213 var sort_text_default = (a2, b2, direction) => { 26214 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2); 26215 }; 26216 26217 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs 26218 function isValidRequired(item, field) { 26219 const value = field.getValue({ item }); 26220 return ![void 0, "", null].includes(value); 26221 } 26222 26223 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs 26224 function isValidMinLength(item, field) { 26225 if (typeof field.isValid.minLength?.constraint !== "number") { 26226 return false; 26227 } 26228 const value = field.getValue({ item }); 26229 if ([void 0, "", null].includes(value)) { 26230 return true; 26231 } 26232 return String(value).length >= field.isValid.minLength.constraint; 26233 } 26234 26235 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs 26236 function isValidMaxLength(item, field) { 26237 if (typeof field.isValid.maxLength?.constraint !== "number") { 26238 return false; 26239 } 26240 const value = field.getValue({ item }); 26241 if ([void 0, "", null].includes(value)) { 26242 return true; 26243 } 26244 return String(value).length <= field.isValid.maxLength.constraint; 26245 } 26246 26247 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs 26248 function isValidPattern(item, field) { 26249 if (field.isValid.pattern?.constraint === void 0) { 26250 return true; 26251 } 26252 try { 26253 const regexp = new RegExp(field.isValid.pattern.constraint); 26254 const value = field.getValue({ item }); 26255 if ([void 0, "", null].includes(value)) { 26256 return true; 26257 } 26258 return regexp.test(String(value)); 26259 } catch { 26260 return false; 26261 } 26262 } 26263 26264 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs 26265 function isValidElements(item, field) { 26266 const elements = field.elements ?? []; 26267 const validValues = elements.map((el) => el.value); 26268 if (validValues.length === 0) { 26269 return true; 26270 } 26271 const value = field.getValue({ item }); 26272 return [].concat(value).every((v2) => validValues.includes(v2)); 26273 } 26274 26275 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs 26276 function getValueFormatted({ 26277 item, 26278 field 26279 }) { 26280 return field.getValue({ item }); 26281 } 26282 var get_value_formatted_default_default = getValueFormatted; 26283 26284 // packages/dataviews/build-module/field-types/email.mjs 26285 var emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 26286 function isValidCustom(item, field) { 26287 const value = field.getValue({ item }); 26288 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) { 26289 return (0, import_i18n37.__)("Value must be a valid email address."); 26290 } 26291 return null; 26292 } 26293 var email_default = { 26294 type: "email", 26295 render, 26296 Edit: "email", 26297 sort: sort_text_default, 26298 enableSorting: true, 26299 enableGlobalSearch: false, 26300 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 26301 validOperators: [ 26302 OPERATOR_IS, 26303 OPERATOR_IS_NOT, 26304 OPERATOR_CONTAINS, 26305 OPERATOR_NOT_CONTAINS, 26306 OPERATOR_STARTS_WITH, 26307 // Multiple selection 26308 OPERATOR_IS_ANY, 26309 OPERATOR_IS_NONE, 26310 OPERATOR_IS_ALL, 26311 OPERATOR_IS_NOT_ALL 26312 ], 26313 format: {}, 26314 getValueFormatted: get_value_formatted_default_default, 26315 validate: { 26316 required: isValidRequired, 26317 pattern: isValidPattern, 26318 minLength: isValidMinLength, 26319 maxLength: isValidMaxLength, 26320 elements: isValidElements, 26321 custom: isValidCustom 26322 } 26323 }; 26324 26325 // packages/dataviews/build-module/field-types/integer.mjs 26326 var import_i18n38 = __toESM(require_i18n(), 1); 26327 26328 // packages/dataviews/build-module/field-types/utils/sort-number.mjs 26329 var sort_number_default = (a2, b2, direction) => { 26330 return direction === "asc" ? a2 - b2 : b2 - a2; 26331 }; 26332 26333 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs 26334 function isValidMin(item, field) { 26335 if (typeof field.isValid.min?.constraint !== "number") { 26336 return false; 26337 } 26338 const value = field.getValue({ item }); 26339 if ([void 0, "", null].includes(value)) { 26340 return true; 26341 } 26342 return Number(value) >= field.isValid.min.constraint; 26343 } 26344 26345 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs 26346 function isValidMax(item, field) { 26347 if (typeof field.isValid.max?.constraint !== "number") { 26348 return false; 26349 } 26350 const value = field.getValue({ item }); 26351 if ([void 0, "", null].includes(value)) { 26352 return true; 26353 } 26354 return Number(value) <= field.isValid.max.constraint; 26355 } 26356 26357 // packages/dataviews/build-module/field-types/integer.mjs 26358 var format2 = { 26359 separatorThousand: "," 26360 }; 26361 function getValueFormatted2({ 26362 item, 26363 field 26364 }) { 26365 let value = field.getValue({ item }); 26366 if (value === null || value === void 0) { 26367 return ""; 26368 } 26369 value = Number(value); 26370 if (!Number.isFinite(value)) { 26371 return String(value); 26372 } 26373 let formatInteger; 26374 if (field.type !== "integer") { 26375 formatInteger = format2; 26376 } else { 26377 formatInteger = field.format; 26378 } 26379 const { separatorThousand } = formatInteger; 26380 const integerValue = Math.trunc(value); 26381 if (!separatorThousand) { 26382 return String(integerValue); 26383 } 26384 return String(integerValue).replace( 26385 /\B(?=(\d{3})+(?!\d))/g, 26386 separatorThousand 26387 ); 26388 } 26389 function isValidCustom2(item, field) { 26390 const value = field.getValue({ item }); 26391 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) { 26392 return (0, import_i18n38.__)("Value must be an integer."); 26393 } 26394 return null; 26395 } 26396 var integer_default = { 26397 type: "integer", 26398 render, 26399 Edit: "integer", 26400 sort: sort_number_default, 26401 enableSorting: true, 26402 enableGlobalSearch: false, 26403 defaultOperators: [ 26404 OPERATOR_IS, 26405 OPERATOR_IS_NOT, 26406 OPERATOR_LESS_THAN, 26407 OPERATOR_GREATER_THAN, 26408 OPERATOR_LESS_THAN_OR_EQUAL, 26409 OPERATOR_GREATER_THAN_OR_EQUAL, 26410 OPERATOR_BETWEEN 26411 ], 26412 validOperators: [ 26413 // Single-selection 26414 OPERATOR_IS, 26415 OPERATOR_IS_NOT, 26416 OPERATOR_LESS_THAN, 26417 OPERATOR_GREATER_THAN, 26418 OPERATOR_LESS_THAN_OR_EQUAL, 26419 OPERATOR_GREATER_THAN_OR_EQUAL, 26420 OPERATOR_BETWEEN, 26421 // Multiple-selection 26422 OPERATOR_IS_ANY, 26423 OPERATOR_IS_NONE, 26424 OPERATOR_IS_ALL, 26425 OPERATOR_IS_NOT_ALL 26426 ], 26427 format: format2, 26428 getValueFormatted: getValueFormatted2, 26429 validate: { 26430 required: isValidRequired, 26431 min: isValidMin, 26432 max: isValidMax, 26433 elements: isValidElements, 26434 custom: isValidCustom2 26435 } 26436 }; 26437 26438 // packages/dataviews/build-module/field-types/number.mjs 26439 var import_i18n39 = __toESM(require_i18n(), 1); 26440 var format3 = { 26441 separatorThousand: ",", 26442 separatorDecimal: ".", 26443 decimals: 2 26444 }; 26445 function getValueFormatted3({ 26446 item, 26447 field 26448 }) { 26449 let value = field.getValue({ item }); 26450 if (value === null || value === void 0) { 26451 return ""; 26452 } 26453 value = Number(value); 26454 if (!Number.isFinite(value)) { 26455 return String(value); 26456 } 26457 let formatNumber; 26458 if (field.type !== "number") { 26459 formatNumber = format3; 26460 } else { 26461 formatNumber = field.format; 26462 } 26463 const { separatorThousand, separatorDecimal, decimals } = formatNumber; 26464 const fixedValue = value.toFixed(decimals); 26465 const [integerPart, decimalPart] = fixedValue.split("."); 26466 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart; 26467 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart; 26468 } 26469 function isEmpty2(value) { 26470 return value === "" || value === void 0 || value === null; 26471 } 26472 function isValidCustom3(item, field) { 26473 const value = field.getValue({ item }); 26474 if (!isEmpty2(value) && !Number.isFinite(value)) { 26475 return (0, import_i18n39.__)("Value must be a number."); 26476 } 26477 return null; 26478 } 26479 var number_default = { 26480 type: "number", 26481 render, 26482 Edit: "number", 26483 sort: sort_number_default, 26484 enableSorting: true, 26485 enableGlobalSearch: false, 26486 defaultOperators: [ 26487 OPERATOR_IS, 26488 OPERATOR_IS_NOT, 26489 OPERATOR_LESS_THAN, 26490 OPERATOR_GREATER_THAN, 26491 OPERATOR_LESS_THAN_OR_EQUAL, 26492 OPERATOR_GREATER_THAN_OR_EQUAL, 26493 OPERATOR_BETWEEN 26494 ], 26495 validOperators: [ 26496 // Single-selection 26497 OPERATOR_IS, 26498 OPERATOR_IS_NOT, 26499 OPERATOR_LESS_THAN, 26500 OPERATOR_GREATER_THAN, 26501 OPERATOR_LESS_THAN_OR_EQUAL, 26502 OPERATOR_GREATER_THAN_OR_EQUAL, 26503 OPERATOR_BETWEEN, 26504 // Multiple-selection 26505 OPERATOR_IS_ANY, 26506 OPERATOR_IS_NONE, 26507 OPERATOR_IS_ALL, 26508 OPERATOR_IS_NOT_ALL 26509 ], 26510 format: format3, 26511 getValueFormatted: getValueFormatted3, 26512 validate: { 26513 required: isValidRequired, 26514 min: isValidMin, 26515 max: isValidMax, 26516 elements: isValidElements, 26517 custom: isValidCustom3 26518 } 26519 }; 26520 26521 // packages/dataviews/build-module/field-types/text.mjs 26522 var text_default = { 26523 type: "text", 26524 render, 26525 Edit: "text", 26526 sort: sort_text_default, 26527 enableSorting: true, 26528 enableGlobalSearch: false, 26529 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 26530 validOperators: [ 26531 // Single selection 26532 OPERATOR_IS, 26533 OPERATOR_IS_NOT, 26534 OPERATOR_CONTAINS, 26535 OPERATOR_NOT_CONTAINS, 26536 OPERATOR_STARTS_WITH, 26537 // Multiple selection 26538 OPERATOR_IS_ANY, 26539 OPERATOR_IS_NONE, 26540 OPERATOR_IS_ALL, 26541 OPERATOR_IS_NOT_ALL 26542 ], 26543 format: {}, 26544 getValueFormatted: get_value_formatted_default_default, 26545 validate: { 26546 required: isValidRequired, 26547 pattern: isValidPattern, 26548 minLength: isValidMinLength, 26549 maxLength: isValidMaxLength, 26550 elements: isValidElements 26551 } 26552 }; 26553 26554 // packages/dataviews/build-module/field-types/datetime.mjs 26555 var import_date7 = __toESM(require_date(), 1); 26556 26557 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs 26558 var import_date6 = __toESM(require_date(), 1); 26559 function parseDateLike(value) { 26560 if (!value) { 26561 return null; 26562 } 26563 if (!isValid(new Date(value))) { 26564 return null; 26565 } 26566 const parsed = (0, import_date6.getDate)(value); 26567 return parsed && isValid(parsed) ? parsed : null; 26568 } 26569 function validateDateLikeBoundary(item, field, boundary) { 26570 const constraint = field.isValid[boundary]?.constraint; 26571 if (typeof constraint !== "string") { 26572 return false; 26573 } 26574 const value = field.getValue({ item }); 26575 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value; 26576 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") { 26577 return true; 26578 } 26579 const parsedConstraint = parseDateLike(constraint); 26580 const parsedValue = parseDateLike(String(boundaryValue)); 26581 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime()); 26582 } 26583 function isValidMinDate(item, field) { 26584 return validateDateLikeBoundary(item, field, "min"); 26585 } 26586 function isValidMaxDate(item, field) { 26587 return validateDateLikeBoundary(item, field, "max"); 26588 } 26589 26590 // packages/dataviews/build-module/field-types/datetime.mjs 26591 var format4 = { 26592 datetime: (0, import_date7.getSettings)().formats.datetime, 26593 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek 26594 }; 26595 function getValueFormatted4({ 26596 item, 26597 field 26598 }) { 26599 const value = field.getValue({ item }); 26600 if (["", void 0, null].includes(value)) { 26601 return ""; 26602 } 26603 let formatDatetime; 26604 if (field.type !== "datetime") { 26605 formatDatetime = format4; 26606 } else { 26607 formatDatetime = field.format; 26608 } 26609 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value)); 26610 } 26611 var sort = (a2, b2, direction) => { 26612 const timeA = new Date(a2).getTime(); 26613 const timeB = new Date(b2).getTime(); 26614 return direction === "asc" ? timeA - timeB : timeB - timeA; 26615 }; 26616 var datetime_default = { 26617 type: "datetime", 26618 render, 26619 Edit: "datetime", 26620 sort, 26621 enableSorting: true, 26622 enableGlobalSearch: false, 26623 defaultOperators: [ 26624 OPERATOR_ON, 26625 OPERATOR_NOT_ON, 26626 OPERATOR_BEFORE, 26627 OPERATOR_AFTER, 26628 OPERATOR_BEFORE_INC, 26629 OPERATOR_AFTER_INC, 26630 OPERATOR_IN_THE_PAST, 26631 OPERATOR_OVER 26632 ], 26633 validOperators: [ 26634 OPERATOR_ON, 26635 OPERATOR_NOT_ON, 26636 OPERATOR_BEFORE, 26637 OPERATOR_AFTER, 26638 OPERATOR_BEFORE_INC, 26639 OPERATOR_AFTER_INC, 26640 OPERATOR_IN_THE_PAST, 26641 OPERATOR_OVER 26642 ], 26643 format: format4, 26644 getValueFormatted: getValueFormatted4, 26645 validate: { 26646 required: isValidRequired, 26647 elements: isValidElements, 26648 min: isValidMinDate, 26649 max: isValidMaxDate 26650 } 26651 }; 26652 26653 // packages/dataviews/build-module/field-types/date.mjs 26654 var import_date8 = __toESM(require_date(), 1); 26655 var format5 = { 26656 date: (0, import_date8.getSettings)().formats.date, 26657 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek 26658 }; 26659 function getValueFormatted5({ 26660 item, 26661 field 26662 }) { 26663 const value = field.getValue({ item }); 26664 if (["", void 0, null].includes(value)) { 26665 return ""; 26666 } 26667 let formatDate2; 26668 if (field.type !== "date") { 26669 formatDate2 = format5; 26670 } else { 26671 formatDate2 = field.format; 26672 } 26673 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value)); 26674 } 26675 var sort2 = (a2, b2, direction) => { 26676 const timeA = new Date(a2).getTime(); 26677 const timeB = new Date(b2).getTime(); 26678 return direction === "asc" ? timeA - timeB : timeB - timeA; 26679 }; 26680 var date_default = { 26681 type: "date", 26682 render, 26683 Edit: "date", 26684 sort: sort2, 26685 enableSorting: true, 26686 enableGlobalSearch: false, 26687 defaultOperators: [ 26688 OPERATOR_ON, 26689 OPERATOR_NOT_ON, 26690 OPERATOR_BEFORE, 26691 OPERATOR_AFTER, 26692 OPERATOR_BEFORE_INC, 26693 OPERATOR_AFTER_INC, 26694 OPERATOR_IN_THE_PAST, 26695 OPERATOR_OVER, 26696 OPERATOR_BETWEEN 26697 ], 26698 validOperators: [ 26699 OPERATOR_ON, 26700 OPERATOR_NOT_ON, 26701 OPERATOR_BEFORE, 26702 OPERATOR_AFTER, 26703 OPERATOR_BEFORE_INC, 26704 OPERATOR_AFTER_INC, 26705 OPERATOR_IN_THE_PAST, 26706 OPERATOR_OVER, 26707 OPERATOR_BETWEEN 26708 ], 26709 format: format5, 26710 getValueFormatted: getValueFormatted5, 26711 validate: { 26712 required: isValidRequired, 26713 elements: isValidElements, 26714 min: isValidMinDate, 26715 max: isValidMaxDate 26716 } 26717 }; 26718 26719 // packages/dataviews/build-module/field-types/boolean.mjs 26720 var import_i18n40 = __toESM(require_i18n(), 1); 26721 26722 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs 26723 function isValidRequiredForBool(item, field) { 26724 const value = field.getValue({ item }); 26725 return value === true; 26726 } 26727 26728 // packages/dataviews/build-module/field-types/boolean.mjs 26729 function getValueFormatted6({ 26730 item, 26731 field 26732 }) { 26733 const value = field.getValue({ item }); 26734 if (value === true) { 26735 return (0, import_i18n40.__)("True"); 26736 } 26737 if (value === false) { 26738 return (0, import_i18n40.__)("False"); 26739 } 26740 return ""; 26741 } 26742 function isValidCustom4(item, field) { 26743 const value = field.getValue({ item }); 26744 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) { 26745 return (0, import_i18n40.__)("Value must be true, false, or undefined"); 26746 } 26747 return null; 26748 } 26749 var sort3 = (a2, b2, direction) => { 26750 const boolA = Boolean(a2); 26751 const boolB = Boolean(b2); 26752 if (boolA === boolB) { 26753 return 0; 26754 } 26755 if (direction === "asc") { 26756 return boolA ? 1 : -1; 26757 } 26758 return boolA ? -1 : 1; 26759 }; 26760 var boolean_default = { 26761 type: "boolean", 26762 render, 26763 Edit: "checkbox", 26764 sort: sort3, 26765 validate: { 26766 required: isValidRequiredForBool, 26767 elements: isValidElements, 26768 custom: isValidCustom4 26769 }, 26770 enableSorting: true, 26771 enableGlobalSearch: false, 26772 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 26773 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 26774 format: {}, 26775 getValueFormatted: getValueFormatted6 26776 }; 26777 26778 // packages/dataviews/build-module/field-types/media.mjs 26779 var media_default = { 26780 type: "media", 26781 render: () => null, 26782 Edit: null, 26783 sort: () => 0, 26784 enableSorting: false, 26785 enableGlobalSearch: false, 26786 defaultOperators: [], 26787 validOperators: [], 26788 format: {}, 26789 getValueFormatted: get_value_formatted_default_default, 26790 // cannot validate any constraint, so 26791 // the only available validation for the field author 26792 // would be providing a custom validator. 26793 validate: {} 26794 }; 26795 26796 // packages/dataviews/build-module/field-types/array.mjs 26797 var import_i18n41 = __toESM(require_i18n(), 1); 26798 26799 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs 26800 function isValidRequiredForArray(item, field) { 26801 const value = field.getValue({ item }); 26802 return Array.isArray(value) && value.length > 0 && value.every( 26803 (element) => ![void 0, "", null].includes(element) 26804 ); 26805 } 26806 26807 // packages/dataviews/build-module/field-types/array.mjs 26808 function getValueFormatted7({ 26809 item, 26810 field 26811 }) { 26812 const value = field.getValue({ item }); 26813 const arr = Array.isArray(value) ? value : []; 26814 return arr.join(", "); 26815 } 26816 function render2({ item, field }) { 26817 return getValueFormatted7({ item, field }); 26818 } 26819 function isValidCustom5(item, field) { 26820 const value = field.getValue({ item }); 26821 if (![void 0, "", null].includes(value) && !Array.isArray(value)) { 26822 return (0, import_i18n41.__)("Value must be an array."); 26823 } 26824 if (!value.every((v2) => typeof v2 === "string")) { 26825 return (0, import_i18n41.__)("Every value must be a string."); 26826 } 26827 return null; 26828 } 26829 var sort4 = (a2, b2, direction) => { 26830 const arrA = Array.isArray(a2) ? a2 : []; 26831 const arrB = Array.isArray(b2) ? b2 : []; 26832 if (arrA.length !== arrB.length) { 26833 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length; 26834 } 26835 const joinedA = arrA.join(","); 26836 const joinedB = arrB.join(","); 26837 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA); 26838 }; 26839 var array_default = { 26840 type: "array", 26841 render: render2, 26842 Edit: "array", 26843 sort: sort4, 26844 enableSorting: true, 26845 enableGlobalSearch: false, 26846 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 26847 validOperators: [ 26848 OPERATOR_IS_ANY, 26849 OPERATOR_IS_NONE, 26850 OPERATOR_IS_ALL, 26851 OPERATOR_IS_NOT_ALL 26852 ], 26853 format: {}, 26854 getValueFormatted: getValueFormatted7, 26855 validate: { 26856 required: isValidRequiredForArray, 26857 elements: isValidElements, 26858 custom: isValidCustom5 26859 } 26860 }; 26861 26862 // packages/dataviews/build-module/field-types/password.mjs 26863 function getValueFormatted8({ 26864 item, 26865 field 26866 }) { 26867 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : ""; 26868 } 26869 var password_default = { 26870 type: "password", 26871 render, 26872 Edit: "password", 26873 sort: () => 0, 26874 // Passwords should not be sortable for security reasons 26875 enableSorting: false, 26876 enableGlobalSearch: false, 26877 defaultOperators: [], 26878 validOperators: [], 26879 format: {}, 26880 getValueFormatted: getValueFormatted8, 26881 validate: { 26882 required: isValidRequired, 26883 pattern: isValidPattern, 26884 minLength: isValidMinLength, 26885 maxLength: isValidMaxLength, 26886 elements: isValidElements 26887 } 26888 }; 26889 26890 // packages/dataviews/build-module/field-types/telephone.mjs 26891 var telephone_default = { 26892 type: "telephone", 26893 render, 26894 Edit: "telephone", 26895 sort: sort_text_default, 26896 enableSorting: true, 26897 enableGlobalSearch: false, 26898 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 26899 validOperators: [ 26900 OPERATOR_IS, 26901 OPERATOR_IS_NOT, 26902 OPERATOR_CONTAINS, 26903 OPERATOR_NOT_CONTAINS, 26904 OPERATOR_STARTS_WITH, 26905 // Multiple selection 26906 OPERATOR_IS_ANY, 26907 OPERATOR_IS_NONE, 26908 OPERATOR_IS_ALL, 26909 OPERATOR_IS_NOT_ALL 26910 ], 26911 format: {}, 26912 getValueFormatted: get_value_formatted_default_default, 26913 validate: { 26914 required: isValidRequired, 26915 pattern: isValidPattern, 26916 minLength: isValidMinLength, 26917 maxLength: isValidMaxLength, 26918 elements: isValidElements 26919 } 26920 }; 26921 26922 // packages/dataviews/build-module/field-types/color.mjs 26923 var import_i18n42 = __toESM(require_i18n(), 1); 26924 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1); 26925 function render3({ item, field }) { 26926 if (field.hasElements) { 26927 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(RenderFromElements, { item, field }); 26928 } 26929 const value = get_value_formatted_default_default({ item, field }); 26930 if (!value || !w(value).isValid()) { 26931 return value; 26932 } 26933 return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [ 26934 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 26935 "div", 26936 { 26937 style: { 26938 width: "16px", 26939 height: "16px", 26940 borderRadius: "50%", 26941 backgroundColor: value, 26942 border: "1px solid #ddd", 26943 flexShrink: 0 26944 } 26945 } 26946 ), 26947 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { children: value }) 26948 ] }); 26949 } 26950 function isValidCustom6(item, field) { 26951 const value = field.getValue({ item }); 26952 if (![void 0, "", null].includes(value) && !w(value).isValid()) { 26953 return (0, import_i18n42.__)("Value must be a valid color."); 26954 } 26955 return null; 26956 } 26957 var sort5 = (a2, b2, direction) => { 26958 const colorA = w(a2); 26959 const colorB = w(b2); 26960 if (!colorA.isValid() && !colorB.isValid()) { 26961 return 0; 26962 } 26963 if (!colorA.isValid()) { 26964 return direction === "asc" ? 1 : -1; 26965 } 26966 if (!colorB.isValid()) { 26967 return direction === "asc" ? -1 : 1; 26968 } 26969 const hslA = colorA.toHsl(); 26970 const hslB = colorB.toHsl(); 26971 if (hslA.h !== hslB.h) { 26972 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h; 26973 } 26974 if (hslA.s !== hslB.s) { 26975 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s; 26976 } 26977 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l; 26978 }; 26979 var color_default = { 26980 type: "color", 26981 render: render3, 26982 Edit: "color", 26983 sort: sort5, 26984 enableSorting: true, 26985 enableGlobalSearch: false, 26986 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 26987 validOperators: [ 26988 OPERATOR_IS, 26989 OPERATOR_IS_NOT, 26990 OPERATOR_IS_ANY, 26991 OPERATOR_IS_NONE 26992 ], 26993 format: {}, 26994 getValueFormatted: get_value_formatted_default_default, 26995 validate: { 26996 required: isValidRequired, 26997 elements: isValidElements, 26998 custom: isValidCustom6 26999 } 27000 }; 27001 27002 // packages/dataviews/build-module/field-types/url.mjs 27003 var url_default = { 27004 type: "url", 27005 render, 27006 Edit: "url", 27007 sort: sort_text_default, 27008 enableSorting: true, 27009 enableGlobalSearch: false, 27010 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 27011 validOperators: [ 27012 OPERATOR_IS, 27013 OPERATOR_IS_NOT, 27014 OPERATOR_CONTAINS, 27015 OPERATOR_NOT_CONTAINS, 27016 OPERATOR_STARTS_WITH, 27017 // Multiple selection 27018 OPERATOR_IS_ANY, 27019 OPERATOR_IS_NONE, 27020 OPERATOR_IS_ALL, 27021 OPERATOR_IS_NOT_ALL 27022 ], 27023 format: {}, 27024 getValueFormatted: get_value_formatted_default_default, 27025 validate: { 27026 required: isValidRequired, 27027 pattern: isValidPattern, 27028 minLength: isValidMinLength, 27029 maxLength: isValidMaxLength, 27030 elements: isValidElements 27031 } 27032 }; 27033 27034 // packages/dataviews/build-module/field-types/no-type.mjs 27035 var sort6 = (a2, b2, direction) => { 27036 if (typeof a2 === "number" && typeof b2 === "number") { 27037 return sort_number_default(a2, b2, direction); 27038 } 27039 return sort_text_default(a2, b2, direction); 27040 }; 27041 var no_type_default = { 27042 // type: no type for this one 27043 render, 27044 Edit: null, 27045 sort: sort6, 27046 enableSorting: true, 27047 enableGlobalSearch: false, 27048 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 27049 validOperators: getAllOperatorNames(), 27050 format: {}, 27051 getValueFormatted: get_value_formatted_default_default, 27052 validate: { 27053 required: isValidRequired, 27054 elements: isValidElements 27055 } 27056 }; 27057 27058 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs 27059 function supportsNumericRangeConstraint(type) { 27060 return type === "integer" || type === "number"; 27061 } 27062 function supportsDateRangeConstraint(type) { 27063 return type === "date" || type === "datetime"; 27064 } 27065 function normalizeRangeRule(value, fieldType, key) { 27066 const validator = fieldType.validate[key]; 27067 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) { 27068 return { constraint: value, validate: validator }; 27069 } 27070 return void 0; 27071 } 27072 function getIsValid(field, fieldType) { 27073 const rules = field.isValid; 27074 let required; 27075 if (rules?.required === true && fieldType.validate.required !== void 0) { 27076 required = { 27077 constraint: true, 27078 validate: fieldType.validate.required 27079 }; 27080 } 27081 let elements; 27082 if ((rules?.elements === true || // elements is enabled unless the field opts-out 27083 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) { 27084 elements = { 27085 constraint: true, 27086 validate: fieldType.validate.elements 27087 }; 27088 } 27089 const min2 = normalizeRangeRule(rules?.min, fieldType, "min"); 27090 const max2 = normalizeRangeRule(rules?.max, fieldType, "max"); 27091 const minLengthValue = rules?.minLength; 27092 let minLength; 27093 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) { 27094 minLength = { 27095 constraint: minLengthValue, 27096 validate: fieldType.validate.minLength 27097 }; 27098 } 27099 const maxLengthValue = rules?.maxLength; 27100 let maxLength; 27101 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) { 27102 maxLength = { 27103 constraint: maxLengthValue, 27104 validate: fieldType.validate.maxLength 27105 }; 27106 } 27107 const patternValue = rules?.pattern; 27108 let pattern; 27109 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) { 27110 pattern = { 27111 constraint: patternValue, 27112 validate: fieldType.validate.pattern 27113 }; 27114 } 27115 const custom = rules?.custom ?? fieldType.validate.custom; 27116 return { 27117 required, 27118 elements, 27119 min: min2, 27120 max: max2, 27121 minLength, 27122 maxLength, 27123 pattern, 27124 custom 27125 }; 27126 } 27127 27128 // packages/dataviews/build-module/field-types/utils/get-filter.mjs 27129 function getFilter(fieldType) { 27130 return fieldType.validOperators.reduce((accumulator, operator) => { 27131 const operatorObj = getOperatorByName(operator); 27132 if (operatorObj?.filter) { 27133 accumulator[operator] = operatorObj.filter; 27134 } 27135 return accumulator; 27136 }, {}); 27137 } 27138 27139 // packages/dataviews/build-module/field-types/utils/get-format.mjs 27140 function getFormat(field, fieldType) { 27141 return { 27142 ...fieldType.format, 27143 ...field.format 27144 }; 27145 } 27146 var get_format_default = getFormat; 27147 27148 // packages/dataviews/build-module/field-types/index.mjs 27149 function getFieldTypeByName(type) { 27150 const found = [ 27151 email_default, 27152 integer_default, 27153 number_default, 27154 text_default, 27155 datetime_default, 27156 date_default, 27157 boolean_default, 27158 media_default, 27159 array_default, 27160 password_default, 27161 telephone_default, 27162 color_default, 27163 url_default 27164 ].find((fieldType) => fieldType?.type === type); 27165 if (!!found) { 27166 return found; 27167 } 27168 return no_type_default; 27169 } 27170 function normalizeFields(fields2) { 27171 return fields2.map((field) => { 27172 const fieldType = getFieldTypeByName(field.type); 27173 const getValue = field.getValue || get_value_from_id_default(field.id); 27174 const sort7 = function(a2, b2, direction) { 27175 const aValue = getValue({ item: a2 }); 27176 const bValue = getValue({ item: b2 }); 27177 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction); 27178 }; 27179 return { 27180 id: field.id, 27181 label: field.label || field.id, 27182 header: field.header || field.label || field.id, 27183 description: field.description, 27184 placeholder: field.placeholder, 27185 getValue, 27186 setValue: field.setValue || set_value_from_id_default(field.id), 27187 elements: field.elements, 27188 getElements: field.getElements, 27189 hasElements: hasElements(field), 27190 isVisible: field.isVisible, 27191 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled, 27192 enableHiding: field.enableHiding ?? true, 27193 readOnly: field.readOnly ?? false, 27194 // The type provides defaults for the following props 27195 type: fieldType.type, 27196 render: field.render ?? fieldType.render, 27197 Edit: getControl(field, fieldType.Edit), 27198 sort: sort7, 27199 enableSorting: field.enableSorting ?? fieldType.enableSorting, 27200 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch, 27201 isValid: getIsValid(field, fieldType), 27202 filterBy: get_filter_by_default( 27203 field, 27204 fieldType.defaultOperators, 27205 fieldType.validOperators 27206 ), 27207 filter: getFilter(fieldType), 27208 format: get_format_default(field, fieldType), 27209 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted 27210 }; 27211 }); 27212 } 27213 27214 // packages/dataviews/build-module/hooks/use-data.mjs 27215 var import_element85 = __toESM(require_element(), 1); 27216 function useData({ 27217 view, 27218 data: shownData, 27219 getItemId, 27220 isLoading, 27221 paginationInfo, 27222 selection 27223 }) { 27224 const isInfiniteScrollEnabled = view.infiniteScrollEnabled; 27225 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element85.useState)( 27226 !isLoading 27227 ); 27228 (0, import_element85.useEffect)(() => { 27229 if (!isLoading) { 27230 setHasInitiallyLoaded(true); 27231 } 27232 }, [isLoading]); 27233 const previousDataRef = (0, import_element85.useRef)(shownData); 27234 const previousPaginationInfoRef = (0, import_element85.useRef)(paginationInfo); 27235 (0, import_element85.useEffect)(() => { 27236 if (!isLoading) { 27237 previousDataRef.current = shownData; 27238 previousPaginationInfoRef.current = paginationInfo; 27239 } 27240 }, [shownData, isLoading, paginationInfo]); 27241 const [visibleEntries, setVisibleEntries] = (0, import_element85.useState)([]); 27242 const positionMapRef = (0, import_element85.useRef)(/* @__PURE__ */ new Map()); 27243 const allLoadedRecordsRef = (0, import_element85.useRef)([]); 27244 const prevViewParamsRef = (0, import_element85.useRef)({ 27245 search: void 0, 27246 filters: void 0, 27247 perPage: void 0 27248 }); 27249 const scrollDirectionRef = (0, import_element85.useRef)(void 0); 27250 const prevStartPositionRef = (0, import_element85.useRef)(void 0); 27251 const hasInitializedRef = (0, import_element85.useRef)(false); 27252 const allLoadedRecords = (0, import_element85.useMemo)(() => { 27253 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) { 27254 if (view.startPosition < prevStartPositionRef.current) { 27255 scrollDirectionRef.current = "up"; 27256 } else if (view.startPosition > prevStartPositionRef.current) { 27257 scrollDirectionRef.current = "down"; 27258 } 27259 } 27260 prevStartPositionRef.current = view.startPosition; 27261 const currentFiltersKey = JSON.stringify(view.filters ?? []); 27262 const prevFiltersKey = prevViewParamsRef.current.filters; 27263 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage; 27264 hasInitializedRef.current = true; 27265 prevViewParamsRef.current = { 27266 search: view.search, 27267 filters: currentFiltersKey, 27268 perPage: view.perPage 27269 }; 27270 if (shouldReset) { 27271 positionMapRef.current.clear(); 27272 scrollDirectionRef.current = void 0; 27273 const startPosition = view.search ? 1 : view.startPosition ?? 1; 27274 const records = shownData.map((record, index2) => { 27275 const position = startPosition + index2; 27276 positionMapRef.current.set(getItemId(record), position); 27277 return { 27278 ...record, 27279 position 27280 }; 27281 }); 27282 allLoadedRecordsRef.current = records; 27283 return records; 27284 } 27285 const prev = allLoadedRecordsRef.current; 27286 const shownDataIds = new Set(shownData.map(getItemId)); 27287 const scrollDirection = scrollDirectionRef.current; 27288 const basePosition = view.search ? 1 : view.startPosition ?? 1; 27289 const newRecords = shownData.map((record, index2) => { 27290 const itemId = getItemId(record); 27291 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0; 27292 if (position !== void 0) { 27293 positionMapRef.current.set(itemId, position); 27294 } 27295 return { 27296 ...record, 27297 position 27298 }; 27299 }); 27300 if (newRecords.length === 0) { 27301 return prev; 27302 } 27303 const prevWithoutDuplicates = prev.filter( 27304 (record) => !shownDataIds.has(getItemId(record)) 27305 ); 27306 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords]; 27307 allRecords.sort((a2, b2) => { 27308 const posA = a2.position; 27309 const posB = b2.position; 27310 return posA - posB; 27311 }); 27312 let result = allRecords; 27313 if (visibleEntries.length > 0) { 27314 const visibleMin = Math.min(...visibleEntries); 27315 const visibleMax = Math.max(...visibleEntries); 27316 const buffer = 20; 27317 const recordPositions = allRecords.map( 27318 (r3) => r3.position 27319 ); 27320 const minRecordPos = Math.min(...recordPositions); 27321 const maxRecordPos = Math.max(...recordPositions); 27322 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer); 27323 if (hasOverlap) { 27324 result = allRecords.filter((record) => { 27325 const itemId = getItemId(record); 27326 const isSelected2 = selection?.includes(itemId); 27327 if (isSelected2) { 27328 return true; 27329 } 27330 const itemPosition = record.position; 27331 if (scrollDirection === "up") { 27332 return itemPosition <= visibleMax + buffer; 27333 } else if (scrollDirection === "down") { 27334 return itemPosition >= visibleMin - buffer; 27335 } 27336 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer; 27337 }); 27338 } 27339 } 27340 allLoadedRecordsRef.current = result; 27341 return result; 27342 }, [ 27343 shownData, 27344 view.search, 27345 view.filters, 27346 view.perPage, 27347 view.startPosition, 27348 view.infiniteScrollEnabled, 27349 visibleEntries, 27350 selection, 27351 getItemId 27352 ]); 27353 if (!isInfiniteScrollEnabled) { 27354 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData; 27355 return { 27356 data: dataToReturn.map((item) => ({ 27357 ...item, 27358 position: void 0 27359 })), 27360 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo, 27361 hasInitiallyLoaded, 27362 setVisibleEntries: void 0 27363 }; 27364 } 27365 return { 27366 data: allLoadedRecords, 27367 paginationInfo, 27368 hasInitiallyLoaded, 27369 setVisibleEntries 27370 }; 27371 } 27372 27373 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs 27374 var import_element86 = __toESM(require_element(), 1); 27375 var import_compose11 = __toESM(require_compose(), 1); 27376 function captureAnchorElement(container, anchorElementRef, direction) { 27377 const containerRect = container.getBoundingClientRect(); 27378 const centerY = containerRect.top + containerRect.height / 2; 27379 const items = Array.from(container.querySelectorAll("[aria-posinset]")); 27380 if (items.length === 0) { 27381 return false; 27382 } 27383 const bestAnchor = items.reduce((best, item) => { 27384 const itemRect = item.getBoundingClientRect(); 27385 const itemCenterY = itemRect.top + itemRect.height / 2; 27386 const distance = Math.abs(itemCenterY - centerY); 27387 const bestRect = best.getBoundingClientRect(); 27388 const bestCenterY = bestRect.top + bestRect.height / 2; 27389 const bestDistance = Math.abs(bestCenterY - centerY); 27390 return distance < bestDistance ? item : best; 27391 }); 27392 const posinset = Number(bestAnchor.getAttribute("aria-posinset")); 27393 const anchorRect = bestAnchor.getBoundingClientRect(); 27394 anchorElementRef.current = { 27395 posinset, 27396 viewportOffset: anchorRect.top - containerRect.top, 27397 direction 27398 }; 27399 return true; 27400 } 27401 function useInfiniteScroll({ 27402 view, 27403 onChangeView, 27404 isLoading, 27405 paginationInfo, 27406 containerRef, 27407 setVisibleEntries 27408 }) { 27409 const anchorElementRef = (0, import_element86.useRef)(null); 27410 const viewRef = (0, import_element86.useRef)(view); 27411 const isLoadingRef = (0, import_element86.useRef)(isLoading); 27412 const onChangeViewRef = (0, import_element86.useRef)(onChangeView); 27413 const totalItemsRef = (0, import_element86.useRef)(paginationInfo.totalItems); 27414 (0, import_element86.useLayoutEffect)(() => { 27415 viewRef.current = view; 27416 isLoadingRef.current = isLoading; 27417 onChangeViewRef.current = onChangeView; 27418 totalItemsRef.current = paginationInfo.totalItems; 27419 }, [view, isLoading, onChangeView, paginationInfo.totalItems]); 27420 const intersectionObserverCallback = (0, import_element86.useCallback)( 27421 (entries) => { 27422 if (!setVisibleEntries) { 27423 return; 27424 } 27425 setVisibleEntries((prev) => { 27426 const newVisibleEntries = new Set(prev); 27427 let hasChanged = false; 27428 entries.forEach((entry) => { 27429 const posInSet = Number( 27430 entry.target?.attributes?.getNamedItem( 27431 "aria-posinset" 27432 )?.value 27433 ); 27434 if (isNaN(posInSet)) { 27435 return; 27436 } 27437 if (entry.isIntersecting) { 27438 if (!newVisibleEntries.has(posInSet)) { 27439 newVisibleEntries.add(posInSet); 27440 hasChanged = true; 27441 } 27442 } else if (newVisibleEntries.has(posInSet)) { 27443 newVisibleEntries.delete(posInSet); 27444 hasChanged = true; 27445 } 27446 }); 27447 return hasChanged ? Array.from(newVisibleEntries).sort() : prev; 27448 }); 27449 }, 27450 [setVisibleEntries] 27451 ); 27452 (0, import_element86.useLayoutEffect)(() => { 27453 const container = containerRef.current; 27454 const anchor = anchorElementRef.current; 27455 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) { 27456 return; 27457 } 27458 const anchorElement = container.querySelector( 27459 `[aria-posinset="$anchor.posinset}"]` 27460 ); 27461 if (anchorElement) { 27462 const containerRect = container.getBoundingClientRect(); 27463 const anchorRect = anchorElement.getBoundingClientRect(); 27464 const currentOffset = anchorRect.top - containerRect.top; 27465 const scrollAdjustment = currentOffset - anchor.viewportOffset; 27466 if (Math.abs(scrollAdjustment) > 1) { 27467 container.scrollTop += scrollAdjustment; 27468 } 27469 } 27470 anchorElementRef.current = null; 27471 }, [containerRef, isLoading, view.infiniteScrollEnabled]); 27472 const intersectionObserverRef = (0, import_element86.useRef)( 27473 null 27474 ); 27475 (0, import_element86.useEffect)(() => { 27476 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) { 27477 if (intersectionObserverRef.current) { 27478 intersectionObserverRef.current.disconnect(); 27479 intersectionObserverRef.current = null; 27480 } 27481 return; 27482 } 27483 intersectionObserverRef.current = new IntersectionObserver( 27484 intersectionObserverCallback, 27485 { root: null, rootMargin: "0px", threshold: 0.1 } 27486 ); 27487 return () => { 27488 if (intersectionObserverRef.current) { 27489 intersectionObserverRef.current.disconnect(); 27490 intersectionObserverRef.current = null; 27491 } 27492 }; 27493 }, [view.infiniteScrollEnabled, intersectionObserverCallback]); 27494 (0, import_element86.useEffect)(() => { 27495 if (!view.infiniteScrollEnabled || !containerRef.current) { 27496 return; 27497 } 27498 let lastScrollTop = 0; 27499 const BOTTOM_THRESHOLD = 600; 27500 const TOP_THRESHOLD = 800; 27501 const handleScroll = (0, import_compose11.throttle)((event) => { 27502 const currentView = viewRef.current; 27503 const totalItems = totalItemsRef.current; 27504 const target = event.target; 27505 const scrollTop = target.scrollTop; 27506 const scrollHeight = target.scrollHeight; 27507 const clientHeight = target.clientHeight; 27508 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up"; 27509 lastScrollTop = scrollTop; 27510 if (isLoadingRef.current) { 27511 return; 27512 } 27513 const currentStartPosition = currentView.startPosition || 1; 27514 const batchSize = currentView.perPage || 10; 27515 const currentEndPosition = Math.min( 27516 currentStartPosition + batchSize, 27517 totalItems 27518 ); 27519 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) { 27520 if (currentEndPosition < totalItems) { 27521 const newStartPosition = currentEndPosition; 27522 captureAnchorElement(target, anchorElementRef, "down"); 27523 onChangeViewRef.current({ 27524 ...currentView, 27525 startPosition: newStartPosition 27526 }); 27527 } 27528 } 27529 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) { 27530 if (currentStartPosition > 1) { 27531 const calculatedStartPosition = currentStartPosition - batchSize; 27532 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition; 27533 captureAnchorElement(target, anchorElementRef, "up"); 27534 onChangeViewRef.current({ 27535 ...currentView, 27536 startPosition: newStartPosition 27537 }); 27538 } 27539 } 27540 }, 50); 27541 const container = containerRef.current; 27542 container.addEventListener("scroll", handleScroll); 27543 return () => { 27544 container.removeEventListener("scroll", handleScroll); 27545 handleScroll.cancel(); 27546 }; 27547 }, [containerRef, view.infiniteScrollEnabled]); 27548 return { 27549 intersectionObserver: intersectionObserverRef.current 27550 }; 27551 } 27552 27553 // packages/dataviews/build-module/dataviews/index.mjs 27554 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1); 27555 var defaultGetItemId = (item) => item.id; 27556 var defaultIsItemClickable = () => true; 27557 var EMPTY_ARRAY6 = []; 27558 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} }; 27559 var dataViewsLayouts = VIEW_LAYOUTS.filter( 27560 (viewLayout) => !viewLayout.isPicker 27561 ); 27562 function DefaultUI({ 27563 header, 27564 search = true, 27565 searchLabel = void 0 27566 }) { 27567 const { view } = (0, import_element87.useContext)(dataviews_context_default); 27568 const isInfiniteScroll = view.infiniteScrollEnabled; 27569 return /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(import_jsx_runtime128.Fragment, { children: [ 27570 /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)( 27571 Stack, 27572 { 27573 direction: "row", 27574 align: "top", 27575 justify: "space-between", 27576 className: clsx_default("dataviews__view-actions", { 27577 "dataviews__view-actions--infinite-scroll": isInfiniteScroll 27578 }), 27579 gap: "xs", 27580 children: [ 27581 /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)( 27582 Stack, 27583 { 27584 direction: "row", 27585 justify: "start", 27586 gap: "sm", 27587 className: "dataviews__search", 27588 children: [ 27589 search && /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(dataviews_search_default, { label: searchLabel }), 27590 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(toggle_default, {}) 27591 ] 27592 } 27593 ), 27594 /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [ 27595 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(dataviews_view_config_default, {}), 27596 header 27597 ] }) 27598 ] 27599 } 27600 ), 27601 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }), 27602 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(DataViewsLayout, {}), 27603 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(DataViewsFooter, {}) 27604 ] }); 27605 } 27606 function DataViews({ 27607 view, 27608 onChangeView, 27609 fields: fields2, 27610 search = true, 27611 searchLabel = void 0, 27612 actions: actions2 = EMPTY_ARRAY6, 27613 data, 27614 getItemId = defaultGetItemId, 27615 getItemLevel, 27616 isLoading = false, 27617 paginationInfo, 27618 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS, 27619 selection: selectionProperty, 27620 onChangeSelection, 27621 onClickItem, 27622 renderItemLink, 27623 isItemClickable = defaultIsItemClickable, 27624 header, 27625 children, 27626 config = { perPageSizes: [10, 20, 50, 100] }, 27627 empty, 27628 onReset 27629 }) { 27630 const [selectionState, setSelectionState] = (0, import_element87.useState)([]); 27631 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0; 27632 const selection = isUncontrolled ? selectionState : selectionProperty; 27633 const { 27634 data: displayData, 27635 paginationInfo: displayPaginationInfo, 27636 hasInitiallyLoaded, 27637 setVisibleEntries 27638 } = useData({ 27639 view, 27640 data, 27641 getItemId, 27642 isLoading, 27643 selection, 27644 paginationInfo 27645 }); 27646 const containerRef = (0, import_element87.useRef)(null); 27647 const [containerWidth, setContainerWidth] = (0, import_element87.useState)(0); 27648 const resizeObserverRef = (0, import_compose12.useResizeObserver)( 27649 (resizeObserverEntries) => { 27650 setContainerWidth( 27651 resizeObserverEntries[0].borderBoxSize[0].inlineSize 27652 ); 27653 }, 27654 { box: "border-box" } 27655 ); 27656 const [openedFilter, setOpenedFilter] = (0, import_element87.useState)(null); 27657 function setSelectionWithChange(value) { 27658 const newValue = typeof value === "function" ? value(selection) : value; 27659 if (isUncontrolled) { 27660 setSelectionState(newValue); 27661 } 27662 if (onChangeSelection) { 27663 onChangeSelection(newValue); 27664 } 27665 } 27666 const _fields = (0, import_element87.useMemo)(() => normalizeFields(fields2), [fields2]); 27667 const _selection = (0, import_element87.useMemo)(() => { 27668 if (view.infiniteScrollEnabled) { 27669 return selection; 27670 } 27671 return selection.filter( 27672 (id) => data.some((item) => getItemId(item) === id) 27673 ); 27674 }, [selection, data, getItemId, view.infiniteScrollEnabled]); 27675 const filters = use_filters_default(_fields, view); 27676 const hasPrimaryOrLockedFilters = (0, import_element87.useMemo)( 27677 () => (filters || []).some( 27678 (filter) => filter.isPrimary || filter.isLocked 27679 ), 27680 [filters] 27681 ); 27682 const [isShowingFilter, setIsShowingFilter] = (0, import_element87.useState)( 27683 hasPrimaryOrLockedFilters 27684 ); 27685 const { intersectionObserver } = useInfiniteScroll({ 27686 view, 27687 onChangeView, 27688 isLoading, 27689 paginationInfo, 27690 containerRef, 27691 setVisibleEntries 27692 }); 27693 (0, import_element87.useEffect)(() => { 27694 if (hasPrimaryOrLockedFilters && !isShowingFilter) { 27695 setIsShowingFilter(true); 27696 } 27697 }, [hasPrimaryOrLockedFilters, isShowingFilter]); 27698 const defaultLayouts = (0, import_element87.useMemo)( 27699 () => Object.fromEntries( 27700 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => { 27701 return dataViewsLayouts.some( 27702 (viewLayout) => viewLayout.type === layoutType 27703 ); 27704 }).map(([key, value]) => [ 27705 key, 27706 value === true ? {} : value 27707 ]) 27708 ), 27709 [defaultLayoutsProperty] 27710 ); 27711 if (!defaultLayouts[view.type]) { 27712 return null; 27713 } 27714 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 27715 dataviews_context_default.Provider, 27716 { 27717 value: { 27718 view, 27719 onChangeView, 27720 fields: _fields, 27721 actions: actions2, 27722 data: displayData, 27723 isLoading, 27724 paginationInfo: displayPaginationInfo, 27725 selection: _selection, 27726 onChangeSelection: setSelectionWithChange, 27727 openedFilter, 27728 setOpenedFilter, 27729 getItemId, 27730 getItemLevel, 27731 isItemClickable, 27732 onClickItem, 27733 renderItemLink, 27734 containerWidth, 27735 containerRef, 27736 resizeObserverRef, 27737 defaultLayouts, 27738 filters, 27739 isShowingFilter, 27740 setIsShowingFilter, 27741 config, 27742 empty, 27743 hasInitiallyLoaded, 27744 onReset, 27745 intersectionObserver 27746 }, 27747 children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 27748 DefaultUI, 27749 { 27750 header, 27751 search, 27752 searchLabel 27753 } 27754 ) }) 27755 } 27756 ); 27757 } 27758 var DataViewsSubComponents = DataViews; 27759 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter; 27760 DataViewsSubComponents.Filters = filters_default; 27761 DataViewsSubComponents.FiltersToggled = filters_toggled_default; 27762 DataViewsSubComponents.FiltersToggle = toggle_default; 27763 DataViewsSubComponents.Layout = DataViewsLayout; 27764 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu; 27765 DataViewsSubComponents.Pagination = DataViewsPagination; 27766 DataViewsSubComponents.Search = dataviews_search_default; 27767 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown; 27768 DataViewsSubComponents.Footer = DataViewsFooter; 27769 var dataviews_default = DataViewsSubComponents; 27770 27771 // packages/dataviews/build-module/dataform/index.mjs 27772 var import_element99 = __toESM(require_element(), 1); 27773 27774 // packages/dataviews/build-module/components/dataform-context/index.mjs 27775 var import_element88 = __toESM(require_element(), 1); 27776 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1); 27777 var DataFormContext = (0, import_element88.createContext)({ 27778 fields: [] 27779 }); 27780 DataFormContext.displayName = "DataFormContext"; 27781 function DataFormProvider({ 27782 fields: fields2, 27783 children 27784 }) { 27785 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(DataFormContext.Provider, { value: { fields: fields2 }, children }); 27786 } 27787 var dataform_context_default = DataFormContext; 27788 27789 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs 27790 var import_element98 = __toESM(require_element(), 1); 27791 27792 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs 27793 var import_element89 = __toESM(require_element(), 1); 27794 var import_components47 = __toESM(require_components(), 1); 27795 27796 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs 27797 var import_i18n43 = __toESM(require_i18n(), 1); 27798 var DEFAULT_LAYOUT = { 27799 type: "regular", 27800 labelPosition: "top" 27801 }; 27802 var normalizeCardSummaryField = (sum) => { 27803 if (typeof sum === "string") { 27804 return [{ id: sum, visibility: "when-collapsed" }]; 27805 } 27806 return sum.map((item) => { 27807 if (typeof item === "string") { 27808 return { id: item, visibility: "when-collapsed" }; 27809 } 27810 return { id: item.id, visibility: item.visibility }; 27811 }); 27812 }; 27813 function normalizeLayout(layout) { 27814 let normalizedLayout = DEFAULT_LAYOUT; 27815 if (layout?.type === "regular") { 27816 normalizedLayout = { 27817 type: "regular", 27818 labelPosition: layout?.labelPosition ?? "top" 27819 }; 27820 } else if (layout?.type === "panel") { 27821 const summary = layout.summary ?? []; 27822 const normalizedSummary = Array.isArray(summary) ? summary : [summary]; 27823 const openAs = layout?.openAs; 27824 let normalizedOpenAs; 27825 if (typeof openAs === "object" && openAs.type === "modal") { 27826 normalizedOpenAs = { 27827 type: "modal", 27828 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n43.__)("Apply"), 27829 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n43.__)("Cancel") 27830 }; 27831 } else if (openAs === "modal") { 27832 normalizedOpenAs = { 27833 type: "modal", 27834 applyLabel: (0, import_i18n43.__)("Apply"), 27835 cancelLabel: (0, import_i18n43.__)("Cancel") 27836 }; 27837 } else { 27838 normalizedOpenAs = { type: "dropdown" }; 27839 } 27840 normalizedLayout = { 27841 type: "panel", 27842 labelPosition: layout?.labelPosition ?? "side", 27843 openAs: normalizedOpenAs, 27844 summary: normalizedSummary, 27845 editVisibility: layout?.editVisibility ?? "on-hover" 27846 }; 27847 } else if (layout?.type === "card") { 27848 if (layout.withHeader === false) { 27849 normalizedLayout = { 27850 type: "card", 27851 withHeader: false, 27852 isOpened: true, 27853 summary: [], 27854 isCollapsible: false 27855 }; 27856 } else { 27857 const summary = layout.summary ?? []; 27858 normalizedLayout = { 27859 type: "card", 27860 withHeader: true, 27861 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true, 27862 summary: normalizeCardSummaryField(summary), 27863 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible 27864 }; 27865 } 27866 } else if (layout?.type === "row") { 27867 normalizedLayout = { 27868 type: "row", 27869 alignment: layout?.alignment ?? "center", 27870 styles: layout?.styles ?? {} 27871 }; 27872 } else if (layout?.type === "details") { 27873 normalizedLayout = { 27874 type: "details", 27875 summary: layout?.summary ?? "" 27876 }; 27877 } 27878 return normalizedLayout; 27879 } 27880 function normalizeForm(form) { 27881 const normalizedFormLayout = normalizeLayout(form?.layout); 27882 const normalizedFields = (form.fields ?? []).map( 27883 (field) => { 27884 if (typeof field === "string") { 27885 return { 27886 id: field, 27887 layout: normalizedFormLayout 27888 }; 27889 } 27890 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout; 27891 return { 27892 id: field.id, 27893 layout: fieldLayout, 27894 ...!!field.label && { label: field.label }, 27895 ...!!field.description && { 27896 description: field.description 27897 }, 27898 ..."children" in field && Array.isArray(field.children) && { 27899 children: normalizeForm({ 27900 fields: field.children, 27901 layout: DEFAULT_LAYOUT 27902 }).fields 27903 } 27904 }; 27905 } 27906 ); 27907 return { 27908 layout: normalizedFormLayout, 27909 fields: normalizedFields 27910 }; 27911 } 27912 var normalize_form_default = normalizeForm; 27913 27914 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs 27915 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1); 27916 function Header4({ title }) { 27917 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 27918 Stack, 27919 { 27920 direction: "column", 27921 className: "dataforms-layouts-regular__header", 27922 gap: "lg", 27923 children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components47.__experimentalHeading, { level: 2, size: 13, children: title }) }) 27924 } 27925 ); 27926 } 27927 function FormRegularField({ 27928 data, 27929 field, 27930 onChange, 27931 hideLabelFromVision, 27932 markWhenOptional, 27933 validity 27934 }) { 27935 const { fields: fields2 } = (0, import_element89.useContext)(dataform_context_default); 27936 const layout = field.layout; 27937 const form = (0, import_element89.useMemo)( 27938 () => ({ 27939 layout: DEFAULT_LAYOUT, 27940 fields: !!field.children ? field.children : [] 27941 }), 27942 [field] 27943 ); 27944 if (!!field.children) { 27945 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [ 27946 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Header4, { title: field.label }), 27947 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 27948 DataFormLayout, 27949 { 27950 data, 27951 form, 27952 onChange, 27953 validity: validity?.children 27954 } 27955 ) 27956 ] }); 27957 } 27958 const labelPosition = layout.labelPosition; 27959 const fieldDefinition = fields2.find( 27960 (fieldDef) => fieldDef.id === field.id 27961 ); 27962 if (!fieldDefinition || !fieldDefinition.Edit) { 27963 return null; 27964 } 27965 if (labelPosition === "side") { 27966 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)( 27967 Stack, 27968 { 27969 direction: "row", 27970 className: "dataforms-layouts-regular__field", 27971 gap: "sm", 27972 children: [ 27973 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 27974 "div", 27975 { 27976 className: clsx_default( 27977 "dataforms-layouts-regular__field-label", 27978 `dataforms-layouts-regular__field-label--label-position-$labelPosition}` 27979 ), 27980 children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components47.BaseControl.VisualLabel, { children: fieldDefinition.label }) 27981 } 27982 ), 27983 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 27984 fieldDefinition.render, 27985 { 27986 item: data, 27987 field: fieldDefinition 27988 } 27989 ) : /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 27990 fieldDefinition.Edit, 27991 { 27992 data, 27993 field: fieldDefinition, 27994 onChange, 27995 hideLabelFromVision: true, 27996 markWhenOptional, 27997 validity 27998 }, 27999 fieldDefinition.id 28000 ) }) 28001 ] 28002 } 28003 ); 28004 } 28005 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_jsx_runtime130.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [ 28006 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components47.BaseControl.VisualLabel, { children: fieldDefinition.label }), 28007 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 28008 fieldDefinition.render, 28009 { 28010 item: data, 28011 field: fieldDefinition 28012 } 28013 ) 28014 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 28015 fieldDefinition.Edit, 28016 { 28017 data, 28018 field: fieldDefinition, 28019 onChange, 28020 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision, 28021 markWhenOptional, 28022 validity 28023 } 28024 ) }); 28025 } 28026 28027 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs 28028 var import_deepmerge2 = __toESM(require_cjs(), 1); 28029 var import_components50 = __toESM(require_components(), 1); 28030 var import_element94 = __toESM(require_element(), 1); 28031 var import_compose14 = __toESM(require_compose(), 1); 28032 28033 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs 28034 var import_components49 = __toESM(require_components(), 1); 28035 var import_i18n44 = __toESM(require_i18n(), 1); 28036 var import_compose13 = __toESM(require_compose(), 1); 28037 var import_element90 = __toESM(require_element(), 1); 28038 28039 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs 28040 function getLabelClassName(labelPosition, showError) { 28041 return clsx_default( 28042 "dataforms-layouts-panel__field-label", 28043 `dataforms-layouts-panel__field-label--label-position-$labelPosition}`, 28044 { "has-error": showError } 28045 ); 28046 } 28047 var get_label_classname_default = getLabelClassName; 28048 28049 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs 28050 var import_components48 = __toESM(require_components(), 1); 28051 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1); 28052 function getLabelContent(showError, errorMessage, fieldLabel) { 28053 return showError ? /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(tooltip_exports.Root, { children: [ 28054 /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 28055 tooltip_exports.Trigger, 28056 { 28057 render: /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [ 28058 /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(import_components48.Icon, { icon: error_default, size: 16 }), 28059 /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(VisuallyHidden, { children: [ 28060 errorMessage, 28061 ": " 28062 ] }), 28063 fieldLabel 28064 ] }) 28065 } 28066 ), 28067 /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(tooltip_exports.Popup, { children: errorMessage }) 28068 ] }) : fieldLabel; 28069 } 28070 var get_label_content_default = getLabelContent; 28071 28072 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs 28073 function getFirstValidationError(validity) { 28074 if (!validity) { 28075 return void 0; 28076 } 28077 const validityRules = Object.keys(validity).filter( 28078 (key) => key !== "children" 28079 ); 28080 for (const key of validityRules) { 28081 const rule = validity[key]; 28082 if (rule === void 0) { 28083 continue; 28084 } 28085 if (rule.type === "invalid") { 28086 if (rule.message) { 28087 return rule.message; 28088 } 28089 if (key === "required") { 28090 return "A required field is empty"; 28091 } 28092 return "Unidentified validation error"; 28093 } 28094 } 28095 if (validity.children) { 28096 for (const childValidity of Object.values(validity.children)) { 28097 const childError = getFirstValidationError(childValidity); 28098 if (childError) { 28099 return childError; 28100 } 28101 } 28102 } 28103 return void 0; 28104 } 28105 var get_first_validation_error_default = getFirstValidationError; 28106 28107 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs 28108 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1); 28109 function SummaryButton({ 28110 data, 28111 field, 28112 fieldLabel, 28113 summaryFields, 28114 validity, 28115 touched, 28116 disabled: disabled2, 28117 onClick, 28118 "aria-expanded": ariaExpanded 28119 }) { 28120 const { labelPosition, editVisibility } = field.layout; 28121 const errorMessage = get_first_validation_error_default(validity); 28122 const showError = touched && !!errorMessage; 28123 const labelClassName = get_label_classname_default(labelPosition, showError); 28124 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel); 28125 const className = clsx_default( 28126 "dataforms-layouts-panel__field-trigger", 28127 `dataforms-layouts-panel__field-trigger--label-$labelPosition}`, 28128 { 28129 "is-disabled": disabled2, 28130 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always" 28131 } 28132 ); 28133 const controlId = (0, import_compose13.useInstanceId)( 28134 SummaryButton, 28135 "dataforms-layouts-panel__field-control" 28136 ); 28137 const ariaLabel = showError ? (0, import_i18n44.sprintf)( 28138 // translators: %s: Field name. 28139 (0, import_i18n44._x)("Edit %s (has errors)", "field"), 28140 fieldLabel || "" 28141 ) : (0, import_i18n44.sprintf)( 28142 // translators: %s: Field name. 28143 (0, import_i18n44._x)("Edit %s", "field"), 28144 fieldLabel || "" 28145 ); 28146 const rowRef = (0, import_element90.useRef)(null); 28147 const handleRowClick = () => { 28148 const selection = rowRef.current?.ownerDocument.defaultView?.getSelection(); 28149 if (selection && selection.toString().length > 0) { 28150 return; 28151 } 28152 onClick(); 28153 }; 28154 const handleKeyDown = (event) => { 28155 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) { 28156 event.preventDefault(); 28157 onClick(); 28158 } 28159 }; 28160 return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)( 28161 "div", 28162 { 28163 ref: rowRef, 28164 className, 28165 onClick: !disabled2 ? handleRowClick : void 0, 28166 onKeyDown: !disabled2 ? handleKeyDown : void 0, 28167 children: [ 28168 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: labelClassName, children: labelContent }), 28169 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(tooltip_exports.Root, { children: [ 28170 /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 28171 tooltip_exports.Trigger, 28172 { 28173 render: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 28174 "span", 28175 { 28176 className: "dataforms-layouts-panel__field-label-error-content", 28177 role: "img", 28178 "aria-label": errorMessage, 28179 children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_components49.Icon, { icon: error_default, size: 16 }) 28180 } 28181 ) 28182 } 28183 ), 28184 /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(tooltip_exports.Popup, { children: errorMessage }) 28185 ] }), 28186 /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 28187 "span", 28188 { 28189 id: `$controlId}`, 28190 className: "dataforms-layouts-panel__field-control", 28191 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 28192 "span", 28193 { 28194 style: { 28195 display: "flex", 28196 flexDirection: "column", 28197 alignItems: "flex-start", 28198 width: "100%", 28199 gap: "2px" 28200 }, 28201 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 28202 "span", 28203 { 28204 style: { width: "100%" }, 28205 children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 28206 summaryField.render, 28207 { 28208 item: data, 28209 field: summaryField 28210 } 28211 ) 28212 }, 28213 summaryField.id 28214 )) 28215 } 28216 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 28217 summaryField.render, 28218 { 28219 item: data, 28220 field: summaryField 28221 }, 28222 summaryField.id 28223 )) 28224 } 28225 ), 28226 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 28227 import_components49.Button, 28228 { 28229 className: "dataforms-layouts-panel__field-trigger-icon", 28230 label: ariaLabel, 28231 icon: pencil_default, 28232 size: "small", 28233 "aria-expanded": ariaExpanded, 28234 "aria-haspopup": "dialog", 28235 "aria-describedby": `$controlId}` 28236 } 28237 ) 28238 ] 28239 } 28240 ); 28241 } 28242 28243 // packages/dataviews/build-module/hooks/use-form-validity.mjs 28244 var import_deepmerge = __toESM(require_cjs(), 1); 28245 var import_es62 = __toESM(require_es6(), 1); 28246 var import_element91 = __toESM(require_element(), 1); 28247 var import_i18n45 = __toESM(require_i18n(), 1); 28248 function isFormValid(formValidity) { 28249 if (!formValidity) { 28250 return true; 28251 } 28252 return Object.values(formValidity).every((fieldValidation) => { 28253 return Object.entries(fieldValidation).every( 28254 ([key, validation]) => { 28255 if (key === "children" && validation && typeof validation === "object") { 28256 return isFormValid(validation); 28257 } 28258 return validation.type !== "invalid" && validation.type !== "validating"; 28259 } 28260 ); 28261 }); 28262 } 28263 function getFormFieldsToValidate(form, fields2) { 28264 const normalizedForm = normalize_form_default(form); 28265 if (normalizedForm.fields.length === 0) { 28266 return []; 28267 } 28268 const fieldsMap = /* @__PURE__ */ new Map(); 28269 fields2.forEach((field) => { 28270 fieldsMap.set(field.id, field); 28271 }); 28272 function processFormField(formField) { 28273 if ("children" in formField && Array.isArray(formField.children)) { 28274 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null); 28275 if (processedChildren.length === 0) { 28276 return null; 28277 } 28278 const fieldDef2 = fieldsMap.get(formField.id); 28279 if (fieldDef2) { 28280 const [normalizedField2] = normalizeFields([ 28281 fieldDef2 28282 ]); 28283 return { 28284 id: formField.id, 28285 children: processedChildren, 28286 field: normalizedField2 28287 }; 28288 } 28289 return { 28290 id: formField.id, 28291 children: processedChildren 28292 }; 28293 } 28294 const fieldDef = fieldsMap.get(formField.id); 28295 if (!fieldDef) { 28296 return null; 28297 } 28298 const [normalizedField] = normalizeFields([fieldDef]); 28299 return { 28300 id: formField.id, 28301 children: [], 28302 field: normalizedField 28303 }; 28304 } 28305 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null); 28306 return toValidate; 28307 } 28308 function setValidityAtPath(formValidity, fieldValidity, path) { 28309 if (!formValidity) { 28310 formValidity = {}; 28311 } 28312 if (path.length === 0) { 28313 return formValidity; 28314 } 28315 const result = { ...formValidity }; 28316 let current = result; 28317 for (let i2 = 0; i2 < path.length - 1; i2++) { 28318 const segment = path[i2]; 28319 if (!current[segment]) { 28320 current[segment] = {}; 28321 } 28322 current[segment] = { ...current[segment] }; 28323 current = current[segment]; 28324 } 28325 const finalKey = path[path.length - 1]; 28326 current[finalKey] = { 28327 ...current[finalKey] || {}, 28328 ...fieldValidity 28329 }; 28330 return result; 28331 } 28332 function removeValidationProperty(formValidity, path, property) { 28333 if (!formValidity || path.length === 0) { 28334 return formValidity; 28335 } 28336 const result = { ...formValidity }; 28337 let current = result; 28338 for (let i2 = 0; i2 < path.length - 1; i2++) { 28339 const segment = path[i2]; 28340 if (!current[segment]) { 28341 return formValidity; 28342 } 28343 current[segment] = { ...current[segment] }; 28344 current = current[segment]; 28345 } 28346 const finalKey = path[path.length - 1]; 28347 if (!current[finalKey]) { 28348 return formValidity; 28349 } 28350 const fieldValidity = { ...current[finalKey] }; 28351 delete fieldValidity[property]; 28352 if (Object.keys(fieldValidity).length === 0) { 28353 delete current[finalKey]; 28354 } else { 28355 current[finalKey] = fieldValidity; 28356 } 28357 if (Object.keys(result).length === 0) { 28358 return void 0; 28359 } 28360 return result; 28361 } 28362 function handleElementsValidationAsync(promise, formField, promiseHandler) { 28363 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler; 28364 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1; 28365 elementsCounterRef.current[formField.id] = currentToken; 28366 promise.then((result) => { 28367 if (currentToken !== elementsCounterRef.current[formField.id]) { 28368 return; 28369 } 28370 if (!Array.isArray(result)) { 28371 setFormValidity((prev) => { 28372 const newFormValidity = setValidityAtPath( 28373 prev, 28374 { 28375 elements: { 28376 type: "invalid", 28377 message: (0, import_i18n45.__)("Could not validate elements.") 28378 } 28379 }, 28380 [...path, formField.id] 28381 ); 28382 return newFormValidity; 28383 }); 28384 return; 28385 } 28386 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, { 28387 ...formField.field, 28388 elements: result 28389 })) { 28390 setFormValidity((prev) => { 28391 const newFormValidity = setValidityAtPath( 28392 prev, 28393 { 28394 elements: { 28395 type: "invalid", 28396 message: (0, import_i18n45.__)( 28397 "Value must be one of the elements." 28398 ) 28399 } 28400 }, 28401 [...path, formField.id] 28402 ); 28403 return newFormValidity; 28404 }); 28405 } else { 28406 setFormValidity((prev) => { 28407 return removeValidationProperty( 28408 prev, 28409 [...path, formField.id], 28410 "elements" 28411 ); 28412 }); 28413 } 28414 }).catch((error2) => { 28415 if (currentToken !== elementsCounterRef.current[formField.id]) { 28416 return; 28417 } 28418 let errorMessage; 28419 if (error2 instanceof Error) { 28420 errorMessage = error2.message; 28421 } else { 28422 errorMessage = String(error2) || (0, import_i18n45.__)( 28423 "Unknown error when running elements validation asynchronously." 28424 ); 28425 } 28426 setFormValidity((prev) => { 28427 const newFormValidity = setValidityAtPath( 28428 prev, 28429 { 28430 elements: { 28431 type: "invalid", 28432 message: errorMessage 28433 } 28434 }, 28435 [...path, formField.id] 28436 ); 28437 return newFormValidity; 28438 }); 28439 }); 28440 } 28441 function handleCustomValidationAsync(promise, formField, promiseHandler) { 28442 const { customCounterRef, setFormValidity, path } = promiseHandler; 28443 const currentToken = (customCounterRef.current[formField.id] || 0) + 1; 28444 customCounterRef.current[formField.id] = currentToken; 28445 promise.then((result) => { 28446 if (currentToken !== customCounterRef.current[formField.id]) { 28447 return; 28448 } 28449 if (result === null) { 28450 setFormValidity((prev) => { 28451 return removeValidationProperty( 28452 prev, 28453 [...path, formField.id], 28454 "custom" 28455 ); 28456 }); 28457 return; 28458 } 28459 if (typeof result === "string") { 28460 setFormValidity((prev) => { 28461 const newFormValidity = setValidityAtPath( 28462 prev, 28463 { 28464 custom: { 28465 type: "invalid", 28466 message: result 28467 } 28468 }, 28469 [...path, formField.id] 28470 ); 28471 return newFormValidity; 28472 }); 28473 return; 28474 } 28475 setFormValidity((prev) => { 28476 const newFormValidity = setValidityAtPath( 28477 prev, 28478 { 28479 custom: { 28480 type: "invalid", 28481 message: (0, import_i18n45.__)("Validation could not be processed.") 28482 } 28483 }, 28484 [...path, formField.id] 28485 ); 28486 return newFormValidity; 28487 }); 28488 }).catch((error2) => { 28489 if (currentToken !== customCounterRef.current[formField.id]) { 28490 return; 28491 } 28492 let errorMessage; 28493 if (error2 instanceof Error) { 28494 errorMessage = error2.message; 28495 } else { 28496 errorMessage = String(error2) || (0, import_i18n45.__)( 28497 "Unknown error when running custom validation asynchronously." 28498 ); 28499 } 28500 setFormValidity((prev) => { 28501 const newFormValidity = setValidityAtPath( 28502 prev, 28503 { 28504 custom: { 28505 type: "invalid", 28506 message: errorMessage 28507 } 28508 }, 28509 [...path, formField.id] 28510 ); 28511 return newFormValidity; 28512 }); 28513 }); 28514 } 28515 function validateFormField(item, formField, promiseHandler) { 28516 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) { 28517 return { 28518 required: { type: "invalid" } 28519 }; 28520 } 28521 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) { 28522 return { 28523 pattern: { 28524 type: "invalid", 28525 message: (0, import_i18n45.__)("Value does not match the required pattern.") 28526 } 28527 }; 28528 } 28529 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) { 28530 return { 28531 min: { 28532 type: "invalid", 28533 message: (0, import_i18n45.__)("Value is below the minimum.") 28534 } 28535 }; 28536 } 28537 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) { 28538 return { 28539 max: { 28540 type: "invalid", 28541 message: (0, import_i18n45.__)("Value is above the maximum.") 28542 } 28543 }; 28544 } 28545 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) { 28546 return { 28547 minLength: { 28548 type: "invalid", 28549 message: (0, import_i18n45.__)("Value is too short.") 28550 } 28551 }; 28552 } 28553 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) { 28554 return { 28555 maxLength: { 28556 type: "invalid", 28557 message: (0, import_i18n45.__)("Value is too long.") 28558 } 28559 }; 28560 } 28561 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) { 28562 return { 28563 elements: { 28564 type: "invalid", 28565 message: (0, import_i18n45.__)("Value must be one of the elements.") 28566 } 28567 }; 28568 } 28569 let customError; 28570 if (!!formField.field && formField.field.isValid.custom) { 28571 try { 28572 const value = formField.field.getValue({ item }); 28573 customError = formField.field.isValid.custom( 28574 (0, import_deepmerge.default)( 28575 item, 28576 formField.field.setValue({ 28577 item, 28578 value 28579 }) 28580 ), 28581 formField.field 28582 ); 28583 } catch (error2) { 28584 let errorMessage; 28585 if (error2 instanceof Error) { 28586 errorMessage = error2.message; 28587 } else { 28588 errorMessage = String(error2) || (0, import_i18n45.__)("Unknown error when running custom validation."); 28589 } 28590 return { 28591 custom: { 28592 type: "invalid", 28593 message: errorMessage 28594 } 28595 }; 28596 } 28597 } 28598 if (typeof customError === "string") { 28599 return { 28600 custom: { 28601 type: "invalid", 28602 message: customError 28603 } 28604 }; 28605 } 28606 const fieldValidity = {}; 28607 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") { 28608 handleElementsValidationAsync( 28609 formField.field.getElements(), 28610 formField, 28611 promiseHandler 28612 ); 28613 fieldValidity.elements = { 28614 type: "validating", 28615 message: (0, import_i18n45.__)("Validating\u2026") 28616 }; 28617 } 28618 if (customError instanceof Promise) { 28619 handleCustomValidationAsync(customError, formField, promiseHandler); 28620 fieldValidity.custom = { 28621 type: "validating", 28622 message: (0, import_i18n45.__)("Validating\u2026") 28623 }; 28624 } 28625 if (Object.keys(fieldValidity).length > 0) { 28626 return fieldValidity; 28627 } 28628 if (formField.children.length > 0) { 28629 const result = {}; 28630 formField.children.forEach((child) => { 28631 result[child.id] = validateFormField(item, child, { 28632 ...promiseHandler, 28633 path: [...promiseHandler.path, formField.id, "children"] 28634 }); 28635 }); 28636 const filteredResult = {}; 28637 Object.entries(result).forEach(([key, value]) => { 28638 if (value !== void 0) { 28639 filteredResult[key] = value; 28640 } 28641 }); 28642 if (Object.keys(filteredResult).length === 0) { 28643 return void 0; 28644 } 28645 return { 28646 children: filteredResult 28647 }; 28648 } 28649 return void 0; 28650 } 28651 function getFormFieldValue(formField, item) { 28652 const fieldValue = formField?.field?.getValue({ item }); 28653 if (formField.children.length === 0) { 28654 return fieldValue; 28655 } 28656 const childrenValues = formField.children.map( 28657 (child) => getFormFieldValue(child, item) 28658 ); 28659 if (!childrenValues) { 28660 return fieldValue; 28661 } 28662 return { 28663 value: fieldValue, 28664 children: childrenValues 28665 }; 28666 } 28667 function useFormValidity(item, fields2, form) { 28668 const [formValidity, setFormValidity] = (0, import_element91.useState)(); 28669 const customCounterRef = (0, import_element91.useRef)({}); 28670 const elementsCounterRef = (0, import_element91.useRef)({}); 28671 const previousValuesRef = (0, import_element91.useRef)({}); 28672 const validate = (0, import_element91.useCallback)(() => { 28673 const promiseHandler = { 28674 customCounterRef, 28675 elementsCounterRef, 28676 setFormValidity, 28677 path: [], 28678 item 28679 }; 28680 const formFieldsToValidate = getFormFieldsToValidate(form, fields2); 28681 if (formFieldsToValidate.length === 0) { 28682 setFormValidity(void 0); 28683 return; 28684 } 28685 const newFormValidity = {}; 28686 const untouchedFields = []; 28687 formFieldsToValidate.forEach((formField) => { 28688 const value = getFormFieldValue(formField, item); 28689 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)( 28690 previousValuesRef.current[formField.id], 28691 value 28692 )) { 28693 untouchedFields.push(formField.id); 28694 return; 28695 } 28696 previousValuesRef.current[formField.id] = value; 28697 const fieldValidity = validateFormField( 28698 item, 28699 formField, 28700 promiseHandler 28701 ); 28702 if (fieldValidity !== void 0) { 28703 newFormValidity[formField.id] = fieldValidity; 28704 } 28705 }); 28706 setFormValidity((existingFormValidity) => { 28707 let validity = { 28708 ...existingFormValidity, 28709 ...newFormValidity 28710 }; 28711 const fieldsToKeep = [ 28712 ...untouchedFields, 28713 ...Object.keys(newFormValidity) 28714 ]; 28715 Object.keys(validity).forEach((key) => { 28716 if (validity && !fieldsToKeep.includes(key)) { 28717 delete validity[key]; 28718 } 28719 }); 28720 if (Object.keys(validity).length === 0) { 28721 validity = void 0; 28722 } 28723 const areEqual = (0, import_es62.default)(existingFormValidity, validity); 28724 if (areEqual) { 28725 return existingFormValidity; 28726 } 28727 return validity; 28728 }); 28729 }, [item, fields2, form]); 28730 (0, import_element91.useEffect)(() => { 28731 validate(); 28732 }, [validate]); 28733 return { 28734 validity: formValidity, 28735 isValid: isFormValid(formValidity) 28736 }; 28737 } 28738 var use_form_validity_default = useFormValidity; 28739 28740 // packages/dataviews/build-module/hooks/use-report-validity.mjs 28741 var import_element92 = __toESM(require_element(), 1); 28742 function useReportValidity(ref, shouldReport) { 28743 (0, import_element92.useEffect)(() => { 28744 if (shouldReport && ref.current) { 28745 const inputs = ref.current.querySelectorAll( 28746 "input, textarea, select" 28747 ); 28748 inputs.forEach((input) => { 28749 input.reportValidity(); 28750 }); 28751 } 28752 }, [shouldReport, ref]); 28753 } 28754 28755 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs 28756 var import_element93 = __toESM(require_element(), 1); 28757 28758 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs 28759 function extractSummaryIds(summary) { 28760 if (Array.isArray(summary)) { 28761 return summary.map( 28762 (item) => typeof item === "string" ? item : item.id 28763 ); 28764 } 28765 return []; 28766 } 28767 var getSummaryFields = (summaryField, fields2) => { 28768 if (Array.isArray(summaryField) && summaryField.length > 0) { 28769 const summaryIds = extractSummaryIds(summaryField); 28770 return summaryIds.map( 28771 (summaryId) => fields2.find((_field) => _field.id === summaryId) 28772 ).filter((_field) => _field !== void 0); 28773 } 28774 return []; 28775 }; 28776 28777 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs 28778 var getFieldDefinition = (field, fields2) => { 28779 const fieldDefinition = fields2.find((_field) => _field.id === field.id); 28780 if (!fieldDefinition) { 28781 return fields2.find((_field) => { 28782 if (!!field.children) { 28783 const simpleChildren = field.children.filter( 28784 (child) => !child.children 28785 ); 28786 if (simpleChildren.length === 0) { 28787 return false; 28788 } 28789 return _field.id === simpleChildren[0].id; 28790 } 28791 return _field.id === field.id; 28792 }); 28793 } 28794 return fieldDefinition; 28795 }; 28796 function useFieldFromFormField(field) { 28797 const { fields: fields2 } = (0, import_element93.useContext)(dataform_context_default); 28798 const layout = field.layout; 28799 const summaryFields = getSummaryFields(layout.summary, fields2); 28800 const fieldDefinition = getFieldDefinition(field, fields2); 28801 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label; 28802 if (summaryFields.length === 0) { 28803 return { 28804 summaryFields: fieldDefinition ? [fieldDefinition] : [], 28805 fieldDefinition, 28806 fieldLabel 28807 }; 28808 } 28809 return { 28810 summaryFields, 28811 fieldDefinition, 28812 fieldLabel 28813 }; 28814 } 28815 var use_field_from_form_field_default = useFieldFromFormField; 28816 28817 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs 28818 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1); 28819 function ModalContent({ 28820 data, 28821 field, 28822 onChange, 28823 fieldLabel, 28824 onClose, 28825 touched 28826 }) { 28827 const { openAs } = field.layout; 28828 const { applyLabel, cancelLabel } = openAs; 28829 const { fields: fields2 } = (0, import_element94.useContext)(dataform_context_default); 28830 const [changes, setChanges] = (0, import_element94.useState)({}); 28831 const modalData = (0, import_element94.useMemo)(() => { 28832 return (0, import_deepmerge2.default)(data, changes, { 28833 arrayMerge: (target, source) => source 28834 }); 28835 }, [data, changes]); 28836 const form = (0, import_element94.useMemo)( 28837 () => ({ 28838 layout: DEFAULT_LAYOUT, 28839 fields: !!field.children ? field.children : ( 28840 // If not explicit children return the field id itself. 28841 [{ id: field.id, layout: DEFAULT_LAYOUT }] 28842 ) 28843 }), 28844 [field] 28845 ); 28846 const fieldsAsFieldType = fields2.map((f2) => ({ 28847 ...f2, 28848 Edit: f2.Edit === null ? void 0 : f2.Edit, 28849 isValid: { 28850 required: f2.isValid.required?.constraint, 28851 elements: f2.isValid.elements?.constraint, 28852 min: f2.isValid.min?.constraint, 28853 max: f2.isValid.max?.constraint, 28854 pattern: f2.isValid.pattern?.constraint, 28855 minLength: f2.isValid.minLength?.constraint, 28856 maxLength: f2.isValid.maxLength?.constraint 28857 } 28858 })); 28859 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form); 28860 const onApply = () => { 28861 onChange(changes); 28862 onClose(); 28863 }; 28864 const handleOnChange = (newValue) => { 28865 setChanges( 28866 (prev) => (0, import_deepmerge2.default)(prev, newValue, { 28867 arrayMerge: (target, source) => source 28868 }) 28869 ); 28870 }; 28871 const focusOnMountRef = (0, import_compose14.useFocusOnMount)("firstInputElement"); 28872 const contentRef = (0, import_element94.useRef)(null); 28873 const mergedRef = (0, import_compose14.useMergeRefs)([focusOnMountRef, contentRef]); 28874 useReportValidity(contentRef, touched); 28875 return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)( 28876 import_components50.Modal, 28877 { 28878 className: "dataforms-layouts-panel__modal", 28879 onRequestClose: onClose, 28880 isFullScreen: false, 28881 title: fieldLabel, 28882 size: "medium", 28883 children: [ 28884 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)( 28885 DataFormLayout, 28886 { 28887 data: modalData, 28888 form, 28889 onChange: handleOnChange, 28890 validity, 28891 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)( 28892 FieldLayout, 28893 { 28894 data: modalData, 28895 field: childField, 28896 onChange: handleOnChange, 28897 hideLabelFromVision: form.fields.length < 2, 28898 markWhenOptional, 28899 validity: childFieldValidity 28900 }, 28901 childField.id 28902 ) 28903 } 28904 ) }), 28905 /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)( 28906 Stack, 28907 { 28908 direction: "row", 28909 className: "dataforms-layouts-panel__modal-footer", 28910 gap: "md", 28911 children: [ 28912 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_components50.__experimentalSpacer, { style: { flex: 1 } }), 28913 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)( 28914 import_components50.Button, 28915 { 28916 variant: "tertiary", 28917 onClick: onClose, 28918 __next40pxDefaultSize: true, 28919 children: cancelLabel 28920 } 28921 ), 28922 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)( 28923 import_components50.Button, 28924 { 28925 variant: "primary", 28926 onClick: onApply, 28927 __next40pxDefaultSize: true, 28928 children: applyLabel 28929 } 28930 ) 28931 ] 28932 } 28933 ) 28934 ] 28935 } 28936 ); 28937 } 28938 function PanelModal({ 28939 data, 28940 field, 28941 onChange, 28942 validity 28943 }) { 28944 const [touched, setTouched] = (0, import_element94.useState)(false); 28945 const [isOpen, setIsOpen] = (0, import_element94.useState)(false); 28946 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field); 28947 if (!fieldDefinition) { 28948 return null; 28949 } 28950 const handleClose = () => { 28951 setIsOpen(false); 28952 setTouched(true); 28953 }; 28954 return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(import_jsx_runtime133.Fragment, { children: [ 28955 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)( 28956 SummaryButton, 28957 { 28958 data, 28959 field, 28960 fieldLabel, 28961 summaryFields, 28962 validity, 28963 touched, 28964 disabled: fieldDefinition.readOnly === true, 28965 onClick: () => setIsOpen(true), 28966 "aria-expanded": isOpen 28967 } 28968 ), 28969 isOpen && /* @__PURE__ */ (0, import_jsx_runtime133.jsx)( 28970 ModalContent, 28971 { 28972 data, 28973 field, 28974 onChange, 28975 fieldLabel: fieldLabel ?? "", 28976 onClose: handleClose, 28977 touched 28978 } 28979 ) 28980 ] }); 28981 } 28982 var modal_default = PanelModal; 28983 28984 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs 28985 var import_components51 = __toESM(require_components(), 1); 28986 var import_i18n46 = __toESM(require_i18n(), 1); 28987 var import_element95 = __toESM(require_element(), 1); 28988 var import_compose15 = __toESM(require_compose(), 1); 28989 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1); 28990 function DropdownHeader({ 28991 title, 28992 onClose 28993 }) { 28994 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 28995 Stack, 28996 { 28997 direction: "column", 28998 className: "dataforms-layouts-panel__dropdown-header", 28999 gap: "lg", 29000 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [ 29001 title && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_components51.__experimentalHeading, { level: 2, size: 13, children: title }), 29002 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_components51.__experimentalSpacer, { style: { flex: 1 } }), 29003 onClose && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 29004 import_components51.Button, 29005 { 29006 label: (0, import_i18n46.__)("Close"), 29007 icon: close_small_default, 29008 onClick: onClose, 29009 size: "small" 29010 } 29011 ) 29012 ] }) 29013 } 29014 ); 29015 } 29016 function DropdownContentWithValidation({ 29017 touched, 29018 children 29019 }) { 29020 const ref = (0, import_element95.useRef)(null); 29021 useReportValidity(ref, touched); 29022 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("div", { ref, children }); 29023 } 29024 function PanelDropdown({ 29025 data, 29026 field, 29027 onChange, 29028 validity 29029 }) { 29030 const [touched, setTouched] = (0, import_element95.useState)(false); 29031 const [popoverAnchor, setPopoverAnchor] = (0, import_element95.useState)( 29032 null 29033 ); 29034 const popoverProps = (0, import_element95.useMemo)( 29035 () => ({ 29036 // Anchor the popover to the middle of the entire row so that it doesn't 29037 // move around when the label changes. 29038 anchor: popoverAnchor, 29039 placement: "left-start", 29040 offset: 36, 29041 shift: true 29042 }), 29043 [popoverAnchor] 29044 ); 29045 const [dialogRef, dialogProps] = (0, import_compose15.__experimentalUseDialog)({ 29046 focusOnMount: "firstInputElement" 29047 }); 29048 const form = (0, import_element95.useMemo)( 29049 () => ({ 29050 layout: DEFAULT_LAYOUT, 29051 fields: !!field.children ? field.children : ( 29052 // If not explicit children return the field id itself. 29053 [{ id: field.id, layout: DEFAULT_LAYOUT }] 29054 ) 29055 }), 29056 [field] 29057 ); 29058 const formValidity = (0, import_element95.useMemo)(() => { 29059 if (validity === void 0) { 29060 return void 0; 29061 } 29062 if (!!field.children) { 29063 return validity?.children; 29064 } 29065 return { [field.id]: validity }; 29066 }, [validity, field]); 29067 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field); 29068 if (!fieldDefinition) { 29069 return null; 29070 } 29071 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 29072 "div", 29073 { 29074 ref: setPopoverAnchor, 29075 className: "dataforms-layouts-panel__field-dropdown-anchor", 29076 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 29077 import_components51.Dropdown, 29078 { 29079 contentClassName: "dataforms-layouts-panel__field-dropdown", 29080 popoverProps, 29081 focusOnMount: false, 29082 onToggle: (willOpen) => { 29083 if (!willOpen) { 29084 setTouched(true); 29085 } 29086 }, 29087 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 29088 SummaryButton, 29089 { 29090 data, 29091 field, 29092 fieldLabel, 29093 summaryFields, 29094 validity, 29095 touched, 29096 disabled: fieldDefinition.readOnly === true, 29097 onClick: onToggle, 29098 "aria-expanded": isOpen 29099 } 29100 ), 29101 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [ 29102 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 29103 DropdownHeader, 29104 { 29105 title: fieldLabel, 29106 onClose 29107 } 29108 ), 29109 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 29110 DataFormLayout, 29111 { 29112 data, 29113 form, 29114 onChange, 29115 validity: formValidity, 29116 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 29117 FieldLayout, 29118 { 29119 data, 29120 field: childField, 29121 onChange, 29122 hideLabelFromVision: (form?.fields ?? []).length < 2, 29123 markWhenOptional, 29124 validity: childFieldValidity 29125 }, 29126 childField.id 29127 ) 29128 } 29129 ) 29130 ] }) }) 29131 } 29132 ) 29133 } 29134 ); 29135 } 29136 var dropdown_default = PanelDropdown; 29137 29138 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs 29139 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1); 29140 function FormPanelField({ 29141 data, 29142 field, 29143 onChange, 29144 validity 29145 }) { 29146 const layout = field.layout; 29147 if (layout.openAs.type === "modal") { 29148 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29149 modal_default, 29150 { 29151 data, 29152 field, 29153 onChange, 29154 validity 29155 } 29156 ); 29157 } 29158 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29159 dropdown_default, 29160 { 29161 data, 29162 field, 29163 onChange, 29164 validity 29165 } 29166 ); 29167 } 29168 29169 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs 29170 var import_element96 = __toESM(require_element(), 1); 29171 29172 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs 29173 var import_i18n47 = __toESM(require_i18n(), 1); 29174 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1); 29175 function countInvalidFields(validity) { 29176 if (!validity) { 29177 return 0; 29178 } 29179 let count = 0; 29180 const validityRules = Object.keys(validity).filter( 29181 (key) => key !== "children" 29182 ); 29183 for (const key of validityRules) { 29184 const rule = validity[key]; 29185 if (rule?.type === "invalid") { 29186 count++; 29187 } 29188 } 29189 if (validity.children) { 29190 for (const childValidity of Object.values(validity.children)) { 29191 count += countInvalidFields(childValidity); 29192 } 29193 } 29194 return count; 29195 } 29196 function ValidationBadge({ 29197 validity 29198 }) { 29199 const invalidCount = countInvalidFields(validity); 29200 if (invalidCount === 0) { 29201 return null; 29202 } 29203 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(Badge, { intent: "high", children: (0, import_i18n47.sprintf)( 29204 /* translators: %d: Number of fields that need attention */ 29205 (0, import_i18n47._n)( 29206 "%d field needs attention", 29207 "%d fields need attention", 29208 invalidCount 29209 ), 29210 invalidCount 29211 ) }); 29212 } 29213 29214 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs 29215 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1); 29216 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) { 29217 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) { 29218 return false; 29219 } 29220 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig]; 29221 const fieldConfig = summaryConfigArray.find((config) => { 29222 if (typeof config === "string") { 29223 return config === summaryField.id; 29224 } 29225 if (typeof config === "object" && "id" in config) { 29226 return config.id === summaryField.id; 29227 } 29228 return false; 29229 }); 29230 if (!fieldConfig) { 29231 return false; 29232 } 29233 if (typeof fieldConfig === "string") { 29234 return true; 29235 } 29236 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) { 29237 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen; 29238 } 29239 return true; 29240 } 29241 function HeaderContent({ 29242 data, 29243 fields: fields2, 29244 label, 29245 layout, 29246 isOpen, 29247 touched, 29248 validity 29249 }) { 29250 const summaryFields = getSummaryFields(layout.summary, fields2); 29251 const visibleSummaryFields = summaryFields.filter( 29252 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen) 29253 ); 29254 const hasBadge = touched && layout.isCollapsible; 29255 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader; 29256 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)( 29257 Stack, 29258 { 29259 align: "center", 29260 justify: "space-between", 29261 className: "dataforms-layouts-card__field-header-content", 29262 children: [ 29263 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(card_exports.Title, { children: label }), 29264 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [ 29265 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(ValidationBadge, { validity }), 29266 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 29267 summaryField.render, 29268 { 29269 item: data, 29270 field: summaryField 29271 }, 29272 summaryField.id 29273 )) }) 29274 ] }) 29275 ] 29276 } 29277 ); 29278 } 29279 function BodyContent({ 29280 data, 29281 field, 29282 form, 29283 onChange, 29284 hideLabelFromVision, 29285 markWhenOptional, 29286 validity, 29287 withHeader 29288 }) { 29289 if (field.children) { 29290 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(import_jsx_runtime137.Fragment, { children: [ 29291 field.description && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }), 29292 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 29293 DataFormLayout, 29294 { 29295 data, 29296 form, 29297 onChange, 29298 validity: validity?.children 29299 } 29300 ) 29301 ] }); 29302 } 29303 const SingleFieldLayout = getFormFieldLayout("regular")?.component; 29304 if (!SingleFieldLayout) { 29305 return null; 29306 } 29307 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 29308 SingleFieldLayout, 29309 { 29310 data, 29311 field, 29312 onChange, 29313 hideLabelFromVision: hideLabelFromVision || withHeader, 29314 markWhenOptional, 29315 validity 29316 } 29317 ); 29318 } 29319 function FormCardField({ 29320 data, 29321 field, 29322 onChange, 29323 hideLabelFromVision, 29324 markWhenOptional, 29325 validity 29326 }) { 29327 const { fields: fields2 } = (0, import_element96.useContext)(dataform_context_default); 29328 const layout = field.layout; 29329 const contentRef = (0, import_element96.useRef)(null); 29330 const form = (0, import_element96.useMemo)( 29331 () => ({ 29332 layout: DEFAULT_LAYOUT, 29333 fields: field.children ?? [] 29334 }), 29335 [field] 29336 ); 29337 const { isOpened, isCollapsible } = layout; 29338 const [isOpen, setIsOpen] = (0, import_element96.useState)(isOpened); 29339 const [touched, setTouched] = (0, import_element96.useState)(false); 29340 (0, import_element96.useEffect)(() => { 29341 setIsOpen(isOpened); 29342 }, [isOpened]); 29343 const handleOpenChange = (0, import_element96.useCallback)((open) => { 29344 if (!open) { 29345 setTouched(true); 29346 } 29347 setIsOpen(open); 29348 }, []); 29349 const handleBlur = (0, import_element96.useCallback)(() => { 29350 setTouched(true); 29351 }, []); 29352 useReportValidity( 29353 contentRef, 29354 (isCollapsible ? isOpen : true) && touched 29355 ); 29356 let label = field.label; 29357 let withHeader; 29358 if (field.children) { 29359 withHeader = !!label && layout.withHeader; 29360 } else { 29361 const fieldDefinition = fields2.find( 29362 (fieldDef) => fieldDef.id === field.id 29363 ); 29364 if (!fieldDefinition || !fieldDefinition.Edit) { 29365 return null; 29366 } 29367 label = fieldDefinition.label; 29368 withHeader = !!label && layout.withHeader; 29369 } 29370 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 29371 BodyContent, 29372 { 29373 data, 29374 field, 29375 form, 29376 onChange, 29377 hideLabelFromVision, 29378 markWhenOptional, 29379 validity, 29380 withHeader 29381 } 29382 ); 29383 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 29384 HeaderContent, 29385 { 29386 data, 29387 fields: fields2, 29388 label, 29389 layout, 29390 isOpen: isCollapsible ? !!isOpen : true, 29391 touched, 29392 validity 29393 } 29394 ); 29395 if (withHeader && isCollapsible) { 29396 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)( 29397 collapsible_card_exports.Root, 29398 { 29399 className: "dataforms-layouts-card__field", 29400 open: isOpen, 29401 onOpenChange: handleOpenChange, 29402 children: [ 29403 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(collapsible_card_exports.Header, { children: headerContent }), 29404 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 29405 collapsible_card_exports.Content, 29406 { 29407 ref: contentRef, 29408 onBlur: handleBlur, 29409 children: bodyContent 29410 } 29411 ) 29412 ] 29413 } 29414 ); 29415 } 29416 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [ 29417 withHeader && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(card_exports.Header, { children: headerContent }), 29418 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent }) 29419 ] }); 29420 } 29421 29422 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs 29423 var import_components52 = __toESM(require_components(), 1); 29424 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1); 29425 function Header5({ title }) { 29426 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 29427 Stack, 29428 { 29429 direction: "column", 29430 className: "dataforms-layouts-row__header", 29431 gap: "lg", 29432 children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_components52.__experimentalHeading, { level: 2, size: 13, children: title }) }) 29433 } 29434 ); 29435 } 29436 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_jsx_runtime138.Fragment, { children }); 29437 function FormRowField({ 29438 data, 29439 field, 29440 onChange, 29441 hideLabelFromVision, 29442 markWhenOptional, 29443 validity 29444 }) { 29445 const layout = field.layout; 29446 if (!!field.children) { 29447 const form = { 29448 layout: DEFAULT_LAYOUT, 29449 fields: field.children 29450 }; 29451 return /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)("div", { className: "dataforms-layouts-row__field", children: [ 29452 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(Header5, { title: field.label }), 29453 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 29454 DataFormLayout, 29455 { 29456 data, 29457 form, 29458 onChange, 29459 validity: validity?.children, 29460 as: EMPTY_WRAPPER, 29461 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 29462 "div", 29463 { 29464 className: "dataforms-layouts-row__field-control", 29465 style: layout.styles[childField.id], 29466 children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 29467 FieldLayout, 29468 { 29469 data, 29470 field: childField, 29471 onChange, 29472 hideLabelFromVision, 29473 markWhenOptional, 29474 validity: childFieldValidity 29475 } 29476 ) 29477 }, 29478 childField.id 29479 ) 29480 } 29481 ) }) 29482 ] }); 29483 } 29484 const RegularLayout = getFormFieldLayout("regular")?.component; 29485 if (!RegularLayout) { 29486 return null; 29487 } 29488 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_jsx_runtime138.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 29489 RegularLayout, 29490 { 29491 data, 29492 field, 29493 onChange, 29494 markWhenOptional, 29495 validity 29496 } 29497 ) }) }); 29498 } 29499 29500 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs 29501 var import_element97 = __toESM(require_element(), 1); 29502 var import_i18n48 = __toESM(require_i18n(), 1); 29503 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1); 29504 function FormDetailsField({ 29505 data, 29506 field, 29507 onChange, 29508 validity 29509 }) { 29510 const { fields: fields2 } = (0, import_element97.useContext)(dataform_context_default); 29511 const detailsRef = (0, import_element97.useRef)(null); 29512 const contentRef = (0, import_element97.useRef)(null); 29513 const [touched, setTouched] = (0, import_element97.useState)(false); 29514 const [isOpen, setIsOpen] = (0, import_element97.useState)(false); 29515 const form = (0, import_element97.useMemo)( 29516 () => ({ 29517 layout: DEFAULT_LAYOUT, 29518 fields: field.children ?? [] 29519 }), 29520 [field] 29521 ); 29522 (0, import_element97.useEffect)(() => { 29523 const details = detailsRef.current; 29524 if (!details) { 29525 return; 29526 } 29527 const handleToggle = () => { 29528 const nowOpen = details.open; 29529 if (!nowOpen) { 29530 setTouched(true); 29531 } 29532 setIsOpen(nowOpen); 29533 }; 29534 details.addEventListener("toggle", handleToggle); 29535 return () => { 29536 details.removeEventListener("toggle", handleToggle); 29537 }; 29538 }, []); 29539 useReportValidity(contentRef, isOpen && touched); 29540 const handleBlur = (0, import_element97.useCallback)(() => { 29541 setTouched(true); 29542 }, []); 29543 if (!field.children) { 29544 return null; 29545 } 29546 const summaryFieldId = field.layout.summary ?? ""; 29547 const summaryField = summaryFieldId ? fields2.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0; 29548 let summaryContent; 29549 if (summaryField && summaryField.render) { 29550 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(summaryField.render, { item: data, field: summaryField }); 29551 } else { 29552 summaryContent = field.label || (0, import_i18n48.__)("More details"); 29553 } 29554 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)( 29555 "details", 29556 { 29557 ref: detailsRef, 29558 className: "dataforms-layouts-details__details", 29559 children: [ 29560 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)( 29561 Stack, 29562 { 29563 direction: "row", 29564 align: "center", 29565 gap: "md", 29566 className: "dataforms-layouts-details__summary-content", 29567 children: [ 29568 summaryContent, 29569 touched && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(ValidationBadge, { validity }) 29570 ] 29571 } 29572 ) }), 29573 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 29574 "div", 29575 { 29576 ref: contentRef, 29577 className: "dataforms-layouts-details__content", 29578 onBlur: handleBlur, 29579 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 29580 DataFormLayout, 29581 { 29582 data, 29583 form, 29584 onChange, 29585 validity: validity?.children 29586 } 29587 ) 29588 } 29589 ) 29590 ] 29591 } 29592 ); 29593 } 29594 29595 // packages/dataviews/build-module/components/dataform-layouts/index.mjs 29596 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1); 29597 var FORM_FIELD_LAYOUTS = [ 29598 { 29599 type: "regular", 29600 component: FormRegularField, 29601 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 29602 Stack, 29603 { 29604 direction: "column", 29605 className: "dataforms-layouts__wrapper", 29606 gap: "lg", 29607 children 29608 } 29609 ) 29610 }, 29611 { 29612 type: "panel", 29613 component: FormPanelField, 29614 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 29615 Stack, 29616 { 29617 direction: "column", 29618 className: "dataforms-layouts__wrapper", 29619 gap: "md", 29620 children 29621 } 29622 ) 29623 }, 29624 { 29625 type: "card", 29626 component: FormCardField, 29627 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 29628 Stack, 29629 { 29630 direction: "column", 29631 className: "dataforms-layouts__wrapper", 29632 gap: "xl", 29633 children 29634 } 29635 ) 29636 }, 29637 { 29638 type: "row", 29639 component: FormRowField, 29640 wrapper: ({ 29641 children, 29642 layout 29643 }) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 29644 Stack, 29645 { 29646 direction: "column", 29647 className: "dataforms-layouts__wrapper", 29648 gap: "lg", 29649 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 29650 Stack, 29651 { 29652 direction: "row", 29653 gap: "lg", 29654 align: layout.alignment, 29655 children 29656 } 29657 ) }) 29658 } 29659 ) 29660 }, 29661 { 29662 type: "details", 29663 component: FormDetailsField 29664 } 29665 ]; 29666 function getFormFieldLayout(type) { 29667 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type); 29668 } 29669 29670 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs 29671 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1); 29672 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children }); 29673 function DataFormLayout({ 29674 data, 29675 form, 29676 onChange, 29677 validity, 29678 children, 29679 as 29680 }) { 29681 const { fields: fieldDefinitions } = (0, import_element98.useContext)(dataform_context_default); 29682 const markWhenOptional = (0, import_element98.useMemo)(() => { 29683 const requiredCount = fieldDefinitions.filter( 29684 (f2) => !!f2.isValid?.required 29685 ).length; 29686 const optionalCount = fieldDefinitions.length - requiredCount; 29687 return requiredCount > optionalCount; 29688 }, [fieldDefinitions]); 29689 function getFieldDefinition2(field) { 29690 return fieldDefinitions.find( 29691 (fieldDefinition) => fieldDefinition.id === field.id 29692 ); 29693 } 29694 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER; 29695 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => { 29696 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component; 29697 if (!FieldLayout) { 29698 return null; 29699 } 29700 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0; 29701 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) { 29702 return null; 29703 } 29704 if (children) { 29705 return children( 29706 FieldLayout, 29707 formField, 29708 validity?.[formField.id], 29709 markWhenOptional 29710 ); 29711 } 29712 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)( 29713 FieldLayout, 29714 { 29715 data, 29716 field: formField, 29717 onChange, 29718 markWhenOptional, 29719 validity: validity?.[formField.id] 29720 }, 29721 formField.id 29722 ); 29723 }) }); 29724 } 29725 29726 // packages/dataviews/build-module/dataform/index.mjs 29727 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1); 29728 function DataForm({ 29729 data, 29730 form, 29731 fields: fields2, 29732 onChange, 29733 validity 29734 }) { 29735 const normalizedForm = (0, import_element99.useMemo)(() => normalize_form_default(form), [form]); 29736 const normalizedFields = (0, import_element99.useMemo)( 29737 () => normalizeFields(fields2), 29738 [fields2] 29739 ); 29740 if (!form.fields) { 29741 return null; 29742 } 29743 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 29744 DataFormLayout, 29745 { 29746 data, 29747 form: normalizedForm, 29748 onChange, 29749 validity 29750 } 29751 ) }); 29752 } 29753 29754 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs 29755 var import_remove_accents2 = __toESM(require_remove_accents(), 1); 29756 var import_deprecated = __toESM(require_deprecated(), 1); 29757 function normalizeSearchInput2(input = "") { 29758 return (0, import_remove_accents2.default)(input.trim().toLowerCase()); 29759 } 29760 var EMPTY_ARRAY7 = []; 29761 function filterSortAndPaginate(data, view, fields2) { 29762 if (!data) { 29763 return { 29764 data: EMPTY_ARRAY7, 29765 paginationInfo: { totalItems: 0, totalPages: 0 } 29766 }; 29767 } 29768 const _fields = normalizeFields(fields2); 29769 let filteredData = [...data]; 29770 if (view.search) { 29771 const normalizedSearch = normalizeSearchInput2(view.search); 29772 filteredData = filteredData.filter((item) => { 29773 return _fields.filter((field) => field.enableGlobalSearch).some((field) => { 29774 const fieldValue = field.getValue({ item }); 29775 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue]; 29776 return values.some( 29777 (value) => normalizeSearchInput2(String(value)).includes( 29778 normalizedSearch 29779 ) 29780 ); 29781 }); 29782 }); 29783 } 29784 if (view.filters && view.filters?.length > 0) { 29785 view.filters.forEach((filter) => { 29786 const field = _fields.find( 29787 (_field) => _field.id === filter.field 29788 ); 29789 if (field) { 29790 if (filter.operator === OPERATOR_IS_NOT_ALL) { 29791 (0, import_deprecated.default)("The 'isNotAll' filter operator", { 29792 since: "7.0", 29793 alternative: "'isNone'" 29794 }); 29795 } 29796 const handler = field.filter[filter.operator]; 29797 if (handler) { 29798 filteredData = filteredData.filter( 29799 (item) => handler(item, field, filter.value) 29800 ); 29801 } 29802 } 29803 }); 29804 } 29805 const sortByField = view.sort?.field ? _fields.find((field) => { 29806 return field.enableSorting !== false && field.id === view.sort?.field; 29807 }) : null; 29808 const groupByField = view.groupBy?.field ? _fields.find((field) => { 29809 return field.enableSorting !== false && field.id === view.groupBy?.field; 29810 }) : null; 29811 if (sortByField || groupByField) { 29812 filteredData.sort((a2, b2) => { 29813 if (groupByField) { 29814 const groupCompare = groupByField.sort( 29815 a2, 29816 b2, 29817 view.groupBy?.direction ?? "asc" 29818 ); 29819 if (groupCompare !== 0) { 29820 return groupCompare; 29821 } 29822 } 29823 if (sortByField) { 29824 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc"); 29825 } 29826 return 0; 29827 }); 29828 } 29829 let totalItems = filteredData.length; 29830 let totalPages = 1; 29831 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) { 29832 const start = view.startPosition - 1; 29833 const end = Math.min(start + view.perPage, totalItems); 29834 filteredData = filteredData?.slice(start, end); 29835 } else if (view.page !== void 0 && view.perPage !== void 0) { 29836 const start = (view.page - 1) * view.perPage; 29837 totalItems = filteredData?.length || 0; 29838 totalPages = Math.ceil(totalItems / view.perPage); 29839 filteredData = filteredData?.slice(start, start + view.perPage); 29840 } 29841 return { 29842 data: filteredData, 29843 paginationInfo: { 29844 totalItems, 29845 totalPages 29846 } 29847 }; 29848 } 29849 29850 // routes/guidelines/components/guideline-accordion-form.tsx 29851 var import_i18n50 = __toESM(require_i18n()); 29852 var import_element100 = __toESM(require_element()); 29853 var import_data8 = __toESM(require_data()); 29854 var import_notices2 = __toESM(require_notices()); 29855 29856 // routes/guidelines/store.ts 29857 var import_data6 = __toESM(require_data()); 29858 var STORE_NAME = "core/guidelines"; 29859 var DEFAULT_STATE = { 29860 id: null, 29861 status: null, 29862 categories: { 29863 site: "", 29864 copy: "", 29865 images: "", 29866 additional: "", 29867 blocks: {} 29868 } 29869 }; 29870 var CATEGORIES = ["site", "copy", "images", "additional", "blocks"]; 29871 var actions = { 29872 setFromResponse(response) { 29873 return { 29874 type: "SET_FROM_RESPONSE", 29875 response 29876 }; 29877 }, 29878 setGuideline(category, value) { 29879 return { 29880 type: "SET_GUIDELINE", 29881 category, 29882 value 29883 }; 29884 }, 29885 setBlockGuideline(blockName, value) { 29886 return { 29887 type: "SET_BLOCK_GUIDELINE", 29888 blockName, 29889 value 29890 }; 29891 } 29892 }; 29893 function parseResponse(response) { 29894 if (!response || typeof response !== "object") { 29895 return {}; 29896 } 29897 const categoriesFromResponse = response.guideline_categories ?? {}; 29898 const result = { 29899 id: response.id ?? null, 29900 status: response.status ?? null, 29901 categories: { 29902 site: "", 29903 copy: "", 29904 images: "", 29905 additional: "", 29906 blocks: {} 29907 } 29908 }; 29909 CATEGORIES.forEach((category) => { 29910 const guidelines = categoriesFromResponse?.[category]?.guidelines; 29911 if (typeof guidelines === "string") { 29912 result.categories[category] = guidelines; 29913 } else if (category === "blocks") { 29914 const blocks = categoriesFromResponse?.blocks ?? {}; 29915 for (const [blockName, blockData] of Object.entries(blocks)) { 29916 result.categories.blocks[blockName] = blockData?.guidelines; 29917 } 29918 } 29919 }); 29920 return result; 29921 } 29922 function reducer(state = DEFAULT_STATE, action) { 29923 switch (action.type) { 29924 case "SET_FROM_RESPONSE": 29925 return { 29926 ...state, 29927 ...parseResponse(action.response) 29928 }; 29929 case "SET_GUIDELINE": 29930 return { 29931 ...state, 29932 categories: { 29933 ...state.categories, 29934 [action.category]: action.value 29935 } 29936 }; 29937 case "SET_BLOCK_GUIDELINE": { 29938 const blocks = { 29939 ...state.categories.blocks, 29940 [action.blockName]: action.value 29941 }; 29942 if (action.value === void 0) { 29943 delete blocks[action.blockName]; 29944 } 29945 return { 29946 ...state, 29947 categories: { 29948 ...state.categories, 29949 blocks 29950 } 29951 }; 29952 } 29953 default: 29954 return state; 29955 } 29956 } 29957 var selectors3 = { 29958 getGuideline(state, category) { 29959 return state.categories[category]; 29960 }, 29961 getAllGuidelines(state) { 29962 return state.categories; 29963 }, 29964 getBlockGuidelines(state) { 29965 return state.categories.blocks; 29966 }, 29967 getBlockGuideline(state, blockName) { 29968 return state.categories.blocks[blockName] ?? ""; 29969 }, 29970 getId(state) { 29971 return state.id; 29972 }, 29973 getStatus(state) { 29974 return state.status; 29975 } 29976 }; 29977 var store = (0, import_data6.createReduxStore)(STORE_NAME, { 29978 reducer, 29979 actions, 29980 selectors: selectors3 29981 }); 29982 (0, import_data6.register)(store); 29983 29984 // routes/guidelines/api.ts 29985 var import_api_fetch = __toESM(require_api_fetch()); 29986 var import_blob = __toESM(require_blob()); 29987 var import_data7 = __toESM(require_data()); 29988 var import_i18n49 = __toESM(require_i18n()); 29989 var import_notices = __toESM(require_notices()); 29990 var FLAT_CATEGORIES = ["site", "copy", "images", "additional"]; 29991 function isValidGuidelinesImport(data) { 29992 return !!data && typeof data === "object" && "guideline_categories" in data && typeof data.guideline_categories === "object" && data.guideline_categories !== null; 29993 } 29994 async function fetchGuidelines() { 29995 const { setFromResponse } = (0, import_data7.dispatch)(store); 29996 const response = await (0, import_api_fetch.default)({ 29997 path: "/wp/v2/content-guidelines?context=edit" 29998 }); 29999 setFromResponse(response); 30000 return response; 30001 } 30002 async function saveGuidelines() { 30003 const { setFromResponse } = (0, import_data7.dispatch)(store); 30004 const guidelinesStore = (0, import_data7.select)(store); 30005 const id = guidelinesStore.getId(); 30006 const status = guidelinesStore.getStatus() || "draft"; 30007 const categories = guidelinesStore.getAllGuidelines(); 30008 const response = await saveGuidelinesBypassingStore( 30009 id, 30010 status, 30011 categories 30012 ); 30013 setFromResponse(response); 30014 return response; 30015 } 30016 async function saveGuidelinesBypassingStore(id, status, categories) { 30017 const data = { 30018 id, 30019 status, 30020 guideline_categories: { 30021 site: { 30022 guidelines: categories.site 30023 }, 30024 copy: { 30025 guidelines: categories.copy 30026 }, 30027 images: { 30028 guidelines: categories.images 30029 }, 30030 additional: { 30031 guidelines: categories.additional 30032 }, 30033 blocks: Object.fromEntries( 30034 Object.entries(categories.blocks).map( 30035 ([blockName, guidelines]) => [ 30036 blockName, 30037 { guidelines } 30038 ] 30039 ) 30040 ) 30041 } 30042 }; 30043 const path = id ? `/wp/v2/content-guidelines/$id}` : "/wp/v2/content-guidelines"; 30044 const method = id ? "PUT" : "POST"; 30045 const response = await (0, import_api_fetch.default)({ 30046 path, 30047 method, 30048 data 30049 }); 30050 return response; 30051 } 30052 async function importGuidelines(file) { 30053 const { setFromResponse } = (0, import_data7.dispatch)(store); 30054 const guidelinesStore = (0, import_data7.select)(store); 30055 const { createSuccessNotice } = (0, import_data7.dispatch)(import_notices.store); 30056 const parsed = JSON.parse(await file.text()); 30057 if (!isValidGuidelinesImport(parsed)) { 30058 throw new Error( 30059 (0, import_i18n49.__)( 30060 "Check that your file contains valid JSON markup and try again." 30061 ) 30062 ); 30063 } 30064 const existingGuidelines = guidelinesStore.getAllGuidelines(); 30065 const newGuidelines = { 30066 /** 30067 * Set empty string to all the simple guidelines so that if the category is not present 30068 * in the parsed data, the category gets removed. 30069 */ 30070 ...Object.fromEntries( 30071 FLAT_CATEGORIES.map((category) => [category, ""]) 30072 ), 30073 /** 30074 * Set empty string to all the existing block guidelines so that if the block is not present 30075 * in the parsed data, the block gets removed. 30076 */ 30077 blocks: Object.fromEntries( 30078 Object.keys(existingGuidelines.blocks).map((block) => [ 30079 block, 30080 "" 30081 ]) 30082 ) 30083 }; 30084 for (const cat of FLAT_CATEGORIES) { 30085 const guidelines = parsed.guideline_categories[cat]?.guidelines || ""; 30086 newGuidelines[cat] = guidelines; 30087 } 30088 const parsedBlocks = parsed.guideline_categories?.blocks ?? {}; 30089 for (const [key, value] of Object.entries(parsedBlocks)) { 30090 newGuidelines.blocks[key] = value?.guidelines || ""; 30091 } 30092 const response = await saveGuidelinesBypassingStore( 30093 guidelinesStore.getId(), 30094 guidelinesStore.getStatus() || "draft", 30095 newGuidelines 30096 ); 30097 setFromResponse(response); 30098 createSuccessNotice((0, import_i18n49.__)("Guidelines imported."), { 30099 type: "snackbar" 30100 }); 30101 } 30102 function exportGuidelines() { 30103 const { createSuccessNotice } = (0, import_data7.dispatch)(import_notices.store); 30104 const guidelinesStore = (0, import_data7.select)(store); 30105 const guidelinesCategories = guidelinesStore.getAllGuidelines(); 30106 const blockGuidelines = guidelinesStore.getBlockGuidelines(); 30107 const data = { 30108 guideline_categories: { 30109 ...Object.fromEntries( 30110 FLAT_CATEGORIES.map((guidelineCategory) => [ 30111 guidelineCategory, 30112 { 30113 guidelines: guidelinesCategories[guidelineCategory] ?? "" 30114 } 30115 ]) 30116 ), 30117 blocks: Object.fromEntries( 30118 Object.entries(blockGuidelines).map( 30119 ([blockName, guidelines]) => [ 30120 blockName, 30121 { guidelines } 30122 ] 30123 ) 30124 ) 30125 } 30126 }; 30127 const now = /* @__PURE__ */ new Date(); 30128 const exportDate = [ 30129 now.getFullYear(), 30130 String(now.getMonth() + 1).padStart(2, "0"), 30131 String(now.getDate()).padStart(2, "0") 30132 ].join("-"); 30133 (0, import_blob.downloadBlob)( 30134 `guidelines-$exportDate}.json`, 30135 JSON.stringify(data, null, 2), 30136 "application/json" 30137 ); 30138 createSuccessNotice((0, import_i18n49.__)("Guidelines exported."), { 30139 type: "snackbar" 30140 }); 30141 } 30142 async function fetchGuidelinesRevisions({ 30143 guidelinesId, 30144 page = 1, 30145 perPage = 10, 30146 search 30147 }) { 30148 const params = new URLSearchParams({ 30149 page: String(page), 30150 per_page: String(perPage), 30151 _embed: "author", 30152 ...search ? { search } : {} 30153 }); 30154 const response = await (0, import_api_fetch.default)({ 30155 path: `/wp/v2/content-guidelines/$guidelinesId}/revisions?$params}`, 30156 parse: false 30157 }); 30158 const revisions = await response.json(); 30159 const total = parseInt(response.headers.get("X-WP-Total") ?? "0", 10); 30160 const totalPages = parseInt( 30161 response.headers.get("X-WP-TotalPages") ?? "0", 30162 10 30163 ); 30164 return { revisions, total, totalPages }; 30165 } 30166 async function restoreGuidelinesRevision(guidelinesId, revisionId) { 30167 return await (0, import_api_fetch.default)({ 30168 path: `/wp/v2/content-guidelines/$guidelinesId}/revisions/$revisionId}/restore`, 30169 method: "POST" 30170 }); 30171 } 30172 30173 // routes/guidelines/components/guideline-accordion-form.tsx 30174 function GuidelineAccordionForm({ slug }) { 30175 const { setGuideline } = (0, import_data8.useDispatch)(store); 30176 const { createSuccessNotice } = (0, import_data8.useDispatch)(import_notices2.store); 30177 const [loading, setLoading] = (0, import_element100.useState)(false); 30178 const [error2, setError] = (0, import_element100.useState)(null); 30179 const [showClearConfirmation, setShowClearConfirmation] = (0, import_element100.useState)(false); 30180 const { value } = (0, import_data8.useSelect)( 30181 (select2) => ({ 30182 value: select2(store).getGuideline(slug) 30183 }), 30184 [slug] 30185 ); 30186 const [draft, setDraft] = (0, import_element100.useState)(value); 30187 (0, import_element100.useEffect)(() => setDraft(value), [value]); 30188 const data = (0, import_element100.useMemo)(() => ({ guidelines: draft }), [draft]); 30189 const fields2 = (0, import_element100.useMemo)( 30190 () => [ 30191 { 30192 id: "guidelines", 30193 label: (0, import_i18n50.sprintf)( 30194 /* translators: %s: Guideline category. */ 30195 (0, import_i18n50.__)("%s guidelines"), 30196 slug 30197 ), 30198 type: "text", 30199 Edit: "textarea" 30200 } 30201 ], 30202 [slug] 30203 ); 30204 const form = (0, import_element100.useMemo)( 30205 () => ({ 30206 layout: { type: "regular", labelPosition: "none" }, 30207 fields: ["guidelines"] 30208 }), 30209 [] 30210 ); 30211 const handleSave = (event) => { 30212 event.preventDefault(); 30213 setGuideline(slug, draft); 30214 setLoading(true); 30215 saveGuidelines().then(() => { 30216 setError(null); 30217 createSuccessNotice((0, import_i18n50.__)("Guidelines saved."), { 30218 type: "snackbar" 30219 }); 30220 }).catch( 30221 (e2) => setError( 30222 (0, import_i18n50.sprintf)( 30223 /* translators: %s: Error message. */ 30224 (0, import_i18n50.__)("Error saving guidelines: %s"), 30225 e2.message 30226 ) 30227 ) 30228 ).finally(() => setLoading(false)); 30229 }; 30230 const handleClearClick = () => setShowClearConfirmation(true); 30231 const handleClearConfirm = () => { 30232 const oldValue = draft; 30233 setGuideline(slug, ""); 30234 setLoading(true); 30235 saveGuidelines().then(() => { 30236 setError(null); 30237 createSuccessNotice((0, import_i18n50.__)("Guidelines cleared."), { 30238 type: "snackbar" 30239 }); 30240 }).catch((e2) => { 30241 setError( 30242 (0, import_i18n50.sprintf)( 30243 /* translators: %s: Error message. */ 30244 (0, import_i18n50.__)("Error clearing guidelines: %s"), 30245 e2.message 30246 ) 30247 ); 30248 setGuideline(slug, oldValue); 30249 }).finally(() => { 30250 setLoading(false); 30251 setShowClearConfirmation(false); 30252 }); 30253 }; 30254 return /* @__PURE__ */ React.createElement("form", { onSubmit: handleSave }, /* @__PURE__ */ React.createElement(import_components53.__experimentalVStack, { spacing: 4 }, /* @__PURE__ */ React.createElement( 30255 DataForm, 30256 { 30257 data, 30258 fields: fields2, 30259 form, 30260 onChange: (edits) => setDraft(edits.guidelines ?? draft) 30261 } 30262 ), error2 && /* @__PURE__ */ React.createElement(import_components53.Notice, { status: "error", onRemove: () => setError(null) }, error2), /* @__PURE__ */ React.createElement(import_components53.__experimentalHStack, { spacing: 4, alignment: "left" }, /* @__PURE__ */ React.createElement( 30263 import_components53.Button, 30264 { 30265 variant: "primary", 30266 type: "submit", 30267 disabled: loading || !draft, 30268 accessibleWhenDisabled: true, 30269 isBusy: loading, 30270 __next40pxDefaultSize: true 30271 }, 30272 (0, import_i18n50.__)("Save guidelines") 30273 ), /* @__PURE__ */ React.createElement( 30274 import_components53.Button, 30275 { 30276 variant: "tertiary", 30277 type: "button", 30278 disabled: loading || !value, 30279 accessibleWhenDisabled: true, 30280 isBusy: loading, 30281 onClick: handleClearClick, 30282 __next40pxDefaultSize: true 30283 }, 30284 (0, import_i18n50.__)("Clear guidelines") 30285 ))), /* @__PURE__ */ React.createElement( 30286 import_components53.__experimentalConfirmDialog, 30287 { 30288 isOpen: showClearConfirmation, 30289 title: (0, import_i18n50.sprintf)( 30290 /* translators: %s: Guideline category. */ 30291 (0, import_i18n50.__)("Clear %s guidelines"), 30292 slug 30293 ), 30294 __experimentalHideHeader: false, 30295 onConfirm: handleClearConfirm, 30296 onCancel: () => setShowClearConfirmation(false), 30297 confirmButtonText: (0, import_i18n50.__)("Clear guidelines"), 30298 isBusy: loading, 30299 size: "small" 30300 }, 30301 (0, import_i18n50.sprintf)( 30302 /* translators: %s: Guideline category slug. */ 30303 (0, import_i18n50.__)( 30304 "You are about to clear the %s guidelines. This can be undone from revision history." 30305 ), 30306 slug 30307 ) 30308 )); 30309 } 30310 30311 // routes/guidelines/components/block-guidelines.tsx 30312 var import_components55 = __toESM(require_components()); 30313 var import_i18n52 = __toESM(require_i18n()); 30314 var import_element102 = __toESM(require_element()); 30315 var import_data10 = __toESM(require_data()); 30316 var import_blocks2 = __toESM(require_blocks()); 30317 var import_notices4 = __toESM(require_notices()); 30318 30319 // routes/guidelines/components/block-guideline-modal.tsx 30320 var import_components54 = __toESM(require_components()); 30321 var import_i18n51 = __toESM(require_i18n()); 30322 var import_element101 = __toESM(require_element()); 30323 var import_data9 = __toESM(require_data()); 30324 var import_blocks = __toESM(require_blocks()); 30325 var import_notices3 = __toESM(require_notices()); 30326 30327 // routes/lock-unlock.ts 30328 var import_private_apis3 = __toESM(require_private_apis()); 30329 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 30330 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 30331 "@wordpress/routes" 30332 ); 30333 30334 // routes/guidelines/components/block-guideline-modal.scss 30335 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='7c0ecac6c9']")) { 30336 const style = document.createElement("style"); 30337 style.setAttribute("data-wp-hash", "7c0ecac6c9"); 30338 style.appendChild(document.createTextNode(".block-guideline-modal{width:min(100%,660px)}.block-guideline-modal__actions{margin-top:8px}")); 30339 document.head.appendChild(style); 30340 } 30341 30342 // routes/guidelines/components/block-guideline-modal.tsx 30343 var { isContentBlock } = unlock3(import_blocks.privateApis); 30344 function BlockGuidelineModal({ 30345 closeModal, 30346 initialBlock 30347 }) { 30348 const [selectedBlock, setSelectedBlock] = (0, import_element101.useState)( 30349 initialBlock 30350 ); 30351 const [isSaving, setIsSaving] = (0, import_element101.useState)(false); 30352 const [error2, setError] = (0, import_element101.useState)(null); 30353 const [showRemoveConfirmation, setShowRemoveConfirmation] = (0, import_element101.useState)(false); 30354 const blockGuidelines = (0, import_data9.useSelect)( 30355 (select2) => select2(store).getBlockGuidelines(), 30356 [] 30357 ); 30358 const isEditing = !!initialBlock; 30359 const currentGuideline = blockGuidelines[selectedBlock] ?? ""; 30360 const [guidelineText, setGuidelineText] = (0, import_element101.useState)(currentGuideline); 30361 const blockOptions = (0, import_data9.useSelect)( 30362 // @ts-ignore 30363 (select2) => select2(import_blocks.store).getBlockTypes(), 30364 [] 30365 ); 30366 const availableBlockOptions = (0, import_element101.useMemo)(() => { 30367 const set3 = new Set(Object.keys(blockGuidelines)); 30368 if (initialBlock) { 30369 set3.delete(initialBlock); 30370 } 30371 if (selectedBlock) { 30372 set3.delete(selectedBlock); 30373 } 30374 return blockOptions.filter( 30375 (block) => isContentBlock(block.name) && !set3.has(block.name) 30376 ).map((block) => ({ 30377 value: block.name, 30378 label: block.title 30379 })); 30380 }, [blockGuidelines, blockOptions, initialBlock, selectedBlock]); 30381 const selectedBlockLabel = (0, import_element101.useMemo)( 30382 () => blockOptions.find((block) => block.name === selectedBlock)?.title || "", 30383 [blockOptions, selectedBlock] 30384 ); 30385 const { setBlockGuideline } = (0, import_data9.useDispatch)(store); 30386 const { createSuccessNotice } = (0, import_data9.useDispatch)(import_notices3.store); 30387 const handleSave = (value) => { 30388 value = value.trim(); 30389 if (!selectedBlock) { 30390 return; 30391 } 30392 setIsSaving(true); 30393 const oldValue = blockGuidelines[selectedBlock]; 30394 setBlockGuideline(selectedBlock, value); 30395 saveGuidelines().then(() => { 30396 setError(null); 30397 createSuccessNotice( 30398 value ? (0, import_i18n51.__)("Guidelines saved.") : (0, import_i18n51.__)("Guidelines removed."), 30399 { type: "snackbar" } 30400 ); 30401 closeModal(); 30402 }).catch((e2) => { 30403 setError(e2.message); 30404 setBlockGuideline(selectedBlock, oldValue); 30405 }).finally(() => setIsSaving(false)); 30406 }; 30407 const canSubmit = selectedBlock && guidelineText.trim().length > 0; 30408 let submitButtonLabel = (0, import_i18n51.__)("Save guidelines"); 30409 if (isSaving) { 30410 submitButtonLabel = (0, import_i18n51.__)("Saving\u2026"); 30411 } 30412 return /* @__PURE__ */ React.createElement( 30413 import_components54.Modal, 30414 { 30415 className: "block-guideline-modal", 30416 title: isEditing ? (0, import_i18n51.__)("Edit guidelines") : (0, import_i18n51.__)("Add guidelines"), 30417 onRequestClose: closeModal 30418 }, 30419 /* @__PURE__ */ React.createElement(import_components54.__experimentalVStack, { spacing: 4 }, isEditing ? /* @__PURE__ */ React.createElement( 30420 import_components54.TextControl, 30421 { 30422 __next40pxDefaultSize: true, 30423 label: (0, import_i18n51.__)("Block"), 30424 value: selectedBlockLabel, 30425 onChange: () => { 30426 }, 30427 disabled: true 30428 } 30429 ) : /* @__PURE__ */ React.createElement( 30430 import_components54.ComboboxControl, 30431 { 30432 __next40pxDefaultSize: true, 30433 label: (0, import_i18n51.__)("Block"), 30434 options: availableBlockOptions, 30435 value: selectedBlock, 30436 onChange: (value) => setSelectedBlock(value ?? void 0), 30437 placeholder: (0, import_i18n51.__)("Search for a block\u2026") 30438 } 30439 ), /* @__PURE__ */ React.createElement( 30440 import_components54.TextareaControl, 30441 { 30442 label: (0, import_i18n51.__)("Guideline text"), 30443 value: guidelineText, 30444 onChange: setGuidelineText, 30445 placeholder: (0, import_i18n51.__)( 30446 "Enter guidelines for how this block should be used\u2026" 30447 ), 30448 rows: 6 30449 } 30450 ), error2 && /* @__PURE__ */ React.createElement(import_components54.Notice, { status: "error", onRemove: () => setError(null) }, (0, import_i18n51.sprintf)( 30451 /* translators: %s: Error message. */ 30452 (0, import_i18n51.__)("Error: %s"), 30453 error2 30454 )), /* @__PURE__ */ React.createElement( 30455 import_components54.__experimentalHStack, 30456 { 30457 justify: "flex-end", 30458 spacing: 2, 30459 className: "block-guideline-modal__actions" 30460 }, 30461 isEditing && /* @__PURE__ */ React.createElement( 30462 import_components54.Button, 30463 { 30464 variant: "tertiary", 30465 isDestructive: true, 30466 onClick: () => setShowRemoveConfirmation(true), 30467 disabled: isSaving, 30468 accessibleWhenDisabled: true, 30469 type: "button", 30470 __next40pxDefaultSize: true 30471 }, 30472 (0, import_i18n51.__)("Remove") 30473 ), 30474 /* @__PURE__ */ React.createElement( 30475 import_components54.Button, 30476 { 30477 variant: "primary", 30478 onClick: () => handleSave(guidelineText), 30479 disabled: !canSubmit || isSaving, 30480 isBusy: isSaving, 30481 accessibleWhenDisabled: true, 30482 __next40pxDefaultSize: true 30483 }, 30484 submitButtonLabel 30485 ) 30486 )), 30487 /* @__PURE__ */ React.createElement( 30488 import_components54.__experimentalConfirmDialog, 30489 { 30490 isOpen: showRemoveConfirmation, 30491 title: (0, import_i18n51.__)("Remove block guidelines"), 30492 __experimentalHideHeader: false, 30493 onConfirm: () => { 30494 handleSave(""); 30495 setShowRemoveConfirmation(false); 30496 }, 30497 onCancel: () => setShowRemoveConfirmation(false), 30498 confirmButtonText: (0, import_i18n51.__)("Remove"), 30499 isBusy: isSaving, 30500 size: "small" 30501 }, 30502 (0, import_i18n51.sprintf)( 30503 /* translators: %s: Block name. */ 30504 (0, import_i18n51.__)( 30505 "You are about to remove the block guidelines for the %s block. This can be undone from revision history." 30506 ), 30507 selectedBlockLabel 30508 ) 30509 ) 30510 ); 30511 } 30512 30513 // routes/guidelines/components/block-guidelines.scss 30514 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='3b11cd5a2f']")) { 30515 const style = document.createElement("style"); 30516 style.setAttribute("data-wp-hash", "3b11cd5a2f"); 30517 style.appendChild(document.createTextNode(".block-guidelines .block-guidelines__icon{align-items:center;display:flex;height:100%;justify-content:center;width:100%}.block-guidelines .dataviews-view-list__field-wrapper{display:flex;justify-content:center}.block-guidelines .dataviews-wrapper{margin-inline:-24px}.block-guidelines .dataviews-search{margin-inline:24px}")); 30518 document.head.appendChild(style); 30519 } 30520 30521 // routes/guidelines/components/block-guidelines.tsx 30522 var PER_PAGE = 5; 30523 var initialView = { 30524 type: "list", 30525 search: "", 30526 page: 1, 30527 perPage: PER_PAGE, 30528 filters: [], 30529 mediaField: "icon", 30530 showMedia: true, 30531 titleField: "label", 30532 layout: { 30533 density: "compact" 30534 } 30535 }; 30536 var fields = [ 30537 { 30538 id: "icon", 30539 label: (0, import_i18n52.__)("Icon"), 30540 type: "media", 30541 render: ({ item }) => /* @__PURE__ */ React.createElement("div", { className: "block-guidelines__icon" }, /* @__PURE__ */ React.createElement(import_components55.Icon, { icon: item.icon ?? block_default_default, size: 16 })) 30542 }, 30543 { 30544 id: "label", 30545 label: (0, import_i18n52.__)("Label"), 30546 type: "text", 30547 enableGlobalSearch: true, 30548 getValue: ({ item }) => item.label, 30549 render: ({ item }) => item.label 30550 } 30551 ]; 30552 function BlockGuidelines() { 30553 const [isOpen, setIsOpen] = (0, import_element102.useState)(false); 30554 const [view, setView] = (0, import_element102.useState)(initialView); 30555 const [selectedItem, setSelectedItem] = (0, import_element102.useState)(); 30556 const [error2, setError] = (0, import_element102.useState)(null); 30557 const [busy, setBusy] = (0, import_element102.useState)(false); 30558 const [itemToDelete, setItemToDelete] = (0, import_element102.useState)( 30559 null 30560 ); 30561 const { createSuccessNotice } = (0, import_data10.useDispatch)(import_notices4.store); 30562 const blockGuidelines = (0, import_data10.useSelect)( 30563 (select2) => select2(store).getBlockGuidelines(), 30564 [] 30565 ); 30566 const blockTypes = (0, import_data10.useSelect)( 30567 // @ts-ignore 30568 (select2) => select2(import_blocks2.store).getBlockTypes(), 30569 [] 30570 ); 30571 const rows = (0, import_element102.useMemo)( 30572 () => blockTypes.filter((blockType) => blockGuidelines[blockType.name]).map((blockType) => ({ 30573 id: blockType.name, 30574 label: blockType.title, 30575 guidelines: blockGuidelines[blockType.name] ?? "", 30576 icon: blockType.icon?.src 30577 })), 30578 [blockGuidelines, blockTypes] 30579 ); 30580 const { setBlockGuideline } = (0, import_data10.useDispatch)(store); 30581 const handleRowClick = (id) => { 30582 setSelectedItem(id); 30583 setIsOpen(true); 30584 }; 30585 const actions2 = (0, import_element102.useMemo)( 30586 () => [ 30587 { 30588 id: "edit", 30589 label: (0, import_i18n52.__)("Edit"), 30590 callback: (items) => { 30591 const item = items[0]; 30592 handleRowClick(item.id); 30593 } 30594 }, 30595 { 30596 id: "remove", 30597 label: (0, import_i18n52.__)("Remove"), 30598 callback: (items) => { 30599 const item = items[0]; 30600 setItemToDelete(item); 30601 } 30602 } 30603 ], 30604 [setItemToDelete] 30605 ); 30606 const handleDelete = () => { 30607 if (!itemToDelete) { 30608 return; 30609 } 30610 const oldValue = blockGuidelines[itemToDelete.id]; 30611 setBlockGuideline(itemToDelete.id, ""); 30612 setBusy(true); 30613 saveGuidelines().then(() => { 30614 setError(null); 30615 createSuccessNotice((0, import_i18n52.__)("Guidelines removed."), { 30616 type: "snackbar" 30617 }); 30618 }).catch((e2) => { 30619 setError(e2.message); 30620 setBlockGuideline(itemToDelete.id, oldValue); 30621 }).finally(() => { 30622 setBusy(false); 30623 setItemToDelete(null); 30624 }); 30625 }; 30626 const { data: processedData, paginationInfo } = (0, import_element102.useMemo)( 30627 () => filterSortAndPaginate(rows, view, fields), 30628 [rows, view] 30629 ); 30630 (0, import_element102.useEffect)(() => { 30631 const lastPage = Math.max(paginationInfo.totalPages, 1); 30632 if (view.page && view.page > lastPage) { 30633 setView( 30634 (currentView) => currentView.page && currentView.page > lastPage ? { 30635 ...currentView, 30636 page: lastPage 30637 } : currentView 30638 ); 30639 } 30640 }, [paginationInfo.totalPages, view.page]); 30641 const closeModal = () => { 30642 setIsOpen(false); 30643 setSelectedItem(void 0); 30644 }; 30645 const openModal = () => { 30646 setSelectedItem(void 0); 30647 setIsOpen(true); 30648 }; 30649 const shouldShowDataViewControls = rows.length > PER_PAGE; 30650 return /* @__PURE__ */ React.createElement(import_components55.__experimentalVStack, { spacing: 4, className: "block-guidelines" }, error2 && /* @__PURE__ */ React.createElement(import_components55.Notice, { status: "error", onRemove: () => setError(null) }, (0, import_i18n52.sprintf)( 30651 /* translators: %s: Error message. */ 30652 (0, import_i18n52.__)("Error: %s"), 30653 error2 30654 )), rows.length > 0 && /* @__PURE__ */ React.createElement( 30655 dataviews_default, 30656 { 30657 paginationInfo, 30658 data: processedData, 30659 view, 30660 onChangeView: setView, 30661 fields, 30662 actions: actions2, 30663 config: { perPageSizes: [PER_PAGE] }, 30664 onChangeSelection: (items) => { 30665 const id = items[0]; 30666 handleRowClick(id); 30667 }, 30668 defaultLayouts: { 30669 list: true 30670 } 30671 }, 30672 /* @__PURE__ */ React.createElement(import_components55.__experimentalVStack, { spacing: 4 }, shouldShowDataViewControls && /* @__PURE__ */ React.createElement(dataviews_default.Search, { label: (0, import_i18n52.__)("Search blocks") }), /* @__PURE__ */ React.createElement(dataviews_default.Layout, null), shouldShowDataViewControls && /* @__PURE__ */ React.createElement(dataviews_default.Footer, null)) 30673 ), /* @__PURE__ */ React.createElement(import_components55.__experimentalHStack, null, /* @__PURE__ */ React.createElement( 30674 import_components55.Button, 30675 { 30676 variant: "primary", 30677 onClick: openModal, 30678 __next40pxDefaultSize: true 30679 }, 30680 (0, import_i18n52.__)("Add guidelines") 30681 )), isOpen && /* @__PURE__ */ React.createElement( 30682 BlockGuidelineModal, 30683 { 30684 closeModal, 30685 initialBlock: selectedItem 30686 } 30687 ), /* @__PURE__ */ React.createElement( 30688 import_components55.__experimentalConfirmDialog, 30689 { 30690 isOpen: !!itemToDelete, 30691 title: (0, import_i18n52.__)("Remove block guidelines"), 30692 __experimentalHideHeader: false, 30693 onConfirm: handleDelete, 30694 onCancel: () => setItemToDelete(null), 30695 confirmButtonText: (0, import_i18n52.__)("Remove"), 30696 isBusy: busy, 30697 size: "small" 30698 }, 30699 (0, import_i18n52.sprintf)( 30700 /* translators: %s: Block name. */ 30701 (0, import_i18n52.__)( 30702 "You are about to remove the block guidelines for the %s block. This can be undone from revision history." 30703 ), 30704 itemToDelete?.label ?? "" 30705 ) 30706 )); 30707 } 30708 30709 // routes/guidelines/components/guideline-actions-section.tsx 30710 var import_components57 = __toESM(require_components()); 30711 var import_i18n53 = __toESM(require_i18n()); 30712 var import_element103 = __toESM(require_element()); 30713 30714 // routes/guidelines/components/guideline-actions-section.scss 30715 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='6d10be742e']")) { 30716 const style = document.createElement("style"); 30717 style.setAttribute("data-wp-hash", "6d10be742e"); 30718 style.appendChild(document.createTextNode('.guidelines__actions{margin:16px auto 0;width:min(680px,100%)}.guidelines__actions-card{overflow:hidden;padding:0}.guidelines__actions-list{list-style:none;margin:0;padding:0}.guidelines__action-list-item{margin-bottom:0;position:relative}.guidelines__action-list-item:not(:first-child):before{background-color:#f0f0f0;content:"";height:1px;position:absolute;top:0;inset-inline:24px}.guidelines__action-row{align-items:center;box-sizing:border-box;padding:16px 24px;width:100%}.guidelines__actions-card .guidelines__action-button{font-size:13px;font-weight:400;justify-content:center;min-width:100px}.guidelines__action-title{color:#1e1e1e}.guidelines__action-description{color:#757575}')); 30719 document.head.appendChild(style); 30720 } 30721 30722 // routes/guidelines/components/action-item.tsx 30723 var import_components56 = __toESM(require_components()); 30724 function ActionItem({ 30725 slug, 30726 title, 30727 description, 30728 buttonLabel, 30729 ariaLabel, 30730 onClick, 30731 disabled: disabled2, 30732 isBusy 30733 }) { 30734 const descriptionId = `guidelines-action-$slug}-description`; 30735 return /* @__PURE__ */ React.createElement(import_components56.__experimentalHStack, { justify: "space-between", className: "guidelines__action-row" }, /* @__PURE__ */ React.createElement(import_components56.__experimentalVStack, { spacing: 1 }, /* @__PURE__ */ React.createElement( 30736 import_components56.__experimentalHeading, 30737 { 30738 level: 3, 30739 size: 13, 30740 weight: 400, 30741 className: "guidelines__action-title" 30742 }, 30743 title 30744 ), /* @__PURE__ */ React.createElement( 30745 import_components56.__experimentalText, 30746 { 30747 id: descriptionId, 30748 size: 13, 30749 weight: 400, 30750 variant: "muted", 30751 className: "guidelines__action-description" 30752 }, 30753 description 30754 )), /* @__PURE__ */ React.createElement( 30755 import_components56.Button, 30756 { 30757 size: "compact", 30758 variant: "secondary", 30759 className: "guidelines__action-button", 30760 "aria-label": ariaLabel, 30761 "aria-describedby": descriptionId, 30762 onClick, 30763 isBusy, 30764 disabled: disabled2, 30765 accessibleWhenDisabled: true 30766 }, 30767 buttonLabel 30768 )); 30769 } 30770 30771 // routes/guidelines/components/guideline-actions-section.tsx 30772 function getErrorMessage(err) { 30773 return err instanceof Error ? err.message : (0, import_i18n53.__)("Unknown error"); 30774 } 30775 function GuidelineActionsSection() { 30776 const { goTo } = (0, import_components57.useNavigator)(); 30777 const fileInputRef = (0, import_element103.useRef)(null); 30778 const [isImporting, setIsImporting] = (0, import_element103.useState)(false); 30779 const [error2, setError] = (0, import_element103.useState)(null); 30780 const [pendingImport, setPendingImport] = (0, import_element103.useState)(null); 30781 function handleImportClick() { 30782 fileInputRef.current?.click(); 30783 } 30784 function handleFileChange(event) { 30785 const file = event.target.files?.[0]; 30786 event.target.value = ""; 30787 if (!file) { 30788 return; 30789 } 30790 setPendingImport(file); 30791 } 30792 async function handleModalContinue() { 30793 if (!pendingImport) { 30794 return; 30795 } 30796 const file = pendingImport; 30797 setPendingImport(null); 30798 setIsImporting(true); 30799 try { 30800 await importGuidelines(file); 30801 setError(null); 30802 } catch (err) { 30803 setError( 30804 (0, import_i18n53.sprintf)( 30805 /* translators: %s: Error message. */ 30806 (0, import_i18n53.__)("We ran into a problem importing your guidelines: %s"), 30807 getErrorMessage(err) 30808 ) 30809 ); 30810 } finally { 30811 setIsImporting(false); 30812 } 30813 } 30814 async function handleExportClick() { 30815 try { 30816 exportGuidelines(); 30817 setError(null); 30818 } catch (err) { 30819 setError( 30820 (0, import_i18n53.sprintf)( 30821 /* translators: %s: Error message. */ 30822 (0, import_i18n53.__)("We ran into a problem exporting your guidelines: %s"), 30823 getErrorMessage(err) 30824 ) 30825 ); 30826 } 30827 } 30828 function navigateToRevisionHistory() { 30829 if (window?.location?.href) { 30830 const url = new URL(window.location.href); 30831 url.searchParams.set("view", "revision-history"); 30832 window.history.replaceState({}, "", url.toString()); 30833 } 30834 goTo("/revision-history"); 30835 } 30836 const ACTIONS = [ 30837 { 30838 slug: "import", 30839 title: (0, import_i18n53.__)("Import"), 30840 description: (0, import_i18n53.__)("Upload a JSON file to import your guidelines."), 30841 buttonLabel: (0, import_i18n53.__)("Upload"), 30842 ariaLabel: (0, import_i18n53.__)("Import guidelines"), 30843 onClick: handleImportClick, 30844 isBusy: isImporting, 30845 disabled: isImporting || !!pendingImport 30846 }, 30847 { 30848 slug: "export", 30849 title: (0, import_i18n53.__)("Export"), 30850 description: (0, import_i18n53.__)("Export your guidelines to a JSON file."), 30851 buttonLabel: (0, import_i18n53.__)("Download"), 30852 ariaLabel: (0, import_i18n53.__)("Export guidelines"), 30853 onClick: handleExportClick 30854 }, 30855 { 30856 slug: "revert", 30857 title: (0, import_i18n53.__)("Revert"), 30858 description: (0, import_i18n53.__)("Use a previous version of your guidelines."), 30859 buttonLabel: (0, import_i18n53.__)("View history"), 30860 ariaLabel: (0, import_i18n53.__)("View history of guidelines"), 30861 onClick: navigateToRevisionHistory 30862 } 30863 ]; 30864 return /* @__PURE__ */ React.createElement(import_components57.__experimentalVStack, { spacing: 4, className: "guidelines__actions" }, /* @__PURE__ */ React.createElement(import_components57.__experimentalHeading, { level: 3, size: 15, weight: 500 }, (0, import_i18n53.__)("Actions")), /* @__PURE__ */ React.createElement( 30865 "input", 30866 { 30867 type: "file", 30868 accept: ".json", 30869 ref: fileInputRef, 30870 onChange: handleFileChange, 30871 style: { display: "none" } 30872 } 30873 ), error2 && /* @__PURE__ */ React.createElement( 30874 import_components57.Notice, 30875 { 30876 status: "error", 30877 onRemove: () => setError(null), 30878 isDismissible: true 30879 }, 30880 error2 30881 ), /* @__PURE__ */ React.createElement(import_components57.Card, { className: "guidelines__actions-card" }, /* @__PURE__ */ React.createElement("ul", { role: "list", className: "guidelines__actions-list" }, ACTIONS.map((action) => /* @__PURE__ */ React.createElement( 30882 "li", 30883 { 30884 key: action.slug, 30885 className: "guidelines__action-list-item" 30886 }, 30887 /* @__PURE__ */ React.createElement(ActionItem, { ...action }) 30888 )))), /* @__PURE__ */ React.createElement( 30889 import_components57.__experimentalConfirmDialog, 30890 { 30891 isOpen: !!pendingImport, 30892 __experimentalHideHeader: false, 30893 title: (0, import_i18n53.__)("Import guidelines"), 30894 confirmButtonText: (0, import_i18n53.__)("Continue"), 30895 onConfirm: handleModalContinue, 30896 onCancel: () => setPendingImport(null), 30897 size: "small" 30898 }, 30899 (0, import_i18n53.__)( 30900 "Importing new guidelines will replace your current guidelines. This can be undone from revision history." 30901 ) 30902 )); 30903 } 30904 30905 // routes/guidelines/components/revision-history.tsx 30906 var import_components58 = __toESM(require_components()); 30907 var import_i18n54 = __toESM(require_i18n()); 30908 var import_element104 = __toESM(require_element()); 30909 var import_data11 = __toESM(require_data()); 30910 var import_date10 = __toESM(require_date()); 30911 var import_notices5 = __toESM(require_notices()); 30912 var DEFAULT_VIEW = { 30913 type: "table", 30914 fields: ["date", "author"], 30915 page: 1, 30916 perPage: 10, 30917 layout: { 30918 enableMoving: false 30919 } 30920 }; 30921 function RevisionHistory() { 30922 const [view, setView] = (0, import_element104.useState)(DEFAULT_VIEW); 30923 const [revisions, setRevisions] = (0, import_element104.useState)([]); 30924 const [isLoading, setIsLoading] = (0, import_element104.useState)(false); 30925 const [revisionToRestore, setRevisionToRestore] = (0, import_element104.useState)(null); 30926 const [isRestoring, setIsRestoring] = (0, import_element104.useState)(false); 30927 const { createSuccessNotice, createErrorNotice } = (0, import_data11.useDispatch)(import_notices5.store); 30928 const guidelinesId = (0, import_data11.useSelect)( 30929 (select2) => select2(store).getId(), 30930 [] 30931 ); 30932 const loadRevisions = (0, import_element104.useCallback)(async () => { 30933 if (!guidelinesId) { 30934 return; 30935 } 30936 setIsLoading(true); 30937 try { 30938 const result = await fetchGuidelinesRevisions({ 30939 guidelinesId, 30940 page: 1, 30941 perPage: 100 30942 }); 30943 setRevisions(result.revisions); 30944 } catch { 30945 createErrorNotice( 30946 (0, import_i18n54.__)("Could not load revision history. Please try again."), 30947 { type: "snackbar" } 30948 ); 30949 } finally { 30950 setIsLoading(false); 30951 } 30952 }, [guidelinesId, createErrorNotice]); 30953 (0, import_element104.useEffect)(() => { 30954 loadRevisions(); 30955 }, [loadRevisions]); 30956 const authorElements = (0, import_element104.useMemo)(() => { 30957 return [ 30958 ...new Set( 30959 revisions.map( 30960 (r3) => r3._embedded?.author?.[0]?.name ?? (0, import_i18n54.__)("Unknown") 30961 ) 30962 ) 30963 ].map((name) => ({ value: name, label: name })); 30964 }, [revisions]); 30965 const fields2 = (0, import_element104.useMemo)( 30966 () => [ 30967 { 30968 id: "date", 30969 type: "date", 30970 label: (0, import_i18n54.__)("Date"), 30971 getValue: ({ item }) => item.date, 30972 render: ({ item }) => /* @__PURE__ */ React.createElement("time", { dateTime: item.date }, (0, import_date10.dateI18n)( 30973 (0, import_date10.getSettings)().formats.datetimeAbbreviated, 30974 (0, import_date10.getDate)(item.date) 30975 )), 30976 enableSorting: false, 30977 enableHiding: false, 30978 filterBy: { 30979 operators: ["before", "after", "between", "inThePast"] 30980 } 30981 }, 30982 { 30983 id: "author", 30984 label: (0, import_i18n54.__)("User"), 30985 getValue: ({ item }) => item._embedded?.author?.[0]?.name ?? (0, import_i18n54.__)("Unknown"), 30986 render: ({ item }) => /* @__PURE__ */ React.createElement("span", null, item._embedded?.author?.[0]?.name ?? (0, import_i18n54.__)("Unknown")), 30987 enableSorting: false, 30988 enableHiding: false, 30989 enableGlobalSearch: true, 30990 elements: authorElements, 30991 filterBy: { 30992 operators: ["isAny", "isNone"] 30993 } 30994 } 30995 ], 30996 [authorElements] 30997 ); 30998 const actions2 = (0, import_element104.useMemo)( 30999 () => [ 31000 { 31001 id: "restore-revision", 31002 label: (0, import_i18n54.__)("Restore"), 31003 callback: (items) => setRevisionToRestore(items[0]) 31004 } 31005 ], 31006 [setRevisionToRestore] 31007 ); 31008 const { data: displayedRevisions, paginationInfo: paginationToShow } = (0, import_element104.useMemo)( 31009 () => filterSortAndPaginate(revisions, view, fields2), 31010 [revisions, view, fields2] 31011 ); 31012 async function handleRestore() { 31013 if (!guidelinesId || !revisionToRestore) { 31014 return; 31015 } 31016 setIsRestoring(true); 31017 try { 31018 await restoreGuidelinesRevision( 31019 guidelinesId, 31020 revisionToRestore.id 31021 ); 31022 await fetchGuidelines(); 31023 setRevisionToRestore(null); 31024 await loadRevisions(); 31025 createSuccessNotice((0, import_i18n54.__)("Revision restored."), { 31026 type: "snackbar" 31027 }); 31028 } catch { 31029 createErrorNotice( 31030 (0, import_i18n54.__)("Could not restore revision. Please try again."), 31031 { type: "snackbar" } 31032 ); 31033 } finally { 31034 setIsRestoring(false); 31035 } 31036 } 31037 const navigateToGuidelines = () => { 31038 if (window?.location?.href) { 31039 const url = new URL(window.location.href); 31040 url.searchParams.delete("view"); 31041 window.history.replaceState({}, "", url.toString()); 31042 } 31043 }; 31044 return /* @__PURE__ */ React.createElement("div", { className: "guidelines__revision-history" }, /* @__PURE__ */ React.createElement( 31045 import_components58.Navigator.BackButton, 31046 { 31047 icon: (0, import_i18n54.isRTL)() ? chevron_right_default : chevron_left_default, 31048 className: "guidelines__revision-history-back", 31049 onClick: navigateToGuidelines 31050 }, 31051 (0, import_i18n54.__)("Revision history") 31052 ), /* @__PURE__ */ React.createElement(import_components58.__experimentalText, { size: 13, weight: 400, variant: "muted" }, (0, import_i18n54.__)("Use a previous version of your guidelines.")), /* @__PURE__ */ React.createElement( 31053 dataviews_default, 31054 { 31055 data: displayedRevisions, 31056 fields: fields2, 31057 view, 31058 onChangeView: setView, 31059 actions: actions2, 31060 isLoading, 31061 paginationInfo: paginationToShow, 31062 defaultLayouts: { table: true }, 31063 getItemId: (item) => String(item.id), 31064 empty: isLoading && displayedRevisions.length === 0 ? /* @__PURE__ */ React.createElement(import_components58.Spinner, null) : (0, import_i18n54.__)("No revisions found.") 31065 } 31066 ), revisionToRestore && /* @__PURE__ */ React.createElement( 31067 import_components58.Modal, 31068 { 31069 title: (0, import_i18n54.__)("Restore guidelines"), 31070 onRequestClose: () => setRevisionToRestore(null), 31071 size: "medium" 31072 }, 31073 /* @__PURE__ */ React.createElement(import_components58.__experimentalVStack, { spacing: 4 }, /* @__PURE__ */ React.createElement(import_components58.__experimentalText, { size: 13, weight: 400 }, (0, import_i18n54.sprintf)( 31074 /* translators: %s: formatted revision date */ 31075 (0, import_i18n54.__)( 31076 "You are about to restore the guidelines from %s." 31077 ), 31078 (0, import_date10.dateI18n)( 31079 (0, import_date10.getSettings)().formats.datetimeAbbreviated, 31080 (0, import_date10.getDate)(revisionToRestore.date) 31081 ) 31082 )), /* @__PURE__ */ React.createElement(import_components58.__experimentalText, { size: 13, weight: 400 }, (0, import_i18n54.__)( 31083 "You can undo this anytime from revision history." 31084 ))), 31085 /* @__PURE__ */ React.createElement( 31086 import_components58.__experimentalHStack, 31087 { 31088 justify: "flex-end", 31089 className: "guidelines__restore-modal-actions" 31090 }, 31091 /* @__PURE__ */ React.createElement( 31092 import_components58.Button, 31093 { 31094 variant: "tertiary", 31095 onClick: () => setRevisionToRestore(null), 31096 __next40pxDefaultSize: true 31097 }, 31098 (0, import_i18n54.__)("Cancel") 31099 ), 31100 /* @__PURE__ */ React.createElement( 31101 import_components58.Button, 31102 { 31103 variant: "primary", 31104 onClick: handleRestore, 31105 isBusy: isRestoring, 31106 disabled: isRestoring, 31107 accessibleWhenDisabled: true, 31108 __next40pxDefaultSize: true 31109 }, 31110 (0, import_i18n54.__)("Restore") 31111 ) 31112 ) 31113 )); 31114 } 31115 31116 // routes/guidelines/stage.tsx 31117 var GUIDELINE_ITEMS = [ 31118 { 31119 title: (0, import_i18n55.__)("Site"), 31120 description: (0, import_i18n55.__)( 31121 "Describe your site's purpose, goals, and primary audience." 31122 ), 31123 slug: "site" 31124 }, 31125 { 31126 title: (0, import_i18n55.__)("Copy"), 31127 description: (0, import_i18n55.__)( 31128 "Set your writing standards for tone, voice, style, and formatting." 31129 ), 31130 slug: "copy" 31131 }, 31132 { 31133 title: (0, import_i18n55.__)("Images"), 31134 description: (0, import_i18n55.__)( 31135 "Outline your style, dimensions, formats, mood and aesthetic preferences." 31136 ), 31137 slug: "images" 31138 }, 31139 { 31140 title: (0, import_i18n55.__)("Blocks"), 31141 description: (0, import_i18n55.__)( 31142 "Create tailored guidelines for specific block types." 31143 ), 31144 slug: "blocks" 31145 }, 31146 { 31147 title: (0, import_i18n55.__)("Additional"), 31148 description: (0, import_i18n55.__)("Add additional guidelines."), 31149 slug: "additional" 31150 } 31151 ]; 31152 var KNOWN_VIEWS = ["revision-history"]; 31153 function getInitialNavigatorPath() { 31154 if (window?.location?.href) { 31155 const url = new URL(window.location.href); 31156 const view = url.searchParams.get("view") ?? ""; 31157 if (KNOWN_VIEWS.includes(view)) { 31158 return `/$view}`; 31159 } 31160 } 31161 return "/"; 31162 } 31163 function GuidelinesPage() { 31164 const [loading, setLoading] = (0, import_element105.useState)(true); 31165 const [error2, setError] = (0, import_element105.useState)(null); 31166 (0, import_element105.useEffect)(() => { 31167 fetchGuidelines().then(() => setError(null)).catch((e2) => setError(e2.message)).finally(() => setLoading(false)); 31168 }, []); 31169 return /* @__PURE__ */ React.createElement( 31170 page_default, 31171 { 31172 title: (0, import_i18n55.__)("Guidelines"), 31173 subTitle: (0, import_i18n55.__)( 31174 "Set content standards that guide your team, inform plugins, and help AI tools generate content that matches your site's voice and requirements." 31175 ) 31176 }, 31177 error2 && /* @__PURE__ */ React.createElement("div", { className: "guidelines__content" }, /* @__PURE__ */ React.createElement(import_components59.Notice, { status: "error", isDismissible: false }, /* @__PURE__ */ React.createElement("strong", null, (0, import_i18n55.sprintf)( 31178 /* translators: %s: Error message. */ 31179 (0, import_i18n55.__)("Error loading guidelines: %s"), 31180 error2 31181 )), /* @__PURE__ */ React.createElement("p", { className: "guidelines__error-description" }, (0, import_i18n55.__)( 31182 "Please try again. If the problem persists, contact support." 31183 )))), 31184 loading ? /* @__PURE__ */ React.createElement("div", { className: "guidelines__loading" }, /* @__PURE__ */ React.createElement(import_components59.Spinner, null)) : !error2 && /* @__PURE__ */ React.createElement(import_components59.Navigator, { initialPath: getInitialNavigatorPath() }, /* @__PURE__ */ React.createElement(import_components59.Navigator.Screen, { path: "/" }, /* @__PURE__ */ React.createElement(import_components59.__experimentalVStack, { className: "guidelines__content" }, /* @__PURE__ */ React.createElement("ul", { role: "list", className: "guidelines__list" }, GUIDELINE_ITEMS.map((item) => /* @__PURE__ */ React.createElement( 31185 "li", 31186 { 31187 key: item.slug, 31188 className: "guidelines__list-item", 31189 "data-slug": item.slug 31190 }, 31191 /* @__PURE__ */ React.createElement( 31192 GuidelineAccordion, 31193 { 31194 title: item.title, 31195 description: item.description 31196 }, 31197 item.slug === "blocks" ? /* @__PURE__ */ React.createElement(BlockGuidelines, null) : /* @__PURE__ */ React.createElement( 31198 GuidelineAccordionForm, 31199 { 31200 slug: item.slug 31201 } 31202 ) 31203 ) 31204 ))), /* @__PURE__ */ React.createElement(GuidelineActionsSection, null))), /* @__PURE__ */ React.createElement(import_components59.Navigator.Screen, { path: "/revision-history" }, /* @__PURE__ */ React.createElement(RevisionHistory, null))) 31205 ); 31206 } 31207 var stage = GuidelinesPage; 31208 export { 31209 stage 31210 }; 31211 /*! Bundled license information: 31212 31213 use-sync-external-store/cjs/use-sync-external-store-shim.development.js: 31214 (** 31215 * @license React 31216 * use-sync-external-store-shim.development.js 31217 * 31218 * Copyright (c) Meta Platforms, Inc. and affiliates. 31219 * 31220 * This source code is licensed under the MIT license found in the 31221 * LICENSE file in the root directory of this source tree. 31222 *) 31223 31224 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js: 31225 (** 31226 * @license React 31227 * use-sync-external-store-shim/with-selector.development.js 31228 * 31229 * Copyright (c) Meta Platforms, Inc. and affiliates. 31230 * 31231 * This source code is licensed under the MIT license found in the 31232 * LICENSE file in the root directory of this source tree. 31233 *) 31234 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed Jul 15 08:20:16 2026 | Cross-referenced by PHPXref |