[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> media-utils.js (source)

   1  (function() {
   2  "use strict";
   3  var wp;
   4  (wp ||= {}).mediaUtils = (() => {
   5    var __create = Object.create;
   6    var __defProp = Object.defineProperty;
   7    var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
   8    var __getOwnPropNames = Object.getOwnPropertyNames;
   9    var __getProtoOf = Object.getPrototypeOf;
  10    var __hasOwnProp = Object.prototype.hasOwnProperty;
  11    var __commonJS = (cb, mod) => function __require() {
  12      return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  13    };
  14    var __export = (target, all) => {
  15      for (var name in all)
  16        __defProp(target, name, { get: all[name], enumerable: true });
  17    };
  18    var __copyProps = (to, from, except, desc) => {
  19      if (from && typeof from === "object" || typeof from === "function") {
  20        for (let key of __getOwnPropNames(from))
  21          if (!__hasOwnProp.call(to, key) && key !== except)
  22            __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  23      }
  24      return to;
  25    };
  26    var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  27      // If the importer is in node compatibility mode or this is not an ESM
  28      // file that has been converted to a CommonJS file using a Babel-
  29      // compatible transform (i.e. "__esModule" has not been set), then set
  30      // "default" to the CommonJS "module.exports" for node compatibility.
  31      isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  32      mod
  33    ));
  34    var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  35  
  36    // package-external:@wordpress/element
  37    var require_element = __commonJS({
  38      "package-external:@wordpress/element"(exports, module) {
  39        module.exports = window.wp.element;
  40      }
  41    });
  42  
  43    // package-external:@wordpress/i18n
  44    var require_i18n = __commonJS({
  45      "package-external:@wordpress/i18n"(exports, module) {
  46        module.exports = window.wp.i18n;
  47      }
  48    });
  49  
  50    // package-external:@wordpress/data
  51    var require_data = __commonJS({
  52      "package-external:@wordpress/data"(exports, module) {
  53        module.exports = window.wp.data;
  54      }
  55    });
  56  
  57    // package-external:@wordpress/core-data
  58    var require_core_data = __commonJS({
  59      "package-external:@wordpress/core-data"(exports, module) {
  60        module.exports = window.wp.coreData;
  61      }
  62    });
  63  
  64    // package-external:@wordpress/blob
  65    var require_blob = __commonJS({
  66      "package-external:@wordpress/blob"(exports, module) {
  67        module.exports = window.wp.blob;
  68      }
  69    });
  70  
  71    // package-external:@wordpress/api-fetch
  72    var require_api_fetch = __commonJS({
  73      "package-external:@wordpress/api-fetch"(exports, module) {
  74        module.exports = window.wp.apiFetch;
  75      }
  76    });
  77  
  78    // package-external:@wordpress/components
  79    var require_components = __commonJS({
  80      "package-external:@wordpress/components"(exports, module) {
  81        module.exports = window.wp.components;
  82      }
  83    });
  84  
  85    // package-external:@wordpress/primitives
  86    var require_primitives = __commonJS({
  87      "package-external:@wordpress/primitives"(exports, module) {
  88        module.exports = window.wp.primitives;
  89      }
  90    });
  91  
  92    // vendor-external:react/jsx-runtime
  93    var require_jsx_runtime = __commonJS({
  94      "vendor-external:react/jsx-runtime"(exports, module) {
  95        module.exports = window.ReactJSXRuntime;
  96      }
  97    });
  98  
  99    // package-external:@wordpress/compose
 100    var require_compose = __commonJS({
 101      "package-external:@wordpress/compose"(exports, module) {
 102        module.exports = window.wp.compose;
 103      }
 104    });
 105  
 106    // vendor-external:react
 107    var require_react = __commonJS({
 108      "vendor-external:react"(exports, module) {
 109        module.exports = window.React;
 110      }
 111    });
 112  
 113    // vendor-external:react-dom
 114    var require_react_dom = __commonJS({
 115      "vendor-external:react-dom"(exports, module) {
 116        module.exports = window.ReactDOM;
 117      }
 118    });
 119  
 120    // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
 121    var require_use_sync_external_store_shim_development = __commonJS({
 122      "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
 123        "use strict";
 124        (function() {
 125          function is(x2, y2) {
 126            return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
 127          }
 128          function useSyncExternalStore$2(subscribe2, getSnapshot) {
 129            didWarnOld18Alpha || void 0 === React49.startTransition || (didWarnOld18Alpha = true, console.error(
 130              "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."
 131            ));
 132            var value = getSnapshot();
 133            if (!didWarnUncachedGetSnapshot) {
 134              var cachedValue = getSnapshot();
 135              objectIs(value, cachedValue) || (console.error(
 136                "The result of getSnapshot should be cached to avoid an infinite loop"
 137              ), didWarnUncachedGetSnapshot = true);
 138            }
 139            cachedValue = useState43({
 140              inst: { value, getSnapshot }
 141            });
 142            var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
 143            useLayoutEffect6(
 144              function() {
 145                inst.value = value;
 146                inst.getSnapshot = getSnapshot;
 147                checkIfSnapshotChanged(inst) && forceUpdate({ inst });
 148              },
 149              [subscribe2, value, getSnapshot]
 150            );
 151            useEffect36(
 152              function() {
 153                checkIfSnapshotChanged(inst) && forceUpdate({ inst });
 154                return subscribe2(function() {
 155                  checkIfSnapshotChanged(inst) && forceUpdate({ inst });
 156                });
 157              },
 158              [subscribe2]
 159            );
 160            useDebugValue2(value);
 161            return value;
 162          }
 163          function checkIfSnapshotChanged(inst) {
 164            var latestGetSnapshot = inst.getSnapshot;
 165            inst = inst.value;
 166            try {
 167              var nextValue = latestGetSnapshot();
 168              return !objectIs(inst, nextValue);
 169            } catch (error) {
 170              return true;
 171            }
 172          }
 173          function useSyncExternalStore$1(subscribe2, getSnapshot) {
 174            return getSnapshot();
 175          }
 176          "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
 177          var React49 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState43 = React49.useState, useEffect36 = React49.useEffect, useLayoutEffect6 = React49.useLayoutEffect, useDebugValue2 = React49.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
 178          exports.useSyncExternalStore = void 0 !== React49.useSyncExternalStore ? React49.useSyncExternalStore : shim;
 179          "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
 180        })();
 181      }
 182    });
 183  
 184    // node_modules/use-sync-external-store/shim/index.js
 185    var require_shim = __commonJS({
 186      "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
 187        "use strict";
 188        if (false) {
 189          module.exports = null;
 190        } else {
 191          module.exports = require_use_sync_external_store_shim_development();
 192        }
 193      }
 194    });
 195  
 196    // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
 197    var require_with_selector_development = __commonJS({
 198      "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
 199        "use strict";
 200        (function() {
 201          function is(x2, y2) {
 202            return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
 203          }
 204          "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
 205          var React49 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef51 = React49.useRef, useEffect36 = React49.useEffect, useMemo43 = React49.useMemo, useDebugValue2 = React49.useDebugValue;
 206          exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
 207            var instRef = useRef51(null);
 208            if (null === instRef.current) {
 209              var inst = { hasValue: false, value: null };
 210              instRef.current = inst;
 211            } else inst = instRef.current;
 212            instRef = useMemo43(
 213              function() {
 214                function memoizedSelector(nextSnapshot) {
 215                  if (!hasMemo) {
 216                    hasMemo = true;
 217                    memoizedSnapshot = nextSnapshot;
 218                    nextSnapshot = selector2(nextSnapshot);
 219                    if (void 0 !== isEqual && inst.hasValue) {
 220                      var currentSelection = inst.value;
 221                      if (isEqual(currentSelection, nextSnapshot))
 222                        return memoizedSelection = currentSelection;
 223                    }
 224                    return memoizedSelection = nextSnapshot;
 225                  }
 226                  currentSelection = memoizedSelection;
 227                  if (objectIs(memoizedSnapshot, nextSnapshot))
 228                    return currentSelection;
 229                  var nextSelection = selector2(nextSnapshot);
 230                  if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
 231                    return memoizedSnapshot = nextSnapshot, currentSelection;
 232                  memoizedSnapshot = nextSnapshot;
 233                  return memoizedSelection = nextSelection;
 234                }
 235                var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
 236                return [
 237                  function() {
 238                    return memoizedSelector(getSnapshot());
 239                  },
 240                  null === maybeGetServerSnapshot ? void 0 : function() {
 241                    return memoizedSelector(maybeGetServerSnapshot());
 242                  }
 243                ];
 244              },
 245              [getSnapshot, getServerSnapshot, selector2, isEqual]
 246            );
 247            var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
 248            useEffect36(
 249              function() {
 250                inst.hasValue = true;
 251                inst.value = value;
 252              },
 253              [value]
 254            );
 255            useDebugValue2(value);
 256            return value;
 257          };
 258          "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
 259        })();
 260      }
 261    });
 262  
 263    // node_modules/use-sync-external-store/shim/with-selector.js
 264    var require_with_selector = __commonJS({
 265      "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
 266        "use strict";
 267        if (false) {
 268          module.exports = null;
 269        } else {
 270          module.exports = require_with_selector_development();
 271        }
 272      }
 273    });
 274  
 275    // package-external:@wordpress/a11y
 276    var require_a11y = __commonJS({
 277      "package-external:@wordpress/a11y"(exports, module) {
 278        module.exports = window.wp.a11y;
 279      }
 280    });
 281  
 282    // package-external:@wordpress/theme
 283    var require_theme = __commonJS({
 284      "package-external:@wordpress/theme"(exports, module) {
 285        module.exports = window.wp.theme;
 286      }
 287    });
 288  
 289    // package-external:@wordpress/private-apis
 290    var require_private_apis = __commonJS({
 291      "package-external:@wordpress/private-apis"(exports, module) {
 292        module.exports = window.wp.privateApis;
 293      }
 294    });
 295  
 296    // package-external:@wordpress/keycodes
 297    var require_keycodes = __commonJS({
 298      "package-external:@wordpress/keycodes"(exports, module) {
 299        module.exports = window.wp.keycodes;
 300      }
 301    });
 302  
 303    // node_modules/remove-accents/index.js
 304    var require_remove_accents = __commonJS({
 305      "node_modules/remove-accents/index.js"(exports, module) {
 306        var characterMap = {
 307          "\xC0": "A",
 308          "\xC1": "A",
 309          "\xC2": "A",
 310          "\xC3": "A",
 311          "\xC4": "A",
 312          "\xC5": "A",
 313          "\u1EA4": "A",
 314          "\u1EAE": "A",
 315          "\u1EB2": "A",
 316          "\u1EB4": "A",
 317          "\u1EB6": "A",
 318          "\xC6": "AE",
 319          "\u1EA6": "A",
 320          "\u1EB0": "A",
 321          "\u0202": "A",
 322          "\u1EA2": "A",
 323          "\u1EA0": "A",
 324          "\u1EA8": "A",
 325          "\u1EAA": "A",
 326          "\u1EAC": "A",
 327          "\xC7": "C",
 328          "\u1E08": "C",
 329          "\xC8": "E",
 330          "\xC9": "E",
 331          "\xCA": "E",
 332          "\xCB": "E",
 333          "\u1EBE": "E",
 334          "\u1E16": "E",
 335          "\u1EC0": "E",
 336          "\u1E14": "E",
 337          "\u1E1C": "E",
 338          "\u0206": "E",
 339          "\u1EBA": "E",
 340          "\u1EBC": "E",
 341          "\u1EB8": "E",
 342          "\u1EC2": "E",
 343          "\u1EC4": "E",
 344          "\u1EC6": "E",
 345          "\xCC": "I",
 346          "\xCD": "I",
 347          "\xCE": "I",
 348          "\xCF": "I",
 349          "\u1E2E": "I",
 350          "\u020A": "I",
 351          "\u1EC8": "I",
 352          "\u1ECA": "I",
 353          "\xD0": "D",
 354          "\xD1": "N",
 355          "\xD2": "O",
 356          "\xD3": "O",
 357          "\xD4": "O",
 358          "\xD5": "O",
 359          "\xD6": "O",
 360          "\xD8": "O",
 361          "\u1ED0": "O",
 362          "\u1E4C": "O",
 363          "\u1E52": "O",
 364          "\u020E": "O",
 365          "\u1ECE": "O",
 366          "\u1ECC": "O",
 367          "\u1ED4": "O",
 368          "\u1ED6": "O",
 369          "\u1ED8": "O",
 370          "\u1EDC": "O",
 371          "\u1EDE": "O",
 372          "\u1EE0": "O",
 373          "\u1EDA": "O",
 374          "\u1EE2": "O",
 375          "\xD9": "U",
 376          "\xDA": "U",
 377          "\xDB": "U",
 378          "\xDC": "U",
 379          "\u1EE6": "U",
 380          "\u1EE4": "U",
 381          "\u1EEC": "U",
 382          "\u1EEE": "U",
 383          "\u1EF0": "U",
 384          "\xDD": "Y",
 385          "\xE0": "a",
 386          "\xE1": "a",
 387          "\xE2": "a",
 388          "\xE3": "a",
 389          "\xE4": "a",
 390          "\xE5": "a",
 391          "\u1EA5": "a",
 392          "\u1EAF": "a",
 393          "\u1EB3": "a",
 394          "\u1EB5": "a",
 395          "\u1EB7": "a",
 396          "\xE6": "ae",
 397          "\u1EA7": "a",
 398          "\u1EB1": "a",
 399          "\u0203": "a",
 400          "\u1EA3": "a",
 401          "\u1EA1": "a",
 402          "\u1EA9": "a",
 403          "\u1EAB": "a",
 404          "\u1EAD": "a",
 405          "\xE7": "c",
 406          "\u1E09": "c",
 407          "\xE8": "e",
 408          "\xE9": "e",
 409          "\xEA": "e",
 410          "\xEB": "e",
 411          "\u1EBF": "e",
 412          "\u1E17": "e",
 413          "\u1EC1": "e",
 414          "\u1E15": "e",
 415          "\u1E1D": "e",
 416          "\u0207": "e",
 417          "\u1EBB": "e",
 418          "\u1EBD": "e",
 419          "\u1EB9": "e",
 420          "\u1EC3": "e",
 421          "\u1EC5": "e",
 422          "\u1EC7": "e",
 423          "\xEC": "i",
 424          "\xED": "i",
 425          "\xEE": "i",
 426          "\xEF": "i",
 427          "\u1E2F": "i",
 428          "\u020B": "i",
 429          "\u1EC9": "i",
 430          "\u1ECB": "i",
 431          "\xF0": "d",
 432          "\xF1": "n",
 433          "\xF2": "o",
 434          "\xF3": "o",
 435          "\xF4": "o",
 436          "\xF5": "o",
 437          "\xF6": "o",
 438          "\xF8": "o",
 439          "\u1ED1": "o",
 440          "\u1E4D": "o",
 441          "\u1E53": "o",
 442          "\u020F": "o",
 443          "\u1ECF": "o",
 444          "\u1ECD": "o",
 445          "\u1ED5": "o",
 446          "\u1ED7": "o",
 447          "\u1ED9": "o",
 448          "\u1EDD": "o",
 449          "\u1EDF": "o",
 450          "\u1EE1": "o",
 451          "\u1EDB": "o",
 452          "\u1EE3": "o",
 453          "\xF9": "u",
 454          "\xFA": "u",
 455          "\xFB": "u",
 456          "\xFC": "u",
 457          "\u1EE7": "u",
 458          "\u1EE5": "u",
 459          "\u1EED": "u",
 460          "\u1EEF": "u",
 461          "\u1EF1": "u",
 462          "\xFD": "y",
 463          "\xFF": "y",
 464          "\u0100": "A",
 465          "\u0101": "a",
 466          "\u0102": "A",
 467          "\u0103": "a",
 468          "\u0104": "A",
 469          "\u0105": "a",
 470          "\u0106": "C",
 471          "\u0107": "c",
 472          "\u0108": "C",
 473          "\u0109": "c",
 474          "\u010A": "C",
 475          "\u010B": "c",
 476          "\u010C": "C",
 477          "\u010D": "c",
 478          "C\u0306": "C",
 479          "c\u0306": "c",
 480          "\u010E": "D",
 481          "\u010F": "d",
 482          "\u0110": "D",
 483          "\u0111": "d",
 484          "\u0112": "E",
 485          "\u0113": "e",
 486          "\u0114": "E",
 487          "\u0115": "e",
 488          "\u0116": "E",
 489          "\u0117": "e",
 490          "\u0118": "E",
 491          "\u0119": "e",
 492          "\u011A": "E",
 493          "\u011B": "e",
 494          "\u011C": "G",
 495          "\u01F4": "G",
 496          "\u011D": "g",
 497          "\u01F5": "g",
 498          "\u011E": "G",
 499          "\u011F": "g",
 500          "\u0120": "G",
 501          "\u0121": "g",
 502          "\u0122": "G",
 503          "\u0123": "g",
 504          "\u0124": "H",
 505          "\u0125": "h",
 506          "\u0126": "H",
 507          "\u0127": "h",
 508          "\u1E2A": "H",
 509          "\u1E2B": "h",
 510          "\u0128": "I",
 511          "\u0129": "i",
 512          "\u012A": "I",
 513          "\u012B": "i",
 514          "\u012C": "I",
 515          "\u012D": "i",
 516          "\u012E": "I",
 517          "\u012F": "i",
 518          "\u0130": "I",
 519          "\u0131": "i",
 520          "\u0132": "IJ",
 521          "\u0133": "ij",
 522          "\u0134": "J",
 523          "\u0135": "j",
 524          "\u0136": "K",
 525          "\u0137": "k",
 526          "\u1E30": "K",
 527          "\u1E31": "k",
 528          "K\u0306": "K",
 529          "k\u0306": "k",
 530          "\u0139": "L",
 531          "\u013A": "l",
 532          "\u013B": "L",
 533          "\u013C": "l",
 534          "\u013D": "L",
 535          "\u013E": "l",
 536          "\u013F": "L",
 537          "\u0140": "l",
 538          "\u0141": "l",
 539          "\u0142": "l",
 540          "\u1E3E": "M",
 541          "\u1E3F": "m",
 542          "M\u0306": "M",
 543          "m\u0306": "m",
 544          "\u0143": "N",
 545          "\u0144": "n",
 546          "\u0145": "N",
 547          "\u0146": "n",
 548          "\u0147": "N",
 549          "\u0148": "n",
 550          "\u0149": "n",
 551          "N\u0306": "N",
 552          "n\u0306": "n",
 553          "\u014C": "O",
 554          "\u014D": "o",
 555          "\u014E": "O",
 556          "\u014F": "o",
 557          "\u0150": "O",
 558          "\u0151": "o",
 559          "\u0152": "OE",
 560          "\u0153": "oe",
 561          "P\u0306": "P",
 562          "p\u0306": "p",
 563          "\u0154": "R",
 564          "\u0155": "r",
 565          "\u0156": "R",
 566          "\u0157": "r",
 567          "\u0158": "R",
 568          "\u0159": "r",
 569          "R\u0306": "R",
 570          "r\u0306": "r",
 571          "\u0212": "R",
 572          "\u0213": "r",
 573          "\u015A": "S",
 574          "\u015B": "s",
 575          "\u015C": "S",
 576          "\u015D": "s",
 577          "\u015E": "S",
 578          "\u0218": "S",
 579          "\u0219": "s",
 580          "\u015F": "s",
 581          "\u0160": "S",
 582          "\u0161": "s",
 583          "\u0162": "T",
 584          "\u0163": "t",
 585          "\u021B": "t",
 586          "\u021A": "T",
 587          "\u0164": "T",
 588          "\u0165": "t",
 589          "\u0166": "T",
 590          "\u0167": "t",
 591          "T\u0306": "T",
 592          "t\u0306": "t",
 593          "\u0168": "U",
 594          "\u0169": "u",
 595          "\u016A": "U",
 596          "\u016B": "u",
 597          "\u016C": "U",
 598          "\u016D": "u",
 599          "\u016E": "U",
 600          "\u016F": "u",
 601          "\u0170": "U",
 602          "\u0171": "u",
 603          "\u0172": "U",
 604          "\u0173": "u",
 605          "\u0216": "U",
 606          "\u0217": "u",
 607          "V\u0306": "V",
 608          "v\u0306": "v",
 609          "\u0174": "W",
 610          "\u0175": "w",
 611          "\u1E82": "W",
 612          "\u1E83": "w",
 613          "X\u0306": "X",
 614          "x\u0306": "x",
 615          "\u0176": "Y",
 616          "\u0177": "y",
 617          "\u0178": "Y",
 618          "Y\u0306": "Y",
 619          "y\u0306": "y",
 620          "\u0179": "Z",
 621          "\u017A": "z",
 622          "\u017B": "Z",
 623          "\u017C": "z",
 624          "\u017D": "Z",
 625          "\u017E": "z",
 626          "\u017F": "s",
 627          "\u0192": "f",
 628          "\u01A0": "O",
 629          "\u01A1": "o",
 630          "\u01AF": "U",
 631          "\u01B0": "u",
 632          "\u01CD": "A",
 633          "\u01CE": "a",
 634          "\u01CF": "I",
 635          "\u01D0": "i",
 636          "\u01D1": "O",
 637          "\u01D2": "o",
 638          "\u01D3": "U",
 639          "\u01D4": "u",
 640          "\u01D5": "U",
 641          "\u01D6": "u",
 642          "\u01D7": "U",
 643          "\u01D8": "u",
 644          "\u01D9": "U",
 645          "\u01DA": "u",
 646          "\u01DB": "U",
 647          "\u01DC": "u",
 648          "\u1EE8": "U",
 649          "\u1EE9": "u",
 650          "\u1E78": "U",
 651          "\u1E79": "u",
 652          "\u01FA": "A",
 653          "\u01FB": "a",
 654          "\u01FC": "AE",
 655          "\u01FD": "ae",
 656          "\u01FE": "O",
 657          "\u01FF": "o",
 658          "\xDE": "TH",
 659          "\xFE": "th",
 660          "\u1E54": "P",
 661          "\u1E55": "p",
 662          "\u1E64": "S",
 663          "\u1E65": "s",
 664          "X\u0301": "X",
 665          "x\u0301": "x",
 666          "\u0403": "\u0413",
 667          "\u0453": "\u0433",
 668          "\u040C": "\u041A",
 669          "\u045C": "\u043A",
 670          "A\u030B": "A",
 671          "a\u030B": "a",
 672          "E\u030B": "E",
 673          "e\u030B": "e",
 674          "I\u030B": "I",
 675          "i\u030B": "i",
 676          "\u01F8": "N",
 677          "\u01F9": "n",
 678          "\u1ED2": "O",
 679          "\u1ED3": "o",
 680          "\u1E50": "O",
 681          "\u1E51": "o",
 682          "\u1EEA": "U",
 683          "\u1EEB": "u",
 684          "\u1E80": "W",
 685          "\u1E81": "w",
 686          "\u1EF2": "Y",
 687          "\u1EF3": "y",
 688          "\u0200": "A",
 689          "\u0201": "a",
 690          "\u0204": "E",
 691          "\u0205": "e",
 692          "\u0208": "I",
 693          "\u0209": "i",
 694          "\u020C": "O",
 695          "\u020D": "o",
 696          "\u0210": "R",
 697          "\u0211": "r",
 698          "\u0214": "U",
 699          "\u0215": "u",
 700          "B\u030C": "B",
 701          "b\u030C": "b",
 702          "\u010C\u0323": "C",
 703          "\u010D\u0323": "c",
 704          "\xCA\u030C": "E",
 705          "\xEA\u030C": "e",
 706          "F\u030C": "F",
 707          "f\u030C": "f",
 708          "\u01E6": "G",
 709          "\u01E7": "g",
 710          "\u021E": "H",
 711          "\u021F": "h",
 712          "J\u030C": "J",
 713          "\u01F0": "j",
 714          "\u01E8": "K",
 715          "\u01E9": "k",
 716          "M\u030C": "M",
 717          "m\u030C": "m",
 718          "P\u030C": "P",
 719          "p\u030C": "p",
 720          "Q\u030C": "Q",
 721          "q\u030C": "q",
 722          "\u0158\u0329": "R",
 723          "\u0159\u0329": "r",
 724          "\u1E66": "S",
 725          "\u1E67": "s",
 726          "V\u030C": "V",
 727          "v\u030C": "v",
 728          "W\u030C": "W",
 729          "w\u030C": "w",
 730          "X\u030C": "X",
 731          "x\u030C": "x",
 732          "Y\u030C": "Y",
 733          "y\u030C": "y",
 734          "A\u0327": "A",
 735          "a\u0327": "a",
 736          "B\u0327": "B",
 737          "b\u0327": "b",
 738          "\u1E10": "D",
 739          "\u1E11": "d",
 740          "\u0228": "E",
 741          "\u0229": "e",
 742          "\u0190\u0327": "E",
 743          "\u025B\u0327": "e",
 744          "\u1E28": "H",
 745          "\u1E29": "h",
 746          "I\u0327": "I",
 747          "i\u0327": "i",
 748          "\u0197\u0327": "I",
 749          "\u0268\u0327": "i",
 750          "M\u0327": "M",
 751          "m\u0327": "m",
 752          "O\u0327": "O",
 753          "o\u0327": "o",
 754          "Q\u0327": "Q",
 755          "q\u0327": "q",
 756          "U\u0327": "U",
 757          "u\u0327": "u",
 758          "X\u0327": "X",
 759          "x\u0327": "x",
 760          "Z\u0327": "Z",
 761          "z\u0327": "z",
 762          "\u0439": "\u0438",
 763          "\u0419": "\u0418",
 764          "\u0451": "\u0435",
 765          "\u0401": "\u0415"
 766        };
 767        var chars = Object.keys(characterMap).join("|");
 768        var allAccents = new RegExp(chars, "g");
 769        var firstAccent = new RegExp(chars, "");
 770        function matcher(match2) {
 771          return characterMap[match2];
 772        }
 773        var removeAccents2 = function(string) {
 774          return string.replace(allAccents, matcher);
 775        };
 776        var hasAccents = function(string) {
 777          return !!string.match(firstAccent);
 778        };
 779        module.exports = removeAccents2;
 780        module.exports.has = hasAccents;
 781        module.exports.remove = removeAccents2;
 782      }
 783    });
 784  
 785    // node_modules/fast-deep-equal/es6/index.js
 786    var require_es6 = __commonJS({
 787      "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
 788        "use strict";
 789        module.exports = function equal(a2, b2) {
 790          if (a2 === b2) return true;
 791          if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
 792            if (a2.constructor !== b2.constructor) return false;
 793            var length, i2, keys;
 794            if (Array.isArray(a2)) {
 795              length = a2.length;
 796              if (length != b2.length) return false;
 797              for (i2 = length; i2-- !== 0; )
 798                if (!equal(a2[i2], b2[i2])) return false;
 799              return true;
 800            }
 801            if (a2 instanceof Map && b2 instanceof Map) {
 802              if (a2.size !== b2.size) return false;
 803              for (i2 of a2.entries())
 804                if (!b2.has(i2[0])) return false;
 805              for (i2 of a2.entries())
 806                if (!equal(i2[1], b2.get(i2[0]))) return false;
 807              return true;
 808            }
 809            if (a2 instanceof Set && b2 instanceof Set) {
 810              if (a2.size !== b2.size) return false;
 811              for (i2 of a2.entries())
 812                if (!b2.has(i2[0])) return false;
 813              return true;
 814            }
 815            if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
 816              length = a2.length;
 817              if (length != b2.length) return false;
 818              for (i2 = length; i2-- !== 0; )
 819                if (a2[i2] !== b2[i2]) return false;
 820              return true;
 821            }
 822            if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
 823            if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
 824            if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
 825            keys = Object.keys(a2);
 826            length = keys.length;
 827            if (length !== Object.keys(b2).length) return false;
 828            for (i2 = length; i2-- !== 0; )
 829              if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
 830            for (i2 = length; i2-- !== 0; ) {
 831              var key = keys[i2];
 832              if (!equal(a2[key], b2[key])) return false;
 833            }
 834            return true;
 835          }
 836          return a2 !== a2 && b2 !== b2;
 837        };
 838      }
 839    });
 840  
 841    // package-external:@wordpress/date
 842    var require_date = __commonJS({
 843      "package-external:@wordpress/date"(exports, module) {
 844        module.exports = window.wp.date;
 845      }
 846    });
 847  
 848    // package-external:@wordpress/warning
 849    var require_warning = __commonJS({
 850      "package-external:@wordpress/warning"(exports, module) {
 851        module.exports = window.wp.warning;
 852      }
 853    });
 854  
 855    // package-external:@wordpress/rich-text
 856    var require_rich_text = __commonJS({
 857      "package-external:@wordpress/rich-text"(exports, module) {
 858        module.exports = window.wp.richText;
 859      }
 860    });
 861  
 862    // package-external:@wordpress/preferences
 863    var require_preferences = __commonJS({
 864      "package-external:@wordpress/preferences"(exports, module) {
 865        module.exports = window.wp.preferences;
 866      }
 867    });
 868  
 869    // package-external:@wordpress/url
 870    var require_url = __commonJS({
 871      "package-external:@wordpress/url"(exports, module) {
 872        module.exports = window.wp.url;
 873      }
 874    });
 875  
 876    // package-external:@wordpress/notices
 877    var require_notices = __commonJS({
 878      "package-external:@wordpress/notices"(exports, module) {
 879        module.exports = window.wp.notices;
 880      }
 881    });
 882  
 883    // packages/media-utils/build-module/index.mjs
 884    var index_exports = {};
 885    __export(index_exports, {
 886      MediaUpload: () => media_upload_default,
 887      privateApis: () => privateApis12,
 888      transformAttachment: () => transformAttachment,
 889      uploadMedia: () => uploadMedia,
 890      validateFileSize: () => validateFileSize,
 891      validateMimeType: () => validateMimeType,
 892      validateMimeTypeForUser: () => validateMimeTypeForUser
 893    });
 894  
 895    // packages/media-utils/build-module/components/media-upload/index.mjs
 896    var import_element = __toESM(require_element(), 1);
 897    var import_i18n = __toESM(require_i18n(), 1);
 898    var import_data = __toESM(require_data(), 1);
 899  
 900    // packages/media-utils/build-module/utils/invalidate-attachment-resolutions.mjs
 901    var import_core_data = __toESM(require_core_data(), 1);
 902    function invalidateAttachmentResolutions(registry) {
 903      const resolvers = registry.select(import_core_data.store).getCachedResolvers();
 904      const entityRecordResolutions = resolvers.getEntityRecords;
 905      entityRecordResolutions?.forEach((_value, args) => {
 906        if (args[0] === "postType" && args[1] === "attachment") {
 907          registry.dispatch(import_core_data.store).invalidateResolution("getEntityRecords", args);
 908        }
 909      });
 910    }
 911  
 912    // packages/media-utils/build-module/components/media-upload/index.mjs
 913    var DEFAULT_EMPTY_GALLERY = [];
 914    var getFeaturedImageMediaFrame = () => {
 915      const { wp } = window;
 916      return wp.media.view.MediaFrame.Select.extend({
 917        /**
 918         * Enables the Set Featured Image Button.
 919         *
 920         * @param {Object} toolbar toolbar for featured image state
 921         * @return {void}
 922         */
 923        featuredImageToolbar(toolbar) {
 924          this.createSelectToolbar(toolbar, {
 925            text: wp.media.view.l10n.setFeaturedImage,
 926            state: this.options.state
 927          });
 928        },
 929        /**
 930         * Handle the edit state requirements of selected media item.
 931         *
 932         * @return {void}
 933         */
 934        editState() {
 935          const selection = this.state("featured-image").get("selection");
 936          const view = new wp.media.view.EditImage({
 937            model: selection.single(),
 938            controller: this
 939          }).render();
 940          this.content.set(view);
 941          view.loadEditor();
 942        },
 943        /**
 944         * Create the default states.
 945         *
 946         * @return {void}
 947         */
 948        createStates: function createStates() {
 949          this.on(
 950            "toolbar:create:featured-image",
 951            this.featuredImageToolbar,
 952            this
 953          );
 954          this.on("content:render:edit-image", this.editState, this);
 955          this.states.add([
 956            new wp.media.controller.FeaturedImage(),
 957            new wp.media.controller.EditImage({
 958              model: this.options.editImage
 959            })
 960          ]);
 961        }
 962      });
 963    };
 964    var getSingleMediaFrame = () => {
 965      const { wp } = window;
 966      return wp.media.view.MediaFrame.Select.extend({
 967        /**
 968         * Create the default states on the frame.
 969         */
 970        createStates() {
 971          const options = this.options;
 972          if (this.options.states) {
 973            return;
 974          }
 975          this.states.add([
 976            // Main states.
 977            new wp.media.controller.Library({
 978              library: wp.media.query(options.library),
 979              multiple: options.multiple,
 980              title: options.title,
 981              priority: 20,
 982              filterable: "uploaded"
 983              // Allow filtering by uploaded images.
 984            }),
 985            new wp.media.controller.EditImage({
 986              model: options.editImage
 987            })
 988          ]);
 989        }
 990      });
 991    };
 992    var getGalleryDetailsMediaFrame = () => {
 993      const { wp } = window;
 994      return wp.media.view.MediaFrame.Post.extend({
 995        /**
 996         * Set up gallery toolbar.
 997         *
 998         * @return {void}
 999         */
1000        galleryToolbar() {
1001          const editing = this.state().get("editing");
1002          this.toolbar.set(
1003            new wp.media.view.Toolbar({
1004              controller: this,
1005              items: {
1006                insert: {
1007                  style: "primary",
1008                  text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery,
1009                  priority: 80,
1010                  requires: { library: true },
1011                  /**
1012                   * @fires wp.media.controller.State#update
1013                   */
1014                  click() {
1015                    const controller = this.controller, state = controller.state();
1016                    controller.close();
1017                    state.trigger(
1018                      "update",
1019                      state.get("library")
1020                    );
1021                    controller.setState(controller.options.state);
1022                    controller.reset();
1023                  }
1024                }
1025              }
1026            })
1027          );
1028        },
1029        /**
1030         * Handle the edit state requirements of selected media item.
1031         *
1032         * @return {void}
1033         */
1034        editState() {
1035          const selection = this.state("gallery").get("selection");
1036          const view = new wp.media.view.EditImage({
1037            model: selection.single(),
1038            controller: this
1039          }).render();
1040          this.content.set(view);
1041          view.loadEditor();
1042        },
1043        /**
1044         * Create the default states.
1045         *
1046         * @return {void}
1047         */
1048        createStates: function createStates() {
1049          this.on("toolbar:create:main-gallery", this.galleryToolbar, this);
1050          this.on("content:render:edit-image", this.editState, this);
1051          this.states.add([
1052            new wp.media.controller.Library({
1053              id: "gallery",
1054              title: wp.media.view.l10n.createGalleryTitle,
1055              priority: 40,
1056              toolbar: "main-gallery",
1057              filterable: "uploaded",
1058              multiple: "add",
1059              editable: false,
1060              library: wp.media.query({
1061                type: "image",
1062                ...this.options.library
1063              })
1064            }),
1065            new wp.media.controller.EditImage({
1066              model: this.options.editImage
1067            }),
1068            new wp.media.controller.GalleryEdit({
1069              library: this.options.selection,
1070              editing: this.options.editing,
1071              menu: "gallery",
1072              displaySettings: false,
1073              multiple: true
1074            }),
1075            new wp.media.controller.GalleryAdd()
1076          ]);
1077        }
1078      });
1079    };
1080    var slimImageObject = (img) => {
1081      const attrSet = [
1082        "sizes",
1083        "mime",
1084        "type",
1085        "subtype",
1086        "id",
1087        "url",
1088        "alt",
1089        "link",
1090        "caption"
1091      ];
1092      return attrSet.reduce((result, key) => {
1093        if (img?.hasOwnProperty(key)) {
1094          result[key] = img[key];
1095        }
1096        return result;
1097      }, {});
1098    };
1099    var getAttachmentsCollection = (ids) => {
1100      const { wp } = window;
1101      return wp.media.query({
1102        order: "ASC",
1103        orderby: "post__in",
1104        post__in: ids,
1105        posts_per_page: -1,
1106        query: true,
1107        type: "image"
1108      });
1109    };
1110    var MediaUpload = class extends import_element.Component {
1111      constructor() {
1112        super(...arguments);
1113        this.openModal = this.openModal.bind(this);
1114        this.onOpen = this.onOpen.bind(this);
1115        this.onSelect = this.onSelect.bind(this);
1116        this.onUpdate = this.onUpdate.bind(this);
1117        this.onClose = this.onClose.bind(this);
1118      }
1119      initializeListeners() {
1120        this.frame.on("select", this.onSelect);
1121        this.frame.on("update", this.onUpdate);
1122        this.frame.on("open", this.onOpen);
1123        this.frame.on("close", this.onClose);
1124      }
1125      /**
1126       * Sets the Gallery frame and initializes listeners.
1127       *
1128       * @return {void}
1129       */
1130      buildAndSetGalleryFrame() {
1131        const {
1132          addToGallery = false,
1133          allowedTypes,
1134          multiple = false,
1135          value = DEFAULT_EMPTY_GALLERY
1136        } = this.props;
1137        if (value === this.lastGalleryValue) {
1138          return;
1139        }
1140        const { wp } = window;
1141        this.lastGalleryValue = value;
1142        if (this.frame) {
1143          this.frame.remove();
1144        }
1145        let currentState;
1146        if (addToGallery) {
1147          currentState = "gallery-library";
1148        } else {
1149          currentState = value && value.length ? "gallery-edit" : "gallery";
1150        }
1151        if (!this.GalleryDetailsMediaFrame) {
1152          this.GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame();
1153        }
1154        const attachments = getAttachmentsCollection(value);
1155        const selection = new wp.media.model.Selection(attachments.models, {
1156          props: attachments.props.toJSON(),
1157          multiple
1158        });
1159        this.frame = new this.GalleryDetailsMediaFrame({
1160          mimeType: allowedTypes,
1161          state: currentState,
1162          multiple,
1163          selection,
1164          editing: !!value?.length
1165        });
1166        wp.media.frame = this.frame;
1167        this.initializeListeners();
1168      }
1169      /**
1170       * Initializes the Media Library requirements for the featured image flow.
1171       *
1172       * @return {void}
1173       */
1174      buildAndSetFeatureImageFrame() {
1175        const { wp } = window;
1176        const { value: featuredImageId, multiple, allowedTypes } = this.props;
1177        const featuredImageFrame = getFeaturedImageMediaFrame();
1178        const attachments = getAttachmentsCollection(featuredImageId);
1179        const selection = new wp.media.model.Selection(attachments.models, {
1180          props: attachments.props.toJSON()
1181        });
1182        this.frame = new featuredImageFrame({
1183          mimeType: allowedTypes,
1184          state: "featured-image",
1185          multiple,
1186          selection,
1187          editing: featuredImageId
1188        });
1189        wp.media.frame = this.frame;
1190        wp.media.view.settings.post = {
1191          ...wp.media.view.settings.post,
1192          featuredImageId: featuredImageId || -1
1193        };
1194      }
1195      /**
1196       * Initializes the Media Library requirements for the single image flow.
1197       *
1198       * @return {void}
1199       */
1200      buildAndSetSingleMediaFrame() {
1201        const { wp } = window;
1202        const {
1203          allowedTypes,
1204          multiple = false,
1205          title = (0, import_i18n.__)("Select or Upload Media"),
1206          value
1207        } = this.props;
1208        const frameConfig = {
1209          title,
1210          multiple
1211        };
1212        if (!!allowedTypes) {
1213          frameConfig.library = { type: allowedTypes };
1214        }
1215        if (this.frame) {
1216          this.frame.remove();
1217        }
1218        const singleImageFrame = getSingleMediaFrame();
1219        const attachments = getAttachmentsCollection(value);
1220        const selection = new wp.media.model.Selection(attachments.models, {
1221          props: attachments.props.toJSON()
1222        });
1223        this.frame = new singleImageFrame({
1224          mimeType: allowedTypes,
1225          multiple,
1226          selection,
1227          ...frameConfig
1228        });
1229        wp.media.frame = this.frame;
1230      }
1231      componentWillUnmount() {
1232        this.frame?.remove();
1233      }
1234      onUpdate(selections) {
1235        const { onSelect, multiple = false } = this.props;
1236        const state = this.frame.state();
1237        const selectedImages = selections || state.get("selection");
1238        if (!selectedImages || !selectedImages.models.length) {
1239          return;
1240        }
1241        if (multiple) {
1242          onSelect(
1243            selectedImages.models.map(
1244              (model) => slimImageObject(model.toJSON())
1245            )
1246          );
1247        } else {
1248          onSelect(slimImageObject(selectedImages.models[0].toJSON()));
1249        }
1250      }
1251      onSelect() {
1252        const { onSelect, multiple = false } = this.props;
1253        const attachment = this.frame.state().get("selection").toJSON();
1254        onSelect(multiple ? attachment : attachment[0]);
1255      }
1256      onOpen() {
1257        const { wp } = window;
1258        const { value } = this.props;
1259        this.updateCollection();
1260        if (this.props.mode) {
1261          this.frame.content.mode(this.props.mode);
1262        }
1263        const hasMedia = Array.isArray(value) ? !!value?.length : !!value;
1264        if (!hasMedia) {
1265          return;
1266        }
1267        const isGallery = this.props.gallery;
1268        const selection = this.frame.state().get("selection");
1269        const valueArray = Array.isArray(value) ? value : [value];
1270        if (!isGallery) {
1271          valueArray.forEach((id) => {
1272            selection.add(wp.media.attachment(id));
1273          });
1274        }
1275        const attachments = getAttachmentsCollection(valueArray);
1276        attachments.more().done(function() {
1277          if (isGallery && attachments?.models?.length) {
1278            selection.add(attachments.models);
1279          }
1280        });
1281      }
1282      onClose() {
1283        const { onClose } = this.props;
1284        if (onClose) {
1285          onClose();
1286        }
1287        invalidateAttachmentResolutions({ select: import_data.select, dispatch: import_data.dispatch });
1288        this.frame.detach();
1289      }
1290      updateCollection() {
1291        const frameContent = this.frame.content.get();
1292        if (frameContent && frameContent.collection) {
1293          const collection = frameContent.collection;
1294          collection.toArray().forEach((model) => model.trigger("destroy", model));
1295          collection.mirroring._hasMore = true;
1296          collection.more();
1297        }
1298      }
1299      openModal() {
1300        const {
1301          gallery = false,
1302          unstableFeaturedImageFlow = false,
1303          modalClass
1304        } = this.props;
1305        if (gallery) {
1306          this.buildAndSetGalleryFrame();
1307        } else {
1308          this.buildAndSetSingleMediaFrame();
1309        }
1310        if (modalClass) {
1311          this.frame.$el.addClass(modalClass);
1312        }
1313        if (unstableFeaturedImageFlow) {
1314          this.buildAndSetFeatureImageFrame();
1315        }
1316        this.initializeListeners();
1317        this.frame.open();
1318      }
1319      render() {
1320        return this.props.render({ open: this.openModal });
1321      }
1322    };
1323    var media_upload_default = MediaUpload;
1324  
1325    // packages/media-utils/build-module/utils/upload-media.mjs
1326    var import_i18n5 = __toESM(require_i18n(), 1);
1327    var import_blob = __toESM(require_blob(), 1);
1328  
1329    // packages/media-utils/build-module/utils/upload-to-server.mjs
1330    var import_api_fetch = __toESM(require_api_fetch(), 1);
1331  
1332    // packages/media-utils/build-module/utils/flatten-form-data.mjs
1333    function isPlainObject(data) {
1334      return data !== null && typeof data === "object" && Object.getPrototypeOf(data) === Object.prototype;
1335    }
1336    function flattenFormData(formData, key, data) {
1337      if (isPlainObject(data)) {
1338        for (const [name, value] of Object.entries(data)) {
1339          flattenFormData(formData, `$key}[$name}]`, value);
1340        }
1341      } else if (data !== void 0) {
1342        formData.append(key, String(data));
1343      }
1344    }
1345  
1346    // packages/media-utils/build-module/utils/transform-attachment.mjs
1347    function transformAttachment(attachment) {
1348      const { alt_text, source_url, ...savedMediaProps } = attachment;
1349      return {
1350        ...savedMediaProps,
1351        alt: attachment.alt_text,
1352        caption: attachment.caption?.raw ?? "",
1353        title: attachment.title.raw,
1354        url: attachment.source_url,
1355        poster: attachment._embedded?.["wp:featuredmedia"]?.[0]?.source_url || void 0
1356      };
1357    }
1358  
1359    // packages/media-utils/build-module/utils/upload-to-server.mjs
1360    async function uploadToServer(file, additionalData = {}, signal) {
1361      const data = new FormData();
1362      data.append("file", file, file.name || file.type.replace("/", "."));
1363      for (const [key, value] of Object.entries(additionalData)) {
1364        flattenFormData(
1365          data,
1366          key,
1367          value
1368        );
1369      }
1370      return transformAttachment(
1371        await (0, import_api_fetch.default)({
1372          // This allows the video block to directly get a video's poster image.
1373          path: "/wp/v2/media?_embed=wp:featuredmedia",
1374          body: data,
1375          method: "POST",
1376          signal
1377        })
1378      );
1379    }
1380  
1381    // packages/media-utils/build-module/utils/validate-mime-type.mjs
1382    var import_i18n2 = __toESM(require_i18n(), 1);
1383  
1384    // packages/media-utils/build-module/utils/upload-error.mjs
1385    var UploadError = class extends Error {
1386      code;
1387      file;
1388      constructor({ code, message: message2, file, cause }) {
1389        super(message2, { cause });
1390        Object.setPrototypeOf(this, new.target.prototype);
1391        this.code = code;
1392        this.file = file;
1393      }
1394    };
1395  
1396    // packages/media-utils/build-module/utils/validate-mime-type.mjs
1397    function validateMimeType(file, allowedTypes) {
1398      if (!allowedTypes || allowedTypes.includes("*")) {
1399        return;
1400      }
1401      const isAllowedType = allowedTypes.some((allowedType) => {
1402        if (allowedType.includes("/")) {
1403          return allowedType === file.type;
1404        }
1405        return file.type.startsWith(`$allowedType}/`);
1406      });
1407      if (file.type && !isAllowedType) {
1408        throw new UploadError({
1409          code: "MIME_TYPE_NOT_SUPPORTED",
1410          message: (0, import_i18n2.sprintf)(
1411            // translators: %s: file name.
1412            (0, import_i18n2.__)("%s: Sorry, this file type is not supported here."),
1413            file.name
1414          ),
1415          file
1416        });
1417      }
1418    }
1419  
1420    // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1421    var import_i18n3 = __toESM(require_i18n(), 1);
1422  
1423    // packages/media-utils/build-module/utils/get-mime-types-array.mjs
1424    function getMimeTypesArray(wpMimeTypesObject) {
1425      if (!wpMimeTypesObject) {
1426        return null;
1427      }
1428      return Object.entries(wpMimeTypesObject).flatMap(
1429        ([extensionsString, mime]) => {
1430          const [type] = mime.split("/");
1431          const extensions = extensionsString.split("|");
1432          return [
1433            mime,
1434            ...extensions.map(
1435              (extension) => `$type}/$extension}`
1436            )
1437          ];
1438        }
1439      );
1440    }
1441  
1442    // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1443    function validateMimeTypeForUser(file, wpAllowedMimeTypes) {
1444      const allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes);
1445      if (!allowedMimeTypesForUser) {
1446        return;
1447      }
1448      const isAllowedMimeTypeForUser = allowedMimeTypesForUser.includes(
1449        file.type
1450      );
1451      if (file.type && !isAllowedMimeTypeForUser) {
1452        throw new UploadError({
1453          code: "MIME_TYPE_NOT_ALLOWED_FOR_USER",
1454          message: (0, import_i18n3.sprintf)(
1455            // translators: %s: file name.
1456            (0, import_i18n3.__)(
1457              "%s: Sorry, you are not allowed to upload this file type."
1458            ),
1459            file.name
1460          ),
1461          file
1462        });
1463      }
1464    }
1465  
1466    // packages/media-utils/build-module/utils/validate-file-size.mjs
1467    var import_i18n4 = __toESM(require_i18n(), 1);
1468    function validateFileSize(file, maxUploadFileSize) {
1469      if (file.size <= 0) {
1470        throw new UploadError({
1471          code: "EMPTY_FILE",
1472          message: (0, import_i18n4.sprintf)(
1473            // translators: %s: file name.
1474            (0, import_i18n4.__)("%s: This file is empty."),
1475            file.name
1476          ),
1477          file
1478        });
1479      }
1480      if (maxUploadFileSize && file.size > maxUploadFileSize) {
1481        throw new UploadError({
1482          code: "SIZE_ABOVE_LIMIT",
1483          message: (0, import_i18n4.sprintf)(
1484            // translators: %s: file name.
1485            (0, import_i18n4.__)(
1486              "%s: This file exceeds the maximum upload size for this site."
1487            ),
1488            file.name
1489          ),
1490          file
1491        });
1492      }
1493    }
1494  
1495    // packages/media-utils/build-module/utils/upload-media.mjs
1496    function uploadMedia({
1497      wpAllowedMimeTypes,
1498      allowedTypes,
1499      additionalData = {},
1500      filesList,
1501      maxUploadFileSize,
1502      onError,
1503      onFileChange,
1504      signal,
1505      multiple = true
1506    }) {
1507      if (!multiple && filesList.length > 1) {
1508        onError?.(new Error((0, import_i18n5.__)("Only one file can be used here.")));
1509        return;
1510      }
1511      const validFiles = [];
1512      const filesSet = [];
1513      const setAndUpdateFiles = (index2, value) => {
1514        if (!window.__clientSideMediaProcessing) {
1515          if (filesSet[index2]?.url) {
1516            (0, import_blob.revokeBlobURL)(filesSet[index2].url);
1517          }
1518        }
1519        filesSet[index2] = value;
1520        onFileChange?.(
1521          filesSet.filter((attachment) => attachment !== null)
1522        );
1523      };
1524      for (const mediaFile of filesList) {
1525        try {
1526          validateMimeTypeForUser(mediaFile, wpAllowedMimeTypes);
1527        } catch (error) {
1528          onError?.(error);
1529          continue;
1530        }
1531        try {
1532          validateMimeType(mediaFile, allowedTypes);
1533        } catch (error) {
1534          onError?.(error);
1535          continue;
1536        }
1537        try {
1538          validateFileSize(mediaFile, maxUploadFileSize);
1539        } catch (error) {
1540          onError?.(error);
1541          continue;
1542        }
1543        validFiles.push(mediaFile);
1544        if (!window.__clientSideMediaProcessing) {
1545          filesSet.push({ url: (0, import_blob.createBlobURL)(mediaFile) });
1546          onFileChange?.(filesSet);
1547        }
1548      }
1549      validFiles.map(async (file, index2) => {
1550        try {
1551          const attachment = await uploadToServer(
1552            file,
1553            additionalData,
1554            signal
1555          );
1556          setAndUpdateFiles(index2, attachment);
1557        } catch (error) {
1558          setAndUpdateFiles(index2, null);
1559          let message2;
1560          if (typeof error === "object" && error !== null && "message" in error) {
1561            message2 = typeof error.message === "string" ? error.message : String(error.message);
1562          } else {
1563            message2 = (0, import_i18n5.sprintf)(
1564              // translators: %s: file name
1565              (0, import_i18n5.__)("Error while uploading file %s to the media library."),
1566              file.name
1567            );
1568          }
1569          onError?.(
1570            new UploadError({
1571              code: "GENERAL",
1572              message: message2,
1573              file,
1574              cause: error instanceof Error ? error : void 0
1575            })
1576          );
1577        }
1578      });
1579    }
1580  
1581    // packages/media-utils/build-module/utils/sideload-media.mjs
1582    var import_i18n6 = __toESM(require_i18n(), 1);
1583  
1584    // packages/media-utils/build-module/utils/sideload-to-server.mjs
1585    var import_api_fetch2 = __toESM(require_api_fetch(), 1);
1586    async function sideloadToServer(file, attachmentId, additionalData = {}, signal) {
1587      const data = new FormData();
1588      data.append("file", file, file.name || file.type.replace("/", "."));
1589      for (const [key, value] of Object.entries(additionalData)) {
1590        flattenFormData(
1591          data,
1592          key,
1593          value
1594        );
1595      }
1596      return (0, import_api_fetch2.default)({
1597        path: `/wp/v2/media/$attachmentId}/sideload`,
1598        body: data,
1599        method: "POST",
1600        signal
1601      });
1602    }
1603  
1604    // packages/media-utils/build-module/utils/sideload-media.mjs
1605    var noop = () => {
1606    };
1607    async function sideloadMedia({
1608      file,
1609      attachmentId,
1610      additionalData = {},
1611      signal,
1612      onSuccess,
1613      onError = noop
1614    }) {
1615      try {
1616        const subSizeData = await sideloadToServer(
1617          file,
1618          attachmentId,
1619          additionalData,
1620          signal
1621        );
1622        onSuccess?.(subSizeData);
1623      } catch (error) {
1624        let message2;
1625        if (error instanceof Error) {
1626          message2 = error.message;
1627        } else {
1628          message2 = (0, import_i18n6.sprintf)(
1629            // translators: %s: file name
1630            (0, import_i18n6.__)("Error while sideloading file %s to the server."),
1631            file.name
1632          );
1633        }
1634        onError(
1635          new UploadError({
1636            code: "GENERAL",
1637            message: message2,
1638            file,
1639            cause: error instanceof Error ? error : void 0
1640          })
1641        );
1642      }
1643    }
1644  
1645    // node_modules/clsx/dist/clsx.mjs
1646    function r(e2) {
1647      var t2, f2, n2 = "";
1648      if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1649      else if ("object" == typeof e2) if (Array.isArray(e2)) {
1650        var o2 = e2.length;
1651        for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1652      } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1653      return n2;
1654    }
1655    function clsx() {
1656      for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1657      return n2;
1658    }
1659    var clsx_default = clsx;
1660  
1661    // packages/media-utils/build-module/components/media-upload-modal/index.mjs
1662    var import_element87 = __toESM(require_element(), 1);
1663    var import_i18n68 = __toESM(require_i18n(), 1);
1664    var import_core_data6 = __toESM(require_core_data(), 1);
1665    var import_data14 = __toESM(require_data(), 1);
1666    var import_components54 = __toESM(require_components(), 1);
1667  
1668    // packages/icons/build-module/library/arrow-down.mjs
1669    var import_primitives = __toESM(require_primitives(), 1);
1670    var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
1671    var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.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" }) });
1672  
1673    // packages/icons/build-module/library/arrow-left.mjs
1674    var import_primitives2 = __toESM(require_primitives(), 1);
1675    var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
1676    var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
1677  
1678    // packages/icons/build-module/library/arrow-right.mjs
1679    var import_primitives3 = __toESM(require_primitives(), 1);
1680    var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
1681    var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
1682  
1683    // packages/icons/build-module/library/arrow-up.mjs
1684    var import_primitives4 = __toESM(require_primitives(), 1);
1685    var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
1686    var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
1687  
1688    // packages/icons/build-module/library/audio.mjs
1689    var import_primitives5 = __toESM(require_primitives(), 1);
1690    var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
1691    var audio_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M17.7 4.3c-1.2 0-2.8 0-3.8 1-.6.6-.9 1.5-.9 2.6V14c-.6-.6-1.5-1-2.5-1C8.6 13 7 14.6 7 16.5S8.6 20 10.5 20c1.5 0 2.8-1 3.3-2.3.5-.8.7-1.8.7-2.5V7.9c0-.7.2-1.2.5-1.6.6-.6 1.8-.6 2.8-.6h.3V4.3h-.4z" }) });
1692  
1693    // packages/icons/build-module/library/block-table.mjs
1694    var import_primitives6 = __toESM(require_primitives(), 1);
1695    var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
1696    var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.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" }) });
1697  
1698    // packages/icons/build-module/library/category.mjs
1699    var import_primitives7 = __toESM(require_primitives(), 1);
1700    var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
1701    var category_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.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" }) });
1702  
1703    // packages/icons/build-module/library/check.mjs
1704    var import_primitives8 = __toESM(require_primitives(), 1);
1705    var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
1706    var check_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
1707  
1708    // packages/icons/build-module/library/chevron-down.mjs
1709    var import_primitives9 = __toESM(require_primitives(), 1);
1710    var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
1711    var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
1712  
1713    // packages/icons/build-module/library/close-small.mjs
1714    var import_primitives10 = __toESM(require_primitives(), 1);
1715    var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
1716    var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.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" }) });
1717  
1718    // packages/icons/build-module/library/cog.mjs
1719    var import_primitives11 = __toESM(require_primitives(), 1);
1720    var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
1721    var cog_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.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" }) });
1722  
1723    // packages/icons/build-module/library/comment-author-avatar.mjs
1724    var import_primitives12 = __toESM(require_primitives(), 1);
1725    var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
1726    var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z" }) });
1727  
1728    // packages/icons/build-module/library/envelope.mjs
1729    var import_primitives13 = __toESM(require_primitives(), 1);
1730    var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
1731    var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.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" }) });
1732  
1733    // packages/icons/build-module/library/error.mjs
1734    var import_primitives14 = __toESM(require_primitives(), 1);
1735    var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
1736    var error_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.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" }) });
1737  
1738    // packages/icons/build-module/library/file.mjs
1739    var import_primitives15 = __toESM(require_primitives(), 1);
1740    var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
1741    var file_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z" }) });
1742  
1743    // packages/icons/build-module/library/format-list-bullets-rtl.mjs
1744    var import_primitives16 = __toESM(require_primitives(), 1);
1745    var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
1746    var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.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" }) });
1747  
1748    // packages/icons/build-module/library/format-list-bullets.mjs
1749    var import_primitives17 = __toESM(require_primitives(), 1);
1750    var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
1751    var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.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" }) });
1752  
1753    // packages/icons/build-module/library/funnel.mjs
1754    var import_primitives18 = __toESM(require_primitives(), 1);
1755    var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
1756    var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
1757  
1758    // packages/icons/build-module/library/image.mjs
1759    var import_primitives19 = __toESM(require_primitives(), 1);
1760    var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
1761    var image_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.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.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z" }) });
1762  
1763    // packages/icons/build-module/library/link.mjs
1764    var import_primitives20 = __toESM(require_primitives(), 1);
1765    var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1766    var link_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.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" }) });
1767  
1768    // packages/icons/build-module/library/mobile.mjs
1769    var import_primitives21 = __toESM(require_primitives(), 1);
1770    var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1771    var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.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" }) });
1772  
1773    // packages/icons/build-module/library/more-vertical.mjs
1774    var import_primitives22 = __toESM(require_primitives(), 1);
1775    var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
1776    var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
1777  
1778    // packages/icons/build-module/library/next.mjs
1779    var import_primitives23 = __toESM(require_primitives(), 1);
1780    var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
1781    var next_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime23.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" }) });
1782  
1783    // packages/icons/build-module/library/previous.mjs
1784    var import_primitives24 = __toESM(require_primitives(), 1);
1785    var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
1786    var previous_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.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" }) });
1787  
1788    // packages/icons/build-module/library/scheduled.mjs
1789    var import_primitives25 = __toESM(require_primitives(), 1);
1790    var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
1791    var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.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" }) });
1792  
1793    // packages/icons/build-module/library/search.mjs
1794    var import_primitives26 = __toESM(require_primitives(), 1);
1795    var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
1796    var search_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.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" }) });
1797  
1798    // packages/icons/build-module/library/seen.mjs
1799    var import_primitives27 = __toESM(require_primitives(), 1);
1800    var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
1801    var seen_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.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" }) });
1802  
1803    // packages/icons/build-module/library/unseen.mjs
1804    var import_primitives28 = __toESM(require_primitives(), 1);
1805    var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
1806    var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.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" }) });
1807  
1808    // packages/icons/build-module/library/upload.mjs
1809    var import_primitives29 = __toESM(require_primitives(), 1);
1810    var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
1811    var upload_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.Path, { d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z" }) });
1812  
1813    // packages/icons/build-module/library/video.mjs
1814    var import_primitives30 = __toESM(require_primitives(), 1);
1815    var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
1816    var video_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.Path, { d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z" }) });
1817  
1818    // node_modules/@base-ui/utils/safeReact.mjs
1819    var React = __toESM(require_react(), 1);
1820    var SafeReact = {
1821      ...React
1822    };
1823  
1824    // node_modules/@base-ui/utils/useRefWithInit.mjs
1825    var React2 = __toESM(require_react(), 1);
1826    var UNINITIALIZED = {};
1827    function useRefWithInit(init2, initArg) {
1828      const ref = React2.useRef(UNINITIALIZED);
1829      if (ref.current === UNINITIALIZED) {
1830        ref.current = init2(initArg);
1831      }
1832      return ref;
1833    }
1834  
1835    // node_modules/@base-ui/utils/useStableCallback.mjs
1836    var useInsertionEffect = SafeReact.useInsertionEffect;
1837    var useSafeInsertionEffect = (
1838      // React 17 doesn't have useInsertionEffect.
1839      useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1840      useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1841    );
1842    function useStableCallback(callback) {
1843      const stable = useRefWithInit(createStableCallback).current;
1844      stable.next = callback;
1845      useSafeInsertionEffect(stable.effect);
1846      return stable.trampoline;
1847    }
1848    function createStableCallback() {
1849      const stable = {
1850        next: void 0,
1851        callback: assertNotCalled,
1852        trampoline: (...args) => stable.callback?.(...args),
1853        effect: () => {
1854          stable.callback = stable.next;
1855        }
1856      };
1857      return stable;
1858    }
1859    function assertNotCalled() {
1860      if (true) {
1861        throw (
1862          /* minify-error-disabled */
1863          new Error("Base UI: Cannot call an event handler while rendering.")
1864        );
1865      }
1866    }
1867  
1868    // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs
1869    var React3 = __toESM(require_react(), 1);
1870    var noop2 = () => {
1871    };
1872    var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop2;
1873  
1874    // node_modules/@base-ui/utils/warn.mjs
1875    var set;
1876    if (true) {
1877      set = /* @__PURE__ */ new Set();
1878    }
1879    function warn(...messages) {
1880      if (true) {
1881        const messageKey = messages.join(" ");
1882        if (!set.has(messageKey)) {
1883          set.add(messageKey);
1884          console.warn(`Base UI: $messageKey}`);
1885        }
1886      }
1887    }
1888  
1889    // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
1890    var React4 = __toESM(require_react(), 1);
1891    var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
1892    if (true) DirectionContext.displayName = "DirectionContext";
1893    function useDirection() {
1894      const context = React4.useContext(DirectionContext);
1895      return context?.direction ?? "ltr";
1896    }
1897  
1898    // node_modules/@base-ui/react/internals/useRenderElement.mjs
1899    var React7 = __toESM(require_react(), 1);
1900  
1901    // node_modules/@base-ui/utils/useMergedRefs.mjs
1902    function useMergedRefs(a2, b2, c2, d2) {
1903      const forkRef = useRefWithInit(createForkRef).current;
1904      if (didChange(forkRef, a2, b2, c2, d2)) {
1905        update(forkRef, [a2, b2, c2, d2]);
1906      }
1907      return forkRef.callback;
1908    }
1909    function useMergedRefsN(refs) {
1910      const forkRef = useRefWithInit(createForkRef).current;
1911      if (didChangeN(forkRef, refs)) {
1912        update(forkRef, refs);
1913      }
1914      return forkRef.callback;
1915    }
1916    function createForkRef() {
1917      return {
1918        callback: null,
1919        cleanup: null,
1920        refs: []
1921      };
1922    }
1923    function didChange(forkRef, a2, b2, c2, d2) {
1924      return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1925    }
1926    function didChangeN(forkRef, newRefs) {
1927      return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1928    }
1929    function update(forkRef, refs) {
1930      forkRef.refs = refs;
1931      if (refs.every((ref) => ref == null)) {
1932        forkRef.callback = null;
1933        return;
1934      }
1935      forkRef.callback = (instance) => {
1936        if (forkRef.cleanup) {
1937          forkRef.cleanup();
1938          forkRef.cleanup = null;
1939        }
1940        if (instance != null) {
1941          const cleanupCallbacks = Array(refs.length).fill(null);
1942          for (let i2 = 0; i2 < refs.length; i2 += 1) {
1943            const ref = refs[i2];
1944            if (ref == null) {
1945              continue;
1946            }
1947            switch (typeof ref) {
1948              case "function": {
1949                const refCleanup = ref(instance);
1950                if (typeof refCleanup === "function") {
1951                  cleanupCallbacks[i2] = refCleanup;
1952                }
1953                break;
1954              }
1955              case "object": {
1956                ref.current = instance;
1957                break;
1958              }
1959              default:
1960            }
1961          }
1962          forkRef.cleanup = () => {
1963            for (let i2 = 0; i2 < refs.length; i2 += 1) {
1964              const ref = refs[i2];
1965              if (ref == null) {
1966                continue;
1967              }
1968              switch (typeof ref) {
1969                case "function": {
1970                  const cleanupCallback = cleanupCallbacks[i2];
1971                  if (typeof cleanupCallback === "function") {
1972                    cleanupCallback();
1973                  } else {
1974                    ref(null);
1975                  }
1976                  break;
1977                }
1978                case "object": {
1979                  ref.current = null;
1980                  break;
1981                }
1982                default:
1983              }
1984            }
1985          };
1986        }
1987      };
1988    }
1989  
1990    // node_modules/@base-ui/utils/getReactElementRef.mjs
1991    var React6 = __toESM(require_react(), 1);
1992  
1993    // node_modules/@base-ui/utils/reactVersion.mjs
1994    var React5 = __toESM(require_react(), 1);
1995    var majorVersion = parseInt(React5.version, 10);
1996    function isReactVersionAtLeast(reactVersionToCheck) {
1997      return majorVersion >= reactVersionToCheck;
1998    }
1999  
2000    // node_modules/@base-ui/utils/getReactElementRef.mjs
2001    function getReactElementRef(element) {
2002      if (!/* @__PURE__ */ React6.isValidElement(element)) {
2003        return null;
2004      }
2005      const reactElement = element;
2006      const propsWithRef = reactElement.props;
2007      return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
2008    }
2009  
2010    // node_modules/@base-ui/utils/mergeObjects.mjs
2011    function mergeObjects(a2, b2) {
2012      if (a2 && !b2) {
2013        return a2;
2014      }
2015      if (!a2 && b2) {
2016        return b2;
2017      }
2018      if (a2 || b2) {
2019        return {
2020          ...a2,
2021          ...b2
2022        };
2023      }
2024      return void 0;
2025    }
2026  
2027    // node_modules/@base-ui/utils/empty.mjs
2028    function NOOP() {
2029    }
2030    var EMPTY_ARRAY = Object.freeze([]);
2031    var EMPTY_OBJECT = Object.freeze({});
2032  
2033    // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
2034    function getStateAttributesProps(state, customMapping) {
2035      const props = {};
2036      for (const key in state) {
2037        const value = state[key];
2038        if (customMapping?.hasOwnProperty(key)) {
2039          const customProps = customMapping[key](value);
2040          if (customProps != null) {
2041            Object.assign(props, customProps);
2042          }
2043          continue;
2044        }
2045        if (value === true) {
2046          props[`data-$key.toLowerCase()}`] = "";
2047        } else if (value) {
2048          props[`data-$key.toLowerCase()}`] = value.toString();
2049        }
2050      }
2051      return props;
2052    }
2053  
2054    // node_modules/@base-ui/react/utils/resolveClassName.mjs
2055    function resolveClassName(className, state) {
2056      return typeof className === "function" ? className(state) : className;
2057    }
2058  
2059    // node_modules/@base-ui/react/utils/resolveStyle.mjs
2060    function resolveStyle(style, state) {
2061      return typeof style === "function" ? style(state) : style;
2062    }
2063  
2064    // node_modules/@base-ui/react/merge-props/mergeProps.mjs
2065    var EMPTY_PROPS = {};
2066    function mergeProps(a2, b2, c2, d2, e2) {
2067      if (!c2 && !d2 && !e2 && !a2) {
2068        return createInitialMergedProps(b2);
2069      }
2070      let merged = createInitialMergedProps(a2);
2071      if (b2) {
2072        merged = mergeInto(merged, b2);
2073      }
2074      if (c2) {
2075        merged = mergeInto(merged, c2);
2076      }
2077      if (d2) {
2078        merged = mergeInto(merged, d2);
2079      }
2080      if (e2) {
2081        merged = mergeInto(merged, e2);
2082      }
2083      return merged;
2084    }
2085    function mergePropsN(props) {
2086      if (props.length === 0) {
2087        return EMPTY_PROPS;
2088      }
2089      if (props.length === 1) {
2090        return createInitialMergedProps(props[0]);
2091      }
2092      let merged = createInitialMergedProps(props[0]);
2093      for (let i2 = 1; i2 < props.length; i2 += 1) {
2094        merged = mergeInto(merged, props[i2]);
2095      }
2096      return merged;
2097    }
2098    function createInitialMergedProps(inputProps) {
2099      if (isPropsGetter(inputProps)) {
2100        return {
2101          ...resolvePropsGetter(inputProps, EMPTY_PROPS)
2102        };
2103      }
2104      return copyInitialProps(inputProps);
2105    }
2106    function mergeInto(merged, inputProps) {
2107      if (isPropsGetter(inputProps)) {
2108        return resolvePropsGetter(inputProps, merged);
2109      }
2110      return mutablyMergeInto(merged, inputProps);
2111    }
2112    function copyInitialProps(inputProps) {
2113      const copiedProps = {
2114        ...inputProps
2115      };
2116      for (const propName in copiedProps) {
2117        const propValue = copiedProps[propName];
2118        if (isEventHandler(propName, propValue)) {
2119          copiedProps[propName] = wrapEventHandler(propValue);
2120        }
2121      }
2122      return copiedProps;
2123    }
2124    function mutablyMergeInto(mergedProps, externalProps) {
2125      if (!externalProps) {
2126        return mergedProps;
2127      }
2128      for (const propName in externalProps) {
2129        const externalPropValue = externalProps[propName];
2130        switch (propName) {
2131          case "style": {
2132            mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
2133            break;
2134          }
2135          case "className": {
2136            mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
2137            break;
2138          }
2139          default: {
2140            if (isEventHandler(propName, externalPropValue)) {
2141              mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
2142            } else {
2143              mergedProps[propName] = externalPropValue;
2144            }
2145          }
2146        }
2147      }
2148      return mergedProps;
2149    }
2150    function isEventHandler(key, value) {
2151      const code0 = key.charCodeAt(0);
2152      const code1 = key.charCodeAt(1);
2153      const code2 = key.charCodeAt(2);
2154      return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
2155    }
2156    function isPropsGetter(inputProps) {
2157      return typeof inputProps === "function";
2158    }
2159    function resolvePropsGetter(inputProps, previousProps) {
2160      if (isPropsGetter(inputProps)) {
2161        return inputProps(previousProps);
2162      }
2163      return inputProps ?? EMPTY_PROPS;
2164    }
2165    function mergeEventHandlers(ourHandler, theirHandler) {
2166      if (!theirHandler) {
2167        return ourHandler;
2168      }
2169      if (!ourHandler) {
2170        return wrapEventHandler(theirHandler);
2171      }
2172      return (...args) => {
2173        const event = args[0];
2174        if (isSyntheticEvent(event)) {
2175          const baseUIEvent = event;
2176          makeEventPreventable(baseUIEvent);
2177          const result2 = theirHandler(...args);
2178          if (!baseUIEvent.baseUIHandlerPrevented) {
2179            ourHandler?.(...args);
2180          }
2181          return result2;
2182        }
2183        const result = theirHandler(...args);
2184        ourHandler?.(...args);
2185        return result;
2186      };
2187    }
2188    function wrapEventHandler(handler) {
2189      if (!handler) {
2190        return handler;
2191      }
2192      return (...args) => {
2193        const event = args[0];
2194        if (isSyntheticEvent(event)) {
2195          makeEventPreventable(event);
2196        }
2197        return handler(...args);
2198      };
2199    }
2200    function makeEventPreventable(event) {
2201      event.preventBaseUIHandler = () => {
2202        event.baseUIHandlerPrevented = true;
2203      };
2204      return event;
2205    }
2206    function mergeClassNames(ourClassName, theirClassName) {
2207      if (theirClassName) {
2208        if (ourClassName) {
2209          return theirClassName + " " + ourClassName;
2210        }
2211        return theirClassName;
2212      }
2213      return ourClassName;
2214    }
2215    function isSyntheticEvent(event) {
2216      return event != null && typeof event === "object" && "nativeEvent" in event;
2217    }
2218  
2219    // node_modules/@base-ui/react/internals/useRenderElement.mjs
2220    var import_react = __toESM(require_react(), 1);
2221    function useRenderElement(element, componentProps, params = {}) {
2222      const renderProp = componentProps.render;
2223      const outProps = useRenderElementProps(componentProps, params);
2224      if (params.enabled === false) {
2225        return null;
2226      }
2227      const state = params.state ?? EMPTY_OBJECT;
2228      return evaluateRenderProp(element, renderProp, outProps, state);
2229    }
2230    function useRenderElementProps(componentProps, params = {}) {
2231      const {
2232        className: classNameProp,
2233        style: styleProp,
2234        render: renderProp
2235      } = componentProps;
2236      const {
2237        state = EMPTY_OBJECT,
2238        ref,
2239        props,
2240        stateAttributesMapping: stateAttributesMapping3,
2241        enabled = true
2242      } = params;
2243      const className = enabled ? resolveClassName(classNameProp, state) : void 0;
2244      const style = enabled ? resolveStyle(styleProp, state) : void 0;
2245      const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
2246      const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
2247      const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
2248      if (typeof document !== "undefined") {
2249        if (!enabled) {
2250          useMergedRefs(null, null);
2251        } else if (Array.isArray(ref)) {
2252          outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
2253        } else {
2254          outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
2255        }
2256      }
2257      if (!enabled) {
2258        return EMPTY_OBJECT;
2259      }
2260      if (className !== void 0) {
2261        outProps.className = mergeClassNames(outProps.className, className);
2262      }
2263      if (style !== void 0) {
2264        outProps.style = mergeObjects(outProps.style, style);
2265      }
2266      return outProps;
2267    }
2268    function resolveRenderFunctionProps(props) {
2269      if (Array.isArray(props)) {
2270        return mergePropsN(props);
2271      }
2272      return mergeProps(void 0, props);
2273    }
2274    var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
2275    var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
2276    var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
2277    function evaluateRenderProp(element, render4, props, state) {
2278      if (render4) {
2279        if (typeof render4 === "function") {
2280          if (true) {
2281            warnIfRenderPropLooksLikeComponent(render4);
2282          }
2283          return render4(props, state);
2284        }
2285        const mergedProps = mergeProps(props, render4.props);
2286        mergedProps.ref = props.ref;
2287        let newElement = render4;
2288        if (newElement?.$$typeof === REACT_LAZY_TYPE) {
2289          const children = React7.Children.toArray(render4);
2290          newElement = children[0];
2291        }
2292        if (true) {
2293          if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
2294            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"));
2295          }
2296        }
2297        return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
2298      }
2299      if (element) {
2300        if (typeof element === "string") {
2301          return renderTag(element, props);
2302        }
2303      }
2304      throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
2305    }
2306    function warnIfRenderPropLooksLikeComponent(renderFn) {
2307      const functionName = renderFn.name;
2308      if (functionName.length === 0) {
2309        return;
2310      }
2311      if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
2312        return;
2313      }
2314      if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
2315        return;
2316      }
2317      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");
2318    }
2319    function renderTag(Tag, props) {
2320      if (Tag === "button") {
2321        return /* @__PURE__ */ (0, import_react.createElement)("button", {
2322          type: "button",
2323          ...props,
2324          key: props.key
2325        });
2326      }
2327      if (Tag === "img") {
2328        return /* @__PURE__ */ (0, import_react.createElement)("img", {
2329          alt: "",
2330          ...props,
2331          key: props.key
2332        });
2333      }
2334      return /* @__PURE__ */ React7.createElement(Tag, props);
2335    }
2336  
2337    // node_modules/@base-ui/utils/useId.mjs
2338    var React8 = __toESM(require_react(), 1);
2339    var globalId = 0;
2340    function useGlobalId(idOverride, prefix = "mui") {
2341      const [defaultId, setDefaultId] = React8.useState(idOverride);
2342      const id = idOverride || defaultId;
2343      React8.useEffect(() => {
2344        if (defaultId == null) {
2345          globalId += 1;
2346          setDefaultId(`$prefix}-$globalId}`);
2347        }
2348      }, [defaultId, prefix]);
2349      return id;
2350    }
2351    var maybeReactUseId = SafeReact.useId;
2352    function useId(idOverride, prefix) {
2353      if (maybeReactUseId !== void 0) {
2354        const reactId = maybeReactUseId();
2355        return idOverride ?? (prefix ? `$prefix}-$reactId}` : reactId);
2356      }
2357      return useGlobalId(idOverride, prefix);
2358    }
2359  
2360    // node_modules/@base-ui/react/internals/useBaseUiId.mjs
2361    function useBaseUiId(idOverride) {
2362      return useId(idOverride, "base-ui");
2363    }
2364  
2365    // node_modules/@base-ui/react/internals/reason-parts.mjs
2366    var reason_parts_exports = {};
2367    __export(reason_parts_exports, {
2368      cancelOpen: () => cancelOpen,
2369      chipRemovePress: () => chipRemovePress,
2370      clearPress: () => clearPress,
2371      closePress: () => closePress,
2372      closeWatcher: () => closeWatcher,
2373      decrementPress: () => decrementPress,
2374      disabled: () => disabled,
2375      drag: () => drag,
2376      escapeKey: () => escapeKey,
2377      focusOut: () => focusOut,
2378      imperativeAction: () => imperativeAction,
2379      incrementPress: () => incrementPress,
2380      initial: () => initial,
2381      inputBlur: () => inputBlur,
2382      inputChange: () => inputChange,
2383      inputClear: () => inputClear,
2384      inputPaste: () => inputPaste,
2385      inputPress: () => inputPress,
2386      itemPress: () => itemPress,
2387      keyboard: () => keyboard,
2388      linkPress: () => linkPress,
2389      listNavigation: () => listNavigation,
2390      missing: () => missing,
2391      none: () => none,
2392      outsidePress: () => outsidePress,
2393      pointer: () => pointer,
2394      scrub: () => scrub,
2395      siblingOpen: () => siblingOpen,
2396      swipe: () => swipe,
2397      trackPress: () => trackPress,
2398      triggerFocus: () => triggerFocus,
2399      triggerHover: () => triggerHover,
2400      triggerPress: () => triggerPress,
2401      wheel: () => wheel,
2402      windowResize: () => windowResize
2403    });
2404    var none = "none";
2405    var triggerPress = "trigger-press";
2406    var triggerHover = "trigger-hover";
2407    var triggerFocus = "trigger-focus";
2408    var outsidePress = "outside-press";
2409    var itemPress = "item-press";
2410    var closePress = "close-press";
2411    var linkPress = "link-press";
2412    var clearPress = "clear-press";
2413    var chipRemovePress = "chip-remove-press";
2414    var trackPress = "track-press";
2415    var incrementPress = "increment-press";
2416    var decrementPress = "decrement-press";
2417    var inputChange = "input-change";
2418    var inputClear = "input-clear";
2419    var inputBlur = "input-blur";
2420    var inputPaste = "input-paste";
2421    var inputPress = "input-press";
2422    var focusOut = "focus-out";
2423    var escapeKey = "escape-key";
2424    var closeWatcher = "close-watcher";
2425    var listNavigation = "list-navigation";
2426    var keyboard = "keyboard";
2427    var pointer = "pointer";
2428    var drag = "drag";
2429    var wheel = "wheel";
2430    var scrub = "scrub";
2431    var cancelOpen = "cancel-open";
2432    var siblingOpen = "sibling-open";
2433    var disabled = "disabled";
2434    var missing = "missing";
2435    var initial = "initial";
2436    var imperativeAction = "imperative-action";
2437    var swipe = "swipe";
2438    var windowResize = "window-resize";
2439  
2440    // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
2441    function createChangeEventDetails(reason, event, trigger, customProperties) {
2442      let canceled = false;
2443      let allowPropagation = false;
2444      const custom = customProperties ?? EMPTY_OBJECT;
2445      const details = {
2446        reason,
2447        event: event ?? new Event("base-ui"),
2448        cancel() {
2449          canceled = true;
2450        },
2451        allowPropagation() {
2452          allowPropagation = true;
2453        },
2454        get isCanceled() {
2455          return canceled;
2456        },
2457        get isPropagationAllowed() {
2458          return allowPropagation;
2459        },
2460        trigger,
2461        ...custom
2462      };
2463      return details;
2464    }
2465  
2466    // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
2467    var React10 = __toESM(require_react(), 1);
2468  
2469    // node_modules/@base-ui/utils/useOnMount.mjs
2470    var React9 = __toESM(require_react(), 1);
2471    var EMPTY = [];
2472    function useOnMount(fn) {
2473      React9.useEffect(fn, EMPTY);
2474    }
2475  
2476    // node_modules/@base-ui/utils/useAnimationFrame.mjs
2477    var EMPTY2 = null;
2478    var LAST_RAF = globalThis.requestAnimationFrame;
2479    var Scheduler = class {
2480      /* This implementation uses an array as a backing data-structure for frame callbacks.
2481       * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
2482       * never calls the native `cancelAnimationFrame` if there are no frames left. This can
2483       * be much more efficient if there is a call pattern that alterns as
2484       * "request-cancel-request-cancel-…".
2485       * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
2486       * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
2487      callbacks = [];
2488      callbacksCount = 0;
2489      nextId = 1;
2490      startId = 1;
2491      isScheduled = false;
2492      tick = (timestamp) => {
2493        this.isScheduled = false;
2494        const currentCallbacks = this.callbacks;
2495        const currentCallbacksCount = this.callbacksCount;
2496        this.callbacks = [];
2497        this.callbacksCount = 0;
2498        this.startId = this.nextId;
2499        if (currentCallbacksCount > 0) {
2500          for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
2501            currentCallbacks[i2]?.(timestamp);
2502          }
2503        }
2504      };
2505      request(fn) {
2506        const id = this.nextId;
2507        this.nextId += 1;
2508        this.callbacks.push(fn);
2509        this.callbacksCount += 1;
2510        const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
2511        if (!this.isScheduled || didRAFChange) {
2512          requestAnimationFrame(this.tick);
2513          this.isScheduled = true;
2514        }
2515        return id;
2516      }
2517      cancel(id) {
2518        const index2 = id - this.startId;
2519        if (index2 < 0 || index2 >= this.callbacks.length) {
2520          return;
2521        }
2522        this.callbacks[index2] = null;
2523        this.callbacksCount -= 1;
2524      }
2525    };
2526    var scheduler = new Scheduler();
2527    var AnimationFrame = class _AnimationFrame {
2528      static create() {
2529        return new _AnimationFrame();
2530      }
2531      static request(fn) {
2532        return scheduler.request(fn);
2533      }
2534      static cancel(id) {
2535        return scheduler.cancel(id);
2536      }
2537      currentId = EMPTY2;
2538      /**
2539       * Executes `fn` after `delay`, clearing any previously scheduled call.
2540       */
2541      request(fn) {
2542        this.cancel();
2543        this.currentId = scheduler.request(() => {
2544          this.currentId = EMPTY2;
2545          fn();
2546        });
2547      }
2548      cancel = () => {
2549        if (this.currentId !== EMPTY2) {
2550          scheduler.cancel(this.currentId);
2551          this.currentId = EMPTY2;
2552        }
2553      };
2554      disposeEffect = () => {
2555        return this.cancel;
2556      };
2557    };
2558    function useAnimationFrame() {
2559      const timeout = useRefWithInit(AnimationFrame.create).current;
2560      useOnMount(timeout.disposeEffect);
2561      return timeout;
2562    }
2563  
2564    // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
2565    function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
2566      const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0);
2567      const [mounted, setMounted] = React10.useState(open);
2568      if (open && !mounted) {
2569        setMounted(true);
2570        setTransitionStatus("starting");
2571      }
2572      if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
2573        setTransitionStatus("ending");
2574      }
2575      if (!open && !mounted && transitionStatus === "ending") {
2576        setTransitionStatus(void 0);
2577      }
2578      useIsoLayoutEffect(() => {
2579        if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
2580          const frame = AnimationFrame.request(() => {
2581            setTransitionStatus("ending");
2582          });
2583          return () => {
2584            AnimationFrame.cancel(frame);
2585          };
2586        }
2587        return void 0;
2588      }, [open, mounted, transitionStatus, deferEndingState]);
2589      useIsoLayoutEffect(() => {
2590        if (!open || enableIdleState) {
2591          return void 0;
2592        }
2593        const frame = AnimationFrame.request(() => {
2594          setTransitionStatus(void 0);
2595        });
2596        return () => {
2597          AnimationFrame.cancel(frame);
2598        };
2599      }, [enableIdleState, open]);
2600      useIsoLayoutEffect(() => {
2601        if (!open || !enableIdleState) {
2602          return void 0;
2603        }
2604        if (open && mounted && transitionStatus !== "idle") {
2605          setTransitionStatus("starting");
2606        }
2607        const frame = AnimationFrame.request(() => {
2608          setTransitionStatus("idle");
2609        });
2610        return () => {
2611          AnimationFrame.cancel(frame);
2612        };
2613      }, [enableIdleState, open, mounted, transitionStatus]);
2614      return {
2615        mounted,
2616        setMounted,
2617        transitionStatus
2618      };
2619    }
2620  
2621    // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs
2622    var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
2623      TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
2624      TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
2625      return TransitionStatusDataAttributes2;
2626    })({});
2627    var STARTING_HOOK = {
2628      [TransitionStatusDataAttributes.startingStyle]: ""
2629    };
2630    var ENDING_HOOK = {
2631      [TransitionStatusDataAttributes.endingStyle]: ""
2632    };
2633    var transitionStatusMapping = {
2634      transitionStatus(value) {
2635        if (value === "starting") {
2636          return STARTING_HOOK;
2637        }
2638        if (value === "ending") {
2639          return ENDING_HOOK;
2640        }
2641        return null;
2642      }
2643    };
2644  
2645    // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2646    function hasWindow() {
2647      return typeof window !== "undefined";
2648    }
2649    function getNodeName(node) {
2650      if (isNode(node)) {
2651        return (node.nodeName || "").toLowerCase();
2652      }
2653      return "#document";
2654    }
2655    function getWindow(node) {
2656      var _node$ownerDocument;
2657      return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2658    }
2659    function getDocumentElement(node) {
2660      var _ref;
2661      return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2662    }
2663    function isNode(value) {
2664      if (!hasWindow()) {
2665        return false;
2666      }
2667      return value instanceof Node || value instanceof getWindow(value).Node;
2668    }
2669    function isElement(value) {
2670      if (!hasWindow()) {
2671        return false;
2672      }
2673      return value instanceof Element || value instanceof getWindow(value).Element;
2674    }
2675    function isHTMLElement(value) {
2676      if (!hasWindow()) {
2677        return false;
2678      }
2679      return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2680    }
2681    function isShadowRoot(value) {
2682      if (!hasWindow() || typeof ShadowRoot === "undefined") {
2683        return false;
2684      }
2685      return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2686    }
2687    function isOverflowElement(element) {
2688      const {
2689        overflow,
2690        overflowX,
2691        overflowY,
2692        display
2693      } = getComputedStyle2(element);
2694      return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2695    }
2696    function isTableElement(element) {
2697      return /^(table|td|th)$/.test(getNodeName(element));
2698    }
2699    function isTopLayer(element) {
2700      try {
2701        if (element.matches(":popover-open")) {
2702          return true;
2703        }
2704      } catch (_e) {
2705      }
2706      try {
2707        return element.matches(":modal");
2708      } catch (_e) {
2709        return false;
2710      }
2711    }
2712    var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2713    var containRe = /paint|layout|strict|content/;
2714    var isNotNone = (value) => !!value && value !== "none";
2715    var isWebKitValue;
2716    function isContainingBlock(elementOrCss) {
2717      const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2718      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 || "");
2719    }
2720    function getContainingBlock(element) {
2721      let currentNode = getParentNode(element);
2722      while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2723        if (isContainingBlock(currentNode)) {
2724          return currentNode;
2725        } else if (isTopLayer(currentNode)) {
2726          return null;
2727        }
2728        currentNode = getParentNode(currentNode);
2729      }
2730      return null;
2731    }
2732    function isWebKit() {
2733      if (isWebKitValue == null) {
2734        isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2735      }
2736      return isWebKitValue;
2737    }
2738    function isLastTraversableNode(node) {
2739      return /^(html|body|#document)$/.test(getNodeName(node));
2740    }
2741    function getComputedStyle2(element) {
2742      return getWindow(element).getComputedStyle(element);
2743    }
2744    function getNodeScroll(element) {
2745      if (isElement(element)) {
2746        return {
2747          scrollLeft: element.scrollLeft,
2748          scrollTop: element.scrollTop
2749        };
2750      }
2751      return {
2752        scrollLeft: element.scrollX,
2753        scrollTop: element.scrollY
2754      };
2755    }
2756    function getParentNode(node) {
2757      if (getNodeName(node) === "html") {
2758        return node;
2759      }
2760      const result = (
2761        // Step into the shadow DOM of the parent of a slotted node.
2762        node.assignedSlot || // DOM Element detected.
2763        node.parentNode || // ShadowRoot detected.
2764        isShadowRoot(node) && node.host || // Fallback.
2765        getDocumentElement(node)
2766      );
2767      return isShadowRoot(result) ? result.host : result;
2768    }
2769    function getNearestOverflowAncestor(node) {
2770      const parentNode = getParentNode(node);
2771      if (isLastTraversableNode(parentNode)) {
2772        return node.ownerDocument ? node.ownerDocument.body : node.body;
2773      }
2774      if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2775        return parentNode;
2776      }
2777      return getNearestOverflowAncestor(parentNode);
2778    }
2779    function getOverflowAncestors(node, list, traverseIframes) {
2780      var _node$ownerDocument2;
2781      if (list === void 0) {
2782        list = [];
2783      }
2784      if (traverseIframes === void 0) {
2785        traverseIframes = true;
2786      }
2787      const scrollableAncestor = getNearestOverflowAncestor(node);
2788      const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2789      const win = getWindow(scrollableAncestor);
2790      if (isBody) {
2791        const frameElement = getFrameElement(win);
2792        return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2793      } else {
2794        return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2795      }
2796    }
2797    function getFrameElement(win) {
2798      return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2799    }
2800  
2801    // node_modules/@base-ui/utils/addEventListener.mjs
2802    function addEventListener(target, type, listener, options) {
2803      target.addEventListener(type, listener, options);
2804      return () => {
2805        target.removeEventListener(type, listener, options);
2806      };
2807    }
2808  
2809    // node_modules/@base-ui/utils/useValueAsRef.mjs
2810    function useValueAsRef(value) {
2811      const latest = useRefWithInit(createLatestRef, value).current;
2812      latest.next = value;
2813      useIsoLayoutEffect(latest.effect);
2814      return latest;
2815    }
2816    function createLatestRef(value) {
2817      const latest = {
2818        current: value,
2819        next: value,
2820        effect: () => {
2821          latest.current = latest.next;
2822        }
2823      };
2824      return latest;
2825    }
2826  
2827    // node_modules/@base-ui/utils/owner.mjs
2828    function ownerDocument(node) {
2829      return node?.ownerDocument || document;
2830    }
2831  
2832    // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2833    var React11 = __toESM(require_react(), 1);
2834  
2835    // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2836    var ReactDOM = __toESM(require_react_dom(), 1);
2837  
2838    // node_modules/@base-ui/react/utils/resolveRef.mjs
2839    function resolveRef(maybeRef) {
2840      if (maybeRef == null) {
2841        return maybeRef;
2842      }
2843      return "current" in maybeRef ? maybeRef.current : maybeRef;
2844    }
2845  
2846    // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2847    function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2848      const frame = useAnimationFrame();
2849      return useStableCallback((fnToExecute, signal = null) => {
2850        frame.cancel();
2851        const element = resolveRef(elementOrRef);
2852        if (element == null) {
2853          return;
2854        }
2855        const resolvedElement = element;
2856        const done = () => {
2857          ReactDOM.flushSync(fnToExecute);
2858        };
2859        if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2860          fnToExecute();
2861          return;
2862        }
2863        function exec() {
2864          Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2865            if (!signal?.aborted) {
2866              done();
2867            }
2868          }).catch(() => {
2869            if (treatAbortedAsFinished) {
2870              if (!signal?.aborted) {
2871                done();
2872              }
2873              return;
2874            }
2875            const currentAnimations = resolvedElement.getAnimations();
2876            if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2877              exec();
2878            }
2879          });
2880        }
2881        if (waitForStartingStyleRemoved) {
2882          const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2883          if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2884            frame.request(exec);
2885            return;
2886          }
2887          const attributeObserver = new MutationObserver(() => {
2888            if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2889              attributeObserver.disconnect();
2890              exec();
2891            }
2892          });
2893          attributeObserver.observe(resolvedElement, {
2894            attributes: true,
2895            attributeFilter: [startingStyleAttribute]
2896          });
2897          signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2898            once: true
2899          });
2900          return;
2901        }
2902        frame.request(exec);
2903      });
2904    }
2905  
2906    // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2907    function useOpenChangeComplete(parameters) {
2908      const {
2909        enabled = true,
2910        open,
2911        ref,
2912        onComplete: onCompleteParam
2913      } = parameters;
2914      const onComplete = useStableCallback(onCompleteParam);
2915      const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2916      React11.useEffect(() => {
2917        if (!enabled) {
2918          return void 0;
2919        }
2920        const abortController = new AbortController();
2921        runOnceAnimationsFinish(onComplete, abortController.signal);
2922        return () => {
2923          abortController.abort();
2924        };
2925      }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2926    }
2927  
2928    // node_modules/@base-ui/utils/useOnFirstRender.mjs
2929    var React12 = __toESM(require_react(), 1);
2930    function useOnFirstRender(fn) {
2931      const ref = React12.useRef(true);
2932      if (ref.current) {
2933        ref.current = false;
2934        fn();
2935      }
2936    }
2937  
2938    // node_modules/@base-ui/utils/platform/parts.mjs
2939    var parts_exports = {};
2940    __export(parts_exports, {
2941      engine: () => engine_exports,
2942      env: () => env_exports,
2943      os: () => os_exports,
2944      screenReader: () => screen_reader_exports
2945    });
2946  
2947    // node_modules/@base-ui/utils/platform/os.mjs
2948    var os_exports = {};
2949    __export(os_exports, {
2950      android: () => android,
2951      apple: () => apple,
2952      ios: () => ios,
2953      linux: () => linux,
2954      mac: () => mac,
2955      windows: () => windows
2956    });
2957  
2958    // node_modules/@base-ui/utils/platform/shared.mjs
2959    function readRawData() {
2960      if (typeof navigator === "undefined") {
2961        return {
2962          userAgent: "",
2963          platform: "",
2964          maxTouchPoints: 0
2965        };
2966      }
2967      if (true) {
2968        const uaData = navigator.userAgentData;
2969        if (uaData && Array.isArray(uaData.brands)) {
2970          return {
2971            userAgent: uaData.brands.map(({
2972              brand,
2973              version: version2
2974            }) => `$brand}/$version2}`).join(" "),
2975            platform: uaData.platform ?? navigator.platform ?? "",
2976            maxTouchPoints: navigator.maxTouchPoints ?? 0
2977          };
2978        }
2979      }
2980      return {
2981        userAgent: navigator.userAgent,
2982        platform: navigator.platform ?? "",
2983        maxTouchPoints: navigator.maxTouchPoints ?? 0
2984      };
2985    }
2986    var {
2987      userAgent,
2988      platform,
2989      maxTouchPoints
2990    } = readRawData();
2991    var lowerUserAgent = userAgent.toLowerCase();
2992    var lowerPlatform = platform.toLowerCase();
2993  
2994    // node_modules/@base-ui/utils/platform/os.mjs
2995    var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1;
2996    var ANDROID_STRING = "android";
2997    var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
2998    var mac = !ios && lowerPlatform.startsWith("mac");
2999    var windows = lowerPlatform.startsWith("win");
3000    var linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
3001    var apple = mac || ios;
3002  
3003    // node_modules/@base-ui/utils/platform/engine.mjs
3004    var engine_exports = {};
3005    __export(engine_exports, {
3006      blink: () => blink,
3007      gecko: () => gecko,
3008      webkit: () => webkit
3009    });
3010    var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none");
3011    var gecko = !webkit && lowerUserAgent.includes("firefox");
3012    var blink = !webkit && lowerUserAgent.includes("chrom");
3013  
3014    // node_modules/@base-ui/utils/platform/screen-reader.mjs
3015    var screen_reader_exports = {};
3016    __export(screen_reader_exports, {
3017      voiceOver: () => voiceOver
3018    });
3019    var voiceOver = apple;
3020  
3021    // node_modules/@base-ui/utils/platform/env.mjs
3022    var env_exports = {};
3023    __export(env_exports, {
3024      jsdom: () => jsdom
3025    });
3026    var jsdom = /jsdom|happydom/.test(lowerUserAgent);
3027  
3028    // node_modules/@base-ui/utils/useTimeout.mjs
3029    var EMPTY3 = 0;
3030    var Timeout = class _Timeout {
3031      static create() {
3032        return new _Timeout();
3033      }
3034      currentId = EMPTY3;
3035      /**
3036       * Executes `fn` after `delay`, clearing any previously scheduled call.
3037       */
3038      start(delay, fn) {
3039        this.clear();
3040        this.currentId = setTimeout(() => {
3041          this.currentId = EMPTY3;
3042          fn();
3043        }, delay);
3044      }
3045      isStarted() {
3046        return this.currentId !== EMPTY3;
3047      }
3048      clear = () => {
3049        if (this.currentId !== EMPTY3) {
3050          clearTimeout(this.currentId);
3051          this.currentId = EMPTY3;
3052        }
3053      };
3054      disposeEffect = () => {
3055        return this.clear;
3056      };
3057    };
3058    function useTimeout() {
3059      const timeout = useRefWithInit(Timeout.create).current;
3060      useOnMount(timeout.disposeEffect);
3061      return timeout;
3062    }
3063  
3064    // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
3065    var React13 = __toESM(require_react(), 1);
3066  
3067    // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs
3068    function isReactEvent(event) {
3069      return "nativeEvent" in event;
3070    }
3071    function isMouseLikePointerType(pointerType, strict) {
3072      const values = ["mouse", "pen"];
3073      if (!strict) {
3074        values.push("", void 0);
3075      }
3076      return values.includes(pointerType);
3077    }
3078    function isClickLikeEvent(event) {
3079      const type = event.type;
3080      return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
3081    }
3082  
3083    // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
3084    var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
3085    var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
3086  
3087    // node_modules/@base-ui/react/internals/shadowDom.mjs
3088    function activeElement(doc) {
3089      let element = doc.activeElement;
3090      while (element?.shadowRoot?.activeElement != null) {
3091        element = element.shadowRoot.activeElement;
3092      }
3093      return element;
3094    }
3095    function contains(parent, child) {
3096      if (!parent || !child) {
3097        return false;
3098      }
3099      const rootNode = child.getRootNode?.();
3100      if (parent.contains(child)) {
3101        return true;
3102      }
3103      if (rootNode && isShadowRoot(rootNode)) {
3104        let next = child;
3105        while (next) {
3106          if (parent === next) {
3107            return true;
3108          }
3109          next = next.parentNode || next.host;
3110        }
3111      }
3112      return false;
3113    }
3114    function getTarget(event) {
3115      if ("composedPath" in event) {
3116        return event.composedPath()[0];
3117      }
3118      return event.target;
3119    }
3120  
3121    // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
3122    function isTargetInsideEnabledTrigger(target, triggerElements) {
3123      if (!isElement(target)) {
3124        return false;
3125      }
3126      const targetElement = target;
3127      if (triggerElements.hasElement(targetElement)) {
3128        return !targetElement.hasAttribute("data-trigger-disabled");
3129      }
3130      for (const [, trigger] of triggerElements.entries()) {
3131        if (contains(trigger, targetElement)) {
3132          return !trigger.hasAttribute("data-trigger-disabled");
3133        }
3134      }
3135      return false;
3136    }
3137    function isEventTargetWithin(event, node) {
3138      if (node == null) {
3139        return false;
3140      }
3141      if ("composedPath" in event) {
3142        return event.composedPath().includes(node);
3143      }
3144      const eventAgain = event;
3145      return eventAgain.target != null && node.contains(eventAgain.target);
3146    }
3147    function isRootElement(element) {
3148      return element.matches("html,body");
3149    }
3150    function isTypeableElement(element) {
3151      return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
3152    }
3153    function isInteractiveElement(element) {
3154      return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),$TYPEABLE_SELECTOR}`) != null;
3155    }
3156    function matchesFocusVisible(element) {
3157      if (!element || parts_exports.env.jsdom) {
3158        return true;
3159      }
3160      try {
3161        return element.matches(":focus-visible");
3162      } catch (_e) {
3163        return true;
3164      }
3165    }
3166  
3167    // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs
3168    function resolveValue(value, pointerType) {
3169      if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3170        return 0;
3171      }
3172      if (typeof value === "function") {
3173        return value();
3174      }
3175      return value;
3176    }
3177    function getDelay(value, prop, pointerType) {
3178      const result = resolveValue(value, pointerType);
3179      if (typeof result === "number") {
3180        return result;
3181      }
3182      return result?.[prop];
3183    }
3184    function getRestMs(value) {
3185      if (typeof value === "function") {
3186        return value();
3187      }
3188      return value;
3189    }
3190    function isClickLikeOpenEvent(openEventType, interactedInside) {
3191      return interactedInside || openEventType === "click" || openEventType === "mousedown";
3192    }
3193    function isHoverOpenEvent(openEventType) {
3194      return openEventType?.includes("mouse") && openEventType !== "mousedown";
3195    }
3196  
3197    // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
3198    var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3199    var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({
3200      hasProvider: false,
3201      timeoutMs: 0,
3202      delayRef: {
3203        current: 0
3204      },
3205      initialDelayRef: {
3206        current: 0
3207      },
3208      timeout: new Timeout(),
3209      currentIdRef: {
3210        current: null
3211      },
3212      currentContextRef: {
3213        current: null
3214      }
3215    });
3216    if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3217    function resetDelayRef(delayRef, initialDelayRef) {
3218      delayRef.current = initialDelayRef.current;
3219    }
3220    function FloatingDelayGroup(props) {
3221      const {
3222        children,
3223        delay,
3224        timeoutMs = 0
3225      } = props;
3226      const delayRef = React13.useRef(delay);
3227      const initialDelayRef = React13.useRef(delay);
3228      const currentIdRef = React13.useRef(null);
3229      const currentContextRef = React13.useRef(null);
3230      const timeout = useTimeout();
3231      useIsoLayoutEffect(() => {
3232        initialDelayRef.current = delay;
3233        if (!currentIdRef.current) {
3234          delayRef.current = delay;
3235          return;
3236        }
3237        delayRef.current = {
3238          open: getDelay(delayRef.current, "open"),
3239          close: getDelay(delay, "close")
3240        };
3241      }, [delay, currentIdRef, delayRef, initialDelayRef]);
3242      return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(FloatingDelayGroupContext.Provider, {
3243        value: React13.useMemo(() => ({
3244          hasProvider: true,
3245          delayRef,
3246          initialDelayRef,
3247          currentIdRef,
3248          timeoutMs,
3249          currentContextRef,
3250          timeout
3251        }), [timeoutMs, timeout]),
3252        children
3253      });
3254    }
3255    function useDelayGroup(context, options = {
3256      open: false
3257    }) {
3258      const {
3259        open
3260      } = options;
3261      const store = "rootStore" in context ? context.rootStore : context;
3262      const floatingId = store.useState("floatingId");
3263      const groupContext = React13.useContext(FloatingDelayGroupContext);
3264      const {
3265        currentIdRef,
3266        delayRef,
3267        timeoutMs,
3268        initialDelayRef,
3269        currentContextRef,
3270        hasProvider,
3271        timeout
3272      } = groupContext;
3273      const [isInstantPhase, setIsInstantPhase] = React13.useState(false);
3274      const openRef = React13.useRef(open);
3275      const isUnmountedRef = React13.useRef(false);
3276      useIsoLayoutEffect(() => {
3277        openRef.current = open;
3278      }, [open]);
3279      useIsoLayoutEffect(() => {
3280        return () => {
3281          isUnmountedRef.current = true;
3282        };
3283      }, []);
3284      useIsoLayoutEffect(() => {
3285        function unset() {
3286          if (!isUnmountedRef.current) {
3287            setIsInstantPhase(false);
3288          }
3289          currentContextRef.current?.setIsInstantPhase(false);
3290          currentIdRef.current = null;
3291          currentContextRef.current = null;
3292          delayRef.current = initialDelayRef.current;
3293          timeout.clear();
3294        }
3295        if (!currentIdRef.current) {
3296          return void 0;
3297        }
3298        if (!open && currentIdRef.current === floatingId) {
3299          setIsInstantPhase(false);
3300          if (timeoutMs) {
3301            const closingId = floatingId;
3302            timeout.start(timeoutMs, () => {
3303              if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3304                return;
3305              }
3306              unset();
3307            });
3308            return () => {
3309              if (openRef.current || currentIdRef.current !== closingId) {
3310                timeout.clear();
3311              }
3312            };
3313          }
3314          unset();
3315        }
3316        return void 0;
3317      }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3318      useIsoLayoutEffect(() => {
3319        if (!open) {
3320          return;
3321        }
3322        const prevContext = currentContextRef.current;
3323        const prevId = currentIdRef.current;
3324        timeout.clear();
3325        currentContextRef.current = {
3326          onOpenChange: store.setOpen,
3327          setIsInstantPhase
3328        };
3329        currentIdRef.current = floatingId;
3330        delayRef.current = {
3331          open: 0,
3332          close: getDelay(initialDelayRef.current, "close")
3333        };
3334        if (prevId !== null && prevId !== floatingId) {
3335          setIsInstantPhase(true);
3336          prevContext?.setIsInstantPhase(true);
3337          prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3338        } else {
3339          setIsInstantPhase(false);
3340          prevContext?.setIsInstantPhase(false);
3341        }
3342      }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
3343      useIsoLayoutEffect(() => {
3344        return () => {
3345          if (currentIdRef.current === floatingId) {
3346            currentContextRef.current = null;
3347            if (!openRef.current) {
3348              return;
3349            }
3350            currentIdRef.current = null;
3351            resetDelayRef(delayRef, initialDelayRef);
3352            timeout.clear();
3353          }
3354        };
3355      }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]);
3356      return React13.useMemo(() => ({
3357        hasProvider,
3358        delayRef,
3359        isInstantPhase
3360      }), [hasProvider, delayRef, isInstantPhase]);
3361    }
3362  
3363    // node_modules/@base-ui/utils/mergeCleanups.mjs
3364    function mergeCleanups(...cleanups) {
3365      return () => {
3366        for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3367          const cleanup = cleanups[i2];
3368          if (cleanup) {
3369            cleanup();
3370          }
3371        }
3372      };
3373    }
3374  
3375    // node_modules/@base-ui/react/utils/FocusGuard.mjs
3376    var React14 = __toESM(require_react(), 1);
3377  
3378    // node_modules/@base-ui/utils/visuallyHidden.mjs
3379    var visuallyHiddenBase = {
3380      clipPath: "inset(50%)",
3381      overflow: "hidden",
3382      whiteSpace: "nowrap",
3383      border: 0,
3384      padding: 0,
3385      width: 1,
3386      height: 1,
3387      margin: -1
3388    };
3389    var visuallyHidden = {
3390      ...visuallyHiddenBase,
3391      position: "fixed",
3392      top: 0,
3393      left: 0
3394    };
3395    var visuallyHiddenInput = {
3396      ...visuallyHiddenBase,
3397      position: "absolute"
3398    };
3399  
3400    // node_modules/@base-ui/react/utils/FocusGuard.mjs
3401    var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3402    var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) {
3403      const [role, setRole] = React14.useState();
3404      useIsoLayoutEffect(() => {
3405        if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) {
3406          setRole("button");
3407        }
3408      }, []);
3409      const restProps = {
3410        tabIndex: 0,
3411        // Role is only for VoiceOver
3412        role
3413      };
3414      return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", {
3415        ...props,
3416        ref,
3417        style: visuallyHidden,
3418        "aria-hidden": role ? void 0 : true,
3419        ...restProps,
3420        "data-base-ui-focus-guard": ""
3421      });
3422    });
3423    if (true) FocusGuard.displayName = "FocusGuard";
3424  
3425    // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
3426    var sides = ["top", "right", "bottom", "left"];
3427    var min = Math.min;
3428    var max = Math.max;
3429    var round = Math.round;
3430    var floor = Math.floor;
3431    var createCoords = (v2) => ({
3432      x: v2,
3433      y: v2
3434    });
3435    var oppositeSideMap = {
3436      left: "right",
3437      right: "left",
3438      bottom: "top",
3439      top: "bottom"
3440    };
3441    function clamp(start, value, end) {
3442      return max(start, min(value, end));
3443    }
3444    function evaluate(value, param) {
3445      return typeof value === "function" ? value(param) : value;
3446    }
3447    function getSide(placement) {
3448      return placement.split("-")[0];
3449    }
3450    function getAlignment(placement) {
3451      return placement.split("-")[1];
3452    }
3453    function getOppositeAxis(axis) {
3454      return axis === "x" ? "y" : "x";
3455    }
3456    function getAxisLength(axis) {
3457      return axis === "y" ? "height" : "width";
3458    }
3459    function getSideAxis(placement) {
3460      const firstChar = placement[0];
3461      return firstChar === "t" || firstChar === "b" ? "y" : "x";
3462    }
3463    function getAlignmentAxis(placement) {
3464      return getOppositeAxis(getSideAxis(placement));
3465    }
3466    function getAlignmentSides(placement, rects, rtl) {
3467      if (rtl === void 0) {
3468        rtl = false;
3469      }
3470      const alignment = getAlignment(placement);
3471      const alignmentAxis = getAlignmentAxis(placement);
3472      const length = getAxisLength(alignmentAxis);
3473      let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
3474      if (rects.reference[length] > rects.floating[length]) {
3475        mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
3476      }
3477      return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
3478    }
3479    function getExpandedPlacements(placement) {
3480      const oppositePlacement = getOppositePlacement(placement);
3481      return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
3482    }
3483    function getOppositeAlignmentPlacement(placement) {
3484      return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
3485    }
3486    var lrPlacement = ["left", "right"];
3487    var rlPlacement = ["right", "left"];
3488    var tbPlacement = ["top", "bottom"];
3489    var btPlacement = ["bottom", "top"];
3490    function getSideList(side, isStart, rtl) {
3491      switch (side) {
3492        case "top":
3493        case "bottom":
3494          if (rtl) return isStart ? rlPlacement : lrPlacement;
3495          return isStart ? lrPlacement : rlPlacement;
3496        case "left":
3497        case "right":
3498          return isStart ? tbPlacement : btPlacement;
3499        default:
3500          return [];
3501      }
3502    }
3503    function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
3504      const alignment = getAlignment(placement);
3505      let list = getSideList(getSide(placement), direction === "start", rtl);
3506      if (alignment) {
3507        list = list.map((side) => side + "-" + alignment);
3508        if (flipAlignment) {
3509          list = list.concat(list.map(getOppositeAlignmentPlacement));
3510        }
3511      }
3512      return list;
3513    }
3514    function getOppositePlacement(placement) {
3515      const side = getSide(placement);
3516      return oppositeSideMap[side] + placement.slice(side.length);
3517    }
3518    function expandPaddingObject(padding) {
3519      return {
3520        top: 0,
3521        right: 0,
3522        bottom: 0,
3523        left: 0,
3524        ...padding
3525      };
3526    }
3527    function getPaddingObject(padding) {
3528      return typeof padding !== "number" ? expandPaddingObject(padding) : {
3529        top: padding,
3530        right: padding,
3531        bottom: padding,
3532        left: padding
3533      };
3534    }
3535    function rectToClientRect(rect) {
3536      const {
3537        x: x2,
3538        y: y2,
3539        width,
3540        height
3541      } = rect;
3542      return {
3543        width,
3544        height,
3545        top: y2,
3546        left: x2,
3547        right: x2 + width,
3548        bottom: y2 + height,
3549        x: x2,
3550        y: y2
3551      };
3552    }
3553  
3554    // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
3555    function isHiddenByStyles(styles) {
3556      return styles.visibility === "hidden" || styles.visibility === "collapse";
3557    }
3558    function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
3559      if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
3560        return false;
3561      }
3562      if (typeof element.checkVisibility === "function") {
3563        return element.checkVisibility();
3564      }
3565      return styles.display !== "none" && styles.display !== "contents";
3566    }
3567  
3568    // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs
3569    var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
3570    function getParentElement(element) {
3571      const assignedSlot = element.assignedSlot;
3572      if (assignedSlot) {
3573        return assignedSlot;
3574      }
3575      if (element.parentElement) {
3576        return element.parentElement;
3577      }
3578      const rootNode = element.getRootNode();
3579      return isShadowRoot(rootNode) ? rootNode.host : null;
3580    }
3581    function getDetailsSummary(details) {
3582      for (const child of Array.from(details.children)) {
3583        if (getNodeName(child) === "summary") {
3584          return child;
3585        }
3586      }
3587      return null;
3588    }
3589    function isWithinOpenDetailsSummary(element, details) {
3590      const summary = getDetailsSummary(details);
3591      return !!summary && (element === summary || contains(summary, element));
3592    }
3593    function isFocusableCandidate(element) {
3594      const nodeName = element ? getNodeName(element) : "";
3595      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");
3596    }
3597    function isFocusableElement(element) {
3598      if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
3599        return false;
3600      }
3601      for (let current = element; current; current = getParentElement(current)) {
3602        const isAncestor = current !== element;
3603        const isSlot = getNodeName(current) === "slot";
3604        if (current.hasAttribute("inert")) {
3605          return false;
3606        }
3607        if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
3608          return false;
3609        }
3610      }
3611      return true;
3612    }
3613    function isVisibleInTabbableTree(element, isAncestor) {
3614      const styles = getComputedStyle2(element);
3615      if (!isAncestor) {
3616        return isElementVisible(element, styles);
3617      }
3618      return styles.display !== "none";
3619    }
3620    function getTabIndex(element) {
3621      const tabIndex = element.tabIndex;
3622      if (tabIndex < 0) {
3623        const nodeName = getNodeName(element);
3624        if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
3625          return 0;
3626        }
3627      }
3628      return tabIndex;
3629    }
3630    function getNamedRadioInput(element) {
3631      if (getNodeName(element) !== "input") {
3632        return null;
3633      }
3634      const input = element;
3635      return input.type === "radio" && input.name !== "" ? input : null;
3636    }
3637    function isTabbableRadio(element, candidates) {
3638      const input = getNamedRadioInput(element);
3639      if (!input) {
3640        return true;
3641      }
3642      const checkedRadio = candidates.find((candidate) => {
3643        const radio = getNamedRadioInput(candidate);
3644        return radio?.name === input.name && radio.form === input.form && radio.checked;
3645      });
3646      if (checkedRadio) {
3647        return checkedRadio === input;
3648      }
3649      return candidates.find((candidate) => {
3650        const radio = getNamedRadioInput(candidate);
3651        return radio?.name === input.name && radio.form === input.form;
3652      }) === input;
3653    }
3654    function getComposedChildren(container) {
3655      if (isHTMLElement(container) && getNodeName(container) === "slot") {
3656        const assignedElements = container.assignedElements({
3657          flatten: true
3658        });
3659        if (assignedElements.length > 0) {
3660          return assignedElements;
3661        }
3662      }
3663      if (isHTMLElement(container) && container.shadowRoot) {
3664        return Array.from(container.shadowRoot.children);
3665      }
3666      return Array.from(container.children);
3667    }
3668    function appendCandidates(container, list) {
3669      getComposedChildren(container).forEach((child) => {
3670        if (isFocusableCandidate(child)) {
3671          list.push(child);
3672        }
3673        appendCandidates(child, list);
3674      });
3675    }
3676    function appendMatchingElements(container, selector2, list) {
3677      getComposedChildren(container).forEach((child) => {
3678        if (isHTMLElement(child) && child.matches(selector2)) {
3679          list.push(child);
3680        }
3681        appendMatchingElements(child, selector2, list);
3682      });
3683    }
3684    function focusable(container) {
3685      const candidates = [];
3686      appendCandidates(container, candidates);
3687      return candidates.filter(isFocusableElement);
3688    }
3689    function tabbable(container) {
3690      const candidates = focusable(container);
3691      return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
3692    }
3693    function getTabbableIn(container, dir) {
3694      const list = tabbable(container);
3695      const len = list.length;
3696      if (len === 0) {
3697        return void 0;
3698      }
3699      const active = activeElement(ownerDocument(container));
3700      const index2 = list.indexOf(active);
3701      const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
3702      return list[nextIndex];
3703    }
3704    function getNextTabbable(referenceElement) {
3705      return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
3706    }
3707    function getPreviousTabbable(referenceElement) {
3708      return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
3709    }
3710    function isOutsideEvent(event, container) {
3711      const containerElement = container || event.currentTarget;
3712      const relatedTarget = event.relatedTarget;
3713      return !relatedTarget || !contains(containerElement, relatedTarget);
3714    }
3715    function disableFocusInside(container) {
3716      const tabbableElements = tabbable(container);
3717      tabbableElements.forEach((element) => {
3718        element.dataset.tabindex = element.getAttribute("tabindex") || "";
3719        element.setAttribute("tabindex", "-1");
3720      });
3721    }
3722    function enableFocusInside(container) {
3723      const elements = [];
3724      appendMatchingElements(container, "[data-tabindex]", elements);
3725      elements.forEach((element) => {
3726        const tabindex = element.dataset.tabindex;
3727        delete element.dataset.tabindex;
3728        if (tabindex) {
3729          element.setAttribute("tabindex", tabindex);
3730        } else {
3731          element.removeAttribute("tabindex");
3732        }
3733      });
3734    }
3735  
3736    // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs
3737    function getNodeChildren(nodes, id, onlyOpenChildren = true) {
3738      const directChildren = nodes.filter((node) => node.parentId === id);
3739      return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
3740    }
3741  
3742    // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
3743    function createAttribute(name) {
3744      return `data-base-ui-$name}`;
3745    }
3746  
3747    // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3748    var React15 = __toESM(require_react(), 1);
3749    var ReactDOM2 = __toESM(require_react_dom(), 1);
3750  
3751    // node_modules/@base-ui/react/internals/constants.mjs
3752    var DISABLED_TRANSITIONS_STYLE = {
3753      style: {
3754        transition: "none"
3755      }
3756    };
3757    var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3758    var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3759    var BASE_UI_SWIPE_IGNORE_SELECTOR = `[$BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3760    var LEGACY_SWIPE_IGNORE_SELECTOR = `[$LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3761    var POPUP_COLLISION_AVOIDANCE = {
3762      fallbackAxisSide: "end"
3763    };
3764    var ownerVisuallyHidden = {
3765      clipPath: "inset(50%)",
3766      position: "fixed",
3767      top: 0,
3768      left: 0
3769    };
3770  
3771    // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3772    var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3773    var PortalContext = /* @__PURE__ */ React15.createContext(null);
3774    if (true) PortalContext.displayName = "PortalContext";
3775    var usePortalContext = () => React15.useContext(PortalContext);
3776    var attr = createAttribute("portal");
3777    function useFloatingPortalNode(props = {}) {
3778      const {
3779        ref,
3780        container: containerProp,
3781        componentProps = EMPTY_OBJECT,
3782        elementProps
3783      } = props;
3784      const uniqueId = useId();
3785      const portalContext = usePortalContext();
3786      const parentPortalNode = portalContext?.portalNode;
3787      const [containerElement, setContainerElement] = React15.useState(null);
3788      const [portalNode, setPortalNode] = React15.useState(null);
3789      const setPortalNodeRef = useStableCallback((node) => {
3790        if (node !== null) {
3791          setPortalNode(node);
3792        }
3793      });
3794      const containerRef = React15.useRef(null);
3795      useIsoLayoutEffect(() => {
3796        if (containerProp === null) {
3797          if (containerRef.current) {
3798            containerRef.current = null;
3799            setPortalNode(null);
3800            setContainerElement(null);
3801          }
3802          return;
3803        }
3804        if (uniqueId == null) {
3805          return;
3806        }
3807        const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3808        if (resolvedContainer == null) {
3809          if (containerRef.current) {
3810            containerRef.current = null;
3811            setPortalNode(null);
3812            setContainerElement(null);
3813          }
3814          return;
3815        }
3816        if (containerRef.current !== resolvedContainer) {
3817          containerRef.current = resolvedContainer;
3818          setPortalNode(null);
3819          setContainerElement(resolvedContainer);
3820        }
3821      }, [containerProp, parentPortalNode, uniqueId]);
3822      const portalElement = useRenderElement("div", componentProps, {
3823        ref: [ref, setPortalNodeRef],
3824        props: [{
3825          id: uniqueId,
3826          [attr]: ""
3827        }, elementProps]
3828      });
3829      const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3830      return {
3831        portalNode,
3832        portalSubtree
3833      };
3834    }
3835    var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3836      const {
3837        render: render4,
3838        className,
3839        style,
3840        children,
3841        container,
3842        renderGuards,
3843        ...elementProps
3844      } = componentProps;
3845      const {
3846        portalNode,
3847        portalSubtree
3848      } = useFloatingPortalNode({
3849        container,
3850        ref: forwardedRef,
3851        componentProps,
3852        elementProps
3853      });
3854      const beforeOutsideRef = React15.useRef(null);
3855      const afterOutsideRef = React15.useRef(null);
3856      const beforeInsideRef = React15.useRef(null);
3857      const afterInsideRef = React15.useRef(null);
3858      const [focusManagerState, setFocusManagerState] = React15.useState(null);
3859      const focusInsideDisabledRef = React15.useRef(false);
3860      const modal = focusManagerState?.modal;
3861      const open = focusManagerState?.open;
3862      const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3863      React15.useEffect(() => {
3864        if (!portalNode || modal) {
3865          return void 0;
3866        }
3867        function onFocus(event) {
3868          if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3869            if (event.type === "focusin") {
3870              if (focusInsideDisabledRef.current) {
3871                enableFocusInside(portalNode);
3872                focusInsideDisabledRef.current = false;
3873              }
3874            } else {
3875              disableFocusInside(portalNode);
3876              focusInsideDisabledRef.current = true;
3877            }
3878          }
3879        }
3880        return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3881      }, [portalNode, modal]);
3882      useIsoLayoutEffect(() => {
3883        if (!portalNode || open !== true || !focusInsideDisabledRef.current) {
3884          return;
3885        }
3886        enableFocusInside(portalNode);
3887        focusInsideDisabledRef.current = false;
3888      }, [open, portalNode]);
3889      const portalContextValue = React15.useMemo(() => ({
3890        beforeOutsideRef,
3891        afterOutsideRef,
3892        beforeInsideRef,
3893        afterInsideRef,
3894        portalNode,
3895        setFocusManagerState
3896      }), [portalNode]);
3897      return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(React15.Fragment, {
3898        children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(PortalContext.Provider, {
3899          value: portalContextValue,
3900          children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FocusGuard, {
3901            "data-type": "outside",
3902            ref: beforeOutsideRef,
3903            onFocus: (event) => {
3904              if (isOutsideEvent(event, portalNode)) {
3905                beforeInsideRef.current?.focus();
3906              } else {
3907                const domReference = focusManagerState ? focusManagerState.domReference : null;
3908                const prevTabbable = getPreviousTabbable(domReference);
3909                prevTabbable?.focus();
3910              }
3911            }
3912          }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", {
3913            "aria-owns": portalNode.id,
3914            style: ownerVisuallyHidden
3915          }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FocusGuard, {
3916            "data-type": "outside",
3917            ref: afterOutsideRef,
3918            onFocus: (event) => {
3919              if (isOutsideEvent(event, portalNode)) {
3920                afterInsideRef.current?.focus();
3921              } else {
3922                const domReference = focusManagerState ? focusManagerState.domReference : null;
3923                const nextTabbable = getNextTabbable(domReference);
3924                nextTabbable?.focus();
3925                if (focusManagerState?.closeOnFocusOut) {
3926                  focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3927                }
3928              }
3929            }
3930          })]
3931        })]
3932      });
3933    });
3934    if (true) FloatingPortal.displayName = "FloatingPortal";
3935  
3936    // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3937    var React16 = __toESM(require_react(), 1);
3938  
3939    // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
3940    function createEventEmitter() {
3941      const map = /* @__PURE__ */ new Map();
3942      return {
3943        emit(event, data) {
3944          map.get(event)?.forEach((listener) => listener(data));
3945        },
3946        on(event, listener) {
3947          if (!map.has(event)) {
3948            map.set(event, /* @__PURE__ */ new Set());
3949          }
3950          map.get(event).add(listener);
3951        },
3952        off(event, listener) {
3953          map.get(event)?.delete(listener);
3954        }
3955      };
3956    }
3957  
3958    // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3959    var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3960    var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null);
3961    if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3962    var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null);
3963    if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3964    var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null;
3965    var useFloatingTree = (externalTree) => {
3966      const contextTree = React16.useContext(FloatingTreeContext);
3967      return externalTree ?? contextTree;
3968    };
3969  
3970    // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
3971    var React17 = __toESM(require_react(), 1);
3972    function createVirtualElement(domElement, data) {
3973      let offsetX = null;
3974      let offsetY = null;
3975      let isAutoUpdateEvent = false;
3976      return {
3977        contextElement: domElement || void 0,
3978        getBoundingClientRect() {
3979          const domRect = domElement?.getBoundingClientRect() || {
3980            width: 0,
3981            height: 0,
3982            x: 0,
3983            y: 0
3984          };
3985          const isXAxis = data.axis === "x" || data.axis === "both";
3986          const isYAxis = data.axis === "y" || data.axis === "both";
3987          const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3988          let width = domRect.width;
3989          let height = domRect.height;
3990          let x2 = domRect.x;
3991          let y2 = domRect.y;
3992          if (offsetX == null && data.x && isXAxis) {
3993            offsetX = domRect.x - data.x;
3994          }
3995          if (offsetY == null && data.y && isYAxis) {
3996            offsetY = domRect.y - data.y;
3997          }
3998          x2 -= offsetX || 0;
3999          y2 -= offsetY || 0;
4000          width = 0;
4001          height = 0;
4002          if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
4003            width = data.axis === "y" ? domRect.width : 0;
4004            height = data.axis === "x" ? domRect.height : 0;
4005            x2 = isXAxis && data.x != null ? data.x : x2;
4006            y2 = isYAxis && data.y != null ? data.y : y2;
4007          } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
4008            height = data.axis === "x" ? domRect.height : height;
4009            width = data.axis === "y" ? domRect.width : width;
4010          }
4011          isAutoUpdateEvent = true;
4012          return {
4013            width,
4014            height,
4015            x: x2,
4016            y: y2,
4017            top: y2,
4018            right: x2 + width,
4019            bottom: y2 + height,
4020            left: x2
4021          };
4022        }
4023      };
4024    }
4025    function isMouseBasedEvent(event) {
4026      return event != null && event.clientX != null;
4027    }
4028    function useClientPoint(context, props = {}) {
4029      const {
4030        enabled = true,
4031        axis = "both"
4032      } = props;
4033      const store = "rootStore" in context ? context.rootStore : context;
4034      const open = store.useState("open");
4035      const floating = store.useState("floatingElement");
4036      const domReference = store.useState("domReferenceElement");
4037      const dataRef = store.context.dataRef;
4038      const initialRef = React17.useRef(false);
4039      const cleanupListenerRef = React17.useRef(null);
4040      const [pointerType, setPointerType] = React17.useState();
4041      const [reactive, setReactive] = React17.useState([]);
4042      const resetReference = useStableCallback((reference2) => {
4043        store.set("positionReference", reference2);
4044      });
4045      const setReference = useStableCallback((newX, newY, referenceElement) => {
4046        if (initialRef.current) {
4047          return;
4048        }
4049        if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
4050          return;
4051        }
4052        store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
4053          x: newX,
4054          y: newY,
4055          axis,
4056          dataRef,
4057          pointerType
4058        }));
4059      });
4060      const handleReferenceEnterOrMove = useStableCallback((event) => {
4061        if (!open) {
4062          setReference(event.clientX, event.clientY, event.currentTarget);
4063        } else if (!cleanupListenerRef.current) {
4064          setReference(event.clientX, event.clientY, event.currentTarget);
4065          setReactive([]);
4066        }
4067      });
4068      const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
4069      React17.useEffect(() => {
4070        if (!enabled) {
4071          resetReference(domReference);
4072          return void 0;
4073        }
4074        if (!openCheck) {
4075          return void 0;
4076        }
4077        function cleanupListener() {
4078          cleanupListenerRef.current?.();
4079          cleanupListenerRef.current = null;
4080        }
4081        const win = getWindow(floating);
4082        function handleMouseMove(event) {
4083          const target = getTarget(event);
4084          if (!contains(floating, target)) {
4085            setReference(event.clientX, event.clientY);
4086          } else {
4087            cleanupListener();
4088          }
4089        }
4090        if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
4091          cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
4092        } else {
4093          resetReference(domReference);
4094        }
4095        return cleanupListener;
4096      }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
4097      React17.useEffect(() => () => {
4098        store.set("positionReference", null);
4099      }, [store]);
4100      React17.useEffect(() => {
4101        if (enabled && !floating) {
4102          initialRef.current = false;
4103        }
4104      }, [enabled, floating]);
4105      React17.useEffect(() => {
4106        if (!enabled && open) {
4107          initialRef.current = true;
4108        }
4109      }, [enabled, open]);
4110      const reference = React17.useMemo(() => {
4111        function setPointerTypeRef(event) {
4112          setPointerType(event.pointerType);
4113        }
4114        return {
4115          onPointerDown: setPointerTypeRef,
4116          onPointerEnter: setPointerTypeRef,
4117          onMouseMove: handleReferenceEnterOrMove,
4118          onMouseEnter: handleReferenceEnterOrMove
4119        };
4120      }, [handleReferenceEnterOrMove]);
4121      return React17.useMemo(() => enabled ? {
4122        reference,
4123        trigger: reference
4124      } : {}, [enabled, reference]);
4125    }
4126  
4127    // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
4128    var React18 = __toESM(require_react(), 1);
4129    function alwaysFalse() {
4130      return false;
4131    }
4132    function normalizeProp(normalizable) {
4133      return {
4134        escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
4135        outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
4136      };
4137    }
4138    function useDismiss(context, props = {}) {
4139      const {
4140        enabled = true,
4141        escapeKey: escapeKey2 = true,
4142        outsidePress: outsidePressProp = true,
4143        outsidePressEvent = "sloppy",
4144        referencePress = alwaysFalse,
4145        bubbles,
4146        externalTree
4147      } = props;
4148      const store = "rootStore" in context ? context.rootStore : context;
4149      const open = store.useState("open");
4150      const floatingElement = store.useState("floatingElement");
4151      const {
4152        dataRef
4153      } = store.context;
4154      const tree = useFloatingTree(externalTree);
4155      const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
4156      const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
4157      const outsidePressEnabled = outsidePress2 !== false;
4158      const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
4159      const {
4160        escapeKey: escapeKeyBubbles,
4161        outsidePress: outsidePressBubbles
4162      } = normalizeProp(bubbles);
4163      const pressStartedInsideRef = React18.useRef(false);
4164      const pressStartPreventedRef = React18.useRef(false);
4165      const suppressNextOutsideClickRef = React18.useRef(false);
4166      const isComposingRef = React18.useRef(false);
4167      const currentPointerTypeRef = React18.useRef("");
4168      const touchStateRef = React18.useRef(null);
4169      const cancelDismissOnEndTimeout = useTimeout();
4170      const clearInsideReactTreeTimeout = useTimeout();
4171      const clearInsideReactTree = useStableCallback(() => {
4172        clearInsideReactTreeTimeout.clear();
4173        dataRef.current.insideReactTree = false;
4174      });
4175      const hasBlockingChild = useStableCallback((bubbleKey) => {
4176        const nodeId = dataRef.current.floatingContext?.nodeId;
4177        const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
4178        return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
4179      });
4180      const isEventWithinOwnElements = useStableCallback((event) => {
4181        return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
4182      });
4183      const closeOnReferencePress = useStableCallback((event) => {
4184        if (!referencePress()) {
4185          return;
4186        }
4187        store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
4188      });
4189      const closeOnEscapeKeyDown = useStableCallback((event) => {
4190        if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
4191          return;
4192        }
4193        if (isComposingRef.current) {
4194          return;
4195        }
4196        if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
4197          return;
4198        }
4199        const native = isReactEvent(event) ? event.nativeEvent : event;
4200        const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
4201        store.setOpen(false, eventDetails);
4202        if (!eventDetails.isCanceled) {
4203          event.preventDefault();
4204        }
4205        if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
4206          event.stopPropagation();
4207        }
4208      });
4209      const markInsideReactTree = useStableCallback(() => {
4210        dataRef.current.insideReactTree = true;
4211        clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
4212      });
4213      const markPressStartedInsideReactTree = useStableCallback((event) => {
4214        if (!open || !enabled || event.button !== 0) {
4215          return;
4216        }
4217        const target = getTarget(event.nativeEvent);
4218        if (!contains(store.select("floatingElement"), target)) {
4219          return;
4220        }
4221        if (!pressStartedInsideRef.current) {
4222          pressStartedInsideRef.current = true;
4223          pressStartPreventedRef.current = false;
4224        }
4225      });
4226      const markInsidePressStartPrevented = useStableCallback((event) => {
4227        if (!open || !enabled) {
4228          return;
4229        }
4230        if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
4231          return;
4232        }
4233        if (pressStartedInsideRef.current) {
4234          pressStartPreventedRef.current = true;
4235        }
4236      });
4237      React18.useEffect(() => {
4238        if (!open || !enabled) {
4239          return void 0;
4240        }
4241        dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
4242        dataRef.current.__outsidePressBubbles = outsidePressBubbles;
4243        const compositionTimeout = new Timeout();
4244        const preventedPressSuppressionTimeout = new Timeout();
4245        function handleCompositionStart() {
4246          compositionTimeout.clear();
4247          isComposingRef.current = true;
4248        }
4249        function handleCompositionEnd() {
4250          compositionTimeout.start(
4251            // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
4252            // Only apply to WebKit for the test to remain 0ms.
4253            parts_exports.engine.webkit ? 5 : 0,
4254            () => {
4255              isComposingRef.current = false;
4256            }
4257          );
4258        }
4259        function suppressImmediateOutsideClickAfterPreventedStart() {
4260          suppressNextOutsideClickRef.current = true;
4261          preventedPressSuppressionTimeout.start(0, () => {
4262            suppressNextOutsideClickRef.current = false;
4263          });
4264        }
4265        function resetPressStartState() {
4266          pressStartedInsideRef.current = false;
4267          pressStartPreventedRef.current = false;
4268        }
4269        function getOutsidePressEvent() {
4270          const type = currentPointerTypeRef.current;
4271          const computedType = type === "pen" || !type ? "mouse" : type;
4272          const outsidePressEventValue = getOutsidePressEventProp();
4273          const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
4274          if (typeof resolved === "string") {
4275            return resolved;
4276          }
4277          return resolved[computedType];
4278        }
4279        function shouldIgnoreEvent(event) {
4280          const computedOutsidePressEvent = getOutsidePressEvent();
4281          return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
4282        }
4283        function isEventWithinFloatingTree(event) {
4284          const nodeId = dataRef.current.floatingContext?.nodeId;
4285          const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
4286          return isEventWithinOwnElements(event) || targetIsInsideChildren;
4287        }
4288        function closeOnPressOutside(event) {
4289          if (shouldIgnoreEvent(event)) {
4290            if (event.type !== "click" && !isEventWithinOwnElements(event)) {
4291              preventedPressSuppressionTimeout.clear();
4292              suppressNextOutsideClickRef.current = false;
4293            }
4294            clearInsideReactTree();
4295            return;
4296          }
4297          if (dataRef.current.insideReactTree) {
4298            clearInsideReactTree();
4299            return;
4300          }
4301          const target = getTarget(event);
4302          const inertSelector = `[$createAttribute("inert")}]`;
4303          const targetRoot = isElement(target) ? target.getRootNode() : null;
4304          const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
4305          const triggers = store.context.triggerElements;
4306          if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
4307            return;
4308          }
4309          let targetRootAncestor = isElement(target) ? target : null;
4310          while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
4311            const nextParent = getParentNode(targetRootAncestor);
4312            if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
4313              break;
4314            }
4315            targetRootAncestor = nextParent;
4316          }
4317          if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
4318          !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
4319          // element was injected after the floating element rendered.
4320          markers.every((marker) => !contains(targetRootAncestor, marker))) {
4321            return;
4322          }
4323          if (isHTMLElement(target) && !("touches" in event)) {
4324            const lastTraversableNode = isLastTraversableNode(target);
4325            const style = getComputedStyle2(target);
4326            const scrollRe = /auto|scroll/;
4327            const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4328            const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
4329            const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
4330            const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
4331            const isRTL7 = style.direction === "rtl";
4332            const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
4333            const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
4334            if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
4335              return;
4336            }
4337          }
4338          if (isEventWithinFloatingTree(event)) {
4339            return;
4340          }
4341          if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
4342            preventedPressSuppressionTimeout.clear();
4343            suppressNextOutsideClickRef.current = false;
4344            return;
4345          }
4346          if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4347            return;
4348          }
4349          if (hasBlockingChild("__outsidePressBubbles")) {
4350            return;
4351          }
4352          store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
4353          clearInsideReactTree();
4354        }
4355        function handlePointerDown(event) {
4356          if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4357            return;
4358          }
4359          closeOnPressOutside(event);
4360        }
4361        function handleTouchStart(event) {
4362          if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4363            return;
4364          }
4365          const touch = event.touches[0];
4366          if (touch) {
4367            touchStateRef.current = {
4368              startTime: Date.now(),
4369              startX: touch.clientX,
4370              startY: touch.clientY,
4371              dismissOnTouchEnd: false,
4372              dismissOnMouseDown: true
4373            };
4374            cancelDismissOnEndTimeout.start(1e3, () => {
4375              if (touchStateRef.current) {
4376                touchStateRef.current.dismissOnTouchEnd = false;
4377                touchStateRef.current.dismissOnMouseDown = false;
4378              }
4379            });
4380          }
4381        }
4382        function addTargetEventListenerOnce(event, listener) {
4383          const target = getTarget(event);
4384          if (!target) {
4385            return;
4386          }
4387          const unsubscribe2 = addEventListener(target, event.type, () => {
4388            listener(event);
4389            unsubscribe2();
4390          });
4391        }
4392        function handleTouchStartCapture(event) {
4393          currentPointerTypeRef.current = "touch";
4394          addTargetEventListenerOnce(event, handleTouchStart);
4395        }
4396        function closeOnPressOutsideCapture(event) {
4397          cancelDismissOnEndTimeout.clear();
4398          if (event.type === "pointerdown") {
4399            currentPointerTypeRef.current = event.pointerType;
4400          }
4401          if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
4402            return;
4403          }
4404          addTargetEventListenerOnce(event, (targetEvent) => {
4405            if (targetEvent.type === "pointerdown") {
4406              handlePointerDown(targetEvent);
4407            } else {
4408              closeOnPressOutside(targetEvent);
4409            }
4410          });
4411        }
4412        function handlePressEndCapture(event) {
4413          if (!pressStartedInsideRef.current) {
4414            return;
4415          }
4416          const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
4417          resetPressStartState();
4418          if (getOutsidePressEvent() !== "intentional") {
4419            return;
4420          }
4421          if (event.type === "pointercancel") {
4422            if (pressStartedInsideDefaultPrevented) {
4423              suppressImmediateOutsideClickAfterPreventedStart();
4424            }
4425            return;
4426          }
4427          if (isEventWithinFloatingTree(event)) {
4428            return;
4429          }
4430          if (pressStartedInsideDefaultPrevented) {
4431            suppressImmediateOutsideClickAfterPreventedStart();
4432            return;
4433          }
4434          if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4435            return;
4436          }
4437          preventedPressSuppressionTimeout.clear();
4438          suppressNextOutsideClickRef.current = true;
4439          clearInsideReactTree();
4440        }
4441        function handleTouchMove(event) {
4442          if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4443            return;
4444          }
4445          const touch = event.touches[0];
4446          if (!touch) {
4447            return;
4448          }
4449          const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
4450          const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
4451          const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
4452          if (distance > 5) {
4453            touchStateRef.current.dismissOnTouchEnd = true;
4454          }
4455          if (distance > 10) {
4456            closeOnPressOutside(event);
4457            cancelDismissOnEndTimeout.clear();
4458            touchStateRef.current = null;
4459          }
4460        }
4461        function handleTouchMoveCapture(event) {
4462          addTargetEventListenerOnce(event, handleTouchMove);
4463        }
4464        function handleTouchEnd(event) {
4465          if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4466            return;
4467          }
4468          if (touchStateRef.current.dismissOnTouchEnd) {
4469            closeOnPressOutside(event);
4470          }
4471          cancelDismissOnEndTimeout.clear();
4472          touchStateRef.current = null;
4473        }
4474        function handleTouchEndCapture(event) {
4475          addTargetEventListenerOnce(event, handleTouchEnd);
4476        }
4477        const doc = ownerDocument(floatingElement);
4478        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)));
4479        return () => {
4480          unsubscribe();
4481          compositionTimeout.clear();
4482          preventedPressSuppressionTimeout.clear();
4483          resetPressStartState();
4484          suppressNextOutsideClickRef.current = false;
4485        };
4486      }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
4487      React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
4488      const reference = React18.useMemo(() => ({
4489        onKeyDown: closeOnEscapeKeyDown,
4490        onPointerDown: closeOnReferencePress,
4491        onClick: closeOnReferencePress
4492      }), [closeOnEscapeKeyDown, closeOnReferencePress]);
4493      const floating = React18.useMemo(() => ({
4494        onKeyDown: closeOnEscapeKeyDown,
4495        // `onMouseDown` may be blocked if `event.preventDefault()` is called in
4496        // `onPointerDown`, such as with <NumberField.ScrubArea>.
4497        // See https://github.com/mui/base-ui/pull/3379
4498        onPointerDown: markInsidePressStartPrevented,
4499        onMouseDown: markInsidePressStartPrevented,
4500        onClickCapture: markInsideReactTree,
4501        onMouseDownCapture(event) {
4502          markInsideReactTree();
4503          markPressStartedInsideReactTree(event);
4504        },
4505        onPointerDownCapture(event) {
4506          markInsideReactTree();
4507          markPressStartedInsideReactTree(event);
4508        },
4509        onMouseUpCapture: markInsideReactTree,
4510        onTouchEndCapture: markInsideReactTree,
4511        onTouchMoveCapture: markInsideReactTree
4512      }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
4513      return React18.useMemo(() => enabled ? {
4514        reference,
4515        floating,
4516        trigger: reference
4517      } : {}, [enabled, reference, floating]);
4518    }
4519  
4520    // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
4521    var React25 = __toESM(require_react(), 1);
4522  
4523    // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4524    function computeCoordsFromPlacement(_ref, placement, rtl) {
4525      let {
4526        reference,
4527        floating
4528      } = _ref;
4529      const sideAxis = getSideAxis(placement);
4530      const alignmentAxis = getAlignmentAxis(placement);
4531      const alignLength = getAxisLength(alignmentAxis);
4532      const side = getSide(placement);
4533      const isVertical = sideAxis === "y";
4534      const commonX = reference.x + reference.width / 2 - floating.width / 2;
4535      const commonY = reference.y + reference.height / 2 - floating.height / 2;
4536      const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4537      let coords;
4538      switch (side) {
4539        case "top":
4540          coords = {
4541            x: commonX,
4542            y: reference.y - floating.height
4543          };
4544          break;
4545        case "bottom":
4546          coords = {
4547            x: commonX,
4548            y: reference.y + reference.height
4549          };
4550          break;
4551        case "right":
4552          coords = {
4553            x: reference.x + reference.width,
4554            y: commonY
4555          };
4556          break;
4557        case "left":
4558          coords = {
4559            x: reference.x - floating.width,
4560            y: commonY
4561          };
4562          break;
4563        default:
4564          coords = {
4565            x: reference.x,
4566            y: reference.y
4567          };
4568      }
4569      switch (getAlignment(placement)) {
4570        case "start":
4571          coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4572          break;
4573        case "end":
4574          coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4575          break;
4576      }
4577      return coords;
4578    }
4579    async function detectOverflow(state, options) {
4580      var _await$platform$isEle;
4581      if (options === void 0) {
4582        options = {};
4583      }
4584      const {
4585        x: x2,
4586        y: y2,
4587        platform: platform3,
4588        rects,
4589        elements,
4590        strategy
4591      } = state;
4592      const {
4593        boundary = "clippingAncestors",
4594        rootBoundary = "viewport",
4595        elementContext = "floating",
4596        altBoundary = false,
4597        padding = 0
4598      } = evaluate(options, state);
4599      const paddingObject = getPaddingObject(padding);
4600      const altContext = elementContext === "floating" ? "reference" : "floating";
4601      const element = elements[altBoundary ? altContext : elementContext];
4602      const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
4603        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)),
4604        boundary,
4605        rootBoundary,
4606        strategy
4607      }));
4608      const rect = elementContext === "floating" ? {
4609        x: x2,
4610        y: y2,
4611        width: rects.floating.width,
4612        height: rects.floating.height
4613      } : rects.reference;
4614      const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4615      const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4616        x: 1,
4617        y: 1
4618      } : {
4619        x: 1,
4620        y: 1
4621      };
4622      const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4623        elements,
4624        rect,
4625        offsetParent,
4626        strategy
4627      }) : rect);
4628      return {
4629        top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4630        bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4631        left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4632        right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4633      };
4634    }
4635    var MAX_RESET_COUNT = 50;
4636    var computePosition = async (reference, floating, config) => {
4637      const {
4638        placement = "bottom",
4639        strategy = "absolute",
4640        middleware = [],
4641        platform: platform3
4642      } = config;
4643      const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4644        ...platform3,
4645        detectOverflow
4646      };
4647      const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4648      let rects = await platform3.getElementRects({
4649        reference,
4650        floating,
4651        strategy
4652      });
4653      let {
4654        x: x2,
4655        y: y2
4656      } = computeCoordsFromPlacement(rects, placement, rtl);
4657      let statefulPlacement = placement;
4658      let resetCount = 0;
4659      const middlewareData = {};
4660      for (let i2 = 0; i2 < middleware.length; i2++) {
4661        const currentMiddleware = middleware[i2];
4662        if (!currentMiddleware) {
4663          continue;
4664        }
4665        const {
4666          name,
4667          fn
4668        } = currentMiddleware;
4669        const {
4670          x: nextX,
4671          y: nextY,
4672          data,
4673          reset
4674        } = await fn({
4675          x: x2,
4676          y: y2,
4677          initialPlacement: placement,
4678          placement: statefulPlacement,
4679          strategy,
4680          middlewareData,
4681          rects,
4682          platform: platformWithDetectOverflow,
4683          elements: {
4684            reference,
4685            floating
4686          }
4687        });
4688        x2 = nextX != null ? nextX : x2;
4689        y2 = nextY != null ? nextY : y2;
4690        middlewareData[name] = {
4691          ...middlewareData[name],
4692          ...data
4693        };
4694        if (reset && resetCount < MAX_RESET_COUNT) {
4695          resetCount++;
4696          if (typeof reset === "object") {
4697            if (reset.placement) {
4698              statefulPlacement = reset.placement;
4699            }
4700            if (reset.rects) {
4701              rects = reset.rects === true ? await platform3.getElementRects({
4702                reference,
4703                floating,
4704                strategy
4705              }) : reset.rects;
4706            }
4707            ({
4708              x: x2,
4709              y: y2
4710            } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4711          }
4712          i2 = -1;
4713        }
4714      }
4715      return {
4716        x: x2,
4717        y: y2,
4718        placement: statefulPlacement,
4719        strategy,
4720        middlewareData
4721      };
4722    };
4723    var flip = function(options) {
4724      if (options === void 0) {
4725        options = {};
4726      }
4727      return {
4728        name: "flip",
4729        options,
4730        async fn(state) {
4731          var _middlewareData$arrow, _middlewareData$flip;
4732          const {
4733            placement,
4734            middlewareData,
4735            rects,
4736            initialPlacement,
4737            platform: platform3,
4738            elements
4739          } = state;
4740          const {
4741            mainAxis: checkMainAxis = true,
4742            crossAxis: checkCrossAxis = true,
4743            fallbackPlacements: specifiedFallbackPlacements,
4744            fallbackStrategy = "bestFit",
4745            fallbackAxisSideDirection = "none",
4746            flipAlignment = true,
4747            ...detectOverflowOptions
4748          } = evaluate(options, state);
4749          if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4750            return {};
4751          }
4752          const side = getSide(placement);
4753          const initialSideAxis = getSideAxis(initialPlacement);
4754          const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4755          const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4756          const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4757          const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4758          if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4759            fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4760          }
4761          const placements2 = [initialPlacement, ...fallbackPlacements];
4762          const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4763          const overflows = [];
4764          let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4765          if (checkMainAxis) {
4766            overflows.push(overflow[side]);
4767          }
4768          if (checkCrossAxis) {
4769            const sides2 = getAlignmentSides(placement, rects, rtl);
4770            overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4771          }
4772          overflowsData = [...overflowsData, {
4773            placement,
4774            overflows
4775          }];
4776          if (!overflows.every((side2) => side2 <= 0)) {
4777            var _middlewareData$flip2, _overflowsData$filter;
4778            const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4779            const nextPlacement = placements2[nextIndex];
4780            if (nextPlacement) {
4781              const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4782              if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4783              // overflows the main axis.
4784              overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4785                return {
4786                  data: {
4787                    index: nextIndex,
4788                    overflows: overflowsData
4789                  },
4790                  reset: {
4791                    placement: nextPlacement
4792                  }
4793                };
4794              }
4795            }
4796            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;
4797            if (!resetPlacement) {
4798              switch (fallbackStrategy) {
4799                case "bestFit": {
4800                  var _overflowsData$filter2;
4801                  const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4802                    if (hasFallbackAxisSideDirection) {
4803                      const currentSideAxis = getSideAxis(d2.placement);
4804                      return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4805                      // reading directions favoring greater width.
4806                      currentSideAxis === "y";
4807                    }
4808                    return true;
4809                  }).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];
4810                  if (placement2) {
4811                    resetPlacement = placement2;
4812                  }
4813                  break;
4814                }
4815                case "initialPlacement":
4816                  resetPlacement = initialPlacement;
4817                  break;
4818              }
4819            }
4820            if (placement !== resetPlacement) {
4821              return {
4822                reset: {
4823                  placement: resetPlacement
4824                }
4825              };
4826            }
4827          }
4828          return {};
4829        }
4830      };
4831    };
4832    function getSideOffsets(overflow, rect) {
4833      return {
4834        top: overflow.top - rect.height,
4835        right: overflow.right - rect.width,
4836        bottom: overflow.bottom - rect.height,
4837        left: overflow.left - rect.width
4838      };
4839    }
4840    function isAnySideFullyClipped(overflow) {
4841      return sides.some((side) => overflow[side] >= 0);
4842    }
4843    var hide = function(options) {
4844      if (options === void 0) {
4845        options = {};
4846      }
4847      return {
4848        name: "hide",
4849        options,
4850        async fn(state) {
4851          const {
4852            rects,
4853            platform: platform3
4854          } = state;
4855          const {
4856            strategy = "referenceHidden",
4857            ...detectOverflowOptions
4858          } = evaluate(options, state);
4859          switch (strategy) {
4860            case "referenceHidden": {
4861              const overflow = await platform3.detectOverflow(state, {
4862                ...detectOverflowOptions,
4863                elementContext: "reference"
4864              });
4865              const offsets = getSideOffsets(overflow, rects.reference);
4866              return {
4867                data: {
4868                  referenceHiddenOffsets: offsets,
4869                  referenceHidden: isAnySideFullyClipped(offsets)
4870                }
4871              };
4872            }
4873            case "escaped": {
4874              const overflow = await platform3.detectOverflow(state, {
4875                ...detectOverflowOptions,
4876                altBoundary: true
4877              });
4878              const offsets = getSideOffsets(overflow, rects.floating);
4879              return {
4880                data: {
4881                  escapedOffsets: offsets,
4882                  escaped: isAnySideFullyClipped(offsets)
4883                }
4884              };
4885            }
4886            default: {
4887              return {};
4888            }
4889          }
4890        }
4891      };
4892    };
4893    var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4894    async function convertValueToCoords(state, options) {
4895      const {
4896        placement,
4897        platform: platform3,
4898        elements
4899      } = state;
4900      const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4901      const side = getSide(placement);
4902      const alignment = getAlignment(placement);
4903      const isVertical = getSideAxis(placement) === "y";
4904      const mainAxisMulti = originSides.has(side) ? -1 : 1;
4905      const crossAxisMulti = rtl && isVertical ? -1 : 1;
4906      const rawValue = evaluate(options, state);
4907      let {
4908        mainAxis,
4909        crossAxis,
4910        alignmentAxis
4911      } = typeof rawValue === "number" ? {
4912        mainAxis: rawValue,
4913        crossAxis: 0,
4914        alignmentAxis: null
4915      } : {
4916        mainAxis: rawValue.mainAxis || 0,
4917        crossAxis: rawValue.crossAxis || 0,
4918        alignmentAxis: rawValue.alignmentAxis
4919      };
4920      if (alignment && typeof alignmentAxis === "number") {
4921        crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4922      }
4923      return isVertical ? {
4924        x: crossAxis * crossAxisMulti,
4925        y: mainAxis * mainAxisMulti
4926      } : {
4927        x: mainAxis * mainAxisMulti,
4928        y: crossAxis * crossAxisMulti
4929      };
4930    }
4931    var offset = function(options) {
4932      if (options === void 0) {
4933        options = 0;
4934      }
4935      return {
4936        name: "offset",
4937        options,
4938        async fn(state) {
4939          var _middlewareData$offse, _middlewareData$arrow;
4940          const {
4941            x: x2,
4942            y: y2,
4943            placement,
4944            middlewareData
4945          } = state;
4946          const diffCoords = await convertValueToCoords(state, options);
4947          if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4948            return {};
4949          }
4950          return {
4951            x: x2 + diffCoords.x,
4952            y: y2 + diffCoords.y,
4953            data: {
4954              ...diffCoords,
4955              placement
4956            }
4957          };
4958        }
4959      };
4960    };
4961    var shift = function(options) {
4962      if (options === void 0) {
4963        options = {};
4964      }
4965      return {
4966        name: "shift",
4967        options,
4968        async fn(state) {
4969          const {
4970            x: x2,
4971            y: y2,
4972            placement,
4973            platform: platform3
4974          } = state;
4975          const {
4976            mainAxis: checkMainAxis = true,
4977            crossAxis: checkCrossAxis = false,
4978            limiter = {
4979              fn: (_ref) => {
4980                let {
4981                  x: x3,
4982                  y: y3
4983                } = _ref;
4984                return {
4985                  x: x3,
4986                  y: y3
4987                };
4988              }
4989            },
4990            ...detectOverflowOptions
4991          } = evaluate(options, state);
4992          const coords = {
4993            x: x2,
4994            y: y2
4995          };
4996          const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4997          const crossAxis = getSideAxis(getSide(placement));
4998          const mainAxis = getOppositeAxis(crossAxis);
4999          let mainAxisCoord = coords[mainAxis];
5000          let crossAxisCoord = coords[crossAxis];
5001          if (checkMainAxis) {
5002            const minSide = mainAxis === "y" ? "top" : "left";
5003            const maxSide = mainAxis === "y" ? "bottom" : "right";
5004            const min2 = mainAxisCoord + overflow[minSide];
5005            const max2 = mainAxisCoord - overflow[maxSide];
5006            mainAxisCoord = clamp(min2, mainAxisCoord, max2);
5007          }
5008          if (checkCrossAxis) {
5009            const minSide = crossAxis === "y" ? "top" : "left";
5010            const maxSide = crossAxis === "y" ? "bottom" : "right";
5011            const min2 = crossAxisCoord + overflow[minSide];
5012            const max2 = crossAxisCoord - overflow[maxSide];
5013            crossAxisCoord = clamp(min2, crossAxisCoord, max2);
5014          }
5015          const limitedCoords = limiter.fn({
5016            ...state,
5017            [mainAxis]: mainAxisCoord,
5018            [crossAxis]: crossAxisCoord
5019          });
5020          return {
5021            ...limitedCoords,
5022            data: {
5023              x: limitedCoords.x - x2,
5024              y: limitedCoords.y - y2,
5025              enabled: {
5026                [mainAxis]: checkMainAxis,
5027                [crossAxis]: checkCrossAxis
5028              }
5029            }
5030          };
5031        }
5032      };
5033    };
5034    var limitShift = function(options) {
5035      if (options === void 0) {
5036        options = {};
5037      }
5038      return {
5039        options,
5040        fn(state) {
5041          const {
5042            x: x2,
5043            y: y2,
5044            placement,
5045            rects,
5046            middlewareData
5047          } = state;
5048          const {
5049            offset: offset4 = 0,
5050            mainAxis: checkMainAxis = true,
5051            crossAxis: checkCrossAxis = true
5052          } = evaluate(options, state);
5053          const coords = {
5054            x: x2,
5055            y: y2
5056          };
5057          const crossAxis = getSideAxis(placement);
5058          const mainAxis = getOppositeAxis(crossAxis);
5059          let mainAxisCoord = coords[mainAxis];
5060          let crossAxisCoord = coords[crossAxis];
5061          const rawOffset = evaluate(offset4, state);
5062          const computedOffset = typeof rawOffset === "number" ? {
5063            mainAxis: rawOffset,
5064            crossAxis: 0
5065          } : {
5066            mainAxis: 0,
5067            crossAxis: 0,
5068            ...rawOffset
5069          };
5070          if (checkMainAxis) {
5071            const len = mainAxis === "y" ? "height" : "width";
5072            const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
5073            const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
5074            if (mainAxisCoord < limitMin) {
5075              mainAxisCoord = limitMin;
5076            } else if (mainAxisCoord > limitMax) {
5077              mainAxisCoord = limitMax;
5078            }
5079          }
5080          if (checkCrossAxis) {
5081            var _middlewareData$offse, _middlewareData$offse2;
5082            const len = mainAxis === "y" ? "width" : "height";
5083            const isOriginSide = originSides.has(getSide(placement));
5084            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);
5085            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);
5086            if (crossAxisCoord < limitMin) {
5087              crossAxisCoord = limitMin;
5088            } else if (crossAxisCoord > limitMax) {
5089              crossAxisCoord = limitMax;
5090            }
5091          }
5092          return {
5093            [mainAxis]: mainAxisCoord,
5094            [crossAxis]: crossAxisCoord
5095          };
5096        }
5097      };
5098    };
5099    var size = function(options) {
5100      if (options === void 0) {
5101        options = {};
5102      }
5103      return {
5104        name: "size",
5105        options,
5106        async fn(state) {
5107          var _state$middlewareData, _state$middlewareData2;
5108          const {
5109            placement,
5110            rects,
5111            platform: platform3,
5112            elements
5113          } = state;
5114          const {
5115            apply = () => {
5116            },
5117            ...detectOverflowOptions
5118          } = evaluate(options, state);
5119          const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
5120          const side = getSide(placement);
5121          const alignment = getAlignment(placement);
5122          const isYAxis = getSideAxis(placement) === "y";
5123          const {
5124            width,
5125            height
5126          } = rects.floating;
5127          let heightSide;
5128          let widthSide;
5129          if (side === "top" || side === "bottom") {
5130            heightSide = side;
5131            widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
5132          } else {
5133            widthSide = side;
5134            heightSide = alignment === "end" ? "top" : "bottom";
5135          }
5136          const maximumClippingHeight = height - overflow.top - overflow.bottom;
5137          const maximumClippingWidth = width - overflow.left - overflow.right;
5138          const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
5139          const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
5140          const noShift = !state.middlewareData.shift;
5141          let availableHeight = overflowAvailableHeight;
5142          let availableWidth = overflowAvailableWidth;
5143          if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
5144            availableWidth = maximumClippingWidth;
5145          }
5146          if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
5147            availableHeight = maximumClippingHeight;
5148          }
5149          if (noShift && !alignment) {
5150            const xMin = max(overflow.left, 0);
5151            const xMax = max(overflow.right, 0);
5152            const yMin = max(overflow.top, 0);
5153            const yMax = max(overflow.bottom, 0);
5154            if (isYAxis) {
5155              availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
5156            } else {
5157              availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
5158            }
5159          }
5160          await apply({
5161            ...state,
5162            availableWidth,
5163            availableHeight
5164          });
5165          const nextDimensions = await platform3.getDimensions(elements.floating);
5166          if (width !== nextDimensions.width || height !== nextDimensions.height) {
5167            return {
5168              reset: {
5169                rects: true
5170              }
5171            };
5172          }
5173          return {};
5174        }
5175      };
5176    };
5177  
5178    // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
5179    function getCssDimensions(element) {
5180      const css = getComputedStyle2(element);
5181      let width = parseFloat(css.width) || 0;
5182      let height = parseFloat(css.height) || 0;
5183      const hasOffset = isHTMLElement(element);
5184      const offsetWidth = hasOffset ? element.offsetWidth : width;
5185      const offsetHeight = hasOffset ? element.offsetHeight : height;
5186      const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
5187      if (shouldFallback) {
5188        width = offsetWidth;
5189        height = offsetHeight;
5190      }
5191      return {
5192        width,
5193        height,
5194        $: shouldFallback
5195      };
5196    }
5197    function unwrapElement(element) {
5198      return !isElement(element) ? element.contextElement : element;
5199    }
5200    function getScale(element) {
5201      const domElement = unwrapElement(element);
5202      if (!isHTMLElement(domElement)) {
5203        return createCoords(1);
5204      }
5205      const rect = domElement.getBoundingClientRect();
5206      const {
5207        width,
5208        height,
5209        $: $2
5210      } = getCssDimensions(domElement);
5211      let x2 = ($2 ? round(rect.width) : rect.width) / width;
5212      let y2 = ($2 ? round(rect.height) : rect.height) / height;
5213      if (!x2 || !Number.isFinite(x2)) {
5214        x2 = 1;
5215      }
5216      if (!y2 || !Number.isFinite(y2)) {
5217        y2 = 1;
5218      }
5219      return {
5220        x: x2,
5221        y: y2
5222      };
5223    }
5224    var noOffsets = /* @__PURE__ */ createCoords(0);
5225    function getVisualOffsets(element) {
5226      const win = getWindow(element);
5227      if (!isWebKit() || !win.visualViewport) {
5228        return noOffsets;
5229      }
5230      return {
5231        x: win.visualViewport.offsetLeft,
5232        y: win.visualViewport.offsetTop
5233      };
5234    }
5235    function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5236      if (isFixed === void 0) {
5237        isFixed = false;
5238      }
5239      if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5240        return false;
5241      }
5242      return isFixed;
5243    }
5244    function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5245      if (includeScale === void 0) {
5246        includeScale = false;
5247      }
5248      if (isFixedStrategy === void 0) {
5249        isFixedStrategy = false;
5250      }
5251      const clientRect = element.getBoundingClientRect();
5252      const domElement = unwrapElement(element);
5253      let scale = createCoords(1);
5254      if (includeScale) {
5255        if (offsetParent) {
5256          if (isElement(offsetParent)) {
5257            scale = getScale(offsetParent);
5258          }
5259        } else {
5260          scale = getScale(element);
5261        }
5262      }
5263      const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5264      let x2 = (clientRect.left + visualOffsets.x) / scale.x;
5265      let y2 = (clientRect.top + visualOffsets.y) / scale.y;
5266      let width = clientRect.width / scale.x;
5267      let height = clientRect.height / scale.y;
5268      if (domElement) {
5269        const win = getWindow(domElement);
5270        const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5271        let currentWin = win;
5272        let currentIFrame = getFrameElement(currentWin);
5273        while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5274          const iframeScale = getScale(currentIFrame);
5275          const iframeRect = currentIFrame.getBoundingClientRect();
5276          const css = getComputedStyle2(currentIFrame);
5277          const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5278          const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5279          x2 *= iframeScale.x;
5280          y2 *= iframeScale.y;
5281          width *= iframeScale.x;
5282          height *= iframeScale.y;
5283          x2 += left;
5284          y2 += top;
5285          currentWin = getWindow(currentIFrame);
5286          currentIFrame = getFrameElement(currentWin);
5287        }
5288      }
5289      return rectToClientRect({
5290        width,
5291        height,
5292        x: x2,
5293        y: y2
5294      });
5295    }
5296    function getWindowScrollBarX(element, rect) {
5297      const leftScroll = getNodeScroll(element).scrollLeft;
5298      if (!rect) {
5299        return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5300      }
5301      return rect.left + leftScroll;
5302    }
5303    function getHTMLOffset(documentElement, scroll) {
5304      const htmlRect = documentElement.getBoundingClientRect();
5305      const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5306      const y2 = htmlRect.top + scroll.scrollTop;
5307      return {
5308        x: x2,
5309        y: y2
5310      };
5311    }
5312    function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5313      let {
5314        elements,
5315        rect,
5316        offsetParent,
5317        strategy
5318      } = _ref;
5319      const isFixed = strategy === "fixed";
5320      const documentElement = getDocumentElement(offsetParent);
5321      const topLayer = elements ? isTopLayer(elements.floating) : false;
5322      if (offsetParent === documentElement || topLayer && isFixed) {
5323        return rect;
5324      }
5325      let scroll = {
5326        scrollLeft: 0,
5327        scrollTop: 0
5328      };
5329      let scale = createCoords(1);
5330      const offsets = createCoords(0);
5331      const isOffsetParentAnElement = isHTMLElement(offsetParent);
5332      if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5333        if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5334          scroll = getNodeScroll(offsetParent);
5335        }
5336        if (isOffsetParentAnElement) {
5337          const offsetRect = getBoundingClientRect(offsetParent);
5338          scale = getScale(offsetParent);
5339          offsets.x = offsetRect.x + offsetParent.clientLeft;
5340          offsets.y = offsetRect.y + offsetParent.clientTop;
5341        }
5342      }
5343      const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5344      return {
5345        width: rect.width * scale.x,
5346        height: rect.height * scale.y,
5347        x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5348        y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5349      };
5350    }
5351    function getClientRects(element) {
5352      return Array.from(element.getClientRects());
5353    }
5354    function getDocumentRect(element) {
5355      const html = getDocumentElement(element);
5356      const scroll = getNodeScroll(element);
5357      const body = element.ownerDocument.body;
5358      const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5359      const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5360      let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
5361      const y2 = -scroll.scrollTop;
5362      if (getComputedStyle2(body).direction === "rtl") {
5363        x2 += max(html.clientWidth, body.clientWidth) - width;
5364      }
5365      return {
5366        width,
5367        height,
5368        x: x2,
5369        y: y2
5370      };
5371    }
5372    var SCROLLBAR_MAX = 25;
5373    function getViewportRect(element, strategy) {
5374      const win = getWindow(element);
5375      const html = getDocumentElement(element);
5376      const visualViewport = win.visualViewport;
5377      let width = html.clientWidth;
5378      let height = html.clientHeight;
5379      let x2 = 0;
5380      let y2 = 0;
5381      if (visualViewport) {
5382        width = visualViewport.width;
5383        height = visualViewport.height;
5384        const visualViewportBased = isWebKit();
5385        if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5386          x2 = visualViewport.offsetLeft;
5387          y2 = visualViewport.offsetTop;
5388        }
5389      }
5390      const windowScrollbarX = getWindowScrollBarX(html);
5391      if (windowScrollbarX <= 0) {
5392        const doc = html.ownerDocument;
5393        const body = doc.body;
5394        const bodyStyles = getComputedStyle(body);
5395        const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5396        const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5397        if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5398          width -= clippingStableScrollbarWidth;
5399        }
5400      } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5401        width += windowScrollbarX;
5402      }
5403      return {
5404        width,
5405        height,
5406        x: x2,
5407        y: y2
5408      };
5409    }
5410    function getInnerBoundingClientRect(element, strategy) {
5411      const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5412      const top = clientRect.top + element.clientTop;
5413      const left = clientRect.left + element.clientLeft;
5414      const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5415      const width = element.clientWidth * scale.x;
5416      const height = element.clientHeight * scale.y;
5417      const x2 = left * scale.x;
5418      const y2 = top * scale.y;
5419      return {
5420        width,
5421        height,
5422        x: x2,
5423        y: y2
5424      };
5425    }
5426    function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5427      let rect;
5428      if (clippingAncestor === "viewport") {
5429        rect = getViewportRect(element, strategy);
5430      } else if (clippingAncestor === "document") {
5431        rect = getDocumentRect(getDocumentElement(element));
5432      } else if (isElement(clippingAncestor)) {
5433        rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5434      } else {
5435        const visualOffsets = getVisualOffsets(element);
5436        rect = {
5437          x: clippingAncestor.x - visualOffsets.x,
5438          y: clippingAncestor.y - visualOffsets.y,
5439          width: clippingAncestor.width,
5440          height: clippingAncestor.height
5441        };
5442      }
5443      return rectToClientRect(rect);
5444    }
5445    function hasFixedPositionAncestor(element, stopNode) {
5446      const parentNode = getParentNode(element);
5447      if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5448        return false;
5449      }
5450      return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5451    }
5452    function getClippingElementAncestors(element, cache) {
5453      const cachedResult = cache.get(element);
5454      if (cachedResult) {
5455        return cachedResult;
5456      }
5457      let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5458      let currentContainingBlockComputedStyle = null;
5459      const elementIsFixed = getComputedStyle2(element).position === "fixed";
5460      let currentNode = elementIsFixed ? getParentNode(element) : element;
5461      while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5462        const computedStyle = getComputedStyle2(currentNode);
5463        const currentNodeIsContaining = isContainingBlock(currentNode);
5464        if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5465          currentContainingBlockComputedStyle = null;
5466        }
5467        const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5468        if (shouldDropCurrentNode) {
5469          result = result.filter((ancestor) => ancestor !== currentNode);
5470        } else {
5471          currentContainingBlockComputedStyle = computedStyle;
5472        }
5473        currentNode = getParentNode(currentNode);
5474      }
5475      cache.set(element, result);
5476      return result;
5477    }
5478    function getClippingRect(_ref) {
5479      let {
5480        element,
5481        boundary,
5482        rootBoundary,
5483        strategy
5484      } = _ref;
5485      const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5486      const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5487      const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
5488      let top = firstRect.top;
5489      let right = firstRect.right;
5490      let bottom = firstRect.bottom;
5491      let left = firstRect.left;
5492      for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
5493        const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
5494        top = max(rect.top, top);
5495        right = min(rect.right, right);
5496        bottom = min(rect.bottom, bottom);
5497        left = max(rect.left, left);
5498      }
5499      return {
5500        width: right - left,
5501        height: bottom - top,
5502        x: left,
5503        y: top
5504      };
5505    }
5506    function getDimensions(element) {
5507      const {
5508        width,
5509        height
5510      } = getCssDimensions(element);
5511      return {
5512        width,
5513        height
5514      };
5515    }
5516    function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5517      const isOffsetParentAnElement = isHTMLElement(offsetParent);
5518      const documentElement = getDocumentElement(offsetParent);
5519      const isFixed = strategy === "fixed";
5520      const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5521      let scroll = {
5522        scrollLeft: 0,
5523        scrollTop: 0
5524      };
5525      const offsets = createCoords(0);
5526      function setLeftRTLScrollbarOffset() {
5527        offsets.x = getWindowScrollBarX(documentElement);
5528      }
5529      if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5530        if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5531          scroll = getNodeScroll(offsetParent);
5532        }
5533        if (isOffsetParentAnElement) {
5534          const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5535          offsets.x = offsetRect.x + offsetParent.clientLeft;
5536          offsets.y = offsetRect.y + offsetParent.clientTop;
5537        } else if (documentElement) {
5538          setLeftRTLScrollbarOffset();
5539        }
5540      }
5541      if (isFixed && !isOffsetParentAnElement && documentElement) {
5542        setLeftRTLScrollbarOffset();
5543      }
5544      const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5545      const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5546      const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5547      return {
5548        x: x2,
5549        y: y2,
5550        width: rect.width,
5551        height: rect.height
5552      };
5553    }
5554    function isStaticPositioned(element) {
5555      return getComputedStyle2(element).position === "static";
5556    }
5557    function getTrueOffsetParent(element, polyfill) {
5558      if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5559        return null;
5560      }
5561      if (polyfill) {
5562        return polyfill(element);
5563      }
5564      let rawOffsetParent = element.offsetParent;
5565      if (getDocumentElement(element) === rawOffsetParent) {
5566        rawOffsetParent = rawOffsetParent.ownerDocument.body;
5567      }
5568      return rawOffsetParent;
5569    }
5570    function getOffsetParent(element, polyfill) {
5571      const win = getWindow(element);
5572      if (isTopLayer(element)) {
5573        return win;
5574      }
5575      if (!isHTMLElement(element)) {
5576        let svgOffsetParent = getParentNode(element);
5577        while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5578          if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5579            return svgOffsetParent;
5580          }
5581          svgOffsetParent = getParentNode(svgOffsetParent);
5582        }
5583        return win;
5584      }
5585      let offsetParent = getTrueOffsetParent(element, polyfill);
5586      while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5587        offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5588      }
5589      if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5590        return win;
5591      }
5592      return offsetParent || getContainingBlock(element) || win;
5593    }
5594    var getElementRects = async function(data) {
5595      const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5596      const getDimensionsFn = this.getDimensions;
5597      const floatingDimensions = await getDimensionsFn(data.floating);
5598      return {
5599        reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5600        floating: {
5601          x: 0,
5602          y: 0,
5603          width: floatingDimensions.width,
5604          height: floatingDimensions.height
5605        }
5606      };
5607    };
5608    function isRTL(element) {
5609      return getComputedStyle2(element).direction === "rtl";
5610    }
5611    var platform2 = {
5612      convertOffsetParentRelativeRectToViewportRelativeRect,
5613      getDocumentElement,
5614      getClippingRect,
5615      getOffsetParent,
5616      getElementRects,
5617      getClientRects,
5618      getDimensions,
5619      getScale,
5620      isElement,
5621      isRTL
5622    };
5623    function rectsAreEqual(a2, b2) {
5624      return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5625    }
5626    function observeMove(element, onMove) {
5627      let io = null;
5628      let timeoutId;
5629      const root = getDocumentElement(element);
5630      function cleanup() {
5631        var _io;
5632        clearTimeout(timeoutId);
5633        (_io = io) == null || _io.disconnect();
5634        io = null;
5635      }
5636      function refresh(skip, threshold) {
5637        if (skip === void 0) {
5638          skip = false;
5639        }
5640        if (threshold === void 0) {
5641          threshold = 1;
5642        }
5643        cleanup();
5644        const elementRectForRootMargin = element.getBoundingClientRect();
5645        const {
5646          left,
5647          top,
5648          width,
5649          height
5650        } = elementRectForRootMargin;
5651        if (!skip) {
5652          onMove();
5653        }
5654        if (!width || !height) {
5655          return;
5656        }
5657        const insetTop = floor(top);
5658        const insetRight = floor(root.clientWidth - (left + width));
5659        const insetBottom = floor(root.clientHeight - (top + height));
5660        const insetLeft = floor(left);
5661        const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5662        const options = {
5663          rootMargin,
5664          threshold: max(0, min(1, threshold)) || 1
5665        };
5666        let isFirstUpdate = true;
5667        function handleObserve(entries) {
5668          const ratio = entries[0].intersectionRatio;
5669          if (ratio !== threshold) {
5670            if (!isFirstUpdate) {
5671              return refresh();
5672            }
5673            if (!ratio) {
5674              timeoutId = setTimeout(() => {
5675                refresh(false, 1e-7);
5676              }, 1e3);
5677            } else {
5678              refresh(false, ratio);
5679            }
5680          }
5681          if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5682            refresh();
5683          }
5684          isFirstUpdate = false;
5685        }
5686        try {
5687          io = new IntersectionObserver(handleObserve, {
5688            ...options,
5689            // Handle <iframe>s
5690            root: root.ownerDocument
5691          });
5692        } catch (_e) {
5693          io = new IntersectionObserver(handleObserve, options);
5694        }
5695        io.observe(element);
5696      }
5697      refresh(true);
5698      return cleanup;
5699    }
5700    function autoUpdate(reference, floating, update2, options) {
5701      if (options === void 0) {
5702        options = {};
5703      }
5704      const {
5705        ancestorScroll = true,
5706        ancestorResize = true,
5707        elementResize = typeof ResizeObserver === "function",
5708        layoutShift = typeof IntersectionObserver === "function",
5709        animationFrame = false
5710      } = options;
5711      const referenceEl = unwrapElement(reference);
5712      const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5713      ancestors.forEach((ancestor) => {
5714        ancestorScroll && ancestor.addEventListener("scroll", update2, {
5715          passive: true
5716        });
5717        ancestorResize && ancestor.addEventListener("resize", update2);
5718      });
5719      const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5720      let reobserveFrame = -1;
5721      let resizeObserver = null;
5722      if (elementResize) {
5723        resizeObserver = new ResizeObserver((_ref) => {
5724          let [firstEntry] = _ref;
5725          if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5726            resizeObserver.unobserve(floating);
5727            cancelAnimationFrame(reobserveFrame);
5728            reobserveFrame = requestAnimationFrame(() => {
5729              var _resizeObserver;
5730              (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5731            });
5732          }
5733          update2();
5734        });
5735        if (referenceEl && !animationFrame) {
5736          resizeObserver.observe(referenceEl);
5737        }
5738        if (floating) {
5739          resizeObserver.observe(floating);
5740        }
5741      }
5742      let frameId;
5743      let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5744      if (animationFrame) {
5745        frameLoop();
5746      }
5747      function frameLoop() {
5748        const nextRefRect = getBoundingClientRect(reference);
5749        if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5750          update2();
5751        }
5752        prevRefRect = nextRefRect;
5753        frameId = requestAnimationFrame(frameLoop);
5754      }
5755      update2();
5756      return () => {
5757        var _resizeObserver2;
5758        ancestors.forEach((ancestor) => {
5759          ancestorScroll && ancestor.removeEventListener("scroll", update2);
5760          ancestorResize && ancestor.removeEventListener("resize", update2);
5761        });
5762        cleanupIo == null || cleanupIo();
5763        (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5764        resizeObserver = null;
5765        if (animationFrame) {
5766          cancelAnimationFrame(frameId);
5767        }
5768      };
5769    }
5770    var offset2 = offset;
5771    var shift2 = shift;
5772    var flip2 = flip;
5773    var size2 = size;
5774    var hide2 = hide;
5775    var limitShift2 = limitShift;
5776    var computePosition2 = (reference, floating, options) => {
5777      const cache = /* @__PURE__ */ new Map();
5778      const mergedOptions = {
5779        platform: platform2,
5780        ...options
5781      };
5782      const platformWithCache = {
5783        ...mergedOptions.platform,
5784        _c: cache
5785      };
5786      return computePosition(reference, floating, {
5787        ...mergedOptions,
5788        platform: platformWithCache
5789      });
5790    };
5791  
5792    // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5793    var React19 = __toESM(require_react(), 1);
5794    var import_react2 = __toESM(require_react(), 1);
5795    var ReactDOM3 = __toESM(require_react_dom(), 1);
5796    var isClient = typeof document !== "undefined";
5797    var noop3 = function noop4() {
5798    };
5799    var index = isClient ? import_react2.useLayoutEffect : noop3;
5800    function deepEqual(a2, b2) {
5801      if (a2 === b2) {
5802        return true;
5803      }
5804      if (typeof a2 !== typeof b2) {
5805        return false;
5806      }
5807      if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5808        return true;
5809      }
5810      let length;
5811      let i2;
5812      let keys;
5813      if (a2 && b2 && typeof a2 === "object") {
5814        if (Array.isArray(a2)) {
5815          length = a2.length;
5816          if (length !== b2.length) return false;
5817          for (i2 = length; i2-- !== 0; ) {
5818            if (!deepEqual(a2[i2], b2[i2])) {
5819              return false;
5820            }
5821          }
5822          return true;
5823        }
5824        keys = Object.keys(a2);
5825        length = keys.length;
5826        if (length !== Object.keys(b2).length) {
5827          return false;
5828        }
5829        for (i2 = length; i2-- !== 0; ) {
5830          if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5831            return false;
5832          }
5833        }
5834        for (i2 = length; i2-- !== 0; ) {
5835          const key = keys[i2];
5836          if (key === "_owner" && a2.$$typeof) {
5837            continue;
5838          }
5839          if (!deepEqual(a2[key], b2[key])) {
5840            return false;
5841          }
5842        }
5843        return true;
5844      }
5845      return a2 !== a2 && b2 !== b2;
5846    }
5847    function getDPR(element) {
5848      if (typeof window === "undefined") {
5849        return 1;
5850      }
5851      const win = element.ownerDocument.defaultView || window;
5852      return win.devicePixelRatio || 1;
5853    }
5854    function roundByDPR(element, value) {
5855      const dpr = getDPR(element);
5856      return Math.round(value * dpr) / dpr;
5857    }
5858    function useLatestRef(value) {
5859      const ref = React19.useRef(value);
5860      index(() => {
5861        ref.current = value;
5862      });
5863      return ref;
5864    }
5865    function useFloating(options) {
5866      if (options === void 0) {
5867        options = {};
5868      }
5869      const {
5870        placement = "bottom",
5871        strategy = "absolute",
5872        middleware = [],
5873        platform: platform3,
5874        elements: {
5875          reference: externalReference,
5876          floating: externalFloating
5877        } = {},
5878        transform = true,
5879        whileElementsMounted,
5880        open
5881      } = options;
5882      const [data, setData] = React19.useState({
5883        x: 0,
5884        y: 0,
5885        strategy,
5886        placement,
5887        middlewareData: {},
5888        isPositioned: false
5889      });
5890      const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware);
5891      if (!deepEqual(latestMiddleware, middleware)) {
5892        setLatestMiddleware(middleware);
5893      }
5894      const [_reference, _setReference] = React19.useState(null);
5895      const [_floating, _setFloating] = React19.useState(null);
5896      const setReference = React19.useCallback((node) => {
5897        if (node !== referenceRef.current) {
5898          referenceRef.current = node;
5899          _setReference(node);
5900        }
5901      }, []);
5902      const setFloating = React19.useCallback((node) => {
5903        if (node !== floatingRef.current) {
5904          floatingRef.current = node;
5905          _setFloating(node);
5906        }
5907      }, []);
5908      const referenceEl = externalReference || _reference;
5909      const floatingEl = externalFloating || _floating;
5910      const referenceRef = React19.useRef(null);
5911      const floatingRef = React19.useRef(null);
5912      const dataRef = React19.useRef(data);
5913      const hasWhileElementsMounted = whileElementsMounted != null;
5914      const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5915      const platformRef = useLatestRef(platform3);
5916      const openRef = useLatestRef(open);
5917      const update2 = React19.useCallback(() => {
5918        if (!referenceRef.current || !floatingRef.current) {
5919          return;
5920        }
5921        const config = {
5922          placement,
5923          strategy,
5924          middleware: latestMiddleware
5925        };
5926        if (platformRef.current) {
5927          config.platform = platformRef.current;
5928        }
5929        computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5930          const fullData = {
5931            ...data2,
5932            // The floating element's position may be recomputed while it's closed
5933            // but still mounted (such as when transitioning out). To ensure
5934            // `isPositioned` will be `false` initially on the next open, avoid
5935            // setting it to `true` when `open === false` (must be specified).
5936            isPositioned: openRef.current !== false
5937          };
5938          if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5939            dataRef.current = fullData;
5940            ReactDOM3.flushSync(() => {
5941              setData(fullData);
5942            });
5943          }
5944        });
5945      }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5946      index(() => {
5947        if (open === false && dataRef.current.isPositioned) {
5948          dataRef.current.isPositioned = false;
5949          setData((data2) => ({
5950            ...data2,
5951            isPositioned: false
5952          }));
5953        }
5954      }, [open]);
5955      const isMountedRef = React19.useRef(false);
5956      index(() => {
5957        isMountedRef.current = true;
5958        return () => {
5959          isMountedRef.current = false;
5960        };
5961      }, []);
5962      index(() => {
5963        if (referenceEl) referenceRef.current = referenceEl;
5964        if (floatingEl) floatingRef.current = floatingEl;
5965        if (referenceEl && floatingEl) {
5966          if (whileElementsMountedRef.current) {
5967            return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5968          }
5969          update2();
5970        }
5971      }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5972      const refs = React19.useMemo(() => ({
5973        reference: referenceRef,
5974        floating: floatingRef,
5975        setReference,
5976        setFloating
5977      }), [setReference, setFloating]);
5978      const elements = React19.useMemo(() => ({
5979        reference: referenceEl,
5980        floating: floatingEl
5981      }), [referenceEl, floatingEl]);
5982      const floatingStyles = React19.useMemo(() => {
5983        const initialStyles = {
5984          position: strategy,
5985          left: 0,
5986          top: 0
5987        };
5988        if (!elements.floating) {
5989          return initialStyles;
5990        }
5991        const x2 = roundByDPR(elements.floating, data.x);
5992        const y2 = roundByDPR(elements.floating, data.y);
5993        if (transform) {
5994          return {
5995            ...initialStyles,
5996            transform: "translate(" + x2 + "px, " + y2 + "px)",
5997            ...getDPR(elements.floating) >= 1.5 && {
5998              willChange: "transform"
5999            }
6000          };
6001        }
6002        return {
6003          position: strategy,
6004          left: x2,
6005          top: y2
6006        };
6007      }, [strategy, transform, elements.floating, data.x, data.y]);
6008      return React19.useMemo(() => ({
6009        ...data,
6010        update: update2,
6011        refs,
6012        elements,
6013        floatingStyles
6014      }), [data, update2, refs, elements, floatingStyles]);
6015    }
6016    var offset3 = (options, deps) => {
6017      const result = offset2(options);
6018      return {
6019        name: result.name,
6020        fn: result.fn,
6021        options: [options, deps]
6022      };
6023    };
6024    var shift3 = (options, deps) => {
6025      const result = shift2(options);
6026      return {
6027        name: result.name,
6028        fn: result.fn,
6029        options: [options, deps]
6030      };
6031    };
6032    var limitShift3 = (options, deps) => {
6033      const result = limitShift2(options);
6034      return {
6035        fn: result.fn,
6036        options: [options, deps]
6037      };
6038    };
6039    var flip3 = (options, deps) => {
6040      const result = flip2(options);
6041      return {
6042        name: result.name,
6043        fn: result.fn,
6044        options: [options, deps]
6045      };
6046    };
6047    var size3 = (options, deps) => {
6048      const result = size2(options);
6049      return {
6050        name: result.name,
6051        fn: result.fn,
6052        options: [options, deps]
6053      };
6054    };
6055    var hide3 = (options, deps) => {
6056      const result = hide2(options);
6057      return {
6058        name: result.name,
6059        fn: result.fn,
6060        options: [options, deps]
6061      };
6062    };
6063  
6064    // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6065    var React24 = __toESM(require_react(), 1);
6066    var ReactDOM4 = __toESM(require_react_dom(), 1);
6067  
6068    // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6069    var React23 = __toESM(require_react(), 1);
6070  
6071    // node_modules/@base-ui/utils/store/createSelector.mjs
6072    var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
6073      if (other.length > 0) {
6074        throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
6075      }
6076      let selector2;
6077      if (a2 && b2 && c2 && d2 && e2 && f2) {
6078        selector2 = (state, a1, a22, a3) => {
6079          const va = a2(state, a1, a22, a3);
6080          const vb = b2(state, a1, a22, a3);
6081          const vc = c2(state, a1, a22, a3);
6082          const vd = d2(state, a1, a22, a3);
6083          const ve = e2(state, a1, a22, a3);
6084          return f2(va, vb, vc, vd, ve, a1, a22, a3);
6085        };
6086      } else if (a2 && b2 && c2 && d2 && e2) {
6087        selector2 = (state, a1, a22, a3) => {
6088          const va = a2(state, a1, a22, a3);
6089          const vb = b2(state, a1, a22, a3);
6090          const vc = c2(state, a1, a22, a3);
6091          const vd = d2(state, a1, a22, a3);
6092          return e2(va, vb, vc, vd, a1, a22, a3);
6093        };
6094      } else if (a2 && b2 && c2 && d2) {
6095        selector2 = (state, a1, a22, a3) => {
6096          const va = a2(state, a1, a22, a3);
6097          const vb = b2(state, a1, a22, a3);
6098          const vc = c2(state, a1, a22, a3);
6099          return d2(va, vb, vc, a1, a22, a3);
6100        };
6101      } else if (a2 && b2 && c2) {
6102        selector2 = (state, a1, a22, a3) => {
6103          const va = a2(state, a1, a22, a3);
6104          const vb = b2(state, a1, a22, a3);
6105          return c2(va, vb, a1, a22, a3);
6106        };
6107      } else if (a2 && b2) {
6108        selector2 = (state, a1, a22, a3) => {
6109          const va = a2(state, a1, a22, a3);
6110          return b2(va, a1, a22, a3);
6111        };
6112      } else if (a2) {
6113        selector2 = a2;
6114      } else {
6115        throw (
6116          /* minify-error-disabled */
6117          new Error("Missing arguments")
6118        );
6119      }
6120      return selector2;
6121    };
6122  
6123    // node_modules/@base-ui/utils/store/useStore.mjs
6124    var React21 = __toESM(require_react(), 1);
6125    var import_shim = __toESM(require_shim(), 1);
6126    var import_with_selector = __toESM(require_with_selector(), 1);
6127  
6128    // node_modules/@base-ui/utils/fastHooks.mjs
6129    var React20 = __toESM(require_react(), 1);
6130    var hooks = [];
6131    var currentInstance = void 0;
6132    function getInstance() {
6133      return currentInstance;
6134    }
6135    function register(hook) {
6136      hooks.push(hook);
6137    }
6138    function fastComponent(fn) {
6139      const FastComponent = (props, forwardedRef) => {
6140        const instance = useRefWithInit(createInstance).current;
6141        let result;
6142        try {
6143          currentInstance = instance;
6144          for (const hook of hooks) {
6145            hook.before(instance);
6146          }
6147          result = fn(props, forwardedRef);
6148          for (const hook of hooks) {
6149            hook.after(instance);
6150          }
6151          instance.didInitialize = true;
6152        } finally {
6153          currentInstance = void 0;
6154        }
6155        return result;
6156      };
6157      FastComponent.displayName = fn.displayName || fn.name;
6158      return FastComponent;
6159    }
6160    function fastComponentRef(fn) {
6161      return /* @__PURE__ */ React20.forwardRef(fastComponent(fn));
6162    }
6163    function createInstance() {
6164      return {
6165        didInitialize: false
6166      };
6167    }
6168  
6169    // node_modules/@base-ui/utils/store/useStore.mjs
6170    var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
6171    var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
6172    function useStore(store, selector2, a1, a2, a3) {
6173      return useStoreImplementation(store, selector2, a1, a2, a3);
6174    }
6175    function useStoreR19(store, selector2, a1, a2, a3) {
6176      const getSelection = React21.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
6177      return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
6178    }
6179    register({
6180      before(instance) {
6181        instance.syncIndex = 0;
6182        if (!instance.didInitialize) {
6183          instance.syncTick = 1;
6184          instance.syncHooks = [];
6185          instance.didChangeStore = true;
6186          instance.getSnapshot = () => {
6187            let didChange2 = false;
6188            for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
6189              const hook = instance.syncHooks[i2];
6190              const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
6191              if (!Object.is(hook.value, value)) {
6192                didChange2 = true;
6193                hook.value = value;
6194              }
6195            }
6196            if (didChange2) {
6197              instance.syncTick += 1;
6198            }
6199            return instance.syncTick;
6200          };
6201        }
6202      },
6203      after(instance) {
6204        if (instance.syncHooks.length > 0) {
6205          if (instance.didChangeStore) {
6206            instance.didChangeStore = false;
6207            instance.subscribe = (onStoreChange) => {
6208              const stores = /* @__PURE__ */ new Set();
6209              for (const hook of instance.syncHooks) {
6210                stores.add(hook.store);
6211              }
6212              const unsubscribes = [];
6213              for (const store of stores) {
6214                unsubscribes.push(store.subscribe(onStoreChange));
6215              }
6216              return () => {
6217                for (const unsubscribe of unsubscribes) {
6218                  unsubscribe();
6219                }
6220              };
6221            };
6222          }
6223          (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
6224        }
6225      }
6226    });
6227    function useStoreFast(store, selector2, a1, a2, a3) {
6228      const instance = getInstance();
6229      if (!instance) {
6230        return useStoreR19(store, selector2, a1, a2, a3);
6231      }
6232      const index2 = instance.syncIndex;
6233      instance.syncIndex += 1;
6234      let hook;
6235      if (!instance.didInitialize) {
6236        hook = {
6237          store,
6238          selector: selector2,
6239          a1,
6240          a2,
6241          a3,
6242          value: selector2(store.getSnapshot(), a1, a2, a3)
6243        };
6244        instance.syncHooks.push(hook);
6245      } else {
6246        hook = instance.syncHooks[index2];
6247        if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
6248          if (hook.store !== store) {
6249            instance.didChangeStore = true;
6250          }
6251          hook.store = store;
6252          hook.selector = selector2;
6253          hook.a1 = a1;
6254          hook.a2 = a2;
6255          hook.a3 = a3;
6256          hook.value = selector2(store.getSnapshot(), a1, a2, a3);
6257        }
6258      }
6259      return hook.value;
6260    }
6261    function useStoreLegacy(store, selector2, a1, a2, a3) {
6262      return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
6263    }
6264  
6265    // node_modules/@base-ui/utils/store/Store.mjs
6266    var Store = class {
6267      /**
6268       * The current state of the store.
6269       * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
6270       * 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).
6271       * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
6272       *
6273       * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
6274       */
6275      // Internal state to handle recursive `setState()` calls
6276      constructor(state) {
6277        this.state = state;
6278        this.listeners = /* @__PURE__ */ new Set();
6279        this.updateTick = 0;
6280      }
6281      /**
6282       * Registers a listener that will be called whenever the store's state changes.
6283       *
6284       * @param fn The listener function to be called on state changes.
6285       * @returns A function to unsubscribe the listener.
6286       */
6287      subscribe = (fn) => {
6288        this.listeners.add(fn);
6289        return () => {
6290          this.listeners.delete(fn);
6291        };
6292      };
6293      /**
6294       * Returns the current state of the store.
6295       */
6296      getSnapshot = () => {
6297        return this.state;
6298      };
6299      /**
6300       * Updates the entire store's state and notifies all registered listeners.
6301       *
6302       * @param newState The new state to set for the store.
6303       */
6304      setState(newState) {
6305        if (this.state === newState) {
6306          return;
6307        }
6308        this.state = newState;
6309        this.updateTick += 1;
6310        const currentTick = this.updateTick;
6311        for (const listener of this.listeners) {
6312          if (currentTick !== this.updateTick) {
6313            return;
6314          }
6315          listener(newState);
6316        }
6317      }
6318      /**
6319       * Merges the provided changes into the current state and notifies listeners if there are changes.
6320       *
6321       * @param changes An object containing the changes to apply to the current state.
6322       */
6323      update(changes) {
6324        for (const key in changes) {
6325          if (!Object.is(this.state[key], changes[key])) {
6326            this.setState({
6327              ...this.state,
6328              ...changes
6329            });
6330            return;
6331          }
6332        }
6333      }
6334      /**
6335       * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
6336       *
6337       * @param key The key in the store's state to update.
6338       * @param value The new value to set for the specified key.
6339       */
6340      set(key, value) {
6341        if (!Object.is(this.state[key], value)) {
6342          this.setState({
6343            ...this.state,
6344            [key]: value
6345          });
6346        }
6347      }
6348      /**
6349       * Gives the state a new reference and updates all registered listeners.
6350       */
6351      notifyAll() {
6352        const newState = {
6353          ...this.state
6354        };
6355        this.setState(newState);
6356      }
6357      use(selector2, a1, a2, a3) {
6358        return useStore(this, selector2, a1, a2, a3);
6359      }
6360    };
6361  
6362    // node_modules/@base-ui/utils/store/ReactStore.mjs
6363    var React22 = __toESM(require_react(), 1);
6364    var ReactStore = class extends Store {
6365      /**
6366       * Creates a new ReactStore instance.
6367       *
6368       * @param state Initial state of the store.
6369       * @param context Non-reactive context values.
6370       * @param selectors Optional selectors for use with `useState`.
6371       */
6372      constructor(state, context = {}, selectors3) {
6373        super(state);
6374        this.context = context;
6375        this.selectors = selectors3;
6376      }
6377      /**
6378       * Non-reactive values such as refs, callbacks, etc.
6379       */
6380      /**
6381       * Synchronizes a single external value into the store.
6382       *
6383       * Note that the while the value in `state` is updated immediately, the value returned
6384       * by `useState` is updated before the next render (similarly to React's `useState`).
6385       */
6386      useSyncedValue(key, value) {
6387        React22.useDebugValue(key);
6388        const store = this;
6389        useIsoLayoutEffect(() => {
6390          if (store.state[key] !== value) {
6391            store.set(key, value);
6392          }
6393        }, [store, key, value]);
6394      }
6395      /**
6396       * Synchronizes a single external value into the store and
6397       * cleans it up (sets to `undefined`) on unmount.
6398       *
6399       * Note that the while the value in `state` is updated immediately, the value returned
6400       * by `useState` is updated before the next render (similarly to React's `useState`).
6401       */
6402      useSyncedValueWithCleanup(key, value) {
6403        const store = this;
6404        useIsoLayoutEffect(() => {
6405          if (store.state[key] !== value) {
6406            store.set(key, value);
6407          }
6408          return () => {
6409            store.set(key, void 0);
6410          };
6411        }, [store, key, value]);
6412      }
6413      /**
6414       * Synchronizes multiple external values into the store.
6415       *
6416       * Note that the while the values in `state` are updated immediately, the values returned
6417       * by `useState` are updated before the next render (similarly to React's `useState`).
6418       */
6419      useSyncedValues(statePart) {
6420        const store = this;
6421        if (true) {
6422          React22.useDebugValue(statePart, (p2) => Object.keys(p2));
6423          const keys = React22.useRef(Object.keys(statePart)).current;
6424          const nextKeys = Object.keys(statePart);
6425          if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
6426            console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
6427          }
6428        }
6429        const dependencies = Object.values(statePart);
6430        useIsoLayoutEffect(() => {
6431          store.update(statePart);
6432        }, [store, ...dependencies]);
6433      }
6434      /**
6435       * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
6436       * is non-undefined, the store's state at `key` is updated to match `controlled`.
6437       */
6438      useControlledProp(key, controlled) {
6439        React22.useDebugValue(key);
6440        const store = this;
6441        const isControlled = controlled !== void 0;
6442        useIsoLayoutEffect(() => {
6443          if (isControlled && !Object.is(store.state[key], controlled)) {
6444            store.setState({
6445              ...store.state,
6446              [key]: controlled
6447            });
6448          }
6449        }, [store, key, controlled, isControlled]);
6450        if (true) {
6451          const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
6452          if (!cache.has(key)) {
6453            cache.set(key, isControlled);
6454          }
6455          const previouslyControlled = cache.get(key);
6456          if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
6457            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).`);
6458          }
6459        }
6460      }
6461      /** Gets the current value from the store using a selector with the provided key.
6462       *
6463       * @param key Key of the selector to use.
6464       */
6465      select(key, a1, a2, a3) {
6466        const selector2 = this.selectors[key];
6467        return selector2(this.state, a1, a2, a3);
6468      }
6469      /**
6470       * Returns a value from the store's state using a selector function.
6471       * Used to subscribe to specific parts of the state.
6472       * This methods causes a rerender whenever the selected state changes.
6473       *
6474       * @param key Key of the selector to use.
6475       */
6476      useState(key, a1, a2, a3) {
6477        React22.useDebugValue(key);
6478        return useStore(this, this.selectors[key], a1, a2, a3);
6479      }
6480      /**
6481       * Wraps a function with `useStableCallback` to ensure it has a stable reference
6482       * and assigns it to the context.
6483       *
6484       * @param key Key of the event callback. Must be a function in the context.
6485       * @param fn Function to assign.
6486       */
6487      useContextCallback(key, fn) {
6488        React22.useDebugValue(key);
6489        const stableFunction = useStableCallback(fn ?? NOOP);
6490        this.context[key] = stableFunction;
6491      }
6492      /**
6493       * Returns a stable setter function for a specific key in the store's state.
6494       * It's commonly used to pass as a ref callback to React elements.
6495       *
6496       * @param key Key of the state to set.
6497       */
6498      useStateSetter(key) {
6499        const ref = React22.useRef(void 0);
6500        if (ref.current === void 0) {
6501          ref.current = (value) => {
6502            this.set(key, value);
6503          };
6504        }
6505        return ref.current;
6506      }
6507      /**
6508       * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
6509       *
6510       * @param key Key of the selector to observe.
6511       * @param listener Listener function called when the selector result changes.
6512       */
6513      observe(selector2, listener) {
6514        let selectFn;
6515        if (typeof selector2 === "function") {
6516          selectFn = selector2;
6517        } else {
6518          selectFn = this.selectors[selector2];
6519        }
6520        let prevValue = selectFn(this.state);
6521        listener(prevValue, prevValue, this);
6522        return this.subscribe((nextState) => {
6523          const nextValue = selectFn(nextState);
6524          if (!Object.is(prevValue, nextValue)) {
6525            const oldValue = prevValue;
6526            prevValue = nextValue;
6527            listener(nextValue, oldValue, this);
6528          }
6529        });
6530      }
6531    };
6532  
6533    // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
6534    var selectors = {
6535      open: createSelector((state) => state.open),
6536      transitionStatus: createSelector((state) => state.transitionStatus),
6537      domReferenceElement: createSelector((state) => state.domReferenceElement),
6538      referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
6539      floatingElement: createSelector((state) => state.floatingElement),
6540      floatingId: createSelector((state) => state.floatingId)
6541    };
6542    var FloatingRootStore = class extends ReactStore {
6543      constructor(options) {
6544        const {
6545          syncOnly,
6546          nested,
6547          onOpenChange,
6548          triggerElements,
6549          ...initialState
6550        } = options;
6551        super({
6552          ...initialState,
6553          positionReference: initialState.referenceElement,
6554          domReferenceElement: initialState.referenceElement
6555        }, {
6556          onOpenChange,
6557          dataRef: {
6558            current: {}
6559          },
6560          events: createEventEmitter(),
6561          nested,
6562          triggerElements
6563        }, selectors);
6564        this.syncOnly = syncOnly;
6565      }
6566      /**
6567       * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
6568       */
6569      syncOpenEvent = (newOpen, event) => {
6570        if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
6571        // click events to upgrade a hover-open.
6572        event != null && isClickLikeEvent(event)) {
6573          this.context.dataRef.current.openEvent = newOpen ? event : void 0;
6574        }
6575      };
6576      /**
6577       * Runs the root-owned side effects for an open state change.
6578       */
6579      dispatchOpenChange = (newOpen, eventDetails) => {
6580        this.syncOpenEvent(newOpen, eventDetails.event);
6581        const details = {
6582          open: newOpen,
6583          reason: eventDetails.reason,
6584          nativeEvent: eventDetails.event,
6585          nested: this.context.nested,
6586          triggerElement: eventDetails.trigger
6587        };
6588        this.context.events.emit("openchange", details);
6589      };
6590      /**
6591       * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
6592       *
6593       * @param newOpen The new open state.
6594       * @param eventDetails Details about the event that triggered the open state change.
6595       */
6596      setOpen = (newOpen, eventDetails) => {
6597        if (this.syncOnly) {
6598          this.context.onOpenChange?.(newOpen, eventDetails);
6599          return;
6600        }
6601        this.dispatchOpenChange(newOpen, eventDetails);
6602        this.context.onOpenChange?.(newOpen, eventDetails);
6603      };
6604    };
6605  
6606    // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6607    function useSyncedFloatingRootContext(options) {
6608      const {
6609        popupStore,
6610        treatPopupAsFloatingElement = false,
6611        floatingRootContext: floatingRootContextProp,
6612        floatingId,
6613        nested,
6614        onOpenChange
6615      } = options;
6616      const open = popupStore.useState("open");
6617      const referenceElement = popupStore.useState("activeTriggerElement");
6618      const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6619      const triggerElements = popupStore.context.triggerElements;
6620      const handleOpenChange = onOpenChange;
6621      const internalStoreRef = React23.useRef(null);
6622      if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
6623        internalStoreRef.current = new FloatingRootStore({
6624          open,
6625          transitionStatus: void 0,
6626          referenceElement,
6627          floatingElement,
6628          triggerElements,
6629          onOpenChange: handleOpenChange,
6630          floatingId,
6631          syncOnly: true,
6632          nested
6633        });
6634      }
6635      const store = floatingRootContextProp ?? internalStoreRef.current;
6636      popupStore.useSyncedValue("floatingId", floatingId);
6637      useIsoLayoutEffect(() => {
6638        const valuesToSync = {
6639          open,
6640          floatingId,
6641          referenceElement,
6642          floatingElement
6643        };
6644        if (isElement(referenceElement)) {
6645          valuesToSync.domReferenceElement = referenceElement;
6646        }
6647        if (store.state.positionReference === store.state.referenceElement) {
6648          valuesToSync.positionReference = referenceElement;
6649        }
6650        store.update(valuesToSync);
6651      }, [open, floatingId, referenceElement, floatingElement, store]);
6652      store.context.onOpenChange = handleOpenChange;
6653      store.context.nested = nested;
6654      return store;
6655    }
6656  
6657    // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6658    var FOCUSABLE_POPUP_PROPS = {
6659      tabIndex: -1,
6660      [FOCUSABLE_ATTRIBUTE]: ""
6661    };
6662    function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
6663      const floatingId = useId();
6664      const nested = useFloatingParentNodeId() != null;
6665      const internalStoreRef = React24.useRef(null);
6666      if (externalStore === void 0 && internalStoreRef.current === null) {
6667        internalStoreRef.current = createStore2(floatingId, nested);
6668      }
6669      const store = externalStore ?? internalStoreRef.current;
6670      useSyncedFloatingRootContext({
6671        popupStore: store,
6672        treatPopupAsFloatingElement,
6673        floatingRootContext: store.state.floatingRootContext,
6674        floatingId,
6675        nested,
6676        onOpenChange: store.setOpen
6677      });
6678      return {
6679        store,
6680        internalStore: internalStoreRef.current
6681      };
6682    }
6683    function useTriggerRegistration(id, store) {
6684      const registeredElementIdRef = React24.useRef(null);
6685      const registeredElementRef = React24.useRef(null);
6686      return React24.useCallback((element) => {
6687        if (id === void 0) {
6688          return;
6689        }
6690        let shouldSyncTriggerCount = false;
6691        if (registeredElementIdRef.current !== null) {
6692          const registeredId = registeredElementIdRef.current;
6693          const registeredElement = registeredElementRef.current;
6694          const currentElement = store.context.triggerElements.getById(registeredId);
6695          if (registeredElement && currentElement === registeredElement) {
6696            store.context.triggerElements.delete(registeredId);
6697            shouldSyncTriggerCount = true;
6698          }
6699          registeredElementIdRef.current = null;
6700          registeredElementRef.current = null;
6701        }
6702        if (element !== null) {
6703          registeredElementIdRef.current = id;
6704          registeredElementRef.current = element;
6705          store.context.triggerElements.add(id, element);
6706          shouldSyncTriggerCount = true;
6707        }
6708        if (shouldSyncTriggerCount) {
6709          const triggerCount = store.context.triggerElements.size;
6710          if (store.select("open") && store.state.triggerCount !== triggerCount) {
6711            store.set("triggerCount", triggerCount);
6712          }
6713        }
6714      }, [store, id]);
6715    }
6716    function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) {
6717      if (open) {
6718        state.preventUnmountingOnClose = false;
6719      } else if (preventUnmountOnClose) {
6720        state.preventUnmountingOnClose = true;
6721      }
6722      const triggerId = trigger?.id ?? null;
6723      if (triggerId || open) {
6724        state.activeTriggerId = triggerId;
6725        state.activeTriggerElement = trigger ?? null;
6726      }
6727    }
6728    function attachPreventUnmountOnClose(eventDetails) {
6729      let preventUnmountOnClose = false;
6730      eventDetails.preventUnmountOnClose = () => {
6731        preventUnmountOnClose = true;
6732      };
6733      return () => preventUnmountOnClose;
6734    }
6735    function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
6736      const reason = eventDetails.reason;
6737      const isHover = reason === reason_parts_exports.triggerHover;
6738      const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
6739      const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
6740      const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
6741      store.context.onOpenChange?.(nextOpen, eventDetails);
6742      if (eventDetails.isCanceled) {
6743        return;
6744      }
6745      options.onBeforeDispatch?.();
6746      store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
6747      const changeState = () => {
6748        const updatedState = {
6749          ...options.extraState,
6750          open: nextOpen
6751        };
6752        if (isFocusOpen) {
6753          updatedState.instantType = "focus";
6754        } else if (isDismissClose) {
6755          updatedState.instantType = "dismiss";
6756        } else if (isHover) {
6757          updatedState.instantType = void 0;
6758        }
6759        setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
6760        store.update(updatedState);
6761      };
6762      if (isHover) {
6763        ReactDOM4.flushSync(changeState);
6764      } else {
6765        changeState();
6766      }
6767    }
6768    function useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerId) {
6769      useOnFirstRender(() => {
6770        if (openProp === void 0 && store.state.open === false && defaultOpen) {
6771          store.state = {
6772            ...store.state,
6773            open: true,
6774            activeTriggerId: defaultTriggerId,
6775            preventUnmountingOnClose: false
6776          };
6777        }
6778      });
6779    }
6780    function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6781      const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6782      const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6783      const registerTrigger = useStableCallback((element) => {
6784        baseRegisterTrigger(element);
6785        if (!element) {
6786          return;
6787        }
6788        const open = store.select("open");
6789        const activeTriggerId = store.select("activeTriggerId");
6790        if (activeTriggerId === triggerId) {
6791          store.update({
6792            activeTriggerElement: element,
6793            ...open ? stateUpdates : null
6794          });
6795          return;
6796        }
6797        if (activeTriggerId == null && open) {
6798          store.update({
6799            activeTriggerId: triggerId,
6800            activeTriggerElement: element,
6801            ...stateUpdates
6802          });
6803        }
6804      });
6805      useIsoLayoutEffect(() => {
6806        if (isMountedByThisTrigger) {
6807          store.update({
6808            activeTriggerElement: triggerElementRef.current,
6809            ...stateUpdates
6810          });
6811        }
6812      }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6813      return {
6814        registerTrigger,
6815        isMountedByThisTrigger
6816      };
6817    }
6818    function useImplicitActiveTrigger(store, options = {}) {
6819      const {
6820        closeOnActiveTriggerUnmount = false
6821      } = options;
6822      const open = store.useState("open");
6823      const reactiveTriggerCount = store.useState("triggerCount");
6824      useIsoLayoutEffect(() => {
6825        if (!open) {
6826          if (store.state.triggerCount !== 0) {
6827            store.set("triggerCount", 0);
6828          }
6829          return;
6830        }
6831        const triggerCount = store.context.triggerElements.size;
6832        const stateUpdates = {};
6833        if (store.state.triggerCount !== triggerCount) {
6834          stateUpdates.triggerCount = triggerCount;
6835        }
6836        const activeTriggerId = store.select("activeTriggerId");
6837        let lostActiveTriggerId = null;
6838        if (activeTriggerId) {
6839          const activeTriggerElement = store.context.triggerElements.getById(activeTriggerId);
6840          if (!activeTriggerElement) {
6841            lostActiveTriggerId = activeTriggerId;
6842          } else if (activeTriggerElement !== store.state.activeTriggerElement) {
6843            stateUpdates.activeTriggerElement = activeTriggerElement;
6844          }
6845        }
6846        if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) {
6847          const iteratorResult = store.context.triggerElements.entries().next();
6848          if (!iteratorResult.done) {
6849            const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6850            stateUpdates.activeTriggerId = implicitTriggerId;
6851            stateUpdates.activeTriggerElement = implicitTriggerElement;
6852          }
6853        }
6854        if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
6855          store.update(stateUpdates);
6856        }
6857        if (lostActiveTriggerId) {
6858          if (closeOnActiveTriggerUnmount) {
6859            queueMicrotask(() => {
6860              if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
6861                const eventDetails = createChangeEventDetails(reason_parts_exports.none);
6862                store.setOpen(false, eventDetails);
6863                if (!eventDetails.isCanceled) {
6864                  store.update({
6865                    activeTriggerId: null,
6866                    activeTriggerElement: null
6867                  });
6868                }
6869              }
6870            });
6871          }
6872        }
6873      }, [open, store, reactiveTriggerCount, closeOnActiveTriggerUnmount]);
6874    }
6875    function useOpenStateTransitions(open, store, onUnmount) {
6876      const {
6877        mounted,
6878        setMounted,
6879        transitionStatus
6880      } = useTransitionStatus(open);
6881      const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6882      const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose;
6883      store.useSyncedValues({
6884        mounted,
6885        transitionStatus,
6886        preventUnmountingOnClose: syncedPreventUnmountingOnClose
6887      });
6888      const forceUnmount = useStableCallback(() => {
6889        setMounted(false);
6890        store.update({
6891          activeTriggerId: null,
6892          activeTriggerElement: null,
6893          mounted: false,
6894          preventUnmountingOnClose: false
6895        });
6896        onUnmount?.();
6897        store.context.onOpenChangeComplete?.(false);
6898      });
6899      useOpenChangeComplete({
6900        enabled: mounted && !open && !syncedPreventUnmountingOnClose,
6901        open,
6902        ref: store.context.popupRef,
6903        onComplete() {
6904          if (!open) {
6905            forceUnmount();
6906          }
6907        }
6908      });
6909      return {
6910        forceUnmount,
6911        transitionStatus
6912      };
6913    }
6914    function usePopupInteractionProps(store, statePart) {
6915      store.useSyncedValues(statePart);
6916      useIsoLayoutEffect(() => () => {
6917        store.update({
6918          activeTriggerProps: EMPTY_OBJECT,
6919          inactiveTriggerProps: EMPTY_OBJECT,
6920          popupProps: EMPTY_OBJECT
6921        });
6922      }, [store]);
6923    }
6924  
6925    // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs
6926    var PopupTriggerMap = class {
6927      constructor() {
6928        this.elementsSet = /* @__PURE__ */ new Set();
6929        this.idMap = /* @__PURE__ */ new Map();
6930      }
6931      /**
6932       * Adds a trigger element with the given ID.
6933       *
6934       * Note: The provided element is assumed to not be registered under multiple IDs.
6935       */
6936      add(id, element) {
6937        const existingElement = this.idMap.get(id);
6938        if (existingElement === element) {
6939          return;
6940        }
6941        if (existingElement !== void 0) {
6942          this.elementsSet.delete(existingElement);
6943        }
6944        this.elementsSet.add(element);
6945        this.idMap.set(id, element);
6946        if (true) {
6947          if (this.elementsSet.size !== this.idMap.size) {
6948            throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6949          }
6950        }
6951      }
6952      /**
6953       * Removes the trigger element with the given ID.
6954       */
6955      delete(id) {
6956        const element = this.idMap.get(id);
6957        if (element) {
6958          this.elementsSet.delete(element);
6959          this.idMap.delete(id);
6960        }
6961      }
6962      /**
6963       * Whether the given element is registered as a trigger.
6964       */
6965      hasElement(element) {
6966        return this.elementsSet.has(element);
6967      }
6968      /**
6969       * Whether there is a registered trigger element matching the given predicate.
6970       */
6971      hasMatchingElement(predicate) {
6972        for (const element of this.elementsSet) {
6973          if (predicate(element)) {
6974            return true;
6975          }
6976        }
6977        return false;
6978      }
6979      /**
6980       * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6981       */
6982      getById(id) {
6983        return this.idMap.get(id);
6984      }
6985      /**
6986       * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6987       */
6988      entries() {
6989        return this.idMap.entries();
6990      }
6991      /**
6992       * Returns an iterable of all registered trigger elements.
6993       */
6994      elements() {
6995        return this.elementsSet.values();
6996      }
6997      /**
6998       * Returns the number of registered trigger elements.
6999       */
7000      get size() {
7001        return this.idMap.size;
7002      }
7003    };
7004  
7005    // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs
7006    function getEmptyRootContext() {
7007      return new FloatingRootStore({
7008        open: false,
7009        transitionStatus: void 0,
7010        floatingElement: null,
7011        referenceElement: null,
7012        triggerElements: new PopupTriggerMap(),
7013        floatingId: void 0,
7014        syncOnly: false,
7015        nested: false,
7016        onOpenChange: void 0
7017      });
7018    }
7019  
7020    // node_modules/@base-ui/react/utils/popups/store.mjs
7021    function createInitialPopupStoreState() {
7022      return {
7023        open: false,
7024        openProp: void 0,
7025        mounted: false,
7026        transitionStatus: void 0,
7027        floatingRootContext: getEmptyRootContext(),
7028        floatingId: void 0,
7029        triggerCount: 0,
7030        preventUnmountingOnClose: false,
7031        payload: void 0,
7032        activeTriggerId: null,
7033        activeTriggerElement: null,
7034        triggerIdProp: void 0,
7035        popupElement: null,
7036        positionerElement: null,
7037        activeTriggerProps: EMPTY_OBJECT,
7038        inactiveTriggerProps: EMPTY_OBJECT,
7039        popupProps: EMPTY_OBJECT
7040      };
7041    }
7042    function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
7043      return new FloatingRootStore({
7044        open: false,
7045        transitionStatus: void 0,
7046        floatingElement: null,
7047        referenceElement: null,
7048        triggerElements,
7049        floatingId,
7050        syncOnly: true,
7051        nested,
7052        onOpenChange: void 0
7053      });
7054    }
7055    var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
7056    var openSelector = createSelector((state) => state.openProp ?? state.open);
7057    var popupIdSelector = createSelector((state) => {
7058      const popupId = state.popupElement?.id ?? state.floatingId;
7059      return popupId || void 0;
7060    });
7061    function triggerOwnsOpenPopup(state, triggerId) {
7062      return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
7063    }
7064    function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
7065      if (triggerOwnsOpenPopup(state, triggerId)) {
7066        return true;
7067      }
7068      return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
7069    }
7070    var popupStoreSelectors = {
7071      open: openSelector,
7072      mounted: createSelector((state) => state.mounted),
7073      transitionStatus: createSelector((state) => state.transitionStatus),
7074      floatingRootContext: createSelector((state) => state.floatingRootContext),
7075      triggerCount: createSelector((state) => state.triggerCount),
7076      preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
7077      payload: createSelector((state) => state.payload),
7078      activeTriggerId: activeTriggerIdSelector,
7079      activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
7080      popupId: popupIdSelector,
7081      /**
7082       * Whether the trigger with the given ID was used to open the popup.
7083       */
7084      isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
7085      /**
7086       * Whether the popup is open and was activated by a trigger with the given ID.
7087       */
7088      isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
7089      /**
7090       * Whether the popup is mounted and was activated by a trigger with the given ID.
7091       */
7092      isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
7093      triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
7094      /**
7095       * Popup id for the trigger that currently owns the open popup.
7096       */
7097      triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
7098      popupProps: createSelector((state) => state.popupProps),
7099      popupElement: createSelector((state) => state.popupElement),
7100      positionerElement: createSelector((state) => state.positionerElement)
7101    };
7102  
7103    // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
7104    function useFloatingRootContext(options) {
7105      const {
7106        open = false,
7107        onOpenChange,
7108        elements = {}
7109      } = options;
7110      const floatingId = useId();
7111      const nested = useFloatingParentNodeId() != null;
7112      if (true) {
7113        const optionDomReference = elements.reference;
7114        if (optionDomReference && !isElement(optionDomReference)) {
7115          console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
7116        }
7117      }
7118      const store = useRefWithInit(() => new FloatingRootStore({
7119        open,
7120        transitionStatus: void 0,
7121        onOpenChange,
7122        referenceElement: elements.reference ?? null,
7123        floatingElement: elements.floating ?? null,
7124        triggerElements: new PopupTriggerMap(),
7125        floatingId,
7126        syncOnly: false,
7127        nested
7128      })).current;
7129      useIsoLayoutEffect(() => {
7130        const valuesToSync = {
7131          open,
7132          floatingId
7133        };
7134        if (elements.reference !== void 0) {
7135          valuesToSync.referenceElement = elements.reference;
7136          valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
7137        }
7138        if (elements.floating !== void 0) {
7139          valuesToSync.floatingElement = elements.floating;
7140        }
7141        store.update(valuesToSync);
7142      }, [open, floatingId, elements.reference, elements.floating, store]);
7143      store.context.onOpenChange = onOpenChange;
7144      store.context.nested = nested;
7145      return store;
7146    }
7147  
7148    // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
7149    function useFloating2(options = {}) {
7150      const {
7151        nodeId,
7152        externalTree
7153      } = options;
7154      const internalStore = useFloatingRootContext(options);
7155      const store = options.rootContext || internalStore;
7156      const referenceElement = store.useState("referenceElement");
7157      const floatingElement = store.useState("floatingElement");
7158      const domReferenceElement = store.useState("domReferenceElement");
7159      const open = store.useState("open");
7160      const floatingId = store.useState("floatingId");
7161      const [positionReference, setPositionReferenceRaw] = React25.useState(null);
7162      const [localDomReference, setLocalDomReference] = React25.useState(void 0);
7163      const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0);
7164      const domReferenceRef = React25.useRef(null);
7165      const tree = useFloatingTree(externalTree);
7166      const storeElements = React25.useMemo(() => ({
7167        reference: referenceElement,
7168        floating: floatingElement,
7169        domReference: domReferenceElement
7170      }), [referenceElement, floatingElement, domReferenceElement]);
7171      const position = useFloating({
7172        ...options,
7173        elements: {
7174          ...storeElements,
7175          ...positionReference && {
7176            reference: positionReference
7177          }
7178        }
7179      });
7180      const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
7181      const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
7182      store.useSyncedValue("referenceElement", localDomReference ?? null);
7183      store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
7184      store.useSyncedValue("floatingElement", syncedFloatingElement);
7185      const setPositionReference = React25.useCallback((node) => {
7186        const computedPositionReference = isElement(node) ? {
7187          getBoundingClientRect: () => node.getBoundingClientRect(),
7188          getClientRects: () => node.getClientRects(),
7189          contextElement: node
7190        } : node;
7191        setPositionReferenceRaw(computedPositionReference);
7192        position.refs.setReference(computedPositionReference);
7193      }, [position.refs]);
7194      const setReference = React25.useCallback((node) => {
7195        if (isElement(node) || node === null) {
7196          domReferenceRef.current = node;
7197          setLocalDomReference(node);
7198        }
7199        if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
7200        // `null` to support `positionReference` + an unstable `reference`
7201        // callback ref.
7202        node !== null && !isElement(node)) {
7203          position.refs.setReference(node);
7204        }
7205      }, [position.refs, setLocalDomReference]);
7206      const setFloating = React25.useCallback((node) => {
7207        setLocalFloatingElement(node);
7208        position.refs.setFloating(node);
7209      }, [position.refs]);
7210      const refs = React25.useMemo(() => ({
7211        ...position.refs,
7212        setReference,
7213        setFloating,
7214        setPositionReference,
7215        domReference: domReferenceRef
7216      }), [position.refs, setReference, setFloating, setPositionReference]);
7217      const elements = React25.useMemo(() => ({
7218        ...position.elements,
7219        domReference: domReferenceElement
7220      }), [position.elements, domReferenceElement]);
7221      const context = React25.useMemo(() => ({
7222        ...position,
7223        dataRef: store.context.dataRef,
7224        open,
7225        onOpenChange: store.setOpen,
7226        events: store.context.events,
7227        floatingId,
7228        refs,
7229        elements,
7230        nodeId,
7231        rootStore: store
7232      }), [position, refs, elements, nodeId, store, open, floatingId]);
7233      useIsoLayoutEffect(() => {
7234        if (domReferenceElement) {
7235          domReferenceRef.current = domReferenceElement;
7236        }
7237      }, [domReferenceElement]);
7238      useIsoLayoutEffect(() => {
7239        store.context.dataRef.current.floatingContext = context;
7240        const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
7241        if (node) {
7242          node.context = context;
7243        }
7244      });
7245      return React25.useMemo(() => ({
7246        ...position,
7247        context,
7248        refs,
7249        elements,
7250        rootStore: store
7251      }), [position, refs, elements, context, store]);
7252    }
7253  
7254    // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
7255    var React26 = __toESM(require_react(), 1);
7256    var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit;
7257    function useFocus(context, props = {}) {
7258      const {
7259        enabled = true,
7260        delay
7261      } = props;
7262      const store = "rootStore" in context ? context.rootStore : context;
7263      const {
7264        events,
7265        dataRef
7266      } = store.context;
7267      const blockFocusRef = React26.useRef(false);
7268      const blockedReferenceRef = React26.useRef(null);
7269      const keyboardModalityRef = React26.useRef(true);
7270      const timeout = useTimeout();
7271      React26.useEffect(() => {
7272        const domReference = store.select("domReferenceElement");
7273        if (!enabled) {
7274          return void 0;
7275        }
7276        const win = getWindow(domReference);
7277        function onBlur() {
7278          const currentDomReference = store.select("domReferenceElement");
7279          if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
7280            blockFocusRef.current = true;
7281          }
7282        }
7283        function onKeyDown() {
7284          keyboardModalityRef.current = true;
7285        }
7286        function onPointerDown() {
7287          keyboardModalityRef.current = false;
7288        }
7289        return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
7290      }, [store, enabled]);
7291      React26.useEffect(() => {
7292        if (!enabled) {
7293          return void 0;
7294        }
7295        function onOpenChangeLocal(details) {
7296          if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7297            const referenceElement = store.select("domReferenceElement");
7298            if (isElement(referenceElement)) {
7299              blockedReferenceRef.current = referenceElement;
7300              blockFocusRef.current = true;
7301            }
7302          }
7303        }
7304        events.on("openchange", onOpenChangeLocal);
7305        return () => {
7306          events.off("openchange", onOpenChangeLocal);
7307        };
7308      }, [events, enabled, store]);
7309      const reference = React26.useMemo(() => {
7310        function resetBlockedFocus() {
7311          blockFocusRef.current = false;
7312          blockedReferenceRef.current = null;
7313        }
7314        return {
7315          onMouseLeave() {
7316            resetBlockedFocus();
7317          },
7318          onFocus(event) {
7319            const focusTarget = event.currentTarget;
7320            if (blockFocusRef.current) {
7321              if (blockedReferenceRef.current === focusTarget) {
7322                return;
7323              }
7324              resetBlockedFocus();
7325            }
7326            const target = getTarget(event.nativeEvent);
7327            if (isElement(target)) {
7328              if (isMacSafari && !event.relatedTarget) {
7329                if (!keyboardModalityRef.current && !isTypeableElement(target)) {
7330                  return;
7331                }
7332              } else if (!matchesFocusVisible(target)) {
7333                return;
7334              }
7335            }
7336            const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
7337            const {
7338              nativeEvent,
7339              currentTarget
7340            } = event;
7341            const delayValue = typeof delay === "function" ? delay() : delay;
7342            if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
7343              store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7344              return;
7345            }
7346            timeout.start(delayValue, () => {
7347              if (blockFocusRef.current) {
7348                return;
7349              }
7350              store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7351            });
7352          },
7353          onBlur(event) {
7354            resetBlockedFocus();
7355            const relatedTarget = event.relatedTarget;
7356            const nativeEvent = event.nativeEvent;
7357            const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
7358            timeout.start(0, () => {
7359              const domReference = store.select("domReferenceElement");
7360              const activeEl = activeElement(ownerDocument(domReference));
7361              if (!relatedTarget && activeEl === domReference) {
7362                return;
7363              }
7364              if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
7365                return;
7366              }
7367              const nextFocusedElement = relatedTarget ?? activeEl;
7368              if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
7369                return;
7370              }
7371              store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
7372            });
7373          }
7374        };
7375      }, [dataRef, delay, store, timeout]);
7376      return React26.useMemo(() => enabled ? {
7377        reference,
7378        trigger: reference
7379      } : {}, [enabled, reference]);
7380    }
7381  
7382    // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7383    var React27 = __toESM(require_react(), 1);
7384  
7385    // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs
7386    var HoverInteraction = class _HoverInteraction {
7387      constructor() {
7388        this.pointerType = void 0;
7389        this.interactedInside = false;
7390        this.handler = void 0;
7391        this.blockMouseMove = true;
7392        this.performedPointerEventsMutation = false;
7393        this.pointerEventsScopeElement = null;
7394        this.pointerEventsReferenceElement = null;
7395        this.pointerEventsFloatingElement = null;
7396        this.restTimeoutPending = false;
7397        this.openChangeTimeout = new Timeout();
7398        this.restTimeout = new Timeout();
7399        this.handleCloseOptions = void 0;
7400      }
7401      static create() {
7402        return new _HoverInteraction();
7403      }
7404      dispose = () => {
7405        this.openChangeTimeout.clear();
7406        this.restTimeout.clear();
7407      };
7408      disposeEffect = () => {
7409        return this.dispose;
7410      };
7411    };
7412    var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
7413    function clearSafePolygonPointerEventsMutation(instance) {
7414      if (!instance.performedPointerEventsMutation) {
7415        return;
7416      }
7417      const scopeElement = instance.pointerEventsScopeElement;
7418      if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
7419        instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
7420        instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
7421        instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
7422        pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
7423      }
7424      instance.performedPointerEventsMutation = false;
7425      instance.pointerEventsScopeElement = null;
7426      instance.pointerEventsReferenceElement = null;
7427      instance.pointerEventsFloatingElement = null;
7428    }
7429    function applySafePolygonPointerEventsMutation(instance, options) {
7430      const {
7431        scopeElement,
7432        referenceElement,
7433        floatingElement
7434      } = options;
7435      const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
7436      if (existingOwner && existingOwner !== instance) {
7437        clearSafePolygonPointerEventsMutation(existingOwner);
7438      }
7439      clearSafePolygonPointerEventsMutation(instance);
7440      instance.performedPointerEventsMutation = true;
7441      instance.pointerEventsScopeElement = scopeElement;
7442      instance.pointerEventsReferenceElement = referenceElement;
7443      instance.pointerEventsFloatingElement = floatingElement;
7444      pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
7445      scopeElement.style.pointerEvents = "none";
7446      referenceElement.style.pointerEvents = "auto";
7447      floatingElement.style.pointerEvents = "auto";
7448    }
7449    function useHoverInteractionSharedState(store) {
7450      const data = store.context.dataRef.current;
7451      const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
7452      if (!data.hoverInteractionState) {
7453        data.hoverInteractionState = instance;
7454      }
7455      useOnMount(data.hoverInteractionState.disposeEffect);
7456      return data.hoverInteractionState;
7457    }
7458  
7459    // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7460    function useHoverFloatingInteraction(context, parameters = {}) {
7461      const {
7462        enabled = true,
7463        closeDelay: closeDelayProp = 0,
7464        nodeId: nodeIdProp
7465      } = parameters;
7466      const store = "rootStore" in context ? context.rootStore : context;
7467      const open = store.useState("open");
7468      const floatingElement = store.useState("floatingElement");
7469      const domReferenceElement = store.useState("domReferenceElement");
7470      const {
7471        dataRef
7472      } = store.context;
7473      const tree = useFloatingTree();
7474      const parentId = useFloatingParentNodeId();
7475      const instance = useHoverInteractionSharedState(store);
7476      const childClosedTimeout = useTimeout();
7477      const isClickLikeOpenEvent2 = useStableCallback(() => {
7478        return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7479      });
7480      const isHoverOpen = useStableCallback(() => {
7481        return isHoverOpenEvent(dataRef.current.openEvent?.type);
7482      });
7483      const clearPointerEvents = useStableCallback(() => {
7484        clearSafePolygonPointerEventsMutation(instance);
7485      });
7486      useIsoLayoutEffect(() => {
7487        if (!open) {
7488          instance.pointerType = void 0;
7489          instance.restTimeoutPending = false;
7490          instance.interactedInside = false;
7491          clearPointerEvents();
7492        }
7493      }, [open, instance, clearPointerEvents]);
7494      React27.useEffect(() => {
7495        return clearPointerEvents;
7496      }, [clearPointerEvents]);
7497      useIsoLayoutEffect(() => {
7498        if (!enabled) {
7499          return void 0;
7500        }
7501        if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
7502          const ref = domReferenceElement;
7503          const floatingEl = floatingElement;
7504          const doc = ownerDocument(floatingElement);
7505          const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
7506          if (parentFloating) {
7507            parentFloating.style.pointerEvents = "";
7508          }
7509          const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
7510          const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
7511          const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
7512          applySafePolygonPointerEventsMutation(instance, {
7513            scopeElement,
7514            referenceElement: ref,
7515            floatingElement: floatingEl
7516          });
7517          return () => {
7518            clearPointerEvents();
7519          };
7520        }
7521        return void 0;
7522      }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
7523      React27.useEffect(() => {
7524        if (!enabled) {
7525          return void 0;
7526        }
7527        function hasParentChildren() {
7528          return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
7529        }
7530        function closeWithDelay(event) {
7531          const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
7532          const close = () => {
7533            store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7534            tree?.events.emit("floating.closed", event);
7535          };
7536          if (closeDelay) {
7537            instance.openChangeTimeout.start(closeDelay, close);
7538          } else {
7539            instance.openChangeTimeout.clear();
7540            close();
7541          }
7542        }
7543        function handleInteractInside(event) {
7544          const target = getTarget(event);
7545          if (!isInteractiveElement(target)) {
7546            instance.interactedInside = false;
7547            return;
7548          }
7549          instance.interactedInside = target?.closest("[aria-haspopup]") != null;
7550        }
7551        function onFloatingMouseEnter() {
7552          instance.openChangeTimeout.clear();
7553          childClosedTimeout.clear();
7554          tree?.events.off("floating.closed", onNodeClosed);
7555          clearPointerEvents();
7556        }
7557        function onFloatingMouseLeave(event) {
7558          if (hasParentChildren() && tree) {
7559            tree.events.on("floating.closed", onNodeClosed);
7560            return;
7561          }
7562          if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7563            return;
7564          }
7565          const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
7566          const relatedTarget = event.relatedTarget;
7567          const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
7568          if (isMovingIntoDescendantFloating) {
7569            return;
7570          }
7571          if (instance.handler) {
7572            instance.handler(event);
7573            return;
7574          }
7575          clearPointerEvents();
7576          if (isHoverOpen() && !isClickLikeOpenEvent2()) {
7577            closeWithDelay(event);
7578          }
7579        }
7580        function onNodeClosed(event) {
7581          if (!tree || !parentId || hasParentChildren()) {
7582            return;
7583          }
7584          childClosedTimeout.start(0, () => {
7585            tree.events.off("floating.closed", onNodeClosed);
7586            store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7587            tree.events.emit("floating.closed", event);
7588          });
7589        }
7590        const floating = floatingElement;
7591        return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
7592          tree?.events.off("floating.closed", onNodeClosed);
7593        });
7594      }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
7595    }
7596  
7597    // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
7598    var React28 = __toESM(require_react(), 1);
7599    var ReactDOM5 = __toESM(require_react_dom(), 1);
7600    var EMPTY_REF = {
7601      current: null
7602    };
7603    function useHoverReferenceInteraction(context, props = {}) {
7604      const {
7605        enabled = true,
7606        delay = 0,
7607        handleClose = null,
7608        mouseOnly = false,
7609        restMs = 0,
7610        move = true,
7611        triggerElementRef = EMPTY_REF,
7612        externalTree,
7613        isActiveTrigger = true,
7614        getHandleCloseContext,
7615        isClosing,
7616        shouldOpen: shouldOpenProp
7617      } = props;
7618      const store = "rootStore" in context ? context.rootStore : context;
7619      const {
7620        dataRef,
7621        events
7622      } = store.context;
7623      const tree = useFloatingTree(externalTree);
7624      const instance = useHoverInteractionSharedState(store);
7625      const isHoverCloseActiveRef = React28.useRef(false);
7626      const handleCloseRef = useValueAsRef(handleClose);
7627      const delayRef = useValueAsRef(delay);
7628      const restMsRef = useValueAsRef(restMs);
7629      const enabledRef = useValueAsRef(enabled);
7630      const shouldOpenRef = useValueAsRef(shouldOpenProp);
7631      const isClosingRef = useValueAsRef(isClosing);
7632      const isClickLikeOpenEvent2 = useStableCallback(() => {
7633        return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7634      });
7635      const checkShouldOpen = useStableCallback(() => {
7636        return shouldOpenRef.current?.() !== false;
7637      });
7638      const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7639        const allTriggers = store.context.triggerElements;
7640        if (allTriggers.hasElement(currentTarget)) {
7641          return !currentDomReference || !contains(currentDomReference, currentTarget);
7642        }
7643        if (!isElement(target)) {
7644          return false;
7645        }
7646        const targetElement = target;
7647        return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7648      });
7649      const cleanupMouseMoveHandler = useStableCallback(() => {
7650        if (!instance.handler) {
7651          return;
7652        }
7653        const doc = ownerDocument(store.select("domReferenceElement"));
7654        doc.removeEventListener("mousemove", instance.handler);
7655        instance.handler = void 0;
7656      });
7657      const clearPointerEvents = useStableCallback(() => {
7658        clearSafePolygonPointerEventsMutation(instance);
7659      });
7660      if (isActiveTrigger) {
7661        instance.handleCloseOptions = handleCloseRef.current?.__options;
7662      }
7663      React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7664      React28.useEffect(() => {
7665        if (!enabled) {
7666          return void 0;
7667        }
7668        function onOpenChangeLocal(details) {
7669          if (!details.open) {
7670            isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7671            cleanupMouseMoveHandler();
7672            instance.openChangeTimeout.clear();
7673            instance.restTimeout.clear();
7674            instance.blockMouseMove = true;
7675            instance.restTimeoutPending = false;
7676          } else {
7677            isHoverCloseActiveRef.current = false;
7678          }
7679        }
7680        events.on("openchange", onOpenChangeLocal);
7681        return () => {
7682          events.off("openchange", onOpenChangeLocal);
7683        };
7684      }, [enabled, events, instance, cleanupMouseMoveHandler]);
7685      React28.useEffect(() => {
7686        if (!enabled) {
7687          return void 0;
7688        }
7689        function closeWithDelay(event, runElseBranch = true) {
7690          const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7691          if (closeDelay) {
7692            instance.openChangeTimeout.start(closeDelay, () => {
7693              store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7694              tree?.events.emit("floating.closed", event);
7695            });
7696          } else if (runElseBranch) {
7697            instance.openChangeTimeout.clear();
7698            store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7699            tree?.events.emit("floating.closed", event);
7700          }
7701        }
7702        const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7703        if (!isElement(trigger)) {
7704          return void 0;
7705        }
7706        function onMouseEnter(event) {
7707          instance.openChangeTimeout.clear();
7708          instance.blockMouseMove = false;
7709          if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7710            return;
7711          }
7712          const restMsValue = getRestMs(restMsRef.current);
7713          const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7714          const eventTarget = getTarget(event);
7715          const currentTarget = event.currentTarget ?? null;
7716          const currentDomReference = store.select("domReferenceElement");
7717          let triggerNode = currentTarget;
7718          if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7719            for (const triggerElement of store.context.triggerElements.elements()) {
7720              if (contains(triggerElement, eventTarget)) {
7721                triggerNode = triggerElement;
7722                break;
7723              }
7724            }
7725          }
7726          if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7727            triggerNode = currentDomReference;
7728          }
7729          const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7730          const isOpen = store.select("open");
7731          const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7732          const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7733          const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7734          const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7735          const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7736          const shouldOpen = !isOpen || isOverInactive;
7737          if (shouldOpenImmediately) {
7738            if (checkShouldOpen()) {
7739              store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7740            }
7741            return;
7742          }
7743          if (isRestOnlyDelay) {
7744            return;
7745          }
7746          if (openDelay) {
7747            instance.openChangeTimeout.start(openDelay, () => {
7748              if (shouldOpen && checkShouldOpen()) {
7749                store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7750              }
7751            });
7752          } else if (shouldOpen) {
7753            if (checkShouldOpen()) {
7754              store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7755            }
7756          }
7757        }
7758        function onMouseLeave(event) {
7759          if (isClickLikeOpenEvent2()) {
7760            clearPointerEvents();
7761            return;
7762          }
7763          cleanupMouseMoveHandler();
7764          const domReferenceElement = store.select("domReferenceElement");
7765          const doc = ownerDocument(domReferenceElement);
7766          instance.restTimeout.clear();
7767          instance.restTimeoutPending = false;
7768          const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7769          if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7770            return;
7771          }
7772          if (handleCloseRef.current && handleCloseContextBase) {
7773            if (!store.select("open")) {
7774              instance.openChangeTimeout.clear();
7775            }
7776            const currentTrigger = triggerElementRef.current;
7777            instance.handler = handleCloseRef.current({
7778              ...handleCloseContextBase,
7779              tree,
7780              x: event.clientX,
7781              y: event.clientY,
7782              onClose() {
7783                clearPointerEvents();
7784                cleanupMouseMoveHandler();
7785                if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7786                  closeWithDelay(event, true);
7787                }
7788              }
7789            });
7790            doc.addEventListener("mousemove", instance.handler);
7791            instance.handler(event);
7792            return;
7793          }
7794          const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7795          if (shouldClose) {
7796            closeWithDelay(event);
7797          }
7798        }
7799        if (move) {
7800          return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7801            once: true
7802          }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7803        }
7804        return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7805      }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7806      return React28.useMemo(() => {
7807        if (!enabled) {
7808          return void 0;
7809        }
7810        function setPointerRef(event) {
7811          instance.pointerType = event.pointerType;
7812        }
7813        return {
7814          onPointerDown: setPointerRef,
7815          onPointerEnter: setPointerRef,
7816          onMouseMove(event) {
7817            const {
7818              nativeEvent
7819            } = event;
7820            const trigger = event.currentTarget;
7821            const currentDomReference = store.select("domReferenceElement");
7822            const currentOpen = store.select("open");
7823            const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7824            if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7825              return;
7826            }
7827            if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7828              const floatingElement = store.select("floatingElement");
7829              if (floatingElement) {
7830                const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7831                applySafePolygonPointerEventsMutation(instance, {
7832                  scopeElement,
7833                  referenceElement: trigger,
7834                  floatingElement
7835                });
7836              }
7837            }
7838            const restMsValue = getRestMs(restMsRef.current);
7839            if (currentOpen && !isOverInactive || restMsValue === 0) {
7840              return;
7841            }
7842            if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7843              return;
7844            }
7845            instance.restTimeout.clear();
7846            function handleMouseMove() {
7847              instance.restTimeoutPending = false;
7848              if (isClickLikeOpenEvent2()) {
7849                return;
7850              }
7851              const latestOpen = store.select("open");
7852              if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7853                store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7854              }
7855            }
7856            if (instance.pointerType === "touch") {
7857              ReactDOM5.flushSync(() => {
7858                handleMouseMove();
7859              });
7860            } else if (isOverInactive && currentOpen) {
7861              handleMouseMove();
7862            } else {
7863              instance.restTimeoutPending = true;
7864              instance.restTimeout.start(restMsValue, handleMouseMove);
7865            }
7866          }
7867        };
7868      }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7869    }
7870  
7871    // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
7872    var CURSOR_SPEED_THRESHOLD = 0.1;
7873    var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7874    var POLYGON_BUFFER = 0.5;
7875    function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7876      return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7877    }
7878    function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7879      let isInsideValue = false;
7880      if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7881        isInsideValue = !isInsideValue;
7882      }
7883      if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7884        isInsideValue = !isInsideValue;
7885      }
7886      if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7887        isInsideValue = !isInsideValue;
7888      }
7889      if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7890        isInsideValue = !isInsideValue;
7891      }
7892      return isInsideValue;
7893    }
7894    function isInsideRect(pointX, pointY, rect) {
7895      return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7896    }
7897    function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7898      const minX = Math.min(x1, x2);
7899      const maxX = Math.max(x1, x2);
7900      const minY = Math.min(y1, y2);
7901      const maxY = Math.max(y1, y2);
7902      return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7903    }
7904    function safePolygon(options = {}) {
7905      const {
7906        blockPointerEvents = false
7907      } = options;
7908      const timeout = new Timeout();
7909      const fn = ({
7910        x: x2,
7911        y: y2,
7912        placement,
7913        elements,
7914        onClose,
7915        nodeId,
7916        tree
7917      }) => {
7918        const side = placement?.split("-")[0];
7919        let hasLanded = false;
7920        let lastX = null;
7921        let lastY = null;
7922        let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7923        function isCursorMovingSlowly(nextX, nextY) {
7924          const currentTime = performance.now();
7925          const elapsedTime = currentTime - lastCursorTime;
7926          if (lastX === null || lastY === null || elapsedTime === 0) {
7927            lastX = nextX;
7928            lastY = nextY;
7929            lastCursorTime = currentTime;
7930            return false;
7931          }
7932          const deltaX = nextX - lastX;
7933          const deltaY = nextY - lastY;
7934          const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7935          const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7936          lastX = nextX;
7937          lastY = nextY;
7938          lastCursorTime = currentTime;
7939          return distanceSquared < thresholdSquared;
7940        }
7941        function close() {
7942          timeout.clear();
7943          onClose();
7944        }
7945        return function onMouseMove(event) {
7946          timeout.clear();
7947          const domReference = elements.domReference;
7948          const floating = elements.floating;
7949          if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7950            return void 0;
7951          }
7952          const {
7953            clientX,
7954            clientY
7955          } = event;
7956          const target = getTarget(event);
7957          const isLeave = event.type === "mouseleave";
7958          const isOverFloatingEl = contains(floating, target);
7959          const isOverReferenceEl = contains(domReference, target);
7960          if (isOverFloatingEl) {
7961            hasLanded = true;
7962            if (!isLeave) {
7963              return void 0;
7964            }
7965          }
7966          if (isOverReferenceEl) {
7967            hasLanded = false;
7968            if (!isLeave) {
7969              hasLanded = true;
7970              return void 0;
7971            }
7972          }
7973          if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7974            return void 0;
7975          }
7976          function hasOpenChildNode() {
7977            return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7978          }
7979          function closeIfNoOpenChild() {
7980            if (!hasOpenChildNode()) {
7981              close();
7982            }
7983          }
7984          if (hasOpenChildNode()) {
7985            return void 0;
7986          }
7987          const refRect = domReference.getBoundingClientRect();
7988          const rect = floating.getBoundingClientRect();
7989          const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7990          const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7991          const isFloatingWider = rect.width > refRect.width;
7992          const isFloatingTaller = rect.height > refRect.height;
7993          const left = (isFloatingWider ? refRect : rect).left;
7994          const right = (isFloatingWider ? refRect : rect).right;
7995          const top = (isFloatingTaller ? refRect : rect).top;
7996          const bottom = (isFloatingTaller ? refRect : rect).bottom;
7997          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) {
7998            closeIfNoOpenChild();
7999            return void 0;
8000          }
8001          let isInsideTroughRect = false;
8002          switch (side) {
8003            case "top":
8004              isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
8005              break;
8006            case "bottom":
8007              isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
8008              break;
8009            case "left":
8010              isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
8011              break;
8012            case "right":
8013              isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
8014              break;
8015            default:
8016          }
8017          if (isInsideTroughRect) {
8018            return void 0;
8019          }
8020          if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
8021            closeIfNoOpenChild();
8022            return void 0;
8023          }
8024          if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
8025            closeIfNoOpenChild();
8026            return void 0;
8027          }
8028          let isInsidePolygon = false;
8029          switch (side) {
8030            case "top": {
8031              const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8032              const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8033              const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8034              const cursorPointY = y2 + POLYGON_BUFFER + 1;
8035              const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
8036              const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
8037              isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8038              break;
8039            }
8040            case "bottom": {
8041              const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8042              const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8043              const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8044              const cursorPointY = y2 - POLYGON_BUFFER;
8045              const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
8046              const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
8047              isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8048              break;
8049            }
8050            case "left": {
8051              const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8052              const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8053              const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8054              const cursorPointX = x2 + POLYGON_BUFFER + 1;
8055              const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
8056              const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
8057              isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
8058              break;
8059            }
8060            case "right": {
8061              const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8062              const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8063              const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8064              const cursorPointX = x2 - POLYGON_BUFFER;
8065              const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
8066              const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
8067              isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
8068              break;
8069            }
8070            default:
8071          }
8072          if (!isInsidePolygon) {
8073            closeIfNoOpenChild();
8074          } else if (!hasLanded) {
8075            timeout.start(40, closeIfNoOpenChild);
8076          }
8077          return void 0;
8078        };
8079      };
8080      fn.__options = {
8081        ...options,
8082        blockPointerEvents
8083      };
8084      return fn;
8085    }
8086  
8087    // node_modules/@base-ui/react/utils/popupStateMapping.mjs
8088    var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
8089      CommonPopupDataAttributes2["open"] = "data-open";
8090      CommonPopupDataAttributes2["closed"] = "data-closed";
8091      CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
8092      CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
8093      CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
8094      CommonPopupDataAttributes2["side"] = "data-side";
8095      CommonPopupDataAttributes2["align"] = "data-align";
8096      return CommonPopupDataAttributes2;
8097    })({});
8098    var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
8099      CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
8100      CommonTriggerDataAttributes2["pressed"] = "data-pressed";
8101      return CommonTriggerDataAttributes2;
8102    })({});
8103    var TRIGGER_HOOK = {
8104      [CommonTriggerDataAttributes.popupOpen]: ""
8105    };
8106    var PRESSABLE_TRIGGER_HOOK = {
8107      [CommonTriggerDataAttributes.popupOpen]: "",
8108      [CommonTriggerDataAttributes.pressed]: ""
8109    };
8110    var POPUP_OPEN_HOOK = {
8111      [CommonPopupDataAttributes.open]: ""
8112    };
8113    var POPUP_CLOSED_HOOK = {
8114      [CommonPopupDataAttributes.closed]: ""
8115    };
8116    var ANCHOR_HIDDEN_HOOK = {
8117      [CommonPopupDataAttributes.anchorHidden]: ""
8118    };
8119    var triggerOpenStateMapping = {
8120      open(value) {
8121        if (value) {
8122          return TRIGGER_HOOK;
8123        }
8124        return null;
8125      }
8126    };
8127    var popupStateMapping = {
8128      open(value) {
8129        if (value) {
8130          return POPUP_OPEN_HOOK;
8131        }
8132        return POPUP_CLOSED_HOOK;
8133      },
8134      anchorHidden(value) {
8135        if (value) {
8136          return ANCHOR_HIDDEN_HOOK;
8137        }
8138        return null;
8139      }
8140    };
8141  
8142    // node_modules/@base-ui/utils/inertValue.mjs
8143    function inertValue(value) {
8144      if (isReactVersionAtLeast(19)) {
8145        return value;
8146      }
8147      return value ? "true" : void 0;
8148    }
8149  
8150    // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
8151    var React29 = __toESM(require_react(), 1);
8152  
8153    // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs
8154    var baseArrow = (options) => ({
8155      name: "arrow",
8156      options,
8157      async fn(state) {
8158        const {
8159          x: x2,
8160          y: y2,
8161          placement,
8162          rects,
8163          platform: platform3,
8164          elements,
8165          middlewareData
8166        } = state;
8167        const {
8168          element,
8169          padding = 0,
8170          offsetParent = "real"
8171        } = evaluate(options, state) || {};
8172        if (element == null) {
8173          return {};
8174        }
8175        const paddingObject = getPaddingObject(padding);
8176        const coords = {
8177          x: x2,
8178          y: y2
8179        };
8180        const axis = getAlignmentAxis(placement);
8181        const length = getAxisLength(axis);
8182        const arrowDimensions = await platform3.getDimensions(element);
8183        const isYAxis = axis === "y";
8184        const minProp = isYAxis ? "top" : "left";
8185        const maxProp = isYAxis ? "bottom" : "right";
8186        const clientProp = isYAxis ? "clientHeight" : "clientWidth";
8187        const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
8188        const startDiff = coords[axis] - rects.reference[axis];
8189        const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
8190        let clientSize = elements.floating[clientProp] || rects.floating[length];
8191        if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
8192          clientSize = elements.floating[clientProp] || rects.floating[length];
8193        }
8194        const centerToReference = endDiff / 2 - startDiff / 2;
8195        const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
8196        const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
8197        const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
8198        const min2 = minPadding;
8199        const max2 = clientSize - arrowDimensions[length] - maxPadding;
8200        const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
8201        const offset4 = clamp(min2, center, max2);
8202        const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
8203        const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
8204        return {
8205          [axis]: coords[axis] + alignmentOffset,
8206          data: {
8207            [axis]: offset4,
8208            centerOffset: center - offset4 - alignmentOffset,
8209            ...shouldAddOffset && {
8210              alignmentOffset
8211            }
8212          },
8213          reset: shouldAddOffset
8214        };
8215      }
8216    });
8217    var arrow4 = (options, deps) => ({
8218      ...baseArrow(options),
8219      options: [options, deps]
8220    });
8221  
8222    // node_modules/@base-ui/react/utils/hideMiddleware.mjs
8223    var nativeHideFn = hide3().fn;
8224    var hide4 = {
8225      name: "hide",
8226      async fn(state) {
8227        const {
8228          width,
8229          height,
8230          x: x2,
8231          y: y2
8232        } = state.rects.reference;
8233        const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
8234        const nativeHideResult = await nativeHideFn(state);
8235        return {
8236          data: {
8237            referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
8238          }
8239        };
8240      }
8241    };
8242  
8243    // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs
8244    var DEFAULT_SIDES = {
8245      sideX: "left",
8246      sideY: "top"
8247    };
8248    var adaptiveOrigin = {
8249      name: "adaptiveOrigin",
8250      async fn(state) {
8251        const {
8252          x: rawX,
8253          y: rawY,
8254          rects: {
8255            floating: floatRect
8256          },
8257          elements: {
8258            floating
8259          },
8260          platform: platform3,
8261          strategy,
8262          placement
8263        } = state;
8264        const win = getWindow(floating);
8265        const styles = win.getComputedStyle(floating);
8266        const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
8267        if (!hasTransition) {
8268          return {
8269            x: rawX,
8270            y: rawY,
8271            data: DEFAULT_SIDES
8272          };
8273        }
8274        const offsetParent = await platform3.getOffsetParent?.(floating);
8275        let offsetDimensions = {
8276          width: 0,
8277          height: 0
8278        };
8279        if (strategy === "fixed" && win?.visualViewport) {
8280          offsetDimensions = {
8281            width: win.visualViewport.width,
8282            height: win.visualViewport.height
8283          };
8284        } else if (offsetParent === win) {
8285          const doc = ownerDocument(floating);
8286          offsetDimensions = {
8287            width: doc.documentElement.clientWidth,
8288            height: doc.documentElement.clientHeight
8289          };
8290        } else if (await platform3.isElement?.(offsetParent)) {
8291          offsetDimensions = await platform3.getDimensions(offsetParent);
8292        }
8293        const currentSide = getSide(placement);
8294        let x2 = rawX;
8295        let y2 = rawY;
8296        if (currentSide === "left") {
8297          x2 = offsetDimensions.width - (rawX + floatRect.width);
8298        }
8299        if (currentSide === "top") {
8300          y2 = offsetDimensions.height - (rawY + floatRect.height);
8301        }
8302        const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
8303        const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
8304        return {
8305          x: x2,
8306          y: y2,
8307          data: {
8308            sideX,
8309            sideY
8310          }
8311        };
8312      }
8313    };
8314  
8315    // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
8316    function getLogicalSide(sideParam, renderedSide, isRtl) {
8317      const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
8318      const logicalRight = isRtl ? "inline-start" : "inline-end";
8319      const logicalLeft = isRtl ? "inline-end" : "inline-start";
8320      return {
8321        top: "top",
8322        right: isLogicalSideParam ? logicalRight : "right",
8323        bottom: "bottom",
8324        left: isLogicalSideParam ? logicalLeft : "left"
8325      }[renderedSide];
8326    }
8327    function getOffsetData(state, sideParam, isRtl) {
8328      const {
8329        rects,
8330        placement
8331      } = state;
8332      const data = {
8333        side: getLogicalSide(sideParam, getSide(placement), isRtl),
8334        align: getAlignment(placement) || "center",
8335        anchor: {
8336          width: rects.reference.width,
8337          height: rects.reference.height
8338        },
8339        positioner: {
8340          width: rects.floating.width,
8341          height: rects.floating.height
8342        }
8343      };
8344      return data;
8345    }
8346    function useAnchorPositioning(params) {
8347      const {
8348        // Public parameters
8349        anchor,
8350        positionMethod = "absolute",
8351        side: sideParam = "bottom",
8352        sideOffset = 0,
8353        align = "center",
8354        alignOffset = 0,
8355        collisionBoundary,
8356        collisionPadding: collisionPaddingParam = 5,
8357        sticky = false,
8358        arrowPadding = 5,
8359        disableAnchorTracking = false,
8360        inline: inlineMiddleware,
8361        // Private parameters
8362        keepMounted = false,
8363        floatingRootContext,
8364        mounted,
8365        collisionAvoidance,
8366        shiftCrossAxis = false,
8367        nodeId,
8368        adaptiveOrigin: adaptiveOrigin2,
8369        lazyFlip = false,
8370        externalTree
8371      } = params;
8372      const [mountSide, setMountSide] = React29.useState(null);
8373      if (!mounted && mountSide !== null) {
8374        setMountSide(null);
8375      }
8376      const collisionAvoidanceSide = collisionAvoidance.side || "flip";
8377      const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
8378      const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
8379      const anchorFn = typeof anchor === "function" ? anchor : void 0;
8380      const anchorFnCallback = useStableCallback(anchorFn);
8381      const anchorDep = anchorFn ? anchorFnCallback : anchor;
8382      const anchorValueRef = useValueAsRef(anchor);
8383      const mountedRef = useValueAsRef(mounted);
8384      const direction = useDirection();
8385      const isRtl = direction === "rtl";
8386      const side = mountSide || {
8387        top: "top",
8388        right: "right",
8389        bottom: "bottom",
8390        left: "left",
8391        "inline-end": isRtl ? "left" : "right",
8392        "inline-start": isRtl ? "right" : "left"
8393      }[sideParam];
8394      const placement = align === "center" ? side : `$side}-$align}`;
8395      let collisionPadding = collisionPaddingParam;
8396      const bias = 1;
8397      const biasTop = sideParam === "bottom" ? bias : 0;
8398      const biasBottom = sideParam === "top" ? bias : 0;
8399      const biasLeft = sideParam === "right" ? bias : 0;
8400      const biasRight = sideParam === "left" ? bias : 0;
8401      if (typeof collisionPadding === "number") {
8402        collisionPadding = {
8403          top: collisionPadding + biasTop,
8404          right: collisionPadding + biasRight,
8405          bottom: collisionPadding + biasBottom,
8406          left: collisionPadding + biasLeft
8407        };
8408      } else if (collisionPadding) {
8409        collisionPadding = {
8410          top: (collisionPadding.top || 0) + biasTop,
8411          right: (collisionPadding.right || 0) + biasRight,
8412          bottom: (collisionPadding.bottom || 0) + biasBottom,
8413          left: (collisionPadding.left || 0) + biasLeft
8414        };
8415      }
8416      const commonCollisionProps = {
8417        boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
8418        padding: collisionPadding
8419      };
8420      const arrowRef = React29.useRef(null);
8421      const sideOffsetRef = useValueAsRef(sideOffset);
8422      const alignOffsetRef = useValueAsRef(alignOffset);
8423      const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
8424      const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
8425      const middleware = [];
8426      if (inlineMiddleware) {
8427        middleware.push(inlineMiddleware);
8428      }
8429      middleware.push(offset3((state) => {
8430        const data = getOffsetData(state, sideParam, isRtl);
8431        const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
8432        const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
8433        return {
8434          mainAxis: sideAxis,
8435          crossAxis: alignAxis,
8436          alignmentAxis: alignAxis
8437        };
8438      }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
8439      const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
8440      const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
8441      const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
8442        ...commonCollisionProps,
8443        // Ensure the popup flips if it's been limited by its --available-height and it resizes.
8444        // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
8445        padding: {
8446          top: collisionPadding.top + bias,
8447          right: collisionPadding.right + bias,
8448          bottom: collisionPadding.bottom + bias,
8449          left: collisionPadding.left + bias
8450        },
8451        mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
8452        crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
8453        fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
8454      });
8455      const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
8456        const html = ownerDocument(data.elements.floating).documentElement;
8457        return {
8458          ...commonCollisionProps,
8459          // Use the Layout Viewport to avoid shifting around when pinch-zooming
8460          // for context menus.
8461          rootBoundary: shiftCrossAxis ? {
8462            x: 0,
8463            y: 0,
8464            width: html.clientWidth,
8465            height: html.clientHeight
8466          } : void 0,
8467          mainAxis: collisionAvoidanceAlign !== "none",
8468          crossAxis: crossAxisShiftEnabled,
8469          limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
8470            if (!arrowRef.current) {
8471              return {};
8472            }
8473            const {
8474              width,
8475              height
8476            } = arrowRef.current.getBoundingClientRect();
8477            const sideAxis = getSideAxis(getSide(limitData.placement));
8478            const arrowSize = sideAxis === "y" ? width : height;
8479            const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
8480            return {
8481              offset: arrowSize / 2 + offsetAmount / 2
8482            };
8483          })
8484        };
8485      }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
8486      if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
8487        middleware.push(shiftMiddleware, flipMiddleware);
8488      } else {
8489        middleware.push(flipMiddleware, shiftMiddleware);
8490      }
8491      middleware.push(size3({
8492        ...commonCollisionProps,
8493        apply({
8494          elements: {
8495            floating
8496          },
8497          availableWidth,
8498          availableHeight,
8499          rects
8500        }) {
8501          if (!mountedRef.current) {
8502            return;
8503          }
8504          const floatingStyle = floating.style;
8505          floatingStyle.setProperty("--available-width", `$availableWidth}px`);
8506          floatingStyle.setProperty("--available-height", `$availableHeight}px`);
8507          const dpr = getWindow(floating).devicePixelRatio || 1;
8508          const {
8509            x: x3,
8510            y: y3,
8511            width,
8512            height
8513          } = rects.reference;
8514          const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
8515          const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
8516          floatingStyle.setProperty("--anchor-width", `$anchorWidth}px`);
8517          floatingStyle.setProperty("--anchor-height", `$anchorHeight}px`);
8518        }
8519      }), arrow4((state) => ({
8520        // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
8521        // we'll create a fake element.
8522        element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
8523        padding: arrowPadding,
8524        offsetParent: "floating"
8525      }), [arrowPadding]), {
8526        name: "transformOrigin",
8527        fn(state) {
8528          const {
8529            elements: elements2,
8530            middlewareData: middlewareData2,
8531            placement: renderedPlacement2,
8532            rects,
8533            y: y3
8534          } = state;
8535          const currentRenderedSide = getSide(renderedPlacement2);
8536          const currentRenderedAxis = getSideAxis(currentRenderedSide);
8537          const arrowEl = arrowRef.current;
8538          const arrowX = middlewareData2.arrow?.x || 0;
8539          const arrowY = middlewareData2.arrow?.y || 0;
8540          const arrowWidth = arrowEl?.clientWidth || 0;
8541          const arrowHeight = arrowEl?.clientHeight || 0;
8542          const transformX = arrowX + arrowWidth / 2;
8543          const transformY = arrowY + arrowHeight / 2;
8544          const shiftY = Math.abs(middlewareData2.shift?.y || 0);
8545          const halfAnchorHeight = rects.reference.height / 2;
8546          const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
8547          const isOverlappingAnchor = shiftY > sideOffsetValue;
8548          const adjacentTransformOrigin = {
8549            top: `$transformX}px calc(100% + $sideOffsetValue}px)`,
8550            bottom: `$transformX}px ${-sideOffsetValue}px`,
8551            left: `calc(100% + $sideOffsetValue}px) $transformY}px`,
8552            right: `${-sideOffsetValue}px $transformY}px`
8553          }[currentRenderedSide];
8554          const overlapTransformOrigin = `$transformX}px $rects.reference.y + halfAnchorHeight - y3}px`;
8555          elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
8556          return {};
8557        }
8558      }, hide4, adaptiveOrigin2);
8559      useIsoLayoutEffect(() => {
8560        if (!mounted && floatingRootContext) {
8561          floatingRootContext.update({
8562            referenceElement: null,
8563            floatingElement: null,
8564            domReferenceElement: null,
8565            positionReference: null
8566          });
8567        }
8568      }, [mounted, floatingRootContext]);
8569      const autoUpdateOptions = React29.useMemo(() => ({
8570        elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
8571        layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
8572      }), [disableAnchorTracking]);
8573      const {
8574        refs,
8575        elements,
8576        x: x2,
8577        y: y2,
8578        middlewareData,
8579        update: update2,
8580        placement: renderedPlacement,
8581        context,
8582        isPositioned,
8583        floatingStyles: originalFloatingStyles
8584      } = useFloating2({
8585        rootContext: floatingRootContext,
8586        open: keepMounted ? mounted : void 0,
8587        placement,
8588        middleware,
8589        strategy: positionMethod,
8590        whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
8591        nodeId,
8592        externalTree
8593      });
8594      const {
8595        sideX,
8596        sideY
8597      } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
8598      const resolvedPosition = isPositioned ? positionMethod : "fixed";
8599      const floatingStyles = React29.useMemo(() => {
8600        const base = adaptiveOrigin2 ? {
8601          position: resolvedPosition,
8602          [sideX]: x2,
8603          [sideY]: y2
8604        } : {
8605          position: resolvedPosition,
8606          ...originalFloatingStyles
8607        };
8608        if (!isPositioned) {
8609          base.opacity = 0;
8610        }
8611        return base;
8612      }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8613      const registeredPositionReferenceRef = React29.useRef(null);
8614      useIsoLayoutEffect(() => {
8615        if (!mounted) {
8616          return;
8617        }
8618        const anchorValue = anchorValueRef.current;
8619        const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8620        const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8621        const finalAnchor = unwrappedElement || null;
8622        if (finalAnchor !== registeredPositionReferenceRef.current) {
8623          refs.setPositionReference(finalAnchor);
8624          registeredPositionReferenceRef.current = finalAnchor;
8625        }
8626      }, [mounted, refs, anchorDep, anchorValueRef]);
8627      React29.useEffect(() => {
8628        if (!mounted) {
8629          return;
8630        }
8631        const anchorValue = anchorValueRef.current;
8632        if (typeof anchorValue === "function") {
8633          return;
8634        }
8635        if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8636          refs.setPositionReference(anchorValue.current);
8637          registeredPositionReferenceRef.current = anchorValue.current;
8638        }
8639      }, [mounted, refs, anchorDep, anchorValueRef]);
8640      React29.useEffect(() => {
8641        if (keepMounted && mounted && elements.reference && elements.floating) {
8642          return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions);
8643        }
8644        return void 0;
8645      }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8646      const renderedSide = getSide(renderedPlacement);
8647      const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8648      const renderedAlign = getAlignment(renderedPlacement) || "center";
8649      const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
8650      useIsoLayoutEffect(() => {
8651        if (lazyFlip && mounted && isPositioned) {
8652          setMountSide(renderedSide);
8653        }
8654      }, [lazyFlip, mounted, isPositioned, renderedSide]);
8655      const arrowStyles = React29.useMemo(() => ({
8656        position: "absolute",
8657        top: middlewareData.arrow?.y,
8658        left: middlewareData.arrow?.x
8659      }), [middlewareData.arrow]);
8660      const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8661      return React29.useMemo(() => ({
8662        positionerStyles: floatingStyles,
8663        arrowStyles,
8664        arrowRef,
8665        arrowUncentered,
8666        side: logicalRenderedSide,
8667        align: renderedAlign,
8668        physicalSide: renderedSide,
8669        anchorHidden,
8670        refs,
8671        context,
8672        isPositioned,
8673        update: update2
8674      }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
8675    }
8676    function isRef(param) {
8677      return param != null && "current" in param;
8678    }
8679  
8680    // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs
8681    function getDisabledMountTransitionStyles(transitionStatus) {
8682      return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8683    }
8684  
8685    // node_modules/@base-ui/react/utils/usePositioner.mjs
8686    function usePositioner(componentProps, state, {
8687      styles,
8688      transitionStatus,
8689      props,
8690      refs,
8691      hidden,
8692      inert = false
8693    }) {
8694      const style = {
8695        ...styles
8696      };
8697      if (inert) {
8698        style.pointerEvents = "none";
8699      }
8700      return useRenderElement("div", componentProps, {
8701        state,
8702        ref: refs,
8703        props: [{
8704          role: "presentation",
8705          hidden,
8706          style
8707        }, getDisabledMountTransitionStyles(transitionStatus), props],
8708        stateAttributesMapping: popupStateMapping
8709      });
8710    }
8711  
8712    // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8713    var React32 = __toESM(require_react(), 1);
8714    var ReactDOM6 = __toESM(require_react_dom(), 1);
8715  
8716    // node_modules/@base-ui/utils/usePreviousValue.mjs
8717    var React30 = __toESM(require_react(), 1);
8718    function usePreviousValue(value) {
8719      const [state, setState] = React30.useState({
8720        current: value,
8721        previous: null
8722      });
8723      if (value !== state.current) {
8724        setState({
8725          current: value,
8726          previous: state.current
8727        });
8728      }
8729      return state.previous;
8730    }
8731  
8732    // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8733    var React31 = __toESM(require_react(), 1);
8734  
8735    // node_modules/@base-ui/react/utils/getCssDimensions.mjs
8736    function getCssDimensions2(element) {
8737      const css = getComputedStyle2(element);
8738      let width = parseFloat(css.width) || 0;
8739      let height = parseFloat(css.height) || 0;
8740      const hasOffset = isHTMLElement(element);
8741      const offsetWidth = hasOffset ? element.offsetWidth : width;
8742      const offsetHeight = hasOffset ? element.offsetHeight : height;
8743      const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
8744      if (shouldFallback) {
8745        width = offsetWidth;
8746        height = offsetHeight;
8747      }
8748      return {
8749        width,
8750        height
8751      };
8752    }
8753  
8754    // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8755    function usePopupAutoResize(parameters) {
8756      const {
8757        popupElement,
8758        positionerElement,
8759        content,
8760        mounted,
8761        onMeasureLayout: onMeasureLayoutParam,
8762        onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8763        side,
8764        direction
8765      } = parameters;
8766      const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8767      const animationFrame = useAnimationFrame();
8768      const committedDimensionsRef = React31.useRef(null);
8769      const isInitialRenderRef = React31.useRef(true);
8770      const restoreAnchoringStylesRef = React31.useRef(NOOP);
8771      const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8772      const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8773      const anchoringStyles = React31.useMemo(() => {
8774        let isOriginSide = side === "top";
8775        let isPhysicalLeft = side === "left";
8776        if (direction === "rtl") {
8777          isOriginSide = isOriginSide || side === "inline-end";
8778          isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8779        } else {
8780          isOriginSide = isOriginSide || side === "inline-start";
8781          isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8782        }
8783        return isOriginSide ? {
8784          position: "absolute",
8785          [side === "top" ? "bottom" : "top"]: "0",
8786          [isPhysicalLeft ? "right" : "left"]: "0"
8787        } : EMPTY_OBJECT;
8788      }, [side, direction]);
8789      useIsoLayoutEffect(() => {
8790        if (!mounted) {
8791          restoreAnchoringStylesRef.current = NOOP;
8792          isInitialRenderRef.current = true;
8793          committedDimensionsRef.current = null;
8794          return void 0;
8795        }
8796        if (!popupElement || !positionerElement) {
8797          return void 0;
8798        }
8799        restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8800        setPopupCssSize(popupElement, "auto");
8801        const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8802        const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8803        const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8804        const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8805          "--available-width": "max-content",
8806          "--available-height": "max-content"
8807        });
8808        function restoreMeasurementOverrides() {
8809          restorePopupPosition();
8810          restorePopupTransform();
8811          restorePositionerAvailableSize();
8812        }
8813        function restoreMeasurementOverridesIncludingScale() {
8814          restoreMeasurementOverrides();
8815          restorePopupScale();
8816        }
8817        onMeasureLayout?.();
8818        if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8819          setPositionerCssSize(positionerElement, "max-content");
8820          const dimensions = getCssDimensions2(popupElement);
8821          committedDimensionsRef.current = dimensions;
8822          setPositionerCssSize(positionerElement, dimensions);
8823          restoreMeasurementOverridesIncludingScale();
8824          onMeasureLayoutComplete?.(null, dimensions);
8825          isInitialRenderRef.current = false;
8826          return () => {
8827            restoreAnchoringStylesRef.current();
8828            restoreAnchoringStylesRef.current = NOOP;
8829          };
8830        }
8831        setPositionerCssSize(positionerElement, "max-content");
8832        const previousDimensions = committedDimensionsRef.current;
8833        const newDimensions = getCssDimensions2(popupElement);
8834        committedDimensionsRef.current = newDimensions;
8835        setPopupCssSize(popupElement, previousDimensions);
8836        restoreMeasurementOverridesIncludingScale();
8837        onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8838        setPositionerCssSize(positionerElement, newDimensions);
8839        const abortController = new AbortController();
8840        animationFrame.request(() => {
8841          setPopupCssSize(popupElement, newDimensions);
8842          runOnceAnimationsFinish(() => {
8843            popupElement.style.setProperty("--popup-width", "auto");
8844            popupElement.style.setProperty("--popup-height", "auto");
8845          }, abortController.signal);
8846        });
8847        return () => {
8848          abortController.abort();
8849          animationFrame.cancel();
8850          restoreAnchoringStylesRef.current();
8851          restoreAnchoringStylesRef.current = NOOP;
8852        };
8853      }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8854    }
8855    function overrideElementStyle(element, property, value) {
8856      const originalValue = element.style.getPropertyValue(property);
8857      element.style.setProperty(property, value);
8858      return () => {
8859        element.style.setProperty(property, originalValue);
8860      };
8861    }
8862    function applyElementStyles(element, styles) {
8863      const restorers = [];
8864      for (const [key, value] of Object.entries(styles)) {
8865        restorers.push(overrideElementStyle(element, key, value));
8866      }
8867      return restorers.length ? () => {
8868        restorers.forEach((restore) => restore());
8869      } : NOOP;
8870    }
8871    function setPopupCssSize(popupElement, size4) {
8872      const width = size4 === "auto" ? "auto" : `$size4.width}px`;
8873      const height = size4 === "auto" ? "auto" : `$size4.height}px`;
8874      popupElement.style.setProperty("--popup-width", width);
8875      popupElement.style.setProperty("--popup-height", height);
8876    }
8877    function setPositionerCssSize(positionerElement, size4) {
8878      const width = size4 === "max-content" ? "max-content" : `$size4.width}px`;
8879      const height = size4 === "max-content" ? "max-content" : `$size4.height}px`;
8880      positionerElement.style.setProperty("--positioner-width", width);
8881      positionerElement.style.setProperty("--positioner-height", height);
8882    }
8883  
8884    // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8885    var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
8886    function usePopupViewport(parameters) {
8887      const {
8888        store,
8889        side,
8890        cssVars,
8891        children
8892      } = parameters;
8893      const direction = useDirection();
8894      const activeTrigger = store.useState("activeTriggerElement");
8895      const activeTriggerId = store.useState("activeTriggerId");
8896      const open = store.useState("open");
8897      const payload = store.useState("payload");
8898      const mounted = store.useState("mounted");
8899      const popupElement = store.useState("popupElement");
8900      const positionerElement = store.useState("positionerElement");
8901      const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8902      const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8903      const capturedNodeRef = React32.useRef(null);
8904      const [previousContentNode, setPreviousContentNode] = React32.useState(null);
8905      const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null);
8906      const currentContainerRef = React32.useRef(null);
8907      const previousContainerRef = React32.useRef(null);
8908      const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8909      const cleanupFrame = useAnimationFrame();
8910      const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null);
8911      const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false);
8912      useIsoLayoutEffect(() => {
8913        store.set("hasViewport", true);
8914        return () => {
8915          store.set("hasViewport", false);
8916        };
8917      }, [store]);
8918      const handleMeasureLayout = useStableCallback(() => {
8919        currentContainerRef.current?.style.setProperty("animation", "none");
8920        currentContainerRef.current?.style.setProperty("transition", "none");
8921        previousContainerRef.current?.style.setProperty("display", "none");
8922      });
8923      const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8924        currentContainerRef.current?.style.removeProperty("animation");
8925        currentContainerRef.current?.style.removeProperty("transition");
8926        previousContainerRef.current?.style.removeProperty("display");
8927        if (previousDimensions) {
8928          setPreviousContentDimensions(previousDimensions);
8929        }
8930      });
8931      const lastHandledTriggerRef = React32.useRef(null);
8932      useIsoLayoutEffect(() => {
8933        if (!open || !mounted) {
8934          lastHandledTriggerRef.current = null;
8935        }
8936      }, [open, mounted]);
8937      useIsoLayoutEffect(() => {
8938        if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8939          setPreviousContentNode(capturedNodeRef.current);
8940          setShowStartingStyleAttribute(true);
8941          const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8942          setNewTriggerOffset(offset4);
8943          cleanupFrame.request(() => {
8944            ReactDOM6.flushSync(() => {
8945              setShowStartingStyleAttribute(false);
8946            });
8947            onAnimationsFinished(() => {
8948              setPreviousContentNode(null);
8949              setPreviousContentDimensions(null);
8950              capturedNodeRef.current = null;
8951            });
8952          });
8953          lastHandledTriggerRef.current = activeTrigger;
8954        }
8955      }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8956      useIsoLayoutEffect(() => {
8957        const source = currentContainerRef.current;
8958        if (!source) {
8959          return;
8960        }
8961        const wrapper = ownerDocument(source).createElement("div");
8962        for (const child of Array.from(source.childNodes)) {
8963          wrapper.appendChild(child.cloneNode(true));
8964        }
8965        capturedNodeRef.current = wrapper;
8966      });
8967      const isTransitioning = previousContentNode != null;
8968      let childrenToRender;
8969      if (!isTransitioning) {
8970        childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8971          "data-current": true,
8972          ref: currentContainerRef,
8973          children
8974        }, currentContentKey);
8975      } else {
8976        childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(React32.Fragment, {
8977          children: [/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8978            "data-previous": true,
8979            inert: inertValue(true),
8980            ref: previousContainerRef,
8981            style: {
8982              ...previousContentDimensions ? {
8983                [cssVars.popupWidth]: `$previousContentDimensions.width}px`,
8984                [cssVars.popupHeight]: `$previousContentDimensions.height}px`
8985              } : null,
8986              position: "absolute"
8987            },
8988            "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8989          }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8990            "data-current": true,
8991            ref: currentContainerRef,
8992            "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8993            children
8994          }, currentContentKey)]
8995        });
8996      }
8997      useIsoLayoutEffect(() => {
8998        const container = previousContainerRef.current;
8999        if (!container || !previousContentNode) {
9000          return;
9001        }
9002        container.replaceChildren(...Array.from(previousContentNode.childNodes));
9003      }, [previousContentNode]);
9004      usePopupAutoResize({
9005        popupElement,
9006        positionerElement,
9007        mounted,
9008        content: payload,
9009        onMeasureLayout: handleMeasureLayout,
9010        onMeasureLayoutComplete: handleMeasureLayoutComplete,
9011        side,
9012        direction
9013      });
9014      const state = {
9015        activationDirection: getActivationDirection(newTriggerOffset),
9016        transitioning: isTransitioning
9017      };
9018      return {
9019        children: childrenToRender,
9020        state
9021      };
9022    }
9023    function getActivationDirection(offset4) {
9024      if (!offset4) {
9025        return void 0;
9026      }
9027      return `$getValueWithTolerance(offset4.horizontal, 5, "right", "left")} $getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
9028    }
9029    function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
9030      if (value > tolerance) {
9031        return positiveLabel;
9032      }
9033      if (value < -tolerance) {
9034        return negativeLabel;
9035      }
9036      return "";
9037    }
9038    function calculateRelativePosition(from, to) {
9039      const fromRect = from.getBoundingClientRect();
9040      const toRect = to.getBoundingClientRect();
9041      const fromCenter = {
9042        x: fromRect.left + fromRect.width / 2,
9043        y: fromRect.top + fromRect.height / 2
9044      };
9045      const toCenter = {
9046        x: toRect.left + toRect.width / 2,
9047        y: toRect.top + toRect.height / 2
9048      };
9049      return {
9050        horizontal: toCenter.x - fromCenter.x,
9051        vertical: toCenter.y - fromCenter.y
9052      };
9053    }
9054    function usePopupContentKey(activeTriggerId, payload) {
9055      const [contentKey, setContentKey] = React32.useState(0);
9056      const previousActiveTriggerIdRef = React32.useRef(activeTriggerId);
9057      const previousPayloadRef = React32.useRef(payload);
9058      const pendingPayloadUpdateRef = React32.useRef(false);
9059      useIsoLayoutEffect(() => {
9060        const previousActiveTriggerId = previousActiveTriggerIdRef.current;
9061        const previousPayload = previousPayloadRef.current;
9062        const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
9063        const payloadChanged = payload !== previousPayload;
9064        if (triggerIdChanged) {
9065          setContentKey((value) => value + 1);
9066          pendingPayloadUpdateRef.current = !payloadChanged;
9067        } else if (pendingPayloadUpdateRef.current && payloadChanged) {
9068          setContentKey((value) => value + 1);
9069          pendingPayloadUpdateRef.current = false;
9070        }
9071        previousActiveTriggerIdRef.current = activeTriggerId;
9072        previousPayloadRef.current = payload;
9073      }, [activeTriggerId, payload]);
9074      return `$activeTriggerId ?? "current"}-$contentKey}`;
9075    }
9076  
9077    // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs
9078    var React33 = __toESM(require_react(), 1);
9079    var ReactDOM7 = __toESM(require_react_dom(), 1);
9080    var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9081    var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
9082      const {
9083        children,
9084        container,
9085        className,
9086        render: render4,
9087        style,
9088        ...elementProps
9089      } = componentProps;
9090      const {
9091        portalNode,
9092        portalSubtree
9093      } = useFloatingPortalNode({
9094        container,
9095        ref: forwardedRef,
9096        componentProps,
9097        elementProps
9098      });
9099      if (!portalSubtree && !portalNode) {
9100        return null;
9101      }
9102      return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(React33.Fragment, {
9103        children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)]
9104      });
9105    });
9106    if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
9107  
9108    // node_modules/@base-ui/react/tooltip/index.parts.mjs
9109    var index_parts_exports = {};
9110    __export(index_parts_exports, {
9111      Arrow: () => TooltipArrow,
9112      Handle: () => TooltipHandle,
9113      Popup: () => TooltipPopup,
9114      Portal: () => TooltipPortal,
9115      Positioner: () => TooltipPositioner,
9116      Provider: () => TooltipProvider,
9117      Root: () => TooltipRoot,
9118      Trigger: () => TooltipTrigger,
9119      Viewport: () => TooltipViewport,
9120      createHandle: () => createTooltipHandle
9121    });
9122  
9123    // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
9124    var React36 = __toESM(require_react(), 1);
9125  
9126    // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs
9127    var React34 = __toESM(require_react(), 1);
9128    var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0);
9129    if (true) TooltipRootContext.displayName = "TooltipRootContext";
9130    function useTooltipRootContext(optional) {
9131      const context = React34.useContext(TooltipRootContext);
9132      if (context === void 0 && !optional) {
9133        throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
9134      }
9135      return context;
9136    }
9137  
9138    // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
9139    var React35 = __toESM(require_react(), 1);
9140    var selectors2 = {
9141      ...popupStoreSelectors,
9142      disabled: createSelector((state) => state.disabled),
9143      instantType: createSelector((state) => state.instantType),
9144      isInstantPhase: createSelector((state) => state.isInstantPhase),
9145      trackCursorAxis: createSelector((state) => state.trackCursorAxis),
9146      disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
9147      lastOpenChangeReason: createSelector((state) => state.openChangeReason),
9148      closeOnClick: createSelector((state) => state.closeOnClick),
9149      closeDelay: createSelector((state) => state.closeDelay),
9150      hasViewport: createSelector((state) => state.hasViewport)
9151    };
9152    var TooltipStore = class _TooltipStore extends ReactStore {
9153      constructor(initialState, floatingId, nested = false) {
9154        const triggerElements = new PopupTriggerMap();
9155        const state = {
9156          ...createInitialState(),
9157          ...initialState
9158        };
9159        state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
9160        super(state, {
9161          popupRef: /* @__PURE__ */ React35.createRef(),
9162          onOpenChange: void 0,
9163          onOpenChangeComplete: void 0,
9164          triggerElements
9165        }, selectors2);
9166      }
9167      setOpen = (nextOpen, eventDetails) => {
9168        applyPopupOpenChange(this, nextOpen, eventDetails, {
9169          extraState: {
9170            openChangeReason: eventDetails.reason
9171          }
9172        });
9173      };
9174      // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
9175      cancelPendingOpen(event) {
9176        this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
9177      }
9178      static useStore(externalStore, initialState) {
9179        const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
9180        return store;
9181      }
9182    };
9183    function createInitialState() {
9184      return {
9185        ...createInitialPopupStoreState(),
9186        disabled: false,
9187        instantType: void 0,
9188        isInstantPhase: false,
9189        trackCursorAxis: "none",
9190        disableHoverablePopup: false,
9191        openChangeReason: null,
9192        closeOnClick: true,
9193        closeDelay: 0,
9194        hasViewport: false
9195      };
9196    }
9197  
9198    // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
9199    var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9200    var TooltipRoot = fastComponent(function TooltipRoot2(props) {
9201      const {
9202        disabled: disabled2 = false,
9203        defaultOpen = false,
9204        open: openProp,
9205        disableHoverablePopup = false,
9206        trackCursorAxis = "none",
9207        actionsRef,
9208        onOpenChange,
9209        onOpenChangeComplete,
9210        handle,
9211        triggerId: triggerIdProp,
9212        defaultTriggerId: defaultTriggerIdProp = null,
9213        children
9214      } = props;
9215      const store = TooltipStore.useStore(handle?.store, {
9216        open: defaultOpen,
9217        openProp,
9218        activeTriggerId: defaultTriggerIdProp,
9219        triggerIdProp
9220      });
9221      useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp);
9222      store.useControlledProp("openProp", openProp);
9223      store.useControlledProp("triggerIdProp", triggerIdProp);
9224      store.useContextCallback("onOpenChange", onOpenChange);
9225      store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
9226      const openState = store.useState("open");
9227      const open = !disabled2 && openState;
9228      const activeTriggerId = store.useState("activeTriggerId");
9229      const mounted = store.useState("mounted");
9230      const payload = store.useState("payload");
9231      store.useSyncedValues({
9232        trackCursorAxis,
9233        disableHoverablePopup
9234      });
9235      store.useSyncedValue("disabled", disabled2);
9236      useImplicitActiveTrigger(store, {
9237        closeOnActiveTriggerUnmount: true
9238      });
9239      const {
9240        forceUnmount,
9241        transitionStatus
9242      } = useOpenStateTransitions(open, store);
9243      const isInstantPhase = store.useState("isInstantPhase");
9244      const instantType = store.useState("instantType");
9245      const lastOpenChangeReason = store.useState("lastOpenChangeReason");
9246      const previousInstantTypeRef = React36.useRef(null);
9247      useIsoLayoutEffect(() => {
9248        if (openState && disabled2) {
9249          store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
9250        }
9251      }, [openState, disabled2, store]);
9252      useIsoLayoutEffect(() => {
9253        if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
9254          if (instantType !== "delay") {
9255            previousInstantTypeRef.current = instantType;
9256          }
9257          store.set("instantType", "delay");
9258        } else if (previousInstantTypeRef.current !== null) {
9259          store.set("instantType", previousInstantTypeRef.current);
9260          previousInstantTypeRef.current = null;
9261        }
9262      }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
9263      useIsoLayoutEffect(() => {
9264        if (open) {
9265          if (activeTriggerId == null) {
9266            store.set("payload", void 0);
9267          }
9268        }
9269      }, [store, activeTriggerId, open]);
9270      const handleImperativeClose = React36.useCallback(() => {
9271        store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
9272      }, [store]);
9273      React36.useImperativeHandle(actionsRef, () => ({
9274        unmount: forceUnmount,
9275        close: handleImperativeClose
9276      }), [forceUnmount, handleImperativeClose]);
9277      const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
9278      return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(TooltipRootContext.Provider, {
9279        value: store,
9280        children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TooltipInteractions, {
9281          store,
9282          disabled: disabled2,
9283          trackCursorAxis
9284        }), typeof children === "function" ? children({
9285          payload
9286        }) : children]
9287      });
9288    });
9289    if (true) TooltipRoot.displayName = "TooltipRoot";
9290    function TooltipInteractions({
9291      store,
9292      disabled: disabled2,
9293      trackCursorAxis
9294    }) {
9295      const floatingRootContext = store.useState("floatingRootContext");
9296      const dismiss = useDismiss(floatingRootContext, {
9297        enabled: !disabled2,
9298        referencePress: () => store.select("closeOnClick")
9299      });
9300      const clientPoint = useClientPoint(floatingRootContext, {
9301        enabled: !disabled2 && trackCursorAxis !== "none",
9302        axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
9303      });
9304      const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
9305      const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
9306      const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
9307      usePopupInteractionProps(store, {
9308        activeTriggerProps,
9309        inactiveTriggerProps,
9310        popupProps
9311      });
9312      return null;
9313    }
9314  
9315    // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
9316    var React38 = __toESM(require_react(), 1);
9317  
9318    // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs
9319    var React37 = __toESM(require_react(), 1);
9320    var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0);
9321    if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
9322    function useTooltipProviderContext() {
9323      return React37.useContext(TooltipProviderContext);
9324    }
9325  
9326    // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs
9327    var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
9328      TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
9329      TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
9330      return TooltipTriggerDataAttributes2;
9331    })({});
9332  
9333    // node_modules/@base-ui/react/tooltip/utils/constants.mjs
9334    var OPEN_DELAY = 600;
9335  
9336    // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
9337    var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
9338    function getTargetElement(event) {
9339      if ("composedPath" in event) {
9340        const path = event.composedPath();
9341        for (let i2 = 0; i2 < path.length; i2 += 1) {
9342          const element = path[i2];
9343          if (isElement(element)) {
9344            return element;
9345          }
9346        }
9347      }
9348      const target = event.target;
9349      if (isElement(target)) {
9350        return target;
9351      }
9352      return null;
9353    }
9354    function closestEnabledTooltipTrigger(element) {
9355      let current = element;
9356      while (current) {
9357        if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
9358          return current;
9359        }
9360        const parentElement = current.parentElement;
9361        if (parentElement) {
9362          current = parentElement;
9363          continue;
9364        }
9365        const root = current.getRootNode();
9366        current = "host" in root && isElement(root.host) ? root.host : null;
9367      }
9368      return null;
9369    }
9370    var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
9371      const {
9372        render: render4,
9373        className,
9374        style,
9375        handle,
9376        payload,
9377        disabled: disabledProp,
9378        delay,
9379        closeOnClick = true,
9380        closeDelay,
9381        id: idProp,
9382        ...elementProps
9383      } = componentProps;
9384      const rootContext = useTooltipRootContext(true);
9385      const store = handle?.store ?? rootContext;
9386      if (!store) {
9387        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));
9388      }
9389      const thisTriggerId = useBaseUiId(idProp);
9390      const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
9391      const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
9392      const floatingRootContext = store.useState("floatingRootContext");
9393      const triggerElementRef = React38.useRef(null);
9394      const delayWithDefault = delay ?? OPEN_DELAY;
9395      const closeDelayWithDefault = closeDelay ?? 0;
9396      const {
9397        registerTrigger,
9398        isMountedByThisTrigger
9399      } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
9400        payload,
9401        closeOnClick,
9402        closeDelay: closeDelayWithDefault
9403      });
9404      const providerContext = useTooltipProviderContext();
9405      const {
9406        delayRef,
9407        isInstantPhase,
9408        hasProvider
9409      } = useDelayGroup(floatingRootContext, {
9410        open: isOpenedByThisTrigger
9411      });
9412      const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
9413      store.useSyncedValue("isInstantPhase", isInstantPhase);
9414      const rootDisabled = store.useState("disabled");
9415      const disabled2 = disabledProp ?? rootDisabled;
9416      const disabledRef = useValueAsRef(disabled2);
9417      const trackCursorAxis = store.useState("trackCursorAxis");
9418      const disableHoverablePopup = store.useState("disableHoverablePopup");
9419      const isNestedTriggerHoveredRef = React38.useRef(false);
9420      const nestedTriggerOpenTimeout = useTimeout();
9421      const pointerTypeRef = React38.useRef(void 0);
9422      function getOpenDelay() {
9423        const providerDelay = providerContext?.delay;
9424        const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
9425        let computedOpenDelay = delayWithDefault;
9426        if (hasProvider) {
9427          if (groupOpenValue !== 0) {
9428            computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
9429          } else {
9430            computedOpenDelay = 0;
9431          }
9432        }
9433        return computedOpenDelay;
9434      }
9435      function isEnabledNestedTriggerTarget(target) {
9436        const triggerEl = triggerElementRef.current;
9437        if (!triggerEl || !target) {
9438          return false;
9439        }
9440        const nearestTrigger = closestEnabledTooltipTrigger(target);
9441        return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
9442      }
9443      function detectNestedTriggerHover(target) {
9444        const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
9445        isNestedTriggerHoveredRef.current = nestedTriggerHovered;
9446        if (nestedTriggerHovered) {
9447          hoverInteraction.openChangeTimeout.clear();
9448          hoverInteraction.restTimeout.clear();
9449          hoverInteraction.restTimeoutPending = false;
9450          nestedTriggerOpenTimeout.clear();
9451        }
9452        return nestedTriggerHovered;
9453      }
9454      const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
9455        enabled: !disabled2,
9456        mouseOnly: true,
9457        move: false,
9458        handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
9459        restMs: getOpenDelay,
9460        delay() {
9461          const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
9462          let computedCloseDelay = closeDelayWithDefault;
9463          if (closeDelay == null && hasProvider) {
9464            computedCloseDelay = closeValue;
9465          }
9466          return {
9467            close: computedCloseDelay
9468          };
9469        },
9470        triggerElementRef,
9471        isActiveTrigger: isTriggerActive,
9472        isClosing: () => store.select("transitionStatus") === "ending",
9473        shouldOpen() {
9474          return !isNestedTriggerHoveredRef.current;
9475        }
9476      });
9477      const focusProps = useFocus(floatingRootContext, {
9478        enabled: !disabled2
9479      }).reference;
9480      const handleNestedTriggerHover = (event) => {
9481        const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
9482        const target = getTargetElement(event);
9483        const nestedTriggerHovered = detectNestedTriggerHover(target);
9484        const triggerEl = triggerElementRef.current;
9485        const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
9486        if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
9487          store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
9488          return;
9489        }
9490        if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
9491        isMouseLikePointerType(pointerTypeRef.current)) {
9492          const open = () => {
9493            if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
9494              store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
9495            }
9496          };
9497          const openDelay = getOpenDelay();
9498          if (openDelay === 0) {
9499            nestedTriggerOpenTimeout.clear();
9500            open();
9501          } else {
9502            nestedTriggerOpenTimeout.start(openDelay, open);
9503          }
9504        }
9505      };
9506      const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
9507      const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
9508      const state = {
9509        open: isOpenedByThisTrigger
9510      };
9511      const element = useRenderElement("button", componentProps, {
9512        state,
9513        ref: [forwardedRef, registerTrigger, triggerElementRef],
9514        props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
9515          onMouseOver(event) {
9516            handleNestedTriggerHover(event.nativeEvent);
9517          },
9518          onFocus(event) {
9519            if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
9520              event.preventBaseUIHandler();
9521            }
9522          },
9523          onMouseLeave() {
9524            isNestedTriggerHoveredRef.current = false;
9525            nestedTriggerOpenTimeout.clear();
9526            pointerTypeRef.current = void 0;
9527          },
9528          onPointerEnter(event) {
9529            pointerTypeRef.current = event.pointerType;
9530          },
9531          onPointerDown(event) {
9532            pointerTypeRef.current = event.pointerType;
9533            store.set("closeOnClick", closeOnClick);
9534            if (closeOnClick && !store.select("open")) {
9535              store.cancelPendingOpen(event.nativeEvent);
9536            }
9537          },
9538          onClick(event) {
9539            if (closeOnClick && !store.select("open")) {
9540              store.cancelPendingOpen(event.nativeEvent);
9541            }
9542          },
9543          id: thisTriggerId,
9544          [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
9545          [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
9546        }, elementProps],
9547        stateAttributesMapping: triggerOpenStateMapping
9548      });
9549      return element;
9550    });
9551    if (true) TooltipTrigger.displayName = "TooltipTrigger";
9552  
9553    // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
9554    var React40 = __toESM(require_react(), 1);
9555  
9556    // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs
9557    var React39 = __toESM(require_react(), 1);
9558    var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0);
9559    if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
9560    function useTooltipPortalContext() {
9561      const value = React39.useContext(TooltipPortalContext);
9562      if (value === void 0) {
9563        throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
9564      }
9565      return value;
9566    }
9567  
9568    // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
9569    var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9570    var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) {
9571      const {
9572        keepMounted = false,
9573        ...portalProps
9574      } = props;
9575      const store = useTooltipRootContext();
9576      const mounted = store.useState("mounted");
9577      const shouldRender = mounted || keepMounted;
9578      if (!shouldRender) {
9579        return null;
9580      }
9581      return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(TooltipPortalContext.Provider, {
9582        value: keepMounted,
9583        children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FloatingPortalLite, {
9584          ref: forwardedRef,
9585          ...portalProps
9586        })
9587      });
9588    });
9589    if (true) TooltipPortal.displayName = "TooltipPortal";
9590  
9591    // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9592    var React42 = __toESM(require_react(), 1);
9593  
9594    // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs
9595    var React41 = __toESM(require_react(), 1);
9596    var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0);
9597    if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
9598    function useTooltipPositionerContext() {
9599      const context = React41.useContext(TooltipPositionerContext);
9600      if (context === void 0) {
9601        throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
9602      }
9603      return context;
9604    }
9605  
9606    // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9607    var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9608    var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
9609      const {
9610        render: render4,
9611        className,
9612        anchor,
9613        positionMethod = "absolute",
9614        side = "top",
9615        align = "center",
9616        sideOffset = 0,
9617        alignOffset = 0,
9618        collisionBoundary = "clipping-ancestors",
9619        collisionPadding = 5,
9620        arrowPadding = 5,
9621        sticky = false,
9622        disableAnchorTracking = false,
9623        collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
9624        style,
9625        ...elementProps
9626      } = componentProps;
9627      const store = useTooltipRootContext();
9628      const keepMounted = useTooltipPortalContext();
9629      const open = store.useState("open");
9630      const mounted = store.useState("mounted");
9631      const trackCursorAxis = store.useState("trackCursorAxis");
9632      const disableHoverablePopup = store.useState("disableHoverablePopup");
9633      const floatingRootContext = store.useState("floatingRootContext");
9634      const instantType = store.useState("instantType");
9635      const transitionStatus = store.useState("transitionStatus");
9636      const hasViewport = store.useState("hasViewport");
9637      const positioning = useAnchorPositioning({
9638        anchor,
9639        positionMethod,
9640        floatingRootContext,
9641        mounted,
9642        side,
9643        sideOffset,
9644        align,
9645        alignOffset,
9646        collisionBoundary,
9647        collisionPadding,
9648        sticky,
9649        arrowPadding,
9650        disableAnchorTracking,
9651        keepMounted,
9652        collisionAvoidance,
9653        adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
9654      });
9655      const state = React42.useMemo(() => ({
9656        open,
9657        side: positioning.side,
9658        align: positioning.align,
9659        anchorHidden: positioning.anchorHidden,
9660        instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
9661      }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
9662      const element = usePositioner(componentProps, state, {
9663        styles: positioning.positionerStyles,
9664        transitionStatus,
9665        props: elementProps,
9666        refs: [forwardedRef, store.useStateSetter("positionerElement")],
9667        hidden: !mounted,
9668        inert: !open || trackCursorAxis === "both" || disableHoverablePopup
9669      });
9670      return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(TooltipPositionerContext.Provider, {
9671        value: positioning,
9672        children: element
9673      });
9674    });
9675    if (true) TooltipPositioner.displayName = "TooltipPositioner";
9676  
9677    // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs
9678    var React43 = __toESM(require_react(), 1);
9679    var stateAttributesMapping = {
9680      ...popupStateMapping,
9681      ...transitionStatusMapping
9682    };
9683    var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
9684      const {
9685        render: render4,
9686        className,
9687        style,
9688        ...elementProps
9689      } = componentProps;
9690      const store = useTooltipRootContext();
9691      const {
9692        side,
9693        align
9694      } = useTooltipPositionerContext();
9695      const open = store.useState("open");
9696      const instantType = store.useState("instantType");
9697      const transitionStatus = store.useState("transitionStatus");
9698      const popupProps = store.useState("popupProps");
9699      const floatingContext = store.useState("floatingRootContext");
9700      const disabled2 = store.useState("disabled");
9701      const closeDelay = store.useState("closeDelay");
9702      useOpenChangeComplete({
9703        open,
9704        ref: store.context.popupRef,
9705        onComplete() {
9706          if (open) {
9707            store.context.onOpenChangeComplete?.(true);
9708          }
9709        }
9710      });
9711      useHoverFloatingInteraction(floatingContext, {
9712        enabled: !disabled2,
9713        closeDelay
9714      });
9715      const setPopupElement = store.useStateSetter("popupElement");
9716      const state = {
9717        open,
9718        side,
9719        align,
9720        instant: instantType,
9721        transitionStatus
9722      };
9723      const element = useRenderElement("div", componentProps, {
9724        state,
9725        ref: [forwardedRef, store.context.popupRef, setPopupElement],
9726        props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9727        stateAttributesMapping
9728      });
9729      return element;
9730    });
9731    if (true) TooltipPopup.displayName = "TooltipPopup";
9732  
9733    // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs
9734    var React44 = __toESM(require_react(), 1);
9735    var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9736      const {
9737        render: render4,
9738        className,
9739        style,
9740        ...elementProps
9741      } = componentProps;
9742      const store = useTooltipRootContext();
9743      const {
9744        arrowRef,
9745        side,
9746        align,
9747        arrowUncentered,
9748        arrowStyles
9749      } = useTooltipPositionerContext();
9750      const open = store.useState("open");
9751      const instantType = store.useState("instantType");
9752      const state = {
9753        open,
9754        side,
9755        align,
9756        uncentered: arrowUncentered,
9757        instant: instantType
9758      };
9759      const element = useRenderElement("div", componentProps, {
9760        state,
9761        ref: [forwardedRef, arrowRef],
9762        props: [{
9763          style: arrowStyles,
9764          "aria-hidden": true
9765        }, elementProps],
9766        stateAttributesMapping: popupStateMapping
9767      });
9768      return element;
9769    });
9770    if (true) TooltipArrow.displayName = "TooltipArrow";
9771  
9772    // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs
9773    var React45 = __toESM(require_react(), 1);
9774    var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9775    var TooltipProvider = function TooltipProvider2(props) {
9776      const {
9777        delay,
9778        closeDelay,
9779        timeout = 400
9780      } = props;
9781      const contextValue = React45.useMemo(() => ({
9782        delay,
9783        closeDelay
9784      }), [delay, closeDelay]);
9785      const delayValue = React45.useMemo(() => ({
9786        open: delay,
9787        close: closeDelay
9788      }), [delay, closeDelay]);
9789      return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(TooltipProviderContext.Provider, {
9790        value: contextValue,
9791        children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(FloatingDelayGroup, {
9792          delay: delayValue,
9793          timeoutMs: timeout,
9794          children: props.children
9795        })
9796      });
9797    };
9798    if (true) TooltipProvider.displayName = "TooltipProvider";
9799  
9800    // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9801    var React46 = __toESM(require_react(), 1);
9802  
9803    // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs
9804    var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9805      TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9806      TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9807      return TooltipViewportCssVars2;
9808    })({});
9809  
9810    // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9811    var stateAttributesMapping2 = {
9812      activationDirection: (value) => value ? {
9813        "data-activation-direction": value
9814      } : null
9815    };
9816    var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9817      const {
9818        render: render4,
9819        className,
9820        style,
9821        children,
9822        ...elementProps
9823      } = componentProps;
9824      const store = useTooltipRootContext();
9825      const positioner = useTooltipPositionerContext();
9826      const instantType = store.useState("instantType");
9827      const {
9828        children: childrenToRender,
9829        state: viewportState
9830      } = usePopupViewport({
9831        store,
9832        side: positioner.side,
9833        cssVars: TooltipViewportCssVars,
9834        children
9835      });
9836      const state = {
9837        activationDirection: viewportState.activationDirection,
9838        transitioning: viewportState.transitioning,
9839        instant: instantType
9840      };
9841      return useRenderElement("div", componentProps, {
9842        state,
9843        ref: forwardedRef,
9844        props: [elementProps, {
9845          children: childrenToRender
9846        }],
9847        stateAttributesMapping: stateAttributesMapping2
9848      });
9849    });
9850    if (true) TooltipViewport.displayName = "TooltipViewport";
9851  
9852    // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs
9853    var TooltipHandle = class {
9854      /**
9855       * Internal store holding the tooltip state.
9856       * @internal
9857       */
9858      constructor() {
9859        this.store = new TooltipStore();
9860      }
9861      /**
9862       * Opens the tooltip and associates it with the trigger with the given ID.
9863       * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9864       *
9865       * This method should only be called in an event handler or an effect (not during rendering).
9866       *
9867       * @param triggerId ID of the trigger to associate with the tooltip.
9868       */
9869      open(triggerId) {
9870        const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9871        if (triggerId && !triggerElement) {
9872          throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "$triggerId}".` : formatErrorMessage_default(81, triggerId));
9873        }
9874        this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9875      }
9876      /**
9877       * Closes the tooltip.
9878       */
9879      close() {
9880        this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9881      }
9882      /**
9883       * Indicates whether the tooltip is currently open.
9884       */
9885      get isOpen() {
9886        return this.store.select("open");
9887      }
9888    };
9889    function createTooltipHandle() {
9890      return new TooltipHandle();
9891    }
9892  
9893    // node_modules/@base-ui/react/use-render/useRender.mjs
9894    function useRender(params) {
9895      return useRenderElement(params.defaultTagName ?? "div", params, params);
9896    }
9897  
9898    // packages/ui/build-module/utils/render-slot-with-children.mjs
9899    var import_element11 = __toESM(require_element(), 1);
9900    function renderSlotWithChildren(slot, defaultSlot, children) {
9901      return (0, import_element11.cloneElement)(slot ?? defaultSlot, { children });
9902    }
9903  
9904    // packages/ui/build-module/utils/theme-provider.mjs
9905    var theme = __toESM(require_theme(), 1);
9906  
9907    // packages/ui/build-module/lock-unlock.mjs
9908    var import_private_apis = __toESM(require_private_apis(), 1);
9909    var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9910      "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9911      "@wordpress/ui"
9912    );
9913  
9914    // packages/ui/build-module/utils/theme-provider.mjs
9915    function getThemeProvider() {
9916      const themePackage = theme;
9917      if (themePackage.ThemeProvider) {
9918        return themePackage.ThemeProvider;
9919      }
9920      if (!themePackage.privateApis) {
9921        throw new Error(
9922          "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
9923        );
9924      }
9925      return unlock(
9926        themePackage.privateApis
9927      ).ThemeProvider;
9928    }
9929    var ThemeProvider = getThemeProvider();
9930  
9931    // packages/ui/build-module/stack/stack.mjs
9932    var import_element12 = __toESM(require_element(), 1);
9933    var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9934    function getRuntime() {
9935      const globalScope = globalThis;
9936      if (globalScope.__wpStyleRuntime) {
9937        return globalScope.__wpStyleRuntime;
9938      }
9939      globalScope.__wpStyleRuntime = {
9940        documents: /* @__PURE__ */ new Map(),
9941        styles: /* @__PURE__ */ new Map(),
9942        injectedStyles: /* @__PURE__ */ new WeakMap()
9943      };
9944      if (typeof document !== "undefined") {
9945        registerDocument(document);
9946      }
9947      return globalScope.__wpStyleRuntime;
9948    }
9949    function documentContainsStyleHash(targetDocument, hash) {
9950      if (!targetDocument.head) {
9951        return false;
9952      }
9953      for (const style of targetDocument.head.querySelectorAll(
9954        `style[$STYLE_HASH_ATTRIBUTE}]`
9955      )) {
9956        if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9957          return true;
9958        }
9959      }
9960      return false;
9961    }
9962    function injectStyle(targetDocument, hash, css) {
9963      if (!targetDocument.head) {
9964        return;
9965      }
9966      const runtime = getRuntime();
9967      let injectedStyles = runtime.injectedStyles.get(targetDocument);
9968      if (!injectedStyles) {
9969        injectedStyles = /* @__PURE__ */ new Set();
9970        runtime.injectedStyles.set(targetDocument, injectedStyles);
9971      }
9972      if (injectedStyles.has(hash)) {
9973        return;
9974      }
9975      if (documentContainsStyleHash(targetDocument, hash)) {
9976        injectedStyles.add(hash);
9977        return;
9978      }
9979      const style = targetDocument.createElement("style");
9980      style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9981      style.appendChild(targetDocument.createTextNode(css));
9982      targetDocument.head.appendChild(style);
9983      injectedStyles.add(hash);
9984    }
9985    function registerDocument(targetDocument) {
9986      const runtime = getRuntime();
9987      runtime.documents.set(
9988        targetDocument,
9989        (runtime.documents.get(targetDocument) ?? 0) + 1
9990      );
9991      for (const [hash, css] of runtime.styles) {
9992        injectStyle(targetDocument, hash, css);
9993      }
9994      return () => {
9995        const count = runtime.documents.get(targetDocument);
9996        if (count === void 0) {
9997          return;
9998        }
9999        if (count <= 1) {
10000          runtime.documents.delete(targetDocument);
10001          return;
10002        }
10003        runtime.documents.set(targetDocument, count - 1);
10004      };
10005    }
10006    function registerStyle(hash, css) {
10007      const runtime = getRuntime();
10008      runtime.styles.set(hash, css);
10009      for (const targetDocument of runtime.documents.keys()) {
10010        injectStyle(targetDocument, hash, css);
10011      }
10012    }
10013    if (typeof process === "undefined" || true) {
10014      registerStyle("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
10015    }
10016    var style_default = { "stack": "_19ce0419607e1896__stack" };
10017    var gapTokens = {
10018      xs: "var(--wpds-dimension-gap-xs, 4px)",
10019      sm: "var(--wpds-dimension-gap-sm, 8px)",
10020      md: "var(--wpds-dimension-gap-md, 12px)",
10021      lg: "var(--wpds-dimension-gap-lg, 16px)",
10022      xl: "var(--wpds-dimension-gap-xl, 24px)",
10023      "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
10024      "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
10025    };
10026    var Stack = (0, import_element12.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
10027      const style = {
10028        gap: gap && gapTokens[gap],
10029        alignItems: align,
10030        justifyContent: justify,
10031        flexDirection: direction,
10032        flexWrap: wrap
10033      };
10034      const element = useRender({
10035        render: render4,
10036        ref,
10037        props: mergeProps(props, { style, className: style_default.stack })
10038      });
10039      return element;
10040    });
10041  
10042    // packages/ui/build-module/tooltip/index.mjs
10043    var tooltip_exports = {};
10044    __export(tooltip_exports, {
10045      Popup: () => Popup,
10046      Portal: () => Portal,
10047      Positioner: () => Positioner,
10048      Provider: () => Provider,
10049      Root: () => Root,
10050      Trigger: () => Trigger
10051    });
10052  
10053    // packages/ui/build-module/tooltip/popup.mjs
10054    var import_element15 = __toESM(require_element(), 1);
10055  
10056    // packages/ui/build-module/tooltip/portal.mjs
10057    var import_element13 = __toESM(require_element(), 1);
10058  
10059    // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
10060    var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
10061    function getRuntime2() {
10062      const globalScope = globalThis;
10063      if (globalScope.__wpStyleRuntime) {
10064        return globalScope.__wpStyleRuntime;
10065      }
10066      globalScope.__wpStyleRuntime = {
10067        documents: /* @__PURE__ */ new Map(),
10068        styles: /* @__PURE__ */ new Map(),
10069        injectedStyles: /* @__PURE__ */ new WeakMap()
10070      };
10071      if (typeof document !== "undefined") {
10072        registerDocument2(document);
10073      }
10074      return globalScope.__wpStyleRuntime;
10075    }
10076    function documentContainsStyleHash2(targetDocument, hash) {
10077      if (!targetDocument.head) {
10078        return false;
10079      }
10080      for (const style of targetDocument.head.querySelectorAll(
10081        `style[$STYLE_HASH_ATTRIBUTE2}]`
10082      )) {
10083        if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
10084          return true;
10085        }
10086      }
10087      return false;
10088    }
10089    function injectStyle2(targetDocument, hash, css) {
10090      if (!targetDocument.head) {
10091        return;
10092      }
10093      const runtime = getRuntime2();
10094      let injectedStyles = runtime.injectedStyles.get(targetDocument);
10095      if (!injectedStyles) {
10096        injectedStyles = /* @__PURE__ */ new Set();
10097        runtime.injectedStyles.set(targetDocument, injectedStyles);
10098      }
10099      if (injectedStyles.has(hash)) {
10100        return;
10101      }
10102      if (documentContainsStyleHash2(targetDocument, hash)) {
10103        injectedStyles.add(hash);
10104        return;
10105      }
10106      const style = targetDocument.createElement("style");
10107      style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
10108      style.appendChild(targetDocument.createTextNode(css));
10109      targetDocument.head.appendChild(style);
10110      injectedStyles.add(hash);
10111    }
10112    function registerDocument2(targetDocument) {
10113      const runtime = getRuntime2();
10114      runtime.documents.set(
10115        targetDocument,
10116        (runtime.documents.get(targetDocument) ?? 0) + 1
10117      );
10118      for (const [hash, css] of runtime.styles) {
10119        injectStyle2(targetDocument, hash, css);
10120      }
10121      return () => {
10122        const count = runtime.documents.get(targetDocument);
10123        if (count === void 0) {
10124          return;
10125        }
10126        if (count <= 1) {
10127          runtime.documents.delete(targetDocument);
10128          return;
10129        }
10130        runtime.documents.set(targetDocument, count - 1);
10131      };
10132    }
10133    function registerStyle2(hash, css) {
10134      const runtime = getRuntime2();
10135      runtime.styles.set(hash, css);
10136      for (const targetDocument of runtime.documents.keys()) {
10137        injectStyle2(targetDocument, hash, css);
10138      }
10139    }
10140    if (typeof process === "undefined" || true) {
10141      registerStyle2("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}");
10142    }
10143    var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
10144    var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
10145    function resolveOwnerDocument() {
10146      return typeof document === "undefined" ? null : document;
10147    }
10148    function isInWordPressEnvironment() {
10149      let topWp;
10150      try {
10151        topWp = window.top?.wp;
10152      } catch {
10153      }
10154      const wp = topWp ?? window.wp;
10155      return typeof wp?.components === "object" && wp.components !== null;
10156    }
10157    var cachedSlot = null;
10158    function ensureSlotIsAccessible(element) {
10159      element.setAttribute("aria-hidden", "false");
10160      return element;
10161    }
10162    function createSlot(ownerDocument2) {
10163      const element = ownerDocument2.createElement("div");
10164      element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
10165      if (wp_compat_overlay_slot_default.slot) {
10166        element.classList.add(wp_compat_overlay_slot_default.slot);
10167      }
10168      ownerDocument2.body.appendChild(element);
10169      return element;
10170    }
10171    function getWpCompatOverlaySlot() {
10172      if (typeof window === "undefined") {
10173        return void 0;
10174      }
10175      if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
10176        return void 0;
10177      }
10178      const ownerDocument2 = resolveOwnerDocument();
10179      if (!ownerDocument2 || !ownerDocument2.body) {
10180        return void 0;
10181      }
10182      if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
10183        return ensureSlotIsAccessible(cachedSlot);
10184      }
10185      const existing = ownerDocument2.querySelector(
10186        `[$WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
10187      );
10188      if (existing instanceof HTMLDivElement) {
10189        cachedSlot = ensureSlotIsAccessible(existing);
10190        return cachedSlot;
10191      }
10192      if (cachedSlot?.isConnected) {
10193        cachedSlot.remove();
10194      }
10195      cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2));
10196      return cachedSlot;
10197    }
10198  
10199    // packages/ui/build-module/tooltip/portal.mjs
10200    var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10201    var Portal = (0, import_element13.forwardRef)(
10202      function TooltipPortal3({ container, ...restProps }, ref) {
10203        return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10204          index_parts_exports.Portal,
10205          {
10206            container: container ?? getWpCompatOverlaySlot(),
10207            ...restProps,
10208            ref
10209          }
10210        );
10211      }
10212    );
10213  
10214    // packages/ui/build-module/tooltip/positioner.mjs
10215    var import_element14 = __toESM(require_element(), 1);
10216    var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10217    var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
10218    function getRuntime3() {
10219      const globalScope = globalThis;
10220      if (globalScope.__wpStyleRuntime) {
10221        return globalScope.__wpStyleRuntime;
10222      }
10223      globalScope.__wpStyleRuntime = {
10224        documents: /* @__PURE__ */ new Map(),
10225        styles: /* @__PURE__ */ new Map(),
10226        injectedStyles: /* @__PURE__ */ new WeakMap()
10227      };
10228      if (typeof document !== "undefined") {
10229        registerDocument3(document);
10230      }
10231      return globalScope.__wpStyleRuntime;
10232    }
10233    function documentContainsStyleHash3(targetDocument, hash) {
10234      if (!targetDocument.head) {
10235        return false;
10236      }
10237      for (const style of targetDocument.head.querySelectorAll(
10238        `style[$STYLE_HASH_ATTRIBUTE3}]`
10239      )) {
10240        if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
10241          return true;
10242        }
10243      }
10244      return false;
10245    }
10246    function injectStyle3(targetDocument, hash, css) {
10247      if (!targetDocument.head) {
10248        return;
10249      }
10250      const runtime = getRuntime3();
10251      let injectedStyles = runtime.injectedStyles.get(targetDocument);
10252      if (!injectedStyles) {
10253        injectedStyles = /* @__PURE__ */ new Set();
10254        runtime.injectedStyles.set(targetDocument, injectedStyles);
10255      }
10256      if (injectedStyles.has(hash)) {
10257        return;
10258      }
10259      if (documentContainsStyleHash3(targetDocument, hash)) {
10260        injectedStyles.add(hash);
10261        return;
10262      }
10263      const style = targetDocument.createElement("style");
10264      style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
10265      style.appendChild(targetDocument.createTextNode(css));
10266      targetDocument.head.appendChild(style);
10267      injectedStyles.add(hash);
10268    }
10269    function registerDocument3(targetDocument) {
10270      const runtime = getRuntime3();
10271      runtime.documents.set(
10272        targetDocument,
10273        (runtime.documents.get(targetDocument) ?? 0) + 1
10274      );
10275      for (const [hash, css] of runtime.styles) {
10276        injectStyle3(targetDocument, hash, css);
10277      }
10278      return () => {
10279        const count = runtime.documents.get(targetDocument);
10280        if (count === void 0) {
10281          return;
10282        }
10283        if (count <= 1) {
10284          runtime.documents.delete(targetDocument);
10285          return;
10286        }
10287        runtime.documents.set(targetDocument, count - 1);
10288      };
10289    }
10290    function registerStyle3(hash, css) {
10291      const runtime = getRuntime3();
10292      runtime.styles.set(hash, css);
10293      for (const targetDocument of runtime.documents.keys()) {
10294        injectStyle3(targetDocument, hash, css);
10295      }
10296    }
10297    if (typeof process === "undefined" || true) {
10298      registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10299    }
10300    var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10301    if (typeof process === "undefined" || true) {
10302      registerStyle3("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-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}}}}');
10303    }
10304    var style_default2 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
10305    var Positioner = (0, import_element14.forwardRef)(
10306      function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
10307        return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10308          index_parts_exports.Positioner,
10309          {
10310            ref,
10311            align,
10312            side,
10313            sideOffset,
10314            ...props,
10315            className: clsx_default(
10316              resets_default["box-sizing"],
10317              style_default2.positioner,
10318              className
10319            )
10320          }
10321        );
10322      }
10323    );
10324  
10325    // packages/ui/build-module/tooltip/popup.mjs
10326    var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10327    var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
10328    function getRuntime4() {
10329      const globalScope = globalThis;
10330      if (globalScope.__wpStyleRuntime) {
10331        return globalScope.__wpStyleRuntime;
10332      }
10333      globalScope.__wpStyleRuntime = {
10334        documents: /* @__PURE__ */ new Map(),
10335        styles: /* @__PURE__ */ new Map(),
10336        injectedStyles: /* @__PURE__ */ new WeakMap()
10337      };
10338      if (typeof document !== "undefined") {
10339        registerDocument4(document);
10340      }
10341      return globalScope.__wpStyleRuntime;
10342    }
10343    function documentContainsStyleHash4(targetDocument, hash) {
10344      if (!targetDocument.head) {
10345        return false;
10346      }
10347      for (const style of targetDocument.head.querySelectorAll(
10348        `style[$STYLE_HASH_ATTRIBUTE4}]`
10349      )) {
10350        if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
10351          return true;
10352        }
10353      }
10354      return false;
10355    }
10356    function injectStyle4(targetDocument, hash, css) {
10357      if (!targetDocument.head) {
10358        return;
10359      }
10360      const runtime = getRuntime4();
10361      let injectedStyles = runtime.injectedStyles.get(targetDocument);
10362      if (!injectedStyles) {
10363        injectedStyles = /* @__PURE__ */ new Set();
10364        runtime.injectedStyles.set(targetDocument, injectedStyles);
10365      }
10366      if (injectedStyles.has(hash)) {
10367        return;
10368      }
10369      if (documentContainsStyleHash4(targetDocument, hash)) {
10370        injectedStyles.add(hash);
10371        return;
10372      }
10373      const style = targetDocument.createElement("style");
10374      style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
10375      style.appendChild(targetDocument.createTextNode(css));
10376      targetDocument.head.appendChild(style);
10377      injectedStyles.add(hash);
10378    }
10379    function registerDocument4(targetDocument) {
10380      const runtime = getRuntime4();
10381      runtime.documents.set(
10382        targetDocument,
10383        (runtime.documents.get(targetDocument) ?? 0) + 1
10384      );
10385      for (const [hash, css] of runtime.styles) {
10386        injectStyle4(targetDocument, hash, css);
10387      }
10388      return () => {
10389        const count = runtime.documents.get(targetDocument);
10390        if (count === void 0) {
10391          return;
10392        }
10393        if (count <= 1) {
10394          runtime.documents.delete(targetDocument);
10395          return;
10396        }
10397        runtime.documents.set(targetDocument, count - 1);
10398      };
10399    }
10400    function registerStyle4(hash, css) {
10401      const runtime = getRuntime4();
10402      runtime.styles.set(hash, css);
10403      for (const targetDocument of runtime.documents.keys()) {
10404        injectStyle4(targetDocument, hash, css);
10405      }
10406    }
10407    if (typeof process === "undefined" || true) {
10408      registerStyle4("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-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}}}}');
10409    }
10410    var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
10411    var POPUP_COLOR = { background: "#1e1e1e" };
10412    var Popup = (0, import_element15.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
10413      const popupContent = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10414        index_parts_exports.Popup,
10415        {
10416          ref,
10417          className: clsx_default(style_default3.popup, className),
10418          ...props,
10419          children
10420        }
10421      ) });
10422      const positionedPopup = renderSlotWithChildren(
10423        positioner,
10424        /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Positioner, {}),
10425        popupContent
10426      );
10427      return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Portal, {}), positionedPopup);
10428    });
10429  
10430    // packages/ui/build-module/tooltip/trigger.mjs
10431    var import_element16 = __toESM(require_element(), 1);
10432    var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
10433    var Trigger = (0, import_element16.forwardRef)(
10434      function TooltipTrigger3(props, ref) {
10435        return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(index_parts_exports.Trigger, { ref, ...props });
10436      }
10437    );
10438  
10439    // packages/ui/build-module/tooltip/root.mjs
10440    var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
10441    function Root(props) {
10442      return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(index_parts_exports.Root, { ...props });
10443    }
10444  
10445    // packages/ui/build-module/tooltip/provider.mjs
10446    var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10447    function Provider({ ...props }) {
10448      return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(index_parts_exports.Provider, { ...props });
10449    }
10450  
10451    // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10452    var import_element17 = __toESM(require_element(), 1);
10453    var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
10454    function getRuntime5() {
10455      const globalScope = globalThis;
10456      if (globalScope.__wpStyleRuntime) {
10457        return globalScope.__wpStyleRuntime;
10458      }
10459      globalScope.__wpStyleRuntime = {
10460        documents: /* @__PURE__ */ new Map(),
10461        styles: /* @__PURE__ */ new Map(),
10462        injectedStyles: /* @__PURE__ */ new WeakMap()
10463      };
10464      if (typeof document !== "undefined") {
10465        registerDocument5(document);
10466      }
10467      return globalScope.__wpStyleRuntime;
10468    }
10469    function documentContainsStyleHash5(targetDocument, hash) {
10470      if (!targetDocument.head) {
10471        return false;
10472      }
10473      for (const style of targetDocument.head.querySelectorAll(
10474        `style[$STYLE_HASH_ATTRIBUTE5}]`
10475      )) {
10476        if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
10477          return true;
10478        }
10479      }
10480      return false;
10481    }
10482    function injectStyle5(targetDocument, hash, css) {
10483      if (!targetDocument.head) {
10484        return;
10485      }
10486      const runtime = getRuntime5();
10487      let injectedStyles = runtime.injectedStyles.get(targetDocument);
10488      if (!injectedStyles) {
10489        injectedStyles = /* @__PURE__ */ new Set();
10490        runtime.injectedStyles.set(targetDocument, injectedStyles);
10491      }
10492      if (injectedStyles.has(hash)) {
10493        return;
10494      }
10495      if (documentContainsStyleHash5(targetDocument, hash)) {
10496        injectedStyles.add(hash);
10497        return;
10498      }
10499      const style = targetDocument.createElement("style");
10500      style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
10501      style.appendChild(targetDocument.createTextNode(css));
10502      targetDocument.head.appendChild(style);
10503      injectedStyles.add(hash);
10504    }
10505    function registerDocument5(targetDocument) {
10506      const runtime = getRuntime5();
10507      runtime.documents.set(
10508        targetDocument,
10509        (runtime.documents.get(targetDocument) ?? 0) + 1
10510      );
10511      for (const [hash, css] of runtime.styles) {
10512        injectStyle5(targetDocument, hash, css);
10513      }
10514      return () => {
10515        const count = runtime.documents.get(targetDocument);
10516        if (count === void 0) {
10517          return;
10518        }
10519        if (count <= 1) {
10520          runtime.documents.delete(targetDocument);
10521          return;
10522        }
10523        runtime.documents.set(targetDocument, count - 1);
10524      };
10525    }
10526    function registerStyle5(hash, css) {
10527      const runtime = getRuntime5();
10528      runtime.styles.set(hash, css);
10529      for (const targetDocument of runtime.documents.keys()) {
10530        injectStyle5(targetDocument, hash, css);
10531      }
10532    }
10533    if (typeof process === "undefined" || true) {
10534      registerStyle5("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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}}}");
10535    }
10536    var style_default4 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10537    var VisuallyHidden = (0, import_element17.forwardRef)(
10538      function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10539        const element = useRender({
10540          render: render4,
10541          ref,
10542          props: mergeProps(
10543            { className: style_default4["visually-hidden"] },
10544            restProps,
10545            {
10546              // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10547              "data-visually-hidden": ""
10548            }
10549          )
10550        });
10551        return element;
10552      }
10553    );
10554  
10555    // packages/ui/build-module/link/link.mjs
10556    var import_element18 = __toESM(require_element(), 1);
10557    var import_i18n7 = __toESM(require_i18n(), 1);
10558    var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10559    var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
10560    function getRuntime6() {
10561      const globalScope = globalThis;
10562      if (globalScope.__wpStyleRuntime) {
10563        return globalScope.__wpStyleRuntime;
10564      }
10565      globalScope.__wpStyleRuntime = {
10566        documents: /* @__PURE__ */ new Map(),
10567        styles: /* @__PURE__ */ new Map(),
10568        injectedStyles: /* @__PURE__ */ new WeakMap()
10569      };
10570      if (typeof document !== "undefined") {
10571        registerDocument6(document);
10572      }
10573      return globalScope.__wpStyleRuntime;
10574    }
10575    function documentContainsStyleHash6(targetDocument, hash) {
10576      if (!targetDocument.head) {
10577        return false;
10578      }
10579      for (const style of targetDocument.head.querySelectorAll(
10580        `style[$STYLE_HASH_ATTRIBUTE6}]`
10581      )) {
10582        if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
10583          return true;
10584        }
10585      }
10586      return false;
10587    }
10588    function injectStyle6(targetDocument, hash, css) {
10589      if (!targetDocument.head) {
10590        return;
10591      }
10592      const runtime = getRuntime6();
10593      let injectedStyles = runtime.injectedStyles.get(targetDocument);
10594      if (!injectedStyles) {
10595        injectedStyles = /* @__PURE__ */ new Set();
10596        runtime.injectedStyles.set(targetDocument, injectedStyles);
10597      }
10598      if (injectedStyles.has(hash)) {
10599        return;
10600      }
10601      if (documentContainsStyleHash6(targetDocument, hash)) {
10602        injectedStyles.add(hash);
10603        return;
10604      }
10605      const style = targetDocument.createElement("style");
10606      style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
10607      style.appendChild(targetDocument.createTextNode(css));
10608      targetDocument.head.appendChild(style);
10609      injectedStyles.add(hash);
10610    }
10611    function registerDocument6(targetDocument) {
10612      const runtime = getRuntime6();
10613      runtime.documents.set(
10614        targetDocument,
10615        (runtime.documents.get(targetDocument) ?? 0) + 1
10616      );
10617      for (const [hash, css] of runtime.styles) {
10618        injectStyle6(targetDocument, hash, css);
10619      }
10620      return () => {
10621        const count = runtime.documents.get(targetDocument);
10622        if (count === void 0) {
10623          return;
10624        }
10625        if (count <= 1) {
10626          runtime.documents.delete(targetDocument);
10627          return;
10628        }
10629        runtime.documents.set(targetDocument, count - 1);
10630      };
10631    }
10632    function registerStyle6(hash, css) {
10633      const runtime = getRuntime6();
10634      runtime.styles.set(hash, css);
10635      for (const targetDocument of runtime.documents.keys()) {
10636        injectStyle6(targetDocument, hash, css);
10637      }
10638    }
10639    if (typeof process === "undefined" || true) {
10640      registerStyle6("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10641    }
10642    var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10643    if (typeof process === "undefined" || true) {
10644      registerStyle6("da99a163ac", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus:focus,.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,: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,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,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,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._970d04df7376df67__outset-ring--focus-within-except-active:focus-within,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus{outline:none}._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active){@include mixins.focus-ring()}}}");
10645    }
10646    var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active" };
10647    if (typeof process === "undefined" || true) {
10648      registerStyle6("e8e6a9be37", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-default,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}}');
10649    }
10650    var style_default5 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
10651    if (typeof process === "undefined" || true) {
10652      registerStyle6("af6d9984a6", "._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,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-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,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-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 transparent)}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-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));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 transparent);transition:var(--_gcd-a-transition,none)}");
10653    }
10654    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" };
10655    var Link = (0, import_element18.forwardRef)(function Link2({
10656      children,
10657      variant = "default",
10658      tone = "brand",
10659      openInNewTab = false,
10660      render: render4,
10661      className,
10662      ...props
10663    }, ref) {
10664      const element = useRender({
10665        render: render4,
10666        defaultTagName: "a",
10667        ref,
10668        props: mergeProps(props, {
10669          className: clsx_default(
10670            global_css_defense_default.a,
10671            resets_default2["box-sizing"],
10672            focus_default["outset-ring--focus-except-active"],
10673            variant !== "unstyled" && style_default5.link,
10674            variant !== "unstyled" && style_default5[`is-$tone}`],
10675            variant === "unstyled" && style_default5["is-unstyled"],
10676            className
10677          ),
10678          target: openInNewTab ? "_blank" : void 0,
10679          children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
10680            children,
10681            openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10682              "span",
10683              {
10684                className: style_default5["link-icon"],
10685                role: "img",
10686                "aria-label": (
10687                  /* translators: accessibility text appended to link text */
10688                  (0, import_i18n7.__)("(opens in a new tab)")
10689                )
10690              }
10691            )
10692          ] })
10693        })
10694      });
10695      return element;
10696    });
10697  
10698    // packages/dataviews/build-module/components/dataviews-context/index.mjs
10699    var import_element19 = __toESM(require_element(), 1);
10700  
10701    // packages/dataviews/build-module/constants.mjs
10702    var import_i18n8 = __toESM(require_i18n(), 1);
10703    var OPERATOR_IS_ANY = "isAny";
10704    var OPERATOR_IS_NONE = "isNone";
10705    var OPERATOR_IS_ALL = "isAll";
10706    var OPERATOR_IS_NOT_ALL = "isNotAll";
10707    var OPERATOR_BETWEEN = "between";
10708    var OPERATOR_IN_THE_PAST = "inThePast";
10709    var OPERATOR_OVER = "over";
10710    var OPERATOR_IS = "is";
10711    var OPERATOR_IS_NOT = "isNot";
10712    var OPERATOR_LESS_THAN = "lessThan";
10713    var OPERATOR_GREATER_THAN = "greaterThan";
10714    var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10715    var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10716    var OPERATOR_BEFORE = "before";
10717    var OPERATOR_AFTER = "after";
10718    var OPERATOR_BEFORE_INC = "beforeInc";
10719    var OPERATOR_AFTER_INC = "afterInc";
10720    var OPERATOR_CONTAINS = "contains";
10721    var OPERATOR_NOT_CONTAINS = "notContains";
10722    var OPERATOR_STARTS_WITH = "startsWith";
10723    var OPERATOR_ON = "on";
10724    var OPERATOR_NOT_ON = "notOn";
10725    var SORTING_DIRECTIONS = ["asc", "desc"];
10726    var sortArrows = { asc: "\u2191", desc: "\u2193" };
10727    var sortValues = { asc: "ascending", desc: "descending" };
10728    var sortLabels = {
10729      asc: (0, import_i18n8.__)("Sort ascending"),
10730      desc: (0, import_i18n8.__)("Sort descending")
10731    };
10732    var sortIcons = {
10733      asc: arrow_up_default,
10734      desc: arrow_down_default
10735    };
10736    var LAYOUT_TABLE = "table";
10737    var LAYOUT_GRID = "grid";
10738    var LAYOUT_LIST = "list";
10739    var LAYOUT_ACTIVITY = "activity";
10740    var LAYOUT_PICKER_GRID = "pickerGrid";
10741    var LAYOUT_PICKER_TABLE = "pickerTable";
10742    var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10743  
10744    // packages/dataviews/build-module/components/dataviews-context/index.mjs
10745    var DataViewsContext = (0, import_element19.createContext)({
10746      view: { type: LAYOUT_TABLE },
10747      onChangeView: () => {
10748      },
10749      fields: [],
10750      data: [],
10751      paginationInfo: {
10752        totalItems: 0,
10753        totalPages: 0
10754      },
10755      selection: [],
10756      onChangeSelection: () => {
10757      },
10758      setOpenedFilter: () => {
10759      },
10760      openedFilter: null,
10761      getItemId: (item) => item.id,
10762      isItemClickable: () => true,
10763      renderItemLink: void 0,
10764      containerWidth: 0,
10765      containerRef: (0, import_element19.createRef)(),
10766      resizeObserverRef: () => {
10767      },
10768      defaultLayouts: { list: {}, grid: {}, table: {} },
10769      filters: [],
10770      isShowingFilter: false,
10771      setIsShowingFilter: () => {
10772      },
10773      hasInitiallyLoaded: false,
10774      config: {
10775        perPageSizes: []
10776      },
10777      intersectionObserver: null
10778    });
10779    DataViewsContext.displayName = "DataViewsContext";
10780    var dataviews_context_default = DataViewsContext;
10781  
10782    // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10783    var import_i18n29 = __toESM(require_i18n(), 1);
10784  
10785    // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10786    var import_i18n16 = __toESM(require_i18n(), 1);
10787    var import_components6 = __toESM(require_components(), 1);
10788    var import_element28 = __toESM(require_element(), 1);
10789    var import_keycodes2 = __toESM(require_keycodes(), 1);
10790  
10791    // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10792    var import_components = __toESM(require_components(), 1);
10793    var import_i18n9 = __toESM(require_i18n(), 1);
10794    var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10795    var SELECTION_CHECKBOX_CLASS = "dataviews-selection-checkbox";
10796    function DataViewsSelectionCheckbox({
10797      selection,
10798      onChangeSelection,
10799      item,
10800      getItemId,
10801      titleField,
10802      disabled: disabled2,
10803      ...extraProps
10804    }) {
10805      const id = getItemId(item);
10806      const isInSelectionArray = selection.includes(id);
10807      const checked = !disabled2 && isInSelectionArray;
10808      const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n9.__)("(no title)");
10809      return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10810        import_components.CheckboxControl,
10811        {
10812          className: SELECTION_CHECKBOX_CLASS,
10813          "aria-label": selectionLabel,
10814          "aria-disabled": disabled2,
10815          checked,
10816          onChange: () => {
10817            if (disabled2) {
10818              return;
10819            }
10820            onChangeSelection(
10821              isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10822            );
10823          },
10824          ...extraProps
10825        }
10826      );
10827    }
10828  
10829    // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10830    var import_components2 = __toESM(require_components(), 1);
10831    var import_i18n10 = __toESM(require_i18n(), 1);
10832    var import_element20 = __toESM(require_element(), 1);
10833    var import_data2 = __toESM(require_data(), 1);
10834    var import_compose = __toESM(require_compose(), 1);
10835  
10836    // packages/dataviews/build-module/lock-unlock.mjs
10837    var import_private_apis2 = __toESM(require_private_apis(), 1);
10838    var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10839      "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10840      "@wordpress/dataviews"
10841    );
10842  
10843    // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10844    var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10845    var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10846    function ButtonTrigger({
10847      action,
10848      onClick,
10849      items,
10850      variant
10851    }) {
10852      const label = typeof action.label === "string" ? action.label : action.label(items);
10853      return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10854        import_components2.Button,
10855        {
10856          disabled: !!action.disabled,
10857          accessibleWhenDisabled: true,
10858          size: "compact",
10859          variant,
10860          onClick,
10861          children: label
10862        }
10863      );
10864    }
10865    function MenuItemTrigger({
10866      action,
10867      onClick,
10868      items
10869    }) {
10870      const label = typeof action.label === "string" ? action.label : action.label(items);
10871      return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.ItemLabel, { children: label }) });
10872    }
10873    function ActionModal({
10874      action,
10875      items,
10876      closeModal
10877    }) {
10878      const label = typeof action.label === "string" ? action.label : action.label(items);
10879      const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10880      return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10881        import_components2.Modal,
10882        {
10883          title: modalHeader || label,
10884          __experimentalHideHeader: !!action.hideModalHeader,
10885          onRequestClose: closeModal,
10886          focusOnMount: action.modalFocusOnMount ?? true,
10887          size: action.modalSize || "medium",
10888          overlayClassName: `dataviews-action-modal dataviews-action-modal__$kebabCase(
10889            action.id
10890          )}`,
10891          children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(action.RenderModal, { items, closeModal })
10892        }
10893      );
10894    }
10895    function ActionsMenuGroup({
10896      actions,
10897      item,
10898      registry,
10899      setActiveModalAction
10900    }) {
10901      const { primaryActions, regularActions } = (0, import_element20.useMemo)(() => {
10902        return actions.reduce(
10903          (acc, action) => {
10904            (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10905            return acc;
10906          },
10907          {
10908            primaryActions: [],
10909            regularActions: []
10910          }
10911        );
10912      }, [actions]);
10913      const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10914        MenuItemTrigger,
10915        {
10916          action,
10917          onClick: () => {
10918            if ("RenderModal" in action) {
10919              setActiveModalAction(action);
10920              return;
10921            }
10922            action.callback([item], { registry });
10923          },
10924          items: [item]
10925        },
10926        action.id
10927      ));
10928      return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu.Group, { children: [
10929        renderActionGroup(primaryActions),
10930        renderActionGroup(regularActions)
10931      ] });
10932    }
10933    function ItemActions({
10934      item,
10935      actions,
10936      isCompact
10937    }) {
10938      const registry = (0, import_data2.useRegistry)();
10939      const { primaryActions, eligibleActions } = (0, import_element20.useMemo)(() => {
10940        const _eligibleActions = actions.filter(
10941          (action) => !action.isEligible || action.isEligible(item)
10942        );
10943        const _primaryActions = _eligibleActions.filter(
10944          (action) => action.isPrimary
10945        );
10946        return {
10947          primaryActions: _primaryActions,
10948          eligibleActions: _eligibleActions
10949        };
10950      }, [actions, item]);
10951      const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10952      if (isCompact) {
10953        return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10954          CompactItemActions,
10955          {
10956            item,
10957            actions: eligibleActions,
10958            isSmall: true,
10959            registry
10960          }
10961        );
10962      }
10963      return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10964        Stack,
10965        {
10966          direction: "row",
10967          justify: "flex-end",
10968          className: "dataviews-item-actions",
10969          style: {
10970            flexShrink: 0,
10971            width: "auto"
10972          },
10973          children: [
10974            /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10975              PrimaryActions,
10976              {
10977                item,
10978                actions: primaryActions,
10979                registry
10980              }
10981            ),
10982            (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10983            // there if there are any actions at all.
10984            isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10985              CompactItemActions,
10986              {
10987                item,
10988                actions: eligibleActions,
10989                registry
10990              }
10991            )
10992          ]
10993        }
10994      );
10995    }
10996    function CompactItemActions({
10997      item,
10998      actions,
10999      isSmall,
11000      registry
11001    }) {
11002      const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(
11003        null
11004      );
11005      return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
11006        /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu, { placement: "bottom-end", children: [
11007          /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11008            Menu.TriggerButton,
11009            {
11010              render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11011                import_components2.Button,
11012                {
11013                  size: isSmall ? "small" : "compact",
11014                  icon: more_vertical_default,
11015                  label: (0, import_i18n10.__)("Actions"),
11016                  accessibleWhenDisabled: true,
11017                  disabled: !actions.length,
11018                  className: "dataviews-all-actions-button"
11019                }
11020              )
11021            }
11022          ),
11023          /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11024            ActionsMenuGroup,
11025            {
11026              actions,
11027              item,
11028              registry,
11029              setActiveModalAction
11030            }
11031          ) })
11032        ] }),
11033        !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11034          ActionModal,
11035          {
11036            action: activeModalAction,
11037            items: [item],
11038            closeModal: () => setActiveModalAction(null)
11039          }
11040        )
11041      ] });
11042    }
11043    function PrimaryActions({
11044      item,
11045      actions,
11046      registry,
11047      buttonVariant
11048    }) {
11049      const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(null);
11050      const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
11051      if (isMobileViewport) {
11052        return null;
11053      }
11054      if (!Array.isArray(actions) || actions.length === 0) {
11055        return null;
11056      }
11057      return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
11058        actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11059          ButtonTrigger,
11060          {
11061            action,
11062            onClick: () => {
11063              if ("RenderModal" in action) {
11064                setActiveModalAction(action);
11065                return;
11066              }
11067              action.callback([item], { registry });
11068            },
11069            items: [item],
11070            variant: buttonVariant
11071          },
11072          action.id
11073        )),
11074        !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11075          ActionModal,
11076          {
11077            action: activeModalAction,
11078            items: [item],
11079            closeModal: () => setActiveModalAction(null)
11080          }
11081        )
11082      ] });
11083    }
11084  
11085    // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
11086    var import_components3 = __toESM(require_components(), 1);
11087    var import_i18n12 = __toESM(require_i18n(), 1);
11088    var import_element21 = __toESM(require_element(), 1);
11089    var import_data3 = __toESM(require_data(), 1);
11090    var import_compose2 = __toESM(require_compose(), 1);
11091  
11092    // packages/dataviews/build-module/utils/get-footer-message.mjs
11093    var import_i18n11 = __toESM(require_i18n(), 1);
11094    function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
11095      if (selectionCount > 0) {
11096        return (0, import_i18n11.sprintf)(
11097          /* translators: %d: number of items. */
11098          (0, import_i18n11._n)("%d Item selected", "%d Items selected", selectionCount),
11099          selectionCount
11100        );
11101      }
11102      if (onlyTotalCount || totalItems <= itemsCount) {
11103        return (0, import_i18n11.sprintf)(
11104          /* translators: %d: number of items. */
11105          (0, import_i18n11._n)("%d Item", "%d Items", totalItems),
11106          totalItems
11107        );
11108      }
11109      return (0, import_i18n11.sprintf)(
11110        /* translators: %1$d: number of items. %2$d: total number of items. */
11111        (0, import_i18n11._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
11112        itemsCount,
11113        totalItems
11114      );
11115    }
11116  
11117    // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
11118    var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11119    function hasAPossibleBulkAction(actions, item) {
11120      return actions.some(
11121        (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
11122      );
11123    }
11124    function useHasAPossibleBulkAction(actions, item) {
11125      return (0, import_element21.useMemo)(
11126        () => hasAPossibleBulkAction(actions, item),
11127        [actions, item]
11128      );
11129    }
11130    function useSomeItemHasAPossibleBulkAction(actions, data) {
11131      return (0, import_element21.useMemo)(
11132        () => data.some((item) => hasAPossibleBulkAction(actions, item)),
11133        [actions, data]
11134      );
11135    }
11136    function BulkSelectionCheckbox({
11137      selection,
11138      onChangeSelection,
11139      data,
11140      actions,
11141      getItemId,
11142      disableSelectAll = false
11143    }) {
11144      const selectableItems = (0, import_element21.useMemo)(() => {
11145        return data.filter((item) => {
11146          return actions.some(
11147            (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
11148          );
11149        });
11150      }, [data, actions]);
11151      const selectedItems = data.filter(
11152        (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11153      );
11154      const hasSelection = selection.length > 0;
11155      const areAllSelected = selectedItems.length === selectableItems.length;
11156      if (disableSelectAll) {
11157        return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11158          import_components3.CheckboxControl,
11159          {
11160            className: "dataviews-view-table-selection-checkbox",
11161            checked: hasSelection,
11162            disabled: !hasSelection,
11163            onChange: () => {
11164              onChangeSelection([]);
11165            },
11166            "aria-label": (0, import_i18n12.__)("Deselect all")
11167          }
11168        );
11169      }
11170      return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11171        import_components3.CheckboxControl,
11172        {
11173          className: "dataviews-view-table-selection-checkbox",
11174          checked: areAllSelected,
11175          indeterminate: !areAllSelected && !!selectedItems.length,
11176          onChange: () => {
11177            if (areAllSelected) {
11178              onChangeSelection([]);
11179            } else {
11180              onChangeSelection(
11181                selectableItems.map((item) => getItemId(item))
11182              );
11183            }
11184          },
11185          "aria-label": areAllSelected ? (0, import_i18n12.__)("Deselect all") : (0, import_i18n12.__)("Select all")
11186        }
11187      );
11188    }
11189  
11190    // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11191    var import_i18n13 = __toESM(require_i18n(), 1);
11192    var import_components4 = __toESM(require_components(), 1);
11193    var import_element22 = __toESM(require_element(), 1);
11194  
11195    // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11196    function getHideableFields(view, fields) {
11197      const togglableFields = [
11198        view?.titleField,
11199        view?.mediaField,
11200        view?.descriptionField
11201      ].filter(Boolean);
11202      return fields.filter(
11203        (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11204      );
11205    }
11206  
11207    // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11208    var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11209    var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11210    function WithMenuSeparators({ children }) {
11211      return import_element22.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_element22.Fragment, { children: [
11212        i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Separator, {}),
11213        child
11214      ] }, i2));
11215    }
11216    var _HeaderMenu = (0, import_element22.forwardRef)(function HeaderMenu({
11217      fieldId,
11218      view,
11219      fields,
11220      onChangeView,
11221      onHide,
11222      setOpenedFilter,
11223      canMove = true,
11224      canInsertLeft = true,
11225      canInsertRight = true
11226    }, ref) {
11227      const visibleFieldIds = view.fields ?? [];
11228      const index2 = visibleFieldIds?.indexOf(fieldId);
11229      const isSorted = view.sort?.field === fieldId;
11230      let isHidable = false;
11231      let isSortable = false;
11232      let canAddFilter = false;
11233      let operators = [];
11234      const field = fields.find((f2) => f2.id === fieldId);
11235      const { setIsShowingFilter } = (0, import_element22.useContext)(dataviews_context_default);
11236      if (!field) {
11237        return null;
11238      }
11239      isHidable = field.enableHiding !== false;
11240      isSortable = field.enableSorting !== false;
11241      const header = field.header;
11242      operators = !!field.filterBy && field.filterBy?.operators || [];
11243      canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11244      if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11245        return header;
11246      }
11247      const hiddenFields = getHideableFields(view, fields).filter(
11248        (f2) => !visibleFieldIds.includes(f2.id)
11249      );
11250      const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11251      const isRtl = (0, import_i18n13.isRTL)();
11252      return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11253        /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11254          Menu2.TriggerButton,
11255          {
11256            render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11257              import_components4.Button,
11258              {
11259                size: "compact",
11260                className: "dataviews-view-table-header-button",
11261                ref,
11262                variant: "tertiary"
11263              }
11264            ),
11265            children: [
11266              header,
11267              view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11268            ]
11269          }
11270        ),
11271        /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(WithMenuSeparators, { children: [
11272          isSortable && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11273            (direction) => {
11274              const isChecked = view.sort && isSorted && view.sort.direction === direction;
11275              const value = `$fieldId}-$direction}`;
11276              return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11277                Menu2.RadioItem,
11278                {
11279                  name: "view-table-sorting",
11280                  value,
11281                  checked: isChecked,
11282                  onChange: () => {
11283                    onChangeView({
11284                      ...view,
11285                      sort: {
11286                        field: fieldId,
11287                        direction
11288                      },
11289                      showLevels: false
11290                    });
11291                  },
11292                  children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11293                },
11294                value
11295              );
11296            }
11297          ) }),
11298          canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11299            Menu2.Item,
11300            {
11301              prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: funnel_default }),
11302              onClick: () => {
11303                setOpenedFilter(fieldId);
11304                setIsShowingFilter(true);
11305                onChangeView({
11306                  ...view,
11307                  page: 1,
11308                  filters: [
11309                    ...view.filters || [],
11310                    {
11311                      field: fieldId,
11312                      value: void 0,
11313                      operator: operators[0]
11314                    }
11315                  ]
11316                });
11317              },
11318              children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Add filter") })
11319            }
11320          ) }),
11321          (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2.Group, { children: [
11322            canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11323              Menu2.Item,
11324              {
11325                prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11326                disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11327                onClick: () => {
11328                  const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11329                  const newFields = [
11330                    ...visibleFieldIds
11331                  ];
11332                  newFields.splice(index2, 1);
11333                  newFields.splice(
11334                    targetIndex,
11335                    0,
11336                    fieldId
11337                  );
11338                  onChangeView({
11339                    ...view,
11340                    fields: newFields
11341                  });
11342                },
11343                children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Move left") })
11344              }
11345            ),
11346            canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11347              Menu2.Item,
11348              {
11349                prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11350                disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11351                onClick: () => {
11352                  const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11353                  const newFields = [
11354                    ...visibleFieldIds
11355                  ];
11356                  newFields.splice(index2, 1);
11357                  newFields.splice(
11358                    targetIndex,
11359                    0,
11360                    fieldId
11361                  );
11362                  onChangeView({
11363                    ...view,
11364                    fields: newFields
11365                  });
11366                },
11367                children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Move right") })
11368              }
11369            ),
11370            canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11371              /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Insert left") }) }),
11372              /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11373                const insertIndex = isRtl ? index2 + 1 : index2;
11374                return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11375                  Menu2.Item,
11376                  {
11377                    onClick: () => {
11378                      onChangeView({
11379                        ...view,
11380                        fields: [
11381                          ...visibleFieldIds.slice(
11382                            0,
11383                            insertIndex
11384                          ),
11385                          hiddenField.id,
11386                          ...visibleFieldIds.slice(
11387                            insertIndex
11388                          )
11389                        ]
11390                      });
11391                    },
11392                    children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11393                  },
11394                  hiddenField.id
11395                );
11396              }) })
11397            ] }),
11398            canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11399              /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Insert right") }) }),
11400              /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11401                const insertIndex = isRtl ? index2 : index2 + 1;
11402                return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11403                  Menu2.Item,
11404                  {
11405                    onClick: () => {
11406                      onChangeView({
11407                        ...view,
11408                        fields: [
11409                          ...visibleFieldIds.slice(
11410                            0,
11411                            insertIndex
11412                          ),
11413                          hiddenField.id,
11414                          ...visibleFieldIds.slice(
11415                            insertIndex
11416                          )
11417                        ]
11418                      });
11419                    },
11420                    children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11421                  },
11422                  hiddenField.id
11423                );
11424              }) })
11425            ] }),
11426            isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11427              Menu2.Item,
11428              {
11429                prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: unseen_default }),
11430                onClick: () => {
11431                  onHide(field);
11432                  onChangeView({
11433                    ...view,
11434                    fields: visibleFieldIds.filter(
11435                      (id) => id !== fieldId
11436                    )
11437                  });
11438                },
11439                children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Hide column") })
11440              }
11441            )
11442          ] })
11443        ] }) })
11444      ] });
11445    });
11446    var ColumnHeaderMenu = _HeaderMenu;
11447    var column_header_menu_default = ColumnHeaderMenu;
11448  
11449    // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11450    var import_element23 = __toESM(require_element(), 1);
11451    var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11452    function getClickableItemProps({
11453      item,
11454      isItemClickable: isItemClickable2,
11455      onClickItem,
11456      className
11457    }) {
11458      if (!isItemClickable2(item) || !onClickItem) {
11459        return { className };
11460      }
11461      return {
11462        className: className ? `$className} $className}--clickable` : void 0,
11463        role: "button",
11464        tabIndex: 0,
11465        onClick: (event) => {
11466          event.stopPropagation();
11467          onClickItem(item);
11468        },
11469        onKeyDown: (event) => {
11470          if (event.key === "Enter" || event.key === "" || event.key === " ") {
11471            event.stopPropagation();
11472            onClickItem(item);
11473          }
11474        }
11475      };
11476    }
11477    function ItemClickWrapper({
11478      item,
11479      isItemClickable: isItemClickable2,
11480      onClickItem,
11481      renderItemLink,
11482      className,
11483      children,
11484      ...extraProps
11485    }) {
11486      if (!isItemClickable2(item)) {
11487        return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className, ...extraProps, children });
11488      }
11489      if (renderItemLink) {
11490        const renderedElement = renderItemLink({
11491          item,
11492          className: `$className} $className}--clickable`,
11493          ...extraProps,
11494          children
11495        });
11496        return (0, import_element23.cloneElement)(renderedElement, {
11497          onClick: (event) => {
11498            event.stopPropagation();
11499            if (renderedElement.props.onClick) {
11500              renderedElement.props.onClick(event);
11501            }
11502          },
11503          onKeyDown: (event) => {
11504            if (event.key === "Enter" || event.key === "" || event.key === " ") {
11505              event.stopPropagation();
11506              if (renderedElement.props.onKeyDown) {
11507                renderedElement.props.onKeyDown(event);
11508              }
11509            }
11510          }
11511        });
11512      }
11513      const clickProps = getClickableItemProps({
11514        item,
11515        isItemClickable: isItemClickable2,
11516        onClickItem,
11517        className
11518      });
11519      return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...clickProps, ...extraProps, children });
11520    }
11521  
11522    // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11523    var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11524    function ColumnPrimary({
11525      item,
11526      level,
11527      titleField,
11528      mediaField,
11529      descriptionField: descriptionField2,
11530      onClickItem,
11531      renderItemLink,
11532      isItemClickable: isItemClickable2
11533    }) {
11534      return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11535        mediaField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11536          ItemClickWrapper,
11537          {
11538            item,
11539            isItemClickable: isItemClickable2,
11540            onClickItem,
11541            renderItemLink,
11542            className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11543            "aria-label": isItemClickable2(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11544            children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11545              mediaField.render,
11546              {
11547                item,
11548                field: mediaField,
11549                config: { sizes: "32px" }
11550              }
11551            )
11552          }
11553        ),
11554        /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11555          Stack,
11556          {
11557            direction: "column",
11558            align: "flex-start",
11559            className: "dataviews-view-table__primary-column-content",
11560            children: [
11561              titleField && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11562                ItemClickWrapper,
11563                {
11564                  item,
11565                  isItemClickable: isItemClickable2,
11566                  onClickItem,
11567                  renderItemLink,
11568                  className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11569                  children: [
11570                    level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "dataviews-view-table__level", children: [
11571                      Array(level).fill("\u2014").join(" "),
11572                      "\xA0"
11573                    ] }),
11574                    /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField })
11575                  ]
11576                }
11577              ),
11578              descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11579                descriptionField2.render,
11580                {
11581                  item,
11582                  field: descriptionField2
11583                }
11584              )
11585            ]
11586          }
11587        )
11588      ] });
11589    }
11590    var column_primary_default = ColumnPrimary;
11591  
11592    // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11593    var import_element24 = __toESM(require_element(), 1);
11594    var import_i18n14 = __toESM(require_i18n(), 1);
11595    var isScrolledToEnd = (element) => {
11596      if ((0, import_i18n14.isRTL)()) {
11597        const scrollLeft = Math.abs(element.scrollLeft);
11598        return scrollLeft <= 1;
11599      }
11600      return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11601    };
11602    function useScrollState({
11603      scrollContainerRef,
11604      enabledHorizontal = false
11605    }) {
11606      const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element24.useState)(false);
11607      const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element24.useState)(false);
11608      const handleScroll = (0, import_element24.useCallback)(() => {
11609        const scrollContainer = scrollContainerRef.current;
11610        if (!scrollContainer) {
11611          return;
11612        }
11613        if (enabledHorizontal) {
11614          setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11615        }
11616        setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11617      }, [scrollContainerRef, enabledHorizontal]);
11618      (0, import_element24.useEffect)(() => {
11619        if (typeof window === "undefined" || !scrollContainerRef.current) {
11620          return () => {
11621          };
11622        }
11623        const scrollContainer = scrollContainerRef.current;
11624        handleScroll();
11625        scrollContainer.addEventListener("scroll", handleScroll);
11626        window.addEventListener("resize", handleScroll);
11627        return () => {
11628          scrollContainer.removeEventListener("scroll", handleScroll);
11629          window.removeEventListener("resize", handleScroll);
11630        };
11631      }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11632      return { isHorizontalScrollEnd, isVerticallyScrolled };
11633    }
11634  
11635    // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11636    function getDataByGroup(data, groupByField) {
11637      return data.reduce((groups, item) => {
11638        const groupName = groupByField.getValue({ item });
11639        if (!groups.has(groupName)) {
11640          groups.set(groupName, []);
11641        }
11642        groups.get(groupName)?.push(item);
11643        return groups;
11644      }, /* @__PURE__ */ new Map());
11645    }
11646  
11647    // packages/dataviews/build-module/components/dataviews-layouts/utils/use-selection-props.mjs
11648    var import_element25 = __toESM(require_element(), 1);
11649    var import_keycodes = __toESM(require_keycodes(), 1);
11650    function getRange(orderedIds, fromIndex, toIndex) {
11651      return orderedIds.slice(
11652        Math.min(fromIndex, toIndex),
11653        Math.max(fromIndex, toIndex) + 1
11654      );
11655    }
11656    function getRangeSelection({
11657      anchorId,
11658      targetId,
11659      lastTargetId,
11660      orderedIds,
11661      selection
11662    }) {
11663      const targetIndex = orderedIds.indexOf(targetId);
11664      if (targetIndex === -1) {
11665        return selection;
11666      }
11667      const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId);
11668      const hasAnchor = anchorIndex !== -1;
11669      const rangeStart = hasAnchor ? anchorIndex : targetIndex;
11670      const lastTargetIndex = hasAnchor && lastTargetId !== null ? orderedIds.indexOf(lastTargetId) : -1;
11671      const lastRange = lastTargetIndex === -1 ? [] : getRange(orderedIds, rangeStart, lastTargetIndex);
11672      const base = selection.filter((id) => !lastRange.includes(id));
11673      return [
11674        .../* @__PURE__ */ new Set([
11675          ...base,
11676          ...getRange(orderedIds, rangeStart, targetIndex)
11677        ])
11678      ];
11679    }
11680    function getClosestSelectedId({
11681      targetId,
11682      orderedIds,
11683      selection
11684    }) {
11685      const targetIndex = orderedIds.indexOf(targetId);
11686      if (targetIndex === -1) {
11687        return null;
11688      }
11689      const selectedIds = new Set(selection);
11690      let closestId = null;
11691      let closestDistance = Infinity;
11692      orderedIds.forEach((id, index2) => {
11693        if (!selectedIds.has(id)) {
11694          return;
11695        }
11696        const distance = Math.abs(index2 - targetIndex);
11697        if (distance < closestDistance) {
11698          closestDistance = distance;
11699          closestId = id;
11700        }
11701      });
11702      return closestId;
11703    }
11704    function useSelectionProps({
11705      data,
11706      actions,
11707      getItemId,
11708      selection,
11709      onChangeSelection
11710    }) {
11711      const gestureRef = (0, import_element25.useRef)(null);
11712      const isTouchDeviceRef = (0, import_element25.useRef)(false);
11713      (0, import_element25.useEffect)(() => {
11714        const markTouchDevice = () => {
11715          isTouchDeviceRef.current = true;
11716        };
11717        document.addEventListener("touchstart", markTouchDevice, {
11718          once: true
11719        });
11720        return () => document.removeEventListener("touchstart", markTouchDevice);
11721      }, []);
11722      const selectableIds = data.filter((item) => hasAPossibleBulkAction(actions, item)).map(getItemId);
11723      const selectableIdSet = new Set(selectableIds);
11724      const hasSelectableItems = selectableIds.length > 0;
11725      const getSelectionProps = (id) => {
11726        const isSelectable = selectableIdSet.has(id);
11727        return {
11728          onMouseDown: (event) => {
11729            if (event.button === 0 && event.shiftKey && hasSelectableItems) {
11730              event.preventDefault();
11731            }
11732          },
11733          onClickCapture: (event) => {
11734            if (!hasSelectableItems) {
11735              return;
11736            }
11737            const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11738            const isSelectionCheckboxClick = event.target instanceof Element && !!event.target.closest(`.$SELECTION_CHECKBOX_CLASS}`);
11739            if (!isModifierKeyPressed && !event.shiftKey) {
11740              if (isSelectable && isSelectionCheckboxClick) {
11741                gestureRef.current = {
11742                  anchorId: id,
11743                  lastTargetId: null
11744                };
11745              }
11746              return;
11747            }
11748            if (isTouchDeviceRef.current || document.getSelection()?.type === "Range") {
11749              return;
11750            }
11751            event.stopPropagation();
11752            if (!isSelectionCheckboxClick) {
11753              event.preventDefault();
11754            }
11755            if (!isSelectable) {
11756              return;
11757            }
11758            if (event.shiftKey) {
11759              let gesture = gestureRef.current;
11760              if (!gesture || !selectableIdSet.has(gesture.anchorId)) {
11761                gesture = {
11762                  anchorId: getClosestSelectedId({
11763                    targetId: id,
11764                    orderedIds: selectableIds,
11765                    selection
11766                  }) ?? id,
11767                  lastTargetId: null
11768                };
11769              }
11770              onChangeSelection(
11771                getRangeSelection({
11772                  anchorId: gesture.anchorId,
11773                  targetId: id,
11774                  lastTargetId: gesture.lastTargetId,
11775                  orderedIds: selectableIds,
11776                  selection
11777                })
11778              );
11779              gestureRef.current = {
11780                anchorId: gesture.anchorId,
11781                lastTargetId: id
11782              };
11783            } else {
11784              onChangeSelection(
11785                selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11786              );
11787              gestureRef.current = { anchorId: id, lastTargetId: null };
11788            }
11789          }
11790        };
11791      };
11792      return { getSelectionProps };
11793    }
11794  
11795    // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11796    var import_components5 = __toESM(require_components(), 1);
11797    var import_i18n15 = __toESM(require_i18n(), 1);
11798    var import_element26 = __toESM(require_element(), 1);
11799    var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11800    function FieldItem({
11801      field,
11802      isVisible: isVisible2,
11803      onToggleVisibility
11804    }) {
11805      return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11806        /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.Icon, { icon: check_default }) }),
11807        /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11808      ] }) });
11809    }
11810    function isDefined(item) {
11811      return !!item;
11812    }
11813    function PropertiesSection({
11814      showLabel = true
11815    }) {
11816      const { view, fields, onChangeView } = (0, import_element26.useContext)(dataviews_context_default);
11817      const regularFields = getHideableFields(view, fields);
11818      if (!regularFields?.length) {
11819        return null;
11820      }
11821      const titleField = fields.find((f2) => f2.id === view.titleField);
11822      const previewField = fields.find((f2) => f2.id === view.mediaField);
11823      const descriptionField2 = fields.find(
11824        (f2) => f2.id === view.descriptionField
11825      );
11826      const lockedFields = [
11827        {
11828          field: titleField,
11829          isVisibleFlag: "showTitle"
11830        },
11831        {
11832          field: previewField,
11833          isVisibleFlag: "showMedia"
11834        },
11835        {
11836          field: descriptionField2,
11837          isVisibleFlag: "showDescription"
11838        }
11839      ].filter(({ field }) => isDefined(field));
11840      const visibleFieldIds = view.fields ?? [];
11841      const visibleRegularFieldsCount = regularFields.filter(
11842        (f2) => visibleFieldIds.includes(f2.id)
11843      ).length;
11844      const visibleLockedFields = lockedFields.filter(
11845        ({ isVisibleFlag }) => (
11846          // @ts-expect-error
11847          view[isVisibleFlag] ?? true
11848        )
11849      );
11850      const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11851      const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11852      return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11853        showLabel && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n15.__)("Properties") }),
11854        /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11855          Stack,
11856          {
11857            direction: "column",
11858            className: "dataviews-view-config__properties",
11859            children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11860              lockedFields.map(({ field, isVisibleFlag }) => {
11861                const isVisible2 = view[isVisibleFlag] ?? true;
11862                const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11863                return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11864                  FieldItem,
11865                  {
11866                    field: fieldToRender,
11867                    isVisible: isVisible2,
11868                    onToggleVisibility: () => {
11869                      onChangeView({
11870                        ...view,
11871                        [isVisibleFlag]: !isVisible2
11872                      });
11873                    }
11874                  },
11875                  field.id
11876                );
11877              }),
11878              regularFields.map((field) => {
11879                const isVisible2 = visibleFieldIds.includes(field.id);
11880                const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11881                return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11882                  FieldItem,
11883                  {
11884                    field: fieldToRender,
11885                    isVisible: isVisible2,
11886                    onToggleVisibility: () => {
11887                      onChangeView({
11888                        ...view,
11889                        fields: isVisible2 ? visibleFieldIds.filter(
11890                          (fieldId) => fieldId !== field.id
11891                        ) : [...visibleFieldIds, field.id]
11892                      });
11893                    }
11894                  },
11895                  field.id
11896                );
11897              })
11898            ] })
11899          }
11900        )
11901      ] });
11902    }
11903  
11904    // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11905    var import_element27 = __toESM(require_element(), 1);
11906    function useDelayedLoading(isLoading, options = { delay: 400 }) {
11907      const [showLoader, setShowLoader] = (0, import_element27.useState)(false);
11908      (0, import_element27.useEffect)(() => {
11909        if (!isLoading) {
11910          return;
11911        }
11912        const timeout = setTimeout(() => {
11913          setShowLoader(true);
11914        }, options.delay);
11915        return () => {
11916          clearTimeout(timeout);
11917          setShowLoader(false);
11918        };
11919      }, [isLoading, options.delay]);
11920      return showLoader;
11921    }
11922  
11923    // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11924    var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11925    function getEffectiveAlign(explicitAlign, fieldType) {
11926      if (explicitAlign) {
11927        return explicitAlign;
11928      }
11929      if (fieldType === "integer" || fieldType === "number") {
11930        return "end";
11931      }
11932      return void 0;
11933    }
11934    function TableColumnField({
11935      item,
11936      fields,
11937      column,
11938      align
11939    }) {
11940      const field = fields.find((f2) => f2.id === column);
11941      if (!field) {
11942        return null;
11943      }
11944      const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11945        "dataviews-view-table__cell-align-end": align === "end",
11946        "dataviews-view-table__cell-align-center": align === "center"
11947      });
11948      return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(field.render, { item, field }) });
11949    }
11950    function TableRow({
11951      hasBulkActions,
11952      item,
11953      level,
11954      actions,
11955      fields,
11956      id,
11957      view,
11958      titleField,
11959      mediaField,
11960      descriptionField: descriptionField2,
11961      selection,
11962      getItemId,
11963      isItemClickable: isItemClickable2,
11964      onClickItem,
11965      renderItemLink,
11966      onChangeSelection,
11967      onMouseDown,
11968      onClickCapture,
11969      isActionsColumnSticky,
11970      posinset
11971    }) {
11972      const { paginationInfo } = (0, import_element28.useContext)(dataviews_context_default);
11973      const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11974      const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11975      const {
11976        showTitle = true,
11977        showMedia = true,
11978        showDescription = true,
11979        infiniteScrollEnabled
11980      } = view;
11981      const columns = view.fields ?? [];
11982      const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
11983      return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
11984        "tr",
11985        {
11986          className: clsx_default("dataviews-view-table__row", {
11987            "is-selected": hasPossibleBulkAction && isSelected2,
11988            "has-bulk-actions": hasPossibleBulkAction
11989          }),
11990          "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11991          "aria-posinset": posinset,
11992          role: infiniteScrollEnabled ? "article" : void 0,
11993          onClickCapture,
11994          onMouseDown: (event) => {
11995            const isMetaClick = (0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey;
11996            if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11997              event.preventDefault();
11998            }
11999            onMouseDown(event);
12000          },
12001          children: [
12002            hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12003              DataViewsSelectionCheckbox,
12004              {
12005                item,
12006                selection,
12007                onChangeSelection,
12008                getItemId,
12009                titleField,
12010                disabled: !hasPossibleBulkAction
12011              }
12012            ) }) }),
12013            hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12014              column_primary_default,
12015              {
12016                item,
12017                level,
12018                titleField: showTitle ? titleField : void 0,
12019                mediaField: showMedia ? mediaField : void 0,
12020                descriptionField: showDescription ? descriptionField2 : void 0,
12021                isItemClickable: isItemClickable2,
12022                onClickItem,
12023                renderItemLink
12024              }
12025            ) }),
12026            columns.map((column) => {
12027              const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12028              const field = fields.find((f2) => f2.id === column);
12029              const effectiveAlign = getEffectiveAlign(align, field?.type);
12030              return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12031                "td",
12032                {
12033                  style: {
12034                    width,
12035                    maxWidth,
12036                    minWidth
12037                  },
12038                  children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12039                    TableColumnField,
12040                    {
12041                      fields,
12042                      item,
12043                      column,
12044                      align: effectiveAlign
12045                    }
12046                  )
12047                },
12048                column
12049              );
12050            }),
12051            !!actions?.length && // Disable reason: we are not making the element interactive,
12052            // but preventing any click events from bubbling up to the
12053            // table row. This allows us to add a click handler to the row
12054            // itself (to toggle row selection) without erroneously
12055            // intercepting click events from ItemActions.
12056            /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12057              "td",
12058              {
12059                className: clsx_default("dataviews-view-table__actions-column", {
12060                  "dataviews-view-table__actions-column--sticky": true,
12061                  "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
12062                }),
12063                onClick: (e2) => e2.stopPropagation(),
12064                children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ItemActions, { item, actions })
12065              }
12066            )
12067          ]
12068        }
12069      );
12070    }
12071    function ViewTable({
12072      actions,
12073      data,
12074      fields,
12075      getItemId,
12076      getItemLevel,
12077      isLoading = false,
12078      onChangeView,
12079      onChangeSelection,
12080      selection,
12081      setOpenedFilter,
12082      onClickItem,
12083      isItemClickable: isItemClickable2,
12084      renderItemLink,
12085      view,
12086      className,
12087      empty
12088    }) {
12089      const { containerRef } = (0, import_element28.useContext)(dataviews_context_default);
12090      const isDelayedLoading = useDelayedLoading(isLoading);
12091      const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12092      const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12093      const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
12094      const { getSelectionProps } = useSelectionProps({
12095        data: orderedData,
12096        actions,
12097        getItemId,
12098        selection,
12099        onChangeSelection
12100      });
12101      const headerMenuRefs = (0, import_element28.useRef)(/* @__PURE__ */ new Map());
12102      const headerMenuToFocusRef = (0, import_element28.useRef)(void 0);
12103      const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element28.useState)();
12104      const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element28.useState)(null);
12105      (0, import_element28.useEffect)(() => {
12106        if (headerMenuToFocusRef.current) {
12107          headerMenuToFocusRef.current.focus();
12108          headerMenuToFocusRef.current = void 0;
12109        }
12110      });
12111      const tableNoticeId = (0, import_element28.useId)();
12112      const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
12113        scrollContainerRef: containerRef,
12114        enabledHorizontal: !!actions?.length
12115      });
12116      const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12117      if (nextHeaderMenuToFocus) {
12118        headerMenuToFocusRef.current = nextHeaderMenuToFocus;
12119        setNextHeaderMenuToFocus(void 0);
12120        return;
12121      }
12122      const onHide = (field) => {
12123        const hidden = headerMenuRefs.current.get(field.id);
12124        const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
12125        setNextHeaderMenuToFocus(fallback?.node);
12126      };
12127      const handleHeaderContextMenu = (event) => {
12128        event.preventDefault();
12129        event.stopPropagation();
12130        const virtualAnchor = {
12131          getBoundingClientRect: () => ({
12132            x: event.clientX,
12133            y: event.clientY,
12134            top: event.clientY,
12135            left: event.clientX,
12136            right: event.clientX,
12137            bottom: event.clientY,
12138            width: 0,
12139            height: 0,
12140            toJSON: () => ({})
12141          })
12142        };
12143        window.requestAnimationFrame(() => {
12144          setContextMenuAnchor(virtualAnchor);
12145        });
12146      };
12147      const hasData = !!data?.length;
12148      const titleField = fields.find((field) => field.id === view.titleField);
12149      const mediaField = fields.find((field) => field.id === view.mediaField);
12150      const descriptionField2 = fields.find(
12151        (field) => field.id === view.descriptionField
12152      );
12153      const { showTitle = true, showMedia = true, showDescription = true } = view;
12154      const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
12155      const columns = view.fields ?? [];
12156      const headerMenuRef = (column, index2) => (node) => {
12157        if (node) {
12158          headerMenuRefs.current.set(column, {
12159            node,
12160            fallback: columns[index2 > 0 ? index2 - 1 : 1]
12161          });
12162        } else {
12163          headerMenuRefs.current.delete(column);
12164        }
12165      };
12166      const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12167      const isRtl = (0, import_i18n16.isRTL)();
12168      if (!hasData) {
12169        return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12170          "div",
12171          {
12172            className: clsx_default("dataviews-no-results", {
12173              "is-refreshing": isDelayedLoading
12174            }),
12175            id: tableNoticeId,
12176            children: empty
12177          }
12178        );
12179      }
12180      return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
12181        /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
12182          "table",
12183          {
12184            className: clsx_default("dataviews-view-table", className, {
12185              [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12186                view.layout.density
12187              ),
12188              "has-bulk-actions": hasBulkActions,
12189              "is-refreshing": !isInfiniteScroll && isDelayedLoading
12190            }),
12191            "aria-busy": isLoading,
12192            "aria-describedby": tableNoticeId,
12193            role: isInfiniteScroll ? "feed" : void 0,
12194            inert: !isInfiniteScroll && isLoading ? "true" : void 0,
12195            children: [
12196              /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("colgroup", { children: [
12197                hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
12198                hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
12199                columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12200                  "col",
12201                  {
12202                    className: clsx_default(
12203                      `dataviews-view-table__col-$column}`,
12204                      {
12205                        "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
12206                      }
12207                    )
12208                  },
12209                  `col-$column}`
12210                )),
12211                !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-actions" })
12212              ] }),
12213              contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12214                import_components6.Popover,
12215                {
12216                  anchor: contextMenuAnchor,
12217                  onClose: () => setContextMenuAnchor(null),
12218                  placement: "bottom-start",
12219                  children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(PropertiesSection, { showLabel: false })
12220                }
12221              ),
12222              /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12223                "thead",
12224                {
12225                  className: clsx_default({
12226                    "dataviews-view-table__thead--stuck": isVerticallyScrolled
12227                  }),
12228                  onContextMenu: handleHeaderContextMenu,
12229                  children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { className: "dataviews-view-table__row", children: [
12230                    hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12231                      "th",
12232                      {
12233                        className: "dataviews-view-table__checkbox-column",
12234                        scope: "col",
12235                        onContextMenu: handleHeaderContextMenu,
12236                        children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12237                          BulkSelectionCheckbox,
12238                          {
12239                            selection,
12240                            onChangeSelection,
12241                            data,
12242                            actions,
12243                            getItemId
12244                          }
12245                        )
12246                      }
12247                    ),
12248                    hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12249                      column_header_menu_default,
12250                      {
12251                        ref: headerMenuRef(
12252                          titleField.id,
12253                          0
12254                        ),
12255                        fieldId: titleField.id,
12256                        view,
12257                        fields,
12258                        onChangeView,
12259                        onHide,
12260                        setOpenedFilter,
12261                        canMove: false,
12262                        canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12263                        canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12264                      }
12265                    ) }),
12266                    columns.map((column, index2) => {
12267                      const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12268                      const field = fields.find(
12269                        (f2) => f2.id === column
12270                      );
12271                      const effectiveAlign = getEffectiveAlign(
12272                        align,
12273                        field?.type
12274                      );
12275                      const canInsertOrMove = view.layout?.enableMoving ?? true;
12276                      return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12277                        "th",
12278                        {
12279                          style: {
12280                            width,
12281                            maxWidth,
12282                            minWidth,
12283                            textAlign: effectiveAlign
12284                          },
12285                          "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12286                          scope: "col",
12287                          children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12288                            column_header_menu_default,
12289                            {
12290                              ref: headerMenuRef(column, index2),
12291                              fieldId: column,
12292                              view,
12293                              fields,
12294                              onChangeView,
12295                              onHide,
12296                              setOpenedFilter,
12297                              canMove: canInsertOrMove,
12298                              canInsertLeft: canInsertOrMove,
12299                              canInsertRight: canInsertOrMove
12300                            }
12301                          )
12302                        },
12303                        column
12304                      );
12305                    }),
12306                    !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12307                      "th",
12308                      {
12309                        className: clsx_default(
12310                          "dataviews-view-table__actions-column",
12311                          {
12312                            "dataviews-view-table__actions-column--sticky": true,
12313                            "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12314                          }
12315                        ),
12316                        children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n16.__)("Actions") })
12317                      }
12318                    )
12319                  ] })
12320                }
12321              ),
12322              hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12323                ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tbody", { children: [
12324                  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12325                    "td",
12326                    {
12327                      colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12328                      className: "dataviews-view-table__group-header-cell",
12329                      children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n16.sprintf)(
12330                        // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12331                        (0, import_i18n16.__)("%1$s: %2$s"),
12332                        groupField.label,
12333                        groupName
12334                      )
12335                    }
12336                  ) }),
12337                  groupItems.map((item, index2) => {
12338                    const id = getItemId(item) || index2.toString();
12339                    return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12340                      TableRow,
12341                      {
12342                        item,
12343                        level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12344                        hasBulkActions,
12345                        actions,
12346                        fields,
12347                        id,
12348                        view,
12349                        titleField,
12350                        mediaField,
12351                        descriptionField: descriptionField2,
12352                        selection,
12353                        getItemId,
12354                        onChangeSelection,
12355                        ...getSelectionProps(id),
12356                        onClickItem,
12357                        renderItemLink,
12358                        isItemClickable: isItemClickable2,
12359                        isActionsColumnSticky: !isHorizontalScrollEnd
12360                      },
12361                      getItemId(item)
12362                    );
12363                  })
12364                ] }, `group-$groupName}`)
12365              ) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tbody", { children: hasData && data.map((item, index2) => {
12366                const id = getItemId(item) || index2.toString();
12367                return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12368                  TableRow,
12369                  {
12370                    item,
12371                    level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12372                    hasBulkActions,
12373                    actions,
12374                    fields,
12375                    id,
12376                    view,
12377                    titleField,
12378                    mediaField,
12379                    descriptionField: descriptionField2,
12380                    selection,
12381                    getItemId,
12382                    onChangeSelection,
12383                    ...getSelectionProps(id),
12384                    onClickItem,
12385                    renderItemLink,
12386                    isItemClickable: isItemClickable2,
12387                    isActionsColumnSticky: !isHorizontalScrollEnd,
12388                    posinset: isInfiniteScroll ? index2 + 1 : void 0
12389                  },
12390                  getItemId(item)
12391                );
12392              }) })
12393            ]
12394          }
12395        ),
12396        isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components6.Spinner, {}) }) })
12397      ] });
12398    }
12399    var table_default = ViewTable;
12400  
12401    // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12402    var import_components9 = __toESM(require_components(), 1);
12403    var import_i18n19 = __toESM(require_i18n(), 1);
12404  
12405    // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12406    var import_components8 = __toESM(require_components(), 1);
12407    var import_i18n18 = __toESM(require_i18n(), 1);
12408    var import_compose3 = __toESM(require_compose(), 1);
12409    var import_element32 = __toESM(require_element(), 1);
12410  
12411    // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12412    var import_components7 = __toESM(require_components(), 1);
12413    var import_i18n17 = __toESM(require_i18n(), 1);
12414    var import_element29 = __toESM(require_element(), 1);
12415    var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12416    var imageSizes = [
12417      {
12418        value: 120,
12419        breakpoint: 1
12420      },
12421      {
12422        value: 170,
12423        breakpoint: 1
12424      },
12425      {
12426        value: 230,
12427        breakpoint: 1
12428      },
12429      {
12430        value: 290,
12431        breakpoint: 1112
12432        // at minimum image width, 4 images display at this container size
12433      },
12434      {
12435        value: 350,
12436        breakpoint: 1636
12437        // at minimum image width, 6 images display at this container size
12438      },
12439      {
12440        value: 430,
12441        breakpoint: 588
12442        // at minimum image width, 2 images display at this container size
12443      }
12444    ];
12445    var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12446    function useGridColumns() {
12447      const context = (0, import_element29.useContext)(dataviews_context_default);
12448      const view = context.view;
12449      return (0, import_element29.useMemo)(() => {
12450        const containerWidth = context.containerWidth;
12451        const gap = 32;
12452        const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12453        const columns = Math.floor(
12454          (containerWidth + gap) / (previewSize + gap)
12455        );
12456        return Math.max(1, columns);
12457      }, [context.containerWidth, view.layout?.previewSize]);
12458    }
12459  
12460    // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12461    var import_element30 = __toESM(require_element(), 1);
12462    var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12463    var GridItems = (0, import_element30.forwardRef)(({ className, previewSize, ...props }, ref) => {
12464      return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12465        "div",
12466        {
12467          ref,
12468          className: clsx_default("dataviews-view-grid-items", className),
12469          style: {
12470            gridTemplateColumns: previewSize && `repeat(auto-fill, minmax($previewSize}px, 1fr))`
12471          },
12472          ...props
12473        }
12474      );
12475    });
12476  
12477    // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12478    var import_element31 = __toESM(require_element(), 1);
12479    function useIntersectionObserver(elementRef, posinset) {
12480      const { intersectionObserver } = (0, import_element31.useContext)(dataviews_context_default);
12481      (0, import_element31.useEffect)(() => {
12482        const element = elementRef.current;
12483        if (!element || posinset === void 0 || !intersectionObserver) {
12484          return;
12485        }
12486        intersectionObserver.observe(element);
12487        return () => {
12488          intersectionObserver.unobserve(element);
12489        };
12490      }, [elementRef, intersectionObserver, posinset]);
12491    }
12492    function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12493      const hasData = !!data?.length;
12494      const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12495      return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12496    }
12497  
12498    // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12499    var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12500    var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12501    function chunk(array, size4) {
12502      const chunks = [];
12503      for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12504        chunks.push(array.slice(i2, i2 + size4));
12505      }
12506      return chunks;
12507    }
12508    var GridItem = (0, import_element32.forwardRef)(
12509      function GridItem2({
12510        view,
12511        selection,
12512        onChangeSelection,
12513        onClickItem,
12514        isItemClickable: isItemClickable2,
12515        renderItemLink,
12516        getItemId,
12517        item,
12518        actions,
12519        mediaField,
12520        titleField,
12521        descriptionField: descriptionField2,
12522        regularFields,
12523        badgeFields,
12524        hasBulkActions,
12525        config,
12526        posinset,
12527        setsize,
12528        ...props
12529      }, forwardedRef) {
12530        const {
12531          showTitle = true,
12532          showMedia = true,
12533          showDescription = true
12534        } = view;
12535        const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12536        const id = getItemId(item);
12537        const elementRef = (0, import_element32.useRef)(null);
12538        const setRefs = (0, import_element32.useCallback)(
12539          (node) => {
12540            elementRef.current = node;
12541            if (typeof forwardedRef === "function") {
12542              forwardedRef(node);
12543            } else if (forwardedRef) {
12544              forwardedRef.current = node;
12545            }
12546          },
12547          [forwardedRef]
12548        );
12549        useIntersectionObserver(elementRef, posinset);
12550        const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12551        const isSelected2 = selection.includes(id);
12552        const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12553        const rendersMediaField = showMedia && mediaField?.render;
12554        const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12555          mediaField.render,
12556          {
12557            item,
12558            field: mediaField,
12559            config
12560          }
12561        ) : mediaPlaceholder;
12562        const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
12563        let mediaA11yProps;
12564        let titleA11yProps;
12565        if (isItemClickable2(item) && onClickItem) {
12566          if (renderedTitleField) {
12567            mediaA11yProps = {
12568              "aria-labelledby": `dataviews-view-grid__title-field-$instanceId}`
12569            };
12570            titleA11yProps = {
12571              id: `dataviews-view-grid__title-field-$instanceId}`
12572            };
12573          } else {
12574            mediaA11yProps = {
12575              "aria-label": (0, import_i18n18.__)("Navigate to item")
12576            };
12577          }
12578        }
12579        return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12580          Stack,
12581          {
12582            direction: "column",
12583            ...props,
12584            ref: setRefs,
12585            "aria-setsize": setsize,
12586            "aria-posinset": posinset,
12587            className: clsx_default(
12588              props.className,
12589              "dataviews-view-grid__row__gridcell",
12590              "dataviews-view-grid__card",
12591              {
12592                "is-selected": hasBulkAction && isSelected2
12593              }
12594            ),
12595            children: [
12596              /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12597                ItemClickWrapper,
12598                {
12599                  item,
12600                  isItemClickable: isItemClickable2,
12601                  onClickItem,
12602                  renderItemLink,
12603                  className: clsx_default("dataviews-view-grid__media", {
12604                    "dataviews-view-grid__media--placeholder": !rendersMediaField
12605                  }),
12606                  ...mediaA11yProps,
12607                  children: renderedMediaField
12608                }
12609              ),
12610              hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12611                DataViewsSelectionCheckbox,
12612                {
12613                  item,
12614                  selection,
12615                  onChangeSelection,
12616                  getItemId,
12617                  titleField,
12618                  disabled: !hasBulkAction
12619                }
12620              ),
12621              !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12622                ItemActions,
12623                {
12624                  item,
12625                  actions,
12626                  isCompact: true
12627                }
12628              ) }),
12629              showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12630                ItemClickWrapper,
12631                {
12632                  item,
12633                  isItemClickable: isItemClickable2,
12634                  onClickItem,
12635                  renderItemLink,
12636                  className: "dataviews-view-grid__title-field dataviews-title-field",
12637                  ...titleA11yProps,
12638                  title: titleField?.getValueFormatted({
12639                    item,
12640                    field: titleField
12641                  }) || void 0,
12642                  children: renderedTitleField
12643                }
12644              ) }),
12645              /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12646                showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12647                  descriptionField2.render,
12648                  {
12649                    item,
12650                    field: descriptionField2
12651                  }
12652                ),
12653                !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12654                  Stack,
12655                  {
12656                    direction: "row",
12657                    className: "dataviews-view-grid__badge-fields",
12658                    gap: "sm",
12659                    wrap: "wrap",
12660                    align: "top",
12661                    justify: "flex-start",
12662                    children: badgeFields.map((field) => {
12663                      return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12664                        WCBadge,
12665                        {
12666                          className: "dataviews-view-grid__field-value",
12667                          children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12668                            field.render,
12669                            {
12670                              item,
12671                              field
12672                            }
12673                          )
12674                        },
12675                        field.id
12676                      );
12677                    })
12678                  }
12679                ),
12680                !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12681                  Stack,
12682                  {
12683                    direction: "column",
12684                    className: "dataviews-view-grid__fields",
12685                    gap: "xs",
12686                    children: regularFields.map((field) => {
12687                      return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12688                        import_components8.Flex,
12689                        {
12690                          className: "dataviews-view-grid__field",
12691                          gap: 1,
12692                          justify: "flex-start",
12693                          expanded: true,
12694                          style: { height: "auto" },
12695                          direction: "row",
12696                          children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
12697                            /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(tooltip_exports.Root, { children: [
12698                              /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12699                                tooltip_exports.Trigger,
12700                                {
12701                                  render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12702                                }
12703                              ),
12704                              /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(tooltip_exports.Popup, { children: field.label })
12705                            ] }),
12706                            /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12707                              import_components8.FlexItem,
12708                              {
12709                                className: "dataviews-view-grid__field-value",
12710                                style: { maxHeight: "none" },
12711                                children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12712                                  field.render,
12713                                  {
12714                                    item,
12715                                    field
12716                                  }
12717                                )
12718                              }
12719                            )
12720                          ] })
12721                        },
12722                        field.id
12723                      );
12724                    })
12725                  }
12726                )
12727              ] })
12728            ]
12729          }
12730        );
12731      }
12732    );
12733    function CompositeGrid({
12734      data,
12735      isInfiniteScroll,
12736      className,
12737      inert,
12738      isLoading,
12739      view,
12740      fields,
12741      selection,
12742      onChangeSelection,
12743      onClickItem,
12744      isItemClickable: isItemClickable2,
12745      renderItemLink,
12746      getItemId,
12747      actions,
12748      getSelectionProps
12749    }) {
12750      const { paginationInfo, resizeObserverRef } = (0, import_element32.useContext)(dataviews_context_default);
12751      const gridColumns = useGridColumns();
12752      const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12753      const titleField = fields.find(
12754        (field) => field.id === view?.titleField
12755      );
12756      const mediaField = fields.find(
12757        (field) => field.id === view?.mediaField
12758      );
12759      const descriptionField2 = fields.find(
12760        (field) => field.id === view?.descriptionField
12761      );
12762      const otherFields = view.fields ?? [];
12763      const { regularFields, badgeFields } = otherFields.reduce(
12764        (accumulator, fieldId) => {
12765          const field = fields.find((f2) => f2.id === fieldId);
12766          if (!field) {
12767            return accumulator;
12768          }
12769          const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12770          accumulator[key].push(field);
12771          return accumulator;
12772        },
12773        { regularFields: [], badgeFields: [] }
12774      );
12775      const size4 = "900px";
12776      const totalRows = Math.ceil(data.length / gridColumns);
12777      const placeholdersNeeded = usePlaceholdersNeeded(
12778        data,
12779        isInfiniteScroll,
12780        gridColumns
12781      );
12782      return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12783        // Render infinite scroll layout (no rows, feed semantics)
12784        children: [
12785          isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12786            import_components8.Composite,
12787            {
12788              render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12789                GridItems,
12790                {
12791                  className: clsx_default(
12792                    "dataviews-view-grid-infinite-scroll",
12793                    className,
12794                    {
12795                      [`has-$view.layout?.density}-density`]: view.layout?.density && [
12796                        "compact",
12797                        "comfortable"
12798                      ].includes(view.layout.density)
12799                    }
12800                  ),
12801                  previewSize: view.layout?.previewSize,
12802                  "aria-busy": isLoading,
12803                  ref: resizeObserverRef
12804                }
12805              ),
12806              role: "feed",
12807              focusWrap: true,
12808              inert,
12809              children: [
12810                Array.from({ length: placeholdersNeeded }).map(
12811                  (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12812                    import_components8.Composite.Item,
12813                    {
12814                      render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12815                        Stack,
12816                        {
12817                          ...props,
12818                          direction: "column",
12819                          role: "article",
12820                          className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12821                        }
12822                      ),
12823                      "aria-hidden": true,
12824                      tabIndex: -1
12825                    },
12826                    `placeholder-$index2}`
12827                  )
12828                ),
12829                data.map((item) => {
12830                  const itemId = getItemId(item);
12831                  const selectionProps = getSelectionProps(itemId);
12832                  const stablePosition = item.position;
12833                  return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12834                    import_components8.Composite.Item,
12835                    {
12836                      render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12837                        GridItem,
12838                        {
12839                          ...props,
12840                          id: itemId,
12841                          role: "article",
12842                          view,
12843                          selection,
12844                          onChangeSelection,
12845                          onClickItem,
12846                          isItemClickable: isItemClickable2,
12847                          renderItemLink,
12848                          getItemId,
12849                          item,
12850                          actions,
12851                          onMouseDown: (event) => {
12852                            props.onMouseDown?.(event);
12853                            selectionProps.onMouseDown(
12854                              event
12855                            );
12856                          },
12857                          onClickCapture: (event) => {
12858                            props.onClickCapture?.(event);
12859                            selectionProps.onClickCapture(
12860                              event
12861                            );
12862                          },
12863                          mediaField,
12864                          titleField,
12865                          descriptionField: descriptionField2,
12866                          regularFields,
12867                          badgeFields,
12868                          hasBulkActions,
12869                          posinset: stablePosition,
12870                          setsize: paginationInfo.totalItems,
12871                          config: {
12872                            sizes: size4
12873                          }
12874                        }
12875                      )
12876                    },
12877                    itemId
12878                  );
12879                })
12880              ]
12881            }
12882          ),
12883          // Render standard grid layout (with rows, grid semantics)
12884          !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12885            import_components8.Composite,
12886            {
12887              role: "grid",
12888              className: clsx_default("dataviews-view-grid", className, {
12889                [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12890                  view.layout.density
12891                )
12892              }),
12893              focusWrap: true,
12894              "aria-busy": isLoading,
12895              "aria-rowcount": totalRows,
12896              ref: resizeObserverRef,
12897              inert,
12898              children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12899                import_components8.Composite.Row,
12900                {
12901                  render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12902                    "div",
12903                    {
12904                      role: "row",
12905                      "aria-rowindex": i2 + 1,
12906                      "aria-label": (0, import_i18n18.sprintf)(
12907                        /* translators: %d: The row number in the grid */
12908                        (0, import_i18n18.__)("Row %d"),
12909                        i2 + 1
12910                      ),
12911                      className: "dataviews-view-grid__row",
12912                      style: {
12913                        gridTemplateColumns: `repeat( $gridColumns}, minmax(0, 1fr) )`
12914                      }
12915                    }
12916                  ),
12917                  children: row.map((item) => {
12918                    const itemId = getItemId(item);
12919                    const selectionProps = getSelectionProps(itemId);
12920                    return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12921                      import_components8.Composite.Item,
12922                      {
12923                        render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12924                          GridItem,
12925                          {
12926                            ...props,
12927                            id: itemId,
12928                            role: "gridcell",
12929                            view,
12930                            selection,
12931                            onChangeSelection,
12932                            onClickItem,
12933                            isItemClickable: isItemClickable2,
12934                            renderItemLink,
12935                            getItemId,
12936                            item,
12937                            actions,
12938                            onMouseDown: (event) => {
12939                              props.onMouseDown?.(
12940                                event
12941                              );
12942                              selectionProps.onMouseDown(
12943                                event
12944                              );
12945                            },
12946                            onClickCapture: (event) => {
12947                              props.onClickCapture?.(
12948                                event
12949                              );
12950                              selectionProps.onClickCapture(
12951                                event
12952                              );
12953                            },
12954                            mediaField,
12955                            titleField,
12956                            descriptionField: descriptionField2,
12957                            regularFields,
12958                            badgeFields,
12959                            hasBulkActions,
12960                            config: {
12961                              sizes: size4
12962                            }
12963                          }
12964                        )
12965                      },
12966                      itemId
12967                    );
12968                  })
12969                },
12970                i2
12971              ))
12972            }
12973          )
12974        ]
12975      });
12976    }
12977  
12978    // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12979    var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12980    function ViewGrid({
12981      actions,
12982      data,
12983      fields,
12984      getItemId,
12985      isLoading,
12986      onChangeSelection,
12987      onClickItem,
12988      isItemClickable: isItemClickable2,
12989      renderItemLink,
12990      selection,
12991      view,
12992      className,
12993      empty
12994    }) {
12995      const isDelayedLoading = useDelayedLoading(!!isLoading);
12996      const hasData = !!data?.length;
12997      const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12998      const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12999      const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13000      const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
13001      const { getSelectionProps } = useSelectionProps({
13002        data: orderedData,
13003        actions,
13004        getItemId,
13005        selection,
13006        onChangeSelection
13007      });
13008      if (!hasData) {
13009        return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13010          "div",
13011          {
13012            className: clsx_default("dataviews-no-results", {
13013              "is-refreshing": isDelayedLoading
13014            }),
13015            children: empty
13016          }
13017        );
13018      }
13019      const gridProps = {
13020        className: clsx_default(className, {
13021          "is-refreshing": !isInfiniteScroll && isDelayedLoading
13022        }),
13023        inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13024        isLoading,
13025        view,
13026        fields,
13027        selection,
13028        onChangeSelection,
13029        onClickItem,
13030        isItemClickable: isItemClickable2,
13031        renderItemLink,
13032        getItemId,
13033        actions,
13034        getSelectionProps
13035      };
13036      return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, {
13037        // Render multiple groups.
13038        children: [
13039          hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
13040            ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13041              Stack,
13042              {
13043                direction: "column",
13044                gap: "sm",
13045                children: [
13046                  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
13047                    // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13048                    (0, import_i18n19.__)("%1$s: %2$s"),
13049                    groupField.label,
13050                    groupName
13051                  ) }),
13052                  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13053                    CompositeGrid,
13054                    {
13055                      ...gridProps,
13056                      data: groupItems,
13057                      isInfiniteScroll: false
13058                    }
13059                  )
13060                ]
13061              },
13062              groupName
13063            )
13064          ) }),
13065          // Render a single grid with all data.
13066          !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13067            CompositeGrid,
13068            {
13069              ...gridProps,
13070              data,
13071              isInfiniteScroll: !!isInfiniteScroll
13072            }
13073          ),
13074          isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components9.Spinner, {}) })
13075        ]
13076      });
13077    }
13078    var grid_default = ViewGrid;
13079  
13080    // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
13081    var import_compose4 = __toESM(require_compose(), 1);
13082    var import_components10 = __toESM(require_components(), 1);
13083    var import_element33 = __toESM(require_element(), 1);
13084    var import_i18n20 = __toESM(require_i18n(), 1);
13085    var import_data4 = __toESM(require_data(), 1);
13086    var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13087    var { Menu: Menu3 } = unlock2(import_components10.privateApis);
13088    function generateItemWrapperCompositeId(idPrefix) {
13089      return `$idPrefix}-item-wrapper`;
13090    }
13091    function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
13092      return `$idPrefix}-primary-action-$primaryActionId}`;
13093    }
13094    function generateDropdownTriggerCompositeId(idPrefix) {
13095      return `$idPrefix}-dropdown`;
13096    }
13097    function PrimaryActionGridCell({
13098      idPrefix,
13099      primaryAction,
13100      item
13101    }) {
13102      const registry = (0, import_data4.useRegistry)();
13103      const [isModalOpen, setIsModalOpen] = (0, import_element33.useState)(false);
13104      const compositeItemId = generatePrimaryActionCompositeId(
13105        idPrefix,
13106        primaryAction.id
13107      );
13108      const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
13109      return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13110        import_components10.Composite.Item,
13111        {
13112          id: compositeItemId,
13113          render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13114            import_components10.Button,
13115            {
13116              disabled: !!primaryAction.disabled,
13117              accessibleWhenDisabled: true,
13118              text: label,
13119              size: "small",
13120              onClick: () => setIsModalOpen(true)
13121            }
13122          ),
13123          children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13124            ActionModal,
13125            {
13126              action: primaryAction,
13127              items: [item],
13128              closeModal: () => setIsModalOpen(false)
13129            }
13130          )
13131        }
13132      ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13133        import_components10.Composite.Item,
13134        {
13135          id: compositeItemId,
13136          render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13137            import_components10.Button,
13138            {
13139              disabled: !!primaryAction.disabled,
13140              accessibleWhenDisabled: true,
13141              size: "small",
13142              onClick: () => {
13143                primaryAction.callback([item], { registry });
13144              },
13145              children: label
13146            }
13147          )
13148        }
13149      ) }, primaryAction.id);
13150    }
13151    function ListItem({
13152      view,
13153      actions,
13154      idPrefix,
13155      isSelected: isSelected2,
13156      item,
13157      titleField,
13158      mediaField,
13159      descriptionField: descriptionField2,
13160      onSelect,
13161      otherFields,
13162      onDropdownTriggerKeyDown,
13163      posinset
13164    }) {
13165      const {
13166        showTitle = true,
13167        showMedia = true,
13168        showDescription = true,
13169        infiniteScrollEnabled
13170      } = view;
13171      const itemRef = (0, import_element33.useRef)(null);
13172      const labelId = `$idPrefix}-label`;
13173      const descriptionId = `$idPrefix}-description`;
13174      const registry = (0, import_data4.useRegistry)();
13175      const [isHovered, setIsHovered] = (0, import_element33.useState)(false);
13176      const [activeModalAction, setActiveModalAction] = (0, import_element33.useState)(
13177        null
13178      );
13179      const handleHover = ({ type }) => {
13180        const isHover = type === "mouseenter";
13181        setIsHovered(isHover);
13182      };
13183      const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
13184      (0, import_element33.useEffect)(() => {
13185        if (isSelected2) {
13186          itemRef.current?.scrollIntoView({
13187            behavior: "auto",
13188            block: "nearest",
13189            inline: "nearest"
13190          });
13191        }
13192      }, [isSelected2]);
13193      const { primaryAction, eligibleActions } = (0, import_element33.useMemo)(() => {
13194        const _eligibleActions = actions.filter(
13195          (action) => !action.isEligible || action.isEligible(item)
13196        );
13197        const _primaryActions = _eligibleActions.filter(
13198          (action) => action.isPrimary
13199        );
13200        return {
13201          primaryAction: _primaryActions[0],
13202          eligibleActions: _eligibleActions
13203        };
13204      }, [actions, item]);
13205      const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
13206      const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13207        mediaField.render,
13208        {
13209          item,
13210          field: mediaField,
13211          config: { sizes: "52px" }
13212        }
13213      ) }) : null;
13214      const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
13215      const renderDescription = showDescription && descriptionField2?.render;
13216      const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
13217      const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13218        Stack,
13219        {
13220          direction: "row",
13221          gap: "md",
13222          className: "dataviews-view-list__item-actions",
13223          children: [
13224            primaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13225              PrimaryActionGridCell,
13226              {
13227                idPrefix,
13228                primaryAction,
13229                item
13230              }
13231            ),
13232            !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { role: "gridcell", children: [
13233              /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu3, { placement: "bottom-end", children: [
13234                /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13235                  Menu3.TriggerButton,
13236                  {
13237                    render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13238                      import_components10.Composite.Item,
13239                      {
13240                        id: generateDropdownTriggerCompositeId(
13241                          idPrefix
13242                        ),
13243                        render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13244                          import_components10.Button,
13245                          {
13246                            size: "small",
13247                            icon: more_vertical_default,
13248                            label: (0, import_i18n20.__)("Actions"),
13249                            accessibleWhenDisabled: true,
13250                            disabled: !actions.length,
13251                            onKeyDown: onDropdownTriggerKeyDown
13252                          }
13253                        )
13254                      }
13255                    )
13256                  }
13257                ),
13258                /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13259                  ActionsMenuGroup,
13260                  {
13261                    actions: eligibleActions,
13262                    item,
13263                    registry,
13264                    setActiveModalAction
13265                  }
13266                ) })
13267              ] }),
13268              !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13269                ActionModal,
13270                {
13271                  action: activeModalAction,
13272                  items: [item],
13273                  closeModal: () => setActiveModalAction(null)
13274                }
13275              )
13276            ] })
13277          ]
13278        }
13279      );
13280      return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13281        import_components10.Composite.Row,
13282        {
13283          ref: itemRef,
13284          render: (
13285            /* aria-posinset breaks Composite.Row if passed to it directly. */
13286            /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13287              "div",
13288              {
13289                "aria-posinset": posinset,
13290                "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13291              }
13292            )
13293          ),
13294          role: infiniteScrollEnabled ? "article" : "row",
13295          className: clsx_default({
13296            "is-selected": isSelected2,
13297            "is-hovered": isHovered
13298          }),
13299          onMouseEnter: handleHover,
13300          onMouseLeave: handleHover,
13301          children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13302            Stack,
13303            {
13304              direction: "row",
13305              className: "dataviews-view-list__item-wrapper",
13306              children: [
13307                /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13308                  import_components10.Composite.Item,
13309                  {
13310                    id: generateItemWrapperCompositeId(idPrefix),
13311                    "aria-pressed": isSelected2,
13312                    "aria-labelledby": labelId,
13313                    "aria-describedby": descriptionId,
13314                    className: "dataviews-view-list__item",
13315                    onClick: () => onSelect(item)
13316                  }
13317                ) }),
13318                /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13319                  Stack,
13320                  {
13321                    direction: "row",
13322                    gap: "md",
13323                    justify: "start",
13324                    align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13325                    style: { flex: 1, minWidth: 0 },
13326                    children: [
13327                      renderedMediaField,
13328                      /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13329                        Stack,
13330                        {
13331                          direction: "column",
13332                          gap: "xs",
13333                          className: "dataviews-view-list__field-wrapper",
13334                          children: [
13335                            /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", align: "center", children: [
13336                              /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13337                                "div",
13338                                {
13339                                  className: "dataviews-title-field dataviews-view-list__title-field",
13340                                  id: labelId,
13341                                  children: renderedTitleField
13342                                }
13343                              ),
13344                              usedActions
13345                            ] }),
13346                            renderDescription && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13347                              descriptionField2.render,
13348                              {
13349                                item,
13350                                field: descriptionField2
13351                              }
13352                            ) }),
13353                            /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13354                              "div",
13355                              {
13356                                className: "dataviews-view-list__fields",
13357                                id: descriptionId,
13358                                children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13359                                  "div",
13360                                  {
13361                                    className: "dataviews-view-list__field",
13362                                    children: [
13363                                      /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13364                                        VisuallyHidden,
13365                                        {
13366                                          className: "dataviews-view-list__field-label",
13367                                          render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
13368                                          children: field.label
13369                                        }
13370                                      ),
13371                                      /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13372                                        field.render,
13373                                        {
13374                                          item,
13375                                          field
13376                                        }
13377                                      ) })
13378                                    ]
13379                                  },
13380                                  field.id
13381                                ))
13382                              }
13383                            )
13384                          ]
13385                        }
13386                      )
13387                    ]
13388                  }
13389                )
13390              ]
13391            }
13392          )
13393        }
13394      );
13395    }
13396    function isDefined2(item) {
13397      return !!item;
13398    }
13399    function ViewList(props) {
13400      const {
13401        actions,
13402        data,
13403        fields,
13404        getItemId,
13405        isLoading,
13406        onChangeSelection,
13407        selection,
13408        view,
13409        className,
13410        empty
13411      } = props;
13412      const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13413      const isDelayedLoading = useDelayedLoading(!!isLoading);
13414      const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
13415      const selectedItem = data?.findLast(
13416        (item) => selection.includes(getItemId(item))
13417      );
13418      const titleField = fields.find((field) => field.id === view.titleField);
13419      const mediaField = fields.find((field) => field.id === view.mediaField);
13420      const descriptionField2 = fields.find(
13421        (field) => field.id === view.descriptionField
13422      );
13423      const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13424      const onSelect = (item) => onChangeSelection([getItemId(item)]);
13425      const generateCompositeItemIdPrefix = (0, import_element33.useCallback)(
13426        (item) => `$baseId}-$getItemId(item)}`,
13427        [baseId, getItemId]
13428      );
13429      const isActiveCompositeItem = (0, import_element33.useCallback)(
13430        (item, idToCheck) => {
13431          return idToCheck.startsWith(
13432            generateCompositeItemIdPrefix(item)
13433          );
13434        },
13435        [generateCompositeItemIdPrefix]
13436      );
13437      const [activeCompositeId, setActiveCompositeId] = (0, import_element33.useState)(void 0);
13438      const compositeRef = (0, import_element33.useRef)(null);
13439      (0, import_element33.useEffect)(() => {
13440        if (selectedItem) {
13441          setActiveCompositeId(
13442            generateItemWrapperCompositeId(
13443              generateCompositeItemIdPrefix(selectedItem)
13444            )
13445          );
13446        }
13447      }, [selectedItem, generateCompositeItemIdPrefix]);
13448      const activeItemIndex = data.findIndex(
13449        (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13450      );
13451      const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13452      const isActiveIdInList = activeItemIndex !== -1;
13453      const selectCompositeItem = (0, import_element33.useCallback)(
13454        (targetIndex, generateCompositeId) => {
13455          const clampedIndex = Math.min(
13456            data.length - 1,
13457            Math.max(0, targetIndex)
13458          );
13459          if (!data[clampedIndex]) {
13460            return;
13461          }
13462          const itemIdPrefix = generateCompositeItemIdPrefix(
13463            data[clampedIndex]
13464          );
13465          const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13466          setActiveCompositeId(targetCompositeItemId);
13467          if (compositeRef.current?.contains(
13468            compositeRef.current.ownerDocument.activeElement
13469          )) {
13470            document.getElementById(targetCompositeItemId)?.focus();
13471          }
13472        },
13473        [data, generateCompositeItemIdPrefix]
13474      );
13475      (0, import_element33.useEffect)(() => {
13476        const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13477        if (!isActiveIdInList && wasActiveIdInList) {
13478          selectCompositeItem(
13479            previousActiveItemIndex,
13480            generateItemWrapperCompositeId
13481          );
13482        }
13483      }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13484      const onDropdownTriggerKeyDown = (0, import_element33.useCallback)(
13485        (event) => {
13486          if (event.key === "ArrowDown") {
13487            event.preventDefault();
13488            selectCompositeItem(
13489              activeItemIndex + 1,
13490              generateDropdownTriggerCompositeId
13491            );
13492          }
13493          if (event.key === "ArrowUp") {
13494            event.preventDefault();
13495            selectCompositeItem(
13496              activeItemIndex - 1,
13497              generateDropdownTriggerCompositeId
13498            );
13499          }
13500        },
13501        [selectCompositeItem, activeItemIndex]
13502      );
13503      const hasData = !!data?.length;
13504      const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13505      const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13506      const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13507      const hasMoreItems = isInfiniteScroll && (view.startPosition ?? 1) + (view.perPage ?? 0) < paginationInfo.totalItems;
13508      const listClassName = clsx_default("dataviews-view-list", className, {
13509        [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(view.layout.density),
13510        "is-refreshing": !isInfiniteScroll && isDelayedLoading
13511      });
13512      const compositeProps = {
13513        ref: compositeRef,
13514        id: baseId,
13515        render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13516        activeId: activeCompositeId,
13517        setActiveId: setActiveCompositeId,
13518        inert: !isInfiniteScroll && !!isLoading ? "true" : void 0
13519      };
13520      if (!hasData) {
13521        return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13522          "div",
13523          {
13524            className: clsx_default("dataviews-no-results", {
13525              "is-refreshing": isDelayedLoading
13526            }),
13527            children: empty
13528          }
13529        );
13530      }
13531      if (hasData && groupField && dataByGroup) {
13532        return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13533          import_components10.Composite,
13534          {
13535            ...compositeProps,
13536            className: "dataviews-view-list__group",
13537            role: "grid",
13538            children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Stack, { direction: "column", gap: "lg", className: listClassName, children: Array.from(dataByGroup.entries()).map(
13539              ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "column", children: [
13540                /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n20.sprintf)(
13541                  // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13542                  (0, import_i18n20.__)("%1$s: %2$s"),
13543                  groupField.label,
13544                  groupName
13545                ) }),
13546                groupItems.map((item) => {
13547                  const id = generateCompositeItemIdPrefix(item);
13548                  return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13549                    ListItem,
13550                    {
13551                      view,
13552                      idPrefix: id,
13553                      actions,
13554                      item,
13555                      isSelected: item === selectedItem,
13556                      onSelect,
13557                      mediaField,
13558                      titleField,
13559                      descriptionField: descriptionField2,
13560                      otherFields,
13561                      onDropdownTriggerKeyDown
13562                    },
13563                    id
13564                  );
13565                })
13566              ] }, groupName)
13567            ) })
13568          }
13569        );
13570      }
13571      return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
13572        /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13573          import_components10.Composite,
13574          {
13575            ...compositeProps,
13576            className: listClassName,
13577            role: view.infiniteScrollEnabled ? "feed" : "grid",
13578            children: data.map((item, index2) => {
13579              const id = generateCompositeItemIdPrefix(item);
13580              return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13581                ListItem,
13582                {
13583                  view,
13584                  idPrefix: id,
13585                  actions,
13586                  item,
13587                  isSelected: item === selectedItem,
13588                  onSelect,
13589                  mediaField,
13590                  titleField,
13591                  descriptionField: descriptionField2,
13592                  otherFields,
13593                  onDropdownTriggerKeyDown,
13594                  posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13595                },
13596                id
13597              );
13598            })
13599          }
13600        ),
13601        (hasMoreItems || isInfiniteScroll && isLoading) && // Keep the spinner's height reserved while loading more so the
13602        // scroll position doesn't bounce. Hidden, and silent to a11y,
13603        // while idle.
13604        /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13605          "p",
13606          {
13607            className: "dataviews-loading-more",
13608            "aria-hidden": !isLoading,
13609            children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components10.Spinner, {})
13610          }
13611        )
13612      ] });
13613    }
13614  
13615    // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13616    var import_components11 = __toESM(require_components(), 1);
13617  
13618    // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13619    var import_i18n21 = __toESM(require_i18n(), 1);
13620    var import_element34 = __toESM(require_element(), 1);
13621    var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13622    function ActivityGroup({
13623      groupName,
13624      groupData,
13625      groupField,
13626      showLabel = true,
13627      children
13628    }) {
13629      const groupHeader = showLabel ? (0, import_element34.createInterpolateElement)(
13630        // translators: %s: The label of the field e.g. "Status".
13631        (0, import_i18n21.sprintf)((0, import_i18n21.__)("%s: <groupName />"), groupField.label).trim(),
13632        {
13633          groupName: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13634            groupField.render,
13635            {
13636              item: groupData[0],
13637              field: groupField
13638            }
13639          )
13640        }
13641      ) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(groupField.render, { item: groupData[0], field: groupField });
13642      return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13643        Stack,
13644        {
13645          direction: "column",
13646          className: "dataviews-view-activity__group",
13647          children: [
13648            /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13649            children
13650          ]
13651        },
13652        groupName
13653      );
13654    }
13655  
13656    // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13657    var import_element35 = __toESM(require_element(), 1);
13658    var import_data5 = __toESM(require_data(), 1);
13659    var import_compose5 = __toESM(require_compose(), 1);
13660    var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13661    function ActivityItem(props) {
13662      const {
13663        view,
13664        actions,
13665        item,
13666        titleField,
13667        mediaField,
13668        descriptionField: descriptionField2,
13669        otherFields,
13670        posinset,
13671        onClickItem,
13672        renderItemLink,
13673        isItemClickable: isItemClickable2
13674      } = props;
13675      const {
13676        showTitle = true,
13677        showMedia = true,
13678        showDescription = true,
13679        infiniteScrollEnabled
13680      } = view;
13681      const itemRef = (0, import_element35.useRef)(null);
13682      const registry = (0, import_data5.useRegistry)();
13683      const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
13684      const { primaryActions, eligibleActions } = (0, import_element35.useMemo)(() => {
13685        const _eligibleActions = actions.filter(
13686          (action) => !action.isEligible || action.isEligible(item)
13687        );
13688        const _primaryActions = _eligibleActions.filter(
13689          (action) => action.isPrimary
13690        );
13691        return {
13692          primaryActions: _primaryActions,
13693          eligibleActions: _eligibleActions
13694        };
13695      }, [actions, item]);
13696      const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13697      const density = view.layout?.density ?? "balanced";
13698      const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13699        mediaField.render,
13700        {
13701          item,
13702          field: mediaField,
13703          config: {
13704            sizes: density === "comfortable" ? "32px" : "24px"
13705          }
13706        }
13707      ) : null;
13708      const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13709        "span",
13710        {
13711          className: "dataviews-view-activity__item-bullet",
13712          "aria-hidden": "true"
13713        }
13714      ) });
13715      const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(titleField.render, { item, field: titleField }) : null;
13716      const verticalGap = (0, import_element35.useMemo)(() => {
13717        switch (density) {
13718          case "comfortable":
13719            return "md";
13720          default:
13721            return "sm";
13722        }
13723      }, [density]);
13724      return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13725        "div",
13726        {
13727          ref: itemRef,
13728          role: infiniteScrollEnabled ? "article" : void 0,
13729          "aria-posinset": posinset,
13730          "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13731          className: clsx_default(
13732            "dataviews-view-activity__item",
13733            density === "compact" && "is-compact",
13734            density === "balanced" && "is-balanced",
13735            density === "comfortable" && "is-comfortable"
13736          ),
13737          children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13738            /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13739              Stack,
13740              {
13741                direction: "column",
13742                gap: "xs",
13743                align: "center",
13744                className: "dataviews-view-activity__item-type",
13745                children: renderedMediaField
13746              }
13747            ),
13748            /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13749              Stack,
13750              {
13751                direction: "column",
13752                gap: verticalGap,
13753                align: "flex-start",
13754                className: "dataviews-view-activity__item-content",
13755                children: [
13756                  renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13757                    ItemClickWrapper,
13758                    {
13759                      item,
13760                      isItemClickable: isItemClickable2,
13761                      onClickItem,
13762                      renderItemLink,
13763                      className: "dataviews-view-activity__item-title",
13764                      children: renderedTitleField
13765                    }
13766                  ),
13767                  showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13768                    descriptionField2.render,
13769                    {
13770                      item,
13771                      field: descriptionField2
13772                    }
13773                  ) }),
13774                  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13775                    "div",
13776                    {
13777                      className: "dataviews-view-activity__item-field",
13778                      children: [
13779                        /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13780                          VisuallyHidden,
13781                          {
13782                            className: "dataviews-view-activity__item-field-label",
13783                            render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", {}),
13784                            children: field.label
13785                          }
13786                        ),
13787                        /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13788                          field.render,
13789                          {
13790                            item,
13791                            field
13792                          }
13793                        ) })
13794                      ]
13795                    },
13796                    field.id
13797                  )) }),
13798                  !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13799                    PrimaryActions,
13800                    {
13801                      item,
13802                      actions: primaryActions,
13803                      registry,
13804                      buttonVariant: "secondary"
13805                    }
13806                  )
13807                ]
13808              }
13809            ),
13810            (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13811            // there if there are any actions at all.
13812            isMobileViewport && // At the same time, only show the menu if there are actions to show.
13813            eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13814              ItemActions,
13815              {
13816                item,
13817                actions: eligibleActions,
13818                isCompact: true
13819              }
13820            ) })
13821          ] })
13822        }
13823      );
13824    }
13825    var activity_item_default = ActivityItem;
13826  
13827    // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13828    var import_react6 = __toESM(require_react(), 1);
13829    function isDefined3(item) {
13830      return !!item;
13831    }
13832    function ActivityItems(props) {
13833      const { data, fields, getItemId, view } = props;
13834      const titleField = fields.find((field) => field.id === view.titleField);
13835      const mediaField = fields.find((field) => field.id === view.mediaField);
13836      const descriptionField2 = fields.find(
13837        (field) => field.id === view.descriptionField
13838      );
13839      const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13840      return data.map((item, index2) => {
13841        return /* @__PURE__ */ (0, import_react6.createElement)(
13842          activity_item_default,
13843          {
13844            ...props,
13845            key: getItemId(item),
13846            item,
13847            mediaField,
13848            titleField,
13849            descriptionField: descriptionField2,
13850            otherFields,
13851            posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13852          }
13853        );
13854      });
13855    }
13856  
13857    // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13858    var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13859    function ViewActivity(props) {
13860      const { empty, data, fields, isLoading, view, className } = props;
13861      const isDelayedLoading = useDelayedLoading(!!isLoading);
13862      const hasData = !!data?.length;
13863      const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13864      const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13865      const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13866      if (!hasData) {
13867        return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13868          "div",
13869          {
13870            className: clsx_default("dataviews-no-results", {
13871              "is-refreshing": isDelayedLoading
13872            }),
13873            children: empty
13874          }
13875        );
13876      }
13877      const isInert = !isInfiniteScroll && !!isLoading;
13878      const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13879        "is-refreshing": !isInfiniteScroll && isDelayedLoading
13880      });
13881      const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13882      if (hasData && groupField && dataByGroup) {
13883        return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13884          Stack,
13885          {
13886            direction: "column",
13887            gap: "sm",
13888            className: wrapperClassName,
13889            inert: isInert ? "true" : void 0,
13890            children: groupedEntries.map(
13891              ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13892                ActivityGroup,
13893                {
13894                  groupName,
13895                  groupData,
13896                  groupField,
13897                  showLabel: view.groupBy?.showLabel !== false,
13898                  children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13899                    ActivityItems,
13900                    {
13901                      ...props,
13902                      data: groupData
13903                    }
13904                  )
13905                },
13906                groupName
13907              )
13908            )
13909          }
13910        );
13911      }
13912      return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
13913        /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13914          "div",
13915          {
13916            className: wrapperClassName,
13917            role: view.infiniteScrollEnabled ? "feed" : void 0,
13918            inert: isInert ? "true" : void 0,
13919            children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ActivityItems, { ...props })
13920          }
13921        ),
13922        isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components11.Spinner, {}) })
13923      ] });
13924    }
13925  
13926    // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13927    var import_components14 = __toESM(require_components(), 1);
13928    var import_i18n24 = __toESM(require_i18n(), 1);
13929    var import_compose6 = __toESM(require_compose(), 1);
13930    var import_element38 = __toESM(require_element(), 1);
13931  
13932    // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13933    var import_components13 = __toESM(require_components(), 1);
13934    var import_data6 = __toESM(require_data(), 1);
13935    var import_element37 = __toESM(require_element(), 1);
13936    var import_i18n23 = __toESM(require_i18n(), 1);
13937  
13938    // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13939    var import_components12 = __toESM(require_components(), 1);
13940    var import_element36 = __toESM(require_element(), 1);
13941    var import_i18n22 = __toESM(require_i18n(), 1);
13942    var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13943    function hasPaginationControls(view, paginationInfo) {
13944      return !view.infiniteScrollEnabled && paginationInfo.totalItems > 0 && paginationInfo.totalPages > 1;
13945    }
13946    function DataViewsPagination() {
13947      const { view, onChangeView, paginationInfo } = (0, import_element36.useContext)(dataviews_context_default);
13948      if (!hasPaginationControls(view, paginationInfo)) {
13949        return null;
13950      }
13951      const { totalPages } = paginationInfo;
13952      const currentPage = view.page ?? 1;
13953      const pageSelectOptions = Array.from(Array(totalPages)).map(
13954        (_, i2) => {
13955          const page = i2 + 1;
13956          return {
13957            value: page.toString(),
13958            label: page.toString(),
13959            "aria-label": currentPage === page ? (0, import_i18n22.sprintf)(
13960              // translators: 1: current page number. 2: total number of pages.
13961              (0, import_i18n22.__)("Page %1$d of %2$d"),
13962              currentPage,
13963              totalPages
13964            ) : page.toString()
13965          };
13966        }
13967      );
13968      return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
13969        Stack,
13970        {
13971          direction: "row",
13972          className: "dataviews-pagination",
13973          justify: "end",
13974          align: "center",
13975          gap: "xl",
13976          children: [
13977            /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13978              Stack,
13979              {
13980                direction: "row",
13981                justify: "flex-start",
13982                align: "center",
13983                gap: "xs",
13984                className: "dataviews-pagination__page-select",
13985                children: (0, import_element36.createInterpolateElement)(
13986                  (0, import_i18n22.sprintf)(
13987                    // translators: 1: Current page number, 2: Total number of pages.
13988                    (0, import_i18n22._x)("<div>Page</div>%1$s<div>of %2$d</div>", "paging"),
13989                    "<CurrentPage />",
13990                    totalPages
13991                  ),
13992                  {
13993                    div: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { "aria-hidden": true }),
13994                    // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13995                    CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13996                      import_components12.SelectControl,
13997                      {
13998                        "aria-label": (0, import_i18n22.__)("Current page"),
13999                        value: currentPage.toString(),
14000                        options: pageSelectOptions,
14001                        onChange: (newValue) => {
14002                          onChangeView({
14003                            ...view,
14004                            page: +newValue
14005                          });
14006                        },
14007                        size: "small",
14008                        variant: "minimal"
14009                      }
14010                    )
14011                  }
14012                )
14013              }
14014            ),
14015            /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
14016              /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14017                import_components12.Button,
14018                {
14019                  onClick: () => onChangeView({
14020                    ...view,
14021                    page: currentPage - 1
14022                  }),
14023                  disabled: currentPage === 1,
14024                  accessibleWhenDisabled: true,
14025                  label: (0, import_i18n22.__)("Previous page"),
14026                  icon: (0, import_i18n22.isRTL)() ? next_default : previous_default,
14027                  showTooltip: true,
14028                  size: "compact",
14029                  tooltipPosition: "top"
14030                }
14031              ),
14032              /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14033                import_components12.Button,
14034                {
14035                  onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
14036                  disabled: currentPage >= totalPages,
14037                  accessibleWhenDisabled: true,
14038                  label: (0, import_i18n22.__)("Next page"),
14039                  icon: (0, import_i18n22.isRTL)() ? previous_default : next_default,
14040                  showTooltip: true,
14041                  size: "compact",
14042                  tooltipPosition: "top"
14043                }
14044              )
14045            ] })
14046          ]
14047        }
14048      );
14049    }
14050    var dataviews_pagination_default = (0, import_element36.memo)(DataViewsPagination);
14051  
14052    // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
14053    var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
14054    var EMPTY_ARRAY2 = [];
14055    function useIsMultiselectPicker(actions) {
14056      return (0, import_element37.useMemo)(() => {
14057        return !!actions?.length && actions?.every((action) => action.supportsBulk);
14058      }, [actions]);
14059    }
14060    function BulkSelectionCheckbox2({
14061      selection,
14062      selectedItems,
14063      onChangeSelection,
14064      data,
14065      getItemId,
14066      disableSelectAll = false
14067    }) {
14068      const hasSelection = selection.length > 0;
14069      const areAllSelected = selectedItems.length === data.length;
14070      if (disableSelectAll) {
14071        return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14072          import_components13.CheckboxControl,
14073          {
14074            className: "dataviews-view-table-selection-checkbox",
14075            checked: hasSelection,
14076            disabled: !hasSelection,
14077            onChange: () => {
14078              onChangeSelection([]);
14079            },
14080            "aria-label": (0, import_i18n23.__)("Deselect all")
14081          }
14082        );
14083      }
14084      return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14085        import_components13.CheckboxControl,
14086        {
14087          className: "dataviews-view-table-selection-checkbox",
14088          checked: areAllSelected,
14089          indeterminate: !areAllSelected && !!selectedItems.length,
14090          onChange: () => {
14091            if (areAllSelected) {
14092              onChangeSelection(
14093                selection.filter(
14094                  (id) => !data.some(
14095                    (item) => id === getItemId(item)
14096                  )
14097                )
14098              );
14099            } else {
14100              const selectionSet = /* @__PURE__ */ new Set([
14101                ...selection,
14102                ...data.map((item) => getItemId(item))
14103              ]);
14104              onChangeSelection(Array.from(selectionSet));
14105            }
14106          },
14107          "aria-label": areAllSelected ? (0, import_i18n23.__)("Deselect all") : (0, import_i18n23.__)("Select all")
14108        }
14109      );
14110    }
14111    function ActionButtons({
14112      actions,
14113      items,
14114      selection
14115    }) {
14116      const registry = (0, import_data6.useRegistry)();
14117      const [actionInProgress, setActionInProgress] = (0, import_element37.useState)(
14118        null
14119      );
14120      return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Stack, { direction: "row", gap: "xs", children: actions.map((action) => {
14121        if (!("callback" in action)) {
14122          return null;
14123        }
14124        const { id, label, icon, isPrimary, callback } = action;
14125        const _label = typeof label === "string" ? label : label(items);
14126        const variant = isPrimary ? "primary" : "tertiary";
14127        const isInProgress = id === actionInProgress;
14128        return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14129          import_components13.Button,
14130          {
14131            accessibleWhenDisabled: true,
14132            icon,
14133            disabled: isInProgress || !selection?.length,
14134            isBusy: isInProgress,
14135            onClick: async () => {
14136              setActionInProgress(id);
14137              await callback(items, {
14138                registry
14139              });
14140              setActionInProgress(null);
14141            },
14142            size: "compact",
14143            variant,
14144            children: _label
14145          },
14146          id
14147        );
14148      }) });
14149    }
14150    function PickerBulkSelectionInfo() {
14151      const {
14152        data,
14153        selection,
14154        onChangeSelection,
14155        getItemId,
14156        actions = EMPTY_ARRAY2,
14157        paginationInfo,
14158        view
14159      } = (0, import_element37.useContext)(dataviews_context_default);
14160      const isMultiselect = useIsMultiselectPicker(actions);
14161      const selectedItems = (0, import_element37.useMemo)(
14162        () => data.filter((item) => selection.includes(getItemId(item))),
14163        [selection, getItemId, data]
14164      );
14165      if (!actions.length) {
14166        return null;
14167      }
14168      const message2 = getFooterMessage(
14169        selection.length,
14170        data.length,
14171        paginationInfo.totalItems,
14172        !!view.infiniteScrollEnabled
14173      );
14174      return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14175        Stack,
14176        {
14177          direction: "row",
14178          className: "dataviews-picker-footer__bulk-selection",
14179          gap: "md",
14180          align: "center",
14181          children: [
14182            isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14183              BulkSelectionCheckbox2,
14184              {
14185                selection,
14186                selectedItems,
14187                onChangeSelection,
14188                data,
14189                getItemId,
14190                disableSelectAll: !!view.infiniteScrollEnabled
14191              }
14192            ),
14193            /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 })
14194          ]
14195        }
14196      );
14197    }
14198    function PickerActions() {
14199      const {
14200        data,
14201        selection,
14202        getItemId,
14203        actions = EMPTY_ARRAY2
14204      } = (0, import_element37.useContext)(dataviews_context_default);
14205      const selectedItems = (0, import_element37.useMemo)(
14206        () => data.filter((item) => selection.includes(getItemId(item))),
14207        [selection, getItemId, data]
14208      );
14209      if (!actions.length) {
14210        return null;
14211      }
14212      return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-picker-footer__actions", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14213        ActionButtons,
14214        {
14215          actions,
14216          items: selectedItems,
14217          selection
14218        }
14219      ) });
14220    }
14221    function DataViewsPickerBulkActionToolbar() {
14222      return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "row", gap: "md", align: "center", children: [
14223        /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerBulkSelectionInfo, {}),
14224        /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerActions, {})
14225      ] });
14226    }
14227    function DataViewsPickerFooter() {
14228      const {
14229        actions = EMPTY_ARRAY2,
14230        paginationInfo,
14231        view
14232      } = (0, import_element37.useContext)(dataviews_context_default);
14233      const hasPagination = !view.infiniteScrollEnabled && !!paginationInfo.totalItems && paginationInfo.totalPages > 1;
14234      if (!actions.length && !hasPagination) {
14235        return null;
14236      }
14237      return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14238        Stack,
14239        {
14240          direction: "row",
14241          justify: "space-between",
14242          align: "center",
14243          className: "dataviews-footer",
14244          gap: "sm",
14245          children: [
14246            /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerBulkSelectionInfo, {}),
14247            /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(dataviews_pagination_default, {}),
14248            /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerActions, {})
14249          ]
14250        }
14251      );
14252    }
14253  
14254    // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
14255    var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14256    var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
14257    function GridItem3({
14258      view,
14259      multiselect,
14260      selection,
14261      onChangeSelection,
14262      getItemId,
14263      item,
14264      mediaField,
14265      titleField,
14266      descriptionField: descriptionField2,
14267      regularFields,
14268      badgeFields,
14269      config,
14270      posinset,
14271      setsize
14272    }) {
14273      const { showTitle = true, showMedia = true, showDescription = true } = view;
14274      const id = getItemId(item);
14275      const elementRef = (0, import_element38.useRef)(null);
14276      const isSelected2 = selection.includes(id);
14277      useIntersectionObserver(elementRef, posinset);
14278      const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14279        mediaField.render,
14280        {
14281          item,
14282          field: mediaField,
14283          config
14284        }
14285      ) : null;
14286      const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(titleField.render, { item, field: titleField }) : null;
14287      return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14288        import_components14.Composite.Item,
14289        {
14290          ref: elementRef,
14291          "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n24.__)("(no title)") : void 0,
14292          render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Stack, { direction: "column", children, ...props }),
14293          role: "option",
14294          "aria-posinset": posinset,
14295          "aria-setsize": setsize,
14296          className: clsx_default("dataviews-view-picker-grid__card", {
14297            "is-selected": isSelected2
14298          }),
14299          "aria-selected": isSelected2,
14300          onClick: () => {
14301            if (isSelected2) {
14302              onChangeSelection(
14303                selection.filter((itemId) => id !== itemId)
14304              );
14305            } else {
14306              const newSelection = multiselect ? [...selection, id] : [id];
14307              onChangeSelection(newSelection);
14308            }
14309          },
14310          children: [
14311            showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
14312            showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14313              DataViewsSelectionCheckbox,
14314              {
14315                item,
14316                selection,
14317                onChangeSelection,
14318                getItemId,
14319                titleField,
14320                disabled: false,
14321                "aria-hidden": true,
14322                tabIndex: -1
14323              }
14324            ),
14325            showTitle && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14326              Stack,
14327              {
14328                direction: "row",
14329                justify: "space-between",
14330                className: "dataviews-view-picker-grid__title-actions",
14331                children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
14332              }
14333            ),
14334            /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14335              showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14336                descriptionField2.render,
14337                {
14338                  item,
14339                  field: descriptionField2
14340                }
14341              ),
14342              !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14343                Stack,
14344                {
14345                  direction: "row",
14346                  className: "dataviews-view-picker-grid__badge-fields",
14347                  gap: "sm",
14348                  wrap: "wrap",
14349                  align: "top",
14350                  justify: "flex-start",
14351                  children: badgeFields.map((field) => {
14352                    return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14353                      WCBadge2,
14354                      {
14355                        className: "dataviews-view-picker-grid__field-value",
14356                        children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14357                          field.render,
14358                          {
14359                            item,
14360                            field
14361                          }
14362                        )
14363                      },
14364                      field.id
14365                    );
14366                  })
14367                }
14368              ),
14369              !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14370                Stack,
14371                {
14372                  direction: "column",
14373                  className: "dataviews-view-picker-grid__fields",
14374                  gap: "xs",
14375                  children: regularFields.map((field) => {
14376                    return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14377                      import_components14.Flex,
14378                      {
14379                        className: "dataviews-view-picker-grid__field",
14380                        gap: 1,
14381                        justify: "flex-start",
14382                        expanded: true,
14383                        style: { height: "auto" },
14384                        direction: "row",
14385                        children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14386                          /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
14387                          /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14388                            import_components14.FlexItem,
14389                            {
14390                              className: "dataviews-view-picker-grid__field-value",
14391                              style: { maxHeight: "none" },
14392                              children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14393                                field.render,
14394                                {
14395                                  item,
14396                                  field
14397                                }
14398                              )
14399                            }
14400                          )
14401                        ] })
14402                      },
14403                      field.id
14404                    );
14405                  })
14406                }
14407              )
14408            ] })
14409          ]
14410        },
14411        id
14412      );
14413    }
14414    function GridGroup({
14415      groupName,
14416      groupField,
14417      showLabel = true,
14418      children
14419    }) {
14420      const headerId = (0, import_compose6.useInstanceId)(
14421        GridGroup,
14422        "dataviews-view-picker-grid-group__header"
14423      );
14424      return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14425        Stack,
14426        {
14427          direction: "column",
14428          gap: "sm",
14429          role: "group",
14430          "aria-labelledby": headerId,
14431          children: [
14432            /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14433              "h3",
14434              {
14435                className: "dataviews-view-picker-grid-group__header",
14436                id: headerId,
14437                children: showLabel ? (0, import_i18n24.sprintf)(
14438                  // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14439                  (0, import_i18n24.__)("%1$s: %2$s"),
14440                  groupField.label,
14441                  groupName
14442                ) : groupName
14443              }
14444            ),
14445            children
14446          ]
14447        },
14448        groupName
14449      );
14450    }
14451    function ViewPickerGrid({
14452      actions,
14453      data,
14454      fields,
14455      getItemId,
14456      isLoading,
14457      onChangeSelection,
14458      selection,
14459      view,
14460      className,
14461      empty
14462    }) {
14463      const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element38.useContext)(dataviews_context_default);
14464      const titleField = fields.find(
14465        (field) => field.id === view?.titleField
14466      );
14467      const mediaField = fields.find(
14468        (field) => field.id === view?.mediaField
14469      );
14470      const descriptionField2 = fields.find(
14471        (field) => field.id === view?.descriptionField
14472      );
14473      const otherFields = view.fields ?? [];
14474      const { regularFields, badgeFields } = otherFields.reduce(
14475        (accumulator, fieldId) => {
14476          const field = fields.find((f2) => f2.id === fieldId);
14477          if (!field) {
14478            return accumulator;
14479          }
14480          const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14481          accumulator[key].push(field);
14482          return accumulator;
14483        },
14484        { regularFields: [], badgeFields: [] }
14485      );
14486      const hasData = !!data?.length;
14487      const usedPreviewSize = view.layout?.previewSize;
14488      const isMultiselect = useIsMultiselectPicker(actions);
14489      const size4 = "900px";
14490      const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14491      const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14492      const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14493      const currentPage = view?.page ?? 1;
14494      const perPage = view?.perPage ?? 0;
14495      const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14496      const gridColumns = useGridColumns();
14497      const placeholdersNeeded = usePlaceholdersNeeded(
14498        data,
14499        isInfiniteScroll,
14500        gridColumns
14501      );
14502      return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, {
14503        // Render multiple groups.
14504        children: [
14505          hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14506            import_components14.Composite,
14507            {
14508              virtualFocus: true,
14509              orientation: "horizontal",
14510              role: "listbox",
14511              "aria-multiselectable": isMultiselect,
14512              className: clsx_default(
14513                "dataviews-view-picker-grid",
14514                className,
14515                {
14516                  [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14517                    view.layout.density
14518                  )
14519                }
14520              ),
14521              "aria-label": itemListLabel,
14522              render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14523                Stack,
14524                {
14525                  direction: "column",
14526                  gap: "lg",
14527                  children,
14528                  ...props
14529                }
14530              ),
14531              children: Array.from(dataByGroup.entries()).map(
14532                ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14533                  GridGroup,
14534                  {
14535                    groupName,
14536                    groupField,
14537                    showLabel: view.groupBy?.showLabel !== false,
14538                    children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14539                      GridItems,
14540                      {
14541                        previewSize: usedPreviewSize,
14542                        style: {
14543                          gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax($usedPreviewSize}px, 1fr))`
14544                        },
14545                        "aria-busy": isLoading,
14546                        ref: resizeObserverRef,
14547                        children: groupItems.map((item) => {
14548                          const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14549                          return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14550                            GridItem3,
14551                            {
14552                              view,
14553                              multiselect: isMultiselect,
14554                              selection,
14555                              onChangeSelection,
14556                              getItemId,
14557                              item,
14558                              mediaField,
14559                              titleField,
14560                              descriptionField: descriptionField2,
14561                              regularFields,
14562                              badgeFields,
14563                              config: {
14564                                sizes: size4
14565                              },
14566                              posinset: posInSet,
14567                              setsize: setSize
14568                            },
14569                            getItemId(item)
14570                          );
14571                        })
14572                      }
14573                    )
14574                  },
14575                  groupName
14576                )
14577              )
14578            }
14579          ),
14580          // Render a single grid with all data.
14581          hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14582            import_components14.Composite,
14583            {
14584              render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14585                GridItems,
14586                {
14587                  className: clsx_default(
14588                    "dataviews-view-picker-grid",
14589                    className,
14590                    {
14591                      [`has-$view.layout?.density}-density`]: view.layout?.density && [
14592                        "compact",
14593                        "comfortable"
14594                      ].includes(view.layout.density)
14595                    }
14596                  ),
14597                  previewSize: usedPreviewSize,
14598                  "aria-busy": isLoading,
14599                  ref: resizeObserverRef
14600                }
14601              ),
14602              virtualFocus: true,
14603              orientation: "horizontal",
14604              role: "listbox",
14605              "aria-multiselectable": isMultiselect,
14606              "aria-label": itemListLabel,
14607              children: [
14608                Array.from({ length: placeholdersNeeded }).map(
14609                  (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14610                    import_components14.Composite.Item,
14611                    {
14612                      render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14613                        Stack,
14614                        {
14615                          direction: "column",
14616                          children,
14617                          ...props
14618                        }
14619                      ),
14620                      role: "option",
14621                      "aria-hidden": true,
14622                      tabIndex: -1,
14623                      className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14624                    },
14625                    `placeholder-$index2}`
14626                  )
14627                ),
14628                data.map((item) => {
14629                  const posinset = item.position;
14630                  return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14631                    GridItem3,
14632                    {
14633                      view,
14634                      multiselect: isMultiselect,
14635                      selection,
14636                      onChangeSelection,
14637                      getItemId,
14638                      item,
14639                      mediaField,
14640                      titleField,
14641                      descriptionField: descriptionField2,
14642                      regularFields,
14643                      badgeFields,
14644                      config: {
14645                        sizes: size4
14646                      },
14647                      posinset,
14648                      setsize: setSize
14649                    },
14650                    getItemId(item)
14651                  );
14652                })
14653              ]
14654            }
14655          ),
14656          // Render empty state.
14657          !hasData && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14658            "div",
14659            {
14660              className: clsx_default({
14661                "dataviews-loading": isLoading,
14662                "dataviews-no-results": !isLoading
14663              }),
14664              children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) }) : empty
14665            }
14666          ),
14667          hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) })
14668        ]
14669      });
14670    }
14671    var picker_grid_default = ViewPickerGrid;
14672  
14673    // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14674    var import_i18n25 = __toESM(require_i18n(), 1);
14675    var import_components15 = __toESM(require_components(), 1);
14676    var import_element39 = __toESM(require_element(), 1);
14677    var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14678    function TableColumnField2({
14679      item,
14680      fields,
14681      column,
14682      align
14683    }) {
14684      const field = fields.find((f2) => f2.id === column);
14685      if (!field) {
14686        return null;
14687      }
14688      const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14689        "dataviews-view-table__cell-align-end": align === "end",
14690        "dataviews-view-table__cell-align-center": align === "center"
14691      });
14692      return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(field.render, { item, field }) });
14693    }
14694    function TableRow2({
14695      item,
14696      fields,
14697      id,
14698      view,
14699      titleField,
14700      mediaField,
14701      descriptionField: descriptionField2,
14702      selection,
14703      getItemId,
14704      onChangeSelection,
14705      multiselect,
14706      posinset
14707    }) {
14708      const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
14709      const isSelected2 = selection.includes(id);
14710      const [isHovered, setIsHovered] = (0, import_element39.useState)(false);
14711      const elementRef = (0, import_element39.useRef)(null);
14712      useIntersectionObserver(elementRef, posinset);
14713      const {
14714        showTitle = true,
14715        showMedia = true,
14716        showDescription = true,
14717        infiniteScrollEnabled
14718      } = view;
14719      const handleMouseEnter = () => {
14720        setIsHovered(true);
14721      };
14722      const handleMouseLeave = () => {
14723        setIsHovered(false);
14724      };
14725      const columns = view.fields ?? [];
14726      const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
14727      return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14728        import_components15.Composite.Item,
14729        {
14730          ref: elementRef,
14731          render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14732            "tr",
14733            {
14734              className: clsx_default("dataviews-view-table__row", {
14735                "is-selected": isSelected2,
14736                "is-hovered": isHovered
14737              }),
14738              onMouseEnter: handleMouseEnter,
14739              onMouseLeave: handleMouseLeave,
14740              children,
14741              ...props
14742            }
14743          ),
14744          "aria-selected": isSelected2,
14745          "aria-setsize": paginationInfo.totalItems || void 0,
14746          "aria-posinset": posinset,
14747          role: infiniteScrollEnabled ? "article" : "option",
14748          onMouseDown: (event) => {
14749            if (event.button !== 0) {
14750              return;
14751            }
14752            event.currentTarget.parentElement?.focus({
14753              preventScroll: true
14754            });
14755          },
14756          onClick: () => {
14757            if (isSelected2) {
14758              onChangeSelection(
14759                selection.filter((itemId) => id !== itemId)
14760              );
14761            } else {
14762              const newSelection = multiselect ? [...selection, id] : [id];
14763              onChangeSelection(newSelection);
14764            }
14765          },
14766          children: [
14767            /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14768              "td",
14769              {
14770                className: "dataviews-view-table__checkbox-column",
14771                role: "presentation",
14772                children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14773                  DataViewsSelectionCheckbox,
14774                  {
14775                    item,
14776                    selection,
14777                    onChangeSelection,
14778                    getItemId,
14779                    titleField,
14780                    disabled: false,
14781                    "aria-hidden": true,
14782                    tabIndex: -1
14783                  }
14784                ) })
14785              }
14786            ),
14787            hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14788              "td",
14789              {
14790                role: "presentation",
14791                children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14792                  column_primary_default,
14793                  {
14794                    item,
14795                    titleField: showTitle ? titleField : void 0,
14796                    mediaField: showMedia ? mediaField : void 0,
14797                    descriptionField: showDescription ? descriptionField2 : void 0,
14798                    isItemClickable: () => false
14799                  }
14800                )
14801              }
14802            ),
14803            columns.map((column) => {
14804              const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14805              return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14806                "td",
14807                {
14808                  style: {
14809                    width,
14810                    maxWidth,
14811                    minWidth
14812                  },
14813                  role: "presentation",
14814                  children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14815                    TableColumnField2,
14816                    {
14817                      fields,
14818                      item,
14819                      column,
14820                      align
14821                    }
14822                  )
14823                },
14824                column
14825              );
14826            })
14827          ]
14828        },
14829        id
14830      );
14831    }
14832    function ViewPickerTable({
14833      actions,
14834      data,
14835      fields,
14836      getItemId,
14837      isLoading = false,
14838      onChangeView,
14839      onChangeSelection,
14840      selection,
14841      setOpenedFilter,
14842      view,
14843      className,
14844      empty
14845    }) {
14846      const headerMenuRefs = (0, import_element39.useRef)(/* @__PURE__ */ new Map());
14847      const headerMenuToFocusRef = (0, import_element39.useRef)(void 0);
14848      const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element39.useState)();
14849      const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14850      (0, import_element39.useEffect)(() => {
14851        if (headerMenuToFocusRef.current) {
14852          headerMenuToFocusRef.current.focus();
14853          headerMenuToFocusRef.current = void 0;
14854        }
14855      });
14856      const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14857      const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14858      const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14859      const tableNoticeId = (0, import_element39.useId)();
14860      if (nextHeaderMenuToFocus) {
14861        headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14862        setNextHeaderMenuToFocus(void 0);
14863        return;
14864      }
14865      const onHide = (field) => {
14866        const hidden = headerMenuRefs.current.get(field.id);
14867        const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14868        setNextHeaderMenuToFocus(fallback?.node);
14869      };
14870      const hasData = !!data?.length;
14871      const titleField = fields.find((field) => field.id === view.titleField);
14872      const mediaField = fields.find((field) => field.id === view.mediaField);
14873      const descriptionField2 = fields.find(
14874        (field) => field.id === view.descriptionField
14875      );
14876      const { showTitle = true, showMedia = true, showDescription = true } = view;
14877      const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
14878      const columns = view.fields ?? [];
14879      const headerMenuRef = (column, index2) => (node) => {
14880        if (node) {
14881          headerMenuRefs.current.set(column, {
14882            node,
14883            fallback: columns[index2 > 0 ? index2 - 1 : 1]
14884          });
14885        } else {
14886          headerMenuRefs.current.delete(column);
14887        }
14888      };
14889      return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
14890        /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14891          "table",
14892          {
14893            className: clsx_default(
14894              "dataviews-view-table",
14895              "dataviews-view-picker-table",
14896              className,
14897              {
14898                [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14899                  view.layout.density
14900                )
14901              }
14902            ),
14903            "aria-busy": isLoading,
14904            "aria-describedby": tableNoticeId,
14905            role: isInfiniteScroll ? "feed" : "listbox",
14906            children: [
14907              /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14908                "tr",
14909                {
14910                  className: "dataviews-view-table__row",
14911                  role: "presentation",
14912                  children: [
14913                    /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14914                      BulkSelectionCheckbox,
14915                      {
14916                        selection,
14917                        onChangeSelection,
14918                        data,
14919                        actions,
14920                        getItemId,
14921                        disableSelectAll: isInfiniteScroll
14922                      }
14923                    ) }),
14924                    hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14925                      column_header_menu_default,
14926                      {
14927                        ref: headerMenuRef(
14928                          titleField.id,
14929                          0
14930                        ),
14931                        fieldId: titleField.id,
14932                        view,
14933                        fields,
14934                        onChangeView,
14935                        onHide,
14936                        setOpenedFilter,
14937                        canMove: false
14938                      }
14939                    ) }),
14940                    columns.map((column, index2) => {
14941                      const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14942                      return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14943                        "th",
14944                        {
14945                          style: {
14946                            width,
14947                            maxWidth,
14948                            minWidth,
14949                            textAlign: align
14950                          },
14951                          "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14952                          scope: "col",
14953                          children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14954                            column_header_menu_default,
14955                            {
14956                              ref: headerMenuRef(column, index2),
14957                              fieldId: column,
14958                              view,
14959                              fields,
14960                              onChangeView,
14961                              onHide,
14962                              setOpenedFilter,
14963                              canMove: view.layout?.enableMoving ?? true
14964                            }
14965                          )
14966                        },
14967                        column
14968                      );
14969                    })
14970                  ]
14971                }
14972              ) }),
14973              hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14974                ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14975                  import_components15.Composite,
14976                  {
14977                    virtualFocus: true,
14978                    orientation: "vertical",
14979                    render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "group" }),
14980                    children: [
14981                      /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14982                        "tr",
14983                        {
14984                          className: "dataviews-view-table__group-header-row",
14985                          role: "presentation",
14986                          children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14987                            "td",
14988                            {
14989                              colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14990                              className: "dataviews-view-table__group-header-cell",
14991                              role: "presentation",
14992                              children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n25.sprintf)(
14993                                // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14994                                (0, import_i18n25.__)("%1$s: %2$s"),
14995                                groupField.label,
14996                                groupName
14997                              )
14998                            }
14999                          )
15000                        }
15001                      ),
15002                      groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15003                        TableRow2,
15004                        {
15005                          item,
15006                          fields,
15007                          id: getItemId(item) || index2.toString(),
15008                          view,
15009                          titleField,
15010                          mediaField,
15011                          descriptionField: descriptionField2,
15012                          selection,
15013                          getItemId,
15014                          onChangeSelection,
15015                          multiselect: isMultiselect
15016                        },
15017                        getItemId(item)
15018                      ))
15019                    ]
15020                  },
15021                  `group-$groupName}`
15022                )
15023              ) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15024                import_components15.Composite,
15025                {
15026                  render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "presentation" }),
15027                  virtualFocus: true,
15028                  orientation: "vertical",
15029                  children: hasData && data.map((item, index2) => {
15030                    const itemId = getItemId(item);
15031                    const posinset = item.position;
15032                    return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15033                      TableRow2,
15034                      {
15035                        item,
15036                        fields,
15037                        id: itemId || index2.toString(),
15038                        view,
15039                        titleField,
15040                        mediaField,
15041                        descriptionField: descriptionField2,
15042                        selection,
15043                        getItemId,
15044                        onChangeSelection,
15045                        multiselect: isMultiselect,
15046                        posinset
15047                      },
15048                      itemId
15049                    );
15050                  })
15051                }
15052              )
15053            ]
15054          }
15055        ),
15056        /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
15057          "div",
15058          {
15059            className: clsx_default({
15060              "dataviews-loading": isLoading,
15061              "dataviews-no-results": !hasData && !isLoading
15062            }),
15063            id: tableNoticeId,
15064            children: [
15065              !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) }) : empty),
15066              hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) })
15067            ]
15068          }
15069        )
15070      ] });
15071    }
15072    var picker_table_default = ViewPickerTable;
15073  
15074    // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
15075    var import_components16 = __toESM(require_components(), 1);
15076    var import_element40 = __toESM(require_element(), 1);
15077    var import_compose7 = __toESM(require_compose(), 1);
15078    var import_i18n26 = __toESM(require_i18n(), 1);
15079    var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
15080    function isDefined4(item) {
15081      return !!item;
15082    }
15083    function PickerActivityItem({
15084      view,
15085      multiselect,
15086      selection,
15087      onChangeSelection,
15088      getItemId,
15089      item,
15090      titleField,
15091      mediaField,
15092      descriptionField: descriptionField2,
15093      otherFields,
15094      posinset,
15095      setsize
15096    }) {
15097      const elementRef = (0, import_element40.useRef)(null);
15098      useIntersectionObserver(elementRef, posinset);
15099      const { showTitle = true, showMedia = true, showDescription = true } = view;
15100      const id = getItemId(item);
15101      const isSelected2 = selection.includes(id);
15102      const density = view.layout?.density ?? "balanced";
15103      const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15104        mediaField.render,
15105        {
15106          item,
15107          field: mediaField,
15108          config: {
15109            sizes: density === "comfortable" ? "32px" : "24px"
15110          }
15111        }
15112      ) : null;
15113      const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15114        "span",
15115        {
15116          className: "dataviews-view-picker-activity__item-bullet",
15117          "aria-hidden": "true"
15118        }
15119      ) });
15120      const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(titleField.render, { item, field: titleField }) : null;
15121      const renderedDescriptionField = showDescription && descriptionField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(descriptionField2.render, { item, field: descriptionField2 }) : null;
15122      const verticalGap = (0, import_element40.useMemo)(() => {
15123        switch (density) {
15124          case "comfortable":
15125            return "md";
15126          default:
15127            return "sm";
15128        }
15129      }, [density]);
15130      return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15131        import_components16.Composite.Item,
15132        {
15133          ref: elementRef,
15134          role: "option",
15135          "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
15136          "aria-posinset": posinset,
15137          "aria-setsize": setsize,
15138          "aria-selected": isSelected2,
15139          className: clsx_default(
15140            "dataviews-view-picker-activity__item",
15141            density === "compact" && "is-compact",
15142            density === "balanced" && "is-balanced",
15143            density === "comfortable" && "is-comfortable",
15144            isSelected2 && "is-selected"
15145          ),
15146          onClick: () => {
15147            if (isSelected2) {
15148              onChangeSelection(
15149                selection.filter((itemId) => id !== itemId)
15150              );
15151            } else {
15152              const newSelection = multiselect ? [...selection, id] : [id];
15153              onChangeSelection(newSelection);
15154            }
15155          },
15156          render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", {}),
15157          children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
15158            /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15159              Stack,
15160              {
15161                direction: "column",
15162                gap: "xs",
15163                align: "center",
15164                className: "dataviews-view-picker-activity__item-type",
15165                children: renderedMediaField
15166              }
15167            ),
15168            /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15169              Stack,
15170              {
15171                direction: "column",
15172                gap: verticalGap,
15173                align: "flex-start",
15174                className: "dataviews-view-picker-activity__item-content",
15175                children: [
15176                  renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
15177                  renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
15178                  /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15179                    "div",
15180                    {
15181                      className: "dataviews-view-picker-activity__item-field",
15182                      children: [
15183                        /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15184                          VisuallyHidden,
15185                          {
15186                            render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", {}),
15187                            className: "dataviews-view-picker-activity__item-field-label",
15188                            children: field.label
15189                          }
15190                        ),
15191                        /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15192                          field.render,
15193                          {
15194                            item,
15195                            field
15196                          }
15197                        ) })
15198                      ]
15199                    },
15200                    field.id
15201                  )) })
15202                ]
15203              }
15204            )
15205          ] })
15206        }
15207      );
15208    }
15209    function PickerActivityGroup({
15210      groupName,
15211      groupField,
15212      showLabel = true,
15213      children
15214    }) {
15215      const headerId = (0, import_compose7.useInstanceId)(
15216        PickerActivityGroup,
15217        "dataviews-view-picker-activity-group__header"
15218      );
15219      return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15220        Stack,
15221        {
15222          direction: "column",
15223          role: "group",
15224          "aria-labelledby": headerId,
15225          className: "dataviews-view-picker-activity-group",
15226          children: [
15227            /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15228              "h3",
15229              {
15230                className: "dataviews-view-picker-activity-group__header",
15231                id: headerId,
15232                children: showLabel ? (0, import_i18n26.sprintf)(
15233                  // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15234                  (0, import_i18n26.__)("%1$s: %2$s"),
15235                  groupField.label,
15236                  groupName
15237                ) : groupName
15238              }
15239            ),
15240            children
15241          ]
15242        }
15243      );
15244    }
15245    function ViewPickerActivity({
15246      data,
15247      fields,
15248      getItemId,
15249      isLoading,
15250      onChangeSelection,
15251      selection,
15252      view,
15253      actions,
15254      className,
15255      empty
15256    }) {
15257      const { itemListLabel, paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
15258      const isMultiselect = useIsMultiselectPicker(actions);
15259      const titleField = fields.find(
15260        (field) => field.id === view?.titleField
15261      );
15262      const mediaField = fields.find(
15263        (field) => field.id === view?.mediaField
15264      );
15265      const descriptionField2 = fields.find(
15266        (field) => field.id === view?.descriptionField
15267      );
15268      const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
15269      const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
15270      const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
15271      const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
15272      const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
15273      const hasData = !!data?.length;
15274      const isGrouped = !!(groupField && dataByGroup);
15275      const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15276        PickerActivityItem,
15277        {
15278          view,
15279          multiselect: isMultiselect,
15280          selection,
15281          onChangeSelection,
15282          getItemId,
15283          item,
15284          titleField,
15285          mediaField,
15286          descriptionField: descriptionField2,
15287          otherFields,
15288          posinset: item.position,
15289          setsize
15290        },
15291        getItemId(item)
15292      );
15293      if (!hasData) {
15294        return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15295          "div",
15296          {
15297            className: clsx_default({
15298              "dataviews-loading": isLoading,
15299              "dataviews-no-results": !isLoading
15300            }),
15301            children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) }) : empty
15302          }
15303        );
15304      }
15305      return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
15306        /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15307          import_components16.Composite,
15308          {
15309            virtualFocus: true,
15310            orientation: "vertical",
15311            role: "listbox",
15312            "aria-multiselectable": isMultiselect,
15313            "aria-label": itemListLabel,
15314            "aria-busy": isLoading,
15315            render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
15316            className: clsx_default(
15317              "dataviews-view-picker-activity",
15318              className
15319            ),
15320            children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
15321              ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15322                PickerActivityGroup,
15323                {
15324                  groupName,
15325                  groupField,
15326                  showLabel: view.groupBy?.showLabel !== false,
15327                  children: groupItems.map(renderItem)
15328                },
15329                groupName
15330              )
15331            ) : data.map(renderItem)
15332          }
15333        ),
15334        isLoading && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) })
15335      ] });
15336    }
15337  
15338    // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
15339    var import_components17 = __toESM(require_components(), 1);
15340    var import_i18n27 = __toESM(require_i18n(), 1);
15341    var import_element41 = __toESM(require_element(), 1);
15342    var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
15343    function DensityPicker() {
15344      const context = (0, import_element41.useContext)(dataviews_context_default);
15345      const view = context.view;
15346      return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
15347        import_components17.__experimentalToggleGroupControl,
15348        {
15349          label: (0, import_i18n27.__)("Density"),
15350          value: view.layout?.density || "balanced",
15351          onChange: (value) => {
15352            context.onChangeView({
15353              ...view,
15354              layout: {
15355                ...view.layout,
15356                density: value
15357              }
15358            });
15359          },
15360          isBlock: true,
15361          children: [
15362            /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15363              import_components17.__experimentalToggleGroupControlOption,
15364              {
15365                value: "comfortable",
15366                label: (0, import_i18n27._x)(
15367                  "Comfortable",
15368                  "Density option for DataView layout"
15369                )
15370              },
15371              "comfortable"
15372            ),
15373            /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15374              import_components17.__experimentalToggleGroupControlOption,
15375              {
15376                value: "balanced",
15377                label: (0, import_i18n27._x)("Balanced", "Density option for DataView layout")
15378              },
15379              "balanced"
15380            ),
15381            /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15382              import_components17.__experimentalToggleGroupControlOption,
15383              {
15384                value: "compact",
15385                label: (0, import_i18n27._x)("Compact", "Density option for DataView layout")
15386              },
15387              "compact"
15388            )
15389          ]
15390        }
15391      );
15392    }
15393  
15394    // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
15395    var import_components18 = __toESM(require_components(), 1);
15396    var import_i18n28 = __toESM(require_i18n(), 1);
15397    var import_element42 = __toESM(require_element(), 1);
15398    var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15399    var imageSizes2 = [
15400      {
15401        value: 120,
15402        breakpoint: 1
15403      },
15404      {
15405        value: 170,
15406        breakpoint: 1
15407      },
15408      {
15409        value: 230,
15410        breakpoint: 1
15411      },
15412      {
15413        value: 290,
15414        breakpoint: 1112
15415        // at minimum image width, 4 images display at this container size
15416      },
15417      {
15418        value: 350,
15419        breakpoint: 1636
15420        // at minimum image width, 6 images display at this container size
15421      },
15422      {
15423        value: 430,
15424        breakpoint: 588
15425        // at minimum image width, 2 images display at this container size
15426      }
15427    ];
15428    function PreviewSizePicker() {
15429      const context = (0, import_element42.useContext)(dataviews_context_default);
15430      const view = context.view;
15431      const breakValues = imageSizes2.filter((size4) => {
15432        return context.containerWidth >= size4.breakpoint;
15433      });
15434      const layoutPreviewSize = view.layout?.previewSize ?? 230;
15435      const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
15436      const marks = breakValues.map((size4, index2) => {
15437        return {
15438          value: index2
15439        };
15440      });
15441      return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
15442        import_components18.RangeControl,
15443        {
15444          showTooltip: false,
15445          label: (0, import_i18n28.__)("Preview size"),
15446          value: previewSizeToUse,
15447          min: 0,
15448          max: breakValues.length - 1,
15449          withInputField: false,
15450          onChange: (value = 0) => {
15451            context.onChangeView({
15452              ...view,
15453              layout: {
15454                ...view.layout,
15455                previewSize: breakValues[value].value
15456              }
15457            });
15458          },
15459          step: 1,
15460          marks
15461        }
15462      );
15463    }
15464  
15465    // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
15466    var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15467    function GridConfigOptions() {
15468      return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
15469        /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DensityPicker, {}),
15470        /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(PreviewSizePicker, {})
15471      ] });
15472    }
15473  
15474    // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
15475    var VIEW_LAYOUTS = [
15476      {
15477        type: LAYOUT_TABLE,
15478        label: (0, import_i18n29.__)("Table"),
15479        component: table_default,
15480        icon: block_table_default,
15481        viewConfigOptions: DensityPicker
15482      },
15483      {
15484        type: LAYOUT_GRID,
15485        label: (0, import_i18n29.__)("Grid"),
15486        component: grid_default,
15487        icon: category_default,
15488        viewConfigOptions: GridConfigOptions
15489      },
15490      {
15491        type: LAYOUT_LIST,
15492        label: (0, import_i18n29.__)("List"),
15493        component: ViewList,
15494        icon: (0, import_i18n29.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
15495        viewConfigOptions: DensityPicker
15496      },
15497      {
15498        type: LAYOUT_ACTIVITY,
15499        label: (0, import_i18n29.__)("Activity"),
15500        component: ViewActivity,
15501        icon: scheduled_default,
15502        viewConfigOptions: DensityPicker
15503      },
15504      {
15505        type: LAYOUT_PICKER_GRID,
15506        label: (0, import_i18n29.__)("Grid"),
15507        component: picker_grid_default,
15508        icon: category_default,
15509        viewConfigOptions: GridConfigOptions,
15510        isPicker: true
15511      },
15512      {
15513        type: LAYOUT_PICKER_TABLE,
15514        label: (0, import_i18n29.__)("Table"),
15515        component: picker_table_default,
15516        icon: block_table_default,
15517        viewConfigOptions: DensityPicker,
15518        isPicker: true
15519      },
15520      {
15521        type: LAYOUT_PICKER_ACTIVITY,
15522        label: (0, import_i18n29.__)("Activity"),
15523        component: ViewPickerActivity,
15524        icon: scheduled_default,
15525        viewConfigOptions: DensityPicker,
15526        isPicker: true
15527      }
15528    ];
15529  
15530    // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15531    var import_element50 = __toESM(require_element(), 1);
15532  
15533    // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15534    var import_components21 = __toESM(require_components(), 1);
15535    var import_i18n32 = __toESM(require_i18n(), 1);
15536    var import_element47 = __toESM(require_element(), 1);
15537  
15538    // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
15539    var import_react7 = __toESM(require_react(), 1);
15540    var FocusableContext = (0, import_react7.createContext)(true);
15541  
15542    // node_modules/@ariakit/utils/dist/index.js
15543    function toArray(arg) {
15544      if (Array.isArray(arg)) return arg;
15545      return typeof arg !== "undefined" ? [arg] : [];
15546    }
15547    function flatten2DArray(array) {
15548      const flattened = [];
15549      for (const row of array) flattened.push(...row);
15550      return flattened;
15551    }
15552    function reverseArray(array) {
15553      return array.slice().reverse();
15554    }
15555    function noop5(..._) {
15556    }
15557    function hasOwnProperty(object, prop) {
15558      if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
15559      return Object.prototype.hasOwnProperty.call(object, prop);
15560    }
15561    function chain(...fns) {
15562      return (...args) => {
15563        for (const fn of fns) if (typeof fn === "function") fn(...args);
15564      };
15565    }
15566    function normalizeString(str) {
15567      return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
15568    }
15569    function omit(object, keys) {
15570      const result = { ...object };
15571      for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
15572      return result;
15573    }
15574    function pick(object, paths) {
15575      const result = {};
15576      for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
15577      return result;
15578    }
15579    function identity(value) {
15580      return value;
15581    }
15582    function afterPaint(cb = noop5) {
15583      let raf = requestAnimationFrame(() => {
15584        raf = requestAnimationFrame(cb);
15585      });
15586      return () => cancelAnimationFrame(raf);
15587    }
15588    function invariant(condition, message2) {
15589      if (condition) return;
15590      if (typeof message2 !== "string") throw new Error("Invariant failed");
15591      throw new Error(message2);
15592    }
15593    function getKeys(obj) {
15594      return Object.keys(obj);
15595    }
15596    function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15597      const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15598      if (result == null) return false;
15599      return !result;
15600    }
15601    function disabledFromProps(props) {
15602      return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15603    }
15604    function removeUndefinedValues(obj) {
15605      const result = {};
15606      for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
15607      return result;
15608    }
15609    function defaultValue(...values) {
15610      for (const value of values) if (value !== void 0) return value;
15611    }
15612    var canUseDOM = checkIsBrowser();
15613    function checkIsBrowser() {
15614      return typeof window !== "undefined" && !!window.document?.createElement;
15615    }
15616    function getDocument(node) {
15617      if (!node) return document;
15618      if ("self" in node) return node.document;
15619      return node.ownerDocument || document;
15620    }
15621    function getActiveElement(node, activeDescendant = false) {
15622      const { activeElement: activeElement2 } = getDocument(node);
15623      if (!activeElement2?.nodeName) return null;
15624      if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
15625      if (activeDescendant) {
15626        const id = activeElement2.getAttribute("aria-activedescendant");
15627        if (id) {
15628          const element = getDocument(activeElement2).getElementById(id);
15629          if (element) return element;
15630        }
15631      }
15632      return activeElement2;
15633    }
15634    function contains2(parent, child) {
15635      return parent === child || parent.contains(child);
15636    }
15637    function isElement2(target) {
15638      return target?.nodeType === 1;
15639    }
15640    function isNode2(target) {
15641      return typeof target?.nodeType === "number";
15642    }
15643    function isFrame(element) {
15644      return element.tagName === "IFRAME";
15645    }
15646    function isButton(element) {
15647      const tagName = element.tagName.toLowerCase();
15648      if (tagName === "button") return true;
15649      if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
15650      return false;
15651    }
15652    var buttonInputTypes = [
15653      "button",
15654      "color",
15655      "file",
15656      "image",
15657      "reset",
15658      "submit"
15659    ];
15660    function isVisible(element) {
15661      if (typeof element.checkVisibility === "function") return element.checkVisibility();
15662      const htmlElement = element;
15663      return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15664    }
15665    function isTextField(element) {
15666      try {
15667        if (element.tagName === "TEXTAREA") return true;
15668        if (element.tagName !== "INPUT") return false;
15669        return element.selectionStart !== null;
15670      } catch (_error) {
15671        return false;
15672      }
15673    }
15674    function isTextbox(element) {
15675      return element.isContentEditable || isTextField(element);
15676    }
15677    function getTextboxValue(element) {
15678      if (isTextField(element)) return element.value;
15679      if (element.isContentEditable) {
15680        const range = getDocument(element).createRange();
15681        range.selectNodeContents(element);
15682        return range.toString();
15683      }
15684      return "";
15685    }
15686    function getTextboxSelection(element) {
15687      let start = 0;
15688      let end = 0;
15689      if (isTextField(element)) {
15690        start = element.selectionStart || 0;
15691        end = element.selectionEnd || 0;
15692      } else if (element.isContentEditable) {
15693        const selection = getDocument(element).getSelection();
15694        if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15695          const range = selection.getRangeAt(0);
15696          const nextRange = range.cloneRange();
15697          nextRange.selectNodeContents(element);
15698          nextRange.setEnd(range.startContainer, range.startOffset);
15699          start = nextRange.toString().length;
15700          nextRange.setEnd(range.endContainer, range.endOffset);
15701          end = nextRange.toString().length;
15702        }
15703      }
15704      return {
15705        start,
15706        end
15707      };
15708    }
15709    var allowedPopupRoles = [
15710      "dialog",
15711      "menu",
15712      "listbox",
15713      "tree",
15714      "grid"
15715    ];
15716    var itemRoleByPopupRole = {
15717      menu: "menuitem",
15718      listbox: "option",
15719      tree: "treeitem"
15720    };
15721    function getPopupRole(element, fallback) {
15722      const role = element?.getAttribute("role");
15723      if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
15724      return fallback;
15725    }
15726    function getItemRoleByPopupRole(popupRole) {
15727      if (popupRole == null) return;
15728      if (!hasOwnProperty(itemRoleByPopupRole, popupRole)) return;
15729      return itemRoleByPopupRole[popupRole];
15730    }
15731    function getScrollingElement(element) {
15732      if (!element) return null;
15733      const isScrollableOverflow = (overflow) => {
15734        if (overflow === "auto") return true;
15735        if (overflow === "scroll") return true;
15736        return false;
15737      };
15738      if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15739        const { overflowY } = getComputedStyle(element);
15740        if (isScrollableOverflow(overflowY)) return element;
15741      } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15742        const { overflowX } = getComputedStyle(element);
15743        if (isScrollableOverflow(overflowX)) return element;
15744      }
15745      const doc = getDocument(element);
15746      return getScrollingElement(element.parentElement) || doc.scrollingElement || doc.body;
15747    }
15748    function setSelectionRange(element, ...args) {
15749      if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
15750    }
15751    function sortBasedOnDOMPosition(items, getElement) {
15752      const pairs = items.map((item, index2) => [index2, item]);
15753      let isOrderDifferent = false;
15754      pairs.sort(([indexA, a2], [indexB, b2]) => {
15755        const elementA = getElement(a2);
15756        const elementB = getElement(b2);
15757        if (elementA === elementB) return 0;
15758        if (!elementA || !elementB) return 0;
15759        if (isElementPreceding(elementA, elementB)) {
15760          if (indexA > indexB) isOrderDifferent = true;
15761          return -1;
15762        }
15763        if (indexA < indexB) isOrderDifferent = true;
15764        return 1;
15765      });
15766      if (isOrderDifferent) return pairs.map(([_, item]) => item);
15767      return items;
15768    }
15769    function isElementPreceding(a2, b2) {
15770      return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
15771    }
15772    function isTouchDevice() {
15773      return canUseDOM && !!navigator.maxTouchPoints;
15774    }
15775    function isApple() {
15776      if (!canUseDOM) return false;
15777      return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15778    }
15779    function isSafari() {
15780      return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15781    }
15782    function isFirefox() {
15783      return canUseDOM && /firefox\//i.test(navigator.userAgent);
15784    }
15785    function isPortalEvent(event) {
15786      const { currentTarget, target } = event;
15787      if (!currentTarget) return false;
15788      if (!isNode2(target)) return true;
15789      return !contains2(currentTarget, target);
15790    }
15791    function isSelfTarget(event) {
15792      return event.target === event.currentTarget;
15793    }
15794    function isActivatableNavigationTarget(element) {
15795      if (!isElement2(element)) return false;
15796      const target = element;
15797      const tagName = target.tagName.toLowerCase();
15798      if (tagName === "a") return true;
15799      if (tagName === "button" && target.type === "submit") return true;
15800      if (tagName === "input" && target.type === "submit") return true;
15801      return false;
15802    }
15803    function isOpeningInNewTab(event) {
15804      const isAppleDevice = isApple();
15805      if (isAppleDevice && !event.metaKey) return false;
15806      if (!isAppleDevice && !event.ctrlKey) return false;
15807      return isActivatableNavigationTarget(event.currentTarget);
15808    }
15809    function isDownloading(event) {
15810      if (!event.altKey) return false;
15811      return isActivatableNavigationTarget(event.currentTarget);
15812    }
15813    function fireBlurEvent(element, eventInit) {
15814      const event = new FocusEvent("blur", eventInit);
15815      const defaultAllowed = element.dispatchEvent(event);
15816      const bubbleInit = {
15817        ...eventInit,
15818        bubbles: true
15819      };
15820      element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15821      return defaultAllowed;
15822    }
15823    function fireKeyboardEvent(element, type, eventInit) {
15824      const event = new KeyboardEvent(type, eventInit);
15825      return element.dispatchEvent(event);
15826    }
15827    function fireClickEvent(element, eventInit) {
15828      const event = new MouseEvent("click", eventInit);
15829      return element.dispatchEvent(event);
15830    }
15831    function isFocusEventOutside(event, container) {
15832      const containerElement = container || event.currentTarget;
15833      const relatedTarget = event.relatedTarget;
15834      return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
15835    }
15836    function isInputEvent(event) {
15837      return event.type === "input";
15838    }
15839    function queueBeforeEvent(element, type, callback, timeout) {
15840      const createTimer = (callback2) => {
15841        if (timeout) {
15842          const timerId2 = setTimeout(callback2, timeout);
15843          return () => clearTimeout(timerId2);
15844        }
15845        const timerId = requestAnimationFrame(callback2);
15846        return () => cancelAnimationFrame(timerId);
15847      };
15848      const cancelTimer = createTimer(() => {
15849        element.removeEventListener(type, callSync, true);
15850        callback();
15851      });
15852      const callSync = () => {
15853        cancelTimer();
15854        callback();
15855      };
15856      element.addEventListener(type, callSync, {
15857        once: true,
15858        capture: true
15859      });
15860      return () => {
15861        cancelTimer();
15862        element.removeEventListener(type, callSync, true);
15863      };
15864    }
15865    function addGlobalEventListener(type, listener, options, scope = window) {
15866      const children = [];
15867      try {
15868        scope.document.addEventListener(type, listener, options);
15869        for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
15870      } catch {
15871      }
15872      const removeEventListener = () => {
15873        try {
15874          scope.document.removeEventListener(type, listener, options);
15875        } catch {
15876        }
15877        for (const remove of children) remove();
15878      };
15879      return removeEventListener;
15880    }
15881    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'])";
15882    function isFocusable(element) {
15883      if (!element.matches(selector)) return false;
15884      if (!isVisible(element)) return false;
15885      if (element.closest("[inert]")) return false;
15886      return true;
15887    }
15888    function hasFocus(element) {
15889      const activeElement2 = getActiveElement(element);
15890      if (!activeElement2) return false;
15891      if (activeElement2 === element) return true;
15892      const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15893      if (!activeDescendant) return false;
15894      return activeDescendant === element.id;
15895    }
15896    function hasFocusWithin(element) {
15897      const activeElement2 = getActiveElement(element);
15898      if (!activeElement2) return false;
15899      if (contains2(element, activeElement2)) return true;
15900      const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15901      if (!activeDescendant) return false;
15902      if (!("id" in element)) return false;
15903      if (activeDescendant === element.id) return true;
15904      return !!element.querySelector(`#$CSS.escape(activeDescendant)}`);
15905    }
15906    function focusIntoView(element, options) {
15907      if (!("scrollIntoView" in element)) element.focus();
15908      else {
15909        element.focus({ preventScroll: true });
15910        element.scrollIntoView({
15911          block: "nearest",
15912          inline: "nearest",
15913          ...options
15914        });
15915      }
15916    }
15917    function createUndoCallback(callback) {
15918      return async () => {
15919        const redo = await callback?.();
15920        return createUndoCallback(async () => {
15921          await redo?.();
15922          return callback;
15923        });
15924      };
15925    }
15926    var UndoManager = createUndoManager();
15927    function createUndoManager({ limit = 100 } = {}) {
15928      const undoStack = [];
15929      let redoStack = [];
15930      let currentGroup = null;
15931      const canUndo = () => undoStack.length > 0;
15932      const canRedo = () => redoStack.length > 0;
15933      const undo = async () => {
15934        if (!canUndo()) return;
15935        currentGroup = null;
15936        redoStack.push(await undoStack.pop()?.());
15937      };
15938      const redo = async () => {
15939        if (!canRedo()) return;
15940        currentGroup = null;
15941        undoStack.push(await redoStack.pop()?.());
15942      };
15943      const execute = async (callback, group) => {
15944        if (!callback) return;
15945        const sameGroup = group === currentGroup;
15946        currentGroup = group ?? null;
15947        const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
15948        const undoCallback = await callback();
15949        if (!undoCallback) return;
15950        redoStack = [];
15951        const currentUndo = undoStack[nextIndex];
15952        undoStack[nextIndex] = createUndoCallback(async () => {
15953          await undoCallback?.();
15954          const currentRedo = await currentUndo?.();
15955          return async () => {
15956            await currentRedo?.();
15957            await callback?.();
15958          };
15959        });
15960        while (undoStack.length > limit) undoStack.shift();
15961      };
15962      return {
15963        canUndo,
15964        canRedo,
15965        undo,
15966        redo,
15967        execute
15968      };
15969    }
15970  
15971    // node_modules/@ariakit/react-utils/dist/index.js
15972    var React47 = __toESM(require_react(), 1);
15973    var import_react8 = __toESM(require_react(), 1);
15974    var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
15975    function setRef(ref, value) {
15976      if (typeof ref === "function") {
15977        const cleanup = ref(value);
15978        if (typeof cleanup === "function") return cleanup;
15979      } else if (ref) ref.current = value;
15980    }
15981    function isValidElementWithRef(element) {
15982      if (!element) return false;
15983      if (!(0, import_react8.isValidElement)(element)) return false;
15984      if ("ref" in element.props) return true;
15985      if ("ref" in element) return true;
15986      return false;
15987    }
15988    function getRefProperty(element) {
15989      if (!isValidElementWithRef(element)) return null;
15990      return { ...element.props }.ref || element.ref;
15991    }
15992    function mergeProps2(base, overrides) {
15993      const props = { ...base };
15994      for (const key in overrides) {
15995        if (!hasOwnProperty(overrides, key)) continue;
15996        if (key === "className") {
15997          const prop = "className";
15998          const baseClass = base[prop];
15999          const overrideClass = overrides[prop];
16000          if (baseClass && overrideClass) props[prop] = `$baseClass} $overrideClass}`;
16001          else props[prop] = overrideClass || baseClass;
16002          continue;
16003        }
16004        if (key === "style") {
16005          const prop = "style";
16006          props[prop] = base[prop] ? {
16007            ...base[prop],
16008            ...overrides[prop]
16009          } : overrides[prop];
16010          continue;
16011        }
16012        const overrideValue = overrides[key];
16013        if (key.startsWith("on")) {
16014          if (typeof overrideValue !== "function") continue;
16015          const baseValue = base[key];
16016          if (typeof baseValue === "function") {
16017            props[key] = (...args) => {
16018              overrideValue(...args);
16019              baseValue(...args);
16020            };
16021            continue;
16022          }
16023        }
16024        props[key] = overrideValue;
16025      }
16026      return props;
16027    }
16028    var _React = { ...React47 };
16029    var useReactId = _React.useId;
16030    var useReactDeferredValue = _React.useDeferredValue;
16031    var useReactInsertionEffect = _React.useInsertionEffect;
16032    var useSafeLayoutEffect = canUseDOM ? import_react8.useLayoutEffect : import_react8.useEffect;
16033    function useInitialValue(value) {
16034      const [initialValue] = (0, import_react8.useState)(value);
16035      return initialValue;
16036    }
16037    function useLiveRef(value) {
16038      const ref = (0, import_react8.useRef)(value);
16039      useSafeLayoutEffect(() => {
16040        ref.current = value;
16041      });
16042      return ref;
16043    }
16044    function useEvent(callback) {
16045      const ref = (0, import_react8.useRef)(() => {
16046        throw new Error("Cannot call an event handler while rendering.");
16047      });
16048      if (useReactInsertionEffect) useReactInsertionEffect(() => {
16049        ref.current = callback;
16050      });
16051      else ref.current = callback;
16052      return (0, import_react8.useCallback)((...args) => ref.current?.(...args), []);
16053    }
16054    function useTransactionState(callback) {
16055      const [state, setState] = (0, import_react8.useState)(null);
16056      useSafeLayoutEffect(() => {
16057        if (state == null) return;
16058        if (!callback) return;
16059        let prevState = null;
16060        callback((prev) => {
16061          prevState = prev;
16062          return state;
16063        });
16064        return () => {
16065          callback(prevState);
16066        };
16067      }, [state, callback]);
16068      return [state, setState];
16069    }
16070    function useMergeRefs(...refs) {
16071      return (0, import_react8.useMemo)(() => {
16072        if (!refs.some(Boolean)) return;
16073        return (value) => {
16074          const refEffects = [];
16075          for (const ref of refs) {
16076            if (!ref) continue;
16077            const cleanup = setRef(ref, value);
16078            refEffects.push({
16079              ref,
16080              cleanup: typeof cleanup === "function" ? cleanup : void 0
16081            });
16082          }
16083          if (!refEffects.some((effect) => effect.cleanup)) return;
16084          return () => {
16085            for (const { ref, cleanup } of refEffects) if (cleanup) cleanup();
16086            else setRef(ref, null);
16087          };
16088        };
16089      }, refs);
16090    }
16091    function useId4(defaultId) {
16092      if (useReactId) {
16093        const reactId = useReactId();
16094        if (defaultId) return defaultId;
16095        return reactId;
16096      }
16097      const [id, setId] = (0, import_react8.useState)(defaultId);
16098      useSafeLayoutEffect(() => {
16099        if (defaultId || id) return;
16100        setId(`id-$Math.random().toString(36).slice(2, 8)}`);
16101      }, [defaultId, id]);
16102      return defaultId || id;
16103    }
16104    function useTagName(refOrElement, type) {
16105      const stringOrUndefined = (type2) => {
16106        if (typeof type2 !== "string") return;
16107        return type2;
16108      };
16109      const [tagName, setTagName] = (0, import_react8.useState)(() => stringOrUndefined(type));
16110      useSafeLayoutEffect(() => {
16111        setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
16112      }, [refOrElement, type]);
16113      return tagName;
16114    }
16115    function useAttribute(refOrElement, attributeName, defaultValue2) {
16116      const initialValue = useInitialValue(defaultValue2);
16117      const [attribute, setAttribute] = (0, import_react8.useState)(initialValue);
16118      (0, import_react8.useEffect)(() => {
16119        const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
16120        if (!element) return;
16121        const callback = () => {
16122          const value = element.getAttribute(attributeName);
16123          setAttribute(value == null ? initialValue : value);
16124        };
16125        const observer = new MutationObserver(callback);
16126        observer.observe(element, { attributeFilter: [attributeName] });
16127        callback();
16128        return () => observer.disconnect();
16129      }, [
16130        refOrElement,
16131        attributeName,
16132        initialValue
16133      ]);
16134      return attribute;
16135    }
16136    function useUpdateEffect(effect, deps) {
16137      const mounted = (0, import_react8.useRef)(false);
16138      (0, import_react8.useEffect)(() => {
16139        if (mounted.current) return effect();
16140        mounted.current = true;
16141      }, deps);
16142      (0, import_react8.useEffect)(() => () => {
16143        mounted.current = false;
16144      }, []);
16145    }
16146    function useUpdateLayoutEffect(effect, deps) {
16147      const mounted = (0, import_react8.useRef)(false);
16148      useSafeLayoutEffect(() => {
16149        if (mounted.current) return effect();
16150        mounted.current = true;
16151      }, deps);
16152      useSafeLayoutEffect(() => () => {
16153        mounted.current = false;
16154      }, []);
16155    }
16156    function useForceUpdate() {
16157      return (0, import_react8.useReducer)(() => [], []);
16158    }
16159    function useBooleanEvent(booleanOrCallback) {
16160      return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
16161    }
16162    function useWrapElement(props, callback, deps = []) {
16163      const wrapElement = (0, import_react8.useCallback)((element) => {
16164        if (props.wrapElement) element = props.wrapElement(element);
16165        return callback(element);
16166      }, [...deps, props.wrapElement]);
16167      return {
16168        ...props,
16169        wrapElement
16170      };
16171    }
16172    function useMetadataProps(props, key, value) {
16173      const parent = props.onLoadedMetadataCapture;
16174      const onLoadedMetadataCapture = (0, import_react8.useMemo)(() => {
16175        return Object.assign(() => {
16176        }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
16177      }, [
16178        parent,
16179        key,
16180        value
16181      ]);
16182      return [parent?.[key], { onLoadedMetadataCapture }];
16183    }
16184    var hasInstalledGlobalEventListeners = false;
16185    function useIsMouseMoving() {
16186      (0, import_react8.useEffect)(() => {
16187        if (hasInstalledGlobalEventListeners) return;
16188        addGlobalEventListener("mousemove", setMouseMoving, true);
16189        addGlobalEventListener("mousedown", resetMouseMoving, true);
16190        addGlobalEventListener("mouseup", resetMouseMoving, true);
16191        addGlobalEventListener("keydown", resetMouseMoving, true);
16192        addGlobalEventListener("scroll", resetMouseMoving, true);
16193        hasInstalledGlobalEventListeners = true;
16194      }, []);
16195      return useEvent(() => mouseMoving);
16196    }
16197    var mouseMoving = false;
16198    var previousScreenX = 0;
16199    var previousScreenY = 0;
16200    function hasMouseMovement(event) {
16201      const movementX = event.movementX || event.screenX - previousScreenX;
16202      const movementY = event.movementY || event.screenY - previousScreenY;
16203      previousScreenX = event.screenX;
16204      previousScreenY = event.screenY;
16205      return movementX || movementY || false;
16206    }
16207    function setMouseMoving(event) {
16208      if (!hasMouseMovement(event)) return;
16209      mouseMoving = true;
16210    }
16211    function resetMouseMoving() {
16212      mouseMoving = false;
16213    }
16214    function forwardRef21(render4) {
16215      const Role = React47.forwardRef((props, ref) => render4({
16216        ...props,
16217        ref
16218      }));
16219      Role.displayName = render4.displayName || render4.name;
16220      return Role;
16221    }
16222    function memo3(Component2, propsAreEqual) {
16223      return React47.memo(Component2, propsAreEqual);
16224    }
16225    function createElement3(Type, props) {
16226      const { wrapElement, render: render4, ...rest } = props;
16227      const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
16228      let element;
16229      if (React47.isValidElement(render4)) {
16230        const renderProps = {
16231          ...render4.props,
16232          ref: mergedRef
16233        };
16234        element = React47.cloneElement(render4, mergeProps2(rest, renderProps));
16235      } else if (render4) element = render4(rest);
16236      else element = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Type, { ...rest });
16237      if (wrapElement) return wrapElement(element);
16238      return element;
16239    }
16240    function createHook(useProps) {
16241      const useRole = (props = {}) => {
16242        return useProps(props);
16243      };
16244      useRole.displayName = useProps.name;
16245      return useRole;
16246    }
16247    function createStoreContext(providers = [], scopedProviders = []) {
16248      const context = React47.createContext(void 0);
16249      const scopedContext = React47.createContext(void 0);
16250      const useContext37 = () => React47.useContext(context);
16251      const useScopedContext = (onlyScoped = false) => {
16252        const scoped = React47.useContext(scopedContext);
16253        const store = useContext37();
16254        if (onlyScoped) return scoped;
16255        return scoped || store;
16256      };
16257      const useProviderContext = () => {
16258        const scoped = React47.useContext(scopedContext);
16259        const store = useContext37();
16260        if (scoped && scoped === store) return;
16261        return store;
16262      };
16263      const ContextProvider = (props) => {
16264        return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, {
16265          ...props,
16266          children
16267        }), /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(context.Provider, { ...props }));
16268      };
16269      const ScopedContextProvider = (props) => {
16270        return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ContextProvider, {
16271          ...props,
16272          children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, {
16273            ...props,
16274            children
16275          }), /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(scopedContext.Provider, { ...props }))
16276        });
16277      };
16278      return {
16279        context,
16280        scopedContext,
16281        useContext: useContext37,
16282        useScopedContext,
16283        useProviderContext,
16284        ContextProvider,
16285        ScopedContextProvider
16286      };
16287    }
16288  
16289    // node_modules/@ariakit/react-components/dist/focusable/focusable.js
16290    var import_react9 = __toESM(require_react(), 1);
16291    var TagName = "div";
16292    var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
16293    var isSafariBrowser = isSafari();
16294    var alwaysFocusVisibleInputTypes = [
16295      "text",
16296      "search",
16297      "url",
16298      "tel",
16299      "email",
16300      "password",
16301      "number",
16302      "date",
16303      "month",
16304      "week",
16305      "time",
16306      "datetime",
16307      "datetime-local"
16308    ];
16309    function isAlwaysFocusVisible(element) {
16310      const { tagName, readOnly, type } = element;
16311      if (tagName === "TEXTAREA" && !readOnly) return true;
16312      if (tagName === "SELECT" && !readOnly) return true;
16313      if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
16314      if (element.isContentEditable) return true;
16315      if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
16316      return false;
16317    }
16318    function isNativeTabbable(tagName) {
16319      if (!tagName) return true;
16320      return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
16321    }
16322    function supportsDisabledAttribute(tagName) {
16323      if (!tagName) return true;
16324      return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
16325    }
16326    function isNativeSubmitControl(element) {
16327      if (element.tagName === "BUTTON") {
16328        const { type } = element;
16329        return type === "submit";
16330      }
16331      if (element.tagName === "INPUT") {
16332        const { type } = element;
16333        return type === "submit" || type === "image";
16334      }
16335      return false;
16336    }
16337    function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
16338      if (!focusable2) return tabIndexProp;
16339      if (trulyDisabled) {
16340        if (nativeTabbable && !supportsDisabled) return -1;
16341        return;
16342      }
16343      if (nativeTabbable) {
16344        if (safariTabIndex && tabIndexProp == null) return 0;
16345        return tabIndexProp;
16346      }
16347      return tabIndexProp ?? 0;
16348    }
16349    function useDisableEvent(onEvent, disabled2) {
16350      return useEvent((event) => {
16351        onEvent?.(event);
16352        if (event.defaultPrevented) return;
16353        if (disabled2) {
16354          event.stopPropagation();
16355          event.preventDefault();
16356        }
16357      });
16358    }
16359    var hasInstalledGlobalEventListeners2 = false;
16360    var isKeyboardModality = true;
16361    function onGlobalMouseDown(event) {
16362      const target = event.target;
16363      if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
16364    }
16365    function onGlobalKeyDown(event) {
16366      if (event.metaKey) return;
16367      if (event.ctrlKey) return;
16368      if (event.altKey) return;
16369      isKeyboardModality = true;
16370    }
16371    var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
16372      const ref = (0, import_react9.useRef)(null);
16373      const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
16374      accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
16375      (0, import_react9.useEffect)(() => {
16376        if (!focusable2) return;
16377        if (hasInstalledGlobalEventListeners2) return;
16378        addGlobalEventListener("mousedown", onGlobalMouseDown, true);
16379        addGlobalEventListener("keydown", onGlobalKeyDown, true);
16380        hasInstalledGlobalEventListeners2 = true;
16381      }, [focusable2]);
16382      const disabled2 = focusable2 && disabledFromProps(props);
16383      const trulyDisabled = disabled2 && !accessibleWhenDisabled;
16384      const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false);
16385      const focusVisibleRef = (0, import_react9.useRef)(false);
16386      const nativeSubmitObserverCleanupRef = (0, import_react9.useRef)(null);
16387      const cleanupFocusVisible = useEvent((element) => {
16388        nativeSubmitObserverCleanupRef.current?.();
16389        nativeSubmitObserverCleanupRef.current = null;
16390        focusVisibleRef.current = false;
16391        element?.removeAttribute("data-focus-visible");
16392      });
16393      (0, import_react9.useEffect)(() => {
16394        if (!focusable2) return;
16395        if (!trulyDisabled) return;
16396        cleanupFocusVisible(ref.current);
16397        if (focusVisible) setFocusVisible(false);
16398      }, [
16399        focusable2,
16400        trulyDisabled,
16401        focusVisible,
16402        cleanupFocusVisible
16403      ]);
16404      (0, import_react9.useEffect)(() => {
16405        if (!focusable2) return;
16406        if (!focusVisible) return;
16407        const element = ref.current;
16408        if (!element) return;
16409        if (typeof IntersectionObserver === "undefined") return;
16410        const observer = new IntersectionObserver(() => {
16411          if (!isFocusable(element)) {
16412            focusVisibleRef.current = false;
16413            setFocusVisible(false);
16414          }
16415        });
16416        observer.observe(element);
16417        return () => observer.disconnect();
16418      }, [focusable2, focusVisible]);
16419      (0, import_react9.useEffect)(() => {
16420        return () => nativeSubmitObserverCleanupRef.current?.();
16421      }, []);
16422      const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
16423      const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
16424      const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
16425      const handleFocusVisible = (event, currentTarget) => {
16426        if (currentTarget) event.currentTarget = currentTarget;
16427        if (!focusable2) return;
16428        const element = event.currentTarget;
16429        if (!element) return;
16430        if (!hasFocus(element)) return;
16431        onFocusVisible?.(event);
16432        if (event.defaultPrevented) return;
16433        element.dataset.focusVisible = "true";
16434        focusVisibleRef.current = true;
16435        if (isNativeSubmitControl(element)) {
16436          nativeSubmitObserverCleanupRef.current?.();
16437          nativeSubmitObserverCleanupRef.current = null;
16438          if (typeof IntersectionObserver !== "undefined") {
16439            const observer = new IntersectionObserver(() => {
16440              if (isFocusable(element)) return;
16441              cleanupFocusVisible(element);
16442            });
16443            observer.observe(element);
16444            nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
16445          }
16446          return;
16447        }
16448        setFocusVisible(true);
16449      };
16450      const onKeyDownCaptureProp = props.onKeyDownCapture;
16451      const onKeyDownCapture = useEvent((event) => {
16452        onKeyDownCaptureProp?.(event);
16453        if (event.defaultPrevented) return;
16454        if (!focusable2) return;
16455        if (focusVisible) return;
16456        if (focusVisibleRef.current) return;
16457        if (event.metaKey) return;
16458        if (event.altKey) return;
16459        if (event.ctrlKey) return;
16460        if (!isSelfTarget(event)) return;
16461        const element = event.currentTarget;
16462        const applyFocusVisible = () => handleFocusVisible(event, element);
16463        queueBeforeEvent(element, "focusout", applyFocusVisible);
16464      });
16465      const onFocusCaptureProp = props.onFocusCapture;
16466      const onFocusCapture = useEvent((event) => {
16467        onFocusCaptureProp?.(event);
16468        if (event.defaultPrevented) return;
16469        if (!focusable2) return;
16470        if (!isSelfTarget(event)) {
16471          setFocusVisible(false);
16472          return;
16473        }
16474        const element = event.currentTarget;
16475        const applyFocusVisible = () => handleFocusVisible(event, element);
16476        if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
16477        else setFocusVisible(false);
16478      });
16479      const onBlurProp = props.onBlur;
16480      const onBlur = useEvent((event) => {
16481        onBlurProp?.(event);
16482        if (!focusable2) return;
16483        if (!isFocusEventOutside(event)) return;
16484        cleanupFocusVisible(event.currentTarget);
16485        setFocusVisible(false);
16486      });
16487      const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext);
16488      const autoFocusRef = useEvent((element) => {
16489        if (!focusable2) return;
16490        if (!autoFocus) return;
16491        if (!element) return;
16492        if (!autoFocusOnShow) return;
16493        queueMicrotask(() => {
16494          if (hasFocus(element)) return;
16495          if (!isFocusable(element)) return;
16496          element.focus();
16497        });
16498      });
16499      const tagName = useTagName(ref);
16500      const nativeTabbable = focusable2 && isNativeTabbable(tagName);
16501      const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
16502      const [safariTabIndex, setSafariTabIndex] = (0, import_react9.useState)(false);
16503      if (isSafariBrowser) (0, import_react9.useEffect)(() => {
16504        if (!focusable2) return;
16505        const element = ref.current;
16506        if (!element) return;
16507        const { type } = element;
16508        const isNativeCheckboxOrRadio = element.tagName === "INPUT" && (type === "checkbox" || type === "radio");
16509        setSafariTabIndex(isButton(element) || isNativeCheckboxOrRadio);
16510      }, [focusable2]);
16511      const styleProp = props.style;
16512      const style = (0, import_react9.useMemo)(() => {
16513        if (trulyDisabled) return {
16514          pointerEvents: "none",
16515          ...styleProp
16516        };
16517        return styleProp;
16518      }, [trulyDisabled, styleProp]);
16519      props = {
16520        "data-focus-visible": focusable2 && focusVisible || void 0,
16521        "data-autofocus": autoFocus || void 0,
16522        "aria-disabled": disabled2 || void 0,
16523        ...props,
16524        ...metadataProps,
16525        ref: useMergeRefs(ref, autoFocusRef, props.ref),
16526        style,
16527        tabIndex: getTabIndex2({
16528          focusable: focusable2,
16529          trulyDisabled,
16530          nativeTabbable,
16531          supportsDisabled,
16532          safariTabIndex,
16533          tabIndexProp: props.tabIndex
16534        }),
16535        disabled: supportsDisabled && trulyDisabled ? true : void 0,
16536        contentEditable: disabled2 ? void 0 : props.contentEditable,
16537        onKeyPressCapture,
16538        onClickCapture,
16539        onMouseDownCapture,
16540        onKeyDownCapture,
16541        onFocusCapture,
16542        onBlur
16543      };
16544      return removeUndefinedValues(props);
16545    });
16546    var Focusable = forwardRef21(function Focusable2(props) {
16547      return createElement3(TagName, useFocusable(props));
16548    });
16549  
16550    // node_modules/@ariakit/react-components/dist/command/command.js
16551    var import_react10 = __toESM(require_react(), 1);
16552    var TagName2 = "button";
16553    function isNativeClick(event) {
16554      if (!event.isTrusted) return false;
16555      const element = event.currentTarget;
16556      if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16557      if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16558      return false;
16559    }
16560    var symbol = /* @__PURE__ */ Symbol("command");
16561    var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16562      const ref = (0, import_react10.useRef)(null);
16563      const [isNativeButton, setIsNativeButton] = (0, import_react10.useState)(false);
16564      (0, import_react10.useEffect)(() => {
16565        if (!ref.current) return;
16566        setIsNativeButton(isButton(ref.current));
16567      }, []);
16568      const [active, setActive] = (0, import_react10.useState)(false);
16569      const activeRef = (0, import_react10.useRef)(false);
16570      const disabled2 = disabledFromProps(props);
16571      const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16572      useSafeLayoutEffect(() => {
16573        if (!disabled2) return;
16574        activeRef.current = false;
16575        setActive(false);
16576      }, [disabled2]);
16577      const onKeyDownProp = props.onKeyDown;
16578      const onKeyDown = useEvent((event) => {
16579        onKeyDownProp?.(event);
16580        const element = event.currentTarget;
16581        if (event.defaultPrevented) return;
16582        if (isDuplicate) return;
16583        if (disabled2) return;
16584        if (!isSelfTarget(event)) return;
16585        if (isTextField(element)) return;
16586        if (element.isContentEditable) return;
16587        const isEnter = clickOnEnter && event.key === "Enter";
16588        const isSpace = clickOnSpace && event.key === " ";
16589        const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16590        const shouldPreventSpace = event.key === " " && !clickOnSpace;
16591        if (shouldPreventEnter || shouldPreventSpace) {
16592          event.preventDefault();
16593          return;
16594        }
16595        if (isEnter || isSpace) {
16596          const nativeClick = isNativeClick(event);
16597          if (isEnter) {
16598            if (!nativeClick) {
16599              event.preventDefault();
16600              const { view, ...eventInit } = event;
16601              const click = () => fireClickEvent(element, eventInit);
16602              if (isFirefox()) queueBeforeEvent(element, "keyup", click);
16603              else queueMicrotask(click);
16604            }
16605          } else if (isSpace) {
16606            activeRef.current = true;
16607            if (!nativeClick) {
16608              event.preventDefault();
16609              setActive(true);
16610            }
16611          }
16612        }
16613      });
16614      const onKeyUpProp = props.onKeyUp;
16615      const onKeyUp = useEvent((event) => {
16616        onKeyUpProp?.(event);
16617        if (isDuplicate) return;
16618        const isSpace = clickOnSpace && event.key === " ";
16619        if (!activeRef.current || !isSpace) return;
16620        const nativeClick = isNativeClick(event);
16621        activeRef.current = false;
16622        if (!nativeClick) setActive(false);
16623        if (event.defaultPrevented) return;
16624        if (!isSelfTarget(event)) return;
16625        if (disabled2) return;
16626        if (event.metaKey) return;
16627        if (nativeClick) return;
16628        event.preventDefault();
16629        const element = event.currentTarget;
16630        const { view, ...eventInit } = event;
16631        queueMicrotask(() => fireClickEvent(element, eventInit));
16632      });
16633      const onBlurProp = props.onBlur;
16634      const onBlur = useEvent((event) => {
16635        onBlurProp?.(event);
16636        if (!activeRef.current) return;
16637        activeRef.current = false;
16638        setActive(false);
16639      });
16640      props = {
16641        "data-active": active || void 0,
16642        type: isNativeButton ? "button" : void 0,
16643        ...metadataProps,
16644        ...props,
16645        ref: useMergeRefs(ref, props.ref),
16646        onKeyDown,
16647        onKeyUp,
16648        onBlur
16649      };
16650      props = useFocusable(props);
16651      return props;
16652    });
16653    var Command = forwardRef21(function Command2(props) {
16654      return createElement3(TagName2, useCommand(props));
16655    });
16656  
16657    // node_modules/@ariakit/react-components/dist/collection/collection-context.js
16658    var ctx = createStoreContext();
16659    var useCollectionContext = ctx.useContext;
16660    var useCollectionScopedContext = ctx.useScopedContext;
16661    var useCollectionProviderContext = ctx.useProviderContext;
16662    var CollectionContextProvider = ctx.ContextProvider;
16663    var CollectionScopedContextProvider = ctx.ScopedContextProvider;
16664  
16665    // node_modules/@ariakit/react-components/dist/collection/collection-item.js
16666    var import_react11 = __toESM(require_react(), 1);
16667    var TagName3 = "div";
16668    var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
16669      const context = useCollectionContext();
16670      store = store || context;
16671      const id = useId4(props.id);
16672      const ref = (0, import_react11.useRef)(element);
16673      (0, import_react11.useEffect)(() => {
16674        const element2 = ref.current;
16675        if (!id) return;
16676        if (!element2) return;
16677        if (!shouldRegisterItem) return;
16678        const item = getItem({
16679          id,
16680          element: element2
16681        });
16682        return store?.renderItem(item);
16683      }, [
16684        id,
16685        shouldRegisterItem,
16686        getItem,
16687        store
16688      ]);
16689      props = {
16690        ...props,
16691        ref: useMergeRefs(ref, props.ref)
16692      };
16693      return removeUndefinedValues(props);
16694    });
16695    var CollectionItem = forwardRef21(function CollectionItem2(props) {
16696      return createElement3(TagName3, useCollectionItem(props));
16697    });
16698  
16699    // node_modules/@ariakit/react-components/dist/composite/composite-context.js
16700    var import_react12 = __toESM(require_react(), 1);
16701    var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
16702    var useCompositeContext = ctx2.useContext;
16703    var useCompositeScopedContext = ctx2.useScopedContext;
16704    var useCompositeProviderContext = ctx2.useProviderContext;
16705    var CompositeContextProvider = ctx2.ContextProvider;
16706    var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
16707    var CompositeItemContext = (0, import_react12.createContext)(void 0);
16708    var CompositeRowContext = (0, import_react12.createContext)(void 0);
16709  
16710    // node_modules/@ariakit/store/dist/index.js
16711    function getInternal(store, key) {
16712      const internals = store.__unstableInternals;
16713      invariant(internals, "Invalid store");
16714      return internals[key];
16715    }
16716    function hasUpdatedKey(keys, updatedKey) {
16717      if (!keys) return true;
16718      for (const currentKey of keys) if (updatedKey instanceof Set) {
16719        if (updatedKey.has(currentKey)) return true;
16720      } else if (currentKey === updatedKey) return true;
16721      return false;
16722    }
16723    function isSameValue(value, other) {
16724      return value === other || value !== value && other !== other;
16725    }
16726    function getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) {
16727      let cleanupPrevState;
16728      for (const key of getKeys(state)) {
16729        if (isSameValue(state[key], stateBeforeCleanup[key])) continue;
16730        if (updatedKey !== void 0 && hasUpdatedKey([key], updatedKey)) continue;
16731        cleanupPrevState ??= { ...prevState };
16732        cleanupPrevState[key] = state[key];
16733      }
16734      return cleanupPrevState;
16735    }
16736    var MAX_REPAIR_PASSES = 100;
16737    function addKeyedListener(map, keys, listener) {
16738      if (!keys) return;
16739      for (const key of keys) {
16740        let listeners = map.get(key);
16741        if (!listeners) {
16742          listeners = /* @__PURE__ */ new Set();
16743          map.set(key, listeners);
16744        }
16745        listeners.add(listener);
16746      }
16747    }
16748    function deleteKeyedListener(map, keys, listener) {
16749      if (!map) return;
16750      if (!keys) return;
16751      for (const key of keys) {
16752        const listeners = map.get(key);
16753        if (!listeners) continue;
16754        listeners.delete(listener);
16755        if (!listeners.size) map.delete(key);
16756      }
16757    }
16758    function getFastPathNotifiedListeners(frame) {
16759      const notifiedListeners = /* @__PURE__ */ new Set();
16760      const currentListener = frame.currentListener;
16761      if (!currentListener) return notifiedListeners;
16762      for (const listener of frame.keyedListeners) {
16763        notifiedListeners.add(listener);
16764        if (listener === currentListener) return notifiedListeners;
16765      }
16766      notifiedListeners.clear();
16767      notifiedListeners.add(currentListener);
16768      return notifiedListeners;
16769    }
16770    function preserveFastPathNotifiedListeners(frame) {
16771      frame.notifiedListeners ??= getFastPathNotifiedListeners(frame);
16772    }
16773    function hasFastPathPassedListener(frame, listener) {
16774      if (!frame.currentListener) return false;
16775      let foundCurrentKeyedListener = false;
16776      for (const currentListener of frame.keyedListeners) {
16777        if (currentListener === frame.currentListener) {
16778          foundCurrentKeyedListener = true;
16779          continue;
16780        }
16781        if (!foundCurrentKeyedListener) continue;
16782        if (currentListener === listener) return false;
16783      }
16784      let foundListener = false;
16785      for (const currentListener of frame.group.listeners) {
16786        if (currentListener === frame.currentListener) return foundListener;
16787        if (currentListener === listener) foundListener = true;
16788      }
16789      return false;
16790    }
16791    function preserveFastPathFrames(fastPathFrames, group, listener) {
16792      for (const frame of fastPathFrames) {
16793        if (frame.group !== group) continue;
16794        if (frame.recovering) continue;
16795        if (listener && !frame.keyedListeners.has(listener)) continue;
16796        preserveFastPathNotifiedListeners(frame);
16797        for (const currentListener of frame.group.listeners) {
16798          if (currentListener === frame.currentListener) break;
16799          if (!hasFastPathPassedListener(frame, currentListener)) continue;
16800          frame.notifiedListeners?.add(currentListener);
16801        }
16802      }
16803    }
16804    function preserveFastPathPassedListeners(fastPathFrames, group, listener) {
16805      for (const frame of fastPathFrames) {
16806        if (frame.group !== group) continue;
16807        if (frame.recovering) continue;
16808        if (!hasFastPathPassedListener(frame, listener)) continue;
16809        preserveFastPathNotifiedListeners(frame);
16810        frame.notifiedListeners?.add(listener);
16811      }
16812    }
16813    function preserveFastPathPassedKeyedListeners({ fastPathFrames, group, keys, listener }) {
16814      const wasRegistered = group.listeners.has(listener);
16815      for (const frame of fastPathFrames) {
16816        if (frame.group !== group) continue;
16817        if (frame.recovering) continue;
16818        if (!keys.includes(frame.updatedKey)) continue;
16819        if (hasFastPathPassedListener(frame, listener)) {
16820          preserveFastPathNotifiedListeners(frame);
16821          frame.notifiedListeners?.add(listener);
16822        } else if (wasRegistered) {
16823          preserveFastPathNotifiedListeners(frame);
16824          frame.recoverToLive = true;
16825        }
16826      }
16827    }
16828    function clearFastPathNotifiedListener(fastPathFrames, group, listener) {
16829      for (const frame of fastPathFrames) {
16830        if (frame.group !== group) continue;
16831        frame.notifiedListeners?.delete(listener);
16832      }
16833    }
16834    function addFastPathKeyedListener({ fastPathFrames, group, keys, listener }) {
16835      for (const frame of fastPathFrames) {
16836        if (frame.group !== group) continue;
16837        if (frame.recovering) continue;
16838        if (!keys.includes(frame.updatedKey)) continue;
16839        frame.keyedListeners.add(listener);
16840      }
16841    }
16842    function runPendingCleanup(group, listener) {
16843      if (!group.disposables.size) return;
16844      const cleanup = group.disposables.get(listener);
16845      if (!cleanup) return;
16846      group.disposables.delete(listener);
16847      cleanup();
16848    }
16849    function setListenerCleanup(group, listener, cleanup) {
16850      const currentCleanup = group.disposables.get(listener);
16851      if (!currentCleanup) {
16852        group.disposables.set(listener, cleanup);
16853        return;
16854      }
16855      group.disposables.set(listener, () => {
16856        currentCleanup();
16857        cleanup();
16858      });
16859    }
16860    function notifyStoreListener(group, listener, state, prevState, getState, updatedKey) {
16861      if (group.suspendCounts?.has(listener)) return;
16862      const { disposables } = group;
16863      const cleanup = disposables.size ? disposables.get(listener) : void 0;
16864      if (cleanup) {
16865        disposables.delete(listener);
16866        const stateBeforeCleanup = state;
16867        cleanup();
16868        state = getState?.() ?? state;
16869        if (state !== stateBeforeCleanup) prevState = getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) ?? prevState;
16870      }
16871      const result = listener(state, prevState);
16872      if (result) setListenerCleanup(group, listener, result);
16873    }
16874    function runLiveListeners({ group, getState, prevState, updatedKey, notifiedListeners }) {
16875      const allKeysListeners = group.allKeysListeners;
16876      for (const listener of group.listeners) {
16877        if (notifiedListeners?.has(listener)) continue;
16878        if (!allKeysListeners?.has(listener)) {
16879          if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
16880        }
16881        notifiedListeners?.add(listener);
16882        notifyStoreListener(group, listener, getState(), prevState, getState, updatedKey);
16883      }
16884    }
16885    function createStore(initialState, ...stores) {
16886      let state = initialState;
16887      let prevStateBatch = state;
16888      let destroy = noop5;
16889      let batchPending = false;
16890      let inDispatch = false;
16891      let updatedKeys = /* @__PURE__ */ new Set();
16892      const instances = /* @__PURE__ */ new Set();
16893      const setups = /* @__PURE__ */ new Set();
16894      const syncListenerGroup = {
16895        listeners: /* @__PURE__ */ new Set(),
16896        disposables: /* @__PURE__ */ new Map(),
16897        listenerKeys: /* @__PURE__ */ new WeakMap()
16898      };
16899      const batchListenerGroup = {
16900        listeners: /* @__PURE__ */ new Set(),
16901        disposables: /* @__PURE__ */ new Map(),
16902        listenerKeys: /* @__PURE__ */ new WeakMap()
16903      };
16904      const storeSetup = (callback) => {
16905        setups.add(callback);
16906        return () => setups.delete(callback);
16907      };
16908      const storeInit = () => {
16909        const initializedInstances = instances.size;
16910        const instance = /* @__PURE__ */ Symbol();
16911        instances.add(instance);
16912        const maybeDestroy = () => {
16913          if (!instances.delete(instance)) return;
16914          if (instances.size) return;
16915          destroy();
16916        };
16917        if (initializedInstances) return maybeDestroy;
16918        const stateKeys = getKeys(state);
16919        const desyncs = [];
16920        for (const store of stores) {
16921          const storeState = store?.getState?.();
16922          if (!storeState) continue;
16923          const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
16924          if (!keys.length) continue;
16925          if (stores.length === 1 || keys.length === stateKeys.length) {
16926            for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
16927              setState(key, state2[key], true);
16928            }));
16929            continue;
16930          }
16931          desyncs.push(subscribe(store, keys, (state2, prevState) => {
16932            for (const key of keys) {
16933              if (state2[key] === prevState[key]) continue;
16934              setState(key, state2[key], true);
16935            }
16936          }));
16937          for (const key of keys) {
16938            const liveState = store?.getState?.();
16939            if (!liveState) continue;
16940            setState(key, liveState[key], true);
16941          }
16942        }
16943        const teardowns = [];
16944        for (const setup2 of setups) teardowns.push(setup2());
16945        const cleanups = stores.map(init);
16946        destroy = chain(...desyncs, ...teardowns, ...cleanups);
16947        return maybeDestroy;
16948      };
16949      const deleteListenerIndexes = (group, listener, keys) => {
16950        if (keys === void 0) return;
16951        if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
16952        else group.allKeysListeners?.delete(listener);
16953      };
16954      const fastPathFrames = [];
16955      const registerListener = (keys, listener, group = syncListenerGroup) => {
16956        const listenerKeysValue = keys ? [...keys] : null;
16957        const wasRegistered = group.listeners.has(listener);
16958        if (!wasRegistered) clearFastPathNotifiedListener(fastPathFrames, group, listener);
16959        if (!listenerKeysValue) {
16960          if (wasRegistered) preserveFastPathFrames(fastPathFrames, group);
16961          preserveFastPathPassedListeners(fastPathFrames, group, listener);
16962        } else preserveFastPathPassedKeyedListeners({
16963          fastPathFrames,
16964          group,
16965          keys: listenerKeysValue,
16966          listener
16967        });
16968        if (wasRegistered) {
16969          preserveFastPathFrames(fastPathFrames, group, listener);
16970          deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
16971        }
16972        group.listeners.add(listener);
16973        if (listenerKeysValue) {
16974          group.listenersByKey ??= /* @__PURE__ */ new Map();
16975          addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
16976          addFastPathKeyedListener({
16977            fastPathFrames,
16978            group,
16979            keys: listenerKeysValue,
16980            listener
16981          });
16982        } else {
16983          group.allKeysListeners ??= /* @__PURE__ */ new Set();
16984          group.allKeysListeners.add(listener);
16985        }
16986        group.listenerKeys.set(listener, listenerKeysValue);
16987        return () => {
16988          const cleanup = group.disposables.get(listener);
16989          group.disposables.delete(listener);
16990          preserveFastPathFrames(fastPathFrames, group, listener);
16991          const currentKeys = group.listenerKeys.get(listener);
16992          deleteListenerIndexes(group, listener, listenerKeysValue);
16993          if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
16994          group.listenerKeys.delete(listener);
16995          group.listeners.delete(listener);
16996          cleanup?.();
16997        };
16998      };
16999      const storeSubscribe = (keys, listener) => registerListener(keys, listener);
17000      const runInitialListener = (group, listener, prevState) => {
17001        const shouldSuspend = group.listeners.has(listener);
17002        if (shouldSuspend) {
17003          group.suspendCounts ??= /* @__PURE__ */ new Map();
17004          const count = group.suspendCounts.get(listener) ?? 0;
17005          group.suspendCounts.set(listener, count + 1);
17006        }
17007        let cleanupPrevState;
17008        try {
17009          const stateBeforeCleanups = state;
17010          runPendingCleanup(group, listener);
17011          if (state !== stateBeforeCleanups) cleanupPrevState = getCleanupPrevState(prevState, state, stateBeforeCleanups);
17012          const cleanup = listener(state, cleanupPrevState ?? prevState);
17013          if (cleanup) setListenerCleanup(group, listener, cleanup);
17014        } finally {
17015          if (shouldSuspend) {
17016            const suspendCounts = group.suspendCounts;
17017            const count = suspendCounts?.get(listener);
17018            if (count && count > 1) suspendCounts?.set(listener, count - 1);
17019            else suspendCounts?.delete(listener);
17020            if (!suspendCounts?.size) delete group.suspendCounts;
17021          }
17022        }
17023      };
17024      const storeSync = (keys, listener) => {
17025        runInitialListener(syncListenerGroup, listener, state);
17026        return registerListener(keys, listener);
17027      };
17028      const storeBatch = (keys, listener) => {
17029        if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
17030        runInitialListener(batchListenerGroup, listener, prevStateBatch);
17031        return registerListener(keys, listener, batchListenerGroup);
17032      };
17033      const storePick = (keys) => createStore(pick(state, keys), finalStore);
17034      const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
17035      const getState = () => state;
17036      const runListeners = (group, prevState, updatedKey) => {
17037        if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
17038          const keyedListeners = group.listenersByKey?.get(updatedKey);
17039          if (!keyedListeners) return;
17040          const frame = {
17041            group,
17042            keyedListeners,
17043            updatedKey,
17044            currentListener: null
17045          };
17046          fastPathFrames.push(frame);
17047          try {
17048            for (const listener of keyedListeners) {
17049              if (frame.notifiedListeners?.has(listener)) continue;
17050              frame.currentListener = listener;
17051              frame.notifiedListeners?.add(listener);
17052              notifyStoreListener(group, listener, state, prevState, getState, updatedKey);
17053              if (!group.allKeysListeners?.size && !frame.recoverToLive) continue;
17054              const notifiedListeners = frame.notifiedListeners ?? getFastPathNotifiedListeners(frame);
17055              frame.notifiedListeners = notifiedListeners;
17056              frame.recovering = true;
17057              runLiveListeners({
17058                group,
17059                getState,
17060                prevState,
17061                updatedKey,
17062                notifiedListeners
17063              });
17064              return;
17065            }
17066          } finally {
17067            fastPathFrames.pop();
17068          }
17069          return;
17070        }
17071        runLiveListeners({
17072          group,
17073          getState,
17074          prevState,
17075          updatedKey
17076        });
17077      };
17078      const setState = (key, value, fromStores = false) => {
17079        if (!hasOwnProperty(state, key)) return;
17080        const currentValue = state[key];
17081        const nextValue = typeof value === "function" ? value(currentValue) : value;
17082        if (isSameValue(nextValue, currentValue)) return;
17083        const wasInDispatch = inDispatch;
17084        inDispatch = true;
17085        const prevState = state;
17086        const nextState = {
17087          ...state,
17088          [key]: nextValue
17089        };
17090        state = nextState;
17091        let superseded = false;
17092        try {
17093          if (!fromStores && stores.length) {
17094            for (const store of stores) {
17095              store?.setState?.(key, nextValue);
17096              if (isSameValue(state[key], nextValue)) continue;
17097              superseded = true;
17098              break;
17099            }
17100            if (superseded) {
17101              let pass = 0;
17102              for (; pass < MAX_REPAIR_PASSES; pass += 1) {
17103                let changed = false;
17104                for (const store of stores) {
17105                  const previousValue = state[key];
17106                  store?.setState?.(key, previousValue);
17107                  if (!isSameValue(state[key], previousValue)) changed = true;
17108                }
17109                if (!changed) break;
17110              }
17111              if (pass === MAX_REPAIR_PASSES) console.warn("Parent stores did not converge after a superseded fan-out; a parent listener may be rewriting this key in a cycle.");
17112            }
17113          }
17114          if (!superseded) runListeners(syncListenerGroup, state === nextState ? prevState : {
17115            ...state,
17116            [key]: prevState[key]
17117          }, key);
17118        } finally {
17119          inDispatch = wasInDispatch;
17120        }
17121        if (!batchListenerGroup.listeners.size) {
17122          if (!inDispatch) prevStateBatch = state;
17123          return;
17124        }
17125        updatedKeys.add(key);
17126        if (batchPending) return;
17127        batchPending = true;
17128        queueMicrotask(() => {
17129          batchPending = false;
17130          const snapshot = state;
17131          const updatedKeysSnapshot = updatedKeys;
17132          updatedKeys = /* @__PURE__ */ new Set();
17133          const prevStateBatchBefore = prevStateBatch;
17134          runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
17135          if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
17136        });
17137      };
17138      const finalStore = {
17139        getState,
17140        setState,
17141        __unstableInternals: {
17142          setup: storeSetup,
17143          init: storeInit,
17144          subscribe: storeSubscribe,
17145          sync: storeSync,
17146          batch: storeBatch,
17147          pick: storePick,
17148          omit: storeOmit
17149        }
17150      };
17151      return finalStore;
17152    }
17153    function setup(store, ...args) {
17154      if (!store) return;
17155      return getInternal(store, "setup")(...args);
17156    }
17157    function init(store, ...args) {
17158      if (!store) return;
17159      return getInternal(store, "init")(...args);
17160    }
17161    function subscribe(store, ...args) {
17162      if (!store) return;
17163      return getInternal(store, "subscribe")(...args);
17164    }
17165    function sync(store, ...args) {
17166      if (!store) return;
17167      return getInternal(store, "sync")(...args);
17168    }
17169    function batch(store, ...args) {
17170      if (!store) return;
17171      return getInternal(store, "batch")(...args);
17172    }
17173    function omit2(store, ...args) {
17174      if (!store) return;
17175      return getInternal(store, "omit")(...args);
17176    }
17177    function pick2(store, ...args) {
17178      if (!store) return;
17179      return getInternal(store, "pick")(...args);
17180    }
17181    function mergeStore(...stores) {
17182      const initialState = {};
17183      for (const store2 of stores) {
17184        const nextState = store2?.getState?.();
17185        if (nextState) Object.assign(initialState, nextState);
17186      }
17187      const store = createStore(initialState, ...stores);
17188      return Object.assign({}, ...stores, store);
17189    }
17190    function throwOnConflictingProps(props, store) {
17191      if (false) return;
17192      if (!store) return;
17193      const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
17194        const stateKey = key.replace("default", "");
17195        return `$stateKey[0]?.toLowerCase() || ""}$stateKey.slice(1)}`;
17196      });
17197      if (!defaultKeys.length) return;
17198      const storeState = store.getState();
17199      if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
17200      throw new Error(`Passing a store prop in conjunction with a default state is not supported.
17201  
17202  const store = useSelectStore();
17203  <SelectProvider store={store} defaultValue="Apple" />
17204                  ^             ^
17205  
17206  Instead, pass the default state to the topmost store:
17207  
17208  const store = useSelectStore({ defaultValue: "Apple" });
17209  <SelectProvider store={store} />
17210  
17211  See https://github.com/ariakit/ariakit/pull/2745 for more details.
17212  
17213  If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
17214  `);
17215    }
17216  
17217    // node_modules/@ariakit/components/dist/collection/collection-store.js
17218    function getCommonParent(items) {
17219      const firstItem = items.find((item) => !!item.element);
17220      const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
17221      let parentElement = firstItem?.element?.parentElement;
17222      if (!lastElement) return getDocument(parentElement).body;
17223      while (parentElement) {
17224        if (parentElement.contains(lastElement)) return parentElement;
17225        parentElement = parentElement.parentElement;
17226      }
17227      return getDocument(parentElement).body;
17228    }
17229    function getPrivateStore(store) {
17230      return store?.__unstablePrivateStore;
17231    }
17232    function createCollectionStore(props = {}) {
17233      throwOnConflictingProps(props, props.store);
17234      const syncState = props.store?.getState();
17235      const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
17236      const itemsMap = new Map(items.map((item) => [item.id, item]));
17237      const initialState = {
17238        items,
17239        renderedItems: defaultValue(syncState?.renderedItems, [])
17240      };
17241      const syncPrivateStore = getPrivateStore(props.store);
17242      const privateStore = createStore({
17243        items,
17244        renderedItems: initialState.renderedItems
17245      }, syncPrivateStore);
17246      const collection = createStore(initialState, props.store);
17247      const sortItems = (renderedItems) => {
17248        const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17249        privateStore.setState("renderedItems", sortedItems);
17250        collection.setState("renderedItems", sortedItems);
17251      };
17252      setup(collection, () => init(privateStore));
17253      setup(privateStore, () => {
17254        return batch(privateStore, ["items"], (state) => {
17255          collection.setState("items", state.items);
17256        });
17257      });
17258      setup(privateStore, () => {
17259        return batch(privateStore, ["renderedItems"], (state) => {
17260          let firstRun = true;
17261          let raf = requestAnimationFrame(() => {
17262            const { renderedItems } = collection.getState();
17263            if (state.renderedItems === renderedItems) return;
17264            sortItems(state.renderedItems);
17265          });
17266          if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
17267          const ioCallback = () => {
17268            if (firstRun) {
17269              firstRun = false;
17270              return;
17271            }
17272            cancelAnimationFrame(raf);
17273            raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17274          };
17275          const root = getCommonParent(state.renderedItems);
17276          const observer = new IntersectionObserver(ioCallback, { root });
17277          for (const item of state.renderedItems) {
17278            if (!item.element) continue;
17279            observer.observe(item.element);
17280          }
17281          return () => {
17282            cancelAnimationFrame(raf);
17283            observer.disconnect();
17284          };
17285        });
17286      });
17287      const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17288        let prevItem;
17289        setItems((items2) => {
17290          const index2 = items2.findIndex(({ id }) => id === item.id);
17291          const nextItems = items2.slice();
17292          if (index2 !== -1) {
17293            prevItem = items2[index2];
17294            const nextItem = {
17295              ...prevItem,
17296              ...item
17297            };
17298            nextItems[index2] = nextItem;
17299            itemsMap.set(item.id, nextItem);
17300          } else {
17301            nextItems.push(item);
17302            itemsMap.set(item.id, item);
17303          }
17304          return nextItems;
17305        });
17306        const unmergeItem = () => {
17307          setItems((items2) => {
17308            if (!prevItem) {
17309              if (canDeleteFromMap) itemsMap.delete(item.id);
17310              return items2.filter(({ id }) => id !== item.id);
17311            }
17312            const index2 = items2.findIndex(({ id }) => id === item.id);
17313            if (index2 === -1) return items2;
17314            const nextItems = items2.slice();
17315            nextItems[index2] = prevItem;
17316            itemsMap.set(item.id, prevItem);
17317            return nextItems;
17318          });
17319        };
17320        return unmergeItem;
17321      };
17322      const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
17323      return {
17324        ...collection,
17325        registerItem,
17326        renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
17327        item: (id) => {
17328          if (!id) return null;
17329          let item = itemsMap.get(id);
17330          if (!item) {
17331            const { items: items2 } = privateStore.getState();
17332            item = items2.find((item2) => item2.id === id);
17333            if (item) itemsMap.set(id, item);
17334          }
17335          return item || null;
17336        },
17337        __unstablePrivateStore: privateStore
17338      };
17339    }
17340  
17341    // node_modules/@ariakit/components/dist/composite/composite-store.js
17342    var NULL_ITEM = { id: null };
17343    function findFirstEnabledItem(items, excludeId) {
17344      return items.find((item) => {
17345        if (excludeId) return !item.disabled && item.id !== excludeId;
17346        return !item.disabled;
17347      });
17348    }
17349    function getEnabledItems(items, excludeId) {
17350      return items.filter((item) => {
17351        if (excludeId) return !item.disabled && item.id !== excludeId;
17352        return !item.disabled;
17353      });
17354    }
17355    function getItemsInRow(items, rowId) {
17356      return items.filter((item) => item.rowId === rowId);
17357    }
17358    function findEnabledItemId({ items, fromIndex, step, rowId, excludeId }) {
17359      for (let i2 = fromIndex; i2 >= 0 && i2 < items.length; i2 += step) {
17360        const item = items[i2];
17361        if (!item) continue;
17362        if (item.rowId !== rowId) continue;
17363        if (item.disabled) continue;
17364        if (excludeId != null && item.id === excludeId) continue;
17365        return item.id;
17366      }
17367    }
17368    function flipItems(items, activeId, shouldInsertNullItem = false) {
17369      const index2 = items.findIndex((item) => item.id === activeId);
17370      return [
17371        ...items.slice(index2 + 1),
17372        ...shouldInsertNullItem ? [NULL_ITEM] : [],
17373        ...items.slice(0, index2)
17374      ];
17375    }
17376    function groupItemsByRows(items) {
17377      const rows = [];
17378      for (const item of items) {
17379        const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
17380        if (row) row.push(item);
17381        else rows.push([item]);
17382      }
17383      return rows;
17384    }
17385    function getMaxRowLength(array) {
17386      let maxLength = 0;
17387      for (const { length } of array) if (length > maxLength) maxLength = length;
17388      return maxLength;
17389    }
17390    function createEmptyItem(rowId) {
17391      return {
17392        id: "__EMPTY_ITEM__",
17393        disabled: true,
17394        rowId
17395      };
17396    }
17397    function normalizeRows(rows, activeId, focusShift) {
17398      const maxLength = getMaxRowLength(rows);
17399      for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
17400        const item = row[i2];
17401        if (!item || focusShift && item.disabled) {
17402          const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem(row) : row[i2 - 1];
17403          row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
17404        }
17405      }
17406      return rows;
17407    }
17408    function verticalizeItems(items) {
17409      const rows = groupItemsByRows(items);
17410      const maxLength = getMaxRowLength(rows);
17411      const verticalized = [];
17412      for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
17413        const item = row[i2];
17414        if (item) verticalized.push({
17415          ...item,
17416          rowId: item.rowId ? `$i2}` : void 0
17417        });
17418      }
17419      return verticalized;
17420    }
17421    function createCompositeStore(props = {}) {
17422      const syncState = props.store?.getState();
17423      const collection = createCollectionStore(props);
17424      const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
17425      const composite = createStore({
17426        ...collection.getState(),
17427        id: defaultValue(props.id, syncState?.id) ?? `id-$Math.random().toString(36).slice(2, 8)}`,
17428        activeId,
17429        baseElement: defaultValue(syncState?.baseElement, null),
17430        includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
17431        moves: defaultValue(syncState?.moves, 0),
17432        orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
17433        rtl: defaultValue(props.rtl, syncState?.rtl, false),
17434        virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
17435        focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
17436        focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
17437        focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
17438      }, collection, props.store);
17439      setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
17440        composite.setState("activeId", (activeId2) => {
17441          if (activeId2 !== void 0) return activeId2;
17442          return findFirstEnabledItem(state.renderedItems)?.id;
17443        });
17444      }));
17445      const getNextId = (direction = "next", options = {}) => {
17446        const defaultState = composite.getState();
17447        const { skip = 0, activeId: activeId2 = defaultState.activeId, focusShift = defaultState.focusShift, focusLoop = defaultState.focusLoop, focusWrap = defaultState.focusWrap, includesBaseElement = defaultState.includesBaseElement, renderedItems = defaultState.renderedItems, rtl = defaultState.rtl } = options;
17448        const isVerticalDirection = direction === "up" || direction === "down";
17449        const isNextDirection = direction === "next" || direction === "down";
17450        const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17451        const canShift = focusShift && !skip;
17452        if (!skip && !focusWrap && !includesBaseElement && activeId2 != null) {
17453          if (!isVerticalDirection ? true : !canShift && !renderedItems.some((item) => item.rowId != null)) {
17454            const activeIndex2 = renderedItems.findIndex((item) => item.id === activeId2);
17455            const activeItem2 = renderedItems[activeIndex2];
17456            if (activeItem2) {
17457              const step = canReverse ? -1 : 1;
17458              const nextId = findEnabledItemId({
17459                items: renderedItems,
17460                fromIndex: activeIndex2 + step,
17461                step,
17462                rowId: activeItem2.rowId,
17463                excludeId: activeId2
17464              });
17465              if (nextId !== void 0) return nextId;
17466              if (!(focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"))) return void 0;
17467              return findEnabledItemId({
17468                items: renderedItems,
17469                fromIndex: step === 1 ? 0 : renderedItems.length - 1,
17470                step,
17471                rowId: activeItem2.rowId,
17472                excludeId: activeId2
17473              });
17474            }
17475          }
17476        }
17477        let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift));
17478        items = canReverse ? reverseArray(items) : items;
17479        items = isVerticalDirection ? verticalizeItems(items) : items;
17480        if (activeId2 == null) return findFirstEnabledItem(items)?.id;
17481        const activeItem = items.find((item) => item.id === activeId2);
17482        if (!activeItem) return findFirstEnabledItem(items)?.id;
17483        const isGrid2 = items.some((item) => item.rowId);
17484        const activeIndex = items.indexOf(activeItem);
17485        const nextItems = items.slice(activeIndex + 1);
17486        const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17487        if (skip) {
17488          const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17489          return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
17490        }
17491        const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17492        const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17493        const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17494        if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
17495        if (canWrap) {
17496          const nextItem2 = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId2);
17497          return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
17498        }
17499        const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2);
17500        if (!nextItem && hasNullItem) return null;
17501        return nextItem?.id;
17502      };
17503      const getNextIdFromOptions = (direction, options) => {
17504        if (typeof options === "number") return getNextId(direction, { skip: options });
17505        return getNextId(direction, options);
17506      };
17507      return {
17508        ...collection,
17509        ...composite,
17510        setBaseElement: (element) => composite.setState("baseElement", element),
17511        setActiveId: (id) => composite.setState("activeId", id),
17512        move: (id) => {
17513          if (id === void 0) return;
17514          composite.setState("activeId", id);
17515          composite.setState("moves", (moves) => moves + 1);
17516        },
17517        first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,
17518        last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id,
17519        next: (options) => getNextIdFromOptions("next", options),
17520        previous: (options) => getNextIdFromOptions("previous", options),
17521        down: (options) => getNextIdFromOptions("down", options),
17522        up: (options) => getNextIdFromOptions("up", options)
17523      };
17524    }
17525  
17526    // node_modules/@ariakit/react-components/dist/composite/utils.js
17527    var findFirstEnabledItem2 = findFirstEnabledItem;
17528    var groupItemsByRows2 = groupItemsByRows;
17529    function getEnabledItem(store, id) {
17530      if (!id) return null;
17531      return store.item(id) || null;
17532    }
17533    function selectTextField(element, collapseToEnd = false) {
17534      if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
17535      else if (element.isContentEditable) {
17536        const selection = getDocument(element).getSelection();
17537        selection?.selectAllChildren(element);
17538        if (collapseToEnd) selection?.collapseToEnd();
17539      }
17540    }
17541    var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
17542    function focusSilently(element) {
17543      element[FOCUS_SILENTLY] = true;
17544      element.focus({ preventScroll: true });
17545    }
17546    function silentlyFocused(element) {
17547      const isSilentlyFocused = element[FOCUS_SILENTLY];
17548      delete element[FOCUS_SILENTLY];
17549      return isSilentlyFocused;
17550    }
17551    function isItem(store, element, exclude) {
17552      if (!element) return false;
17553      if (element === exclude) return false;
17554      const item = store.item(element.id);
17555      if (!item) return false;
17556      if (exclude && item.element === exclude) return false;
17557      return true;
17558    }
17559  
17560    // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17561    var import_react13 = __toESM(require_react(), 1);
17562    var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
17563  
17564    // node_modules/@ariakit/react-store/dist/index.js
17565    var React48 = __toESM(require_react(), 1);
17566    var import_shim2 = __toESM(require_shim(), 1);
17567    var noopSubscribe = () => () => {
17568    };
17569    function useStoreState(store, keyOrSelector = identity) {
17570      const storeSubscribe = React48.useCallback((callback) => {
17571        if (!store) return noopSubscribe();
17572        return subscribe(store, null, callback);
17573      }, [store]);
17574      const getSnapshot = () => {
17575        const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
17576        const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
17577        const state = store?.getState();
17578        if (selector2) return selector2(state);
17579        if (!state) return;
17580        if (!key) return;
17581        if (!hasOwnProperty(state, key)) return;
17582        return state[key];
17583      };
17584      return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17585    }
17586    function useStoreStateObject(store, object) {
17587      const objRef = React48.useRef({});
17588      const storeSubscribe = React48.useCallback((callback) => {
17589        if (!store) return noopSubscribe();
17590        return subscribe(store, null, callback);
17591      }, [store]);
17592      const getSnapshot = () => {
17593        const state = store?.getState();
17594        let updated = false;
17595        const obj = objRef.current;
17596        for (const prop in object) {
17597          const keyOrSelector = object[prop];
17598          if (typeof keyOrSelector === "function") {
17599            const value = keyOrSelector(state);
17600            if (!Object.is(value, obj[prop])) {
17601              obj[prop] = value;
17602              updated = true;
17603            }
17604          }
17605          if (typeof keyOrSelector === "string") {
17606            if (!state) continue;
17607            if (!hasOwnProperty(state, keyOrSelector)) continue;
17608            const value = state[keyOrSelector];
17609            if (!Object.is(value, obj[prop])) {
17610              obj[prop] = value;
17611              updated = true;
17612            }
17613          }
17614        }
17615        if (updated) objRef.current = { ...obj };
17616        return objRef.current;
17617      };
17618      return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17619    }
17620    function useStoreProps(store, props, key, setKey) {
17621      const value = hasOwnProperty(props, key) ? props[key] : void 0;
17622      const propsRef = useLiveRef({
17623        value,
17624        setValue: setKey ? props[setKey] : void 0
17625      });
17626      useSafeLayoutEffect(() => {
17627        return sync(store, [key], (state, prev) => {
17628          const { value: value2, setValue } = propsRef.current;
17629          if (!setValue) return;
17630          if (state[key] === prev[key]) return;
17631          if (state[key] === value2) return;
17632          setValue(state[key]);
17633        });
17634      }, [store, key]);
17635      useSafeLayoutEffect(() => {
17636        if (value === void 0) return;
17637        store.setState(key, value);
17638        return batch(store, [key], () => {
17639          if (value === void 0) return;
17640          store.setState(key, value);
17641        });
17642      });
17643    }
17644    function useStore2(createStore2, props) {
17645      const [store, setStore] = React48.useState(() => createStore2(props));
17646      useSafeLayoutEffect(() => init(store), [store]);
17647      const useState43 = React48.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
17648      return [React48.useMemo(() => ({
17649        ...store,
17650        useState: useState43
17651      }), [store, useState43]), useEvent(() => {
17652        setStore((store2) => createStore2({
17653          ...props,
17654          ...store2.getState()
17655        }));
17656      })];
17657    }
17658  
17659    // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17660    var TagName4 = "button";
17661    function isEditableElement(element) {
17662      if (isTextbox(element)) return true;
17663      return element.tagName === "INPUT" && !isButton(element);
17664    }
17665    function getNextPageOffset(scrollingElement, pageUp = false) {
17666      const height = scrollingElement.clientHeight;
17667      const { top } = scrollingElement.getBoundingClientRect();
17668      const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
17669      const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
17670      if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
17671      return pageOffset;
17672    }
17673    function getItemOffset(itemElement, pageUp = false) {
17674      const { top } = itemElement.getBoundingClientRect();
17675      if (pageUp) return top + itemElement.clientHeight;
17676      return top;
17677    }
17678    function findNextPageItemId(element, store, next, pageUp = false) {
17679      if (!store) return;
17680      if (!next) return;
17681      const { renderedItems } = store.getState();
17682      const scrollingElement = getScrollingElement(element);
17683      if (!scrollingElement) return;
17684      const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
17685      let id;
17686      let prevDifference;
17687      for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
17688        const previousId = id;
17689        id = next(i2);
17690        if (!id) break;
17691        if (id === previousId) continue;
17692        const itemElement = getEnabledItem(store, id)?.element;
17693        if (!itemElement) continue;
17694        const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
17695        const absDifference = Math.abs(difference);
17696        if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
17697          if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
17698          break;
17699        }
17700        prevDifference = absDifference;
17701      }
17702      return id;
17703    }
17704    function targetIsAnotherItem(event, store) {
17705      if (isSelfTarget(event)) return false;
17706      return isItem(store, event.target);
17707    }
17708    var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
17709      const context = useCompositeScopedContext();
17710      store = store || context;
17711      const id = useId4(props.id);
17712      const ref = (0, import_react13.useRef)(null);
17713      const row = (0, import_react13.useContext)(CompositeRowContext);
17714      const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
17715      const shouldRegisterItem = props.shouldRegisterItem;
17716      const getRowId = (state) => {
17717        if (rowIdProp) return rowIdProp;
17718        if (!state) return;
17719        if (!row?.baseElement) return;
17720        if (row.baseElement !== state.baseElement) return;
17721        return row.id;
17722      };
17723      const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
17724        rowId: getRowId,
17725        baseElement(state) {
17726          return state?.baseElement || void 0;
17727        },
17728        isActiveItem(state) {
17729          return !!state && state.activeId === id;
17730        },
17731        ariaSetSize(state) {
17732          if (ariaSetSizeProp != null) return ariaSetSizeProp;
17733          if (!state) return;
17734          if (!row?.ariaSetSize) return;
17735          if (row.baseElement !== state.baseElement) return;
17736          return row.ariaSetSize;
17737        },
17738        ariaPosInSet(state) {
17739          if (ariaPosInSetProp != null) return ariaPosInSetProp;
17740          if (!state) return;
17741          if (!row?.ariaPosInSet) return;
17742          if (row.baseElement !== state.baseElement) return;
17743          const rowId2 = getRowId(state);
17744          const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId2);
17745          return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
17746        },
17747        isTabbable(state) {
17748          if (!state?.renderedItems.length) return true;
17749          if (state.virtualFocus) return false;
17750          if (tabbable2) return true;
17751          if (state.activeId === null) return false;
17752          const item = store?.item(state.activeId);
17753          if (item?.disabled) return true;
17754          if (!item?.element) return true;
17755          return state.activeId === id;
17756        }
17757      });
17758      const getItem = (0, import_react13.useCallback)((item) => {
17759        const nextItem = {
17760          ...item,
17761          id: id || item.id,
17762          rowId,
17763          disabled: trulyDisabled,
17764          children: item.element?.textContent
17765        };
17766        if (getItemProp) return getItemProp(nextItem);
17767        return nextItem;
17768      }, [
17769        id,
17770        rowId,
17771        trulyDisabled,
17772        getItemProp
17773      ]);
17774      const onFocusProp = props.onFocus;
17775      const hasFocusedComposite = (0, import_react13.useRef)(false);
17776      const cancelScheduledFocusRedirectRef = (0, import_react13.useRef)(null);
17777      const onFocus = useEvent((event) => {
17778        onFocusProp?.(event);
17779        if (event.defaultPrevented) return;
17780        if (isPortalEvent(event)) return;
17781        if (!id) return;
17782        if (!store) return;
17783        if (targetIsAnotherItem(event, store)) return;
17784        const { virtualFocus, baseElement: baseElement2 } = store.getState();
17785        store.setActiveId(id);
17786        if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
17787        if (!virtualFocus) return;
17788        if (!isSelfTarget(event)) return;
17789        if (isEditableElement(event.currentTarget)) return;
17790        const redirectFocusToBaseElement = (currentTarget2, relatedTarget2, baseElement3) => {
17791          if (isSafari() && currentTarget2.hasAttribute("data-autofocus")) currentTarget2.scrollIntoView({
17792            block: "nearest",
17793            inline: "nearest"
17794          });
17795          hasFocusedComposite.current = true;
17796          if (relatedTarget2 === baseElement3 || isItem(store, relatedTarget2)) focusSilently(baseElement3);
17797          else baseElement3.focus();
17798        };
17799        if (baseElement2?.isConnected) {
17800          redirectFocusToBaseElement(event.currentTarget, event.relatedTarget, baseElement2);
17801          return;
17802        }
17803        if (shouldRegisterItem === false) return;
17804        const { currentTarget, relatedTarget } = event;
17805        const cancelScheduledFocusRedirect = () => {
17806          cancelScheduledFocusRedirectRef.current?.();
17807          cancelScheduledFocusRedirectRef.current = null;
17808        };
17809        cancelScheduledFocusRedirect();
17810        cancelScheduledFocusRedirectRef.current = subscribe(store, null, () => {
17811          if (getActiveElement(currentTarget) !== currentTarget) {
17812            cancelScheduledFocusRedirect();
17813            return;
17814          }
17815          const state = store.getState();
17816          const nextBaseElement = state.baseElement;
17817          if (!nextBaseElement?.isConnected) return;
17818          cancelScheduledFocusRedirect();
17819          if (!state.virtualFocus) return;
17820          redirectFocusToBaseElement(currentTarget, relatedTarget, nextBaseElement);
17821        });
17822      });
17823      const onBlurCaptureProp = props.onBlurCapture;
17824      const onBlurCapture = useEvent((event) => {
17825        onBlurCaptureProp?.(event);
17826        if (event.defaultPrevented) return;
17827        if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
17828          hasFocusedComposite.current = false;
17829          event.preventDefault();
17830          event.stopPropagation();
17831        }
17832      });
17833      const onKeyDownProp = props.onKeyDown;
17834      const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
17835      const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17836      const onKeyDown = useEvent((event) => {
17837        onKeyDownProp?.(event);
17838        if (event.defaultPrevented) return;
17839        if (!isSelfTarget(event)) return;
17840        if (!store) return;
17841        const { currentTarget } = event;
17842        const state = store.getState();
17843        const isGrid2 = !!store.item(id)?.rowId;
17844        const isVertical = state.orientation !== "horizontal";
17845        const isHorizontal = state.orientation !== "vertical";
17846        const canHomeEnd = () => {
17847          if (isGrid2) return true;
17848          if (isHorizontal) return true;
17849          if (!state.baseElement) return true;
17850          if (!isTextField(state.baseElement)) return true;
17851          return false;
17852        };
17853        const action = {
17854          ArrowUp: (isGrid2 || isVertical) && store.up,
17855          ArrowRight: (isGrid2 || isHorizontal) && store.next,
17856          ArrowDown: (isGrid2 || isVertical) && store.down,
17857          ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
17858          Home: () => {
17859            if (!canHomeEnd()) return;
17860            if (!isGrid2 || event.ctrlKey) return store?.first();
17861            return store?.previous(-1);
17862          },
17863          End: () => {
17864            if (!canHomeEnd()) return;
17865            if (!isGrid2 || event.ctrlKey) return store?.last();
17866            return store?.next(-1);
17867          },
17868          PageUp: () => {
17869            return findNextPageItemId(currentTarget, store, store?.up, true);
17870          },
17871          PageDown: () => {
17872            return findNextPageItemId(currentTarget, store, store?.down);
17873          }
17874        }[event.key];
17875        if (action) {
17876          if (isTextbox(currentTarget)) {
17877            const selection = getTextboxSelection(currentTarget);
17878            const isLeft = isHorizontal && event.key === "ArrowLeft";
17879            const isRight = isHorizontal && event.key === "ArrowRight";
17880            const isUp = isVertical && event.key === "ArrowUp";
17881            const isDown = isVertical && event.key === "ArrowDown";
17882            if (isRight || isDown) {
17883              const { length: valueLength } = getTextboxValue(currentTarget);
17884              if (selection.end !== valueLength) return;
17885            } else if ((isLeft || isUp) && selection.start !== 0) return;
17886          }
17887          const nextId = action();
17888          if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
17889            if (!moveOnKeyPressProp(event)) return;
17890            event.preventDefault();
17891            store.move(nextId);
17892          }
17893        }
17894      });
17895      const providerValue = (0, import_react13.useMemo)(() => ({
17896        id,
17897        baseElement
17898      }), [id, baseElement]);
17899      props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeItemContext.Provider, {
17900        value: providerValue,
17901        children: element
17902      }), [providerValue]);
17903      props = {
17904        "data-active-item": isActiveItem || void 0,
17905        ...props,
17906        id,
17907        ref: useMergeRefs(ref, props.ref),
17908        tabIndex: isTabbable ? props.tabIndex : -1,
17909        onFocus,
17910        onBlurCapture,
17911        onKeyDown
17912      };
17913      props = useCommand(props);
17914      props = useCollectionItem({
17915        store,
17916        ...props,
17917        getItem,
17918        shouldRegisterItem: id ? shouldRegisterItem : false
17919      });
17920      return removeUndefinedValues({
17921        ...props,
17922        "aria-setsize": ariaSetSize,
17923        "aria-posinset": ariaPosInSet
17924      });
17925    });
17926    var CompositeItem = memo3(forwardRef21(function CompositeItem2(props) {
17927      return createElement3(TagName4, useCompositeItem(props));
17928    }));
17929  
17930    // node_modules/@ariakit/react-components/dist/composite/composite.js
17931    var import_react14 = __toESM(require_react(), 1);
17932    var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
17933    var TagName5 = "div";
17934    function isGrid(items) {
17935      return items.some((item) => !!item.rowId);
17936    }
17937    function isPrintableKey(event) {
17938      const target = event.target;
17939      if (target && !isTextField(target)) return false;
17940      return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
17941    }
17942    function isModifierKey(event) {
17943      return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
17944    }
17945    function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
17946      return useEvent((event) => {
17947        onKeyboardEvent?.(event);
17948        if (event.defaultPrevented) return;
17949        if (event.isPropagationStopped()) return;
17950        if (!isSelfTarget(event)) return;
17951        if (isModifierKey(event)) return;
17952        if (isPrintableKey(event)) return;
17953        const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
17954        if (!activeElement2) return;
17955        const { view, ...eventInit } = event;
17956        if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
17957        if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
17958        if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
17959      });
17960    }
17961    function findFirstEnabledItemInTheLastRow(items) {
17962      return findFirstEnabledItem2(flatten2DArray(reverseArray(groupItemsByRows2(items))));
17963    }
17964    function withBaseScrollPreserved(store, callback) {
17965      const { virtualFocus, baseElement } = store.getState();
17966      if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
17967        callback();
17968        return;
17969      }
17970      const savedScrollLeft = baseElement.scrollLeft;
17971      const savedScrollTop = baseElement.scrollTop;
17972      callback();
17973      baseElement.scrollLeft = savedScrollLeft;
17974      baseElement.scrollTop = savedScrollTop;
17975    }
17976    function useScheduleFocus(store) {
17977      const [scheduled, setScheduled] = (0, import_react14.useState)(false);
17978      const schedule = (0, import_react14.useCallback)(() => setScheduled(true), []);
17979      const activeItem = useStoreState(store, (state) => scheduled ? getEnabledItem(store, state.activeId) : null);
17980      (0, import_react14.useEffect)(() => {
17981        const activeElement2 = activeItem?.element;
17982        if (!scheduled) return;
17983        if (!activeElement2) return;
17984        setScheduled(false);
17985        withBaseScrollPreserved(store, () => {
17986          activeElement2.focus({ preventScroll: true });
17987        });
17988      }, [
17989        store,
17990        activeItem,
17991        scheduled
17992      ]);
17993      return schedule;
17994    }
17995    var CompositeFocusOnMove = memo3(function CompositeFocusOnMove2({ store, focusOnMove, previousElementRef }) {
17996      const moves = useStoreState(store, "moves");
17997      const baseElement = useStoreState(store, "baseElement");
17998      (0, import_react14.useEffect)(() => {
17999        if (!moves) return;
18000        if (!focusOnMove) return;
18001        const { activeId } = store.getState();
18002        const itemElement = getEnabledItem(store, activeId)?.element;
18003        if (!itemElement) return;
18004        withBaseScrollPreserved(store, () => focusIntoView(itemElement));
18005      }, [
18006        store,
18007        moves,
18008        focusOnMove
18009      ]);
18010      useSafeLayoutEffect(() => {
18011        if (!moves) return;
18012        if (!baseElement) return;
18013        const { activeId } = store.getState();
18014        if (!(activeId === null)) return;
18015        const previousElement = previousElementRef.current;
18016        previousElementRef.current = null;
18017        if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
18018        if (!hasFocus(baseElement)) baseElement.focus();
18019      }, [
18020        store,
18021        moves,
18022        baseElement
18023      ]);
18024      return null;
18025    });
18026    var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
18027      const context = useCompositeProviderContext();
18028      store = store || context;
18029      invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
18030      const ref = (0, import_react14.useRef)(null);
18031      const previousElementRef = (0, import_react14.useRef)(null);
18032      const scheduleFocus = useScheduleFocus(store);
18033      const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
18034      const virtualFocus = useStoreState(store, "virtualFocus");
18035      const activeId = useStoreState(store, (state) => state.virtualFocus ? state.activeId : null);
18036      useSafeLayoutEffect(() => {
18037        if (!store) return;
18038        if (!composite) return;
18039        if (!virtualFocus) return;
18040        const previousElement = previousElementRef.current;
18041        previousElementRef.current = null;
18042        if (!previousElement) return;
18043        const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
18044        if (relatedTarget === previousElement) return;
18045        fireBlurEvent(previousElement, { relatedTarget });
18046      }, [
18047        store,
18048        activeId,
18049        virtualFocus,
18050        composite
18051      ]);
18052      const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
18053      const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
18054      const onFocusCaptureProp = props.onFocusCapture;
18055      const onFocusCapture = useEvent((event) => {
18056        onFocusCaptureProp?.(event);
18057        if (event.defaultPrevented) return;
18058        if (!store) return;
18059        const { virtualFocus: virtualFocus2 } = store.getState();
18060        if (!virtualFocus2) return;
18061        const previousActiveElement = event.relatedTarget;
18062        const isSilentlyFocused = silentlyFocused(event.currentTarget);
18063        if (isSelfTarget(event) && isSilentlyFocused) {
18064          event.stopPropagation();
18065          previousElementRef.current = previousActiveElement;
18066        }
18067      });
18068      const onFocusProp = props.onFocus;
18069      const onFocus = useEvent((event) => {
18070        onFocusProp?.(event);
18071        if (event.defaultPrevented) return;
18072        if (!composite) return;
18073        if (!store) return;
18074        const { relatedTarget } = event;
18075        const { virtualFocus: virtualFocus2 } = store.getState();
18076        if (virtualFocus2) {
18077          if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
18078        } else if (isSelfTarget(event)) store.setActiveId(null);
18079      });
18080      const onBlurCaptureProp = props.onBlurCapture;
18081      const onBlurCapture = useEvent((event) => {
18082        onBlurCaptureProp?.(event);
18083        if (event.defaultPrevented) return;
18084        if (!store) return;
18085        const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
18086        if (!virtualFocus2) return;
18087        const activeElement2 = getEnabledItem(store, activeId2)?.element;
18088        const nextActiveElement = event.relatedTarget;
18089        const nextActiveElementIsItem = isItem(store, nextActiveElement);
18090        const previousElement = previousElementRef.current;
18091        previousElementRef.current = null;
18092        if (isSelfTarget(event) && nextActiveElementIsItem) {
18093          if (nextActiveElement === activeElement2) {
18094            if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
18095          } else if (activeElement2) fireBlurEvent(activeElement2, event);
18096          else if (previousElement) fireBlurEvent(previousElement, event);
18097          event.stopPropagation();
18098        } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
18099      });
18100      const onKeyDownProp = props.onKeyDown;
18101      const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18102      const onKeyDown = useEvent((event) => {
18103        onKeyDownProp?.(event);
18104        if (event.nativeEvent.isComposing) return;
18105        if (event.defaultPrevented) return;
18106        if (!store) return;
18107        if (!isSelfTarget(event)) return;
18108        const { orientation, renderedItems, activeId: activeId2, rtl } = store.getState();
18109        if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
18110        const isVertical = orientation !== "horizontal";
18111        const isHorizontal = orientation !== "vertical";
18112        const grid = isGrid(renderedItems);
18113        if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
18114        const up = () => {
18115          if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
18116          return store?.last();
18117        };
18118        const action = {
18119          ArrowUp: (grid || isVertical) && up,
18120          ArrowRight: (grid || isHorizontal) && (rtl ? store.last : store.first),
18121          ArrowDown: (grid || isVertical) && store.first,
18122          ArrowLeft: (grid || isHorizontal) && (rtl ? store.first : store.last),
18123          Home: store.first,
18124          End: store.last,
18125          PageUp: store.first,
18126          PageDown: store.last
18127        }[event.key];
18128        if (action) {
18129          const id = action();
18130          if (id !== void 0) {
18131            if (!moveOnKeyPressProp(event)) return;
18132            event.preventDefault();
18133            store.move(id);
18134          }
18135        }
18136      });
18137      props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(CompositeScopedContextProvider, {
18138        value: store,
18139        children: [element, composite && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(CompositeFocusOnMove, {
18140          store,
18141          focusOnMove,
18142          previousElementRef
18143        })]
18144      }), [
18145        store,
18146        composite,
18147        focusOnMove
18148      ]);
18149      props = {
18150        "aria-activedescendant": useStoreState(store, (state) => {
18151          if (!store) return;
18152          if (!composite) return;
18153          if (!state.virtualFocus) return;
18154          return getEnabledItem(store, state.activeId)?.id;
18155        }),
18156        ...props,
18157        ref: useMergeRefs(ref, setBaseElement, props.ref),
18158        onKeyDownCapture,
18159        onKeyUpCapture,
18160        onFocusCapture,
18161        onFocus,
18162        onBlurCapture,
18163        onKeyDown
18164      };
18165      props = useFocusable({
18166        focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
18167        ...props
18168      });
18169      return props;
18170    });
18171    var Composite6 = forwardRef21(function Composite7(props) {
18172      return createElement3(TagName5, useComposite(props));
18173    });
18174  
18175    // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
18176    var ctx3 = createStoreContext();
18177    var useDisclosureContext = ctx3.useContext;
18178    var useDisclosureScopedContext = ctx3.useScopedContext;
18179    var useDisclosureProviderContext = ctx3.useProviderContext;
18180    var DisclosureContextProvider = ctx3.ContextProvider;
18181    var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
18182  
18183    // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
18184    var import_react15 = __toESM(require_react(), 1);
18185    var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
18186    var useDialogContext = ctx4.useContext;
18187    var useDialogScopedContext = ctx4.useScopedContext;
18188    var useDialogProviderContext = ctx4.useProviderContext;
18189    var DialogContextProvider = ctx4.ContextProvider;
18190    var DialogScopedContextProvider = ctx4.ScopedContextProvider;
18191    var DialogHeadingContext = (0, import_react15.createContext)(void 0);
18192    var DialogDescriptionContext = (0, import_react15.createContext)(void 0);
18193  
18194    // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
18195    var import_react16 = __toESM(require_react(), 1);
18196    var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18197    var import_react_dom4 = __toESM(require_react_dom(), 1);
18198    var TagName6 = "div";
18199    function afterTimeout(timeoutMs, cb) {
18200      const timeoutId = setTimeout(cb, timeoutMs);
18201      return () => clearTimeout(timeoutId);
18202    }
18203    function parseCSSTime(time) {
18204      const value = time?.trim() || "0s";
18205      const multiplier = value.endsWith("ms") ? 1 : 1e3;
18206      const parsed = Number.parseFloat(value) * multiplier;
18207      return Number.isNaN(parsed) ? 0 : parsed;
18208    }
18209    function getEndTime(names, delays, durations) {
18210      const nameList = names.split(",");
18211      const delayList = delays.split(",");
18212      const durationList = durations.split(",");
18213      let endTime = 0;
18214      for (const [index2, name] of nameList.entries()) {
18215        if (name.trim() === "none") continue;
18216        const delay = parseCSSTime(delayList[index2 % delayList.length]);
18217        const duration = parseCSSTime(durationList[index2 % durationList.length]);
18218        endTime = Math.max(endTime, delay + duration);
18219      }
18220      return endTime;
18221    }
18222    function getElementEndTime(element) {
18223      const { transitionProperty, transitionDuration, transitionDelay, animationName, animationDuration, animationDelay } = getComputedStyle(element);
18224      return Math.max(getEndTime(transitionProperty, transitionDelay, transitionDuration), getEndTime(animationName, animationDelay, animationDuration));
18225    }
18226    function isHidden(mounted, hidden, alwaysVisible) {
18227      return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
18228    }
18229    var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, unstable_otherElementRef: otherElementRef, ...props }) {
18230      const context = useDisclosureProviderContext();
18231      store = store || context;
18232      invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
18233      const ref = (0, import_react16.useRef)(null);
18234      const id = useId4(props.id);
18235      const [transition, setTransition] = (0, import_react16.useState)(null);
18236      const open = useStoreState(store, "open");
18237      const mounted = useStoreState(store, "mounted");
18238      const animated = useStoreState(store, "animated");
18239      const contentElement = useStoreState(store, "contentElement");
18240      const otherElement = useStoreState(store.disclosure, "contentElement");
18241      const hasClosedRef = (0, import_react16.useRef)(false);
18242      useSafeLayoutEffect(() => {
18243        if (!ref.current) return;
18244        store?.setContentElement(ref.current);
18245      }, [store]);
18246      useSafeLayoutEffect(() => {
18247        let previousAnimated;
18248        store?.setState("animated", (animated2) => {
18249          previousAnimated = animated2;
18250          return true;
18251        });
18252        return () => {
18253          if (previousAnimated === void 0) return;
18254          store?.setState("animated", previousAnimated);
18255        };
18256      }, [store]);
18257      useSafeLayoutEffect(() => {
18258        if (!animated) {
18259          if (!open) {
18260            hasClosedRef.current = true;
18261            setTransition(null);
18262          } else if (hasClosedRef.current) {
18263            hasClosedRef.current = false;
18264            setTransition("enter");
18265          }
18266          return;
18267        }
18268        if (!contentElement?.isConnected) {
18269          setTransition(null);
18270          return;
18271        }
18272        return afterPaint(() => {
18273          setTransition(open ? "enter" : mounted ? "leave" : null);
18274        });
18275      }, [
18276        animated,
18277        contentElement,
18278        open,
18279        mounted
18280      ]);
18281      useSafeLayoutEffect(() => {
18282        if (!store) return;
18283        if (!animated) return;
18284        if (!transition) return;
18285        if (!contentElement) return;
18286        const stopAnimation = () => store?.setState("animating", false);
18287        const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
18288        if (transition === "leave" && open) return;
18289        if (transition === "enter" && !open) return;
18290        if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
18291        const elements = [contentElement];
18292        if (otherElement) elements.push(otherElement);
18293        const relatedElement = otherElementRef?.current;
18294        if (relatedElement) elements.push(relatedElement);
18295        const timeout = Math.max(...elements.map(getElementEndTime));
18296        if (!timeout) {
18297          if (transition === "enter") store.setState("animated", false);
18298          stopAnimation();
18299          return;
18300        }
18301        return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
18302      }, [
18303        store,
18304        animated,
18305        contentElement,
18306        otherElement,
18307        otherElementRef,
18308        open,
18309        transition
18310      ]);
18311      props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DialogScopedContextProvider, {
18312        value: store,
18313        children: element
18314      }), [store]);
18315      const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18316      const styleProp = props.style;
18317      const style = (0, import_react16.useMemo)(() => {
18318        if (hidden) return {
18319          ...styleProp,
18320          display: "none"
18321        };
18322        return styleProp;
18323      }, [hidden, styleProp]);
18324      props = {
18325        "data-open": open || void 0,
18326        "data-enter": transition === "enter" || void 0,
18327        "data-leave": transition === "leave" || void 0,
18328        hidden,
18329        ...props,
18330        id,
18331        ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
18332        style
18333      };
18334      return removeUndefinedValues(props);
18335    });
18336    var DisclosureContentImpl = forwardRef21(function DisclosureContentImpl2(props) {
18337      return createElement3(TagName6, useDisclosureContent(props));
18338    });
18339    var DisclosureContent = forwardRef21(function DisclosureContent2({ unmountOnHide, ...props }) {
18340      const context = useDisclosureProviderContext();
18341      if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
18342      return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DisclosureContentImpl, { ...props });
18343    });
18344  
18345    // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
18346    function createDisclosureStore(props = {}) {
18347      const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"]));
18348      throwOnConflictingProps(props, store);
18349      const syncState = store?.getState();
18350      const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
18351      const animated = defaultValue(props.animated, syncState?.animated, false);
18352      const disclosure = createStore({
18353        open,
18354        animated,
18355        animating: !!animated && open,
18356        mounted: open,
18357        contentElement: defaultValue(syncState?.contentElement, null),
18358        disclosureElement: defaultValue(syncState?.disclosureElement, null)
18359      }, store);
18360      setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
18361        if (state.animated) return;
18362        disclosure.setState("animating", false);
18363      }));
18364      setup(disclosure, () => subscribe(disclosure, ["open"], () => {
18365        if (!disclosure.getState().animated) return;
18366        disclosure.setState("animating", true);
18367      }));
18368      setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
18369        disclosure.setState("mounted", state.open || state.animating);
18370      }));
18371      return {
18372        ...disclosure,
18373        disclosure: props.disclosure,
18374        setOpen: (value) => disclosure.setState("open", value),
18375        show: () => disclosure.setState("open", true),
18376        hide: () => disclosure.setState("open", false),
18377        toggle: () => disclosure.setState("open", (open2) => !open2),
18378        stopAnimation: () => disclosure.setState("animating", false),
18379        setContentElement: (value) => disclosure.setState("contentElement", value),
18380        setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
18381      };
18382    }
18383  
18384    // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
18385    function useDisclosureStoreProps(store, update2, props) {
18386      useUpdateEffect(update2, [props.store, props.disclosure]);
18387      useStoreProps(store, props, "open", "setOpen");
18388      useStoreProps(store, props, "mounted", "setMounted");
18389      useStoreProps(store, props, "animated");
18390      return Object.assign(store, { disclosure: props.disclosure });
18391    }
18392  
18393    // node_modules/@ariakit/react-components/dist/popover/popover-context.js
18394    var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
18395    var usePopoverContext = ctx5.useContext;
18396    var usePopoverScopedContext = ctx5.useScopedContext;
18397    var usePopoverProviderContext = ctx5.useProviderContext;
18398    var PopoverContextProvider = ctx5.ContextProvider;
18399    var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
18400  
18401    // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
18402    var import_react17 = __toESM(require_react(), 1);
18403    var ComboboxListRoleContext = (0, import_react17.createContext)(void 0);
18404    var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
18405    var useComboboxContext = ctx6.useContext;
18406    var useComboboxScopedContext = ctx6.useScopedContext;
18407    var useComboboxProviderContext = ctx6.useProviderContext;
18408    var ComboboxContextProvider = ctx6.ContextProvider;
18409    var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
18410    var ComboboxItemValueContext = (0, import_react17.createContext)(void 0);
18411    var ComboboxItemCheckedContext = (0, import_react17.createContext)(false);
18412  
18413    // node_modules/@ariakit/react-components/dist/collection/collection-store.js
18414    function useCollectionStoreProps(store, update2, props) {
18415      useUpdateEffect(update2, [props.store]);
18416      useStoreProps(store, props, "items", "setItems");
18417      return store;
18418    }
18419  
18420    // node_modules/@ariakit/react-components/dist/composite/composite-store.js
18421    function useCompositeStoreOptions(props) {
18422      return {
18423        id: useId4(props.id),
18424        ...props
18425      };
18426    }
18427    function useCompositeStoreProps(store, update2, props) {
18428      store = useCollectionStoreProps(store, update2, props);
18429      useStoreProps(store, props, "activeId", "setActiveId");
18430      useStoreProps(store, props, "includesBaseElement");
18431      useStoreProps(store, props, "virtualFocus");
18432      useStoreProps(store, props, "orientation");
18433      useStoreProps(store, props, "rtl");
18434      useStoreProps(store, props, "focusLoop");
18435      useStoreProps(store, props, "focusWrap");
18436      useStoreProps(store, props, "focusShift");
18437      return store;
18438    }
18439  
18440    // node_modules/@ariakit/components/dist/dialog/dialog-store.js
18441    function createDialogStore(props = {}) {
18442      return createDisclosureStore(props);
18443    }
18444  
18445    // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
18446    function useDialogStoreProps(store, update2, props) {
18447      return useDisclosureStoreProps(store, update2, props);
18448    }
18449  
18450    // node_modules/@ariakit/components/dist/popover/popover-store.js
18451    function createPopoverStore({ popover: otherPopover, ...props } = {}) {
18452      const store = mergeStore(props.store, omit2(otherPopover, [
18453        "arrowElement",
18454        "anchorElement",
18455        "contentElement",
18456        "popoverElement",
18457        "disclosureElement"
18458      ]));
18459      throwOnConflictingProps(props, store);
18460      const syncState = store?.getState();
18461      const dialog = createDialogStore({
18462        ...props,
18463        store
18464      });
18465      const placement = defaultValue(props.placement, syncState?.placement, "bottom");
18466      const popover = createStore({
18467        ...dialog.getState(),
18468        placement,
18469        currentPlacement: placement,
18470        anchorElement: defaultValue(syncState?.anchorElement, null),
18471        popoverElement: defaultValue(syncState?.popoverElement, null),
18472        arrowElement: defaultValue(syncState?.arrowElement, null),
18473        rendered: /* @__PURE__ */ Symbol("rendered")
18474      }, dialog, store);
18475      return {
18476        ...dialog,
18477        ...popover,
18478        setAnchorElement: (element) => popover.setState("anchorElement", element),
18479        setPopoverElement: (element) => popover.setState("popoverElement", element),
18480        setArrowElement: (element) => popover.setState("arrowElement", element),
18481        render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
18482      };
18483    }
18484  
18485    // node_modules/@ariakit/react-components/dist/popover/popover-store.js
18486    function usePopoverStoreProps(store, update2, props) {
18487      useUpdateEffect(update2, [props.popover]);
18488      useStoreProps(store, props, "placement");
18489      return useDialogStoreProps(store, update2, props);
18490    }
18491  
18492    // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
18493    var TagName7 = "div";
18494    var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
18495      const context = usePopoverProviderContext();
18496      store = store || context;
18497      props = {
18498        ...props,
18499        ref: useMergeRefs(store?.setAnchorElement, props.ref)
18500      };
18501      return props;
18502    });
18503    var PopoverAnchor = forwardRef21(function PopoverAnchor2(props) {
18504      return createElement3(TagName7, usePopoverAnchor(props));
18505    });
18506  
18507    // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
18508    var import_react18 = __toESM(require_react(), 1);
18509    var TagName8 = "div";
18510    function hoveringInside(event) {
18511      const nextElement = event.relatedTarget;
18512      if (!isElement2(nextElement)) return false;
18513      return contains2(event.currentTarget, nextElement);
18514    }
18515    var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
18516    function movingToAnotherItem(event) {
18517      const { relatedTarget } = event;
18518      if (!isElement2(relatedTarget)) return false;
18519      let dest = relatedTarget;
18520      do {
18521        if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
18522        dest = dest.parentElement;
18523      } while (dest);
18524      return false;
18525    }
18526    var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
18527      const context = useCompositeScopedContext();
18528      store = store || context;
18529      invariant(store, "CompositeHover must be wrapped in a Composite component.");
18530      const isMouseMoving = useIsMouseMoving();
18531      const onMouseMoveProp = props.onMouseMove;
18532      const focusOnHoverProp = useBooleanEvent(focusOnHover);
18533      const onMouseMove = useEvent((event) => {
18534        onMouseMoveProp?.(event);
18535        if (event.defaultPrevented) return;
18536        if (!isMouseMoving()) return;
18537        if (!focusOnHoverProp(event)) return;
18538        if (!hasFocusWithin(event.currentTarget)) {
18539          const baseElement = store?.getState().baseElement;
18540          if (baseElement && !hasFocus(baseElement)) baseElement.focus();
18541        }
18542        store?.setActiveId(event.currentTarget.id);
18543      });
18544      const onMouseLeaveProp = props.onMouseLeave;
18545      const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
18546      const onMouseLeave = useEvent((event) => {
18547        onMouseLeaveProp?.(event);
18548        if (event.defaultPrevented) return;
18549        if (!isMouseMoving()) return;
18550        if (hoveringInside(event)) return;
18551        if (movingToAnotherItem(event)) return;
18552        if (!focusOnHoverProp(event)) return;
18553        if (!blurOnHoverEndProp(event)) return;
18554        store?.setActiveId(null);
18555        store?.getState().baseElement?.focus();
18556      });
18557      const ref = (0, import_react18.useCallback)((element) => {
18558        if (!element) return;
18559        element[symbol2] = true;
18560      }, []);
18561      props = {
18562        ...props,
18563        ref: useMergeRefs(ref, props.ref),
18564        onMouseMove,
18565        onMouseLeave
18566      };
18567      return removeUndefinedValues(props);
18568    });
18569    var CompositeHover = memo3(forwardRef21(function CompositeHover2(props) {
18570      return createElement3(TagName8, useCompositeHover(props));
18571    }));
18572  
18573    // node_modules/@ariakit/react-components/dist/combobox/combobox.js
18574    var import_react19 = __toESM(require_react(), 1);
18575    var TagName9 = "input";
18576    function isFirstItemAutoSelected(items, activeValue, autoSelect) {
18577      if (!autoSelect) return false;
18578      return items.find((item) => !item.disabled && item.value)?.value === activeValue;
18579    }
18580    function hasCompletionString(value, activeValue) {
18581      if (!activeValue) return false;
18582      if (value == null) return false;
18583      const normalizedValue = normalizeString(value);
18584      const normalizedActiveValue = normalizeString(activeValue);
18585      if (normalizedValue.length !== value.length) return false;
18586      if (normalizedActiveValue.length !== activeValue.length) return false;
18587      return normalizedActiveValue.length > normalizedValue.length && normalizedActiveValue.toLowerCase().startsWith(normalizedValue.toLowerCase());
18588    }
18589    function isAriaAutoCompleteValue(value) {
18590      return value === "inline" || value === "list" || value === "both" || value === "none";
18591    }
18592    function getDefaultAutoSelectId(items) {
18593      return items.find((item) => {
18594        if (item.disabled) return false;
18595        return item.element?.getAttribute("role") !== "tab";
18596      })?.id;
18597    }
18598    var useCombobox = createHook(function useCombobox2({ store, focusable: focusable2 = true, autoSelect: autoSelectProp = false, getAutoSelectId, setValueOnChange, showMinLength = 0, showOnChange, showOnMouseDown, showOnClick = showOnMouseDown, showOnKeyDown, showOnKeyPress = showOnKeyDown, blurActiveItemOnClick, setValueOnClick = true, moveOnKeyPress = true, autoComplete = "list", ...props }) {
18599      const context = useComboboxProviderContext();
18600      store = store || context;
18601      invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18602      const ref = (0, import_react19.useRef)(null);
18603      const [valueUpdated, forceValueUpdate] = useForceUpdate();
18604      const canAutoSelectRef = (0, import_react19.useRef)(false);
18605      const composingRef = (0, import_react19.useRef)(false);
18606      const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
18607      const inline4 = autoComplete === "inline" || autoComplete === "both";
18608      const [canInline, setCanInline] = (0, import_react19.useState)(inline4);
18609      useUpdateLayoutEffect(() => {
18610        if (!inline4) return;
18611        setCanInline(true);
18612      }, [inline4]);
18613      const storeValue = useStoreState(store, "value");
18614      const prevSelectedValueRef = (0, import_react19.useRef)(void 0);
18615      (0, import_react19.useEffect)(() => {
18616        return sync(store, ["selectedValue", "activeId"], (_, prev) => {
18617          prevSelectedValueRef.current = prev.selectedValue;
18618        });
18619      }, [store]);
18620      const inlineActiveValue = useStoreState(store, (state) => {
18621        if (!inline4) return;
18622        if (!canInline) return;
18623        if (state.activeValue && Array.isArray(state.selectedValue)) {
18624          if (state.selectedValue.includes(state.activeValue)) return;
18625          if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
18626        }
18627        return state.activeValue;
18628      });
18629      const items = useStoreState(store, "renderedItems");
18630      const open = useStoreState(store, "open");
18631      const contentElement = useStoreState(store, "contentElement");
18632      const value = (0, import_react19.useMemo)(() => {
18633        if (!inline4) return storeValue;
18634        if (!canInline) return storeValue;
18635        if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
18636          if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
18637          return storeValue;
18638        }
18639        return inlineActiveValue || storeValue;
18640      }, [
18641        inline4,
18642        canInline,
18643        items,
18644        inlineActiveValue,
18645        autoSelect,
18646        storeValue
18647      ]);
18648      (0, import_react19.useEffect)(() => {
18649        const element = ref.current;
18650        if (!element) return;
18651        const onCompositeItemMove = () => setCanInline(true);
18652        element.addEventListener("combobox-item-move", onCompositeItemMove);
18653        return () => {
18654          element.removeEventListener("combobox-item-move", onCompositeItemMove);
18655        };
18656      }, []);
18657      (0, import_react19.useEffect)(() => {
18658        if (!inline4) return;
18659        if (!canInline) return;
18660        if (!inlineActiveValue) return;
18661        if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
18662        if (!hasCompletionString(storeValue, inlineActiveValue)) return;
18663        let cleanup = noop5;
18664        queueMicrotask(() => {
18665          const element = ref.current;
18666          if (!element) return;
18667          const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18668          const nextStart = storeValue.length;
18669          const nextEnd = inlineActiveValue.length;
18670          setSelectionRange(element, nextStart, nextEnd);
18671          cleanup = () => {
18672            if (!hasFocus(element)) return;
18673            const { start, end } = getTextboxSelection(element);
18674            if (start !== nextStart) return;
18675            if (end !== nextEnd) return;
18676            setSelectionRange(element, prevStart, prevEnd);
18677          };
18678        });
18679        return () => cleanup();
18680      }, [
18681        valueUpdated,
18682        inline4,
18683        canInline,
18684        inlineActiveValue,
18685        items,
18686        autoSelect,
18687        storeValue
18688      ]);
18689      const getAutoSelectIdProp = useEvent(getAutoSelectId);
18690      const autoSelectIdRef = (0, import_react19.useRef)(null);
18691      const autoSelectMovedRef = (0, import_react19.useRef)(void 0);
18692      const userScrolledRef = (0, import_react19.useRef)(false);
18693      const isAutoScrollingRef = (0, import_react19.useRef)(false);
18694      (0, import_react19.useEffect)(() => {
18695        if (!open) return;
18696        if (!contentElement) return;
18697        const scrollingElement = getScrollingElement(contentElement);
18698        if (!scrollingElement) return;
18699        const onUserScroll = () => {
18700          canAutoSelectRef.current = false;
18701          userScrolledRef.current = true;
18702        };
18703        const onScroll = () => {
18704          if (!isAutoScrollingRef.current) userScrolledRef.current = true;
18705          if (!store) return;
18706          if (!canAutoSelectRef.current) return;
18707          const { activeId } = store.getState();
18708          if (activeId === null) return;
18709          if (activeId === autoSelectIdRef.current) return;
18710          canAutoSelectRef.current = false;
18711        };
18712        const options = {
18713          passive: true,
18714          capture: true
18715        };
18716        scrollingElement.addEventListener("wheel", onUserScroll, options);
18717        scrollingElement.addEventListener("touchmove", onUserScroll, options);
18718        scrollingElement.addEventListener("scroll", onScroll, options);
18719        return () => {
18720          scrollingElement.removeEventListener("wheel", onUserScroll, true);
18721          scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18722          scrollingElement.removeEventListener("scroll", onScroll, true);
18723        };
18724      }, [
18725        open,
18726        contentElement,
18727        store
18728      ]);
18729      useSafeLayoutEffect(() => {
18730        userScrolledRef.current = false;
18731        if (!storeValue) return;
18732        if (composingRef.current) return;
18733        canAutoSelectRef.current = true;
18734      }, [storeValue]);
18735      useSafeLayoutEffect(() => {
18736        if (autoSelect !== "always" && open) return;
18737        canAutoSelectRef.current = open;
18738      }, [autoSelect, open]);
18739      useSafeLayoutEffect(() => {
18740        if (open) return;
18741        autoSelectMovedRef.current = void 0;
18742      }, [open]);
18743      const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
18744      useUpdateEffect(() => {
18745        const canAutoSelect = canAutoSelectRef.current;
18746        if (!store) return;
18747        if (!open) return;
18748        if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
18749        const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18750        if (baseElement && !hasFocus(baseElement)) return;
18751        if (contentElement2?.hasAttribute("data-placing")) {
18752          const observer = new MutationObserver(forceValueUpdate);
18753          observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18754          return () => observer.disconnect();
18755        }
18756        if (autoSelect && canAutoSelect) {
18757          const userAutoSelectId = getAutoSelectIdProp(items);
18758          const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
18759          autoSelectIdRef.current = autoSelectId;
18760          const nextActiveId = autoSelectId ?? null;
18761          const nextActiveValue = store.item(nextActiveId)?.value;
18762          const moved = autoSelectMovedRef.current;
18763          if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
18764            autoSelectMovedRef.current = {
18765              id: nextActiveId,
18766              value: nextActiveValue
18767            };
18768            store.move(nextActiveId);
18769          } else store.setState("activeValue", nextActiveValue);
18770        } else {
18771          const element = store.item(activeId || store.first())?.element;
18772          if (element && "scrollIntoView" in element) {
18773            isAutoScrollingRef.current = true;
18774            element.scrollIntoView({
18775              block: "nearest",
18776              inline: "nearest"
18777            });
18778            requestAnimationFrame(() => {
18779              isAutoScrollingRef.current = false;
18780            });
18781          }
18782        }
18783      }, [
18784        store,
18785        open,
18786        valueUpdated,
18787        storeValue,
18788        autoSelect,
18789        resetValueOnSelect,
18790        getAutoSelectIdProp,
18791        items
18792      ]);
18793      (0, import_react19.useEffect)(() => {
18794        if (!inline4) return;
18795        const combobox = ref.current;
18796        if (!combobox) return;
18797        const elements = [combobox, contentElement].filter((value2) => !!value2);
18798        const onBlur2 = (event) => {
18799          if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
18800        };
18801        for (const element of elements) element.addEventListener("focusout", onBlur2);
18802        return () => {
18803          for (const element of elements) element.removeEventListener("focusout", onBlur2);
18804        };
18805      }, [
18806        inline4,
18807        contentElement,
18808        store,
18809        value
18810      ]);
18811      const canShow = (event) => {
18812        return event.currentTarget.value.length >= showMinLength;
18813      };
18814      const onChangeProp = props.onChange;
18815      const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
18816      const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
18817      const onChange = useEvent((event) => {
18818        onChangeProp?.(event);
18819        if (event.defaultPrevented) return;
18820        if (!store) return;
18821        const currentTarget = event.currentTarget;
18822        const { value: value2, selectionStart, selectionEnd } = currentTarget;
18823        const nativeEvent = event.nativeEvent;
18824        canAutoSelectRef.current = true;
18825        if (isInputEvent(nativeEvent)) {
18826          if (nativeEvent.isComposing) {
18827            canAutoSelectRef.current = false;
18828            composingRef.current = true;
18829          }
18830          if (inline4) {
18831            const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18832            const caretAtEnd = selectionStart === value2.length;
18833            setCanInline(textInserted && caretAtEnd);
18834          }
18835        }
18836        if (setValueOnChangeProp(event)) {
18837          const isSameValue2 = value2 === store.getState().value;
18838          store.setValue(value2);
18839          queueMicrotask(() => {
18840            setSelectionRange(currentTarget, selectionStart, selectionEnd);
18841          });
18842          if (inline4 && autoSelect && isSameValue2) forceValueUpdate();
18843        }
18844        if (showOnChangeProp(event)) store.show();
18845        if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
18846      });
18847      const onCompositionEndProp = props.onCompositionEnd;
18848      const onCompositionEnd = useEvent((event) => {
18849        canAutoSelectRef.current = true;
18850        composingRef.current = false;
18851        onCompositionEndProp?.(event);
18852        if (event.defaultPrevented) return;
18853        if (!autoSelect) return;
18854        forceValueUpdate();
18855      });
18856      const onMouseDownProp = props.onMouseDown;
18857      const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
18858      const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18859      const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
18860      const onMouseDown = useEvent((event) => {
18861        onMouseDownProp?.(event);
18862        if (event.defaultPrevented) return;
18863        if (event.button) return;
18864        if (event.ctrlKey) return;
18865        if (!store) return;
18866        if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
18867        if (setValueOnClickProp(event)) store.setValue(value);
18868        if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18869      });
18870      const onKeyDownProp = props.onKeyDown;
18871      const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
18872      const onKeyDown = useEvent((event) => {
18873        onKeyDownProp?.(event);
18874        if (!event.repeat) canAutoSelectRef.current = false;
18875        if (event.defaultPrevented) return;
18876        if (!store) return;
18877        const { open: open2 } = store.getState();
18878        if (open2 && event.key === "Enter") {
18879          event.preventDefault();
18880          return;
18881        }
18882        if (event.ctrlKey) return;
18883        if (event.altKey) return;
18884        if (event.shiftKey) return;
18885        if (event.metaKey) return;
18886        if (open2) return;
18887        if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18888          if (showOnKeyPressProp(event)) {
18889            event.preventDefault();
18890            store.show();
18891          }
18892        }
18893      });
18894      const onBlurProp = props.onBlur;
18895      const onBlur = useEvent((event) => {
18896        canAutoSelectRef.current = false;
18897        onBlurProp?.(event);
18898      });
18899      const id = useId4(props.id);
18900      const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18901      const isActiveItem = useStoreState(store, (state) => state.activeId === null);
18902      props = {
18903        role: "combobox",
18904        "aria-autocomplete": ariaAutoComplete,
18905        "aria-haspopup": getPopupRole(contentElement, "listbox"),
18906        "aria-expanded": open,
18907        "aria-controls": contentElement?.id,
18908        "data-active-item": isActiveItem || void 0,
18909        value,
18910        ...props,
18911        id,
18912        ref: useMergeRefs(ref, props.ref),
18913        onChange,
18914        onCompositionEnd,
18915        onMouseDown,
18916        onKeyDown,
18917        onBlur
18918      };
18919      props = useComposite({
18920        store,
18921        focusable: focusable2,
18922        ...props,
18923        moveOnKeyPress: (event) => {
18924          if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18925          if (inline4) setCanInline(true);
18926          return true;
18927        }
18928      });
18929      props = usePopoverAnchor({
18930        store,
18931        ...props
18932      });
18933      return {
18934        autoComplete: "off",
18935        ...props
18936      };
18937    });
18938    var Combobox = forwardRef21(function Combobox2(props) {
18939      return createElement3(TagName9, useCombobox(props));
18940    });
18941  
18942    // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
18943    var import_react20 = __toESM(require_react(), 1);
18944    var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18945    var TagName10 = "div";
18946    function isSelected(storeValue, itemValue) {
18947      if (itemValue == null) return;
18948      if (storeValue == null) return false;
18949      if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
18950      return storeValue === itemValue;
18951    }
18952    function getItemRole(popupRole) {
18953      return getItemRoleByPopupRole(popupRole) ?? "option";
18954    }
18955    var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
18956      const context = useComboboxScopedContext();
18957      store = store || context;
18958      invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
18959      const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18960        resetValueOnSelectState: "resetValueOnSelect",
18961        multiSelectable(state) {
18962          return Array.isArray(state.selectedValue);
18963        },
18964        selected(state) {
18965          return isSelected(state.selectedValue, value);
18966        }
18967      });
18968      const getItem = (0, import_react20.useCallback)((item) => {
18969        const nextItem = {
18970          ...item,
18971          value
18972        };
18973        if (getItemProp) return getItemProp(nextItem);
18974        return nextItem;
18975      }, [value, getItemProp]);
18976      setValueOnClick = setValueOnClick ?? !multiSelectable;
18977      hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
18978      const onClickProp = props.onClick;
18979      const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18980      const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18981      const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
18982      const hideOnClickProp = useBooleanEvent(hideOnClick);
18983      const onClick = useEvent((event) => {
18984        onClickProp?.(event);
18985        if (event.defaultPrevented) return;
18986        if (isDownloading(event)) return;
18987        if (isOpeningInNewTab(event)) return;
18988        if (value != null) {
18989          if (selectValueOnClickProp(event)) {
18990            if (resetValueOnSelectProp(event)) store?.resetValue();
18991            store?.setSelectedValue((prevValue) => {
18992              if (!Array.isArray(prevValue)) return value;
18993              if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
18994              return [...prevValue, value];
18995            });
18996          }
18997          if (setValueOnClickProp(event)) store?.setValue(value);
18998        }
18999        if (hideOnClickProp(event)) store?.hide();
19000      });
19001      const onKeyDownProp = props.onKeyDown;
19002      const onKeyDown = useEvent((event) => {
19003        onKeyDownProp?.(event);
19004        if (event.defaultPrevented) return;
19005        const baseElement = store?.getState().baseElement;
19006        if (!baseElement) return;
19007        if (hasFocus(baseElement)) return;
19008        const printable = event.key.length === 1 && !event.ctrlKey && !event.metaKey;
19009        const paste = (!isApple() ? event.ctrlKey : event.metaKey) && event.key.toLowerCase() === "v";
19010        const deleteKey = event.key === "Backspace" || event.key === "Delete";
19011        if (printable || paste || deleteKey) {
19012          queueMicrotask(() => baseElement.focus());
19013          if (isTextField(baseElement)) store?.setValue(baseElement.value);
19014        }
19015      });
19016      if (multiSelectable && selected != null) props = {
19017        "aria-selected": selected,
19018        ...props
19019      };
19020      props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemValueContext.Provider, {
19021        value,
19022        children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemCheckedContext.Provider, {
19023          value: selected ?? false,
19024          children: element
19025        })
19026      }), [value, selected]);
19027      props = {
19028        role: getItemRole((0, import_react20.useContext)(ComboboxListRoleContext)),
19029        children: value,
19030        ...props,
19031        onClick,
19032        onKeyDown
19033      };
19034      const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
19035      props = useCompositeItem({
19036        store,
19037        ...props,
19038        getItem,
19039        moveOnKeyPress: (event) => {
19040          if (!moveOnKeyPressProp(event)) return false;
19041          const moveEvent = new Event("combobox-item-move");
19042          store?.getState().baseElement?.dispatchEvent(moveEvent);
19043          return true;
19044        }
19045      });
19046      props = useCompositeHover({
19047        store,
19048        focusOnHover,
19049        ...props
19050      });
19051      return props;
19052    });
19053    var ComboboxItem = memo3(forwardRef21(function ComboboxItem2(props) {
19054      return createElement3(TagName10, useComboboxItem(props));
19055    }));
19056  
19057    // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
19058    var import_react21 = __toESM(require_react(), 1);
19059    var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
19060    var TagName11 = "span";
19061    function normalizeValue(value) {
19062      return normalizeString(value).toLowerCase();
19063    }
19064    function getOffsets(string, values) {
19065      const offsets = [];
19066      for (const value of values) {
19067        if (!value) continue;
19068        let pos = 0;
19069        const length = value.length;
19070        let index2 = string.indexOf(value, pos);
19071        while (index2 !== -1) {
19072          offsets.push([index2, length]);
19073          pos = index2 + 1;
19074          index2 = string.indexOf(value, pos);
19075        }
19076      }
19077      return offsets;
19078    }
19079    function mergeOverlappingOffsets(offsets) {
19080      offsets.sort(([a2], [b2]) => a2 - b2);
19081      const merged = [];
19082      for (const [offset4, length] of offsets) {
19083        const last = merged[merged.length - 1];
19084        if (last && offset4 < last[0] + last[1]) last[1] = Math.max(last[1], offset4 + length - last[0]);
19085        else merged.push([offset4, length]);
19086      }
19087      return merged;
19088    }
19089    function getNormalizedIndexes(itemValue) {
19090      const starts = [];
19091      const ends = [];
19092      let index2 = 0;
19093      for (const char of itemValue) {
19094        const normalizedLength = normalizeValue(char).length;
19095        for (let i2 = 0; i2 < normalizedLength; i2 += 1) {
19096          starts.push(i2 === 0 ? index2 : -1);
19097          ends.push(index2);
19098        }
19099        index2 += char.length;
19100      }
19101      starts.push(itemValue.length);
19102      ends.push(itemValue.length);
19103      let nextBoundary = itemValue.length;
19104      for (let i2 = starts.length - 1; i2 >= 0; i2 -= 1) {
19105        const start = starts[i2];
19106        if (start == null) continue;
19107        if (start === -1) starts[i2] = nextBoundary;
19108        else nextBoundary = start;
19109      }
19110      return {
19111        starts,
19112        ends
19113      };
19114    }
19115    function toOriginalOffsets(itemValue, normalizedOffsets) {
19116      if (!normalizedOffsets.length) return normalizedOffsets;
19117      const { starts, ends } = getNormalizedIndexes(itemValue);
19118      const offsets = [];
19119      for (const [normalizedOffset, normalizedLength] of normalizedOffsets) {
19120        const start = starts[normalizedOffset];
19121        const end = ends[normalizedOffset + normalizedLength];
19122        if (start == null || end == null) continue;
19123        if (end <= start) continue;
19124        offsets.push([start, end - start]);
19125      }
19126      return offsets;
19127    }
19128    function splitValue(itemValue, userValue) {
19129      if (!itemValue) return itemValue;
19130      if (!userValue) return itemValue;
19131      const userValues = toArray(userValue).map(normalizeValue);
19132      const parts = [];
19133      const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", {
19134        "data-autocomplete-value": autocomplete ? "" : void 0,
19135        "data-user-value": autocomplete ? void 0 : "",
19136        children: value
19137      }, parts.length);
19138      const offsets = toOriginalOffsets(itemValue, mergeOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
19139      const firstEntry = offsets[0];
19140      if (!firstEntry) {
19141        parts.push(span(itemValue, true));
19142        return parts;
19143      }
19144      const [firstOffset] = firstEntry;
19145      [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
19146        const value = itemValue.slice(offset4, offset4 + length);
19147        const nextOffset = offsets[i2 + 1]?.[0];
19148        return [value, itemValue.slice(offset4 + length, nextOffset)];
19149      })].forEach((value, i2) => {
19150        if (!value) return;
19151        parts.push(span(value, i2 % 2 === 0));
19152      });
19153      return parts;
19154    }
19155    var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
19156      const context = useComboboxScopedContext();
19157      store = store || context;
19158      const itemContext = (0, import_react21.useContext)(ComboboxItemValueContext);
19159      const itemValue = value ?? itemContext;
19160      const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
19161      props = {
19162        children: (0, import_react21.useMemo)(() => {
19163          if (!itemValue) return;
19164          if (!inputValue) return itemValue;
19165          return splitValue(itemValue, inputValue);
19166        }, [itemValue, inputValue]),
19167        ...props
19168      };
19169      return removeUndefinedValues(props);
19170    });
19171    var ComboboxItemValue = forwardRef21(function ComboboxItemValue2(props) {
19172      return createElement3(TagName11, useComboboxItemValue(props));
19173    });
19174  
19175    // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
19176    var TagName12 = "label";
19177    var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
19178      const context = useComboboxProviderContext();
19179      store = store || context;
19180      invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
19181      props = {
19182        htmlFor: useStoreState(store, (state) => state.baseElement?.id),
19183        ...props
19184      };
19185      return removeUndefinedValues(props);
19186    });
19187    var ComboboxLabel = memo3(forwardRef21(function ComboboxLabel2(props) {
19188      return createElement3(TagName12, useComboboxLabel(props));
19189    }));
19190  
19191    // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
19192    var import_react22 = __toESM(require_react(), 1);
19193    var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
19194    var TagName13 = "div";
19195    var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
19196      const scopedContext = useComboboxScopedContext(true);
19197      const context = useComboboxContext();
19198      store = store || context;
19199      const scopedContextSameStore = !!store && store === scopedContext;
19200      invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
19201      const ref = (0, import_react22.useRef)(null);
19202      const id = useId4(props.id);
19203      const mounted = useStoreState(store, "mounted");
19204      const hidden = isHidden(mounted, props.hidden, alwaysVisible);
19205      const style = hidden ? {
19206        ...props.style,
19207        display: "none"
19208      } : props.style;
19209      const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
19210      const role = useAttribute(ref, "role", props.role);
19211      const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
19212      const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false);
19213      const contentElement = useStoreState(store, "contentElement");
19214      useSafeLayoutEffect(() => {
19215        if (!mounted) return;
19216        const element = ref.current;
19217        if (!element) return;
19218        if (contentElement !== element) return;
19219        const callback = () => {
19220          setHasListboxInside(!!element.querySelector("[role='listbox']"));
19221        };
19222        const observer = new MutationObserver(callback);
19223        observer.observe(element, {
19224          subtree: true,
19225          childList: true,
19226          attributeFilter: ["role"]
19227        });
19228        callback();
19229        return () => observer.disconnect();
19230      }, [mounted, contentElement]);
19231      if (!hasListboxInside) props = {
19232        role: "listbox",
19233        "aria-multiselectable": ariaMultiSelectable,
19234        ...props
19235      };
19236      props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxScopedContextProvider, {
19237        value: store,
19238        children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxListRoleContext.Provider, {
19239          value: role,
19240          children: element
19241        })
19242      }), [store, role]);
19243      const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
19244      props = {
19245        hidden,
19246        ...props,
19247        id,
19248        ref: useMergeRefs(setContentElement, ref, props.ref),
19249        style
19250      };
19251      return removeUndefinedValues(props);
19252    });
19253    var ComboboxList = forwardRef21(function ComboboxList2(props) {
19254      return createElement3(TagName13, useComboboxList(props));
19255    });
19256  
19257    // node_modules/@ariakit/react-components/dist/tag/tag-context.js
19258    var import_react23 = __toESM(require_react(), 1);
19259    var TagValueContext = (0, import_react23.createContext)(null);
19260    var TagRemoveIdContext = (0, import_react23.createContext)(null);
19261    var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
19262    var useTagContext = ctx7.useContext;
19263    var useTagScopedContext = ctx7.useScopedContext;
19264    var useTagProviderContext = ctx7.useProviderContext;
19265    var TagContextProvider = ctx7.ContextProvider;
19266    var TagScopedContextProvider = ctx7.ScopedContextProvider;
19267  
19268    // node_modules/@ariakit/components/dist/combobox/combobox-store.js
19269    var isTouchSafari = isSafari() && isTouchDevice();
19270    function createComboboxStore({ tag, ...props } = {}) {
19271      const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
19272      throwOnConflictingProps(props, store);
19273      const tagState = tag?.getState();
19274      const syncState = store?.getState();
19275      const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
19276      const composite = createCompositeStore({
19277        ...props,
19278        activeId,
19279        includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
19280        orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
19281        focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
19282        focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
19283        virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
19284      });
19285      const popover = createPopoverStore({
19286        ...props,
19287        placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
19288      });
19289      const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
19290      const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
19291      const multiSelectable = Array.isArray(selectedValue);
19292      const initialState = {
19293        ...composite.getState(),
19294        ...popover.getState(),
19295        value,
19296        selectedValue,
19297        resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
19298        resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
19299        activeValue: syncState?.activeValue
19300      };
19301      const combobox = createStore(initialState, composite, popover, store);
19302      if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
19303        combobox.setState("virtualFocus", false);
19304      }));
19305      setup(combobox, () => {
19306        if (!tag) return;
19307        return chain(sync(combobox, ["selectedValue"], (state) => {
19308          if (!Array.isArray(state.selectedValue)) return;
19309          tag.setValues(state.selectedValue);
19310        }), sync(tag, ["values"], (state) => {
19311          combobox.setState("selectedValue", state.values);
19312        }));
19313      });
19314      setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
19315        if (!state.resetValueOnHide) return;
19316        if (state.mounted) return;
19317        combobox.setState("value", value);
19318      }));
19319      setup(combobox, () => sync(combobox, ["open"], (state) => {
19320        if (state.open) return;
19321        combobox.setState("activeId", activeId);
19322        combobox.setState("moves", 0);
19323      }));
19324      setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
19325        if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
19326      }));
19327      setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
19328        if (state.moves === prev.moves) return;
19329        const { activeId: activeId2 } = combobox.getState();
19330        const activeItem = composite.item(activeId2);
19331        combobox.setState("activeValue", activeItem?.value);
19332      }));
19333      return {
19334        ...popover,
19335        ...composite,
19336        ...combobox,
19337        tag,
19338        setValue: (value2) => combobox.setState("value", value2),
19339        resetValue: () => combobox.setState("value", initialState.value),
19340        setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
19341      };
19342    }
19343  
19344    // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
19345    function useComboboxStoreOptions(props) {
19346      const tag = useTagContext();
19347      props = {
19348        ...props,
19349        tag: props.tag !== void 0 ? props.tag : tag
19350      };
19351      return useCompositeStoreOptions(props);
19352    }
19353    function useComboboxStoreProps(store, update2, props) {
19354      useUpdateEffect(update2, [props.tag]);
19355      useStoreProps(store, props, "value", "setValue");
19356      useStoreProps(store, props, "selectedValue", "setSelectedValue");
19357      useStoreProps(store, props, "resetValueOnHide");
19358      useStoreProps(store, props, "resetValueOnSelect");
19359      return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
19360    }
19361    function useComboboxStore(props = {}) {
19362      props = useComboboxStoreOptions(props);
19363      const [store, update2] = useStore2(createComboboxStore, props);
19364      return useComboboxStoreProps(store, update2, props);
19365    }
19366  
19367    // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
19368    var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
19369    function ComboboxProvider(props = {}) {
19370      return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxContextProvider, {
19371        value: useComboboxStore(props),
19372        children: props.children
19373      });
19374    }
19375  
19376    // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19377    var import_remove_accents = __toESM(require_remove_accents(), 1);
19378    var import_compose8 = __toESM(require_compose(), 1);
19379    var import_i18n30 = __toESM(require_i18n(), 1);
19380    var import_element44 = __toESM(require_element(), 1);
19381    var import_components19 = __toESM(require_components(), 1);
19382  
19383    // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
19384    var EMPTY_ARRAY3 = [];
19385    var getCurrentValue = (filterDefinition, currentFilter) => {
19386      if (filterDefinition.singleSelection) {
19387        return currentFilter?.value;
19388      }
19389      if (Array.isArray(currentFilter?.value)) {
19390        return currentFilter.value;
19391      }
19392      if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
19393        return [currentFilter.value];
19394      }
19395      return EMPTY_ARRAY3;
19396    };
19397  
19398    // packages/dataviews/build-module/hooks/use-elements.mjs
19399    var import_element43 = __toESM(require_element(), 1);
19400    var EMPTY_ARRAY4 = [];
19401    function useElements({
19402      elements,
19403      getElements
19404    }) {
19405      const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
19406      const [records, setRecords] = (0, import_element43.useState)(staticElements);
19407      const [isLoading, setIsLoading] = (0, import_element43.useState)(false);
19408      (0, import_element43.useEffect)(() => {
19409        if (!getElements) {
19410          setRecords(staticElements);
19411          return;
19412        }
19413        let cancelled = false;
19414        setIsLoading(true);
19415        getElements().then((fetchedElements) => {
19416          if (!cancelled) {
19417            const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
19418            setRecords(dynamicElements);
19419          }
19420        }).catch(() => {
19421          if (!cancelled) {
19422            setRecords(staticElements);
19423          }
19424        }).finally(() => {
19425          if (!cancelled) {
19426            setIsLoading(false);
19427          }
19428        });
19429        return () => {
19430          cancelled = true;
19431        };
19432      }, [getElements, staticElements]);
19433      return {
19434        elements: records,
19435        isLoading
19436      };
19437    }
19438  
19439    // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19440    var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
19441    function normalizeSearchInput(input = "") {
19442      return (0, import_remove_accents.default)(input.trim().toLowerCase());
19443    }
19444    var getNewValue = (filterDefinition, currentFilter, value) => {
19445      if (filterDefinition.singleSelection) {
19446        return value;
19447      }
19448      if (Array.isArray(currentFilter?.value)) {
19449        return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
19450      }
19451      return [value];
19452    };
19453    function generateFilterElementCompositeItemId(prefix, filterElementValue) {
19454      return `$prefix}-$filterElementValue}`;
19455    }
19456    var MultiSelectionOption = ({ selected }) => {
19457      return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19458        "span",
19459        {
19460          className: clsx_default(
19461            "dataviews-filters__search-widget-listitem-multi-selection",
19462            { "is-selected": selected }
19463          ),
19464          children: selected && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: check_default })
19465        }
19466      );
19467    };
19468    var SingleSelectionOption = ({ selected }) => {
19469      return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19470        "span",
19471        {
19472          className: clsx_default(
19473            "dataviews-filters__search-widget-listitem-single-selection",
19474            { "is-selected": selected }
19475          )
19476        }
19477      );
19478    };
19479    function ListBox({ view, filter, onChangeView }) {
19480      const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
19481      const [activeCompositeId, setActiveCompositeId] = (0, import_element44.useState)(
19482        // When there are one or less operators, the first item is set as active
19483        // (by setting the initial `activeId` to `undefined`).
19484        // With 2 or more operators, the focus is moved on the operators control
19485        // (by setting the initial `activeId` to `null`), meaning that there won't
19486        // be an active item initially. Focus is then managed via the
19487        // `onFocusVisible` callback.
19488        filter.operators?.length === 1 ? void 0 : null
19489      );
19490      const currentFilter = view.filters?.find(
19491        (f2) => f2.field === filter.field
19492      );
19493      const currentValue = getCurrentValue(filter, currentFilter);
19494      return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19495        import_components19.Composite,
19496        {
19497          virtualFocus: true,
19498          focusLoop: true,
19499          activeId: activeCompositeId,
19500          setActiveId: setActiveCompositeId,
19501          role: "listbox",
19502          className: "dataviews-filters__search-widget-listbox",
19503          "aria-label": (0, import_i18n30.sprintf)(
19504            /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
19505            (0, import_i18n30.__)("List of: %1$s"),
19506            filter.name
19507          ),
19508          onFocusVisible: () => {
19509            if (!activeCompositeId && filter.elements.length) {
19510              setActiveCompositeId(
19511                generateFilterElementCompositeItemId(
19512                  baseId,
19513                  filter.elements[0].value
19514                )
19515              );
19516            }
19517          },
19518          render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Composite.Typeahead, {}),
19519          children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19520            import_components19.Composite.Hover,
19521            {
19522              render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19523                import_components19.Composite.Item,
19524                {
19525                  id: generateFilterElementCompositeItemId(
19526                    baseId,
19527                    element.value
19528                  ),
19529                  render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19530                    "div",
19531                    {
19532                      "aria-label": element.label,
19533                      role: "option",
19534                      className: "dataviews-filters__search-widget-listitem"
19535                    }
19536                  ),
19537                  onClick: () => {
19538                    const newFilters = currentFilter ? [
19539                      ...(view.filters ?? []).map(
19540                        (_filter) => {
19541                          if (_filter.field === filter.field) {
19542                            return {
19543                              ..._filter,
19544                              operator: currentFilter.operator || filter.operators[0],
19545                              value: getNewValue(
19546                                filter,
19547                                currentFilter,
19548                                element.value
19549                              )
19550                            };
19551                          }
19552                          return _filter;
19553                        }
19554                      )
19555                    ] : [
19556                      ...view.filters ?? [],
19557                      {
19558                        field: filter.field,
19559                        operator: filter.operators[0],
19560                        value: getNewValue(
19561                          filter,
19562                          currentFilter,
19563                          element.value
19564                        )
19565                      }
19566                    ];
19567                    onChangeView({
19568                      ...view,
19569                      page: 1,
19570                      filters: newFilters
19571                    });
19572                  }
19573                }
19574              ),
19575              children: [
19576                filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19577                  SingleSelectionOption,
19578                  {
19579                    selected: currentValue === element.value
19580                  }
19581                ),
19582                !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19583                  MultiSelectionOption,
19584                  {
19585                    selected: currentValue.includes(element.value)
19586                  }
19587                ),
19588                /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19589                  "span",
19590                  {
19591                    className: "dataviews-filters__search-widget-listitem-value",
19592                    title: element.label,
19593                    children: element.label
19594                  }
19595                )
19596              ]
19597            },
19598            element.value
19599          ))
19600        }
19601      );
19602    }
19603    function ComboboxList22({ view, filter, onChangeView }) {
19604      const [searchValue, setSearchValue] = (0, import_element44.useState)("");
19605      const deferredSearchValue = (0, import_element44.useDeferredValue)(searchValue);
19606      const currentFilter = view.filters?.find(
19607        (_filter) => _filter.field === filter.field
19608      );
19609      const currentValue = getCurrentValue(filter, currentFilter);
19610      const matches = (0, import_element44.useMemo)(() => {
19611        const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19612        return filter.elements.filter(
19613          (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19614        );
19615      }, [filter.elements, deferredSearchValue]);
19616      return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19617        ComboboxProvider,
19618        {
19619          selectedValue: currentValue,
19620          setSelectedValue: (value) => {
19621            const newFilters = currentFilter ? [
19622              ...(view.filters ?? []).map((_filter) => {
19623                if (_filter.field === filter.field) {
19624                  return {
19625                    ..._filter,
19626                    operator: currentFilter.operator || filter.operators[0],
19627                    value
19628                  };
19629                }
19630                return _filter;
19631              })
19632            ] : [
19633              ...view.filters ?? [],
19634              {
19635                field: filter.field,
19636                operator: filter.operators[0],
19637                value
19638              }
19639            ];
19640            onChangeView({
19641              ...view,
19642              page: 1,
19643              filters: newFilters
19644            });
19645          },
19646          setValue: setSearchValue,
19647          children: [
19648            /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19649              /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ComboboxLabel, {}), children: (0, import_i18n30.__)("Search items") }),
19650              /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19651                Combobox,
19652                {
19653                  autoSelect: "always",
19654                  placeholder: (0, import_i18n30.__)("Search"),
19655                  className: "dataviews-filters__search-widget-filter-combobox__input"
19656                }
19657              ),
19658              /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: search_default }) })
19659            ] }),
19660            /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19661              ComboboxList,
19662              {
19663                className: "dataviews-filters__search-widget-filter-combobox-list",
19664                alwaysVisible: true,
19665                children: [
19666                  matches.map((element) => {
19667                    return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19668                      ComboboxItem,
19669                      {
19670                        resetValueOnSelect: false,
19671                        value: element.value,
19672                        className: "dataviews-filters__search-widget-listitem",
19673                        hideOnClick: false,
19674                        setValueOnClick: false,
19675                        focusOnHover: true,
19676                        children: [
19677                          filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19678                            SingleSelectionOption,
19679                            {
19680                              selected: currentValue === element.value
19681                            }
19682                          ),
19683                          !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19684                            MultiSelectionOption,
19685                            {
19686                              selected: currentValue.includes(
19687                                element.value
19688                              )
19689                            }
19690                          ),
19691                          /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19692                            "span",
19693                            {
19694                              className: "dataviews-filters__search-widget-listitem-value",
19695                              title: element.label,
19696                              children: [
19697                                /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19698                                  ComboboxItemValue,
19699                                  {
19700                                    className: "dataviews-filters__search-widget-filter-combobox-item-value",
19701                                    value: element.label
19702                                  }
19703                                ),
19704                                !!element.description && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19705                              ]
19706                            }
19707                          )
19708                        ]
19709                      },
19710                      element.value
19711                    );
19712                  }),
19713                  !matches.length && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { children: (0, import_i18n30.__)("No results found") })
19714                ]
19715              }
19716            )
19717          ]
19718        }
19719      );
19720    }
19721    function SearchWidget(props) {
19722      const { elements, isLoading } = useElements({
19723        elements: props.filter.elements,
19724        getElements: props.filter.getElements
19725      });
19726      if (isLoading) {
19727        return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Spinner, {}) });
19728      }
19729      if (elements.length === 0) {
19730        return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n30.__)("No elements found") });
19731      }
19732      const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19733      return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19734    }
19735  
19736    // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19737    var import_es6 = __toESM(require_es6(), 1);
19738    var import_compose9 = __toESM(require_compose(), 1);
19739    var import_element45 = __toESM(require_element(), 1);
19740    var import_components20 = __toESM(require_components(), 1);
19741    var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
19742    function InputWidget({
19743      filter,
19744      view,
19745      onChangeView,
19746      fields
19747    }) {
19748      const currentFilter = view.filters?.find(
19749        (f2) => f2.field === filter.field
19750      );
19751      const currentValue = getCurrentValue(filter, currentFilter);
19752      const field = (0, import_element45.useMemo)(() => {
19753        const currentField = fields.find((f2) => f2.id === filter.field);
19754        if (currentField) {
19755          return {
19756            ...currentField,
19757            // Deactivate validation for filters.
19758            isValid: {},
19759            // Filter controls are always enabled.
19760            isDisabled: () => false,
19761            // Filter controls are always visible.
19762            isVisible: () => true,
19763            // Configure getValue/setValue as if Item was a plain object.
19764            getValue: ({ item }) => item[currentField.id],
19765            setValue: ({ value }) => ({
19766              [currentField.id]: value
19767            })
19768          };
19769        }
19770        return currentField;
19771      }, [fields, filter.field]);
19772      const data = (0, import_element45.useMemo)(() => {
19773        return (view.filters ?? []).reduce(
19774          (acc, activeFilter) => {
19775            acc[activeFilter.field] = activeFilter.value;
19776            return acc;
19777          },
19778          {}
19779        );
19780      }, [view.filters]);
19781      const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19782        if (!field || !currentFilter) {
19783          return;
19784        }
19785        const nextValue = field.getValue({ item: updatedData });
19786        if ((0, import_es6.default)(nextValue, currentValue)) {
19787          return;
19788        }
19789        onChangeView({
19790          ...view,
19791          filters: (view.filters ?? []).map(
19792            (_filter) => _filter.field === filter.field ? {
19793              ..._filter,
19794              operator: currentFilter.operator || filter.operators[0],
19795              // Consider empty strings as undefined:
19796              //
19797              // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19798              // - empty string as value means "search empty string": returns only the records that have an empty string as value
19799              //
19800              // In practice, this means the filter will not be able to find an empty string as the value.
19801              value: nextValue === "" ? void 0 : nextValue
19802            } : _filter
19803          )
19804        });
19805      });
19806      if (!field || !field.Edit || !currentFilter) {
19807        return null;
19808      }
19809      return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19810        import_components20.Flex,
19811        {
19812          className: "dataviews-filters__user-input-widget",
19813          gap: 2.5,
19814          direction: "column",
19815          children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19816            field.Edit,
19817            {
19818              hideLabelFromVision: true,
19819              data,
19820              field,
19821              operator: currentFilter.operator,
19822              onChange: handleChange
19823            }
19824          )
19825        }
19826      );
19827    }
19828  
19829    // node_modules/date-fns/constants.js
19830    var daysInYear = 365.2425;
19831    var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19832    var minTime = -maxTime;
19833    var millisecondsInWeek = 6048e5;
19834    var millisecondsInDay = 864e5;
19835    var secondsInHour = 3600;
19836    var secondsInDay = secondsInHour * 24;
19837    var secondsInWeek = secondsInDay * 7;
19838    var secondsInYear = secondsInDay * daysInYear;
19839    var secondsInMonth = secondsInYear / 12;
19840    var secondsInQuarter = secondsInMonth * 3;
19841    var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19842  
19843    // node_modules/date-fns/constructFrom.js
19844    function constructFrom(date, value) {
19845      if (typeof date === "function") return date(value);
19846      if (date && typeof date === "object" && constructFromSymbol in date)
19847        return date[constructFromSymbol](value);
19848      if (date instanceof Date) return new date.constructor(value);
19849      return new Date(value);
19850    }
19851  
19852    // node_modules/date-fns/toDate.js
19853    function toDate(argument, context) {
19854      return constructFrom(context || argument, argument);
19855    }
19856  
19857    // node_modules/date-fns/addDays.js
19858    function addDays(date, amount, options) {
19859      const _date = toDate(date, options?.in);
19860      if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19861      if (!amount) return _date;
19862      _date.setDate(_date.getDate() + amount);
19863      return _date;
19864    }
19865  
19866    // node_modules/date-fns/addMonths.js
19867    function addMonths(date, amount, options) {
19868      const _date = toDate(date, options?.in);
19869      if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19870      if (!amount) {
19871        return _date;
19872      }
19873      const dayOfMonth = _date.getDate();
19874      const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19875      endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19876      const daysInMonth = endOfDesiredMonth.getDate();
19877      if (dayOfMonth >= daysInMonth) {
19878        return endOfDesiredMonth;
19879      } else {
19880        _date.setFullYear(
19881          endOfDesiredMonth.getFullYear(),
19882          endOfDesiredMonth.getMonth(),
19883          dayOfMonth
19884        );
19885        return _date;
19886      }
19887    }
19888  
19889    // node_modules/date-fns/_lib/defaultOptions.js
19890    var defaultOptions = {};
19891    function getDefaultOptions() {
19892      return defaultOptions;
19893    }
19894  
19895    // node_modules/date-fns/startOfWeek.js
19896    function startOfWeek(date, options) {
19897      const defaultOptions2 = getDefaultOptions();
19898      const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19899      const _date = toDate(date, options?.in);
19900      const day = _date.getDay();
19901      const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19902      _date.setDate(_date.getDate() - diff);
19903      _date.setHours(0, 0, 0, 0);
19904      return _date;
19905    }
19906  
19907    // node_modules/date-fns/startOfISOWeek.js
19908    function startOfISOWeek(date, options) {
19909      return startOfWeek(date, { ...options, weekStartsOn: 1 });
19910    }
19911  
19912    // node_modules/date-fns/getISOWeekYear.js
19913    function getISOWeekYear(date, options) {
19914      const _date = toDate(date, options?.in);
19915      const year = _date.getFullYear();
19916      const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19917      fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19918      fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19919      const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19920      const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19921      fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19922      fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19923      const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19924      if (_date.getTime() >= startOfNextYear.getTime()) {
19925        return year + 1;
19926      } else if (_date.getTime() >= startOfThisYear.getTime()) {
19927        return year;
19928      } else {
19929        return year - 1;
19930      }
19931    }
19932  
19933    // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19934    function getTimezoneOffsetInMilliseconds(date) {
19935      const _date = toDate(date);
19936      const utcDate = new Date(
19937        Date.UTC(
19938          _date.getFullYear(),
19939          _date.getMonth(),
19940          _date.getDate(),
19941          _date.getHours(),
19942          _date.getMinutes(),
19943          _date.getSeconds(),
19944          _date.getMilliseconds()
19945        )
19946      );
19947      utcDate.setUTCFullYear(_date.getFullYear());
19948      return +date - +utcDate;
19949    }
19950  
19951    // node_modules/date-fns/_lib/normalizeDates.js
19952    function normalizeDates(context, ...dates) {
19953      const normalize = constructFrom.bind(
19954        null,
19955        context || dates.find((date) => typeof date === "object")
19956      );
19957      return dates.map(normalize);
19958    }
19959  
19960    // node_modules/date-fns/startOfDay.js
19961    function startOfDay(date, options) {
19962      const _date = toDate(date, options?.in);
19963      _date.setHours(0, 0, 0, 0);
19964      return _date;
19965    }
19966  
19967    // node_modules/date-fns/differenceInCalendarDays.js
19968    function differenceInCalendarDays(laterDate, earlierDate, options) {
19969      const [laterDate_, earlierDate_] = normalizeDates(
19970        options?.in,
19971        laterDate,
19972        earlierDate
19973      );
19974      const laterStartOfDay = startOfDay(laterDate_);
19975      const earlierStartOfDay = startOfDay(earlierDate_);
19976      const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19977      const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19978      return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19979    }
19980  
19981    // node_modules/date-fns/startOfISOWeekYear.js
19982    function startOfISOWeekYear(date, options) {
19983      const year = getISOWeekYear(date, options);
19984      const fourthOfJanuary = constructFrom(options?.in || date, 0);
19985      fourthOfJanuary.setFullYear(year, 0, 4);
19986      fourthOfJanuary.setHours(0, 0, 0, 0);
19987      return startOfISOWeek(fourthOfJanuary);
19988    }
19989  
19990    // node_modules/date-fns/addWeeks.js
19991    function addWeeks(date, amount, options) {
19992      return addDays(date, amount * 7, options);
19993    }
19994  
19995    // node_modules/date-fns/addYears.js
19996    function addYears(date, amount, options) {
19997      return addMonths(date, amount * 12, options);
19998    }
19999  
20000    // node_modules/date-fns/isDate.js
20001    function isDate(value) {
20002      return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
20003    }
20004  
20005    // node_modules/date-fns/isValid.js
20006    function isValid(date) {
20007      return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
20008    }
20009  
20010    // node_modules/date-fns/startOfMonth.js
20011    function startOfMonth(date, options) {
20012      const _date = toDate(date, options?.in);
20013      _date.setDate(1);
20014      _date.setHours(0, 0, 0, 0);
20015      return _date;
20016    }
20017  
20018    // node_modules/date-fns/startOfYear.js
20019    function startOfYear(date, options) {
20020      const date_ = toDate(date, options?.in);
20021      date_.setFullYear(date_.getFullYear(), 0, 1);
20022      date_.setHours(0, 0, 0, 0);
20023      return date_;
20024    }
20025  
20026    // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
20027    var formatDistanceLocale = {
20028      lessThanXSeconds: {
20029        one: "less than a second",
20030        other: "less than {{count}} seconds"
20031      },
20032      xSeconds: {
20033        one: "1 second",
20034        other: "{{count}} seconds"
20035      },
20036      halfAMinute: "half a minute",
20037      lessThanXMinutes: {
20038        one: "less than a minute",
20039        other: "less than {{count}} minutes"
20040      },
20041      xMinutes: {
20042        one: "1 minute",
20043        other: "{{count}} minutes"
20044      },
20045      aboutXHours: {
20046        one: "about 1 hour",
20047        other: "about {{count}} hours"
20048      },
20049      xHours: {
20050        one: "1 hour",
20051        other: "{{count}} hours"
20052      },
20053      xDays: {
20054        one: "1 day",
20055        other: "{{count}} days"
20056      },
20057      aboutXWeeks: {
20058        one: "about 1 week",
20059        other: "about {{count}} weeks"
20060      },
20061      xWeeks: {
20062        one: "1 week",
20063        other: "{{count}} weeks"
20064      },
20065      aboutXMonths: {
20066        one: "about 1 month",
20067        other: "about {{count}} months"
20068      },
20069      xMonths: {
20070        one: "1 month",
20071        other: "{{count}} months"
20072      },
20073      aboutXYears: {
20074        one: "about 1 year",
20075        other: "about {{count}} years"
20076      },
20077      xYears: {
20078        one: "1 year",
20079        other: "{{count}} years"
20080      },
20081      overXYears: {
20082        one: "over 1 year",
20083        other: "over {{count}} years"
20084      },
20085      almostXYears: {
20086        one: "almost 1 year",
20087        other: "almost {{count}} years"
20088      }
20089    };
20090    var formatDistance = (token, count, options) => {
20091      let result;
20092      const tokenValue = formatDistanceLocale[token];
20093      if (typeof tokenValue === "string") {
20094        result = tokenValue;
20095      } else if (count === 1) {
20096        result = tokenValue.one;
20097      } else {
20098        result = tokenValue.other.replace("{{count}}", count.toString());
20099      }
20100      if (options?.addSuffix) {
20101        if (options.comparison && options.comparison > 0) {
20102          return "in " + result;
20103        } else {
20104          return result + " ago";
20105        }
20106      }
20107      return result;
20108    };
20109  
20110    // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
20111    function buildFormatLongFn(args) {
20112      return (options = {}) => {
20113        const width = options.width ? String(options.width) : args.defaultWidth;
20114        const format6 = args.formats[width] || args.formats[args.defaultWidth];
20115        return format6;
20116      };
20117    }
20118  
20119    // node_modules/date-fns/locale/en-US/_lib/formatLong.js
20120    var dateFormats = {
20121      full: "EEEE, MMMM do, y",
20122      long: "MMMM do, y",
20123      medium: "MMM d, y",
20124      short: "MM/dd/yyyy"
20125    };
20126    var timeFormats = {
20127      full: "h:mm:ss a zzzz",
20128      long: "h:mm:ss a z",
20129      medium: "h:mm:ss a",
20130      short: "h:mm a"
20131    };
20132    var dateTimeFormats = {
20133      full: "{{date}} 'at' {{time}}",
20134      long: "{{date}} 'at' {{time}}",
20135      medium: "{{date}}, {{time}}",
20136      short: "{{date}}, {{time}}"
20137    };
20138    var formatLong = {
20139      date: buildFormatLongFn({
20140        formats: dateFormats,
20141        defaultWidth: "full"
20142      }),
20143      time: buildFormatLongFn({
20144        formats: timeFormats,
20145        defaultWidth: "full"
20146      }),
20147      dateTime: buildFormatLongFn({
20148        formats: dateTimeFormats,
20149        defaultWidth: "full"
20150      })
20151    };
20152  
20153    // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
20154    var formatRelativeLocale = {
20155      lastWeek: "'last' eeee 'at' p",
20156      yesterday: "'yesterday at' p",
20157      today: "'today at' p",
20158      tomorrow: "'tomorrow at' p",
20159      nextWeek: "eeee 'at' p",
20160      other: "P"
20161    };
20162    var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
20163  
20164    // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
20165    function buildLocalizeFn(args) {
20166      return (value, options) => {
20167        const context = options?.context ? String(options.context) : "standalone";
20168        let valuesArray;
20169        if (context === "formatting" && args.formattingValues) {
20170          const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
20171          const width = options?.width ? String(options.width) : defaultWidth;
20172          valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
20173        } else {
20174          const defaultWidth = args.defaultWidth;
20175          const width = options?.width ? String(options.width) : args.defaultWidth;
20176          valuesArray = args.values[width] || args.values[defaultWidth];
20177        }
20178        const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
20179        return valuesArray[index2];
20180      };
20181    }
20182  
20183    // node_modules/date-fns/locale/en-US/_lib/localize.js
20184    var eraValues = {
20185      narrow: ["B", "A"],
20186      abbreviated: ["BC", "AD"],
20187      wide: ["Before Christ", "Anno Domini"]
20188    };
20189    var quarterValues = {
20190      narrow: ["1", "2", "3", "4"],
20191      abbreviated: ["Q1", "Q2", "Q3", "Q4"],
20192      wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
20193    };
20194    var monthValues = {
20195      narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
20196      abbreviated: [
20197        "Jan",
20198        "Feb",
20199        "Mar",
20200        "Apr",
20201        "May",
20202        "Jun",
20203        "Jul",
20204        "Aug",
20205        "Sep",
20206        "Oct",
20207        "Nov",
20208        "Dec"
20209      ],
20210      wide: [
20211        "January",
20212        "February",
20213        "March",
20214        "April",
20215        "May",
20216        "June",
20217        "July",
20218        "August",
20219        "September",
20220        "October",
20221        "November",
20222        "December"
20223      ]
20224    };
20225    var dayValues = {
20226      narrow: ["S", "M", "T", "W", "T", "F", "S"],
20227      short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
20228      abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
20229      wide: [
20230        "Sunday",
20231        "Monday",
20232        "Tuesday",
20233        "Wednesday",
20234        "Thursday",
20235        "Friday",
20236        "Saturday"
20237      ]
20238    };
20239    var dayPeriodValues = {
20240      narrow: {
20241        am: "a",
20242        pm: "p",
20243        midnight: "mi",
20244        noon: "n",
20245        morning: "morning",
20246        afternoon: "afternoon",
20247        evening: "evening",
20248        night: "night"
20249      },
20250      abbreviated: {
20251        am: "AM",
20252        pm: "PM",
20253        midnight: "midnight",
20254        noon: "noon",
20255        morning: "morning",
20256        afternoon: "afternoon",
20257        evening: "evening",
20258        night: "night"
20259      },
20260      wide: {
20261        am: "a.m.",
20262        pm: "p.m.",
20263        midnight: "midnight",
20264        noon: "noon",
20265        morning: "morning",
20266        afternoon: "afternoon",
20267        evening: "evening",
20268        night: "night"
20269      }
20270    };
20271    var formattingDayPeriodValues = {
20272      narrow: {
20273        am: "a",
20274        pm: "p",
20275        midnight: "mi",
20276        noon: "n",
20277        morning: "in the morning",
20278        afternoon: "in the afternoon",
20279        evening: "in the evening",
20280        night: "at night"
20281      },
20282      abbreviated: {
20283        am: "AM",
20284        pm: "PM",
20285        midnight: "midnight",
20286        noon: "noon",
20287        morning: "in the morning",
20288        afternoon: "in the afternoon",
20289        evening: "in the evening",
20290        night: "at night"
20291      },
20292      wide: {
20293        am: "a.m.",
20294        pm: "p.m.",
20295        midnight: "midnight",
20296        noon: "noon",
20297        morning: "in the morning",
20298        afternoon: "in the afternoon",
20299        evening: "in the evening",
20300        night: "at night"
20301      }
20302    };
20303    var ordinalNumber = (dirtyNumber, _options) => {
20304      const number = Number(dirtyNumber);
20305      const rem100 = number % 100;
20306      if (rem100 > 20 || rem100 < 10) {
20307        switch (rem100 % 10) {
20308          case 1:
20309            return number + "st";
20310          case 2:
20311            return number + "nd";
20312          case 3:
20313            return number + "rd";
20314        }
20315      }
20316      return number + "th";
20317    };
20318    var localize = {
20319      ordinalNumber,
20320      era: buildLocalizeFn({
20321        values: eraValues,
20322        defaultWidth: "wide"
20323      }),
20324      quarter: buildLocalizeFn({
20325        values: quarterValues,
20326        defaultWidth: "wide",
20327        argumentCallback: (quarter) => quarter - 1
20328      }),
20329      month: buildLocalizeFn({
20330        values: monthValues,
20331        defaultWidth: "wide"
20332      }),
20333      day: buildLocalizeFn({
20334        values: dayValues,
20335        defaultWidth: "wide"
20336      }),
20337      dayPeriod: buildLocalizeFn({
20338        values: dayPeriodValues,
20339        defaultWidth: "wide",
20340        formattingValues: formattingDayPeriodValues,
20341        defaultFormattingWidth: "wide"
20342      })
20343    };
20344  
20345    // node_modules/date-fns/locale/_lib/buildMatchFn.js
20346    function buildMatchFn(args) {
20347      return (string, options = {}) => {
20348        const width = options.width;
20349        const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
20350        const matchResult = string.match(matchPattern);
20351        if (!matchResult) {
20352          return null;
20353        }
20354        const matchedString = matchResult[0];
20355        const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
20356        const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
20357          // [TODO] -- I challenge you to fix the type
20358          findKey(parsePatterns, (pattern) => pattern.test(matchedString))
20359        );
20360        let value;
20361        value = args.valueCallback ? args.valueCallback(key) : key;
20362        value = options.valueCallback ? (
20363          // [TODO] -- I challenge you to fix the type
20364          options.valueCallback(value)
20365        ) : value;
20366        const rest = string.slice(matchedString.length);
20367        return { value, rest };
20368      };
20369    }
20370    function findKey(object, predicate) {
20371      for (const key in object) {
20372        if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
20373          return key;
20374        }
20375      }
20376      return void 0;
20377    }
20378    function findIndex(array, predicate) {
20379      for (let key = 0; key < array.length; key++) {
20380        if (predicate(array[key])) {
20381          return key;
20382        }
20383      }
20384      return void 0;
20385    }
20386  
20387    // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
20388    function buildMatchPatternFn(args) {
20389      return (string, options = {}) => {
20390        const matchResult = string.match(args.matchPattern);
20391        if (!matchResult) return null;
20392        const matchedString = matchResult[0];
20393        const parseResult = string.match(args.parsePattern);
20394        if (!parseResult) return null;
20395        let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
20396        value = options.valueCallback ? options.valueCallback(value) : value;
20397        const rest = string.slice(matchedString.length);
20398        return { value, rest };
20399      };
20400    }
20401  
20402    // node_modules/date-fns/locale/en-US/_lib/match.js
20403    var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
20404    var parseOrdinalNumberPattern = /\d+/i;
20405    var matchEraPatterns = {
20406      narrow: /^(b|a)/i,
20407      abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
20408      wide: /^(before christ|before common era|anno domini|common era)/i
20409    };
20410    var parseEraPatterns = {
20411      any: [/^b/i, /^(a|c)/i]
20412    };
20413    var matchQuarterPatterns = {
20414      narrow: /^[1234]/i,
20415      abbreviated: /^q[1234]/i,
20416      wide: /^[1234](th|st|nd|rd)? quarter/i
20417    };
20418    var parseQuarterPatterns = {
20419      any: [/1/i, /2/i, /3/i, /4/i]
20420    };
20421    var matchMonthPatterns = {
20422      narrow: /^[jfmasond]/i,
20423      abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
20424      wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
20425    };
20426    var parseMonthPatterns = {
20427      narrow: [
20428        /^j/i,
20429        /^f/i,
20430        /^m/i,
20431        /^a/i,
20432        /^m/i,
20433        /^j/i,
20434        /^j/i,
20435        /^a/i,
20436        /^s/i,
20437        /^o/i,
20438        /^n/i,
20439        /^d/i
20440      ],
20441      any: [
20442        /^ja/i,
20443        /^f/i,
20444        /^mar/i,
20445        /^ap/i,
20446        /^may/i,
20447        /^jun/i,
20448        /^jul/i,
20449        /^au/i,
20450        /^s/i,
20451        /^o/i,
20452        /^n/i,
20453        /^d/i
20454      ]
20455    };
20456    var matchDayPatterns = {
20457      narrow: /^[smtwf]/i,
20458      short: /^(su|mo|tu|we|th|fr|sa)/i,
20459      abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
20460      wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
20461    };
20462    var parseDayPatterns = {
20463      narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
20464      any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
20465    };
20466    var matchDayPeriodPatterns = {
20467      narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
20468      any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
20469    };
20470    var parseDayPeriodPatterns = {
20471      any: {
20472        am: /^a/i,
20473        pm: /^p/i,
20474        midnight: /^mi/i,
20475        noon: /^no/i,
20476        morning: /morning/i,
20477        afternoon: /afternoon/i,
20478        evening: /evening/i,
20479        night: /night/i
20480      }
20481    };
20482    var match = {
20483      ordinalNumber: buildMatchPatternFn({
20484        matchPattern: matchOrdinalNumberPattern,
20485        parsePattern: parseOrdinalNumberPattern,
20486        valueCallback: (value) => parseInt(value, 10)
20487      }),
20488      era: buildMatchFn({
20489        matchPatterns: matchEraPatterns,
20490        defaultMatchWidth: "wide",
20491        parsePatterns: parseEraPatterns,
20492        defaultParseWidth: "any"
20493      }),
20494      quarter: buildMatchFn({
20495        matchPatterns: matchQuarterPatterns,
20496        defaultMatchWidth: "wide",
20497        parsePatterns: parseQuarterPatterns,
20498        defaultParseWidth: "any",
20499        valueCallback: (index2) => index2 + 1
20500      }),
20501      month: buildMatchFn({
20502        matchPatterns: matchMonthPatterns,
20503        defaultMatchWidth: "wide",
20504        parsePatterns: parseMonthPatterns,
20505        defaultParseWidth: "any"
20506      }),
20507      day: buildMatchFn({
20508        matchPatterns: matchDayPatterns,
20509        defaultMatchWidth: "wide",
20510        parsePatterns: parseDayPatterns,
20511        defaultParseWidth: "any"
20512      }),
20513      dayPeriod: buildMatchFn({
20514        matchPatterns: matchDayPeriodPatterns,
20515        defaultMatchWidth: "any",
20516        parsePatterns: parseDayPeriodPatterns,
20517        defaultParseWidth: "any"
20518      })
20519    };
20520  
20521    // node_modules/date-fns/locale/en-US.js
20522    var enUS = {
20523      code: "en-US",
20524      formatDistance,
20525      formatLong,
20526      formatRelative,
20527      localize,
20528      match,
20529      options: {
20530        weekStartsOn: 0,
20531        firstWeekContainsDate: 1
20532      }
20533    };
20534  
20535    // node_modules/date-fns/getDayOfYear.js
20536    function getDayOfYear(date, options) {
20537      const _date = toDate(date, options?.in);
20538      const diff = differenceInCalendarDays(_date, startOfYear(_date));
20539      const dayOfYear = diff + 1;
20540      return dayOfYear;
20541    }
20542  
20543    // node_modules/date-fns/getISOWeek.js
20544    function getISOWeek(date, options) {
20545      const _date = toDate(date, options?.in);
20546      const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
20547      return Math.round(diff / millisecondsInWeek) + 1;
20548    }
20549  
20550    // node_modules/date-fns/getWeekYear.js
20551    function getWeekYear(date, options) {
20552      const _date = toDate(date, options?.in);
20553      const year = _date.getFullYear();
20554      const defaultOptions2 = getDefaultOptions();
20555      const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20556      const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
20557      firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
20558      firstWeekOfNextYear.setHours(0, 0, 0, 0);
20559      const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
20560      const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
20561      firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
20562      firstWeekOfThisYear.setHours(0, 0, 0, 0);
20563      const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
20564      if (+_date >= +startOfNextYear) {
20565        return year + 1;
20566      } else if (+_date >= +startOfThisYear) {
20567        return year;
20568      } else {
20569        return year - 1;
20570      }
20571    }
20572  
20573    // node_modules/date-fns/startOfWeekYear.js
20574    function startOfWeekYear(date, options) {
20575      const defaultOptions2 = getDefaultOptions();
20576      const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20577      const year = getWeekYear(date, options);
20578      const firstWeek = constructFrom(options?.in || date, 0);
20579      firstWeek.setFullYear(year, 0, firstWeekContainsDate);
20580      firstWeek.setHours(0, 0, 0, 0);
20581      const _date = startOfWeek(firstWeek, options);
20582      return _date;
20583    }
20584  
20585    // node_modules/date-fns/getWeek.js
20586    function getWeek(date, options) {
20587      const _date = toDate(date, options?.in);
20588      const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
20589      return Math.round(diff / millisecondsInWeek) + 1;
20590    }
20591  
20592    // node_modules/date-fns/_lib/addLeadingZeros.js
20593    function addLeadingZeros(number, targetLength) {
20594      const sign = number < 0 ? "-" : "";
20595      const output = Math.abs(number).toString().padStart(targetLength, "0");
20596      return sign + output;
20597    }
20598  
20599    // node_modules/date-fns/_lib/format/lightFormatters.js
20600    var lightFormatters = {
20601      // Year
20602      y(date, token) {
20603        const signedYear = date.getFullYear();
20604        const year = signedYear > 0 ? signedYear : 1 - signedYear;
20605        return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20606      },
20607      // Month
20608      M(date, token) {
20609        const month = date.getMonth();
20610        return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20611      },
20612      // Day of the month
20613      d(date, token) {
20614        return addLeadingZeros(date.getDate(), token.length);
20615      },
20616      // AM or PM
20617      a(date, token) {
20618        const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20619        switch (token) {
20620          case "a":
20621          case "aa":
20622            return dayPeriodEnumValue.toUpperCase();
20623          case "aaa":
20624            return dayPeriodEnumValue;
20625          case "aaaaa":
20626            return dayPeriodEnumValue[0];
20627          case "aaaa":
20628          default:
20629            return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20630        }
20631      },
20632      // Hour [1-12]
20633      h(date, token) {
20634        return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20635      },
20636      // Hour [0-23]
20637      H(date, token) {
20638        return addLeadingZeros(date.getHours(), token.length);
20639      },
20640      // Minute
20641      m(date, token) {
20642        return addLeadingZeros(date.getMinutes(), token.length);
20643      },
20644      // Second
20645      s(date, token) {
20646        return addLeadingZeros(date.getSeconds(), token.length);
20647      },
20648      // Fraction of second
20649      S(date, token) {
20650        const numberOfDigits = token.length;
20651        const milliseconds = date.getMilliseconds();
20652        const fractionalSeconds = Math.trunc(
20653          milliseconds * Math.pow(10, numberOfDigits - 3)
20654        );
20655        return addLeadingZeros(fractionalSeconds, token.length);
20656      }
20657    };
20658  
20659    // node_modules/date-fns/_lib/format/formatters.js
20660    var dayPeriodEnum = {
20661      am: "am",
20662      pm: "pm",
20663      midnight: "midnight",
20664      noon: "noon",
20665      morning: "morning",
20666      afternoon: "afternoon",
20667      evening: "evening",
20668      night: "night"
20669    };
20670    var formatters = {
20671      // Era
20672      G: function(date, token, localize2) {
20673        const era = date.getFullYear() > 0 ? 1 : 0;
20674        switch (token) {
20675          // AD, BC
20676          case "G":
20677          case "GG":
20678          case "GGG":
20679            return localize2.era(era, { width: "abbreviated" });
20680          // A, B
20681          case "GGGGG":
20682            return localize2.era(era, { width: "narrow" });
20683          // Anno Domini, Before Christ
20684          case "GGGG":
20685          default:
20686            return localize2.era(era, { width: "wide" });
20687        }
20688      },
20689      // Year
20690      y: function(date, token, localize2) {
20691        if (token === "yo") {
20692          const signedYear = date.getFullYear();
20693          const year = signedYear > 0 ? signedYear : 1 - signedYear;
20694          return localize2.ordinalNumber(year, { unit: "year" });
20695        }
20696        return lightFormatters.y(date, token);
20697      },
20698      // Local week-numbering year
20699      Y: function(date, token, localize2, options) {
20700        const signedWeekYear = getWeekYear(date, options);
20701        const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20702        if (token === "YY") {
20703          const twoDigitYear = weekYear % 100;
20704          return addLeadingZeros(twoDigitYear, 2);
20705        }
20706        if (token === "Yo") {
20707          return localize2.ordinalNumber(weekYear, { unit: "year" });
20708        }
20709        return addLeadingZeros(weekYear, token.length);
20710      },
20711      // ISO week-numbering year
20712      R: function(date, token) {
20713        const isoWeekYear = getISOWeekYear(date);
20714        return addLeadingZeros(isoWeekYear, token.length);
20715      },
20716      // Extended year. This is a single number designating the year of this calendar system.
20717      // The main difference between `y` and `u` localizers are B.C. years:
20718      // | Year | `y` | `u` |
20719      // |------|-----|-----|
20720      // | AC 1 |   1 |   1 |
20721      // | BC 1 |   1 |   0 |
20722      // | BC 2 |   2 |  -1 |
20723      // Also `yy` always returns the last two digits of a year,
20724      // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20725      u: function(date, token) {
20726        const year = date.getFullYear();
20727        return addLeadingZeros(year, token.length);
20728      },
20729      // Quarter
20730      Q: function(date, token, localize2) {
20731        const quarter = Math.ceil((date.getMonth() + 1) / 3);
20732        switch (token) {
20733          // 1, 2, 3, 4
20734          case "Q":
20735            return String(quarter);
20736          // 01, 02, 03, 04
20737          case "QQ":
20738            return addLeadingZeros(quarter, 2);
20739          // 1st, 2nd, 3rd, 4th
20740          case "Qo":
20741            return localize2.ordinalNumber(quarter, { unit: "quarter" });
20742          // Q1, Q2, Q3, Q4
20743          case "QQQ":
20744            return localize2.quarter(quarter, {
20745              width: "abbreviated",
20746              context: "formatting"
20747            });
20748          // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20749          case "QQQQQ":
20750            return localize2.quarter(quarter, {
20751              width: "narrow",
20752              context: "formatting"
20753            });
20754          // 1st quarter, 2nd quarter, ...
20755          case "QQQQ":
20756          default:
20757            return localize2.quarter(quarter, {
20758              width: "wide",
20759              context: "formatting"
20760            });
20761        }
20762      },
20763      // Stand-alone quarter
20764      q: function(date, token, localize2) {
20765        const quarter = Math.ceil((date.getMonth() + 1) / 3);
20766        switch (token) {
20767          // 1, 2, 3, 4
20768          case "q":
20769            return String(quarter);
20770          // 01, 02, 03, 04
20771          case "qq":
20772            return addLeadingZeros(quarter, 2);
20773          // 1st, 2nd, 3rd, 4th
20774          case "qo":
20775            return localize2.ordinalNumber(quarter, { unit: "quarter" });
20776          // Q1, Q2, Q3, Q4
20777          case "qqq":
20778            return localize2.quarter(quarter, {
20779              width: "abbreviated",
20780              context: "standalone"
20781            });
20782          // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20783          case "qqqqq":
20784            return localize2.quarter(quarter, {
20785              width: "narrow",
20786              context: "standalone"
20787            });
20788          // 1st quarter, 2nd quarter, ...
20789          case "qqqq":
20790          default:
20791            return localize2.quarter(quarter, {
20792              width: "wide",
20793              context: "standalone"
20794            });
20795        }
20796      },
20797      // Month
20798      M: function(date, token, localize2) {
20799        const month = date.getMonth();
20800        switch (token) {
20801          case "M":
20802          case "MM":
20803            return lightFormatters.M(date, token);
20804          // 1st, 2nd, ..., 12th
20805          case "Mo":
20806            return localize2.ordinalNumber(month + 1, { unit: "month" });
20807          // Jan, Feb, ..., Dec
20808          case "MMM":
20809            return localize2.month(month, {
20810              width: "abbreviated",
20811              context: "formatting"
20812            });
20813          // J, F, ..., D
20814          case "MMMMM":
20815            return localize2.month(month, {
20816              width: "narrow",
20817              context: "formatting"
20818            });
20819          // January, February, ..., December
20820          case "MMMM":
20821          default:
20822            return localize2.month(month, { width: "wide", context: "formatting" });
20823        }
20824      },
20825      // Stand-alone month
20826      L: function(date, token, localize2) {
20827        const month = date.getMonth();
20828        switch (token) {
20829          // 1, 2, ..., 12
20830          case "L":
20831            return String(month + 1);
20832          // 01, 02, ..., 12
20833          case "LL":
20834            return addLeadingZeros(month + 1, 2);
20835          // 1st, 2nd, ..., 12th
20836          case "Lo":
20837            return localize2.ordinalNumber(month + 1, { unit: "month" });
20838          // Jan, Feb, ..., Dec
20839          case "LLL":
20840            return localize2.month(month, {
20841              width: "abbreviated",
20842              context: "standalone"
20843            });
20844          // J, F, ..., D
20845          case "LLLLL":
20846            return localize2.month(month, {
20847              width: "narrow",
20848              context: "standalone"
20849            });
20850          // January, February, ..., December
20851          case "LLLL":
20852          default:
20853            return localize2.month(month, { width: "wide", context: "standalone" });
20854        }
20855      },
20856      // Local week of year
20857      w: function(date, token, localize2, options) {
20858        const week = getWeek(date, options);
20859        if (token === "wo") {
20860          return localize2.ordinalNumber(week, { unit: "week" });
20861        }
20862        return addLeadingZeros(week, token.length);
20863      },
20864      // ISO week of year
20865      I: function(date, token, localize2) {
20866        const isoWeek = getISOWeek(date);
20867        if (token === "Io") {
20868          return localize2.ordinalNumber(isoWeek, { unit: "week" });
20869        }
20870        return addLeadingZeros(isoWeek, token.length);
20871      },
20872      // Day of the month
20873      d: function(date, token, localize2) {
20874        if (token === "do") {
20875          return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20876        }
20877        return lightFormatters.d(date, token);
20878      },
20879      // Day of year
20880      D: function(date, token, localize2) {
20881        const dayOfYear = getDayOfYear(date);
20882        if (token === "Do") {
20883          return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20884        }
20885        return addLeadingZeros(dayOfYear, token.length);
20886      },
20887      // Day of week
20888      E: function(date, token, localize2) {
20889        const dayOfWeek = date.getDay();
20890        switch (token) {
20891          // Tue
20892          case "E":
20893          case "EE":
20894          case "EEE":
20895            return localize2.day(dayOfWeek, {
20896              width: "abbreviated",
20897              context: "formatting"
20898            });
20899          // T
20900          case "EEEEE":
20901            return localize2.day(dayOfWeek, {
20902              width: "narrow",
20903              context: "formatting"
20904            });
20905          // Tu
20906          case "EEEEEE":
20907            return localize2.day(dayOfWeek, {
20908              width: "short",
20909              context: "formatting"
20910            });
20911          // Tuesday
20912          case "EEEE":
20913          default:
20914            return localize2.day(dayOfWeek, {
20915              width: "wide",
20916              context: "formatting"
20917            });
20918        }
20919      },
20920      // Local day of week
20921      e: function(date, token, localize2, options) {
20922        const dayOfWeek = date.getDay();
20923        const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20924        switch (token) {
20925          // Numerical value (Nth day of week with current locale or weekStartsOn)
20926          case "e":
20927            return String(localDayOfWeek);
20928          // Padded numerical value
20929          case "ee":
20930            return addLeadingZeros(localDayOfWeek, 2);
20931          // 1st, 2nd, ..., 7th
20932          case "eo":
20933            return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20934          case "eee":
20935            return localize2.day(dayOfWeek, {
20936              width: "abbreviated",
20937              context: "formatting"
20938            });
20939          // T
20940          case "eeeee":
20941            return localize2.day(dayOfWeek, {
20942              width: "narrow",
20943              context: "formatting"
20944            });
20945          // Tu
20946          case "eeeeee":
20947            return localize2.day(dayOfWeek, {
20948              width: "short",
20949              context: "formatting"
20950            });
20951          // Tuesday
20952          case "eeee":
20953          default:
20954            return localize2.day(dayOfWeek, {
20955              width: "wide",
20956              context: "formatting"
20957            });
20958        }
20959      },
20960      // Stand-alone local day of week
20961      c: function(date, token, localize2, options) {
20962        const dayOfWeek = date.getDay();
20963        const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20964        switch (token) {
20965          // Numerical value (same as in `e`)
20966          case "c":
20967            return String(localDayOfWeek);
20968          // Padded numerical value
20969          case "cc":
20970            return addLeadingZeros(localDayOfWeek, token.length);
20971          // 1st, 2nd, ..., 7th
20972          case "co":
20973            return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20974          case "ccc":
20975            return localize2.day(dayOfWeek, {
20976              width: "abbreviated",
20977              context: "standalone"
20978            });
20979          // T
20980          case "ccccc":
20981            return localize2.day(dayOfWeek, {
20982              width: "narrow",
20983              context: "standalone"
20984            });
20985          // Tu
20986          case "cccccc":
20987            return localize2.day(dayOfWeek, {
20988              width: "short",
20989              context: "standalone"
20990            });
20991          // Tuesday
20992          case "cccc":
20993          default:
20994            return localize2.day(dayOfWeek, {
20995              width: "wide",
20996              context: "standalone"
20997            });
20998        }
20999      },
21000      // ISO day of week
21001      i: function(date, token, localize2) {
21002        const dayOfWeek = date.getDay();
21003        const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
21004        switch (token) {
21005          // 2
21006          case "i":
21007            return String(isoDayOfWeek);
21008          // 02
21009          case "ii":
21010            return addLeadingZeros(isoDayOfWeek, token.length);
21011          // 2nd
21012          case "io":
21013            return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
21014          // Tue
21015          case "iii":
21016            return localize2.day(dayOfWeek, {
21017              width: "abbreviated",
21018              context: "formatting"
21019            });
21020          // T
21021          case "iiiii":
21022            return localize2.day(dayOfWeek, {
21023              width: "narrow",
21024              context: "formatting"
21025            });
21026          // Tu
21027          case "iiiiii":
21028            return localize2.day(dayOfWeek, {
21029              width: "short",
21030              context: "formatting"
21031            });
21032          // Tuesday
21033          case "iiii":
21034          default:
21035            return localize2.day(dayOfWeek, {
21036              width: "wide",
21037              context: "formatting"
21038            });
21039        }
21040      },
21041      // AM or PM
21042      a: function(date, token, localize2) {
21043        const hours = date.getHours();
21044        const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
21045        switch (token) {
21046          case "a":
21047          case "aa":
21048            return localize2.dayPeriod(dayPeriodEnumValue, {
21049              width: "abbreviated",
21050              context: "formatting"
21051            });
21052          case "aaa":
21053            return localize2.dayPeriod(dayPeriodEnumValue, {
21054              width: "abbreviated",
21055              context: "formatting"
21056            }).toLowerCase();
21057          case "aaaaa":
21058            return localize2.dayPeriod(dayPeriodEnumValue, {
21059              width: "narrow",
21060              context: "formatting"
21061            });
21062          case "aaaa":
21063          default:
21064            return localize2.dayPeriod(dayPeriodEnumValue, {
21065              width: "wide",
21066              context: "formatting"
21067            });
21068        }
21069      },
21070      // AM, PM, midnight, noon
21071      b: function(date, token, localize2) {
21072        const hours = date.getHours();
21073        let dayPeriodEnumValue;
21074        if (hours === 12) {
21075          dayPeriodEnumValue = dayPeriodEnum.noon;
21076        } else if (hours === 0) {
21077          dayPeriodEnumValue = dayPeriodEnum.midnight;
21078        } else {
21079          dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
21080        }
21081        switch (token) {
21082          case "b":
21083          case "bb":
21084            return localize2.dayPeriod(dayPeriodEnumValue, {
21085              width: "abbreviated",
21086              context: "formatting"
21087            });
21088          case "bbb":
21089            return localize2.dayPeriod(dayPeriodEnumValue, {
21090              width: "abbreviated",
21091              context: "formatting"
21092            }).toLowerCase();
21093          case "bbbbb":
21094            return localize2.dayPeriod(dayPeriodEnumValue, {
21095              width: "narrow",
21096              context: "formatting"
21097            });
21098          case "bbbb":
21099          default:
21100            return localize2.dayPeriod(dayPeriodEnumValue, {
21101              width: "wide",
21102              context: "formatting"
21103            });
21104        }
21105      },
21106      // in the morning, in the afternoon, in the evening, at night
21107      B: function(date, token, localize2) {
21108        const hours = date.getHours();
21109        let dayPeriodEnumValue;
21110        if (hours >= 17) {
21111          dayPeriodEnumValue = dayPeriodEnum.evening;
21112        } else if (hours >= 12) {
21113          dayPeriodEnumValue = dayPeriodEnum.afternoon;
21114        } else if (hours >= 4) {
21115          dayPeriodEnumValue = dayPeriodEnum.morning;
21116        } else {
21117          dayPeriodEnumValue = dayPeriodEnum.night;
21118        }
21119        switch (token) {
21120          case "B":
21121          case "BB":
21122          case "BBB":
21123            return localize2.dayPeriod(dayPeriodEnumValue, {
21124              width: "abbreviated",
21125              context: "formatting"
21126            });
21127          case "BBBBB":
21128            return localize2.dayPeriod(dayPeriodEnumValue, {
21129              width: "narrow",
21130              context: "formatting"
21131            });
21132          case "BBBB":
21133          default:
21134            return localize2.dayPeriod(dayPeriodEnumValue, {
21135              width: "wide",
21136              context: "formatting"
21137            });
21138        }
21139      },
21140      // Hour [1-12]
21141      h: function(date, token, localize2) {
21142        if (token === "ho") {
21143          let hours = date.getHours() % 12;
21144          if (hours === 0) hours = 12;
21145          return localize2.ordinalNumber(hours, { unit: "hour" });
21146        }
21147        return lightFormatters.h(date, token);
21148      },
21149      // Hour [0-23]
21150      H: function(date, token, localize2) {
21151        if (token === "Ho") {
21152          return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
21153        }
21154        return lightFormatters.H(date, token);
21155      },
21156      // Hour [0-11]
21157      K: function(date, token, localize2) {
21158        const hours = date.getHours() % 12;
21159        if (token === "Ko") {
21160          return localize2.ordinalNumber(hours, { unit: "hour" });
21161        }
21162        return addLeadingZeros(hours, token.length);
21163      },
21164      // Hour [1-24]
21165      k: function(date, token, localize2) {
21166        let hours = date.getHours();
21167        if (hours === 0) hours = 24;
21168        if (token === "ko") {
21169          return localize2.ordinalNumber(hours, { unit: "hour" });
21170        }
21171        return addLeadingZeros(hours, token.length);
21172      },
21173      // Minute
21174      m: function(date, token, localize2) {
21175        if (token === "mo") {
21176          return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
21177        }
21178        return lightFormatters.m(date, token);
21179      },
21180      // Second
21181      s: function(date, token, localize2) {
21182        if (token === "so") {
21183          return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
21184        }
21185        return lightFormatters.s(date, token);
21186      },
21187      // Fraction of second
21188      S: function(date, token) {
21189        return lightFormatters.S(date, token);
21190      },
21191      // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
21192      X: function(date, token, _localize) {
21193        const timezoneOffset = date.getTimezoneOffset();
21194        if (timezoneOffset === 0) {
21195          return "Z";
21196        }
21197        switch (token) {
21198          // Hours and optional minutes
21199          case "X":
21200            return formatTimezoneWithOptionalMinutes(timezoneOffset);
21201          // Hours, minutes and optional seconds without `:` delimiter
21202          // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21203          // so this token always has the same output as `XX`
21204          case "XXXX":
21205          case "XX":
21206            return formatTimezone(timezoneOffset);
21207          // Hours, minutes and optional seconds with `:` delimiter
21208          // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21209          // so this token always has the same output as `XXX`
21210          case "XXXXX":
21211          case "XXX":
21212          // Hours and minutes with `:` delimiter
21213          default:
21214            return formatTimezone(timezoneOffset, ":");
21215        }
21216      },
21217      // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
21218      x: function(date, token, _localize) {
21219        const timezoneOffset = date.getTimezoneOffset();
21220        switch (token) {
21221          // Hours and optional minutes
21222          case "x":
21223            return formatTimezoneWithOptionalMinutes(timezoneOffset);
21224          // Hours, minutes and optional seconds without `:` delimiter
21225          // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21226          // so this token always has the same output as `xx`
21227          case "xxxx":
21228          case "xx":
21229            return formatTimezone(timezoneOffset);
21230          // Hours, minutes and optional seconds with `:` delimiter
21231          // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21232          // so this token always has the same output as `xxx`
21233          case "xxxxx":
21234          case "xxx":
21235          // Hours and minutes with `:` delimiter
21236          default:
21237            return formatTimezone(timezoneOffset, ":");
21238        }
21239      },
21240      // Timezone (GMT)
21241      O: function(date, token, _localize) {
21242        const timezoneOffset = date.getTimezoneOffset();
21243        switch (token) {
21244          // Short
21245          case "O":
21246          case "OO":
21247          case "OOO":
21248            return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21249          // Long
21250          case "OOOO":
21251          default:
21252            return "GMT" + formatTimezone(timezoneOffset, ":");
21253        }
21254      },
21255      // Timezone (specific non-location)
21256      z: function(date, token, _localize) {
21257        const timezoneOffset = date.getTimezoneOffset();
21258        switch (token) {
21259          // Short
21260          case "z":
21261          case "zz":
21262          case "zzz":
21263            return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21264          // Long
21265          case "zzzz":
21266          default:
21267            return "GMT" + formatTimezone(timezoneOffset, ":");
21268        }
21269      },
21270      // Seconds timestamp
21271      t: function(date, token, _localize) {
21272        const timestamp = Math.trunc(+date / 1e3);
21273        return addLeadingZeros(timestamp, token.length);
21274      },
21275      // Milliseconds timestamp
21276      T: function(date, token, _localize) {
21277        return addLeadingZeros(+date, token.length);
21278      }
21279    };
21280    function formatTimezoneShort(offset4, delimiter = "") {
21281      const sign = offset4 > 0 ? "-" : "+";
21282      const absOffset = Math.abs(offset4);
21283      const hours = Math.trunc(absOffset / 60);
21284      const minutes = absOffset % 60;
21285      if (minutes === 0) {
21286        return sign + String(hours);
21287      }
21288      return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
21289    }
21290    function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
21291      if (offset4 % 60 === 0) {
21292        const sign = offset4 > 0 ? "-" : "+";
21293        return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
21294      }
21295      return formatTimezone(offset4, delimiter);
21296    }
21297    function formatTimezone(offset4, delimiter = "") {
21298      const sign = offset4 > 0 ? "-" : "+";
21299      const absOffset = Math.abs(offset4);
21300      const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
21301      const minutes = addLeadingZeros(absOffset % 60, 2);
21302      return sign + hours + delimiter + minutes;
21303    }
21304  
21305    // node_modules/date-fns/_lib/format/longFormatters.js
21306    var dateLongFormatter = (pattern, formatLong2) => {
21307      switch (pattern) {
21308        case "P":
21309          return formatLong2.date({ width: "short" });
21310        case "PP":
21311          return formatLong2.date({ width: "medium" });
21312        case "PPP":
21313          return formatLong2.date({ width: "long" });
21314        case "PPPP":
21315        default:
21316          return formatLong2.date({ width: "full" });
21317      }
21318    };
21319    var timeLongFormatter = (pattern, formatLong2) => {
21320      switch (pattern) {
21321        case "p":
21322          return formatLong2.time({ width: "short" });
21323        case "pp":
21324          return formatLong2.time({ width: "medium" });
21325        case "ppp":
21326          return formatLong2.time({ width: "long" });
21327        case "pppp":
21328        default:
21329          return formatLong2.time({ width: "full" });
21330      }
21331    };
21332    var dateTimeLongFormatter = (pattern, formatLong2) => {
21333      const matchResult = pattern.match(/(P+)(p+)?/) || [];
21334      const datePattern = matchResult[1];
21335      const timePattern = matchResult[2];
21336      if (!timePattern) {
21337        return dateLongFormatter(pattern, formatLong2);
21338      }
21339      let dateTimeFormat;
21340      switch (datePattern) {
21341        case "P":
21342          dateTimeFormat = formatLong2.dateTime({ width: "short" });
21343          break;
21344        case "PP":
21345          dateTimeFormat = formatLong2.dateTime({ width: "medium" });
21346          break;
21347        case "PPP":
21348          dateTimeFormat = formatLong2.dateTime({ width: "long" });
21349          break;
21350        case "PPPP":
21351        default:
21352          dateTimeFormat = formatLong2.dateTime({ width: "full" });
21353          break;
21354      }
21355      return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
21356    };
21357    var longFormatters = {
21358      p: timeLongFormatter,
21359      P: dateTimeLongFormatter
21360    };
21361  
21362    // node_modules/date-fns/_lib/protectedTokens.js
21363    var dayOfYearTokenRE = /^D+$/;
21364    var weekYearTokenRE = /^Y+$/;
21365    var throwTokens = ["D", "DD", "YY", "YYYY"];
21366    function isProtectedDayOfYearToken(token) {
21367      return dayOfYearTokenRE.test(token);
21368    }
21369    function isProtectedWeekYearToken(token) {
21370      return weekYearTokenRE.test(token);
21371    }
21372    function warnOrThrowProtectedError(token, format6, input) {
21373      const _message = message(token, format6, input);
21374      console.warn(_message);
21375      if (throwTokens.includes(token)) throw new RangeError(_message);
21376    }
21377    function message(token, format6, input) {
21378      const subject = token[0] === "Y" ? "years" : "days of the month";
21379      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`;
21380    }
21381  
21382    // node_modules/date-fns/format.js
21383    var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
21384    var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
21385    var escapedStringRegExp = /^'([^]*?)'?$/;
21386    var doubleQuoteRegExp = /''/g;
21387    var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
21388    function format(date, formatStr, options) {
21389      const defaultOptions2 = getDefaultOptions();
21390      const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
21391      const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
21392      const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
21393      const originalDate = toDate(date, options?.in);
21394      if (!isValid(originalDate)) {
21395        throw new RangeError("Invalid time value");
21396      }
21397      let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
21398        const firstCharacter = substring[0];
21399        if (firstCharacter === "p" || firstCharacter === "P") {
21400          const longFormatter = longFormatters[firstCharacter];
21401          return longFormatter(substring, locale.formatLong);
21402        }
21403        return substring;
21404      }).join("").match(formattingTokensRegExp).map((substring) => {
21405        if (substring === "''") {
21406          return { isToken: false, value: "'" };
21407        }
21408        const firstCharacter = substring[0];
21409        if (firstCharacter === "'") {
21410          return { isToken: false, value: cleanEscapedString(substring) };
21411        }
21412        if (formatters[firstCharacter]) {
21413          return { isToken: true, value: substring };
21414        }
21415        if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
21416          throw new RangeError(
21417            "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
21418          );
21419        }
21420        return { isToken: false, value: substring };
21421      });
21422      if (locale.localize.preprocessor) {
21423        parts = locale.localize.preprocessor(originalDate, parts);
21424      }
21425      const formatterOptions = {
21426        firstWeekContainsDate,
21427        weekStartsOn,
21428        locale
21429      };
21430      return parts.map((part) => {
21431        if (!part.isToken) return part.value;
21432        const token = part.value;
21433        if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
21434          warnOrThrowProtectedError(token, formatStr, String(date));
21435        }
21436        const formatter = formatters[token[0]];
21437        return formatter(originalDate, token, locale.localize, formatterOptions);
21438      }).join("");
21439    }
21440    function cleanEscapedString(input) {
21441      const matched = input.match(escapedStringRegExp);
21442      if (!matched) {
21443        return input;
21444      }
21445      return matched[1].replace(doubleQuoteRegExp, "'");
21446    }
21447  
21448    // node_modules/date-fns/subDays.js
21449    function subDays(date, amount, options) {
21450      return addDays(date, -amount, options);
21451    }
21452  
21453    // node_modules/date-fns/subMonths.js
21454    function subMonths(date, amount, options) {
21455      return addMonths(date, -amount, options);
21456    }
21457  
21458    // node_modules/date-fns/subWeeks.js
21459    function subWeeks(date, amount, options) {
21460      return addWeeks(date, -amount, options);
21461    }
21462  
21463    // node_modules/date-fns/subYears.js
21464    function subYears(date, amount, options) {
21465      return addYears(date, -amount, options);
21466    }
21467  
21468    // packages/dataviews/build-module/utils/operators.mjs
21469    var import_i18n31 = __toESM(require_i18n(), 1);
21470    var import_element46 = __toESM(require_element(), 1);
21471    var import_date = __toESM(require_date(), 1);
21472    var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21473    var filterTextWrappers = {
21474      Name: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
21475      Value: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
21476    };
21477    function getRelativeDate(value, unit) {
21478      switch (unit) {
21479        case "days":
21480          return subDays(/* @__PURE__ */ new Date(), value);
21481        case "weeks":
21482          return subWeeks(/* @__PURE__ */ new Date(), value);
21483        case "months":
21484          return subMonths(/* @__PURE__ */ new Date(), value);
21485        case "years":
21486          return subYears(/* @__PURE__ */ new Date(), value);
21487        default:
21488          return /* @__PURE__ */ new Date();
21489      }
21490    }
21491    var isNoneOperatorDefinition = {
21492      /* translators: DataViews operator name */
21493      label: (0, import_i18n31.__)("Is none of"),
21494      filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21495        (0, import_i18n31.sprintf)(
21496          /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
21497          (0, import_i18n31.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
21498          filter.name,
21499          activeElements.map((element) => element.label).join(", ")
21500        ),
21501        filterTextWrappers
21502      ),
21503      filter: ((item, field, filterValue) => {
21504        if (!filterValue?.length) {
21505          return true;
21506        }
21507        const fieldValue = field.getValue({ item });
21508        if (Array.isArray(fieldValue)) {
21509          return !filterValue.some(
21510            (fv) => fieldValue.includes(fv)
21511          );
21512        } else if (typeof fieldValue === "string") {
21513          return !filterValue.includes(fieldValue);
21514        }
21515        return false;
21516      }),
21517      selection: "multi"
21518    };
21519    var OPERATORS = [
21520      {
21521        name: OPERATOR_IS_ANY,
21522        /* translators: DataViews operator name */
21523        label: (0, import_i18n31.__)("Includes"),
21524        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21525          (0, import_i18n31.sprintf)(
21526            /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
21527            (0, import_i18n31.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
21528            filter.name,
21529            activeElements.map((element) => element.label).join(", ")
21530          ),
21531          filterTextWrappers
21532        ),
21533        filter(item, field, filterValue) {
21534          if (!filterValue?.length) {
21535            return true;
21536          }
21537          const fieldValue = field.getValue({ item });
21538          if (Array.isArray(fieldValue)) {
21539            return filterValue.some(
21540              (fv) => fieldValue.includes(fv)
21541            );
21542          } else if (typeof fieldValue === "string") {
21543            return filterValue.includes(fieldValue);
21544          }
21545          return false;
21546        },
21547        selection: "multi"
21548      },
21549      {
21550        name: OPERATOR_IS_NONE,
21551        ...isNoneOperatorDefinition
21552      },
21553      {
21554        name: OPERATOR_IS_ALL,
21555        /* translators: DataViews operator name */
21556        label: (0, import_i18n31.__)("Includes all"),
21557        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21558          (0, import_i18n31.sprintf)(
21559            /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
21560            (0, import_i18n31.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
21561            filter.name,
21562            activeElements.map((element) => element.label).join(", ")
21563          ),
21564          filterTextWrappers
21565        ),
21566        filter(item, field, filterValue) {
21567          if (!filterValue?.length) {
21568            return true;
21569          }
21570          return filterValue.every((value) => {
21571            return field.getValue({ item })?.includes(value);
21572          });
21573        },
21574        selection: "multi"
21575      },
21576      {
21577        name: OPERATOR_IS_NOT_ALL,
21578        ...isNoneOperatorDefinition
21579      },
21580      {
21581        name: OPERATOR_BETWEEN,
21582        /* translators: DataViews operator name */
21583        label: (0, import_i18n31.__)("Between (inc)"),
21584        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21585          (0, import_i18n31.sprintf)(
21586            /* 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". */
21587            (0, import_i18n31.__)(
21588              "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
21589            ),
21590            filter.name,
21591            activeElements[0].label[0],
21592            activeElements[0].label[1]
21593          ),
21594          filterTextWrappers
21595        ),
21596        filter(item, field, filterValue) {
21597          if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21598            return true;
21599          }
21600          const fieldValue = field.getValue({ item });
21601          if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21602            return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21603          }
21604          return false;
21605        },
21606        selection: "custom"
21607      },
21608      {
21609        name: OPERATOR_IN_THE_PAST,
21610        /* translators: DataViews operator name */
21611        label: (0, import_i18n31.__)("In the past"),
21612        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21613          (0, import_i18n31.sprintf)(
21614            /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21615            (0, import_i18n31.__)(
21616              "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21617            ),
21618            filter.name,
21619            `$activeElements[0].value.value} $activeElements[0].value.unit}`
21620          ),
21621          filterTextWrappers
21622        ),
21623        filter(item, field, filterValue) {
21624          if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21625            return true;
21626          }
21627          const targetDate = getRelativeDate(
21628            filterValue.value,
21629            filterValue.unit
21630          );
21631          const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21632          return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21633        },
21634        selection: "custom"
21635      },
21636      {
21637        name: OPERATOR_OVER,
21638        /* translators: DataViews operator name */
21639        label: (0, import_i18n31.__)("Over"),
21640        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21641          (0, import_i18n31.sprintf)(
21642            /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21643            (0, import_i18n31.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21644            filter.name,
21645            `$activeElements[0].value.value} $activeElements[0].value.unit}`
21646          ),
21647          filterTextWrappers
21648        ),
21649        filter(item, field, filterValue) {
21650          if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21651            return true;
21652          }
21653          const targetDate = getRelativeDate(
21654            filterValue.value,
21655            filterValue.unit
21656          );
21657          const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21658          return fieldValue < targetDate;
21659        },
21660        selection: "custom"
21661      },
21662      {
21663        name: OPERATOR_IS,
21664        /* translators: DataViews operator name */
21665        label: (0, import_i18n31.__)("Is"),
21666        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21667          (0, import_i18n31.sprintf)(
21668            /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21669            (0, import_i18n31.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21670            filter.name,
21671            activeElements[0].label
21672          ),
21673          filterTextWrappers
21674        ),
21675        filter(item, field, filterValue) {
21676          return filterValue === field.getValue({ item }) || filterValue === void 0;
21677        },
21678        selection: "single"
21679      },
21680      {
21681        name: OPERATOR_IS_NOT,
21682        /* translators: DataViews operator name */
21683        label: (0, import_i18n31.__)("Is not"),
21684        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21685          (0, import_i18n31.sprintf)(
21686            /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21687            (0, import_i18n31.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21688            filter.name,
21689            activeElements[0].label
21690          ),
21691          filterTextWrappers
21692        ),
21693        filter(item, field, filterValue) {
21694          return filterValue !== field.getValue({ item });
21695        },
21696        selection: "single"
21697      },
21698      {
21699        name: OPERATOR_LESS_THAN,
21700        /* translators: DataViews operator name */
21701        label: (0, import_i18n31.__)("Less than"),
21702        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21703          (0, import_i18n31.sprintf)(
21704            /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21705            (0, import_i18n31.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21706            filter.name,
21707            activeElements[0].label
21708          ),
21709          filterTextWrappers
21710        ),
21711        filter(item, field, filterValue) {
21712          if (filterValue === void 0) {
21713            return true;
21714          }
21715          const fieldValue = field.getValue({ item });
21716          return fieldValue < filterValue;
21717        },
21718        selection: "single"
21719      },
21720      {
21721        name: OPERATOR_GREATER_THAN,
21722        /* translators: DataViews operator name */
21723        label: (0, import_i18n31.__)("Greater than"),
21724        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21725          (0, import_i18n31.sprintf)(
21726            /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21727            (0, import_i18n31.__)(
21728              "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21729            ),
21730            filter.name,
21731            activeElements[0].label
21732          ),
21733          filterTextWrappers
21734        ),
21735        filter(item, field, filterValue) {
21736          if (filterValue === void 0) {
21737            return true;
21738          }
21739          const fieldValue = field.getValue({ item });
21740          return fieldValue > filterValue;
21741        },
21742        selection: "single"
21743      },
21744      {
21745        name: OPERATOR_LESS_THAN_OR_EQUAL,
21746        /* translators: DataViews operator name */
21747        label: (0, import_i18n31.__)("Less than or equal"),
21748        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21749          (0, import_i18n31.sprintf)(
21750            /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21751            (0, import_i18n31.__)(
21752              "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21753            ),
21754            filter.name,
21755            activeElements[0].label
21756          ),
21757          filterTextWrappers
21758        ),
21759        filter(item, field, filterValue) {
21760          if (filterValue === void 0) {
21761            return true;
21762          }
21763          const fieldValue = field.getValue({ item });
21764          return fieldValue <= filterValue;
21765        },
21766        selection: "single"
21767      },
21768      {
21769        name: OPERATOR_GREATER_THAN_OR_EQUAL,
21770        /* translators: DataViews operator name */
21771        label: (0, import_i18n31.__)("Greater than or equal"),
21772        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21773          (0, import_i18n31.sprintf)(
21774            /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21775            (0, import_i18n31.__)(
21776              "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21777            ),
21778            filter.name,
21779            activeElements[0].label
21780          ),
21781          filterTextWrappers
21782        ),
21783        filter(item, field, filterValue) {
21784          if (filterValue === void 0) {
21785            return true;
21786          }
21787          const fieldValue = field.getValue({ item });
21788          return fieldValue >= filterValue;
21789        },
21790        selection: "single"
21791      },
21792      {
21793        name: OPERATOR_BEFORE,
21794        /* translators: DataViews operator name */
21795        label: (0, import_i18n31.__)("Before"),
21796        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21797          (0, import_i18n31.sprintf)(
21798            /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21799            (0, import_i18n31.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21800            filter.name,
21801            activeElements[0].label
21802          ),
21803          filterTextWrappers
21804        ),
21805        filter(item, field, filterValue) {
21806          if (filterValue === void 0) {
21807            return true;
21808          }
21809          const filterDate = (0, import_date.getDate)(filterValue);
21810          const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21811          return fieldDate < filterDate;
21812        },
21813        selection: "single"
21814      },
21815      {
21816        name: OPERATOR_AFTER,
21817        /* translators: DataViews operator name */
21818        label: (0, import_i18n31.__)("After"),
21819        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21820          (0, import_i18n31.sprintf)(
21821            /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21822            (0, import_i18n31.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21823            filter.name,
21824            activeElements[0].label
21825          ),
21826          filterTextWrappers
21827        ),
21828        filter(item, field, filterValue) {
21829          if (filterValue === void 0) {
21830            return true;
21831          }
21832          const filterDate = (0, import_date.getDate)(filterValue);
21833          const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21834          return fieldDate > filterDate;
21835        },
21836        selection: "single"
21837      },
21838      {
21839        name: OPERATOR_BEFORE_INC,
21840        /* translators: DataViews operator name */
21841        label: (0, import_i18n31.__)("Before (inc)"),
21842        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21843          (0, import_i18n31.sprintf)(
21844            /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21845            (0, import_i18n31.__)(
21846              "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21847            ),
21848            filter.name,
21849            activeElements[0].label
21850          ),
21851          filterTextWrappers
21852        ),
21853        filter(item, field, filterValue) {
21854          if (filterValue === void 0) {
21855            return true;
21856          }
21857          const filterDate = (0, import_date.getDate)(filterValue);
21858          const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21859          return fieldDate <= filterDate;
21860        },
21861        selection: "single"
21862      },
21863      {
21864        name: OPERATOR_AFTER_INC,
21865        /* translators: DataViews operator name */
21866        label: (0, import_i18n31.__)("After (inc)"),
21867        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21868          (0, import_i18n31.sprintf)(
21869            /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21870            (0, import_i18n31.__)(
21871              "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21872            ),
21873            filter.name,
21874            activeElements[0].label
21875          ),
21876          filterTextWrappers
21877        ),
21878        filter(item, field, filterValue) {
21879          if (filterValue === void 0) {
21880            return true;
21881          }
21882          const filterDate = (0, import_date.getDate)(filterValue);
21883          const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21884          return fieldDate >= filterDate;
21885        },
21886        selection: "single"
21887      },
21888      {
21889        name: OPERATOR_CONTAINS,
21890        /* translators: DataViews operator name */
21891        label: (0, import_i18n31.__)("Contains"),
21892        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21893          (0, import_i18n31.sprintf)(
21894            /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21895            (0, import_i18n31.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21896            filter.name,
21897            activeElements[0].label
21898          ),
21899          filterTextWrappers
21900        ),
21901        filter(item, field, filterValue) {
21902          if (filterValue === void 0) {
21903            return true;
21904          }
21905          const fieldValue = field.getValue({ item });
21906          return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21907        },
21908        selection: "single"
21909      },
21910      {
21911        name: OPERATOR_NOT_CONTAINS,
21912        /* translators: DataViews operator name */
21913        label: (0, import_i18n31.__)("Doesn't contain"),
21914        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21915          (0, import_i18n31.sprintf)(
21916            /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21917            (0, import_i18n31.__)(
21918              "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21919            ),
21920            filter.name,
21921            activeElements[0].label
21922          ),
21923          filterTextWrappers
21924        ),
21925        filter(item, field, filterValue) {
21926          if (filterValue === void 0) {
21927            return true;
21928          }
21929          const fieldValue = field.getValue({ item });
21930          return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21931        },
21932        selection: "single"
21933      },
21934      {
21935        name: OPERATOR_STARTS_WITH,
21936        /* translators: DataViews operator name */
21937        label: (0, import_i18n31.__)("Starts with"),
21938        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21939          (0, import_i18n31.sprintf)(
21940            /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21941            (0, import_i18n31.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21942            filter.name,
21943            activeElements[0].label
21944          ),
21945          filterTextWrappers
21946        ),
21947        filter(item, field, filterValue) {
21948          if (filterValue === void 0) {
21949            return true;
21950          }
21951          const fieldValue = field.getValue({ item });
21952          return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21953        },
21954        selection: "single"
21955      },
21956      {
21957        name: OPERATOR_ON,
21958        /* translators: DataViews operator name */
21959        label: (0, import_i18n31.__)("On"),
21960        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21961          (0, import_i18n31.sprintf)(
21962            /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21963            (0, import_i18n31.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21964            filter.name,
21965            activeElements[0].label
21966          ),
21967          filterTextWrappers
21968        ),
21969        filter(item, field, filterValue) {
21970          if (filterValue === void 0) {
21971            return true;
21972          }
21973          const filterDate = (0, import_date.getDate)(filterValue);
21974          const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21975          return filterDate.getTime() === fieldDate.getTime();
21976        },
21977        selection: "single"
21978      },
21979      {
21980        name: OPERATOR_NOT_ON,
21981        /* translators: DataViews operator name */
21982        label: (0, import_i18n31.__)("Not on"),
21983        filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21984          (0, import_i18n31.sprintf)(
21985            /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21986            (0, import_i18n31.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21987            filter.name,
21988            activeElements[0].label
21989          ),
21990          filterTextWrappers
21991        ),
21992        filter(item, field, filterValue) {
21993          if (filterValue === void 0) {
21994            return true;
21995          }
21996          const filterDate = (0, import_date.getDate)(filterValue);
21997          const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21998          return filterDate.getTime() !== fieldDate.getTime();
21999        },
22000        selection: "single"
22001      }
22002    ];
22003    var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
22004    var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
22005    var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
22006      (op) => op.name === name
22007    );
22008    var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
22009  
22010    // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
22011    var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
22012    var ENTER = "Enter";
22013    var SPACE = " ";
22014    var FilterText = ({
22015      activeElements,
22016      filterInView,
22017      filter
22018    }) => {
22019      if (activeElements === void 0 || activeElements.length === 0) {
22020        return filter.name;
22021      }
22022      const operator = getOperatorByName(filterInView?.operator);
22023      if (operator !== void 0) {
22024        return operator.filterText(filter, activeElements);
22025      }
22026      return (0, import_i18n32.sprintf)(
22027        /* translators: 1: Filter name e.g.: "Unknown status for Author". */
22028        (0, import_i18n32.__)("Unknown status for %1$s"),
22029        filter.name
22030      );
22031    };
22032    function OperatorSelector({
22033      filter,
22034      view,
22035      onChangeView
22036    }) {
22037      const operatorOptions = filter.operators?.map((operator) => ({
22038        value: operator,
22039        label: getOperatorByName(operator)?.label || operator
22040      }));
22041      const currentFilter = view.filters?.find(
22042        (_filter) => _filter.field === filter.field
22043      );
22044      const value = currentFilter?.operator || filter.operators[0];
22045      return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
22046        Stack,
22047        {
22048          direction: "row",
22049          gap: "sm",
22050          justify: "flex-start",
22051          className: "dataviews-filters__summary-operators-container",
22052          align: "center",
22053          children: [
22054            /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
22055            /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22056              import_components21.SelectControl,
22057              {
22058                className: "dataviews-filters__summary-operators-filter-select",
22059                label: (0, import_i18n32.__)("Conditions"),
22060                value,
22061                options: operatorOptions,
22062                onChange: (newValue) => {
22063                  const newOperator = newValue;
22064                  const currentOperator = currentFilter?.operator;
22065                  const newFilters = currentFilter ? [
22066                    ...(view.filters ?? []).map(
22067                      (_filter) => {
22068                        if (_filter.field === filter.field) {
22069                          const currentOpSelectionModel = getOperatorByName(
22070                            currentOperator
22071                          )?.selection;
22072                          const newOpSelectionModel = getOperatorByName(
22073                            newOperator
22074                          )?.selection;
22075                          const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
22076                            currentOpSelectionModel,
22077                            newOpSelectionModel
22078                          ].includes("custom");
22079                          return {
22080                            ..._filter,
22081                            value: shouldResetValue ? void 0 : _filter.value,
22082                            operator: newOperator
22083                          };
22084                        }
22085                        return _filter;
22086                      }
22087                    )
22088                  ] : [
22089                    ...view.filters ?? [],
22090                    {
22091                      field: filter.field,
22092                      operator: newOperator,
22093                      value: void 0
22094                    }
22095                  ];
22096                  onChangeView({
22097                    ...view,
22098                    page: 1,
22099                    filters: newFilters
22100                  });
22101                },
22102                size: "small",
22103                variant: "minimal",
22104                hideLabelFromVision: true
22105              }
22106            )
22107          ]
22108        }
22109      );
22110    }
22111    function Filter({
22112      addFilterRef,
22113      openedFilter,
22114      fields,
22115      ...commonProps
22116    }) {
22117      const toggleRef = (0, import_element47.useRef)(null);
22118      const { filter, view, onChangeView } = commonProps;
22119      const filterInView = view.filters?.find(
22120        (f2) => f2.field === filter.field
22121      );
22122      let activeElements = [];
22123      const field = (0, import_element47.useMemo)(() => {
22124        const currentField = fields.find((f2) => f2.id === filter.field);
22125        if (currentField) {
22126          return {
22127            ...currentField,
22128            // Configure getValue as if Item was a plain object.
22129            // See related input-widget.tsx
22130            getValue: ({ item }) => item[currentField.id]
22131          };
22132        }
22133        return currentField;
22134      }, [fields, filter.field]);
22135      const { elements } = useElements({
22136        elements: filter.elements,
22137        getElements: filter.getElements
22138      });
22139      if (elements.length > 0) {
22140        activeElements = elements.filter((element) => {
22141          if (filter.singleSelection) {
22142            return element.value === filterInView?.value;
22143          }
22144          return filterInView?.value?.includes(element.value);
22145        });
22146      } else if (Array.isArray(filterInView?.value)) {
22147        const label = filterInView.value.map((v2) => {
22148          const formattedValue = field?.getValueFormatted({
22149            item: { [field.id]: v2 },
22150            field
22151          });
22152          return formattedValue || String(v2);
22153        });
22154        activeElements = [
22155          {
22156            value: filterInView.value,
22157            // @ts-ignore
22158            label
22159          }
22160        ];
22161      } else if (typeof filterInView?.value === "object") {
22162        activeElements = [
22163          { value: filterInView.value, label: filterInView.value }
22164        ];
22165      } else if (filterInView?.value !== void 0) {
22166        const label = field !== void 0 ? field.getValueFormatted({
22167          item: { [field.id]: filterInView.value },
22168          field
22169        }) : String(filterInView.value);
22170        activeElements = [
22171          {
22172            value: filterInView.value,
22173            label
22174          }
22175        ];
22176      }
22177      const isPrimary = filter.isPrimary;
22178      const isLocked = filterInView?.isLocked;
22179      const hasValues = !isLocked && filterInView?.value !== void 0;
22180      const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
22181      const resetOrRemoveLabel = isPrimary ? (0, import_i18n32.__)("Reset") : (0, import_i18n32.__)("Remove");
22182      return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22183        import_components21.Dropdown,
22184        {
22185          defaultOpen: openedFilter === filter.field,
22186          contentClassName: "dataviews-filters__summary-popover",
22187          popoverProps: { placement: "bottom-start", role: "dialog" },
22188          onClose: () => {
22189            toggleRef.current?.focus();
22190          },
22191          renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
22192            /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
22193              /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22194                tooltip_exports.Trigger,
22195                {
22196                  render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22197                    "div",
22198                    {
22199                      className: clsx_default(
22200                        "dataviews-filters__summary-chip",
22201                        {
22202                          "has-reset": canResetOrRemove,
22203                          "has-values": hasValues,
22204                          "is-not-clickable": isLocked
22205                        }
22206                      ),
22207                      role: "button",
22208                      tabIndex: isLocked ? -1 : 0,
22209                      onClick: () => {
22210                        if (!isLocked) {
22211                          onToggle();
22212                        }
22213                      },
22214                      onKeyDown: (event) => {
22215                        if (!isLocked && [ENTER, SPACE].includes(
22216                          event.key
22217                        )) {
22218                          onToggle();
22219                          event.preventDefault();
22220                        }
22221                      },
22222                      "aria-disabled": isLocked,
22223                      "aria-pressed": isOpen,
22224                      "aria-expanded": isOpen,
22225                      ref: toggleRef,
22226                      children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22227                        FilterText,
22228                        {
22229                          activeElements,
22230                          filterInView,
22231                          filter
22232                        }
22233                      )
22234                    }
22235                  )
22236                }
22237              ),
22238              /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: (0, import_i18n32.sprintf)(
22239                /* translators: 1: Filter name. */
22240                (0, import_i18n32.__)("Filter by: %1$s"),
22241                filter.name.toLowerCase()
22242              ) })
22243            ] }),
22244            canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
22245              /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22246                tooltip_exports.Trigger,
22247                {
22248                  render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22249                    "button",
22250                    {
22251                      className: clsx_default(
22252                        "dataviews-filters__summary-chip-remove",
22253                        { "has-values": hasValues }
22254                      ),
22255                      "aria-label": resetOrRemoveLabel,
22256                      onClick: () => {
22257                        onChangeView({
22258                          ...view,
22259                          page: 1,
22260                          filters: view.filters?.filter(
22261                            (_filter) => _filter.field !== filter.field
22262                          )
22263                        });
22264                        if (!isPrimary) {
22265                          addFilterRef.current?.focus();
22266                        } else {
22267                          toggleRef.current?.focus();
22268                        }
22269                      },
22270                      children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.Icon, { icon: close_small_default })
22271                    }
22272                  )
22273                }
22274              ),
22275              /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
22276            ] })
22277          ] }),
22278          renderContent: () => {
22279            return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
22280              /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(OperatorSelector, { ...commonProps }),
22281              commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22282                SearchWidget,
22283                {
22284                  ...commonProps,
22285                  filter: {
22286                    ...commonProps.filter,
22287                    elements
22288                  }
22289                }
22290              ) : /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(InputWidget, { ...commonProps, fields })
22291            ] });
22292          }
22293        }
22294      );
22295    }
22296  
22297    // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
22298    var import_components22 = __toESM(require_components(), 1);
22299    var import_i18n33 = __toESM(require_i18n(), 1);
22300    var import_element48 = __toESM(require_element(), 1);
22301    var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22302    var { Menu: Menu4 } = unlock2(import_components22.privateApis);
22303    function AddFilterMenu({
22304      filters,
22305      view,
22306      onChangeView,
22307      setOpenedFilter,
22308      triggerProps
22309    }) {
22310      const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22311      return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Menu4, { children: [
22312        /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.TriggerButton, { ...triggerProps }),
22313        /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
22314          return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22315            Menu4.Item,
22316            {
22317              onClick: () => {
22318                setOpenedFilter(filter.field);
22319                onChangeView({
22320                  ...view,
22321                  page: 1,
22322                  filters: [
22323                    ...view.filters || [],
22324                    {
22325                      field: filter.field,
22326                      value: void 0,
22327                      operator: filter.operators[0]
22328                    }
22329                  ]
22330                });
22331              },
22332              children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.ItemLabel, { children: filter.name })
22333            },
22334            filter.field
22335          );
22336        }) })
22337      ] });
22338    }
22339    function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
22340      if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
22341        return null;
22342      }
22343      const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22344      return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22345        AddFilterMenu,
22346        {
22347          triggerProps: {
22348            render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22349              import_components22.Button,
22350              {
22351                accessibleWhenDisabled: true,
22352                size: "compact",
22353                className: "dataviews-filters-button",
22354                variant: "tertiary",
22355                disabled: !inactiveFilters.length,
22356                ref
22357              }
22358            ),
22359            children: (0, import_i18n33.__)("Add filter")
22360          },
22361          ...{ filters, view, onChangeView, setOpenedFilter }
22362        }
22363      );
22364    }
22365    var add_filter_default = (0, import_element48.forwardRef)(AddFilter);
22366  
22367    // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
22368    var import_components23 = __toESM(require_components(), 1);
22369    var import_i18n34 = __toESM(require_i18n(), 1);
22370    var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22371    function ResetFilter({
22372      filters,
22373      view,
22374      onChangeView
22375    }) {
22376      const isPrimary = (field) => filters.some(
22377        (_filter) => _filter.field === field && _filter.isPrimary
22378      );
22379      const isDisabled = !view.search && !view.filters?.some(
22380        (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
22381      );
22382      return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22383        import_components23.Button,
22384        {
22385          disabled: isDisabled,
22386          accessibleWhenDisabled: true,
22387          size: "compact",
22388          variant: "tertiary",
22389          className: "dataviews-filters__reset-button",
22390          onClick: () => {
22391            onChangeView({
22392              ...view,
22393              page: 1,
22394              search: "",
22395              filters: view.filters?.filter((f2) => !!f2.isLocked) || []
22396            });
22397          },
22398          children: (0, import_i18n34.__)("Reset")
22399        }
22400      );
22401    }
22402  
22403    // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
22404    var import_element49 = __toESM(require_element(), 1);
22405    function useFilters(fields, view) {
22406      return (0, import_element49.useMemo)(() => {
22407        const filters = [];
22408        fields.forEach((field) => {
22409          if (field.filterBy === false || !field.hasElements && !field.Edit) {
22410            return;
22411          }
22412          const operators = field.filterBy.operators;
22413          const isPrimary = !!field.filterBy?.isPrimary;
22414          const isLocked = view.filters?.some(
22415            (f2) => f2.field === field.id && !!f2.isLocked
22416          ) ?? false;
22417          filters.push({
22418            field: field.id,
22419            name: field.label,
22420            elements: field.elements,
22421            getElements: field.getElements,
22422            hasElements: field.hasElements,
22423            singleSelection: operators.some(
22424              (op) => isSingleSelectionOperator(op)
22425            ),
22426            operators,
22427            isVisible: isLocked || isPrimary || !!view.filters?.some(
22428              (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
22429            ),
22430            isPrimary,
22431            isLocked
22432          });
22433        });
22434        filters.sort((a2, b2) => {
22435          if (a2.isLocked && !b2.isLocked) {
22436            return -1;
22437          }
22438          if (!a2.isLocked && b2.isLocked) {
22439            return 1;
22440          }
22441          if (a2.isPrimary && !b2.isPrimary) {
22442            return -1;
22443          }
22444          if (!a2.isPrimary && b2.isPrimary) {
22445            return 1;
22446          }
22447          return a2.name.localeCompare(b2.name);
22448        });
22449        return filters;
22450      }, [fields, view]);
22451    }
22452    var use_filters_default = useFilters;
22453  
22454    // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
22455    var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22456    function Filters({ className }) {
22457      const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element50.useContext)(dataviews_context_default);
22458      const addFilterRef = (0, import_element50.useRef)(null);
22459      const filters = use_filters_default(fields, view);
22460      const addFilter = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22461        add_filter_default,
22462        {
22463          filters,
22464          view,
22465          onChangeView,
22466          ref: addFilterRef,
22467          setOpenedFilter
22468        },
22469        "add-filter"
22470      );
22471      const visibleFilters = filters.filter((filter) => filter.isVisible);
22472      if (visibleFilters.length === 0) {
22473        return null;
22474      }
22475      const filterComponents = [
22476        ...visibleFilters.map((filter) => {
22477          return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22478            Filter,
22479            {
22480              filter,
22481              view,
22482              fields,
22483              onChangeView,
22484              addFilterRef,
22485              openedFilter
22486            },
22487            filter.field
22488          );
22489        }),
22490        addFilter
22491      ];
22492      filterComponents.push(
22493        /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22494          ResetFilter,
22495          {
22496            filters,
22497            view,
22498            onChangeView
22499          },
22500          "reset-filters"
22501        )
22502      );
22503      return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22504        Stack,
22505        {
22506          direction: "row",
22507          justify: "flex-start",
22508          gap: "sm",
22509          style: { width: "fit-content" },
22510          wrap: "wrap",
22511          className,
22512          children: filterComponents
22513        }
22514      );
22515    }
22516    var filters_default = (0, import_element50.memo)(Filters);
22517  
22518    // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
22519    var import_element51 = __toESM(require_element(), 1);
22520    var import_components24 = __toESM(require_components(), 1);
22521    var import_i18n35 = __toESM(require_i18n(), 1);
22522    var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22523    function FiltersToggle() {
22524      const {
22525        filters,
22526        view,
22527        onChangeView,
22528        setOpenedFilter,
22529        isShowingFilter,
22530        setIsShowingFilter
22531      } = (0, import_element51.useContext)(dataviews_context_default);
22532      const buttonRef = (0, import_element51.useRef)(null);
22533      const onChangeViewWithFilterVisibility = (0, import_element51.useCallback)(
22534        (_view) => {
22535          onChangeView(_view);
22536          setIsShowingFilter(true);
22537        },
22538        [onChangeView, setIsShowingFilter]
22539      );
22540      if (filters.length === 0) {
22541        return null;
22542      }
22543      const hasVisibleFilters = filters.some((filter) => filter.isVisible);
22544      const addFilterButtonProps = {
22545        label: (0, import_i18n35.__)("Add filter"),
22546        "aria-expanded": false,
22547        isPressed: false
22548      };
22549      const toggleFiltersButtonProps = {
22550        label: (0, import_i18n35._x)("Filter", "verb"),
22551        "aria-expanded": isShowingFilter,
22552        isPressed: isShowingFilter,
22553        onClick: () => {
22554          if (!isShowingFilter) {
22555            setOpenedFilter(null);
22556          }
22557          setIsShowingFilter(!isShowingFilter);
22558        }
22559      };
22560      const hasPrimaryOrLockedFilters = filters.some(
22561        (filter) => filter.isPrimary || filter.isLocked
22562      );
22563      const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22564        import_components24.Button,
22565        {
22566          ref: buttonRef,
22567          className: "dataviews-filters__visibility-toggle",
22568          size: "compact",
22569          icon: funnel_default,
22570          disabled: hasPrimaryOrLockedFilters,
22571          accessibleWhenDisabled: true,
22572          ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
22573        }
22574      );
22575      return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22576        AddFilterMenu,
22577        {
22578          filters,
22579          view,
22580          onChangeView: onChangeViewWithFilterVisibility,
22581          setOpenedFilter,
22582          triggerProps: { render: buttonComponent }
22583        }
22584      ) : /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22585        FilterVisibilityToggle,
22586        {
22587          buttonRef,
22588          filtersCount: view.filters?.length,
22589          children: buttonComponent
22590        }
22591      ) });
22592    }
22593    function FilterVisibilityToggle({
22594      buttonRef,
22595      filtersCount,
22596      children
22597    }) {
22598      (0, import_element51.useEffect)(
22599        () => () => {
22600          buttonRef.current?.focus();
22601        },
22602        [buttonRef]
22603      );
22604      return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_jsx_runtime87.Fragment, { children: [
22605        children,
22606        !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22607      ] });
22608    }
22609    var toggle_default = FiltersToggle;
22610  
22611    // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22612    var import_element52 = __toESM(require_element(), 1);
22613    var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22614    function FiltersToggled(props) {
22615      const { isShowingFilter } = (0, import_element52.useContext)(dataviews_context_default);
22616      if (!isShowingFilter) {
22617        return null;
22618      }
22619      return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(filters_default, { ...props });
22620    }
22621    var filters_toggled_default = FiltersToggled;
22622  
22623    // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22624    var import_element53 = __toESM(require_element(), 1);
22625    var import_components25 = __toESM(require_components(), 1);
22626    var import_i18n36 = __toESM(require_i18n(), 1);
22627    var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22628    function DataViewsLayout({ className }) {
22629      const {
22630        actions = [],
22631        data,
22632        fields,
22633        getItemId,
22634        getItemLevel,
22635        hasInitiallyLoaded,
22636        isLoading,
22637        view,
22638        onChangeView,
22639        selection,
22640        onChangeSelection,
22641        setOpenedFilter,
22642        onClickItem,
22643        isItemClickable: isItemClickable2,
22644        renderItemLink,
22645        defaultLayouts: defaultLayouts2,
22646        containerRef,
22647        empty = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: (0, import_i18n36.__)("No results") })
22648      } = (0, import_element53.useContext)(dataviews_context_default);
22649      const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22650        delay: 200
22651      });
22652      if (!hasInitiallyLoaded) {
22653        if (!isDelayedInitialLoading) {
22654          return null;
22655        }
22656        return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components25.Spinner, {}) }) });
22657      }
22658      const ViewComponent = VIEW_LAYOUTS.find(
22659        (v2) => v2.type === view.type && defaultLayouts2[v2.type]
22660      )?.component;
22661      return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22662        ViewComponent,
22663        {
22664          className,
22665          actions,
22666          data,
22667          fields,
22668          getItemId,
22669          getItemLevel,
22670          isLoading,
22671          onChangeView,
22672          onChangeSelection,
22673          selection,
22674          setOpenedFilter,
22675          onClickItem,
22676          renderItemLink,
22677          isItemClickable: isItemClickable2,
22678          view,
22679          empty
22680        }
22681      ) });
22682    }
22683  
22684    // packages/dataviews/build-module/components/dataviews-search/index.mjs
22685    var import_i18n37 = __toESM(require_i18n(), 1);
22686    var import_element54 = __toESM(require_element(), 1);
22687    var import_components26 = __toESM(require_components(), 1);
22688    var import_compose10 = __toESM(require_compose(), 1);
22689    var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22690    var DataViewsSearch = (0, import_element54.memo)(function Search({ label }) {
22691      const { view, onChangeView } = (0, import_element54.useContext)(dataviews_context_default);
22692      const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22693        view.search
22694      );
22695      (0, import_element54.useEffect)(() => {
22696        if (view.search !== debouncedSearch) {
22697          setSearch(view.search ?? "");
22698        }
22699      }, [view.search, setSearch]);
22700      const onChangeViewRef = (0, import_element54.useRef)(onChangeView);
22701      const viewRef = (0, import_element54.useRef)(view);
22702      (0, import_element54.useEffect)(() => {
22703        onChangeViewRef.current = onChangeView;
22704        viewRef.current = view;
22705      }, [onChangeView, view]);
22706      (0, import_element54.useEffect)(() => {
22707        if (debouncedSearch !== viewRef.current?.search) {
22708          onChangeViewRef.current({
22709            ...viewRef.current,
22710            page: view.page ? 1 : void 0,
22711            startPosition: view.startPosition ? 1 : void 0,
22712            search: debouncedSearch
22713          });
22714        }
22715      }, [debouncedSearch]);
22716      const searchLabel = label || (0, import_i18n37.__)("Search");
22717      return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22718        import_components26.SearchControl,
22719        {
22720          className: "dataviews-search",
22721          onChange: setSearch,
22722          value: search,
22723          label: searchLabel,
22724          placeholder: searchLabel,
22725          size: "compact"
22726        }
22727      );
22728    });
22729    var dataviews_search_default = DataViewsSearch;
22730  
22731    // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22732    var import_components27 = __toESM(require_components(), 1);
22733    var import_i18n38 = __toESM(require_i18n(), 1);
22734    var import_element55 = __toESM(require_element(), 1);
22735    var import_warning = __toESM(require_warning(), 1);
22736    var import_compose11 = __toESM(require_compose(), 1);
22737    var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22738    var { Menu: Menu5 } = unlock2(import_components27.privateApis);
22739    var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22740      className: "dataviews-config__popover",
22741      placement: "bottom-end",
22742      offset: 9
22743    };
22744    function ViewTypeMenu() {
22745      const { view, onChangeView, defaultLayouts: defaultLayouts2 } = (0, import_element55.useContext)(dataviews_context_default);
22746      const availableLayouts = Object.keys(defaultLayouts2);
22747      if (availableLayouts.length <= 1) {
22748        return null;
22749      }
22750      const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22751      return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Menu5, { children: [
22752        /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22753          Menu5.TriggerButton,
22754          {
22755            render: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22756              import_components27.Button,
22757              {
22758                size: "compact",
22759                icon: activeView?.icon,
22760                label: (0, import_i18n38.__)("Layout")
22761              }
22762            )
22763          }
22764        ),
22765        /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22766          const config = VIEW_LAYOUTS.find(
22767            (v2) => v2.type === layout
22768          );
22769          if (!config) {
22770            return null;
22771          }
22772          return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22773            Menu5.RadioItem,
22774            {
22775              value: layout,
22776              name: "view-actions-available-view",
22777              checked: layout === view.type,
22778              hideOnClick: true,
22779              onChange: (e2) => {
22780                switch (e2.target.value) {
22781                  case "list":
22782                  case "grid":
22783                  case "table":
22784                  case "pickerGrid":
22785                  case "pickerTable":
22786                  case "pickerActivity":
22787                  case "activity":
22788                    const viewWithoutLayout = { ...view };
22789                    if ("layout" in viewWithoutLayout) {
22790                      delete viewWithoutLayout.layout;
22791                    }
22792                    return onChangeView({
22793                      ...viewWithoutLayout,
22794                      type: e2.target.value,
22795                      ...defaultLayouts2[e2.target.value]
22796                    });
22797                }
22798                (0, import_warning.default)("Invalid dataview");
22799              },
22800              children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.ItemLabel, { children: config.label })
22801            },
22802            layout
22803          );
22804        }) })
22805      ] });
22806    }
22807    function SortFieldControl() {
22808      const { view, fields, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22809      const orderOptions = (0, import_element55.useMemo)(() => {
22810        const sortableFields = fields.filter(
22811          (field) => field.enableSorting !== false
22812        );
22813        return sortableFields.map((field) => {
22814          return {
22815            label: field.label,
22816            value: field.id
22817          };
22818        });
22819      }, [fields]);
22820      return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22821        import_components27.SelectControl,
22822        {
22823          label: (0, import_i18n38.__)("Sort by"),
22824          value: view.sort?.field,
22825          options: orderOptions,
22826          onChange: (value) => {
22827            onChangeView({
22828              ...view,
22829              sort: {
22830                direction: view?.sort?.direction || "desc",
22831                field: value
22832              },
22833              showLevels: false
22834            });
22835          }
22836        }
22837      );
22838    }
22839    function SortDirectionControl() {
22840      const { view, fields, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22841      const sortableFields = fields.filter(
22842        (field) => field.enableSorting !== false
22843      );
22844      if (sortableFields.length === 0) {
22845        return null;
22846      }
22847      let value = view.sort?.direction;
22848      if (!value && view.sort?.field) {
22849        value = "desc";
22850      }
22851      return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22852        import_components27.__experimentalToggleGroupControl,
22853        {
22854          className: "dataviews-view-config__sort-direction",
22855          isBlock: true,
22856          label: (0, import_i18n38.__)("Order"),
22857          value,
22858          onChange: (newDirection) => {
22859            if (newDirection === "asc" || newDirection === "desc") {
22860              onChangeView({
22861                ...view,
22862                sort: {
22863                  direction: newDirection,
22864                  field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22865                  fields.find(
22866                    (field) => field.enableSorting !== false
22867                  )?.id || ""
22868                },
22869                showLevels: false
22870              });
22871              return;
22872            }
22873            (0, import_warning.default)("Invalid direction");
22874          },
22875          children: SORTING_DIRECTIONS.map((direction) => {
22876            return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22877              import_components27.__experimentalToggleGroupControlOptionIcon,
22878              {
22879                value: direction,
22880                icon: sortIcons[direction],
22881                label: sortLabels[direction]
22882              },
22883              direction
22884            );
22885          })
22886        }
22887      );
22888    }
22889    function ItemsPerPageControl() {
22890      const { view, config, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22891      const { infiniteScrollEnabled } = view;
22892      if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22893        return null;
22894      }
22895      return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22896        import_components27.__experimentalToggleGroupControl,
22897        {
22898          isBlock: true,
22899          label: (0, import_i18n38.__)("Items per page"),
22900          value: view.perPage || 10,
22901          disabled: !view?.sort?.field,
22902          onChange: (newItemsPerPage) => {
22903            const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22904            onChangeView({
22905              ...view,
22906              perPage: newItemsPerPageNumber,
22907              page: 1
22908            });
22909          },
22910          children: config.perPageSizes.map((value) => {
22911            return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22912              import_components27.__experimentalToggleGroupControlOption,
22913              {
22914                value,
22915                label: value.toString()
22916              },
22917              value
22918            );
22919          })
22920        }
22921      );
22922    }
22923    function ResetViewButton() {
22924      const { onReset } = (0, import_element55.useContext)(dataviews_context_default);
22925      if (onReset === void 0) {
22926        return null;
22927      }
22928      const isDisabled = onReset === false;
22929      return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22930        import_components27.Button,
22931        {
22932          variant: "tertiary",
22933          size: "compact",
22934          disabled: isDisabled,
22935          accessibleWhenDisabled: true,
22936          className: "dataviews-view-config__reset-button",
22937          onClick: () => {
22938            if (typeof onReset === "function") {
22939              onReset();
22940            }
22941          },
22942          children: (0, import_i18n38.__)("Reset view")
22943        }
22944      );
22945    }
22946    function DataviewsViewConfigDropdown() {
22947      const { view, onReset } = (0, import_element55.useContext)(dataviews_context_default);
22948      const popoverId = (0, import_compose11.useInstanceId)(
22949        _DataViewsViewConfig,
22950        "dataviews-view-config-dropdown"
22951      );
22952      const activeLayout = VIEW_LAYOUTS.find(
22953        (layout) => layout.type === view.type
22954      );
22955      const isModified = typeof onReset === "function";
22956      return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22957        import_components27.Dropdown,
22958        {
22959          expandOnMobile: true,
22960          popoverProps: {
22961            ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22962            id: popoverId
22963          },
22964          renderToggle: ({ onToggle, isOpen }) => {
22965            return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22966              /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22967                import_components27.Button,
22968                {
22969                  size: "compact",
22970                  icon: cog_default,
22971                  label: (0, import_i18n38._x)(
22972                    "View options",
22973                    "View is used as a noun"
22974                  ),
22975                  onClick: onToggle,
22976                  "aria-expanded": isOpen ? "true" : "false",
22977                  "aria-controls": popoverId
22978                }
22979              ),
22980              isModified && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22981            ] });
22982          },
22983          renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22984            import_components27.__experimentalDropdownContentWrapper,
22985            {
22986              paddingSize: "medium",
22987              className: "dataviews-config__popover-content-wrapper",
22988              children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22989                Stack,
22990                {
22991                  direction: "column",
22992                  className: "dataviews-view-config",
22993                  gap: "xl",
22994                  children: [
22995                    /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22996                      Stack,
22997                      {
22998                        direction: "row",
22999                        justify: "space-between",
23000                        align: "center",
23001                        className: "dataviews-view-config__header",
23002                        children: [
23003                          /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
23004                            import_components27.__experimentalHeading,
23005                            {
23006                              level: 2,
23007                              className: "dataviews-settings-section__title",
23008                              children: (0, import_i18n38.__)("Appearance")
23009                            }
23010                          ),
23011                          /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ResetViewButton, {})
23012                        ]
23013                      }
23014                    ),
23015                    /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23016                      /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
23017                        Stack,
23018                        {
23019                          direction: "row",
23020                          gap: "sm",
23021                          className: "dataviews-view-config__sort-controls",
23022                          children: [
23023                            /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortFieldControl, {}),
23024                            /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortDirectionControl, {})
23025                          ]
23026                        }
23027                      ),
23028                      !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(activeLayout.viewConfigOptions, {}),
23029                      /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ItemsPerPageControl, {}),
23030                      /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(PropertiesSection, {})
23031                    ] })
23032                  ]
23033                }
23034              )
23035            }
23036          )
23037        }
23038      );
23039    }
23040    function _DataViewsViewConfig() {
23041      return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [
23042        /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ViewTypeMenu, {}),
23043        /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DataviewsViewConfigDropdown, {})
23044      ] });
23045    }
23046    var DataViewsViewConfig = (0, import_element55.memo)(_DataViewsViewConfig);
23047    var dataviews_view_config_default = DataViewsViewConfig;
23048  
23049    // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
23050    var import_components28 = __toESM(require_components(), 1);
23051    var import_element56 = __toESM(require_element(), 1);
23052  
23053    // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
23054    function getCustomValidity(isValid2, validity) {
23055      let customValidity;
23056      if (isValid2?.required && validity?.required) {
23057        customValidity = validity?.required?.message ? validity.required : void 0;
23058      } else if (isValid2?.pattern && validity?.pattern) {
23059        customValidity = validity.pattern;
23060      } else if (isValid2?.min && validity?.min) {
23061        customValidity = validity.min;
23062      } else if (isValid2?.max && validity?.max) {
23063        customValidity = validity.max;
23064      } else if (isValid2?.minLength && validity?.minLength) {
23065        customValidity = validity.minLength;
23066      } else if (isValid2?.maxLength && validity?.maxLength) {
23067        customValidity = validity.maxLength;
23068      } else if (isValid2?.elements && validity?.elements) {
23069        customValidity = validity.elements;
23070      } else if (validity?.custom) {
23071        customValidity = validity.custom;
23072      }
23073      return customValidity;
23074    }
23075  
23076    // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
23077    var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
23078    var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
23079    function Checkbox({
23080      field,
23081      onChange,
23082      data,
23083      hideLabelFromVision,
23084      markWhenOptional,
23085      validity
23086    }) {
23087      const { getValue, setValue, label, description, isValid: isValid2 } = field;
23088      const disabled2 = field.isDisabled({ item: data, field });
23089      const onChangeControl = (0, import_element56.useCallback)(() => {
23090        onChange(
23091          setValue({ item: data, value: !getValue({ item: data }) })
23092        );
23093      }, [data, getValue, onChange, setValue]);
23094      return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23095        ValidatedCheckboxControl,
23096        {
23097          required: !!field.isValid?.required,
23098          markWhenOptional,
23099          customValidity: getCustomValidity(isValid2, validity),
23100          hidden: hideLabelFromVision,
23101          label,
23102          help: description,
23103          checked: getValue({ item: data }),
23104          onChange: onChangeControl,
23105          disabled: disabled2
23106        }
23107      );
23108    }
23109  
23110    // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
23111    var import_components29 = __toESM(require_components(), 1);
23112    var import_element57 = __toESM(require_element(), 1);
23113    var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23114    var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
23115    function Combobox3({
23116      data,
23117      field,
23118      onChange,
23119      hideLabelFromVision,
23120      validity
23121    }) {
23122      const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
23123      const value = getValue({ item: data }) ?? "";
23124      const onChangeControl = (0, import_element57.useCallback)(
23125        (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
23126        [data, onChange, setValue]
23127      );
23128      const { elements, isLoading } = useElements({
23129        elements: field.elements,
23130        getElements: field.getElements
23131      });
23132      if (isLoading) {
23133        return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components29.Spinner, {});
23134      }
23135      return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23136        ValidatedComboboxControl,
23137        {
23138          required: !!field.isValid?.required,
23139          customValidity: getCustomValidity(isValid2, validity),
23140          label,
23141          value,
23142          help: description,
23143          placeholder,
23144          options: elements,
23145          onChange: onChangeControl,
23146          hideLabelFromVision,
23147          allowReset: true,
23148          expandOnFocus: true
23149        }
23150      );
23151    }
23152  
23153    // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23154    var import_components31 = __toESM(require_components(), 1);
23155    var import_element60 = __toESM(require_element(), 1);
23156    var import_i18n40 = __toESM(require_i18n(), 1);
23157    var import_date3 = __toESM(require_date(), 1);
23158  
23159    // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
23160    var import_components30 = __toESM(require_components(), 1);
23161    var import_element58 = __toESM(require_element(), 1);
23162    var import_i18n39 = __toESM(require_i18n(), 1);
23163    var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23164    var TIME_UNITS_OPTIONS = {
23165      [OPERATOR_IN_THE_PAST]: [
23166        { value: "days", label: (0, import_i18n39.__)("Days") },
23167        { value: "weeks", label: (0, import_i18n39.__)("Weeks") },
23168        { value: "months", label: (0, import_i18n39.__)("Months") },
23169        { value: "years", label: (0, import_i18n39.__)("Years") }
23170      ],
23171      [OPERATOR_OVER]: [
23172        { value: "days", label: (0, import_i18n39.__)("Days ago") },
23173        { value: "weeks", label: (0, import_i18n39.__)("Weeks ago") },
23174        { value: "months", label: (0, import_i18n39.__)("Months ago") },
23175        { value: "years", label: (0, import_i18n39.__)("Years ago") }
23176      ]
23177    };
23178    function RelativeDateControl({
23179      className,
23180      data,
23181      field,
23182      onChange,
23183      hideLabelFromVision,
23184      operator
23185    }) {
23186      const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
23187      const { id, label, description, getValue, setValue } = field;
23188      const disabled2 = field.isDisabled({ item: data, field });
23189      const fieldValue = getValue({ item: data });
23190      const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
23191      const onChangeValue = (0, import_element58.useCallback)(
23192        (newValue) => onChange(
23193          setValue({
23194            item: data,
23195            value: { value: Number(newValue), unit }
23196          })
23197        ),
23198        [onChange, setValue, data, unit]
23199      );
23200      const onChangeUnit = (0, import_element58.useCallback)(
23201        (newUnit) => onChange(
23202          setValue({
23203            item: data,
23204            value: { value: relValue, unit: newUnit }
23205          })
23206        ),
23207        [onChange, setValue, data, relValue]
23208      );
23209      return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23210        import_components30.BaseControl,
23211        {
23212          id,
23213          className: clsx_default(className, "dataviews-controls__relative-date"),
23214          label,
23215          hideLabelFromVision,
23216          help: description,
23217          children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "row", gap: "sm", children: [
23218            /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23219              import_components30.__experimentalNumberControl,
23220              {
23221                className: "dataviews-controls__relative-date-number",
23222                spinControls: "none",
23223                min: 1,
23224                step: 1,
23225                value: relValue,
23226                onChange: onChangeValue,
23227                disabled: disabled2
23228              }
23229            ),
23230            /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23231              import_components30.SelectControl,
23232              {
23233                className: "dataviews-controls__relative-date-unit",
23234                label: (0, import_i18n39.__)("Unit"),
23235                value: unit,
23236                options,
23237                onChange: onChangeUnit,
23238                hideLabelFromVision: true,
23239                disabled: disabled2
23240              }
23241            )
23242          ] })
23243        }
23244      );
23245    }
23246  
23247    // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
23248    var import_element59 = __toESM(require_element(), 1);
23249    function useDisabledDateMatchers(isValid2, parseDateFn) {
23250      const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
23251      const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
23252      const disabledMatchers = (0, import_element59.useMemo)(() => {
23253        const matchers = [];
23254        if (minConstraint) {
23255          const minDate = parseDateFn(minConstraint);
23256          if (minDate) {
23257            matchers.push({ before: minDate });
23258          }
23259        }
23260        if (maxConstraint) {
23261          const maxDate = parseDateFn(maxConstraint);
23262          if (maxDate) {
23263            matchers.push({ after: maxDate });
23264          }
23265        }
23266        return matchers.length > 0 ? matchers : void 0;
23267      }, [minConstraint, maxConstraint, parseDateFn]);
23268      return { minConstraint, maxConstraint, disabledMatchers };
23269    }
23270  
23271    // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
23272    var import_date2 = __toESM(require_date(), 1);
23273    function parseDateTime(dateTimeString) {
23274      if (!dateTimeString) {
23275        return null;
23276      }
23277      const parsed = (0, import_date2.getDate)(dateTimeString);
23278      return parsed && isValid(parsed) ? parsed : null;
23279    }
23280  
23281    // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23282    var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23283    var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
23284    var formatDateTime = (value) => {
23285      if (!value) {
23286        return "";
23287      }
23288      return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
23289    };
23290    function CalendarDateTimeControl({
23291      data,
23292      field,
23293      onChange,
23294      hideLabelFromVision,
23295      markWhenOptional,
23296      validity,
23297      config
23298    }) {
23299      const { compact } = config || {};
23300      const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
23301      const disabled2 = field.isDisabled({ item: data, field });
23302      const fieldValue = getValue({ item: data });
23303      const value = typeof fieldValue === "string" ? fieldValue : void 0;
23304      const [calendarMonth, setCalendarMonth] = (0, import_element60.useState)(() => {
23305        const parsedDate = parseDateTime(value);
23306        return parsedDate || /* @__PURE__ */ new Date();
23307      });
23308      const inputControlRef = (0, import_element60.useRef)(null);
23309      const validationTimeoutRef = (0, import_element60.useRef)(void 0);
23310      const previousFocusRef = (0, import_element60.useRef)(null);
23311      const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
23312      const onChangeCallback = (0, import_element60.useCallback)(
23313        (newValue) => onChange(setValue({ item: data, value: newValue })),
23314        [data, onChange, setValue]
23315      );
23316      (0, import_element60.useEffect)(() => {
23317        return () => {
23318          if (validationTimeoutRef.current) {
23319            clearTimeout(validationTimeoutRef.current);
23320          }
23321        };
23322      }, []);
23323      const onSelectDate = (0, import_element60.useCallback)(
23324        (newDate) => {
23325          let dateTimeValue;
23326          if (newDate) {
23327            const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
23328            let wpTime;
23329            if (value) {
23330              wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
23331            } else {
23332              wpTime = (0, import_date3.dateI18n)("H:i", newDate);
23333            }
23334            const finalDateTime = (0, import_date3.getDate)(`$wpDate}T$wpTime}`);
23335            dateTimeValue = finalDateTime.toISOString();
23336            onChangeCallback(dateTimeValue);
23337            if (validationTimeoutRef.current) {
23338              clearTimeout(validationTimeoutRef.current);
23339            }
23340          } else {
23341            onChangeCallback(void 0);
23342          }
23343          previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
23344          validationTimeoutRef.current = setTimeout(() => {
23345            if (inputControlRef.current) {
23346              inputControlRef.current.focus();
23347              inputControlRef.current.blur();
23348              onChangeCallback(dateTimeValue);
23349              if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
23350                previousFocusRef.current.focus();
23351              }
23352            }
23353          }, 0);
23354        },
23355        [onChangeCallback, value]
23356      );
23357      const handleManualDateTimeChange = (0, import_element60.useCallback)(
23358        (newValue) => {
23359          if (newValue) {
23360            const dateTime = (0, import_date3.getDate)(newValue);
23361            onChangeCallback(dateTime.toISOString());
23362            const parsedDate = parseDateTime(dateTime.toISOString());
23363            if (parsedDate) {
23364              setCalendarMonth(parsedDate);
23365            }
23366          } else {
23367            onChangeCallback(void 0);
23368          }
23369        },
23370        [onChangeCallback]
23371      );
23372      const { format: fieldFormat } = field;
23373      const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
23374      const {
23375        timezone: { string: timezoneString }
23376      } = (0, import_date3.getSettings)();
23377      let displayLabel = label;
23378      if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
23379        displayLabel = `$label} (${(0, import_i18n40.__)("Required")})`;
23380      } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
23381        displayLabel = `$label} (${(0, import_i18n40.__)("Optional")})`;
23382      }
23383      return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23384        import_components31.BaseControl,
23385        {
23386          id,
23387          label: displayLabel,
23388          help: description,
23389          hideLabelFromVision,
23390          children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23391            /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23392              ValidatedInputControl,
23393              {
23394                ref: inputControlRef,
23395                required: !!isValid2?.required,
23396                customValidity: getCustomValidity(isValid2, validity),
23397                type: "datetime-local",
23398                label: (0, import_i18n40.__)("Date time"),
23399                hideLabelFromVision: true,
23400                value: formatDateTime(value),
23401                onChange: handleManualDateTimeChange,
23402                disabled: disabled2,
23403                min: minConstraint ? formatDateTime(minConstraint) : void 0,
23404                max: maxConstraint ? formatDateTime(maxConstraint) : void 0
23405              }
23406            ),
23407            !compact && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23408              DateCalendar,
23409              {
23410                style: { width: "100%" },
23411                selected: value ? parseDateTime(value) || void 0 : void 0,
23412                onSelect: onSelectDate,
23413                month: calendarMonth,
23414                onMonthChange: setCalendarMonth,
23415                timeZone: timezoneString || void 0,
23416                weekStartsOn,
23417                disabled: disabled2 || disabledMatchers
23418              }
23419            )
23420          ] })
23421        }
23422      );
23423    }
23424    function DateTime({
23425      data,
23426      field,
23427      onChange,
23428      hideLabelFromVision,
23429      markWhenOptional,
23430      operator,
23431      validity,
23432      config
23433    }) {
23434      if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23435        return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23436          RelativeDateControl,
23437          {
23438            className: "dataviews-controls__datetime",
23439            data,
23440            field,
23441            onChange,
23442            hideLabelFromVision,
23443            operator
23444          }
23445        );
23446      }
23447      return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23448        CalendarDateTimeControl,
23449        {
23450          data,
23451          field,
23452          onChange,
23453          hideLabelFromVision,
23454          markWhenOptional,
23455          validity,
23456          config
23457        }
23458      );
23459    }
23460  
23461    // packages/dataviews/build-module/components/dataform-controls/date.mjs
23462    var import_components32 = __toESM(require_components(), 1);
23463    var import_a11y = __toESM(require_a11y(), 1);
23464    var import_element61 = __toESM(require_element(), 1);
23465    var import_i18n41 = __toESM(require_i18n(), 1);
23466    var import_date4 = __toESM(require_date(), 1);
23467    var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23468    var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
23469    var DATE_PRESETS = [
23470      {
23471        id: "today",
23472        label: (0, import_i18n41.__)("Today"),
23473        getValue: () => (0, import_date4.getDate)(null)
23474      },
23475      {
23476        id: "yesterday",
23477        label: (0, import_i18n41.__)("Yesterday"),
23478        getValue: () => {
23479          const today = (0, import_date4.getDate)(null);
23480          return subDays(today, 1);
23481        }
23482      },
23483      {
23484        id: "past-week",
23485        label: (0, import_i18n41.__)("Past week"),
23486        getValue: () => {
23487          const today = (0, import_date4.getDate)(null);
23488          return subDays(today, 7);
23489        }
23490      },
23491      {
23492        id: "past-month",
23493        label: (0, import_i18n41.__)("Past month"),
23494        getValue: () => {
23495          const today = (0, import_date4.getDate)(null);
23496          return subMonths(today, 1);
23497        }
23498      }
23499    ];
23500    var DATE_RANGE_PRESETS = [
23501      {
23502        id: "last-7-days",
23503        label: (0, import_i18n41.__)("Last 7 days"),
23504        getValue: () => {
23505          const today = (0, import_date4.getDate)(null);
23506          return [subDays(today, 7), today];
23507        }
23508      },
23509      {
23510        id: "last-30-days",
23511        label: (0, import_i18n41.__)("Last 30 days"),
23512        getValue: () => {
23513          const today = (0, import_date4.getDate)(null);
23514          return [subDays(today, 30), today];
23515        }
23516      },
23517      {
23518        id: "month-to-date",
23519        label: (0, import_i18n41.__)("Month to date"),
23520        getValue: () => {
23521          const today = (0, import_date4.getDate)(null);
23522          return [startOfMonth(today), today];
23523        }
23524      },
23525      {
23526        id: "last-year",
23527        label: (0, import_i18n41.__)("Last year"),
23528        getValue: () => {
23529          const today = (0, import_date4.getDate)(null);
23530          return [subYears(today, 1), today];
23531        }
23532      },
23533      {
23534        id: "year-to-date",
23535        label: (0, import_i18n41.__)("Year to date"),
23536        getValue: () => {
23537          const today = (0, import_date4.getDate)(null);
23538          return [startOfYear(today), today];
23539        }
23540      }
23541    ];
23542    var parseDate = (dateString) => {
23543      if (!dateString) {
23544        return null;
23545      }
23546      const parsed = (0, import_date4.getDate)(dateString);
23547      return parsed && isValid(parsed) ? parsed : null;
23548    };
23549    var formatDate = (date) => {
23550      if (!date) {
23551        return "";
23552      }
23553      return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23554    };
23555    function ValidatedDateControl({
23556      field,
23557      validity,
23558      inputRefs,
23559      isTouched,
23560      setIsTouched,
23561      children
23562    }) {
23563      const { isValid: isValid2 } = field;
23564      const [customValidity, setCustomValidity] = (0, import_element61.useState)(void 0);
23565      const validateRefs = (0, import_element61.useCallback)(() => {
23566        const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23567        for (const ref of refs) {
23568          const input = ref.current;
23569          if (input && !input.validity.valid) {
23570            setCustomValidity({
23571              type: "invalid",
23572              message: input.validationMessage
23573            });
23574            return;
23575          }
23576        }
23577        setCustomValidity(void 0);
23578      }, [inputRefs]);
23579      (0, import_element61.useEffect)(() => {
23580        const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23581        const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23582        for (const ref of refs) {
23583          const input = ref.current;
23584          if (input) {
23585            input.setCustomValidity(
23586              result?.type === "invalid" && result.message ? result.message : ""
23587            );
23588          }
23589        }
23590      }, [inputRefs, isValid2, validity]);
23591      (0, import_element61.useEffect)(() => {
23592        const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23593        const handleInvalid = (event) => {
23594          event.preventDefault();
23595          setIsTouched(true);
23596        };
23597        for (const ref of refs) {
23598          ref.current?.addEventListener("invalid", handleInvalid);
23599        }
23600        return () => {
23601          for (const ref of refs) {
23602            ref.current?.removeEventListener("invalid", handleInvalid);
23603          }
23604        };
23605      }, [inputRefs, setIsTouched]);
23606      (0, import_element61.useEffect)(() => {
23607        if (!isTouched) {
23608          return;
23609        }
23610        const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23611        if (result) {
23612          setCustomValidity(result);
23613        } else {
23614          validateRefs();
23615        }
23616      }, [isTouched, isValid2, validity, validateRefs]);
23617      (0, import_element61.useEffect)(() => {
23618        if (isTouched && customValidity?.message) {
23619          (0, import_a11y.speak)(customValidity.message);
23620        }
23621      }, [isTouched, customValidity?.message]);
23622      const onBlur = (event) => {
23623        if (isTouched) {
23624          return;
23625        }
23626        if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23627          setIsTouched(true);
23628        }
23629      };
23630      return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { onBlur, children: [
23631        children,
23632        customValidity && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23633          "p",
23634          {
23635            className: clsx_default(
23636              "components-validated-control__indicator",
23637              customValidity.type === "invalid" ? "is-invalid" : void 0
23638            ),
23639            children: [
23640              /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23641                import_components32.Icon,
23642                {
23643                  className: "components-validated-control__indicator-icon",
23644                  icon: error_default,
23645                  size: 16,
23646                  fill: "currentColor"
23647                }
23648              ),
23649              customValidity.message
23650            ]
23651          }
23652        )
23653      ] });
23654    }
23655    function CalendarDateControl({
23656      data,
23657      field,
23658      onChange,
23659      hideLabelFromVision,
23660      markWhenOptional,
23661      validity
23662    }) {
23663      const {
23664        id,
23665        label,
23666        description,
23667        setValue,
23668        getValue,
23669        isValid: isValid2,
23670        format: fieldFormat
23671      } = field;
23672      const disabled2 = field.isDisabled({ item: data, field });
23673      const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
23674        null
23675      );
23676      const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23677      const fieldValue = getValue({ item: data });
23678      const value = typeof fieldValue === "string" ? fieldValue : void 0;
23679      const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
23680        const parsedDate = parseDate(value);
23681        return parsedDate || /* @__PURE__ */ new Date();
23682      });
23683      const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
23684      const validityTargetRef = (0, import_element61.useRef)(null);
23685      const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23686      const onChangeCallback = (0, import_element61.useCallback)(
23687        (newValue) => onChange(setValue({ item: data, value: newValue })),
23688        [data, onChange, setValue]
23689      );
23690      const onSelectDate = (0, import_element61.useCallback)(
23691        (newDate) => {
23692          const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23693          onChangeCallback(dateValue);
23694          setSelectedPresetId(null);
23695          setIsTouched(true);
23696        },
23697        [onChangeCallback]
23698      );
23699      const handlePresetClick = (0, import_element61.useCallback)(
23700        (preset) => {
23701          const presetDate = preset.getValue();
23702          const dateValue = formatDate(presetDate);
23703          setCalendarMonth(presetDate);
23704          onChangeCallback(dateValue);
23705          setSelectedPresetId(preset.id);
23706          setIsTouched(true);
23707        },
23708        [onChangeCallback]
23709      );
23710      const handleManualDateChange = (0, import_element61.useCallback)(
23711        (newValue) => {
23712          onChangeCallback(newValue);
23713          if (newValue) {
23714            const parsedDate = parseDate(newValue);
23715            if (parsedDate) {
23716              setCalendarMonth(parsedDate);
23717            }
23718          }
23719          setSelectedPresetId(null);
23720          setIsTouched(true);
23721        },
23722        [onChangeCallback]
23723      );
23724      const {
23725        timezone: { string: timezoneString }
23726      } = (0, import_date4.getSettings)();
23727      let displayLabel = label;
23728      if (isValid2?.required && !markWhenOptional) {
23729        displayLabel = `$label} (${(0, import_i18n41.__)("Required")})`;
23730      } else if (!isValid2?.required && markWhenOptional) {
23731        displayLabel = `$label} (${(0, import_i18n41.__)("Optional")})`;
23732      }
23733      return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23734        ValidatedDateControl,
23735        {
23736          field,
23737          validity,
23738          inputRefs: validityTargetRef,
23739          isTouched,
23740          setIsTouched,
23741          children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23742            import_components32.BaseControl,
23743            {
23744              id,
23745              className: "dataviews-controls__date",
23746              label: displayLabel,
23747              help: description,
23748              hideLabelFromVision,
23749              children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23750                /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23751                  Stack,
23752                  {
23753                    direction: "row",
23754                    gap: "sm",
23755                    wrap: "wrap",
23756                    justify: "flex-start",
23757                    children: [
23758                      DATE_PRESETS.map((preset) => {
23759                        const isSelected2 = selectedPresetId === preset.id;
23760                        return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23761                          import_components32.Button,
23762                          {
23763                            className: "dataviews-controls__date-preset",
23764                            variant: "tertiary",
23765                            isPressed: isSelected2,
23766                            size: "small",
23767                            disabled: disabled2,
23768                            accessibleWhenDisabled: true,
23769                            onClick: () => handlePresetClick(preset),
23770                            children: preset.label
23771                          },
23772                          preset.id
23773                        );
23774                      }),
23775                      /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23776                        import_components32.Button,
23777                        {
23778                          className: "dataviews-controls__date-preset",
23779                          variant: "tertiary",
23780                          isPressed: !selectedPresetId,
23781                          size: "small",
23782                          disabled: !!selectedPresetId || disabled2,
23783                          accessibleWhenDisabled: true,
23784                          children: (0, import_i18n41.__)("Custom")
23785                        }
23786                      )
23787                    ]
23788                  }
23789                ),
23790                /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23791                  import_components32.__experimentalInputControl,
23792                  {
23793                    ref: validityTargetRef,
23794                    type: "date",
23795                    label: (0, import_i18n41.__)("Date"),
23796                    hideLabelFromVision: true,
23797                    value,
23798                    onChange: handleManualDateChange,
23799                    required: !!field.isValid?.required,
23800                    disabled: disabled2,
23801                    min: minConstraint,
23802                    max: maxConstraint
23803                  }
23804                ),
23805                /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23806                  DateCalendar2,
23807                  {
23808                    style: { width: "100%" },
23809                    selected: value ? parseDate(value) || void 0 : void 0,
23810                    onSelect: onSelectDate,
23811                    month: calendarMonth,
23812                    onMonthChange: setCalendarMonth,
23813                    timeZone: timezoneString || void 0,
23814                    weekStartsOn,
23815                    disabled: disabled2 || disabledMatchers,
23816                    disableNavigation: disabled2
23817                  }
23818                )
23819              ] })
23820            }
23821          )
23822        }
23823      );
23824    }
23825    function CalendarDateRangeControl({
23826      data,
23827      field,
23828      onChange,
23829      hideLabelFromVision,
23830      markWhenOptional,
23831      validity
23832    }) {
23833      const {
23834        id,
23835        label,
23836        description,
23837        getValue,
23838        setValue,
23839        isValid: isValid2,
23840        format: fieldFormat
23841      } = field;
23842      const disabled2 = field.isDisabled({ item: data, field });
23843      let value;
23844      const fieldValue = getValue({ item: data });
23845      if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23846        value = fieldValue;
23847      }
23848      const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23849      const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23850      const onChangeCallback = (0, import_element61.useCallback)(
23851        (newValue) => {
23852          onChange(
23853            setValue({
23854              item: data,
23855              value: newValue
23856            })
23857          );
23858        },
23859        [data, onChange, setValue]
23860      );
23861      const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
23862        null
23863      );
23864      const selectedRange = (0, import_element61.useMemo)(() => {
23865        if (!value) {
23866          return { from: void 0, to: void 0 };
23867        }
23868        const [from, to] = value;
23869        return {
23870          from: parseDate(from) || void 0,
23871          to: parseDate(to) || void 0
23872        };
23873      }, [value]);
23874      const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
23875        return selectedRange.from || /* @__PURE__ */ new Date();
23876      });
23877      const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
23878      const fromInputRef = (0, import_element61.useRef)(null);
23879      const toInputRef = (0, import_element61.useRef)(null);
23880      const updateDateRange = (0, import_element61.useCallback)(
23881        (fromDate, toDate2) => {
23882          if (fromDate && toDate2) {
23883            onChangeCallback([
23884              formatDate(fromDate),
23885              formatDate(toDate2)
23886            ]);
23887          } else if (!fromDate && !toDate2) {
23888            onChangeCallback(void 0);
23889          }
23890        },
23891        [onChangeCallback]
23892      );
23893      const onSelectCalendarRange = (0, import_element61.useCallback)(
23894        (newRange) => {
23895          updateDateRange(newRange?.from, newRange?.to);
23896          setSelectedPresetId(null);
23897          setIsTouched(true);
23898        },
23899        [updateDateRange]
23900      );
23901      const handlePresetClick = (0, import_element61.useCallback)(
23902        (preset) => {
23903          const [startDate, endDate] = preset.getValue();
23904          setCalendarMonth(startDate);
23905          updateDateRange(startDate, endDate);
23906          setSelectedPresetId(preset.id);
23907          setIsTouched(true);
23908        },
23909        [updateDateRange]
23910      );
23911      const handleManualDateChange = (0, import_element61.useCallback)(
23912        (fromOrTo, newValue) => {
23913          const [currentFrom, currentTo] = value || [
23914            void 0,
23915            void 0
23916          ];
23917          const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23918          const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23919          updateDateRange(updatedFrom, updatedTo);
23920          if (newValue) {
23921            const parsedDate = parseDate(newValue);
23922            if (parsedDate) {
23923              setCalendarMonth(parsedDate);
23924            }
23925          }
23926          setSelectedPresetId(null);
23927          setIsTouched(true);
23928        },
23929        [value, updateDateRange]
23930      );
23931      const { timezone } = (0, import_date4.getSettings)();
23932      let displayLabel = label;
23933      if (field.isValid?.required && !markWhenOptional) {
23934        displayLabel = `$label} (${(0, import_i18n41.__)("Required")})`;
23935      } else if (!field.isValid?.required && markWhenOptional) {
23936        displayLabel = `$label} (${(0, import_i18n41.__)("Optional")})`;
23937      }
23938      return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23939        ValidatedDateControl,
23940        {
23941          field,
23942          validity,
23943          inputRefs: [fromInputRef, toInputRef],
23944          isTouched,
23945          setIsTouched,
23946          children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23947            import_components32.BaseControl,
23948            {
23949              id,
23950              className: "dataviews-controls__date",
23951              label: displayLabel,
23952              help: description,
23953              hideLabelFromVision,
23954              children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23955                /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23956                  Stack,
23957                  {
23958                    direction: "row",
23959                    gap: "sm",
23960                    wrap: "wrap",
23961                    justify: "flex-start",
23962                    children: [
23963                      DATE_RANGE_PRESETS.map((preset) => {
23964                        const isSelected2 = selectedPresetId === preset.id;
23965                        return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23966                          import_components32.Button,
23967                          {
23968                            className: "dataviews-controls__date-preset",
23969                            variant: "tertiary",
23970                            isPressed: isSelected2,
23971                            size: "small",
23972                            disabled: disabled2,
23973                            accessibleWhenDisabled: true,
23974                            onClick: () => handlePresetClick(preset),
23975                            children: preset.label
23976                          },
23977                          preset.id
23978                        );
23979                      }),
23980                      /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23981                        import_components32.Button,
23982                        {
23983                          className: "dataviews-controls__date-preset",
23984                          variant: "tertiary",
23985                          isPressed: !selectedPresetId,
23986                          size: "small",
23987                          accessibleWhenDisabled: true,
23988                          disabled: !!selectedPresetId || disabled2,
23989                          children: (0, import_i18n41.__)("Custom")
23990                        }
23991                      )
23992                    ]
23993                  }
23994                ),
23995                /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23996                  Stack,
23997                  {
23998                    direction: "row",
23999                    gap: "sm",
24000                    justify: "space-between",
24001                    className: "dataviews-controls__date-range-inputs",
24002                    children: [
24003                      /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24004                        import_components32.__experimentalInputControl,
24005                        {
24006                          ref: fromInputRef,
24007                          type: "date",
24008                          label: (0, import_i18n41.__)("From"),
24009                          hideLabelFromVision: true,
24010                          value: value?.[0],
24011                          onChange: (newValue) => handleManualDateChange("from", newValue),
24012                          required: !!field.isValid?.required,
24013                          disabled: disabled2,
24014                          min: minConstraint,
24015                          max: maxConstraint
24016                        }
24017                      ),
24018                      /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24019                        import_components32.__experimentalInputControl,
24020                        {
24021                          ref: toInputRef,
24022                          type: "date",
24023                          label: (0, import_i18n41.__)("To"),
24024                          hideLabelFromVision: true,
24025                          value: value?.[1],
24026                          onChange: (newValue) => handleManualDateChange("to", newValue),
24027                          required: !!field.isValid?.required,
24028                          disabled: disabled2,
24029                          min: minConstraint,
24030                          max: maxConstraint
24031                        }
24032                      )
24033                    ]
24034                  }
24035                ),
24036                /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24037                  DateRangeCalendar,
24038                  {
24039                    style: { width: "100%" },
24040                    selected: selectedRange,
24041                    onSelect: onSelectCalendarRange,
24042                    month: calendarMonth,
24043                    onMonthChange: setCalendarMonth,
24044                    timeZone: timezone.string || void 0,
24045                    weekStartsOn,
24046                    disabled: disabled2 || disabledMatchers
24047                  }
24048                )
24049              ] })
24050            }
24051          )
24052        }
24053      );
24054    }
24055    function DateControl({
24056      data,
24057      field,
24058      onChange,
24059      hideLabelFromVision,
24060      markWhenOptional,
24061      operator,
24062      validity
24063    }) {
24064      if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
24065        return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24066          RelativeDateControl,
24067          {
24068            className: "dataviews-controls__date",
24069            data,
24070            field,
24071            onChange,
24072            hideLabelFromVision,
24073            operator
24074          }
24075        );
24076      }
24077      if (operator === OPERATOR_BETWEEN) {
24078        return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24079          CalendarDateRangeControl,
24080          {
24081            data,
24082            field,
24083            onChange,
24084            hideLabelFromVision,
24085            markWhenOptional,
24086            validity
24087          }
24088        );
24089      }
24090      return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24091        CalendarDateControl,
24092        {
24093          data,
24094          field,
24095          onChange,
24096          hideLabelFromVision,
24097          markWhenOptional,
24098          validity
24099        }
24100      );
24101    }
24102  
24103    // packages/dataviews/build-module/components/dataform-controls/select.mjs
24104    var import_components33 = __toESM(require_components(), 1);
24105    var import_element62 = __toESM(require_element(), 1);
24106    var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
24107    var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
24108    function Select({
24109      data,
24110      field,
24111      onChange,
24112      hideLabelFromVision,
24113      markWhenOptional,
24114      validity
24115    }) {
24116      const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
24117      const disabled2 = field.isDisabled({ item: data, field });
24118      const isMultiple = type === "array";
24119      const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
24120      const onChangeControl = (0, import_element62.useCallback)(
24121        (newValue) => onChange(setValue({ item: data, value: newValue })),
24122        [data, onChange, setValue]
24123      );
24124      const { elements, isLoading } = useElements({
24125        elements: field.elements,
24126        getElements: field.getElements
24127      });
24128      if (isLoading) {
24129        return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components33.Spinner, {});
24130      }
24131      return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24132        ValidatedSelectControl,
24133        {
24134          required: !!field.isValid?.required,
24135          markWhenOptional,
24136          customValidity: getCustomValidity(isValid2, validity),
24137          label,
24138          value,
24139          help: description,
24140          options: elements,
24141          onChange: onChangeControl,
24142          hideLabelFromVision,
24143          multiple: isMultiple,
24144          disabled: disabled2
24145        }
24146      );
24147    }
24148  
24149    // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
24150    var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
24151    var ELEMENTS_THRESHOLD = 10;
24152    function AdaptiveSelect(props) {
24153      const { field } = props;
24154      const { elements } = useElements({
24155        elements: field.elements,
24156        getElements: field.getElements
24157      });
24158      if (elements.length >= ELEMENTS_THRESHOLD) {
24159        return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Combobox3, { ...props });
24160      }
24161      return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Select, { ...props });
24162    }
24163  
24164    // packages/dataviews/build-module/components/dataform-controls/email.mjs
24165    var import_components35 = __toESM(require_components(), 1);
24166  
24167    // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
24168    var import_components34 = __toESM(require_components(), 1);
24169    var import_element63 = __toESM(require_element(), 1);
24170    var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
24171    var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
24172    function ValidatedText({
24173      data,
24174      field,
24175      onChange,
24176      hideLabelFromVision,
24177      markWhenOptional,
24178      type,
24179      prefix,
24180      suffix,
24181      validity
24182    }) {
24183      const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24184      const value = getValue({ item: data });
24185      const disabled2 = field.isDisabled({ item: data, field });
24186      const onChangeControl = (0, import_element63.useCallback)(
24187        (newValue) => onChange(
24188          setValue({
24189            item: data,
24190            value: newValue
24191          })
24192        ),
24193        [data, setValue, onChange]
24194      );
24195      return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
24196        ValidatedInputControl2,
24197        {
24198          required: !!isValid2.required,
24199          markWhenOptional,
24200          customValidity: getCustomValidity(isValid2, validity),
24201          label,
24202          placeholder,
24203          value: value ?? "",
24204          help: description,
24205          onChange: onChangeControl,
24206          hideLabelFromVision,
24207          type,
24208          prefix,
24209          suffix,
24210          disabled: disabled2,
24211          pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
24212          minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24213          maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0
24214        }
24215      );
24216    }
24217  
24218    // packages/dataviews/build-module/components/dataform-controls/email.mjs
24219    var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24220    function Email({
24221      data,
24222      field,
24223      onChange,
24224      hideLabelFromVision,
24225      markWhenOptional,
24226      validity
24227    }) {
24228      return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24229        ValidatedText,
24230        {
24231          ...{
24232            data,
24233            field,
24234            onChange,
24235            hideLabelFromVision,
24236            markWhenOptional,
24237            validity,
24238            type: "email",
24239            prefix: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.Icon, { icon: envelope_default }) })
24240          }
24241        }
24242      );
24243    }
24244  
24245    // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
24246    var import_components36 = __toESM(require_components(), 1);
24247    var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24248    function Telephone({
24249      data,
24250      field,
24251      onChange,
24252      hideLabelFromVision,
24253      markWhenOptional,
24254      validity
24255    }) {
24256      return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24257        ValidatedText,
24258        {
24259          ...{
24260            data,
24261            field,
24262            onChange,
24263            hideLabelFromVision,
24264            markWhenOptional,
24265            validity,
24266            type: "tel",
24267            prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.Icon, { icon: mobile_default }) })
24268          }
24269        }
24270      );
24271    }
24272  
24273    // packages/dataviews/build-module/components/dataform-controls/url.mjs
24274    var import_components37 = __toESM(require_components(), 1);
24275    var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24276    function Url({
24277      data,
24278      field,
24279      onChange,
24280      hideLabelFromVision,
24281      markWhenOptional,
24282      validity
24283    }) {
24284      return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24285        ValidatedText,
24286        {
24287          ...{
24288            data,
24289            field,
24290            onChange,
24291            hideLabelFromVision,
24292            markWhenOptional,
24293            validity,
24294            type: "url",
24295            prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components37.Icon, { icon: link_default }) })
24296          }
24297        }
24298      );
24299    }
24300  
24301    // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
24302    var import_components38 = __toESM(require_components(), 1);
24303    var import_element64 = __toESM(require_element(), 1);
24304    var import_i18n42 = __toESM(require_i18n(), 1);
24305    var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24306    var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
24307    function toNumberOrEmpty(value) {
24308      if (value === "" || value === void 0) {
24309        return "";
24310      }
24311      const number = Number(value);
24312      return Number.isFinite(number) ? number : "";
24313    }
24314    function BetweenControls({
24315      value,
24316      onChange,
24317      hideLabelFromVision,
24318      step
24319    }) {
24320      const [min2 = "", max2 = ""] = value;
24321      const onChangeMin = (0, import_element64.useCallback)(
24322        (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
24323        [onChange, max2]
24324      );
24325      const onChangeMax = (0, import_element64.useCallback)(
24326        (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
24327        [onChange, min2]
24328      );
24329      return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24330        import_components38.BaseControl,
24331        {
24332          help: (0, import_i18n42.__)("The max. value must be greater than the min. value."),
24333          children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
24334            /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24335              import_components38.__experimentalNumberControl,
24336              {
24337                label: (0, import_i18n42.__)("Min."),
24338                value: min2,
24339                max: max2 ? Number(max2) - step : void 0,
24340                onChange: onChangeMin,
24341                hideLabelFromVision,
24342                step
24343              }
24344            ),
24345            /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24346              import_components38.__experimentalNumberControl,
24347              {
24348                label: (0, import_i18n42.__)("Max."),
24349                value: max2,
24350                min: min2 ? Number(min2) + step : void 0,
24351                onChange: onChangeMax,
24352                hideLabelFromVision,
24353                step
24354              }
24355            )
24356          ] })
24357        }
24358      );
24359    }
24360    function ValidatedNumber({
24361      data,
24362      field,
24363      onChange,
24364      hideLabelFromVision,
24365      markWhenOptional,
24366      operator,
24367      validity
24368    }) {
24369      const decimals = field.format?.decimals ?? 0;
24370      const step = Math.pow(10, Math.abs(decimals) * -1);
24371      const { label, description, getValue, setValue, isValid: isValid2 } = field;
24372      const value = getValue({ item: data }) ?? "";
24373      const disabled2 = field.isDisabled({ item: data, field });
24374      const onChangeControl = (0, import_element64.useCallback)(
24375        (newValue) => {
24376          onChange(
24377            setValue({
24378              item: data,
24379              // Do not convert an empty string or undefined to a number,
24380              // otherwise there's a mismatch between the UI control (empty)
24381              // and the data relied by onChange (0).
24382              value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
24383            })
24384          );
24385        },
24386        [data, onChange, setValue]
24387      );
24388      const onChangeBetweenControls = (0, import_element64.useCallback)(
24389        (newValue) => {
24390          onChange(
24391            setValue({
24392              item: data,
24393              value: newValue
24394            })
24395          );
24396        },
24397        [data, onChange, setValue]
24398      );
24399      if (operator === OPERATOR_BETWEEN) {
24400        let valueBetween = ["", ""];
24401        if (Array.isArray(value) && value.length === 2 && value.every(
24402          (element) => typeof element === "number" || element === ""
24403        )) {
24404          valueBetween = value;
24405        }
24406        return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24407          BetweenControls,
24408          {
24409            value: valueBetween,
24410            onChange: onChangeBetweenControls,
24411            hideLabelFromVision,
24412            step
24413          }
24414        );
24415      }
24416      return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24417        ValidatedNumberControl,
24418        {
24419          required: !!isValid2.required,
24420          markWhenOptional,
24421          customValidity: getCustomValidity(isValid2, validity),
24422          label,
24423          help: description,
24424          value,
24425          onChange: onChangeControl,
24426          hideLabelFromVision,
24427          step,
24428          min: isValid2.min ? isValid2.min.constraint : void 0,
24429          max: isValid2.max ? isValid2.max.constraint : void 0,
24430          disabled: disabled2
24431        }
24432      );
24433    }
24434  
24435    // packages/dataviews/build-module/components/dataform-controls/integer.mjs
24436    var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24437    function Integer(props) {
24438      return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(ValidatedNumber, { ...props });
24439    }
24440  
24441    // packages/dataviews/build-module/components/dataform-controls/number.mjs
24442    var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24443    function Number2(props) {
24444      return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ValidatedNumber, { ...props });
24445    }
24446  
24447    // packages/dataviews/build-module/components/dataform-controls/radio.mjs
24448    var import_components39 = __toESM(require_components(), 1);
24449    var import_element65 = __toESM(require_element(), 1);
24450    var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24451    var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
24452    function Radio({
24453      data,
24454      field,
24455      onChange,
24456      hideLabelFromVision,
24457      markWhenOptional,
24458      validity
24459    }) {
24460      const { label, description, getValue, setValue, isValid: isValid2 } = field;
24461      const disabled2 = field.isDisabled({ item: data, field });
24462      const { elements, isLoading } = useElements({
24463        elements: field.elements,
24464        getElements: field.getElements
24465      });
24466      const value = getValue({ item: data });
24467      const onChangeControl = (0, import_element65.useCallback)(
24468        (newValue) => onChange(setValue({ item: data, value: newValue })),
24469        [data, onChange, setValue]
24470      );
24471      if (isLoading) {
24472        return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components39.Spinner, {});
24473      }
24474      return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24475        ValidatedRadioControl,
24476        {
24477          required: !!field.isValid?.required,
24478          markWhenOptional,
24479          customValidity: getCustomValidity(isValid2, validity),
24480          label,
24481          help: description,
24482          onChange: onChangeControl,
24483          options: elements,
24484          selected: value,
24485          hideLabelFromVision,
24486          disabled: disabled2
24487        }
24488      );
24489    }
24490  
24491    // packages/dataviews/build-module/components/dataform-controls/text.mjs
24492    var import_element66 = __toESM(require_element(), 1);
24493    var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24494    function Text({
24495      data,
24496      field,
24497      onChange,
24498      hideLabelFromVision,
24499      markWhenOptional,
24500      config,
24501      validity
24502    }) {
24503      const { prefix, suffix } = config || {};
24504      return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24505        ValidatedText,
24506        {
24507          ...{
24508            data,
24509            field,
24510            onChange,
24511            hideLabelFromVision,
24512            markWhenOptional,
24513            validity,
24514            prefix: prefix ? (0, import_element66.createElement)(prefix) : void 0,
24515            suffix: suffix ? (0, import_element66.createElement)(suffix) : void 0
24516          }
24517        }
24518      );
24519    }
24520  
24521    // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
24522    var import_components40 = __toESM(require_components(), 1);
24523    var import_element67 = __toESM(require_element(), 1);
24524    var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24525    var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
24526    function Toggle({
24527      field,
24528      onChange,
24529      data,
24530      hideLabelFromVision,
24531      markWhenOptional,
24532      validity
24533    }) {
24534      const { label, description, getValue, setValue, isValid: isValid2 } = field;
24535      const disabled2 = field.isDisabled({ item: data, field });
24536      const onChangeControl = (0, import_element67.useCallback)(() => {
24537        onChange(
24538          setValue({ item: data, value: !getValue({ item: data }) })
24539        );
24540      }, [onChange, setValue, data, getValue]);
24541      return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24542        ValidatedToggleControl,
24543        {
24544          required: !!isValid2.required,
24545          markWhenOptional,
24546          customValidity: getCustomValidity(isValid2, validity),
24547          hidden: hideLabelFromVision,
24548          label,
24549          help: description,
24550          checked: getValue({ item: data }),
24551          onChange: onChangeControl,
24552          disabled: disabled2
24553        }
24554      );
24555    }
24556  
24557    // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24558    var import_components41 = __toESM(require_components(), 1);
24559    var import_element68 = __toESM(require_element(), 1);
24560    var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24561    var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
24562    function Textarea({
24563      data,
24564      field,
24565      onChange,
24566      hideLabelFromVision,
24567      markWhenOptional,
24568      config,
24569      validity
24570    }) {
24571      const { rows = 4 } = config || {};
24572      const disabled2 = field.isDisabled({ item: data, field });
24573      const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24574      const value = field.getValue({ item: data });
24575      const onChangeControl = (0, import_element68.useCallback)(
24576        (newValue) => onChange(setValue({ item: data, value: newValue })),
24577        [data, onChange, setValue]
24578      );
24579      return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24580        ValidatedTextareaControl,
24581        {
24582          required: !!isValid2.required,
24583          markWhenOptional,
24584          customValidity: getCustomValidity(isValid2, validity),
24585          label,
24586          placeholder,
24587          value: value ?? "",
24588          help: description,
24589          onChange: onChangeControl,
24590          rows,
24591          disabled: disabled2,
24592          minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24593          maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24594          __next40pxDefaultSize: true,
24595          hideLabelFromVision
24596        }
24597      );
24598    }
24599  
24600    // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24601    var import_element70 = __toESM(require_element(), 1);
24602  
24603    // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24604    var import_components42 = __toESM(require_components(), 1);
24605    var import_compose12 = __toESM(require_compose(), 1);
24606    var import_element69 = __toESM(require_element(), 1);
24607    var import_rich_text2 = __toESM(require_rich_text(), 1);
24608  
24609    // packages/dataviews/build-module/components/dataform-controls/richtext/utils.mjs
24610    var EMPTY_ARRAY5 = [];
24611    function getAllowedFormats({
24612      allowedFormats,
24613      disableFormats
24614    }) {
24615      if (disableFormats) {
24616        return EMPTY_ARRAY5;
24617      }
24618      return allowedFormats;
24619    }
24620  
24621    // packages/dataviews/build-module/components/dataform-controls/richtext/format-edit.mjs
24622    var import_rich_text = __toESM(require_rich_text(), 1);
24623    var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24624    var import_react24 = __toESM(require_react(), 1);
24625    var EMPTY_CONTEXT = {};
24626    function Edit({
24627      onChange,
24628      onFocus,
24629      value,
24630      forwardedRef,
24631      settings,
24632      isVisible: isVisible2
24633    }) {
24634      const { name, edit: EditFunction } = settings;
24635      if (!EditFunction) {
24636        return null;
24637      }
24638      const activeFormat = (0, import_rich_text.getActiveFormat)(value, name);
24639      const isActive = activeFormat !== void 0;
24640      const activeObject = (0, import_rich_text.getActiveObject)(value);
24641      const isObjectActive = activeObject !== void 0 && activeObject.type === name;
24642      return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24643        EditFunction,
24644        {
24645          isActive,
24646          isVisible: isVisible2,
24647          activeAttributes: isActive ? activeFormat.attributes || {} : {},
24648          isObjectActive,
24649          activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
24650          value,
24651          onChange,
24652          onFocus,
24653          contentRef: forwardedRef,
24654          context: EMPTY_CONTEXT
24655        },
24656        name
24657      );
24658    }
24659    function FormatEdit({
24660      formatTypes,
24661      ...props
24662    }) {
24663      return formatTypes.map((settings) => /* @__PURE__ */ (0, import_react24.createElement)(Edit, { settings, ...props, key: settings.name }));
24664    }
24665  
24666    // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24667    var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24668    var {
24669      ValidatedContentEditableControl: RichTextControlShell,
24670      withIgnoreIMEEvents
24671    } = unlock2(import_components42.privateApis);
24672    var {
24673      useRichText,
24674      KeyboardShortcutContext,
24675      InputEventContext,
24676      shortcutsListener,
24677      inputEventsListener
24678    } = unlock2(import_rich_text2.privateApis);
24679    var EMPTY_COMPLETERS = [];
24680    function RichTextControl({
24681      label,
24682      value: attrValue,
24683      onChange,
24684      placeholder,
24685      id,
24686      clientId,
24687      className,
24688      hideLabelFromVision,
24689      help,
24690      disabled: disabled2,
24691      required,
24692      markWhenOptional,
24693      customValidity,
24694      allowedFormats,
24695      disableFormats,
24696      withoutInteractiveFormatting,
24697      preserveWhiteSpace,
24698      disableLineBreaks,
24699      focusOnMount,
24700      completers = EMPTY_COMPLETERS
24701    }) {
24702      const [selection, setSelection] = (0, import_element69.useState)({
24703        start: void 0,
24704        end: void 0
24705      });
24706      const [isSelected2, setIsSelected] = (0, import_element69.useState)(false);
24707      const anchorRef = (0, import_element69.useRef)(void 0);
24708      const inputEvents = (0, import_element69.useRef)(/* @__PURE__ */ new Set());
24709      const keyboardShortcuts = (0, import_element69.useRef)(
24710        /* @__PURE__ */ new Set()
24711      );
24712      const focusOutside = (0, import_compose12.__experimentalUseFocusOutside)(() => setIsSelected(false));
24713      const adjustedAllowedFormats = getAllowedFormats({
24714        allowedFormats,
24715        disableFormats
24716      });
24717      const {
24718        value,
24719        onChange: onRichTextChange,
24720        ref: richTextRef,
24721        formatTypes,
24722        getValue
24723      } = useRichText({
24724        value: attrValue,
24725        onChange,
24726        selectionStart: selection.start,
24727        selectionEnd: selection.end,
24728        onSelectionChange: (start, end) => setSelection({ start, end }),
24729        __unstableIsSelected: isSelected2,
24730        preserveWhiteSpace: !!preserveWhiteSpace,
24731        placeholder,
24732        __unstableDisableFormats: disableFormats,
24733        allowedFormats: adjustedAllowedFormats,
24734        withoutInteractiveFormatting,
24735        __unstableFormatTypeHandlerContext: (0, import_element69.useMemo)(
24736          () => ({
24737            richTextIdentifier: id,
24738            blockClientId: clientId
24739          }),
24740          [id, clientId]
24741        )
24742      });
24743      function onFocus() {
24744        anchorRef.current?.focus();
24745      }
24746      const eventListenersPropsRef = (0, import_element69.useRef)({
24747        keyboardShortcuts,
24748        inputEvents
24749      });
24750      const inputRulePropsRef = (0, import_element69.useRef)({
24751        formatTypes,
24752        getValue,
24753        onChange: onRichTextChange
24754      });
24755      (0, import_element69.useInsertionEffect)(() => {
24756        inputRulePropsRef.current = {
24757          formatTypes,
24758          getValue,
24759          onChange: onRichTextChange
24760        };
24761      });
24762      const enterRef = (0, import_compose12.useRefEffect)(
24763        (element) => {
24764          if (disabled2) {
24765            return;
24766          }
24767          const onKeyDown = withIgnoreIMEEvents((event) => {
24768            if (event.key !== "Enter" || event.defaultPrevented || event.metaKey || event.ctrlKey) {
24769              return;
24770            }
24771            event.preventDefault();
24772            if (disableLineBreaks) {
24773              return;
24774            }
24775            const { getValue: getCurrentValue2, onChange: handleChange } = inputRulePropsRef.current;
24776            const current = getCurrentValue2();
24777            handleChange(
24778              (0, import_rich_text2.insert)(
24779                current,
24780                "\n",
24781                current.start ?? current.text.length,
24782                current.end ?? current.text.length
24783              )
24784            );
24785          });
24786          element.addEventListener("keydown", onKeyDown);
24787          return () => element.removeEventListener("keydown", onKeyDown);
24788        },
24789        [disableLineBreaks, disabled2]
24790      );
24791      const eventListenersRef = (0, import_compose12.useRefEffect)(
24792        (element) => {
24793          if (!isSelected2) {
24794            return;
24795          }
24796          const cleanupShortcuts = shortcutsListener(
24797            eventListenersPropsRef
24798          )(element);
24799          const cleanupInputEvents = inputEventsListener(
24800            eventListenersPropsRef
24801          )(element);
24802          function onFormatInput(event) {
24803            if (event.inputType !== "insertText" && event.type !== "compositionend") {
24804              return;
24805            }
24806            const {
24807              formatTypes: types,
24808              getValue: getCurrentValue2,
24809              onChange: handleChange
24810            } = inputRulePropsRef.current;
24811            const current = getCurrentValue2();
24812            const transformed = types.reduce(
24813              (accumulator, {
24814                __unstableInputRule
24815              }) => __unstableInputRule ? __unstableInputRule(accumulator) : accumulator,
24816              current
24817            );
24818            if (transformed !== current) {
24819              handleChange({
24820                ...transformed,
24821                activeFormats: current.activeFormats
24822              });
24823            }
24824          }
24825          element.addEventListener("input", onFormatInput);
24826          element.addEventListener("compositionend", onFormatInput);
24827          return () => {
24828            cleanupShortcuts();
24829            cleanupInputEvents();
24830            element.removeEventListener("input", onFormatInput);
24831            element.removeEventListener("compositionend", onFormatInput);
24832          };
24833        },
24834        [isSelected2]
24835      );
24836      const { ref: autocompleteRef, ...autocompleteProps } = (0, import_components42.__unstableUseAutocompleteProps)(
24837        {
24838          completers,
24839          record: value,
24840          onChange: onRichTextChange,
24841          // This control's completers insert their completion into the value;
24842          // none replace the whole value, so the required `onReplace` is a
24843          // no-op here.
24844          onReplace: () => {
24845          }
24846        }
24847      );
24848      const focusOnMountRef = (0, import_compose12.useRefEffect)(
24849        (element) => {
24850          if (focusOnMount && !disabled2) {
24851            element.focus();
24852          }
24853        },
24854        [focusOnMount, disabled2]
24855      );
24856      const editableRef = (0, import_compose12.useMergeRefs)([
24857        richTextRef,
24858        anchorRef,
24859        eventListenersRef,
24860        enterRef,
24861        focusOnMountRef,
24862        autocompleteRef
24863      ]);
24864      return (
24865        // Focus boundary for the field's selection: `onFocus` selects on entry;
24866        // the spread `useFocusOutside` handlers deselect once focus leaves.
24867        /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24868          "div",
24869          {
24870            ...focusOutside,
24871            onFocus: (event) => {
24872              setIsSelected(true);
24873              focusOutside.onFocus(event);
24874            },
24875            children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_components42.SlotFillProvider, { children: [
24876              /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24877                RichTextControlShell,
24878                {
24879                  label,
24880                  id,
24881                  className: clsx_default(
24882                    "dataviews-controls__richtext",
24883                    className
24884                  ),
24885                  placeholder,
24886                  hideLabelFromVision,
24887                  help,
24888                  disabled: disabled2,
24889                  required,
24890                  markWhenOptional,
24891                  customValidity,
24892                  value: value.text,
24893                  "aria-multiline": !disableLineBreaks,
24894                  ...autocompleteProps,
24895                  ref: editableRef
24896                }
24897              ),
24898              isSelected2 && !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24899                KeyboardShortcutContext.Provider,
24900                {
24901                  value: keyboardShortcuts,
24902                  children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(InputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24903                    FormatEdit,
24904                    {
24905                      value,
24906                      onChange: onRichTextChange,
24907                      onFocus,
24908                      formatTypes,
24909                      forwardedRef: anchorRef,
24910                      isVisible: true
24911                    }
24912                  ) })
24913                }
24914              )
24915            ] })
24916          }
24917        )
24918      );
24919    }
24920  
24921    // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24922    var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24923    function RichText({
24924      data,
24925      field,
24926      onChange,
24927      hideLabelFromVision,
24928      markWhenOptional,
24929      config,
24930      validity
24931    }) {
24932      const {
24933        className,
24934        clientId,
24935        allowedFormats,
24936        disableFormats,
24937        withoutInteractiveFormatting,
24938        preserveWhiteSpace,
24939        disableLineBreaks
24940      } = config || {};
24941      const disabled2 = field.isDisabled({ item: data, field });
24942      const { label, placeholder, description, id, setValue, isValid: isValid2 } = field;
24943      const value = field.getValue({ item: data }) ?? "";
24944      const onChangeControl = (0, import_element70.useCallback)(
24945        (newValue) => onChange(setValue({ item: data, value: newValue })),
24946        [data, onChange, setValue]
24947      );
24948      return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24949        RichTextControl,
24950        {
24951          label,
24952          value,
24953          onChange: onChangeControl,
24954          placeholder,
24955          id,
24956          hideLabelFromVision,
24957          help: description,
24958          disabled: disabled2,
24959          required: !!isValid2.required,
24960          markWhenOptional,
24961          customValidity: getCustomValidity(isValid2, validity),
24962          className,
24963          clientId,
24964          allowedFormats,
24965          disableFormats,
24966          withoutInteractiveFormatting,
24967          preserveWhiteSpace,
24968          disableLineBreaks
24969        }
24970      );
24971    }
24972  
24973    // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24974    var import_components43 = __toESM(require_components(), 1);
24975    var import_element71 = __toESM(require_element(), 1);
24976    var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24977    var { ValidatedToggleGroupControl } = unlock2(import_components43.privateApis);
24978    function ToggleGroup({
24979      data,
24980      field,
24981      onChange,
24982      hideLabelFromVision,
24983      markWhenOptional,
24984      validity
24985    }) {
24986      const { getValue, setValue, isValid: isValid2 } = field;
24987      const disabled2 = field.isDisabled({ item: data, field });
24988      const value = getValue({ item: data });
24989      const onChangeControl = (0, import_element71.useCallback)(
24990        (newValue) => onChange(setValue({ item: data, value: newValue })),
24991        [data, onChange, setValue]
24992      );
24993      const { elements, isLoading } = useElements({
24994        elements: field.elements,
24995        getElements: field.getElements
24996      });
24997      if (isLoading) {
24998        return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components43.Spinner, {});
24999      }
25000      if (elements.length === 0) {
25001        return null;
25002      }
25003      const selectedOption = elements.find((el) => el.value === value);
25004      return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25005        ValidatedToggleGroupControl,
25006        {
25007          required: !!field.isValid?.required,
25008          markWhenOptional,
25009          customValidity: getCustomValidity(isValid2, validity),
25010          isBlock: true,
25011          label: field.label,
25012          help: selectedOption?.description || field.description,
25013          onChange: onChangeControl,
25014          value,
25015          hideLabelFromVision,
25016          children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25017            import_components43.__experimentalToggleGroupControlOption,
25018            {
25019              label: el.label,
25020              value: el.value,
25021              disabled: disabled2
25022            },
25023            el.value
25024          ))
25025        }
25026      );
25027    }
25028  
25029    // packages/dataviews/build-module/components/dataform-controls/array.mjs
25030    var import_components44 = __toESM(require_components(), 1);
25031    var import_element72 = __toESM(require_element(), 1);
25032    var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
25033    var { ValidatedFormTokenField } = unlock2(import_components44.privateApis);
25034    function ArrayControl({
25035      data,
25036      field,
25037      onChange,
25038      hideLabelFromVision,
25039      markWhenOptional,
25040      validity
25041    }) {
25042      const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
25043      const value = getValue({ item: data });
25044      const disabled2 = field.isDisabled({ item: data, field });
25045      const { elements, isLoading } = useElements({
25046        elements: field.elements,
25047        getElements: field.getElements
25048      });
25049      const arrayValueAsElements = (0, import_element72.useMemo)(
25050        () => Array.isArray(value) ? value.map((token) => {
25051          const element = elements?.find(
25052            (suggestion) => suggestion.value === token
25053          );
25054          return element || { value: token, label: token };
25055        }) : [],
25056        [value, elements]
25057      );
25058      const onChangeControl = (0, import_element72.useCallback)(
25059        (tokens) => {
25060          const valueTokens = tokens.map((token) => {
25061            if (typeof token === "object" && "value" in token) {
25062              return token.value;
25063            }
25064            return token;
25065          });
25066          onChange(setValue({ item: data, value: valueTokens }));
25067        },
25068        [onChange, setValue, data]
25069      );
25070      if (isLoading) {
25071        return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components44.Spinner, {});
25072      }
25073      return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25074        ValidatedFormTokenField,
25075        {
25076          required: !!isValid2?.required,
25077          markWhenOptional,
25078          customValidity: getCustomValidity(isValid2, validity),
25079          label: hideLabelFromVision ? void 0 : label,
25080          value: arrayValueAsElements,
25081          onChange: onChangeControl,
25082          placeholder,
25083          suggestions: elements?.map((element) => element.value),
25084          disabled: disabled2,
25085          __experimentalValidateInput: (token) => {
25086            if (field.isValid?.elements && elements) {
25087              return elements.some(
25088                (element) => element.value === token || element.label === token
25089              );
25090            }
25091            return true;
25092          },
25093          __experimentalExpandOnFocus: elements && elements.length > 0,
25094          help: description ?? (field.isValid?.elements ? "" : void 0),
25095          displayTransform: (token) => {
25096            if (typeof token === "object" && "label" in token) {
25097              return token.label;
25098            }
25099            if (typeof token === "string" && elements) {
25100              const element = elements.find(
25101                (el) => el.value === token
25102              );
25103              return element?.label || token;
25104            }
25105            return token;
25106          },
25107          __experimentalRenderItem: ({ item }) => {
25108            if (typeof item === "string" && elements) {
25109              const element = elements.find(
25110                (el) => el.value === item
25111              );
25112              return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("span", { children: element?.label || item });
25113            }
25114            return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("span", { children: item });
25115          }
25116        }
25117      );
25118    }
25119  
25120    // node_modules/colord/index.mjs
25121    var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
25122    var t = function(r3) {
25123      return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
25124    };
25125    var n = function(r3, t2, n2) {
25126      return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
25127    };
25128    var e = function(r3, t2, n2) {
25129      return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
25130    };
25131    var u = function(r3) {
25132      return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
25133    };
25134    var a = function(r3) {
25135      return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
25136    };
25137    var o = function(r3) {
25138      return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
25139    };
25140    var i = /^#([0-9a-f]{3,8})$/i;
25141    var s = function(r3) {
25142      var t2 = r3.toString(16);
25143      return t2.length < 2 ? "0" + t2 : t2;
25144    };
25145    var h = function(r3) {
25146      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;
25147      return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
25148    };
25149    var b = function(r3) {
25150      var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
25151      t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
25152      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;
25153      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 };
25154    };
25155    var g = function(r3) {
25156      return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
25157    };
25158    var d = function(r3) {
25159      return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
25160    };
25161    var f = function(r3) {
25162      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 }));
25163      var t2, n2, e2;
25164    };
25165    var c = function(r3) {
25166      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 };
25167      var t2, n2, e2, u2;
25168    };
25169    var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25170    var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25171    var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25172    var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25173    var y = { string: [[function(r3) {
25174      var t2 = i.exec(r3);
25175      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;
25176    }, "hex"], [function(r3) {
25177      var t2 = v.exec(r3) || m.exec(r3);
25178      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;
25179    }, "rgb"], [function(t2) {
25180      var n2 = l.exec(t2) || p.exec(t2);
25181      if (!n2) return null;
25182      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) });
25183      return f(a2);
25184    }, "hsl"]], object: [[function(r3) {
25185      var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
25186      return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
25187    }, "rgb"], [function(r3) {
25188      var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
25189      if (!t(n2) || !t(e2) || !t(u2)) return null;
25190      var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
25191      return f(i2);
25192    }, "hsl"], [function(r3) {
25193      var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
25194      if (!t(n2) || !t(a2) || !t(o2)) return null;
25195      var h2 = (function(r4) {
25196        return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
25197      })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
25198      return b(h2);
25199    }, "hsv"]] };
25200    var N = function(r3, t2) {
25201      for (var n2 = 0; n2 < t2.length; n2++) {
25202        var e2 = t2[n2][0](r3);
25203        if (e2) return [e2, t2[n2][1]];
25204      }
25205      return [null, void 0];
25206    };
25207    var x = function(r3) {
25208      return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
25209    };
25210    var M = function(r3, t2) {
25211      var n2 = c(r3);
25212      return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
25213    };
25214    var H = function(r3) {
25215      return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
25216    };
25217    var $ = function(r3, t2) {
25218      var n2 = c(r3);
25219      return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
25220    };
25221    var j = (function() {
25222      function r3(r4) {
25223        this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
25224      }
25225      return r3.prototype.isValid = function() {
25226        return null !== this.parsed;
25227      }, r3.prototype.brightness = function() {
25228        return n(H(this.rgba), 2);
25229      }, r3.prototype.isDark = function() {
25230        return H(this.rgba) < 0.5;
25231      }, r3.prototype.isLight = function() {
25232        return H(this.rgba) >= 0.5;
25233      }, r3.prototype.toHex = function() {
25234        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;
25235        var r4, t2, e2, u2, a2, i2;
25236      }, r3.prototype.toRgb = function() {
25237        return o(this.rgba);
25238      }, r3.prototype.toRgbString = function() {
25239        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 + ")";
25240        var r4, t2, n2, e2, u2;
25241      }, r3.prototype.toHsl = function() {
25242        return d(c(this.rgba));
25243      }, r3.prototype.toHslString = function() {
25244        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 + "%)";
25245        var r4, t2, n2, e2, u2;
25246      }, r3.prototype.toHsv = function() {
25247        return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
25248        var r4;
25249      }, r3.prototype.invert = function() {
25250        return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
25251        var r4;
25252      }, r3.prototype.saturate = function(r4) {
25253        return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
25254      }, r3.prototype.desaturate = function(r4) {
25255        return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
25256      }, r3.prototype.grayscale = function() {
25257        return w(M(this.rgba, -1));
25258      }, r3.prototype.lighten = function(r4) {
25259        return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
25260      }, r3.prototype.darken = function(r4) {
25261        return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
25262      }, r3.prototype.rotate = function(r4) {
25263        return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
25264      }, r3.prototype.alpha = function(r4) {
25265        return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
25266        var t2;
25267      }, r3.prototype.hue = function(r4) {
25268        var t2 = c(this.rgba);
25269        return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
25270      }, r3.prototype.isEqual = function(r4) {
25271        return this.toHex() === w(r4).toHex();
25272      }, r3;
25273    })();
25274    var w = function(r3) {
25275      return r3 instanceof j ? r3 : new j(r3);
25276    };
25277  
25278    // packages/dataviews/build-module/components/dataform-controls/color.mjs
25279    var import_components45 = __toESM(require_components(), 1);
25280    var import_element73 = __toESM(require_element(), 1);
25281    var import_i18n43 = __toESM(require_i18n(), 1);
25282    var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
25283    var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components45.privateApis);
25284    var ColorPickerDropdown = ({
25285      color,
25286      onColorChange,
25287      disabled: disabled2
25288    }) => {
25289      const validColor = color && w(color).isValid() ? color : "#ffffff";
25290      return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25291        import_components45.Dropdown,
25292        {
25293          className: "dataviews-controls__color-picker-dropdown",
25294          popoverProps: { resize: false },
25295          renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25296            import_components45.Button,
25297            {
25298              onClick: onToggle,
25299              "aria-label": (0, import_i18n43.__)("Open color picker"),
25300              size: "small",
25301              disabled: disabled2,
25302              accessibleWhenDisabled: true,
25303              icon: () => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
25304            }
25305          ),
25306          renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25307            import_components45.ColorPicker,
25308            {
25309              color: validColor,
25310              onChange: onColorChange,
25311              enableAlpha: true
25312            }
25313          ) })
25314        }
25315      );
25316    };
25317    function Color({
25318      data,
25319      field,
25320      onChange,
25321      hideLabelFromVision,
25322      markWhenOptional,
25323      validity
25324    }) {
25325      const { label, placeholder, description, setValue, isValid: isValid2 } = field;
25326      const disabled2 = field.isDisabled({ item: data, field });
25327      const value = field.getValue({ item: data }) || "";
25328      const handleColorChange = (0, import_element73.useCallback)(
25329        (newColor) => {
25330          onChange(setValue({ item: data, value: newColor }));
25331        },
25332        [data, onChange, setValue]
25333      );
25334      const handleInputChange = (0, import_element73.useCallback)(
25335        (newValue) => {
25336          onChange(setValue({ item: data, value: newValue || "" }));
25337        },
25338        [data, onChange, setValue]
25339      );
25340      return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25341        ValidatedInputControl3,
25342        {
25343          required: !!field.isValid?.required,
25344          markWhenOptional,
25345          customValidity: getCustomValidity(isValid2, validity),
25346          label,
25347          placeholder,
25348          value,
25349          help: description,
25350          onChange: handleInputChange,
25351          hideLabelFromVision,
25352          type: "text",
25353          disabled: disabled2,
25354          prefix: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25355            ColorPickerDropdown,
25356            {
25357              color: value,
25358              onColorChange: handleColorChange,
25359              disabled: disabled2
25360            }
25361          ) })
25362        }
25363      );
25364    }
25365  
25366    // packages/dataviews/build-module/components/dataform-controls/password.mjs
25367    var import_components46 = __toESM(require_components(), 1);
25368    var import_element74 = __toESM(require_element(), 1);
25369    var import_i18n44 = __toESM(require_i18n(), 1);
25370    var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25371    function Password({
25372      data,
25373      field,
25374      onChange,
25375      hideLabelFromVision,
25376      markWhenOptional,
25377      validity
25378    }) {
25379      const [isVisible2, setIsVisible] = (0, import_element74.useState)(false);
25380      const disabled2 = field.isDisabled({ item: data, field });
25381      const toggleVisibility = (0, import_element74.useCallback)(() => {
25382        setIsVisible((prev) => !prev);
25383      }, []);
25384      return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25385        ValidatedText,
25386        {
25387          ...{
25388            data,
25389            field,
25390            onChange,
25391            hideLabelFromVision,
25392            markWhenOptional,
25393            validity,
25394            type: isVisible2 ? "text" : "password",
25395            suffix: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25396              import_components46.Button,
25397              {
25398                icon: isVisible2 ? unseen_default : seen_default,
25399                onClick: toggleVisibility,
25400                size: "small",
25401                label: isVisible2 ? (0, import_i18n44.__)("Hide password") : (0, import_i18n44.__)("Show password"),
25402                disabled: disabled2,
25403                accessibleWhenDisabled: true
25404              }
25405            ) })
25406          }
25407        }
25408      );
25409    }
25410  
25411    // packages/dataviews/build-module/field-types/utils/has-elements.mjs
25412    function hasElements(field) {
25413      return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
25414    }
25415  
25416    // packages/dataviews/build-module/components/dataform-controls/index.mjs
25417    var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
25418    var FORM_CONTROLS = {
25419      adaptiveSelect: AdaptiveSelect,
25420      array: ArrayControl,
25421      checkbox: Checkbox,
25422      color: Color,
25423      combobox: Combobox3,
25424      datetime: DateTime,
25425      date: DateControl,
25426      email: Email,
25427      telephone: Telephone,
25428      url: Url,
25429      integer: Integer,
25430      number: Number2,
25431      password: Password,
25432      radio: Radio,
25433      select: Select,
25434      text: Text,
25435      toggle: Toggle,
25436      textarea: Textarea,
25437      richtext: RichText,
25438      toggleGroup: ToggleGroup
25439    };
25440    function isEditConfig(value) {
25441      return value && typeof value === "object" && typeof value.control === "string";
25442    }
25443    function createConfiguredControl(config) {
25444      const { control, ...controlConfig } = config;
25445      const BaseControlType = getControlByType(control);
25446      if (BaseControlType === null) {
25447        return null;
25448      }
25449      return function ConfiguredControl(props) {
25450        return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(BaseControlType, { ...props, config: controlConfig });
25451      };
25452    }
25453    function getControl(field, fallback) {
25454      if (typeof field.Edit === "function") {
25455        return field.Edit;
25456      }
25457      if (typeof field.Edit === "string") {
25458        return getControlByType(field.Edit);
25459      }
25460      if (isEditConfig(field.Edit)) {
25461        return createConfiguredControl(field.Edit);
25462      }
25463      if (hasElements(field) && field.type !== "array") {
25464        return getControlByType("adaptiveSelect");
25465      }
25466      if (fallback === null) {
25467        return null;
25468      }
25469      return getControlByType(fallback);
25470    }
25471    function getControlByType(type) {
25472      if (Object.keys(FORM_CONTROLS).includes(type)) {
25473        return FORM_CONTROLS[type];
25474      }
25475      return null;
25476    }
25477  
25478    // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
25479    function getFilterBy(field, defaultOperators, validOperators) {
25480      if (field.filterBy === false) {
25481        return false;
25482      }
25483      const operators = field.filterBy?.operators?.filter(
25484        (op) => validOperators.includes(op)
25485      ) ?? defaultOperators;
25486      if (operators.length === 0) {
25487        return false;
25488      }
25489      return {
25490        isPrimary: !!field.filterBy?.isPrimary,
25491        operators
25492      };
25493    }
25494    var get_filter_by_default = getFilterBy;
25495  
25496    // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
25497    var getValueFromId = (id) => ({ item }) => {
25498      const path = id.split(".");
25499      let value = item;
25500      for (const segment of path) {
25501        if (value.hasOwnProperty(segment)) {
25502          value = value[segment];
25503        } else {
25504          value = void 0;
25505        }
25506      }
25507      return value;
25508    };
25509    var get_value_from_id_default = getValueFromId;
25510  
25511    // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
25512    var setValueFromId = (id) => ({ value }) => {
25513      const path = id.split(".");
25514      const result = {};
25515      let current = result;
25516      for (const segment of path.slice(0, -1)) {
25517        current[segment] = {};
25518        current = current[segment];
25519      }
25520      current[path.at(-1)] = value;
25521      return result;
25522    };
25523    var set_value_from_id_default = setValueFromId;
25524  
25525    // packages/dataviews/build-module/field-types/email.mjs
25526    var import_i18n45 = __toESM(require_i18n(), 1);
25527  
25528    // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
25529    function RenderFromElements({
25530      item,
25531      field
25532    }) {
25533      const { elements, isLoading } = useElements({
25534        elements: field.elements,
25535        getElements: field.getElements
25536      });
25537      const value = field.getValue({ item });
25538      if (isLoading) {
25539        return value;
25540      }
25541      if (elements.length === 0) {
25542        return value;
25543      }
25544      return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
25545    }
25546  
25547    // packages/dataviews/build-module/field-types/utils/render-default.mjs
25548    var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
25549    function render({
25550      item,
25551      field
25552    }) {
25553      if (field.hasElements) {
25554        return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(RenderFromElements, { item, field });
25555      }
25556      return field.getValueFormatted({ item, field });
25557    }
25558  
25559    // packages/dataviews/build-module/field-types/utils/sort-text.mjs
25560    var sort_text_default = (a2, b2, direction) => {
25561      return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
25562    };
25563  
25564    // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
25565    function isValidRequired(item, field) {
25566      const value = field.getValue({ item });
25567      return ![void 0, "", null].includes(value);
25568    }
25569  
25570    // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
25571    function isValidMinLength(item, field) {
25572      if (typeof field.isValid.minLength?.constraint !== "number") {
25573        return false;
25574      }
25575      const value = field.getValue({ item });
25576      if ([void 0, "", null].includes(value)) {
25577        return true;
25578      }
25579      return String(value).length >= field.isValid.minLength.constraint;
25580    }
25581  
25582    // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
25583    function isValidMaxLength(item, field) {
25584      if (typeof field.isValid.maxLength?.constraint !== "number") {
25585        return false;
25586      }
25587      const value = field.getValue({ item });
25588      if ([void 0, "", null].includes(value)) {
25589        return true;
25590      }
25591      return String(value).length <= field.isValid.maxLength.constraint;
25592    }
25593  
25594    // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
25595    function isValidPattern(item, field) {
25596      if (field.isValid.pattern?.constraint === void 0) {
25597        return true;
25598      }
25599      try {
25600        const regexp = new RegExp(field.isValid.pattern.constraint);
25601        const value = field.getValue({ item });
25602        if ([void 0, "", null].includes(value)) {
25603          return true;
25604        }
25605        return regexp.test(String(value));
25606      } catch {
25607        return false;
25608      }
25609    }
25610  
25611    // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
25612    function isValidElements(item, field) {
25613      const elements = field.elements ?? [];
25614      const validValues = elements.map((el) => el.value);
25615      if (validValues.length === 0) {
25616        return true;
25617      }
25618      const value = field.getValue({ item });
25619      return [].concat(value).every((v2) => validValues.includes(v2));
25620    }
25621  
25622    // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
25623    function getValueFormatted({
25624      item,
25625      field
25626    }) {
25627      return field.getValue({ item });
25628    }
25629    var get_value_formatted_default_default = getValueFormatted;
25630  
25631    // packages/dataviews/build-module/field-types/email.mjs
25632    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])?)*$/;
25633    function isValidCustom(item, field) {
25634      const value = field.getValue({ item });
25635      if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
25636        return (0, import_i18n45.__)("Value must be a valid email address.");
25637      }
25638      return null;
25639    }
25640    var email_default = {
25641      type: "email",
25642      render,
25643      Edit: "email",
25644      sort: sort_text_default,
25645      enableSorting: true,
25646      enableGlobalSearch: false,
25647      defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25648      validOperators: [
25649        OPERATOR_IS,
25650        OPERATOR_IS_NOT,
25651        OPERATOR_CONTAINS,
25652        OPERATOR_NOT_CONTAINS,
25653        OPERATOR_STARTS_WITH,
25654        // Multiple selection
25655        OPERATOR_IS_ANY,
25656        OPERATOR_IS_NONE,
25657        OPERATOR_IS_ALL,
25658        OPERATOR_IS_NOT_ALL
25659      ],
25660      format: {},
25661      getValueFormatted: get_value_formatted_default_default,
25662      validate: {
25663        required: isValidRequired,
25664        pattern: isValidPattern,
25665        minLength: isValidMinLength,
25666        maxLength: isValidMaxLength,
25667        elements: isValidElements,
25668        custom: isValidCustom
25669      }
25670    };
25671  
25672    // packages/dataviews/build-module/field-types/integer.mjs
25673    var import_i18n46 = __toESM(require_i18n(), 1);
25674  
25675    // packages/dataviews/build-module/field-types/utils/sort-number.mjs
25676    var sort_number_default = (a2, b2, direction) => {
25677      return direction === "asc" ? a2 - b2 : b2 - a2;
25678    };
25679  
25680    // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
25681    function isValidMin(item, field) {
25682      if (typeof field.isValid.min?.constraint !== "number") {
25683        return false;
25684      }
25685      const value = field.getValue({ item });
25686      if ([void 0, "", null].includes(value)) {
25687        return true;
25688      }
25689      return Number(value) >= field.isValid.min.constraint;
25690    }
25691  
25692    // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
25693    function isValidMax(item, field) {
25694      if (typeof field.isValid.max?.constraint !== "number") {
25695        return false;
25696      }
25697      const value = field.getValue({ item });
25698      if ([void 0, "", null].includes(value)) {
25699        return true;
25700      }
25701      return Number(value) <= field.isValid.max.constraint;
25702    }
25703  
25704    // packages/dataviews/build-module/field-types/integer.mjs
25705    var format2 = {
25706      separatorThousand: ","
25707    };
25708    function getValueFormatted2({
25709      item,
25710      field
25711    }) {
25712      let value = field.getValue({ item });
25713      if (value === null || value === void 0) {
25714        return "";
25715      }
25716      value = Number(value);
25717      if (!Number.isFinite(value)) {
25718        return String(value);
25719      }
25720      let formatInteger;
25721      if (field.type !== "integer") {
25722        formatInteger = format2;
25723      } else {
25724        formatInteger = field.format;
25725      }
25726      const { separatorThousand } = formatInteger;
25727      const integerValue = Math.trunc(value);
25728      if (!separatorThousand) {
25729        return String(integerValue);
25730      }
25731      return String(integerValue).replace(
25732        /\B(?=(\d{3})+(?!\d))/g,
25733        separatorThousand
25734      );
25735    }
25736    function isValidCustom2(item, field) {
25737      const value = field.getValue({ item });
25738      if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
25739        return (0, import_i18n46.__)("Value must be an integer.");
25740      }
25741      return null;
25742    }
25743    var integer_default = {
25744      type: "integer",
25745      render,
25746      Edit: "integer",
25747      sort: sort_number_default,
25748      enableSorting: true,
25749      enableGlobalSearch: false,
25750      defaultOperators: [
25751        OPERATOR_IS,
25752        OPERATOR_IS_NOT,
25753        OPERATOR_LESS_THAN,
25754        OPERATOR_GREATER_THAN,
25755        OPERATOR_LESS_THAN_OR_EQUAL,
25756        OPERATOR_GREATER_THAN_OR_EQUAL,
25757        OPERATOR_BETWEEN
25758      ],
25759      validOperators: [
25760        // Single-selection
25761        OPERATOR_IS,
25762        OPERATOR_IS_NOT,
25763        OPERATOR_LESS_THAN,
25764        OPERATOR_GREATER_THAN,
25765        OPERATOR_LESS_THAN_OR_EQUAL,
25766        OPERATOR_GREATER_THAN_OR_EQUAL,
25767        OPERATOR_BETWEEN,
25768        // Multiple-selection
25769        OPERATOR_IS_ANY,
25770        OPERATOR_IS_NONE,
25771        OPERATOR_IS_ALL,
25772        OPERATOR_IS_NOT_ALL
25773      ],
25774      format: format2,
25775      getValueFormatted: getValueFormatted2,
25776      validate: {
25777        required: isValidRequired,
25778        min: isValidMin,
25779        max: isValidMax,
25780        elements: isValidElements,
25781        custom: isValidCustom2
25782      }
25783    };
25784  
25785    // packages/dataviews/build-module/field-types/number.mjs
25786    var import_i18n47 = __toESM(require_i18n(), 1);
25787    var format3 = {
25788      separatorThousand: ",",
25789      separatorDecimal: ".",
25790      decimals: 2
25791    };
25792    function getValueFormatted3({
25793      item,
25794      field
25795    }) {
25796      let value = field.getValue({ item });
25797      if (value === null || value === void 0) {
25798        return "";
25799      }
25800      value = Number(value);
25801      if (!Number.isFinite(value)) {
25802        return String(value);
25803      }
25804      let formatNumber;
25805      if (field.type !== "number") {
25806        formatNumber = format3;
25807      } else {
25808        formatNumber = field.format;
25809      }
25810      const { separatorThousand, separatorDecimal, decimals } = formatNumber;
25811      const fixedValue = value.toFixed(decimals);
25812      const [integerPart, decimalPart] = fixedValue.split(".");
25813      const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
25814      return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
25815    }
25816    function isEmpty(value) {
25817      return value === "" || value === void 0 || value === null;
25818    }
25819    function isValidCustom3(item, field) {
25820      const value = field.getValue({ item });
25821      if (!isEmpty(value) && !Number.isFinite(value)) {
25822        return (0, import_i18n47.__)("Value must be a number.");
25823      }
25824      return null;
25825    }
25826    var number_default = {
25827      type: "number",
25828      render,
25829      Edit: "number",
25830      sort: sort_number_default,
25831      enableSorting: true,
25832      enableGlobalSearch: false,
25833      defaultOperators: [
25834        OPERATOR_IS,
25835        OPERATOR_IS_NOT,
25836        OPERATOR_LESS_THAN,
25837        OPERATOR_GREATER_THAN,
25838        OPERATOR_LESS_THAN_OR_EQUAL,
25839        OPERATOR_GREATER_THAN_OR_EQUAL,
25840        OPERATOR_BETWEEN
25841      ],
25842      validOperators: [
25843        // Single-selection
25844        OPERATOR_IS,
25845        OPERATOR_IS_NOT,
25846        OPERATOR_LESS_THAN,
25847        OPERATOR_GREATER_THAN,
25848        OPERATOR_LESS_THAN_OR_EQUAL,
25849        OPERATOR_GREATER_THAN_OR_EQUAL,
25850        OPERATOR_BETWEEN,
25851        // Multiple-selection
25852        OPERATOR_IS_ANY,
25853        OPERATOR_IS_NONE,
25854        OPERATOR_IS_ALL,
25855        OPERATOR_IS_NOT_ALL
25856      ],
25857      format: format3,
25858      getValueFormatted: getValueFormatted3,
25859      validate: {
25860        required: isValidRequired,
25861        min: isValidMin,
25862        max: isValidMax,
25863        elements: isValidElements,
25864        custom: isValidCustom3
25865      }
25866    };
25867  
25868    // packages/dataviews/build-module/field-types/text.mjs
25869    var text_default = {
25870      type: "text",
25871      render,
25872      Edit: "text",
25873      sort: sort_text_default,
25874      enableSorting: true,
25875      enableGlobalSearch: false,
25876      defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25877      validOperators: [
25878        // Single selection
25879        OPERATOR_IS,
25880        OPERATOR_IS_NOT,
25881        OPERATOR_CONTAINS,
25882        OPERATOR_NOT_CONTAINS,
25883        OPERATOR_STARTS_WITH,
25884        // Multiple selection
25885        OPERATOR_IS_ANY,
25886        OPERATOR_IS_NONE,
25887        OPERATOR_IS_ALL,
25888        OPERATOR_IS_NOT_ALL
25889      ],
25890      format: {},
25891      getValueFormatted: get_value_formatted_default_default,
25892      validate: {
25893        required: isValidRequired,
25894        pattern: isValidPattern,
25895        minLength: isValidMinLength,
25896        maxLength: isValidMaxLength,
25897        elements: isValidElements
25898      }
25899    };
25900  
25901    // packages/dataviews/build-module/field-types/datetime.mjs
25902    var import_date7 = __toESM(require_date(), 1);
25903  
25904    // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
25905    var import_date6 = __toESM(require_date(), 1);
25906    function parseDateLike(value) {
25907      if (!value) {
25908        return null;
25909      }
25910      if (!isValid(new Date(value))) {
25911        return null;
25912      }
25913      const parsed = (0, import_date6.getDate)(value);
25914      return parsed && isValid(parsed) ? parsed : null;
25915    }
25916    function validateDateLikeBoundary(item, field, boundary) {
25917      const constraint = field.isValid[boundary]?.constraint;
25918      if (typeof constraint !== "string") {
25919        return false;
25920      }
25921      const value = field.getValue({ item });
25922      const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25923      if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25924        return true;
25925      }
25926      const parsedConstraint = parseDateLike(constraint);
25927      const parsedValue = parseDateLike(String(boundaryValue));
25928      return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25929    }
25930    function isValidMinDate(item, field) {
25931      return validateDateLikeBoundary(item, field, "min");
25932    }
25933    function isValidMaxDate(item, field) {
25934      return validateDateLikeBoundary(item, field, "max");
25935    }
25936  
25937    // packages/dataviews/build-module/field-types/datetime.mjs
25938    var format4 = {
25939      datetime: (0, import_date7.getSettings)().formats.datetime,
25940      weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25941    };
25942    function getValueFormatted4({
25943      item,
25944      field
25945    }) {
25946      const value = field.getValue({ item });
25947      if (["", void 0, null].includes(value)) {
25948        return "";
25949      }
25950      let formatDatetime;
25951      if (field.type !== "datetime") {
25952        formatDatetime = format4;
25953      } else {
25954        formatDatetime = field.format;
25955      }
25956      return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25957    }
25958    var sort = (a2, b2, direction) => {
25959      const timeA = new Date(a2).getTime();
25960      const timeB = new Date(b2).getTime();
25961      return direction === "asc" ? timeA - timeB : timeB - timeA;
25962    };
25963    var datetime_default = {
25964      type: "datetime",
25965      render,
25966      Edit: "datetime",
25967      sort,
25968      enableSorting: true,
25969      enableGlobalSearch: false,
25970      defaultOperators: [
25971        OPERATOR_ON,
25972        OPERATOR_NOT_ON,
25973        OPERATOR_BEFORE,
25974        OPERATOR_AFTER,
25975        OPERATOR_BEFORE_INC,
25976        OPERATOR_AFTER_INC,
25977        OPERATOR_IN_THE_PAST,
25978        OPERATOR_OVER
25979      ],
25980      validOperators: [
25981        OPERATOR_ON,
25982        OPERATOR_NOT_ON,
25983        OPERATOR_BEFORE,
25984        OPERATOR_AFTER,
25985        OPERATOR_BEFORE_INC,
25986        OPERATOR_AFTER_INC,
25987        OPERATOR_IN_THE_PAST,
25988        OPERATOR_OVER
25989      ],
25990      format: format4,
25991      getValueFormatted: getValueFormatted4,
25992      validate: {
25993        required: isValidRequired,
25994        elements: isValidElements,
25995        min: isValidMinDate,
25996        max: isValidMaxDate
25997      }
25998    };
25999  
26000    // packages/dataviews/build-module/field-types/date.mjs
26001    var import_date8 = __toESM(require_date(), 1);
26002    var format5 = {
26003      date: (0, import_date8.getSettings)().formats.date,
26004      weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
26005    };
26006    function getValueFormatted5({
26007      item,
26008      field
26009    }) {
26010      const value = field.getValue({ item });
26011      if (["", void 0, null].includes(value)) {
26012        return "";
26013      }
26014      let formatDate2;
26015      if (field.type !== "date") {
26016        formatDate2 = format5;
26017      } else {
26018        formatDate2 = field.format;
26019      }
26020      return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
26021    }
26022    var sort2 = (a2, b2, direction) => {
26023      const timeA = new Date(a2).getTime();
26024      const timeB = new Date(b2).getTime();
26025      return direction === "asc" ? timeA - timeB : timeB - timeA;
26026    };
26027    var date_default = {
26028      type: "date",
26029      render,
26030      Edit: "date",
26031      sort: sort2,
26032      enableSorting: true,
26033      enableGlobalSearch: false,
26034      defaultOperators: [
26035        OPERATOR_ON,
26036        OPERATOR_NOT_ON,
26037        OPERATOR_BEFORE,
26038        OPERATOR_AFTER,
26039        OPERATOR_BEFORE_INC,
26040        OPERATOR_AFTER_INC,
26041        OPERATOR_IN_THE_PAST,
26042        OPERATOR_OVER,
26043        OPERATOR_BETWEEN
26044      ],
26045      validOperators: [
26046        OPERATOR_ON,
26047        OPERATOR_NOT_ON,
26048        OPERATOR_BEFORE,
26049        OPERATOR_AFTER,
26050        OPERATOR_BEFORE_INC,
26051        OPERATOR_AFTER_INC,
26052        OPERATOR_IN_THE_PAST,
26053        OPERATOR_OVER,
26054        OPERATOR_BETWEEN
26055      ],
26056      format: format5,
26057      getValueFormatted: getValueFormatted5,
26058      validate: {
26059        required: isValidRequired,
26060        elements: isValidElements,
26061        min: isValidMinDate,
26062        max: isValidMaxDate
26063      }
26064    };
26065  
26066    // packages/dataviews/build-module/field-types/boolean.mjs
26067    var import_i18n48 = __toESM(require_i18n(), 1);
26068  
26069    // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
26070    function isValidRequiredForBool(item, field) {
26071      const value = field.getValue({ item });
26072      return value === true;
26073    }
26074  
26075    // packages/dataviews/build-module/field-types/boolean.mjs
26076    function getValueFormatted6({
26077      item,
26078      field
26079    }) {
26080      const value = field.getValue({ item });
26081      if (value === true) {
26082        return (0, import_i18n48.__)("True");
26083      }
26084      if (value === false) {
26085        return (0, import_i18n48.__)("False");
26086      }
26087      return "";
26088    }
26089    function isValidCustom4(item, field) {
26090      const value = field.getValue({ item });
26091      if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
26092        return (0, import_i18n48.__)("Value must be true, false, or undefined");
26093      }
26094      return null;
26095    }
26096    var sort3 = (a2, b2, direction) => {
26097      const boolA = Boolean(a2);
26098      const boolB = Boolean(b2);
26099      if (boolA === boolB) {
26100        return 0;
26101      }
26102      if (direction === "asc") {
26103        return boolA ? 1 : -1;
26104      }
26105      return boolA ? -1 : 1;
26106    };
26107    var boolean_default = {
26108      type: "boolean",
26109      render,
26110      Edit: "checkbox",
26111      sort: sort3,
26112      validate: {
26113        required: isValidRequiredForBool,
26114        elements: isValidElements,
26115        custom: isValidCustom4
26116      },
26117      enableSorting: true,
26118      enableGlobalSearch: false,
26119      defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26120      validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26121      format: {},
26122      getValueFormatted: getValueFormatted6
26123    };
26124  
26125    // packages/dataviews/build-module/field-types/media.mjs
26126    var media_default = {
26127      type: "media",
26128      render: () => null,
26129      Edit: null,
26130      sort: () => 0,
26131      enableSorting: false,
26132      enableGlobalSearch: false,
26133      defaultOperators: [],
26134      validOperators: [],
26135      format: {},
26136      getValueFormatted: get_value_formatted_default_default,
26137      // cannot validate any constraint, so
26138      // the only available validation for the field author
26139      // would be providing a custom validator.
26140      validate: {}
26141    };
26142  
26143    // packages/dataviews/build-module/field-types/array.mjs
26144    var import_i18n49 = __toESM(require_i18n(), 1);
26145  
26146    // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
26147    function isValidRequiredForArray(item, field) {
26148      const value = field.getValue({ item });
26149      return Array.isArray(value) && value.length > 0 && value.every(
26150        (element) => ![void 0, "", null].includes(element)
26151      );
26152    }
26153  
26154    // packages/dataviews/build-module/field-types/array.mjs
26155    function getValueFormatted7({
26156      item,
26157      field
26158    }) {
26159      const value = field.getValue({ item });
26160      const arr = Array.isArray(value) ? value : [];
26161      return arr.join(", ");
26162    }
26163    function render2({ item, field }) {
26164      return getValueFormatted7({ item, field });
26165    }
26166    function isValidCustom5(item, field) {
26167      const value = field.getValue({ item });
26168      if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
26169        return (0, import_i18n49.__)("Value must be an array.");
26170      }
26171      if (!value.every((v2) => typeof v2 === "string")) {
26172        return (0, import_i18n49.__)("Every value must be a string.");
26173      }
26174      return null;
26175    }
26176    var sort4 = (a2, b2, direction) => {
26177      const arrA = Array.isArray(a2) ? a2 : [];
26178      const arrB = Array.isArray(b2) ? b2 : [];
26179      if (arrA.length !== arrB.length) {
26180        return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
26181      }
26182      const joinedA = arrA.join(",");
26183      const joinedB = arrB.join(",");
26184      return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
26185    };
26186    var array_default = {
26187      type: "array",
26188      render: render2,
26189      Edit: "array",
26190      sort: sort4,
26191      enableSorting: true,
26192      enableGlobalSearch: false,
26193      defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26194      validOperators: [
26195        OPERATOR_IS_ANY,
26196        OPERATOR_IS_NONE,
26197        OPERATOR_IS_ALL,
26198        OPERATOR_IS_NOT_ALL
26199      ],
26200      format: {},
26201      getValueFormatted: getValueFormatted7,
26202      validate: {
26203        required: isValidRequiredForArray,
26204        elements: isValidElements,
26205        custom: isValidCustom5
26206      }
26207    };
26208  
26209    // packages/dataviews/build-module/field-types/password.mjs
26210    function getValueFormatted8({
26211      item,
26212      field
26213    }) {
26214      return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
26215    }
26216    var password_default = {
26217      type: "password",
26218      render,
26219      Edit: "password",
26220      sort: () => 0,
26221      // Passwords should not be sortable for security reasons
26222      enableSorting: false,
26223      enableGlobalSearch: false,
26224      defaultOperators: [],
26225      validOperators: [],
26226      format: {},
26227      getValueFormatted: getValueFormatted8,
26228      validate: {
26229        required: isValidRequired,
26230        pattern: isValidPattern,
26231        minLength: isValidMinLength,
26232        maxLength: isValidMaxLength,
26233        elements: isValidElements
26234      }
26235    };
26236  
26237    // packages/dataviews/build-module/field-types/telephone.mjs
26238    var telephone_default = {
26239      type: "telephone",
26240      render,
26241      Edit: "telephone",
26242      sort: sort_text_default,
26243      enableSorting: true,
26244      enableGlobalSearch: false,
26245      defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26246      validOperators: [
26247        OPERATOR_IS,
26248        OPERATOR_IS_NOT,
26249        OPERATOR_CONTAINS,
26250        OPERATOR_NOT_CONTAINS,
26251        OPERATOR_STARTS_WITH,
26252        // Multiple selection
26253        OPERATOR_IS_ANY,
26254        OPERATOR_IS_NONE,
26255        OPERATOR_IS_ALL,
26256        OPERATOR_IS_NOT_ALL
26257      ],
26258      format: {},
26259      getValueFormatted: get_value_formatted_default_default,
26260      validate: {
26261        required: isValidRequired,
26262        pattern: isValidPattern,
26263        minLength: isValidMinLength,
26264        maxLength: isValidMaxLength,
26265        elements: isValidElements
26266      }
26267    };
26268  
26269    // packages/dataviews/build-module/field-types/color.mjs
26270    var import_i18n50 = __toESM(require_i18n(), 1);
26271    var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
26272    function render3({ item, field }) {
26273      if (field.hasElements) {
26274        return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(RenderFromElements, { item, field });
26275      }
26276      const value = get_value_formatted_default_default({ item, field });
26277      if (!value || !w(value).isValid()) {
26278        return value;
26279      }
26280      return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
26281        /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26282          "div",
26283          {
26284            style: {
26285              width: "16px",
26286              height: "16px",
26287              borderRadius: "50%",
26288              backgroundColor: value,
26289              border: "1px solid #ddd",
26290              flexShrink: 0
26291            }
26292          }
26293        ),
26294        /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("span", { children: value })
26295      ] });
26296    }
26297    function isValidCustom6(item, field) {
26298      const value = field.getValue({ item });
26299      if (![void 0, "", null].includes(value) && !w(value).isValid()) {
26300        return (0, import_i18n50.__)("Value must be a valid color.");
26301      }
26302      return null;
26303    }
26304    var sort5 = (a2, b2, direction) => {
26305      const colorA = w(a2);
26306      const colorB = w(b2);
26307      if (!colorA.isValid() && !colorB.isValid()) {
26308        return 0;
26309      }
26310      if (!colorA.isValid()) {
26311        return direction === "asc" ? 1 : -1;
26312      }
26313      if (!colorB.isValid()) {
26314        return direction === "asc" ? -1 : 1;
26315      }
26316      const hslA = colorA.toHsl();
26317      const hslB = colorB.toHsl();
26318      if (hslA.h !== hslB.h) {
26319        return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
26320      }
26321      if (hslA.s !== hslB.s) {
26322        return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
26323      }
26324      return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
26325    };
26326    var color_default = {
26327      type: "color",
26328      render: render3,
26329      Edit: "color",
26330      sort: sort5,
26331      enableSorting: true,
26332      enableGlobalSearch: false,
26333      defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26334      validOperators: [
26335        OPERATOR_IS,
26336        OPERATOR_IS_NOT,
26337        OPERATOR_IS_ANY,
26338        OPERATOR_IS_NONE
26339      ],
26340      format: {},
26341      getValueFormatted: get_value_formatted_default_default,
26342      validate: {
26343        required: isValidRequired,
26344        elements: isValidElements,
26345        custom: isValidCustom6
26346      }
26347    };
26348  
26349    // packages/dataviews/build-module/field-types/url.mjs
26350    var url_default = {
26351      type: "url",
26352      render,
26353      Edit: "url",
26354      sort: sort_text_default,
26355      enableSorting: true,
26356      enableGlobalSearch: false,
26357      defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26358      validOperators: [
26359        OPERATOR_IS,
26360        OPERATOR_IS_NOT,
26361        OPERATOR_CONTAINS,
26362        OPERATOR_NOT_CONTAINS,
26363        OPERATOR_STARTS_WITH,
26364        // Multiple selection
26365        OPERATOR_IS_ANY,
26366        OPERATOR_IS_NONE,
26367        OPERATOR_IS_ALL,
26368        OPERATOR_IS_NOT_ALL
26369      ],
26370      format: {},
26371      getValueFormatted: get_value_formatted_default_default,
26372      validate: {
26373        required: isValidRequired,
26374        pattern: isValidPattern,
26375        minLength: isValidMinLength,
26376        maxLength: isValidMaxLength,
26377        elements: isValidElements
26378      }
26379    };
26380  
26381    // packages/dataviews/build-module/field-types/no-type.mjs
26382    var sort6 = (a2, b2, direction) => {
26383      if (typeof a2 === "number" && typeof b2 === "number") {
26384        return sort_number_default(a2, b2, direction);
26385      }
26386      return sort_text_default(a2, b2, direction);
26387    };
26388    var no_type_default = {
26389      // type: no type for this one
26390      render,
26391      Edit: null,
26392      sort: sort6,
26393      enableSorting: true,
26394      enableGlobalSearch: false,
26395      defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26396      validOperators: getAllOperatorNames(),
26397      format: {},
26398      getValueFormatted: get_value_formatted_default_default,
26399      validate: {
26400        required: isValidRequired,
26401        elements: isValidElements
26402      }
26403    };
26404  
26405    // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
26406    function supportsNumericRangeConstraint(type) {
26407      return type === "integer" || type === "number";
26408    }
26409    function supportsDateRangeConstraint(type) {
26410      return type === "date" || type === "datetime";
26411    }
26412    function normalizeRangeRule(value, fieldType, key) {
26413      const validator = fieldType.validate[key];
26414      if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
26415        return { constraint: value, validate: validator };
26416      }
26417      return void 0;
26418    }
26419    function getIsValid(field, fieldType) {
26420      const rules = field.isValid;
26421      let required;
26422      if (rules?.required === true && fieldType.validate.required !== void 0) {
26423        required = {
26424          constraint: true,
26425          validate: fieldType.validate.required
26426        };
26427      }
26428      let elements;
26429      if ((rules?.elements === true || // elements is enabled unless the field opts-out
26430      rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
26431        elements = {
26432          constraint: true,
26433          validate: fieldType.validate.elements
26434        };
26435      }
26436      const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
26437      const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
26438      const minLengthValue = rules?.minLength;
26439      let minLength;
26440      if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
26441        minLength = {
26442          constraint: minLengthValue,
26443          validate: fieldType.validate.minLength
26444        };
26445      }
26446      const maxLengthValue = rules?.maxLength;
26447      let maxLength;
26448      if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
26449        maxLength = {
26450          constraint: maxLengthValue,
26451          validate: fieldType.validate.maxLength
26452        };
26453      }
26454      const patternValue = rules?.pattern;
26455      let pattern;
26456      if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
26457        pattern = {
26458          constraint: patternValue,
26459          validate: fieldType.validate.pattern
26460        };
26461      }
26462      const custom = rules?.custom ?? fieldType.validate.custom;
26463      return {
26464        required,
26465        elements,
26466        min: min2,
26467        max: max2,
26468        minLength,
26469        maxLength,
26470        pattern,
26471        custom
26472      };
26473    }
26474  
26475    // packages/dataviews/build-module/field-types/utils/get-filter.mjs
26476    function getFilter(fieldType) {
26477      return fieldType.validOperators.reduce((accumulator, operator) => {
26478        const operatorObj = getOperatorByName(operator);
26479        if (operatorObj?.filter) {
26480          accumulator[operator] = operatorObj.filter;
26481        }
26482        return accumulator;
26483      }, {});
26484    }
26485  
26486    // packages/dataviews/build-module/field-types/utils/get-format.mjs
26487    function getFormat(field, fieldType) {
26488      return {
26489        ...fieldType.format,
26490        ...field.format
26491      };
26492    }
26493    var get_format_default = getFormat;
26494  
26495    // packages/dataviews/build-module/field-types/index.mjs
26496    function getFieldTypeByName(type) {
26497      const found = [
26498        email_default,
26499        integer_default,
26500        number_default,
26501        text_default,
26502        datetime_default,
26503        date_default,
26504        boolean_default,
26505        media_default,
26506        array_default,
26507        password_default,
26508        telephone_default,
26509        color_default,
26510        url_default
26511      ].find((fieldType) => fieldType?.type === type);
26512      if (!!found) {
26513        return found;
26514      }
26515      return no_type_default;
26516    }
26517    function normalizeFields(fields) {
26518      return fields.map((field) => {
26519        const fieldType = getFieldTypeByName(field.type);
26520        const getValue = field.getValue || get_value_from_id_default(field.id);
26521        const sort7 = function(a2, b2, direction) {
26522          const aValue = getValue({ item: a2 });
26523          const bValue = getValue({ item: b2 });
26524          return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
26525        };
26526        return {
26527          id: field.id,
26528          label: field.label || field.id,
26529          header: field.header || field.label || field.id,
26530          description: field.description,
26531          placeholder: field.placeholder,
26532          getValue,
26533          setValue: field.setValue || set_value_from_id_default(field.id),
26534          elements: field.elements,
26535          getElements: field.getElements,
26536          hasElements: hasElements(field),
26537          isVisible: field.isVisible,
26538          isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
26539          enableHiding: field.enableHiding ?? true,
26540          readOnly: field.readOnly ?? false,
26541          // The type provides defaults for the following props
26542          type: fieldType.type,
26543          render: field.render ?? fieldType.render,
26544          Edit: getControl(field, fieldType.Edit),
26545          sort: sort7,
26546          enableSorting: field.enableSorting ?? fieldType.enableSorting,
26547          enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
26548          isValid: getIsValid(field, fieldType),
26549          filterBy: get_filter_by_default(
26550            field,
26551            fieldType.defaultOperators,
26552            fieldType.validOperators
26553          ),
26554          filter: getFilter(fieldType),
26555          format: get_format_default(field, fieldType),
26556          getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
26557        };
26558      });
26559    }
26560  
26561    // packages/dataviews/build-module/hooks/use-data.mjs
26562    var import_element75 = __toESM(require_element(), 1);
26563    function useData({
26564      view,
26565      data: shownData,
26566      getItemId,
26567      isLoading,
26568      paginationInfo,
26569      selection
26570    }) {
26571      const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
26572      const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element75.useState)(
26573        !isLoading
26574      );
26575      (0, import_element75.useEffect)(() => {
26576        if (!isLoading) {
26577          setHasInitiallyLoaded(true);
26578        }
26579      }, [isLoading]);
26580      const previousDataRef = (0, import_element75.useRef)(shownData);
26581      const previousPaginationInfoRef = (0, import_element75.useRef)(paginationInfo);
26582      (0, import_element75.useEffect)(() => {
26583        if (!isLoading) {
26584          previousDataRef.current = shownData;
26585          previousPaginationInfoRef.current = paginationInfo;
26586        }
26587      }, [shownData, isLoading, paginationInfo]);
26588      const [visibleEntries, setVisibleEntries] = (0, import_element75.useState)([]);
26589      const positionMapRef = (0, import_element75.useRef)(/* @__PURE__ */ new Map());
26590      const allLoadedRecordsRef = (0, import_element75.useRef)([]);
26591      const prevViewParamsRef = (0, import_element75.useRef)({
26592        search: void 0,
26593        filters: void 0,
26594        perPage: void 0
26595      });
26596      const scrollDirectionRef = (0, import_element75.useRef)(void 0);
26597      const prevStartPositionRef = (0, import_element75.useRef)(void 0);
26598      const hasInitializedRef = (0, import_element75.useRef)(false);
26599      const allLoadedRecords = (0, import_element75.useMemo)(() => {
26600        if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
26601          if (view.startPosition < prevStartPositionRef.current) {
26602            scrollDirectionRef.current = "up";
26603          } else if (view.startPosition > prevStartPositionRef.current) {
26604            scrollDirectionRef.current = "down";
26605          }
26606        }
26607        prevStartPositionRef.current = view.startPosition;
26608        const currentFiltersKey = JSON.stringify(view.filters ?? []);
26609        const prevFiltersKey = prevViewParamsRef.current.filters;
26610        const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
26611        hasInitializedRef.current = true;
26612        prevViewParamsRef.current = {
26613          search: view.search,
26614          filters: currentFiltersKey,
26615          perPage: view.perPage
26616        };
26617        if (shouldReset) {
26618          positionMapRef.current.clear();
26619          scrollDirectionRef.current = void 0;
26620          const startPosition = view.search ? 1 : view.startPosition ?? 1;
26621          const records = shownData.map((record, index2) => {
26622            const position = startPosition + index2;
26623            positionMapRef.current.set(getItemId(record), position);
26624            return {
26625              ...record,
26626              position
26627            };
26628          });
26629          allLoadedRecordsRef.current = records;
26630          return records;
26631        }
26632        const prev = allLoadedRecordsRef.current;
26633        const shownDataIds = new Set(shownData.map(getItemId));
26634        const scrollDirection = scrollDirectionRef.current;
26635        const basePosition = view.search ? 1 : view.startPosition ?? 1;
26636        const newRecords = shownData.map((record, index2) => {
26637          const itemId = getItemId(record);
26638          const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
26639          if (position !== void 0) {
26640            positionMapRef.current.set(itemId, position);
26641          }
26642          return {
26643            ...record,
26644            position
26645          };
26646        });
26647        if (newRecords.length === 0) {
26648          return prev;
26649        }
26650        const prevWithoutDuplicates = prev.filter(
26651          (record) => !shownDataIds.has(getItemId(record))
26652        );
26653        const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
26654        allRecords.sort((a2, b2) => {
26655          const posA = a2.position;
26656          const posB = b2.position;
26657          return posA - posB;
26658        });
26659        let result = allRecords;
26660        if (visibleEntries.length > 0) {
26661          const visibleMin = Math.min(...visibleEntries);
26662          const visibleMax = Math.max(...visibleEntries);
26663          const buffer = 20;
26664          const recordPositions = allRecords.map(
26665            (r3) => r3.position
26666          );
26667          const minRecordPos = Math.min(...recordPositions);
26668          const maxRecordPos = Math.max(...recordPositions);
26669          const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
26670          if (hasOverlap) {
26671            result = allRecords.filter((record) => {
26672              const itemId = getItemId(record);
26673              const isSelected2 = selection?.includes(itemId);
26674              if (isSelected2) {
26675                return true;
26676              }
26677              const itemPosition = record.position;
26678              if (scrollDirection === "up") {
26679                return itemPosition <= visibleMax + buffer;
26680              } else if (scrollDirection === "down") {
26681                return itemPosition >= visibleMin - buffer;
26682              }
26683              return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
26684            });
26685          }
26686        }
26687        allLoadedRecordsRef.current = result;
26688        return result;
26689      }, [
26690        shownData,
26691        view.search,
26692        view.filters,
26693        view.perPage,
26694        view.startPosition,
26695        view.infiniteScrollEnabled,
26696        visibleEntries,
26697        selection,
26698        getItemId
26699      ]);
26700      if (!isInfiniteScrollEnabled) {
26701        const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
26702        return {
26703          data: dataToReturn.map((item) => ({
26704            ...item,
26705            position: void 0
26706          })),
26707          paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
26708          hasInitiallyLoaded,
26709          setVisibleEntries: void 0
26710        };
26711      }
26712      return {
26713        data: allLoadedRecords,
26714        paginationInfo,
26715        hasInitiallyLoaded,
26716        setVisibleEntries
26717      };
26718    }
26719  
26720    // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
26721    var import_element76 = __toESM(require_element(), 1);
26722    var import_compose13 = __toESM(require_compose(), 1);
26723    function captureAnchorElement(container, anchorElementRef, direction) {
26724      const containerRect = container.getBoundingClientRect();
26725      const centerY = containerRect.top + containerRect.height / 2;
26726      const items = Array.from(container.querySelectorAll("[aria-posinset]"));
26727      if (items.length === 0) {
26728        return false;
26729      }
26730      const bestAnchor = items.reduce((best, item) => {
26731        const itemRect = item.getBoundingClientRect();
26732        const itemCenterY = itemRect.top + itemRect.height / 2;
26733        const distance = Math.abs(itemCenterY - centerY);
26734        const bestRect = best.getBoundingClientRect();
26735        const bestCenterY = bestRect.top + bestRect.height / 2;
26736        const bestDistance = Math.abs(bestCenterY - centerY);
26737        return distance < bestDistance ? item : best;
26738      });
26739      const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
26740      const anchorRect = bestAnchor.getBoundingClientRect();
26741      anchorElementRef.current = {
26742        posinset,
26743        viewportOffset: anchorRect.top - containerRect.top,
26744        scrollTop: container.scrollTop,
26745        direction
26746      };
26747      return true;
26748    }
26749    function useInfiniteScroll({
26750      view,
26751      onChangeView,
26752      isLoading,
26753      paginationInfo,
26754      containerRef,
26755      setVisibleEntries
26756    }) {
26757      const anchorElementRef = (0, import_element76.useRef)(null);
26758      const viewRef = (0, import_element76.useRef)(view);
26759      const isLoadingRef = (0, import_element76.useRef)(isLoading);
26760      const onChangeViewRef = (0, import_element76.useRef)(onChangeView);
26761      const totalItemsRef = (0, import_element76.useRef)(paginationInfo.totalItems);
26762      (0, import_element76.useLayoutEffect)(() => {
26763        viewRef.current = view;
26764        isLoadingRef.current = isLoading;
26765        onChangeViewRef.current = onChangeView;
26766        totalItemsRef.current = paginationInfo.totalItems;
26767      }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
26768      const intersectionObserverCallback = (0, import_element76.useCallback)(
26769        (entries) => {
26770          if (!setVisibleEntries) {
26771            return;
26772          }
26773          setVisibleEntries((prev) => {
26774            const newVisibleEntries = new Set(prev);
26775            let hasChanged = false;
26776            entries.forEach((entry) => {
26777              const posInSet = Number(
26778                entry.target?.attributes?.getNamedItem(
26779                  "aria-posinset"
26780                )?.value
26781              );
26782              if (isNaN(posInSet)) {
26783                return;
26784              }
26785              if (entry.isIntersecting) {
26786                if (!newVisibleEntries.has(posInSet)) {
26787                  newVisibleEntries.add(posInSet);
26788                  hasChanged = true;
26789                }
26790              } else if (newVisibleEntries.has(posInSet)) {
26791                newVisibleEntries.delete(posInSet);
26792                hasChanged = true;
26793              }
26794            });
26795            return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
26796          });
26797        },
26798        [setVisibleEntries]
26799      );
26800      (0, import_element76.useLayoutEffect)(() => {
26801        const container = containerRef.current;
26802        const anchor = anchorElementRef.current;
26803        if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
26804          return;
26805        }
26806        const anchorElement = container.querySelector(
26807          `[aria-posinset="$anchor.posinset}"]`
26808        );
26809        if (anchorElement) {
26810          const containerRect = container.getBoundingClientRect();
26811          const anchorRect = anchorElement.getBoundingClientRect();
26812          const currentOffset = anchorRect.top - containerRect.top;
26813          const scrollAdjustment = currentOffset - anchor.viewportOffset + (container.scrollTop - anchor.scrollTop);
26814          if (Math.abs(scrollAdjustment) > 1) {
26815            container.scrollTop += scrollAdjustment;
26816          }
26817        }
26818        anchorElementRef.current = null;
26819      }, [containerRef, isLoading, view.infiniteScrollEnabled]);
26820      const intersectionObserverRef = (0, import_element76.useRef)(
26821        null
26822      );
26823      (0, import_element76.useEffect)(() => {
26824        if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
26825          if (intersectionObserverRef.current) {
26826            intersectionObserverRef.current.disconnect();
26827            intersectionObserverRef.current = null;
26828          }
26829          return;
26830        }
26831        intersectionObserverRef.current = new IntersectionObserver(
26832          intersectionObserverCallback,
26833          { root: null, rootMargin: "0px", threshold: 0.1 }
26834        );
26835        return () => {
26836          if (intersectionObserverRef.current) {
26837            intersectionObserverRef.current.disconnect();
26838            intersectionObserverRef.current = null;
26839          }
26840        };
26841      }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
26842      (0, import_element76.useEffect)(() => {
26843        if (!view.infiniteScrollEnabled || !containerRef.current) {
26844          return;
26845        }
26846        let lastScrollTop = 0;
26847        const BOTTOM_THRESHOLD = 600;
26848        const TOP_THRESHOLD = 800;
26849        const handleScroll = (0, import_compose13.throttle)((event) => {
26850          const currentView = viewRef.current;
26851          const totalItems = totalItemsRef.current;
26852          const target = event.target;
26853          const scrollTop = target.scrollTop;
26854          const scrollHeight = target.scrollHeight;
26855          const clientHeight = target.clientHeight;
26856          const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
26857          lastScrollTop = scrollTop;
26858          if (isLoadingRef.current) {
26859            return;
26860          }
26861          const currentStartPosition = currentView.startPosition || 1;
26862          const batchSize = currentView.perPage || 10;
26863          const currentEndPosition = Math.min(
26864            currentStartPosition + batchSize,
26865            totalItems
26866          );
26867          if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
26868            if (currentEndPosition < totalItems) {
26869              const newStartPosition = currentEndPosition;
26870              captureAnchorElement(target, anchorElementRef, "down");
26871              onChangeViewRef.current({
26872                ...currentView,
26873                startPosition: newStartPosition
26874              });
26875            }
26876          }
26877          if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
26878            if (currentStartPosition > 1) {
26879              const calculatedStartPosition = currentStartPosition - batchSize;
26880              const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
26881              captureAnchorElement(target, anchorElementRef, "up");
26882              onChangeViewRef.current({
26883                ...currentView,
26884                startPosition: newStartPosition
26885              });
26886            }
26887          }
26888        }, 50);
26889        const container = containerRef.current;
26890        container.addEventListener("scroll", handleScroll);
26891        return () => {
26892          container.removeEventListener("scroll", handleScroll);
26893          handleScroll.cancel();
26894        };
26895      }, [containerRef, view.infiniteScrollEnabled]);
26896      return {
26897        intersectionObserver: intersectionObserverRef.current
26898      };
26899    }
26900  
26901    // packages/dataviews/build-module/dataviews-picker/index.mjs
26902    var import_element77 = __toESM(require_element(), 1);
26903    var import_compose14 = __toESM(require_compose(), 1);
26904    var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
26905    var isItemClickable = () => false;
26906    var dataViewsPickerLayouts = VIEW_LAYOUTS.filter(
26907      (viewLayout) => viewLayout.isPicker
26908    );
26909    var defaultGetItemId = (item) => item.id;
26910    var EMPTY_ARRAY6 = [];
26911    var DEFAULT_PICKER_LAYOUTS = {
26912      pickerGrid: true,
26913      pickerTable: true
26914    };
26915    function DefaultUI({
26916      search = true,
26917      searchLabel = void 0
26918    }) {
26919      const { view } = (0, import_element77.useContext)(dataviews_context_default);
26920      const isInfiniteScroll = view.infiniteScrollEnabled;
26921      return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_jsx_runtime120.Fragment, { children: [
26922        /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(
26923          Stack,
26924          {
26925            direction: "row",
26926            align: "top",
26927            justify: "space-between",
26928            className: clsx_default("dataviews__view-actions", {
26929              "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26930            }),
26931            gap: "xs",
26932            children: [
26933              /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(
26934                Stack,
26935                {
26936                  direction: "row",
26937                  gap: "sm",
26938                  justify: "start",
26939                  className: "dataviews__search",
26940                  children: [
26941                    search && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(dataviews_search_default, { label: searchLabel }),
26942                    /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(toggle_default, {})
26943                  ]
26944                }
26945              ),
26946              /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(dataviews_view_config_default, {}) })
26947            ]
26948          }
26949        ),
26950        /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26951        /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(DataViewsLayout, {}),
26952        /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(DataViewsPickerFooter, {})
26953      ] });
26954    }
26955    function DataViewsPicker({
26956      view,
26957      onChangeView,
26958      fields,
26959      search = true,
26960      searchLabel = void 0,
26961      actions = EMPTY_ARRAY6,
26962      data,
26963      getItemId = defaultGetItemId,
26964      isLoading = false,
26965      paginationInfo,
26966      defaultLayouts: defaultLayoutsProperty = DEFAULT_PICKER_LAYOUTS,
26967      selection,
26968      onChangeSelection,
26969      children,
26970      config = { perPageSizes: [10, 20, 50, 100] },
26971      itemListLabel,
26972      empty,
26973      onReset
26974    }) {
26975      const { data: displayData, setVisibleEntries } = useData({
26976        view,
26977        data,
26978        getItemId,
26979        selection,
26980        paginationInfo
26981      });
26982      const containerRef = (0, import_element77.useRef)(null);
26983      const [containerWidth, setContainerWidth] = (0, import_element77.useState)(0);
26984      const resizeObserverRef = (0, import_compose14.useResizeObserver)(
26985        (resizeObserverEntries) => {
26986          setContainerWidth(
26987            resizeObserverEntries[0].borderBoxSize[0].inlineSize
26988          );
26989        },
26990        { box: "border-box" }
26991      );
26992      const [openedFilter, setOpenedFilter] = (0, import_element77.useState)(null);
26993      function setSelectionWithChange(value) {
26994        const newValue = typeof value === "function" ? value(selection) : value;
26995        if (onChangeSelection) {
26996          onChangeSelection(newValue);
26997        }
26998      }
26999      const _fields = (0, import_element77.useMemo)(() => normalizeFields(fields), [fields]);
27000      const filters = use_filters_default(_fields, view);
27001      const hasPrimaryOrLockedFilters = (0, import_element77.useMemo)(
27002        () => (filters || []).some(
27003          (filter) => filter.isPrimary || filter.isLocked
27004        ),
27005        [filters]
27006      );
27007      const [isShowingFilter, setIsShowingFilter] = (0, import_element77.useState)(
27008        hasPrimaryOrLockedFilters
27009      );
27010      const { intersectionObserver } = useInfiniteScroll({
27011        view,
27012        onChangeView,
27013        isLoading,
27014        paginationInfo,
27015        containerRef,
27016        setVisibleEntries
27017      });
27018      (0, import_element77.useEffect)(() => {
27019        if (hasPrimaryOrLockedFilters && !isShowingFilter) {
27020          setIsShowingFilter(true);
27021        }
27022      }, [hasPrimaryOrLockedFilters, isShowingFilter]);
27023      const defaultLayouts2 = (0, import_element77.useMemo)(
27024        () => Object.fromEntries(
27025          Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
27026            return dataViewsPickerLayouts.some(
27027              (viewLayout) => viewLayout.type === layoutType
27028            );
27029          }).map(([key, value]) => [
27030            key,
27031            value === true ? {} : value
27032          ])
27033        ),
27034        [defaultLayoutsProperty]
27035      );
27036      if (!defaultLayouts2[view.type]) {
27037        return null;
27038      }
27039      return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
27040        dataviews_context_default.Provider,
27041        {
27042          value: {
27043            view,
27044            onChangeView,
27045            fields: _fields,
27046            actions,
27047            data: displayData,
27048            isLoading,
27049            paginationInfo,
27050            isItemClickable,
27051            selection,
27052            onChangeSelection: setSelectionWithChange,
27053            openedFilter,
27054            setOpenedFilter,
27055            getItemId,
27056            containerWidth,
27057            containerRef,
27058            resizeObserverRef,
27059            defaultLayouts: defaultLayouts2,
27060            filters,
27061            isShowingFilter,
27062            setIsShowingFilter,
27063            config,
27064            itemListLabel,
27065            empty,
27066            onReset,
27067            hasInitiallyLoaded: true,
27068            intersectionObserver
27069          },
27070          children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("div", { className: "dataviews-picker-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(DefaultUI, { search, searchLabel }) })
27071        }
27072      );
27073    }
27074    var DataViewsPickerSubComponents = DataViewsPicker;
27075    DataViewsPickerSubComponents.BulkActionToolbar = DataViewsPickerBulkActionToolbar;
27076    DataViewsPickerSubComponents.Footer = DataViewsPickerFooter;
27077    DataViewsPickerSubComponents.Filters = filters_default;
27078    DataViewsPickerSubComponents.FiltersToggled = filters_toggled_default;
27079    DataViewsPickerSubComponents.FiltersToggle = toggle_default;
27080    DataViewsPickerSubComponents.Layout = DataViewsLayout;
27081    DataViewsPickerSubComponents.LayoutSwitcher = ViewTypeMenu;
27082    DataViewsPickerSubComponents.Pagination = DataViewsPagination;
27083    DataViewsPickerSubComponents.Search = dataviews_search_default;
27084    DataViewsPickerSubComponents.ViewConfig = DataviewsViewConfigDropdown;
27085    var dataviews_picker_default = DataViewsPickerSubComponents;
27086  
27087    // node_modules/dequal/dist/index.mjs
27088    var has = Object.prototype.hasOwnProperty;
27089    function find(iter, tar, key) {
27090      for (key of iter.keys()) {
27091        if (dequal(key, tar)) return key;
27092      }
27093    }
27094    function dequal(foo, bar) {
27095      var ctor, len, tmp;
27096      if (foo === bar) return true;
27097      if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
27098        if (ctor === Date) return foo.getTime() === bar.getTime();
27099        if (ctor === RegExp) return foo.toString() === bar.toString();
27100        if (ctor === Array) {
27101          if ((len = foo.length) === bar.length) {
27102            while (len-- && dequal(foo[len], bar[len])) ;
27103          }
27104          return len === -1;
27105        }
27106        if (ctor === Set) {
27107          if (foo.size !== bar.size) {
27108            return false;
27109          }
27110          for (len of foo) {
27111            tmp = len;
27112            if (tmp && typeof tmp === "object") {
27113              tmp = find(bar, tmp);
27114              if (!tmp) return false;
27115            }
27116            if (!bar.has(tmp)) return false;
27117          }
27118          return true;
27119        }
27120        if (ctor === Map) {
27121          if (foo.size !== bar.size) {
27122            return false;
27123          }
27124          for (len of foo) {
27125            tmp = len[0];
27126            if (tmp && typeof tmp === "object") {
27127              tmp = find(bar, tmp);
27128              if (!tmp) return false;
27129            }
27130            if (!dequal(len[1], bar.get(tmp))) {
27131              return false;
27132            }
27133          }
27134          return true;
27135        }
27136        if (ctor === ArrayBuffer) {
27137          foo = new Uint8Array(foo);
27138          bar = new Uint8Array(bar);
27139        } else if (ctor === DataView) {
27140          if ((len = foo.byteLength) === bar.byteLength) {
27141            while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
27142          }
27143          return len === -1;
27144        }
27145        if (ArrayBuffer.isView(foo)) {
27146          if ((len = foo.byteLength) === bar.byteLength) {
27147            while (len-- && foo[len] === bar[len]) ;
27148          }
27149          return len === -1;
27150        }
27151        if (!ctor || typeof foo === "object") {
27152          len = 0;
27153          for (ctor in foo) {
27154            if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
27155            if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
27156          }
27157          return Object.keys(bar).length === len;
27158        }
27159      }
27160      return foo !== foo && bar !== bar;
27161    }
27162  
27163    // packages/views/build-module/use-view.mjs
27164    var import_element78 = __toESM(require_element(), 1);
27165    var import_data7 = __toESM(require_data(), 1);
27166    var import_preferences = __toESM(require_preferences(), 1);
27167  
27168    // packages/views/build-module/preference-keys.mjs
27169    function generatePreferenceKey(kind, name, slug) {
27170      return `dataviews-$kind}-$name}-$slug}`;
27171    }
27172  
27173    // packages/views/build-module/resolve-view.mjs
27174    var QUERY_PARAMS = ["page", "search"];
27175    function isPlainObject2(value) {
27176      return typeof value === "object" && value !== null && !Array.isArray(value);
27177    }
27178    function withoutQueryParams(layer) {
27179      const result = isPlainObject2(layer) ? { ...layer } : {};
27180      for (const key of QUERY_PARAMS) {
27181        delete result[key];
27182      }
27183      return result;
27184    }
27185    function mergeLayer(lower, upper) {
27186      const result = { ...lower };
27187      for (const key of Object.keys(upper)) {
27188        const value = upper[key];
27189        const current = result[key];
27190        result[key] = isPlainObject2(current) && isPlainObject2(value) ? mergeLayer(current, value) : value;
27191      }
27192      return result;
27193    }
27194    function diffLayer(value, base, persisted = {}) {
27195      const result = {};
27196      for (const key of Object.keys(value)) {
27197        const next = value[key];
27198        const current = base[key];
27199        const prev = persisted[key];
27200        if (next === void 0) {
27201          continue;
27202        }
27203        if (isPlainObject2(next) && isPlainObject2(current)) {
27204          const nested = diffLayer(
27205            next,
27206            current,
27207            isPlainObject2(prev) ? prev : {}
27208          );
27209          if (Object.keys(nested).length > 0) {
27210            result[key] = nested;
27211          }
27212        } else if (!dequal(next, current)) {
27213          result[key] = next;
27214        } else if (prev !== void 0 && dequal(next, prev)) {
27215          result[key] = prev;
27216        }
27217      }
27218      return result;
27219    }
27220    function getLockedFilters(overrides) {
27221      return (overrides?.filters ?? []).filter((filter) => filter.isLocked);
27222    }
27223    function applyLockedFilters(view, overrides) {
27224      const locked = getLockedFilters(overrides);
27225      if (locked.length === 0) {
27226        return view;
27227      }
27228      const rest = (view.filters ?? []).filter(
27229        (filter) => !locked.some((f2) => f2.field === filter.field)
27230      );
27231      return { ...view, filters: [...locked, ...rest] };
27232    }
27233    function resolveBaseView(layers, effectiveType) {
27234      const { defaultView: defaultView2, defaultLayouts: defaultLayouts2, activeViewOverrides } = layers;
27235      const layoutDefaults = defaultLayouts2?.[effectiveType];
27236      return applyLockedFilters(
27237        [layoutDefaults, activeViewOverrides].reduce(
27238          (lower, upper) => mergeLayer(lower, withoutQueryParams(upper)),
27239          withoutQueryParams(defaultView2)
27240        ),
27241        activeViewOverrides
27242      );
27243    }
27244    function resolveView(args) {
27245      const { defaultView: defaultView2, activeViewOverrides, persistedView, page, search } = args;
27246      const effectiveType = persistedView?.type ?? activeViewOverrides?.type ?? defaultView2?.type;
27247      const baseView = resolveBaseView(args, effectiveType);
27248      const view = {
27249        ...applyLockedFilters(
27250          mergeLayer(baseView, withoutQueryParams(persistedView)),
27251          activeViewOverrides
27252        ),
27253        page: Number(page ?? 1),
27254        search: search ?? ""
27255      };
27256      return view;
27257    }
27258    function getUserModifications(newView, layers) {
27259      const { activeViewOverrides, persistedView } = layers;
27260      const baseView = resolveBaseView(layers, newView.type);
27261      const modifications = diffLayer(
27262        withoutQueryParams(newView),
27263        withoutQueryParams(baseView),
27264        withoutQueryParams(persistedView)
27265      );
27266      const locked = getLockedFilters(activeViewOverrides);
27267      if (locked.length > 0 && Array.isArray(modifications.filters)) {
27268        modifications.filters = modifications.filters.filter(
27269          (filter) => !locked.some((f2) => f2.field === filter.field)
27270        );
27271      }
27272      return Object.keys(modifications).length > 0 ? modifications : void 0;
27273    }
27274  
27275    // packages/views/build-module/use-view.mjs
27276    function useView(config) {
27277      const {
27278        kind,
27279        name,
27280        slug,
27281        defaultView: defaultView2,
27282        defaultLayouts: defaultLayouts2,
27283        activeViewOverrides,
27284        queryParams,
27285        onChangeQueryParams
27286      } = config;
27287      const preferenceKey = generatePreferenceKey(kind, name, slug);
27288      const persistedView = (0, import_data7.useSelect)(
27289        (select3) => {
27290          return select3(import_preferences.store).get(
27291            "core/views",
27292            preferenceKey
27293          );
27294        },
27295        [preferenceKey]
27296      );
27297      const { set: set2 } = (0, import_data7.useDispatch)(import_preferences.store);
27298      const page = Number(queryParams?.page ?? 1);
27299      const search = queryParams?.search ?? "";
27300      const view = (0, import_element78.useMemo)(
27301        () => resolveView({
27302          defaultView: defaultView2,
27303          defaultLayouts: defaultLayouts2,
27304          activeViewOverrides,
27305          persistedView,
27306          page,
27307          search
27308        }),
27309        [
27310          defaultView2,
27311          defaultLayouts2,
27312          activeViewOverrides,
27313          persistedView,
27314          page,
27315          search
27316        ]
27317      );
27318      const isModified = !!persistedView && Object.keys(persistedView).length > 0;
27319      const updateView = (0, import_element78.useCallback)(
27320        (newView) => {
27321          const newQueryParams = {
27322            page: Number(newView?.page ?? 1),
27323            search: newView?.search ?? ""
27324          };
27325          if (onChangeQueryParams && !dequal(newQueryParams, { page, search })) {
27326            onChangeQueryParams(newQueryParams);
27327          }
27328          const modifications = getUserModifications(newView, {
27329            defaultView: defaultView2,
27330            defaultLayouts: defaultLayouts2,
27331            activeViewOverrides,
27332            persistedView
27333          });
27334          if (!dequal(modifications, persistedView)) {
27335            set2("core/views", preferenceKey, modifications);
27336          }
27337        },
27338        [
27339          onChangeQueryParams,
27340          page,
27341          search,
27342          defaultView2,
27343          defaultLayouts2,
27344          activeViewOverrides,
27345          persistedView,
27346          set2,
27347          preferenceKey
27348        ]
27349      );
27350      const resetToDefault = (0, import_element78.useCallback)(() => {
27351        set2("core/views", preferenceKey, void 0);
27352      }, [preferenceKey, set2]);
27353      return {
27354        view,
27355        isModified,
27356        updateView,
27357        resetToDefault
27358      };
27359    }
27360  
27361    // packages/views/build-module/load-view.mjs
27362    var import_data8 = __toESM(require_data(), 1);
27363    var import_preferences2 = __toESM(require_preferences(), 1);
27364  
27365    // packages/views/build-module/use-view-config.mjs
27366    var import_data9 = __toESM(require_data(), 1);
27367    var import_core_data2 = __toESM(require_core_data(), 1);
27368  
27369    // packages/views/build-module/lock-unlock.mjs
27370    var import_private_apis3 = __toESM(require_private_apis(), 1);
27371    var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
27372      "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
27373      "@wordpress/views"
27374    );
27375  
27376    // packages/media-fields/build-module/alt_text/index.mjs
27377    var import_i18n51 = __toESM(require_i18n(), 1);
27378    var import_components47 = __toESM(require_components(), 1);
27379    var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
27380    var altTextField = {
27381      id: "alt_text",
27382      type: "text",
27383      label: (0, import_i18n51.__)("Alt text"),
27384      isVisible: (item) => item?.media_type === "image",
27385      render: ({ item }) => item?.alt_text || "-",
27386      Edit: ({ field, onChange, data }) => {
27387        return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27388          import_components47.TextareaControl,
27389          {
27390            label: field.label,
27391            value: data.alt_text || "",
27392            onChange: (value) => onChange({ alt_text: value }),
27393            help: /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_jsx_runtime121.Fragment, { children: [
27394              /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27395                Link,
27396                {
27397                  href: (
27398                    // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
27399                    (0, import_i18n51.__)(
27400                      "https://www.w3.org/WAI/tutorials/images/decision-tree/"
27401                    )
27402                  ),
27403                  openInNewTab: true,
27404                  children: (0, import_i18n51.__)("Describe the purpose of the image.")
27405                }
27406              ),
27407              /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("br", {}),
27408              (0, import_i18n51.__)("Leave empty if decorative.")
27409            ] }),
27410            rows: 2
27411          }
27412        );
27413      },
27414      enableSorting: false,
27415      filterBy: false
27416    };
27417    var alt_text_default = altTextField;
27418  
27419    // packages/media-fields/build-module/attached_to/index.mjs
27420    var import_i18n54 = __toESM(require_i18n(), 1);
27421  
27422    // packages/media-fields/build-module/attached_to/view.mjs
27423    var import_element79 = __toESM(require_element(), 1);
27424    var import_i18n52 = __toESM(require_i18n(), 1);
27425  
27426    // packages/media-fields/build-module/utils/get-rendered-content.mjs
27427    function getRenderedContent(content) {
27428      if (!content) {
27429        return "";
27430      }
27431      if (typeof content === "string") {
27432        return content;
27433      }
27434      if (typeof content === "object") {
27435        return content.rendered || content.raw || "";
27436      }
27437      return "";
27438    }
27439  
27440    // packages/media-fields/build-module/attached_to/view.mjs
27441    var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
27442    function MediaAttachedToView({
27443      item
27444    }) {
27445      const [attachedPostTitle, setAttachedPostTitle] = (0, import_element79.useState)(null);
27446      const parentId = item.post;
27447      const embeddedPostId = item._embedded?.["wp:attached-to"]?.[0]?.id;
27448      const embeddedPostTitle = item._embedded?.["wp:attached-to"]?.[0]?.title;
27449      (0, import_element79.useEffect)(() => {
27450        if (!!parentId && parentId === embeddedPostId) {
27451          setAttachedPostTitle(
27452            getRenderedContent(embeddedPostTitle) || (0, import_i18n52.__)("(no title)")
27453          );
27454        }
27455        if (!parentId) {
27456          setAttachedPostTitle((0, import_i18n52.__)("(Unattached)"));
27457        }
27458      }, [parentId, embeddedPostId, embeddedPostTitle]);
27459      return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_jsx_runtime122.Fragment, { children: attachedPostTitle });
27460    }
27461  
27462    // packages/media-fields/build-module/attached_to/edit.mjs
27463    var import_core_data3 = __toESM(require_core_data(), 1);
27464    var import_components48 = __toESM(require_components(), 1);
27465    var import_i18n53 = __toESM(require_i18n(), 1);
27466    var import_element80 = __toESM(require_element(), 1);
27467    var import_compose15 = __toESM(require_compose(), 1);
27468    var import_data10 = __toESM(require_data(), 1);
27469    var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
27470    function MediaAttachedToEdit({
27471      data,
27472      onChange
27473    }) {
27474      const defaultPost = !!data.post && !!data?._embedded?.["wp:attached-to"]?.[0] ? [
27475        {
27476          label: getRenderedContent(
27477            data._embedded?.["wp:attached-to"]?.[0]?.title
27478          ),
27479          value: data.post.toString()
27480        }
27481      ] : [];
27482      const [options, setOptions] = (0, import_element80.useState)(defaultPost);
27483      const [searchResults, setSearchResults] = (0, import_element80.useState)(
27484        []
27485      );
27486      const [isLoading, setIsLoading] = (0, import_element80.useState)(false);
27487      const [value, setValue] = (0, import_element80.useState)(
27488        data?.post?.toString() ?? null
27489      );
27490      const postTypes = (0, import_data10.useSelect)(
27491        (select3) => select3(import_core_data3.store).getPostTypes(),
27492        []
27493      );
27494      const handleDetach = () => {
27495        onChange({
27496          post: 0,
27497          _embedded: { ...data?._embedded, "wp:attached-to": void 0 }
27498        });
27499        setValue(null);
27500      };
27501      const onValueChange = async (filterValue) => {
27502        setIsLoading(true);
27503        const results = await (0, import_core_data3.__experimentalFetchLinkSuggestions)(
27504          filterValue,
27505          /*
27506           * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.
27507           * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.
27508           */
27509          { type: "post", isInitialSuggestions: true },
27510          {}
27511        );
27512        setSearchResults(results);
27513        const suggestions = results.map((result) => {
27514          return {
27515            label: result.title,
27516            value: result.id.toString()
27517          };
27518        });
27519        const includeCurrent = !filterValue && suggestions.findIndex((s2) => s2.value === value) === -1;
27520        setOptions(suggestions.concat(includeCurrent ? defaultPost : []));
27521        setIsLoading(false);
27522      };
27523      const debouncedValueChange = (0, import_compose15.useDebounce)((0, import_compose15.useEvent)(onValueChange), 300);
27524      const handleSelectOption = (selectedPostId) => {
27525        if (!selectedPostId) {
27526          handleDetach();
27527          return;
27528        }
27529        setValue(selectedPostId);
27530        if (selectedPostId) {
27531          const selectedPost = searchResults.find(
27532            (result) => result.id === Number(selectedPostId)
27533          );
27534          if (selectedPost && postTypes) {
27535            const postType = postTypes.find(
27536              (_postType) => _postType.slug === selectedPost?.type
27537            );
27538            const attachedTo = {
27539              ...postType && { type: postType.slug },
27540              id: Number(selectedPostId),
27541              title: {
27542                raw: selectedPost.title,
27543                rendered: selectedPost.title
27544              }
27545            };
27546            onChange({
27547              post: Number(selectedPostId),
27548              _embedded: {
27549                ...data?._embedded,
27550                "wp:attached-to": [attachedTo]
27551              }
27552            });
27553          }
27554        }
27555      };
27556      return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27557        import_components48.ComboboxControl,
27558        {
27559          className: "dataviews-media-field__attached-to",
27560          isLoading,
27561          label: (0, import_i18n53.__)("Attached to"),
27562          help: (0, import_i18n53.__)("Attach this file to a single post or page."),
27563          value,
27564          options,
27565          onFilterValueChange: (filterValue) => debouncedValueChange(filterValue),
27566          onChange: handleSelectOption,
27567          hideLabelFromVision: true,
27568          expandOnFocus: false
27569        }
27570      );
27571    }
27572  
27573    // packages/media-fields/build-module/attached_to/index.mjs
27574    var attachedToField = {
27575      id: "attached_to",
27576      type: "text",
27577      label: (0, import_i18n54.__)("Attached to"),
27578      Edit: MediaAttachedToEdit,
27579      render: MediaAttachedToView,
27580      enableSorting: false,
27581      filterBy: false
27582    };
27583    var attached_to_default = attachedToField;
27584  
27585    // packages/media-fields/build-module/author/index.mjs
27586    var import_i18n56 = __toESM(require_i18n(), 1);
27587    var import_data11 = __toESM(require_data(), 1);
27588    var import_core_data4 = __toESM(require_core_data(), 1);
27589  
27590    // packages/media-fields/build-module/author/view.mjs
27591    var import_i18n55 = __toESM(require_i18n(), 1);
27592    var import_element81 = __toESM(require_element(), 1);
27593    var import_components49 = __toESM(require_components(), 1);
27594    var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
27595    function AuthorView({
27596      item
27597    }) {
27598      const author = item?._embedded?.author?.[0];
27599      const text = author?.name;
27600      const imageUrl = author?.avatar_urls?.[48];
27601      const [loadingState, setLoadingState] = (0, import_element81.useState)("loading");
27602      (0, import_element81.useEffect)(() => {
27603        setLoadingState("loading");
27604      }, [imageUrl]);
27605      const imgRef = (0, import_element81.useCallback)((img) => {
27606        if (img?.complete) {
27607          setLoadingState("instant");
27608        }
27609      }, []);
27610      const handleLoad = () => {
27611        if (loadingState === "loading") {
27612          setLoadingState("loaded");
27613        }
27614      };
27615      return /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(import_components49.__experimentalHStack, { alignment: "left", spacing: 0, children: [
27616        !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27617          "div",
27618          {
27619            className: clsx_default("media-author-field__avatar", {
27620              "is-loading": loadingState === "loading",
27621              "is-loaded": loadingState === "loaded"
27622            }),
27623            children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27624              "img",
27625              {
27626                ref: imgRef,
27627                onLoad: handleLoad,
27628                alt: (0, import_i18n55.__)("Author avatar"),
27629                src: imageUrl
27630              }
27631            )
27632          }
27633        ),
27634        !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("div", { className: "media-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components49.Icon, { icon: comment_author_avatar_default }) }),
27635        /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "media-author-field__name", children: text })
27636      ] });
27637    }
27638  
27639    // packages/media-fields/build-module/author/index.mjs
27640    var authorField = {
27641      label: (0, import_i18n56.__)("Author"),
27642      id: "author",
27643      type: "integer",
27644      getElements: async () => {
27645        const authors = await (0, import_data11.resolveSelect)(import_core_data4.store).getEntityRecords(
27646          "root",
27647          "user",
27648          {
27649            per_page: -1,
27650            who: "authors",
27651            _fields: "id,name",
27652            context: "view"
27653          }
27654        ) ?? [];
27655        return authors.map(({ id, name }) => ({
27656          value: id,
27657          label: name
27658        }));
27659      },
27660      render: AuthorView,
27661      sort: (a2, b2, direction) => {
27662        const nameA = a2._embedded?.author?.[0]?.name || "";
27663        const nameB = b2._embedded?.author?.[0]?.name || "";
27664        return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
27665      },
27666      filterBy: {
27667        operators: ["isAny", "isNone"]
27668      },
27669      readOnly: true
27670    };
27671    var author_default = authorField;
27672  
27673    // packages/media-fields/build-module/caption/index.mjs
27674    var import_i18n57 = __toESM(require_i18n(), 1);
27675    var import_components50 = __toESM(require_components(), 1);
27676  
27677    // packages/media-fields/build-module/utils/get-raw-content.mjs
27678    function getRawContent(content) {
27679      if (!content) {
27680        return "";
27681      }
27682      if (typeof content === "string") {
27683        return content;
27684      }
27685      if (typeof content === "object" && "raw" in content) {
27686        return content.raw || "";
27687      }
27688      return "";
27689    }
27690  
27691    // packages/media-fields/build-module/caption/index.mjs
27692    var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
27693    var captionField = {
27694      id: "caption",
27695      type: "text",
27696      label: (0, import_i18n57.__)("Caption"),
27697      getValue: ({ item }) => getRawContent(item?.caption),
27698      render: ({ item }) => getRawContent(item?.caption) || "-",
27699      Edit: ({ field, onChange, data }) => {
27700        return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27701          import_components50.TextareaControl,
27702          {
27703            label: field.label,
27704            value: getRawContent(data.caption) || "",
27705            onChange: (value) => onChange({ caption: value }),
27706            rows: 2
27707          }
27708        );
27709      },
27710      enableSorting: false,
27711      filterBy: false
27712    };
27713    var caption_default = captionField;
27714  
27715    // packages/media-fields/build-module/date_added/index.mjs
27716    var import_i18n58 = __toESM(require_i18n(), 1);
27717    var dateAddedField = {
27718      id: "date",
27719      type: "datetime",
27720      label: (0, import_i18n58.__)("Date added"),
27721      filterBy: {
27722        operators: ["before", "after"]
27723      },
27724      readOnly: true
27725    };
27726    var date_added_default = dateAddedField;
27727  
27728    // packages/media-fields/build-module/date_modified/index.mjs
27729    var import_i18n59 = __toESM(require_i18n(), 1);
27730    var dateModifiedField = {
27731      id: "modified",
27732      type: "datetime",
27733      label: (0, import_i18n59.__)("Date modified"),
27734      filterBy: {
27735        operators: ["before", "after"]
27736      },
27737      readOnly: true
27738    };
27739    var date_modified_default = dateModifiedField;
27740  
27741    // packages/media-fields/build-module/description/index.mjs
27742    var import_i18n60 = __toESM(require_i18n(), 1);
27743    var import_components51 = __toESM(require_components(), 1);
27744    var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
27745    var descriptionField = {
27746      id: "description",
27747      type: "text",
27748      label: (0, import_i18n60.__)("Description"),
27749      getValue: ({ item }) => getRawContent(item?.description),
27750      render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("div", { children: getRawContent(item?.description) || "-" }),
27751      Edit: ({ field, onChange, data }) => {
27752        return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27753          import_components51.TextareaControl,
27754          {
27755            label: field.label,
27756            value: getRawContent(data.description) || "",
27757            onChange: (value) => onChange({ description: value }),
27758            rows: 5
27759          }
27760        );
27761      },
27762      enableSorting: false,
27763      filterBy: false
27764    };
27765    var description_default = descriptionField;
27766  
27767    // packages/media-fields/build-module/filename/index.mjs
27768    var import_i18n61 = __toESM(require_i18n(), 1);
27769    var import_url4 = __toESM(require_url(), 1);
27770  
27771    // packages/media-fields/build-module/filename/view.mjs
27772    var import_element82 = __toESM(require_element(), 1);
27773    var import_url3 = __toESM(require_url(), 1);
27774    var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
27775    var TRUNCATE_LENGTH = 15;
27776    function FileNameView({
27777      item
27778    }) {
27779      const fileName = (0, import_element82.useMemo)(
27780        () => item?.source_url ? (0, import_url3.getFilename)(item.source_url) : null,
27781        [item?.source_url]
27782      );
27783      if (!fileName) {
27784        return "";
27785      }
27786      if (fileName.length <= TRUNCATE_LENGTH) {
27787        return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { className: "dataviews-media-field__filename", children: fileName });
27788      }
27789      return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(tooltip_exports.Root, { children: [
27790        /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
27791          tooltip_exports.Trigger,
27792          {
27793            render: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { className: "dataviews-media-field__filename", children: fileName })
27794          }
27795        ),
27796        /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(tooltip_exports.Popup, { children: fileName })
27797      ] });
27798    }
27799  
27800    // packages/media-fields/build-module/filename/index.mjs
27801    var filenameField = {
27802      id: "filename",
27803      type: "text",
27804      label: (0, import_i18n61.__)("File name"),
27805      getValue: ({ item }) => (0, import_url4.getFilename)(item?.source_url || ""),
27806      render: FileNameView,
27807      enableSorting: false,
27808      filterBy: false,
27809      readOnly: true
27810    };
27811    var filename_default = filenameField;
27812  
27813    // packages/media-fields/build-module/filesize/index.mjs
27814    var import_i18n62 = __toESM(require_i18n(), 1);
27815    var KB_IN_BYTES = 1024;
27816    var MB_IN_BYTES = 1024 * KB_IN_BYTES;
27817    var GB_IN_BYTES = 1024 * MB_IN_BYTES;
27818    var TB_IN_BYTES = 1024 * GB_IN_BYTES;
27819    var PB_IN_BYTES = 1024 * TB_IN_BYTES;
27820    var EB_IN_BYTES = 1024 * PB_IN_BYTES;
27821    var ZB_IN_BYTES = 1024 * EB_IN_BYTES;
27822    var YB_IN_BYTES = 1024 * ZB_IN_BYTES;
27823    function getBytesString(bytes, unitSymbol, decimals = 2) {
27824      return (0, import_i18n62.sprintf)(
27825        // translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).
27826        (0, import_i18n62._x)("%1$s %2$s", "file size"),
27827        bytes.toLocaleString(void 0, {
27828          minimumFractionDigits: 0,
27829          maximumFractionDigits: decimals
27830        }),
27831        unitSymbol
27832      );
27833    }
27834    function formatFileSize(bytes, decimals = 2) {
27835      if (bytes === 0) {
27836        return getBytesString(0, (0, import_i18n62._x)("B", "unit symbol"), decimals);
27837      }
27838      const quant = {
27839        /* translators: Unit symbol for yottabyte. */
27840        [(0, import_i18n62._x)("YB", "unit symbol")]: YB_IN_BYTES,
27841        /* translators: Unit symbol for zettabyte. */
27842        [(0, import_i18n62._x)("ZB", "unit symbol")]: ZB_IN_BYTES,
27843        /* translators: Unit symbol for exabyte. */
27844        [(0, import_i18n62._x)("EB", "unit symbol")]: EB_IN_BYTES,
27845        /* translators: Unit symbol for petabyte. */
27846        [(0, import_i18n62._x)("PB", "unit symbol")]: PB_IN_BYTES,
27847        /* translators: Unit symbol for terabyte. */
27848        [(0, import_i18n62._x)("TB", "unit symbol")]: TB_IN_BYTES,
27849        /* translators: Unit symbol for gigabyte. */
27850        [(0, import_i18n62._x)("GB", "unit symbol")]: GB_IN_BYTES,
27851        /* translators: Unit symbol for megabyte. */
27852        [(0, import_i18n62._x)("MB", "unit symbol")]: MB_IN_BYTES,
27853        /* translators: Unit symbol for kilobyte. */
27854        [(0, import_i18n62._x)("KB", "unit symbol")]: KB_IN_BYTES,
27855        /* translators: Unit symbol for byte. */
27856        [(0, import_i18n62._x)("B", "unit symbol")]: 1
27857      };
27858      for (const [unit, mag] of Object.entries(quant)) {
27859        if (bytes >= mag) {
27860          return getBytesString(bytes / mag, unit, decimals);
27861        }
27862      }
27863      return "";
27864    }
27865    var filesizeField = {
27866      id: "filesize",
27867      type: "text",
27868      label: (0, import_i18n62.__)("File size"),
27869      getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "",
27870      isVisible: (item) => {
27871        return !!item?.media_details?.filesize;
27872      },
27873      enableSorting: false,
27874      filterBy: false,
27875      readOnly: true
27876    };
27877    var filesize_default = filesizeField;
27878  
27879    // packages/media-fields/build-module/media_dimensions/index.mjs
27880    var import_i18n63 = __toESM(require_i18n(), 1);
27881    var mediaDimensionsField = {
27882      id: "media_dimensions",
27883      type: "text",
27884      label: (0, import_i18n63.__)("Dimensions"),
27885      getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, import_i18n63.sprintf)(
27886        // translators: 1: Width. 2: Height.
27887        (0, import_i18n63._x)("%1$s \xD7 %2$s", "image dimensions"),
27888        item?.media_details?.width?.toString(),
27889        item?.media_details?.height?.toString()
27890      ) : "",
27891      isVisible: (item) => {
27892        return !!(item?.media_details?.width && item?.media_details?.height);
27893      },
27894      enableSorting: false,
27895      filterBy: false,
27896      readOnly: true
27897    };
27898    var media_dimensions_default = mediaDimensionsField;
27899  
27900    // packages/media-fields/build-module/media_thumbnail/index.mjs
27901    var import_i18n65 = __toESM(require_i18n(), 1);
27902  
27903    // packages/media-fields/build-module/media_thumbnail/view.mjs
27904    var import_data12 = __toESM(require_data(), 1);
27905    var import_core_data5 = __toESM(require_core_data(), 1);
27906    var import_components52 = __toESM(require_components(), 1);
27907    var import_element83 = __toESM(require_element(), 1);
27908    var import_url5 = __toESM(require_url(), 1);
27909  
27910    // packages/media-fields/build-module/utils/get-media-type-from-mime-type.mjs
27911    var import_i18n64 = __toESM(require_i18n(), 1);
27912    function getMediaTypeFromMimeType(mimeType) {
27913      if (mimeType.startsWith("image/")) {
27914        return {
27915          type: "image",
27916          label: (0, import_i18n64.__)("Image"),
27917          icon: image_default
27918        };
27919      }
27920      if (mimeType.startsWith("video/")) {
27921        return {
27922          type: "video",
27923          label: (0, import_i18n64.__)("Video"),
27924          icon: video_default
27925        };
27926      }
27927      if (mimeType.startsWith("audio/")) {
27928        return {
27929          type: "audio",
27930          label: (0, import_i18n64.__)("Audio"),
27931          icon: audio_default
27932        };
27933      }
27934      return {
27935        type: "application",
27936        label: (0, import_i18n64.__)("Application"),
27937        icon: file_default
27938      };
27939    }
27940  
27941    // packages/media-fields/build-module/media_thumbnail/view.mjs
27942    var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
27943    function getBestImageUrl(featuredMedia, configSizes) {
27944      const sizes = featuredMedia?.media_details?.sizes;
27945      if (!sizes) {
27946        return featuredMedia.source_url;
27947      }
27948      const sizeEntries = Object.values(sizes);
27949      if (!sizeEntries.length) {
27950        return featuredMedia.source_url;
27951      }
27952      const targetWidth = configSizes ? parseInt(configSizes, 10) : NaN;
27953      if (!Number.isNaN(targetWidth)) {
27954        const validEntries = sizeEntries.filter(
27955          (s2) => typeof s2.width === "number" && !Number.isNaN(s2.width)
27956        );
27957        if (!validEntries.length) {
27958          return featuredMedia.source_url;
27959        }
27960        const sorted = [...validEntries].sort(
27961          (a2, b2) => a2.width - b2.width
27962        );
27963        const match2 = sorted.find((s2) => s2.width >= targetWidth);
27964        if (match2) {
27965          return match2.source_url;
27966        }
27967        return sorted[sorted.length - 1].source_url;
27968      }
27969      return featuredMedia.source_url;
27970    }
27971    function FallbackView({
27972      item,
27973      filename
27974    }) {
27975      return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("div", { className: "dataviews-media-field__media-thumbnail", children: /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(
27976        import_components52.__experimentalVStack,
27977        {
27978          justify: "center",
27979          alignment: "center",
27980          className: "dataviews-media-field__media-thumbnail__stack",
27981          spacing: 0,
27982          children: [
27983            /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
27984              import_components52.Icon,
27985              {
27986                className: "dataviews-media-field__media-thumbnail--icon",
27987                icon: getMediaTypeFromMimeType(item.mime_type).icon,
27988                size: 24
27989              }
27990            ),
27991            !!filename && /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("div", { className: "dataviews-media-field__media-thumbnail__filename", children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(import_components52.__experimentalTruncate, { className: "dataviews-media-field__media-thumbnail__filename__truncate", children: filename }) })
27992          ]
27993        }
27994      ) });
27995    }
27996    function ImageView({
27997      item,
27998      configSizes,
27999      onError
28000    }) {
28001      const imageUrl = getBestImageUrl(item, configSizes);
28002      const imgRef = (0, import_element83.useRef)(null);
28003      const [loadingState, setLoadingState] = (0, import_element83.useState)("loading");
28004      (0, import_element83.useLayoutEffect)(() => {
28005        if (imgRef.current?.complete) {
28006          setLoadingState("instant");
28007        } else {
28008          setLoadingState("loading");
28009        }
28010      }, [imageUrl]);
28011      const handleLoad = () => {
28012        if (loadingState === "loading") {
28013          setLoadingState("loaded");
28014        }
28015      };
28016      return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28017        "div",
28018        {
28019          className: clsx_default("dataviews-media-field__media-thumbnail", {
28020            "is-loading": loadingState === "loading",
28021            "is-loaded": loadingState === "loaded"
28022          }),
28023          children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28024            "img",
28025            {
28026              ref: imgRef,
28027              className: "dataviews-media-field__media-thumbnail--image",
28028              src: imageUrl,
28029              alt: item.alt_text || item.title.raw,
28030              onLoad: handleLoad,
28031              onError,
28032              loading: "lazy"
28033            }
28034          )
28035        }
28036      );
28037    }
28038    function MediaThumbnailView({
28039      item,
28040      config
28041    }) {
28042      const [imageError, setImageError] = (0, import_element83.useState)(false);
28043      const _featuredMedia = (0, import_data12.useSelect)(
28044        (select3) => {
28045          if (!item.featured_media) {
28046            return;
28047          }
28048          return select3(import_core_data5.store).getEntityRecord(
28049            "postType",
28050            "attachment",
28051            item.featured_media
28052          );
28053        },
28054        [item.featured_media]
28055      );
28056      const featuredMedia = item.featured_media ? _featuredMedia : item;
28057      if (!featuredMedia) {
28058        return null;
28059      }
28060      const filename = (0, import_url5.getFilename)(featuredMedia.source_url || "");
28061      if (imageError || getMediaTypeFromMimeType(featuredMedia.mime_type).type !== "image") {
28062        return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(FallbackView, { item: featuredMedia, filename: filename || "" });
28063      }
28064      return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28065        ImageView,
28066        {
28067          item: featuredMedia,
28068          configSizes: config?.sizes,
28069          onError: () => setImageError(true)
28070        }
28071      );
28072    }
28073  
28074    // packages/media-fields/build-module/media_thumbnail/index.mjs
28075    var mediaThumbnailField = {
28076      id: "media_thumbnail",
28077      type: "media",
28078      label: (0, import_i18n65.__)("Thumbnail"),
28079      render: MediaThumbnailView,
28080      enableSorting: false,
28081      filterBy: false
28082    };
28083    var media_thumbnail_default = mediaThumbnailField;
28084  
28085    // packages/media-fields/build-module/mime_type/index.mjs
28086    var import_i18n66 = __toESM(require_i18n(), 1);
28087    var mimeTypeField = {
28088      id: "mime_type",
28089      type: "text",
28090      label: (0, import_i18n66.__)("File type"),
28091      getValue: ({ item }) => item?.mime_type || "",
28092      render: ({ item }) => item?.mime_type || "-",
28093      // Disable sorting until REST API support for ordering my `mime_type` is added.
28094      // See: https://core.trac.wordpress.org/ticket/64073
28095      enableSorting: false,
28096      filterBy: false,
28097      readOnly: true
28098    };
28099    var mime_type_default = mimeTypeField;
28100  
28101    // packages/media-utils/build-module/components/media-upload-modal/index.mjs
28102    var import_notices = __toESM(require_notices(), 1);
28103  
28104    // packages/media-utils/build-module/lock-unlock.mjs
28105    var import_private_apis4 = __toESM(require_private_apis(), 1);
28106    var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
28107      "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
28108      "@wordpress/media-utils"
28109    );
28110  
28111    // packages/media-utils/build-module/components/media-upload-modal/upload-status-popover.mjs
28112    var import_element84 = __toESM(require_element(), 1);
28113    var import_i18n67 = __toESM(require_i18n(), 1);
28114    var import_components53 = __toESM(require_components(), 1);
28115    var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
28116    function UploadStatusPopover({
28117      uploadingFiles,
28118      onDismissError,
28119      onOpenChange
28120    }) {
28121      const [isOpen, setIsOpen] = (0, import_element84.useState)(false);
28122      const [prevHadErrors, setPrevHadErrors] = (0, import_element84.useState)(false);
28123      const triggerRef = (0, import_element84.useRef)(null);
28124      const updateIsOpen = (0, import_element84.useCallback)(
28125        (open) => {
28126          setIsOpen(open);
28127          onOpenChange?.(open);
28128        },
28129        [onOpenChange]
28130      );
28131      const activeFiles = uploadingFiles.filter(
28132        (file) => file.status === "uploading"
28133      );
28134      const errorFiles = uploadingFiles.filter(
28135        (file) => file.status === "error"
28136      );
28137      const hasErrors = errorFiles.length > 0;
28138      const isUploading = activeFiles.length > 0;
28139      (0, import_element84.useEffect)(() => {
28140        if (hasErrors && !prevHadErrors) {
28141          updateIsOpen(true);
28142        }
28143        setPrevHadErrors(hasErrors);
28144      }, [hasErrors, prevHadErrors, updateIsOpen]);
28145      if (uploadingFiles.length === 0) {
28146        return null;
28147      }
28148      let buttonLabel, popoverHeading;
28149      if (isUploading) {
28150        buttonLabel = (0, import_i18n67.sprintf)(
28151          // translators: %s: number of files being uploaded
28152          (0, import_i18n67._n)("Uploading %s file", "Uploading %s files", activeFiles.length),
28153          activeFiles.length.toLocaleString()
28154        );
28155        popoverHeading = (0, import_i18n67.__)("Uploading");
28156      } else if (hasErrors) {
28157        buttonLabel = (0, import_i18n67.sprintf)(
28158          // translators: %s: number of upload errors
28159          (0, import_i18n67._n)("%s upload error", "%s upload errors", errorFiles.length),
28160          errorFiles.length.toLocaleString()
28161        );
28162        popoverHeading = (0, import_i18n67.__)("Upload errors");
28163      } else {
28164        buttonLabel = (0, import_i18n67.__)("Upload complete");
28165        popoverHeading = (0, import_i18n67.__)("Upload complete");
28166      }
28167      return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("div", { className: "media-upload-modal__upload-status", children: [
28168        isUploading && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components53.Spinner, {}),
28169        /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28170          import_components53.Button,
28171          {
28172            className: "media-upload-modal__upload-status__trigger",
28173            size: "compact",
28174            icon: chevron_down_default,
28175            iconPosition: "right",
28176            onClick: () => updateIsOpen(!isOpen),
28177            "aria-expanded": isOpen,
28178            ref: triggerRef,
28179            children: buttonLabel
28180          }
28181        ),
28182        isOpen && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28183          import_components53.Popover,
28184          {
28185            className: "media-upload-modal__upload-status__popover",
28186            placement: "top-start",
28187            offset: 8,
28188            anchor: triggerRef.current,
28189            focusOnMount: true,
28190            onClose: () => {
28191              if (triggerRef.current?.contains(
28192                triggerRef.current.ownerDocument.activeElement
28193              )) {
28194                return;
28195              }
28196              updateIsOpen(false);
28197            },
28198            children: [
28199              /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("div", { className: "media-upload-modal__upload-status__header", children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("h3", { children: popoverHeading }) }),
28200              /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("ul", { className: "media-upload-modal__upload-status__list", children: uploadingFiles.map((file) => /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28201                "li",
28202                {
28203                  className: "media-upload-modal__upload-status__item",
28204                  children: [
28205                    file.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components53.Spinner, {}),
28206                    file.status === "uploaded" && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components53.Icon, { icon: check_default, size: 16 }),
28207                    (file.status === "uploading" || file.status === "uploaded") && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28208                      "span",
28209                      {
28210                        className: "media-upload-modal__upload-status__filename",
28211                        title: file.name,
28212                        children: file.name
28213                      }
28214                    ),
28215                    file.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28216                      import_components53.Notice,
28217                      {
28218                        status: "error",
28219                        isDismissible: !!onDismissError,
28220                        onRemove: () => onDismissError?.(file.id),
28221                        children: [
28222                          file.name,
28223                          ": ",
28224                          file.error
28225                        ]
28226                      }
28227                    )
28228                  ]
28229                },
28230                file.id
28231              )) })
28232            ]
28233          }
28234        )
28235      ] });
28236    }
28237  
28238    // packages/media-utils/build-module/components/media-upload-modal/use-invalidate-attachment-resolutions.mjs
28239    var import_element85 = __toESM(require_element(), 1);
28240    var import_data13 = __toESM(require_data(), 1);
28241    function useInvalidateAttachmentResolutions() {
28242      const registry = (0, import_data13.useRegistry)();
28243      return (0, import_element85.useCallback)(
28244        () => invalidateAttachmentResolutions(registry),
28245        [registry]
28246      );
28247    }
28248  
28249    // packages/media-utils/build-module/components/media-upload-modal/use-upload-status.mjs
28250    var import_element86 = __toESM(require_element(), 1);
28251    var import_blob2 = __toESM(require_blob(), 1);
28252    var idCounter = 0;
28253    var batchIdCounter = 0;
28254    function useUploadStatus({
28255      onBatchComplete
28256    } = {}) {
28257      const [uploadingFiles, setUploadingFiles] = (0, import_element86.useState)(
28258        []
28259      );
28260      const clearCompleted = (0, import_element86.useCallback)(() => {
28261        setUploadingFiles(
28262          (prev) => prev.filter((item) => item.status !== "uploaded")
28263        );
28264      }, []);
28265      const dismissError = (0, import_element86.useCallback)((fileId) => {
28266        setUploadingFiles(
28267          (prev) => prev.filter((item) => item.id !== fileId)
28268        );
28269      }, []);
28270      const registerBatch = (0, import_element86.useCallback)(
28271        (files) => {
28272          const batchId = String(++batchIdCounter);
28273          const batchSize = files.length;
28274          const newEntries = files.map((file) => ({
28275            id: String(++idCounter),
28276            batchId,
28277            name: file.name,
28278            status: "uploading"
28279          }));
28280          setUploadingFiles((prev) => [...prev, ...newEntries]);
28281          let successCount = 0;
28282          let errorCount = 0;
28283          let batchDone = false;
28284          let successAttachments = [];
28285          const completeBatchIfDone = () => {
28286            if (batchDone || successCount + errorCount < batchSize) {
28287              return;
28288            }
28289            batchDone = true;
28290            setUploadingFiles(
28291              (prev) => prev.map(
28292                (item) => item.batchId === batchId && item.status === "uploading" ? {
28293                  ...item,
28294                  status: "uploaded"
28295                } : item
28296              )
28297            );
28298            onBatchComplete?.(successAttachments);
28299          };
28300          const onFileChange = (attachments) => {
28301            if (batchDone) {
28302              return;
28303            }
28304            const allReal = attachments.every(
28305              (attachment) => attachment.id && attachment.url && !(0, import_blob2.isBlobURL)(attachment.url)
28306            );
28307            if (!allReal) {
28308              return;
28309            }
28310            successCount = attachments.length;
28311            successAttachments = attachments;
28312            completeBatchIfDone();
28313          };
28314          const onError = (error) => {
28315            const fileName = error instanceof UploadError ? error.file.name : void 0;
28316            setUploadingFiles((prev) => {
28317              let matched = false;
28318              return prev.map((item) => {
28319                if (!matched && item.batchId === batchId && item.status === "uploading" && (!fileName || item.name === fileName)) {
28320                  matched = true;
28321                  return {
28322                    ...item,
28323                    status: "error",
28324                    error: error.message
28325                  };
28326                }
28327                return item;
28328              });
28329            });
28330            errorCount++;
28331            completeBatchIfDone();
28332          };
28333          return { onFileChange, onError };
28334        },
28335        [onBatchComplete]
28336      );
28337      const allComplete = uploadingFiles.length > 0 && uploadingFiles.every((item) => item.status !== "uploading");
28338      return {
28339        uploadingFiles,
28340        registerBatch,
28341        dismissError,
28342        clearCompleted,
28343        allComplete
28344      };
28345    }
28346  
28347    // packages/media-utils/build-module/components/media-upload-modal/index.mjs
28348    var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
28349    var { useEntityRecordsWithPermissions } = unlock4(import_core_data6.privateApis);
28350    var LAYOUT_PICKER_GRID2 = "pickerGrid";
28351    var LAYOUT_PICKER_TABLE2 = "pickerTable";
28352    var NOTICES_CONTEXT = "media-modal";
28353    var NOTICE_ID_UPLOAD_PROGRESS = "media-modal-upload-progress";
28354    var defaultQueryParams = {
28355      page: 1,
28356      search: ""
28357    };
28358    function getSelectionFromValue(value) {
28359      if (!value) {
28360        return [];
28361      }
28362      return Array.isArray(value) ? value.map(String) : [String(value)];
28363    }
28364    var defaultView = {
28365      type: LAYOUT_PICKER_GRID2,
28366      fields: [],
28367      showTitle: false,
28368      titleField: "title",
28369      mediaField: "media_thumbnail",
28370      perPage: 50,
28371      filters: [],
28372      layout: {
28373        previewSize: 170,
28374        density: "compact"
28375      }
28376    };
28377    var defaultLayouts = {
28378      [LAYOUT_PICKER_GRID2]: {
28379        fields: [],
28380        showTitle: false,
28381        layout: {
28382          previewSize: 170,
28383          density: "compact"
28384        }
28385      },
28386      [LAYOUT_PICKER_TABLE2]: {
28387        fields: [
28388          "filename",
28389          "filesize",
28390          "media_dimensions",
28391          "author",
28392          "date"
28393        ],
28394        showTitle: true
28395      }
28396    };
28397    function MediaUploadModal({
28398      allowedTypes,
28399      multiple = false,
28400      value,
28401      onSelect,
28402      onClose,
28403      onUpload,
28404      title = (0, import_i18n68.__)("Select Media"),
28405      isOpen,
28406      isDismissible = true,
28407      modalClass,
28408      search = true,
28409      searchLabel = (0, import_i18n68.__)("Search media")
28410    }) {
28411      const [selection, setSelection] = (0, import_element87.useState)(
28412        () => getSelectionFromValue(value)
28413      );
28414      const { createSuccessNotice, removeAllNotices } = (0, import_data14.useDispatch)(import_notices.store);
28415      const invalidateAttachmentResolutions2 = useInvalidateAttachmentResolutions();
28416      const [queryParams, setQueryParams] = (0, import_element87.useState)(
28417        () => defaultQueryParams
28418      );
28419      const { view, updateView, isModified, resetToDefault } = useView({
28420        kind: "postType",
28421        name: "attachment",
28422        slug: "media-modal",
28423        defaultView,
28424        queryParams,
28425        onChangeQueryParams: setQueryParams
28426      });
28427      const handleChangeView = (0, import_element87.useCallback)(
28428        (nextView) => {
28429          const normalizedView = { ...nextView };
28430          if (normalizedView.startPosition === void 0) {
28431            delete normalizedView.startPosition;
28432          }
28433          updateView(normalizedView);
28434        },
28435        [updateView]
28436      );
28437      const queryArgs = (0, import_element87.useMemo)(() => {
28438        const filters = {};
28439        view.filters?.forEach((filter) => {
28440          if (filter.field === "media_type") {
28441            filters.media_type = filter.value;
28442          }
28443          if (filter.field === "author") {
28444            if (filter.operator === "isAny") {
28445              filters.author = filter.value;
28446            } else if (filter.operator === "isNone") {
28447              filters.author_exclude = filter.value;
28448            }
28449          }
28450          if (filter.field === "date" || filter.field === "modified") {
28451            if (filter.operator === "before") {
28452              filters.before = filter.value;
28453            } else if (filter.operator === "after") {
28454              filters.after = filter.value;
28455            }
28456          }
28457          if (filter.field === "mime_type") {
28458            filters.mime_type = filter.value;
28459          }
28460        });
28461        if (!filters.media_type && !filters.mime_type && allowedTypes && !allowedTypes.includes("*")) {
28462          const { mediaTypes, mimeTypes } = allowedTypes.reduce(
28463            (acc, type) => {
28464              if (type.endsWith("/*")) {
28465                acc.mediaTypes.push(type.replace("/*", ""));
28466              } else if (type.includes("/")) {
28467                acc.mimeTypes.push(type);
28468              } else {
28469                acc.mediaTypes.push(type);
28470              }
28471              return acc;
28472            },
28473            { mediaTypes: [], mimeTypes: [] }
28474          );
28475          if (mediaTypes.length) {
28476            filters.media_type = mediaTypes;
28477          }
28478          if (mimeTypes.length) {
28479            filters.mime_type = mimeTypes;
28480          }
28481        }
28482        return {
28483          per_page: view.perPage || 20,
28484          page: view.page || 1,
28485          status: "inherit",
28486          order: view.sort?.direction,
28487          orderby: view.sort?.field,
28488          search: view.search,
28489          _embed: "author,wp:attached-to",
28490          ...filters
28491        };
28492      }, [view, allowedTypes]);
28493      const handleBatchComplete = (0, import_element87.useCallback)(
28494        (attachments) => {
28495          const uploadedIds = attachments.map((attachment) => String(attachment.id)).filter(Boolean);
28496          if (multiple) {
28497            setSelection((prev) => {
28498              const existing = new Set(prev);
28499              const newIds = uploadedIds.filter(
28500                (id) => !existing.has(id)
28501              );
28502              return [...prev, ...newIds];
28503            });
28504          } else {
28505            setSelection(uploadedIds.slice(0, 1));
28506          }
28507          invalidateAttachmentResolutions2();
28508        },
28509        [multiple, invalidateAttachmentResolutions2]
28510      );
28511      const {
28512        uploadingFiles,
28513        registerBatch,
28514        dismissError,
28515        clearCompleted,
28516        allComplete
28517      } = useUploadStatus({ onBatchComplete: handleBatchComplete });
28518      const isPopoverOpenRef = (0, import_element87.useRef)(false);
28519      const handlePopoverOpenChange = (0, import_element87.useCallback)(
28520        (open) => {
28521          isPopoverOpenRef.current = open;
28522          if (!open) {
28523            clearCompleted();
28524          }
28525        },
28526        [clearCompleted]
28527      );
28528      const {
28529        records: mediaRecords,
28530        isResolving: isLoading,
28531        totalItems,
28532        totalPages
28533      } = useEntityRecordsWithPermissions("postType", "attachment", queryArgs);
28534      const fields = (0, import_element87.useMemo)(
28535        () => [
28536          // Media field definitions from @wordpress/media-fields
28537          // Cast is safe because RestAttachment has the same properties as Attachment
28538          {
28539            ...media_thumbnail_default,
28540            enableHiding: false
28541            // Within the modal, the thumbnail should always be shown.
28542          },
28543          {
28544            id: "title",
28545            type: "text",
28546            label: (0, import_i18n68.__)("Title"),
28547            getValue: ({ item }) => {
28548              const titleValue = item.title.raw || item.title.rendered;
28549              return titleValue || (0, import_i18n68.__)("(no title)");
28550            }
28551          },
28552          alt_text_default,
28553          caption_default,
28554          description_default,
28555          date_added_default,
28556          date_modified_default,
28557          author_default,
28558          filename_default,
28559          filesize_default,
28560          media_dimensions_default,
28561          mime_type_default,
28562          attached_to_default
28563        ],
28564        []
28565      );
28566      const actions = (0, import_element87.useMemo)(
28567        () => [
28568          {
28569            id: "select",
28570            label: (0, import_i18n68.__)("Select"),
28571            isPrimary: true,
28572            supportsBulk: multiple,
28573            async callback() {
28574              if (selection.length === 0) {
28575                return;
28576              }
28577              const selectedPostsQuery = {
28578                include: selection,
28579                per_page: -1
28580              };
28581              const selectedPosts = await (0, import_data14.resolveSelect)(
28582                import_core_data6.store
28583              ).getEntityRecords(
28584                "postType",
28585                "attachment",
28586                selectedPostsQuery
28587              );
28588              const transformedPosts = (selectedPosts ?? []).map(transformAttachment).filter(Boolean);
28589              const selectedItems = multiple ? transformedPosts : transformedPosts?.[0];
28590              removeAllNotices("snackbar", NOTICES_CONTEXT);
28591              onSelect(selectedItems);
28592            }
28593          }
28594        ],
28595        [multiple, onSelect, selection, removeAllNotices]
28596      );
28597      const handleModalClose = (0, import_element87.useCallback)(() => {
28598        removeAllNotices("snackbar", NOTICES_CONTEXT);
28599        onClose?.();
28600      }, [removeAllNotices, onClose]);
28601      const valueRef = (0, import_element87.useRef)(value);
28602      (0, import_element87.useEffect)(() => {
28603        valueRef.current = value;
28604      }, [value]);
28605      (0, import_element87.useEffect)(() => {
28606        if (isOpen) {
28607          setSelection(getSelectionFromValue(valueRef.current));
28608        } else {
28609          setQueryParams(defaultQueryParams);
28610        }
28611      }, [isOpen]);
28612      const handleUpload = onUpload || uploadMedia;
28613      const prevAllCompleteRef = (0, import_element87.useRef)(false);
28614      (0, import_element87.useEffect)(() => {
28615        if (allComplete && !prevAllCompleteRef.current) {
28616          const completeCount = uploadingFiles.filter(
28617            (file) => file.status === "uploaded"
28618          ).length;
28619          if (completeCount > 0) {
28620            createSuccessNotice(
28621              (0, import_i18n68.sprintf)(
28622                // translators: %s: number of files
28623                (0, import_i18n68._n)(
28624                  "Uploaded %s file",
28625                  "Uploaded %s files",
28626                  completeCount
28627                ),
28628                completeCount.toLocaleString()
28629              ),
28630              {
28631                type: "snackbar",
28632                context: NOTICES_CONTEXT,
28633                id: NOTICE_ID_UPLOAD_PROGRESS
28634              }
28635            );
28636          }
28637          if (!isPopoverOpenRef.current) {
28638            clearCompleted();
28639          }
28640        }
28641        prevAllCompleteRef.current = allComplete;
28642      }, [allComplete, uploadingFiles, createSuccessNotice, clearCompleted]);
28643      const handleFileSelect = (0, import_element87.useCallback)(
28644        (event) => {
28645          const files = event.target.files;
28646          if (files && files.length > 0) {
28647            const filesArray = Array.from(files);
28648            const { onFileChange, onError } = registerBatch(filesArray);
28649            handleUpload({
28650              allowedTypes,
28651              filesList: filesArray,
28652              onFileChange,
28653              onError
28654            });
28655          }
28656        },
28657        [allowedTypes, handleUpload, registerBatch]
28658      );
28659      const paginationInfo = (0, import_element87.useMemo)(
28660        () => ({
28661          totalItems,
28662          totalPages
28663        }),
28664        [totalItems, totalPages]
28665      );
28666      const acceptTypes = (0, import_element87.useMemo)(() => {
28667        if (allowedTypes?.includes("*")) {
28668          return void 0;
28669        }
28670        return allowedTypes?.join(",");
28671      }, [allowedTypes]);
28672      if (!isOpen) {
28673        return null;
28674      }
28675      return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28676        import_components54.Modal,
28677        {
28678          title,
28679          onRequestClose: handleModalClose,
28680          isDismissible,
28681          className: modalClass,
28682          overlayClassName: "media-upload-modal",
28683          size: "fill",
28684          headerActions: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28685            import_components54.FormFileUpload,
28686            {
28687              accept: acceptTypes,
28688              multiple: true,
28689              onChange: handleFileSelect,
28690              render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28691                import_components54.Button,
28692                {
28693                  onClick: openFileDialog,
28694                  icon: upload_default,
28695                  __next40pxDefaultSize: true,
28696                  children: (0, import_i18n68.__)("Upload media")
28697                }
28698              )
28699            }
28700          ),
28701          children: [
28702            /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28703              import_components54.DropZone,
28704              {
28705                onFilesDrop: (files) => {
28706                  let filteredFiles = files;
28707                  if (allowedTypes && !allowedTypes.includes("*")) {
28708                    filteredFiles = files.filter(
28709                      (file) => allowedTypes.some((allowedType) => {
28710                        return file.type === allowedType || file.type.startsWith(
28711                          allowedType.replace("*", "")
28712                        );
28713                      })
28714                    );
28715                  }
28716                  if (filteredFiles.length > 0) {
28717                    const { onFileChange, onError } = registerBatch(filteredFiles);
28718                    handleUpload({
28719                      allowedTypes,
28720                      filesList: filteredFiles,
28721                      onFileChange,
28722                      onError
28723                    });
28724                  }
28725                },
28726                label: (0, import_i18n68.__)("Drop files to upload")
28727              }
28728            ),
28729            /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28730              dataviews_picker_default,
28731              {
28732                data: mediaRecords || [],
28733                fields,
28734                view,
28735                onChangeView: handleChangeView,
28736                actions,
28737                selection,
28738                onChangeSelection: setSelection,
28739                isLoading,
28740                paginationInfo,
28741                defaultLayouts,
28742                getItemId: (item) => String(item.id),
28743                itemListLabel: (0, import_i18n68.__)("Media items"),
28744                onReset: isModified ? resetToDefault : false,
28745                children: [
28746                  /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28747                    Stack,
28748                    {
28749                      direction: "row",
28750                      align: "top",
28751                      justify: "space-between",
28752                      className: "dataviews__view-actions",
28753                      gap: "xs",
28754                      children: [
28755                        /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28756                          Stack,
28757                          {
28758                            direction: "row",
28759                            gap: "sm",
28760                            justify: "start",
28761                            className: "dataviews__search",
28762                            children: [
28763                              search && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.Search, { label: searchLabel }),
28764                              /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.FiltersToggle, {})
28765                            ]
28766                          }
28767                        ),
28768                        /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
28769                          /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.LayoutSwitcher, {}),
28770                          /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.ViewConfig, {})
28771                        ] })
28772                      ]
28773                    }
28774                  ),
28775                  /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.FiltersToggled, { className: "dataviews-filters__container" }),
28776                  /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.Layout, {}),
28777                  /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28778                    "div",
28779                    {
28780                      className: clsx_default("media-upload-modal__footer", {
28781                        "is-uploading": uploadingFiles.length > 0
28782                      }),
28783                      children: [
28784                        /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28785                          UploadStatusPopover,
28786                          {
28787                            uploadingFiles,
28788                            onDismissError: dismissError,
28789                            onOpenChange: handlePopoverOpenChange
28790                          }
28791                        ),
28792                        /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.Footer, {})
28793                      ]
28794                    }
28795                  )
28796                ]
28797              }
28798            ),
28799            (0, import_element87.createPortal)(
28800              /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28801                import_notices.SnackbarNotices,
28802                {
28803                  className: "media-upload-modal__snackbar",
28804                  context: NOTICES_CONTEXT
28805                }
28806              ),
28807              document.body
28808            )
28809          ]
28810        }
28811      );
28812    }
28813  
28814    // packages/media-utils/build-module/private-apis.mjs
28815    var privateApis12 = {};
28816    lock4(privateApis12, {
28817      sideloadMedia,
28818      MediaUploadModal
28819    });
28820    return __toCommonJS(index_exports);
28821  })();
28822  /*! Bundled license information:
28823  
28824  use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
28825    (**
28826     * @license React
28827     * use-sync-external-store-shim.development.js
28828     *
28829     * Copyright (c) Meta Platforms, Inc. and affiliates.
28830     *
28831     * This source code is licensed under the MIT license found in the
28832     * LICENSE file in the root directory of this source tree.
28833     *)
28834  
28835  use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
28836    (**
28837     * @license React
28838     * use-sync-external-store-shim/with-selector.development.js
28839     *
28840     * Copyright (c) Meta Platforms, Inc. and affiliates.
28841     *
28842     * This source code is licensed under the MIT license found in the
28843     * LICENSE file in the root directory of this source tree.
28844     *)
28845  */
28846  (window.wp ||= {}).mediaUtils = wp.mediaUtils;
28847  })();


Generated : Tue Aug 11 08:20:21 2026 Cross-referenced by PHPXref