"use strict";
var wp;
(wp ||= {}).editor = (() => {
  var __create = Object.create;
  var __defProp = Object.defineProperty;
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  var __getOwnPropNames = Object.getOwnPropertyNames;
  var __getProtoOf = Object.getPrototypeOf;
  var __hasOwnProp = Object.prototype.hasOwnProperty;
  var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
    get: (a3, b3) => (typeof require !== "undefined" ? require : a3)[b3]
  }) : x2)(function(x2) {
    if (typeof require !== "undefined") return require.apply(this, arguments);
    throw Error('Dynamic require of "' + x2 + '" is not supported');
  });
  var __commonJS = (cb, mod) => function __require4() {
    return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  };
  var __export = (target, all) => {
    for (var name2 in all)
      __defProp(target, name2, { get: all[name2], enumerable: true });
  };
  var __copyProps = (to2, from, except, desc) => {
    if (from && typeof from === "object" || typeof from === "function") {
      for (let key of __getOwnPropNames(from))
        if (!__hasOwnProp.call(to2, key) && key !== except)
          __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
    }
    return to2;
  };
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
    // If the importer is in node compatibility mode or this is not an ESM
    // file that has been converted to a CommonJS file using a Babel-
    // compatible transform (i.e. "__esModule" has not been set), then set
    // "default" to the CommonJS "module.exports" for node compatibility.
    isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
    mod
  ));
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

  // package-external:@wordpress/data
  var require_data = __commonJS({
    "package-external:@wordpress/data"(exports, module) {
      module.exports = window.wp.data;
    }
  });

  // package-external:@wordpress/core-data
  var require_core_data = __commonJS({
    "package-external:@wordpress/core-data"(exports, module) {
      module.exports = window.wp.coreData;
    }
  });

  // package-external:@wordpress/element
  var require_element = __commonJS({
    "package-external:@wordpress/element"(exports, module) {
      module.exports = window.wp.element;
    }
  });

  // package-external:@wordpress/compose
  var require_compose = __commonJS({
    "package-external:@wordpress/compose"(exports, module) {
      module.exports = window.wp.compose;
    }
  });

  // package-external:@wordpress/hooks
  var require_hooks = __commonJS({
    "package-external:@wordpress/hooks"(exports, module) {
      module.exports = window.wp.hooks;
    }
  });

  // package-external:@wordpress/block-editor
  var require_block_editor = __commonJS({
    "package-external:@wordpress/block-editor"(exports, module) {
      module.exports = window.wp.blockEditor;
    }
  });

  // package-external:@wordpress/blocks
  var require_blocks = __commonJS({
    "package-external:@wordpress/blocks"(exports, module) {
      module.exports = window.wp.blocks;
    }
  });

  // package-external:@wordpress/date
  var require_date = __commonJS({
    "package-external:@wordpress/date"(exports, module) {
      module.exports = window.wp.date;
    }
  });

  // package-external:@wordpress/url
  var require_url = __commonJS({
    "package-external:@wordpress/url"(exports, module) {
      module.exports = window.wp.url;
    }
  });

  // package-external:@wordpress/deprecated
  var require_deprecated = __commonJS({
    "package-external:@wordpress/deprecated"(exports, module) {
      module.exports = window.wp.deprecated;
    }
  });

  // package-external:@wordpress/preferences
  var require_preferences = __commonJS({
    "package-external:@wordpress/preferences"(exports, module) {
      module.exports = window.wp.preferences;
    }
  });

  // package-external:@wordpress/primitives
  var require_primitives = __commonJS({
    "package-external:@wordpress/primitives"(exports, module) {
      module.exports = window.wp.primitives;
    }
  });

  // vendor-external:react/jsx-runtime
  var require_jsx_runtime = __commonJS({
    "vendor-external:react/jsx-runtime"(exports, module) {
      module.exports = window.ReactJSXRuntime;
    }
  });

  // package-external:@wordpress/private-apis
  var require_private_apis = __commonJS({
    "package-external:@wordpress/private-apis"(exports, module) {
      module.exports = window.wp.privateApis;
    }
  });

  // package-external:@wordpress/a11y
  var require_a11y = __commonJS({
    "package-external:@wordpress/a11y"(exports, module) {
      module.exports = window.wp.a11y;
    }
  });

  // package-external:@wordpress/api-fetch
  var require_api_fetch = __commonJS({
    "package-external:@wordpress/api-fetch"(exports, module) {
      module.exports = window.wp.apiFetch;
    }
  });

  // package-external:@wordpress/notices
  var require_notices = __commonJS({
    "package-external:@wordpress/notices"(exports, module) {
      module.exports = window.wp.notices;
    }
  });

  // package-external:@wordpress/i18n
  var require_i18n = __commonJS({
    "package-external:@wordpress/i18n"(exports, module) {
      module.exports = window.wp.i18n;
    }
  });

  // package-external:@wordpress/html-entities
  var require_html_entities = __commonJS({
    "package-external:@wordpress/html-entities"(exports, module) {
      module.exports = window.wp.htmlEntities;
    }
  });

  // package-external:@wordpress/components
  var require_components = __commonJS({
    "package-external:@wordpress/components"(exports, module) {
      module.exports = window.wp.components;
    }
  });

  // package-external:@wordpress/patterns
  var require_patterns = __commonJS({
    "package-external:@wordpress/patterns"(exports, module) {
      module.exports = window.wp.patterns;
    }
  });

  // package-external:@wordpress/blob
  var require_blob = __commonJS({
    "package-external:@wordpress/blob"(exports, module) {
      module.exports = window.wp.blob;
    }
  });

  // vendor-external:react
  var require_react = __commonJS({
    "vendor-external:react"(exports, module) {
      module.exports = window.React;
    }
  });

  // vendor-external:react-dom
  var require_react_dom = __commonJS({
    "vendor-external:react-dom"(exports, module) {
      module.exports = window.ReactDOM;
    }
  });

  // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
  var require_use_sync_external_store_shim_development = __commonJS({
    "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
      "use strict";
      (function() {
        function is2(x2, y3) {
          return x2 === y3 && (0 !== x2 || 1 / x2 === 1 / y3) || x2 !== x2 && y3 !== y3;
        }
        function useSyncExternalStore$2(subscribe2, getSnapshot) {
          didWarnOld18Alpha || void 0 === React27.startTransition || (didWarnOld18Alpha = true, console.error(
            "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."
          ));
          var value = getSnapshot();
          if (!didWarnUncachedGetSnapshot) {
            var cachedValue = getSnapshot();
            objectIs(value, cachedValue) || (console.error(
              "The result of getSnapshot should be cached to avoid an infinite loop"
            ), didWarnUncachedGetSnapshot = true);
          }
          cachedValue = useState135({
            inst: { value, getSnapshot }
          });
          var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
          useLayoutEffect10(
            function() {
              inst.value = value;
              inst.getSnapshot = getSnapshot;
              checkIfSnapshotChanged(inst) && forceUpdate({ inst });
            },
            [subscribe2, value, getSnapshot]
          );
          useEffect95(
            function() {
              checkIfSnapshotChanged(inst) && forceUpdate({ inst });
              return subscribe2(function() {
                checkIfSnapshotChanged(inst) && forceUpdate({ inst });
              });
            },
            [subscribe2]
          );
          useDebugValue(value);
          return value;
        }
        function checkIfSnapshotChanged(inst) {
          var latestGetSnapshot = inst.getSnapshot;
          inst = inst.value;
          try {
            var nextValue = latestGetSnapshot();
            return !objectIs(inst, nextValue);
          } catch (error2) {
            return true;
          }
        }
        function useSyncExternalStore$1(subscribe2, getSnapshot) {
          return getSnapshot();
        }
        "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
        var React27 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is2, useState135 = React27.useState, useEffect95 = React27.useEffect, useLayoutEffect10 = React27.useLayoutEffect, useDebugValue = React27.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
        exports.useSyncExternalStore = void 0 !== React27.useSyncExternalStore ? React27.useSyncExternalStore : shim;
        "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
      })();
    }
  });

  // node_modules/use-sync-external-store/shim/index.js
  var require_shim = __commonJS({
    "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
      "use strict";
      if (false) {
        module.exports = null;
      } else {
        module.exports = require_use_sync_external_store_shim_development();
      }
    }
  });

  // package-external:@wordpress/media-utils
  var require_media_utils = __commonJS({
    "package-external:@wordpress/media-utils"(exports, module) {
      module.exports = window.wp.mediaUtils;
    }
  });

  // node_modules/remove-accents/index.js
  var require_remove_accents = __commonJS({
    "node_modules/remove-accents/index.js"(exports, module) {
      var characterMap = {
        "\xC0": "A",
        "\xC1": "A",
        "\xC2": "A",
        "\xC3": "A",
        "\xC4": "A",
        "\xC5": "A",
        "\u1EA4": "A",
        "\u1EAE": "A",
        "\u1EB2": "A",
        "\u1EB4": "A",
        "\u1EB6": "A",
        "\xC6": "AE",
        "\u1EA6": "A",
        "\u1EB0": "A",
        "\u0202": "A",
        "\u1EA2": "A",
        "\u1EA0": "A",
        "\u1EA8": "A",
        "\u1EAA": "A",
        "\u1EAC": "A",
        "\xC7": "C",
        "\u1E08": "C",
        "\xC8": "E",
        "\xC9": "E",
        "\xCA": "E",
        "\xCB": "E",
        "\u1EBE": "E",
        "\u1E16": "E",
        "\u1EC0": "E",
        "\u1E14": "E",
        "\u1E1C": "E",
        "\u0206": "E",
        "\u1EBA": "E",
        "\u1EBC": "E",
        "\u1EB8": "E",
        "\u1EC2": "E",
        "\u1EC4": "E",
        "\u1EC6": "E",
        "\xCC": "I",
        "\xCD": "I",
        "\xCE": "I",
        "\xCF": "I",
        "\u1E2E": "I",
        "\u020A": "I",
        "\u1EC8": "I",
        "\u1ECA": "I",
        "\xD0": "D",
        "\xD1": "N",
        "\xD2": "O",
        "\xD3": "O",
        "\xD4": "O",
        "\xD5": "O",
        "\xD6": "O",
        "\xD8": "O",
        "\u1ED0": "O",
        "\u1E4C": "O",
        "\u1E52": "O",
        "\u020E": "O",
        "\u1ECE": "O",
        "\u1ECC": "O",
        "\u1ED4": "O",
        "\u1ED6": "O",
        "\u1ED8": "O",
        "\u1EDC": "O",
        "\u1EDE": "O",
        "\u1EE0": "O",
        "\u1EDA": "O",
        "\u1EE2": "O",
        "\xD9": "U",
        "\xDA": "U",
        "\xDB": "U",
        "\xDC": "U",
        "\u1EE6": "U",
        "\u1EE4": "U",
        "\u1EEC": "U",
        "\u1EEE": "U",
        "\u1EF0": "U",
        "\xDD": "Y",
        "\xE0": "a",
        "\xE1": "a",
        "\xE2": "a",
        "\xE3": "a",
        "\xE4": "a",
        "\xE5": "a",
        "\u1EA5": "a",
        "\u1EAF": "a",
        "\u1EB3": "a",
        "\u1EB5": "a",
        "\u1EB7": "a",
        "\xE6": "ae",
        "\u1EA7": "a",
        "\u1EB1": "a",
        "\u0203": "a",
        "\u1EA3": "a",
        "\u1EA1": "a",
        "\u1EA9": "a",
        "\u1EAB": "a",
        "\u1EAD": "a",
        "\xE7": "c",
        "\u1E09": "c",
        "\xE8": "e",
        "\xE9": "e",
        "\xEA": "e",
        "\xEB": "e",
        "\u1EBF": "e",
        "\u1E17": "e",
        "\u1EC1": "e",
        "\u1E15": "e",
        "\u1E1D": "e",
        "\u0207": "e",
        "\u1EBB": "e",
        "\u1EBD": "e",
        "\u1EB9": "e",
        "\u1EC3": "e",
        "\u1EC5": "e",
        "\u1EC7": "e",
        "\xEC": "i",
        "\xED": "i",
        "\xEE": "i",
        "\xEF": "i",
        "\u1E2F": "i",
        "\u020B": "i",
        "\u1EC9": "i",
        "\u1ECB": "i",
        "\xF0": "d",
        "\xF1": "n",
        "\xF2": "o",
        "\xF3": "o",
        "\xF4": "o",
        "\xF5": "o",
        "\xF6": "o",
        "\xF8": "o",
        "\u1ED1": "o",
        "\u1E4D": "o",
        "\u1E53": "o",
        "\u020F": "o",
        "\u1ECF": "o",
        "\u1ECD": "o",
        "\u1ED5": "o",
        "\u1ED7": "o",
        "\u1ED9": "o",
        "\u1EDD": "o",
        "\u1EDF": "o",
        "\u1EE1": "o",
        "\u1EDB": "o",
        "\u1EE3": "o",
        "\xF9": "u",
        "\xFA": "u",
        "\xFB": "u",
        "\xFC": "u",
        "\u1EE7": "u",
        "\u1EE5": "u",
        "\u1EED": "u",
        "\u1EEF": "u",
        "\u1EF1": "u",
        "\xFD": "y",
        "\xFF": "y",
        "\u0100": "A",
        "\u0101": "a",
        "\u0102": "A",
        "\u0103": "a",
        "\u0104": "A",
        "\u0105": "a",
        "\u0106": "C",
        "\u0107": "c",
        "\u0108": "C",
        "\u0109": "c",
        "\u010A": "C",
        "\u010B": "c",
        "\u010C": "C",
        "\u010D": "c",
        "C\u0306": "C",
        "c\u0306": "c",
        "\u010E": "D",
        "\u010F": "d",
        "\u0110": "D",
        "\u0111": "d",
        "\u0112": "E",
        "\u0113": "e",
        "\u0114": "E",
        "\u0115": "e",
        "\u0116": "E",
        "\u0117": "e",
        "\u0118": "E",
        "\u0119": "e",
        "\u011A": "E",
        "\u011B": "e",
        "\u011C": "G",
        "\u01F4": "G",
        "\u011D": "g",
        "\u01F5": "g",
        "\u011E": "G",
        "\u011F": "g",
        "\u0120": "G",
        "\u0121": "g",
        "\u0122": "G",
        "\u0123": "g",
        "\u0124": "H",
        "\u0125": "h",
        "\u0126": "H",
        "\u0127": "h",
        "\u1E2A": "H",
        "\u1E2B": "h",
        "\u0128": "I",
        "\u0129": "i",
        "\u012A": "I",
        "\u012B": "i",
        "\u012C": "I",
        "\u012D": "i",
        "\u012E": "I",
        "\u012F": "i",
        "\u0130": "I",
        "\u0131": "i",
        "\u0132": "IJ",
        "\u0133": "ij",
        "\u0134": "J",
        "\u0135": "j",
        "\u0136": "K",
        "\u0137": "k",
        "\u1E30": "K",
        "\u1E31": "k",
        "K\u0306": "K",
        "k\u0306": "k",
        "\u0139": "L",
        "\u013A": "l",
        "\u013B": "L",
        "\u013C": "l",
        "\u013D": "L",
        "\u013E": "l",
        "\u013F": "L",
        "\u0140": "l",
        "\u0141": "l",
        "\u0142": "l",
        "\u1E3E": "M",
        "\u1E3F": "m",
        "M\u0306": "M",
        "m\u0306": "m",
        "\u0143": "N",
        "\u0144": "n",
        "\u0145": "N",
        "\u0146": "n",
        "\u0147": "N",
        "\u0148": "n",
        "\u0149": "n",
        "N\u0306": "N",
        "n\u0306": "n",
        "\u014C": "O",
        "\u014D": "o",
        "\u014E": "O",
        "\u014F": "o",
        "\u0150": "O",
        "\u0151": "o",
        "\u0152": "OE",
        "\u0153": "oe",
        "P\u0306": "P",
        "p\u0306": "p",
        "\u0154": "R",
        "\u0155": "r",
        "\u0156": "R",
        "\u0157": "r",
        "\u0158": "R",
        "\u0159": "r",
        "R\u0306": "R",
        "r\u0306": "r",
        "\u0212": "R",
        "\u0213": "r",
        "\u015A": "S",
        "\u015B": "s",
        "\u015C": "S",
        "\u015D": "s",
        "\u015E": "S",
        "\u0218": "S",
        "\u0219": "s",
        "\u015F": "s",
        "\u0160": "S",
        "\u0161": "s",
        "\u0162": "T",
        "\u0163": "t",
        "\u021B": "t",
        "\u021A": "T",
        "\u0164": "T",
        "\u0165": "t",
        "\u0166": "T",
        "\u0167": "t",
        "T\u0306": "T",
        "t\u0306": "t",
        "\u0168": "U",
        "\u0169": "u",
        "\u016A": "U",
        "\u016B": "u",
        "\u016C": "U",
        "\u016D": "u",
        "\u016E": "U",
        "\u016F": "u",
        "\u0170": "U",
        "\u0171": "u",
        "\u0172": "U",
        "\u0173": "u",
        "\u0216": "U",
        "\u0217": "u",
        "V\u0306": "V",
        "v\u0306": "v",
        "\u0174": "W",
        "\u0175": "w",
        "\u1E82": "W",
        "\u1E83": "w",
        "X\u0306": "X",
        "x\u0306": "x",
        "\u0176": "Y",
        "\u0177": "y",
        "\u0178": "Y",
        "Y\u0306": "Y",
        "y\u0306": "y",
        "\u0179": "Z",
        "\u017A": "z",
        "\u017B": "Z",
        "\u017C": "z",
        "\u017D": "Z",
        "\u017E": "z",
        "\u017F": "s",
        "\u0192": "f",
        "\u01A0": "O",
        "\u01A1": "o",
        "\u01AF": "U",
        "\u01B0": "u",
        "\u01CD": "A",
        "\u01CE": "a",
        "\u01CF": "I",
        "\u01D0": "i",
        "\u01D1": "O",
        "\u01D2": "o",
        "\u01D3": "U",
        "\u01D4": "u",
        "\u01D5": "U",
        "\u01D6": "u",
        "\u01D7": "U",
        "\u01D8": "u",
        "\u01D9": "U",
        "\u01DA": "u",
        "\u01DB": "U",
        "\u01DC": "u",
        "\u1EE8": "U",
        "\u1EE9": "u",
        "\u1E78": "U",
        "\u1E79": "u",
        "\u01FA": "A",
        "\u01FB": "a",
        "\u01FC": "AE",
        "\u01FD": "ae",
        "\u01FE": "O",
        "\u01FF": "o",
        "\xDE": "TH",
        "\xFE": "th",
        "\u1E54": "P",
        "\u1E55": "p",
        "\u1E64": "S",
        "\u1E65": "s",
        "X\u0301": "X",
        "x\u0301": "x",
        "\u0403": "\u0413",
        "\u0453": "\u0433",
        "\u040C": "\u041A",
        "\u045C": "\u043A",
        "A\u030B": "A",
        "a\u030B": "a",
        "E\u030B": "E",
        "e\u030B": "e",
        "I\u030B": "I",
        "i\u030B": "i",
        "\u01F8": "N",
        "\u01F9": "n",
        "\u1ED2": "O",
        "\u1ED3": "o",
        "\u1E50": "O",
        "\u1E51": "o",
        "\u1EEA": "U",
        "\u1EEB": "u",
        "\u1E80": "W",
        "\u1E81": "w",
        "\u1EF2": "Y",
        "\u1EF3": "y",
        "\u0200": "A",
        "\u0201": "a",
        "\u0204": "E",
        "\u0205": "e",
        "\u0208": "I",
        "\u0209": "i",
        "\u020C": "O",
        "\u020D": "o",
        "\u0210": "R",
        "\u0211": "r",
        "\u0214": "U",
        "\u0215": "u",
        "B\u030C": "B",
        "b\u030C": "b",
        "\u010C\u0323": "C",
        "\u010D\u0323": "c",
        "\xCA\u030C": "E",
        "\xEA\u030C": "e",
        "F\u030C": "F",
        "f\u030C": "f",
        "\u01E6": "G",
        "\u01E7": "g",
        "\u021E": "H",
        "\u021F": "h",
        "J\u030C": "J",
        "\u01F0": "j",
        "\u01E8": "K",
        "\u01E9": "k",
        "M\u030C": "M",
        "m\u030C": "m",
        "P\u030C": "P",
        "p\u030C": "p",
        "Q\u030C": "Q",
        "q\u030C": "q",
        "\u0158\u0329": "R",
        "\u0159\u0329": "r",
        "\u1E66": "S",
        "\u1E67": "s",
        "V\u030C": "V",
        "v\u030C": "v",
        "W\u030C": "W",
        "w\u030C": "w",
        "X\u030C": "X",
        "x\u030C": "x",
        "Y\u030C": "Y",
        "y\u030C": "y",
        "A\u0327": "A",
        "a\u0327": "a",
        "B\u0327": "B",
        "b\u0327": "b",
        "\u1E10": "D",
        "\u1E11": "d",
        "\u0228": "E",
        "\u0229": "e",
        "\u0190\u0327": "E",
        "\u025B\u0327": "e",
        "\u1E28": "H",
        "\u1E29": "h",
        "I\u0327": "I",
        "i\u0327": "i",
        "\u0197\u0327": "I",
        "\u0268\u0327": "i",
        "M\u0327": "M",
        "m\u0327": "m",
        "O\u0327": "O",
        "o\u0327": "o",
        "Q\u0327": "Q",
        "q\u0327": "q",
        "U\u0327": "U",
        "u\u0327": "u",
        "X\u0327": "X",
        "x\u0327": "x",
        "Z\u0327": "Z",
        "z\u0327": "z",
        "\u0439": "\u0438",
        "\u0419": "\u0418",
        "\u0451": "\u0435",
        "\u0401": "\u0415"
      };
      var chars = Object.keys(characterMap).join("|");
      var allAccents = new RegExp(chars, "g");
      var firstAccent = new RegExp(chars, "");
      function matcher(match3) {
        return characterMap[match3];
      }
      var removeAccents5 = function(string) {
        return string.replace(allAccents, matcher);
      };
      var hasAccents = function(string) {
        return !!string.match(firstAccent);
      };
      module.exports = removeAccents5;
      module.exports.has = hasAccents;
      module.exports.remove = removeAccents5;
    }
  });

  // package-external:@wordpress/wordcount
  var require_wordcount = __commonJS({
    "package-external:@wordpress/wordcount"(exports, module) {
      module.exports = window.wp.wordcount;
    }
  });

  // package-external:@wordpress/keycodes
  var require_keycodes = __commonJS({
    "package-external:@wordpress/keycodes"(exports, module) {
      module.exports = window.wp.keycodes;
    }
  });

  // node_modules/fast-deep-equal/es6/index.js
  var require_es6 = __commonJS({
    "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
      "use strict";
      module.exports = function equal(a3, b3) {
        if (a3 === b3) return true;
        if (a3 && b3 && typeof a3 == "object" && typeof b3 == "object") {
          if (a3.constructor !== b3.constructor) return false;
          var length2, i3, keys;
          if (Array.isArray(a3)) {
            length2 = a3.length;
            if (length2 != b3.length) return false;
            for (i3 = length2; i3-- !== 0; )
              if (!equal(a3[i3], b3[i3])) return false;
            return true;
          }
          if (a3 instanceof Map && b3 instanceof Map) {
            if (a3.size !== b3.size) return false;
            for (i3 of a3.entries())
              if (!b3.has(i3[0])) return false;
            for (i3 of a3.entries())
              if (!equal(i3[1], b3.get(i3[0]))) return false;
            return true;
          }
          if (a3 instanceof Set && b3 instanceof Set) {
            if (a3.size !== b3.size) return false;
            for (i3 of a3.entries())
              if (!b3.has(i3[0])) return false;
            return true;
          }
          if (ArrayBuffer.isView(a3) && ArrayBuffer.isView(b3)) {
            length2 = a3.length;
            if (length2 != b3.length) return false;
            for (i3 = length2; i3-- !== 0; )
              if (a3[i3] !== b3[i3]) return false;
            return true;
          }
          if (a3.constructor === RegExp) return a3.source === b3.source && a3.flags === b3.flags;
          if (a3.valueOf !== Object.prototype.valueOf) return a3.valueOf() === b3.valueOf();
          if (a3.toString !== Object.prototype.toString) return a3.toString() === b3.toString();
          keys = Object.keys(a3);
          length2 = keys.length;
          if (length2 !== Object.keys(b3).length) return false;
          for (i3 = length2; i3-- !== 0; )
            if (!Object.prototype.hasOwnProperty.call(b3, keys[i3])) return false;
          for (i3 = length2; i3-- !== 0; ) {
            var key = keys[i3];
            if (!equal(a3[key], b3[key])) return false;
          }
          return true;
        }
        return a3 !== a3 && b3 !== b3;
      };
    }
  });

  // package-external:@wordpress/warning
  var require_warning = __commonJS({
    "package-external:@wordpress/warning"(exports, module) {
      module.exports = window.wp.warning;
    }
  });

  // node_modules/deepmerge/dist/cjs.js
  var require_cjs = __commonJS({
    "node_modules/deepmerge/dist/cjs.js"(exports, module) {
      "use strict";
      var isMergeableObject = function isMergeableObject2(value) {
        return isNonNullObject(value) && !isSpecial(value);
      };
      function isNonNullObject(value) {
        return !!value && typeof value === "object";
      }
      function isSpecial(value) {
        var stringValue = Object.prototype.toString.call(value);
        return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
      }
      var canUseSymbol = typeof Symbol === "function" && Symbol.for;
      var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
      function isReactElement(value) {
        return value.$$typeof === REACT_ELEMENT_TYPE;
      }
      function emptyTarget(val) {
        return Array.isArray(val) ? [] : {};
      }
      function cloneUnlessOtherwiseSpecified(value, options) {
        return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value;
      }
      function defaultArrayMerge(target, source, options) {
        return target.concat(source).map(function(element) {
          return cloneUnlessOtherwiseSpecified(element, options);
        });
      }
      function getMergeFunction(key, options) {
        if (!options.customMerge) {
          return deepmerge2;
        }
        var customMerge = options.customMerge(key);
        return typeof customMerge === "function" ? customMerge : deepmerge2;
      }
      function getEnumerableOwnPropertySymbols(target) {
        return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) {
          return Object.propertyIsEnumerable.call(target, symbol3);
        }) : [];
      }
      function getKeys2(target) {
        return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
      }
      function propertyIsOnObject(object, property) {
        try {
          return property in object;
        } catch (_) {
          return false;
        }
      }
      function propertyIsUnsafe(target, key) {
        return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
      }
      function mergeObject(target, source, options) {
        var destination = {};
        if (options.isMergeableObject(target)) {
          getKeys2(target).forEach(function(key) {
            destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
          });
        }
        getKeys2(source).forEach(function(key) {
          if (propertyIsUnsafe(target, key)) {
            return;
          }
          if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
            destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
          } else {
            destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
          }
        });
        return destination;
      }
      function deepmerge2(target, source, options) {
        options = options || {};
        options.arrayMerge = options.arrayMerge || defaultArrayMerge;
        options.isMergeableObject = options.isMergeableObject || isMergeableObject;
        options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
        var sourceIsArray = Array.isArray(source);
        var targetIsArray = Array.isArray(target);
        var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
        if (!sourceAndTargetTypesMatch) {
          return cloneUnlessOtherwiseSpecified(source, options);
        } else if (sourceIsArray) {
          return options.arrayMerge(target, source, options);
        } else {
          return mergeObject(target, source, options);
        }
      }
      deepmerge2.all = function deepmergeAll(array, options) {
        if (!Array.isArray(array)) {
          throw new Error("first argument should be an array");
        }
        return array.reduce(function(prev, next) {
          return deepmerge2(prev, next, options);
        }, {});
      };
      var deepmerge_1 = deepmerge2;
      module.exports = deepmerge_1;
    }
  });

  // package-external:@wordpress/viewport
  var require_viewport = __commonJS({
    "package-external:@wordpress/viewport"(exports, module) {
      module.exports = window.wp.viewport;
    }
  });

  // package-external:@wordpress/plugins
  var require_plugins = __commonJS({
    "package-external:@wordpress/plugins"(exports, module) {
      module.exports = window.wp.plugins;
    }
  });

  // package-external:@wordpress/upload-media
  var require_upload_media = __commonJS({
    "package-external:@wordpress/upload-media"(exports, module) {
      module.exports = window.wp.uploadMedia;
    }
  });

  // package-external:@wordpress/style-engine
  var require_style_engine = __commonJS({
    "package-external:@wordpress/style-engine"(exports, module) {
      module.exports = window.wp.styleEngine;
    }
  });

  // node_modules/diff/lib/diff/base.js
  var require_base = __commonJS({
    "node_modules/diff/lib/diff/base.js"(exports) {
      "use strict";
      Object.defineProperty(exports, "__esModule", {
        value: true
      });
      exports.default = Diff;
      function Diff() {
      }
      Diff.prototype = {
        /*istanbul ignore start*/
        /*istanbul ignore end*/
        diff: function diff(oldString, newString) {
          var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
          var callback = options.callback;
          if (typeof options === "function") {
            callback = options;
            options = {};
          }
          this.options = options;
          var self2 = this;
          function done(value) {
            if (callback) {
              setTimeout(function() {
                callback(void 0, value);
              }, 0);
              return true;
            } else {
              return value;
            }
          }
          oldString = this.castInput(oldString);
          newString = this.castInput(newString);
          oldString = this.removeEmpty(this.tokenize(oldString));
          newString = this.removeEmpty(this.tokenize(newString));
          var newLen = newString.length, oldLen = oldString.length;
          var editLength = 1;
          var maxEditLength = newLen + oldLen;
          var bestPath = [{
            newPos: -1,
            components: []
          }];
          var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
          if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
            return done([{
              value: this.join(newString),
              count: newString.length
            }]);
          }
          function execEditLength() {
            for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
              var basePath = (
                /*istanbul ignore start*/
                void 0
              );
              var addPath = bestPath[diagonalPath - 1], removePath = bestPath[diagonalPath + 1], _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
              if (addPath) {
                bestPath[diagonalPath - 1] = void 0;
              }
              var canAdd = addPath && addPath.newPos + 1 < newLen, canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
              if (!canAdd && !canRemove) {
                bestPath[diagonalPath] = void 0;
                continue;
              }
              if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
                basePath = clonePath(removePath);
                self2.pushComponent(basePath.components, void 0, true);
              } else {
                basePath = addPath;
                basePath.newPos++;
                self2.pushComponent(basePath.components, true, void 0);
              }
              _oldPos = self2.extractCommon(basePath, newString, oldString, diagonalPath);
              if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
                return done(buildValues(self2, basePath.components, newString, oldString, self2.useLongestToken));
              } else {
                bestPath[diagonalPath] = basePath;
              }
            }
            editLength++;
          }
          if (callback) {
            (function exec() {
              setTimeout(function() {
                if (editLength > maxEditLength) {
                  return callback();
                }
                if (!execEditLength()) {
                  exec();
                }
              }, 0);
            })();
          } else {
            while (editLength <= maxEditLength) {
              var ret = execEditLength();
              if (ret) {
                return ret;
              }
            }
          }
        },
        /*istanbul ignore start*/
        /*istanbul ignore end*/
        pushComponent: function pushComponent(components, added, removed) {
          var last = components[components.length - 1];
          if (last && last.added === added && last.removed === removed) {
            components[components.length - 1] = {
              count: last.count + 1,
              added,
              removed
            };
          } else {
            components.push({
              count: 1,
              added,
              removed
            });
          }
        },
        /*istanbul ignore start*/
        /*istanbul ignore end*/
        extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
          var newLen = newString.length, oldLen = oldString.length, newPos = basePath.newPos, oldPos = newPos - diagonalPath, commonCount = 0;
          while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
            newPos++;
            oldPos++;
            commonCount++;
          }
          if (commonCount) {
            basePath.components.push({
              count: commonCount
            });
          }
          basePath.newPos = newPos;
          return oldPos;
        },
        /*istanbul ignore start*/
        /*istanbul ignore end*/
        equals: function equals3(left, right) {
          if (this.options.comparator) {
            return this.options.comparator(left, right);
          } else {
            return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
          }
        },
        /*istanbul ignore start*/
        /*istanbul ignore end*/
        removeEmpty: function removeEmpty(array) {
          var ret = [];
          for (var i3 = 0; i3 < array.length; i3++) {
            if (array[i3]) {
              ret.push(array[i3]);
            }
          }
          return ret;
        },
        /*istanbul ignore start*/
        /*istanbul ignore end*/
        castInput: function castInput(value) {
          return value;
        },
        /*istanbul ignore start*/
        /*istanbul ignore end*/
        tokenize: function tokenize(value) {
          return value.split("");
        },
        /*istanbul ignore start*/
        /*istanbul ignore end*/
        join: function join(chars) {
          return chars.join("");
        }
      };
      function buildValues(diff, components, newString, oldString, useLongestToken) {
        var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
        for (; componentPos < componentLen; componentPos++) {
          var component = components[componentPos];
          if (!component.removed) {
            if (!component.added && useLongestToken) {
              var value = newString.slice(newPos, newPos + component.count);
              value = value.map(function(value2, i3) {
                var oldValue = oldString[oldPos + i3];
                return oldValue.length > value2.length ? oldValue : value2;
              });
              component.value = diff.join(value);
            } else {
              component.value = diff.join(newString.slice(newPos, newPos + component.count));
            }
            newPos += component.count;
            if (!component.added) {
              oldPos += component.count;
            }
          } else {
            component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
            oldPos += component.count;
            if (componentPos && components[componentPos - 1].added) {
              var tmp = components[componentPos - 1];
              components[componentPos - 1] = components[componentPos];
              components[componentPos] = tmp;
            }
          }
        }
        var lastComponent = components[componentLen - 1];
        if (componentLen > 1 && typeof lastComponent.value === "string" && (lastComponent.added || lastComponent.removed) && diff.equals("", lastComponent.value)) {
          components[componentLen - 2].value += lastComponent.value;
          components.pop();
        }
        return components;
      }
      function clonePath(path) {
        return {
          newPos: path.newPos,
          components: path.components.slice(0)
        };
      }
    }
  });

  // node_modules/diff/lib/diff/array.js
  var require_array = __commonJS({
    "node_modules/diff/lib/diff/array.js"(exports) {
      "use strict";
      Object.defineProperty(exports, "__esModule", {
        value: true
      });
      exports.diffArrays = diffArrays3;
      exports.arrayDiff = void 0;
      var _base = _interopRequireDefault(require_base());
      function _interopRequireDefault(obj) {
        return obj && obj.__esModule ? obj : { default: obj };
      }
      var arrayDiff = new /*istanbul ignore start*/
      _base.default();
      exports.arrayDiff = arrayDiff;
      arrayDiff.tokenize = function(value) {
        return value.slice();
      };
      arrayDiff.join = arrayDiff.removeEmpty = function(value) {
        return value;
      };
      function diffArrays3(oldArr, newArr, callback) {
        return arrayDiff.diff(oldArr, newArr, callback);
      }
    }
  });

  // node_modules/diff/lib/util/params.js
  var require_params = __commonJS({
    "node_modules/diff/lib/util/params.js"(exports) {
      "use strict";
      Object.defineProperty(exports, "__esModule", {
        value: true
      });
      exports.generateOptions = generateOptions;
      function generateOptions(options, defaults2) {
        if (typeof options === "function") {
          defaults2.callback = options;
        } else if (options) {
          for (var name2 in options) {
            if (options.hasOwnProperty(name2)) {
              defaults2[name2] = options[name2];
            }
          }
        }
        return defaults2;
      }
    }
  });

  // node_modules/diff/lib/diff/word.js
  var require_word = __commonJS({
    "node_modules/diff/lib/diff/word.js"(exports) {
      "use strict";
      Object.defineProperty(exports, "__esModule", {
        value: true
      });
      exports.diffWords = diffWords3;
      exports.diffWordsWithSpace = diffWordsWithSpace;
      exports.wordDiff = void 0;
      var _base = _interopRequireDefault(require_base());
      var _params = require_params();
      function _interopRequireDefault(obj) {
        return obj && obj.__esModule ? obj : { default: obj };
      }
      var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
      var reWhitespace = /\S/;
      var wordDiff = new /*istanbul ignore start*/
      _base.default();
      exports.wordDiff = wordDiff;
      wordDiff.equals = function(left, right) {
        if (this.options.ignoreCase) {
          left = left.toLowerCase();
          right = right.toLowerCase();
        }
        return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
      };
      wordDiff.tokenize = function(value) {
        var tokens = value.split(/(\s+|[()[\]{}'"]|\b)/);
        for (var i3 = 0; i3 < tokens.length - 1; i3++) {
          if (!tokens[i3 + 1] && tokens[i3 + 2] && extendedWordChars.test(tokens[i3]) && extendedWordChars.test(tokens[i3 + 2])) {
            tokens[i3] += tokens[i3 + 2];
            tokens.splice(i3 + 1, 2);
            i3--;
          }
        }
        return tokens;
      };
      function diffWords3(oldStr, newStr, options) {
        options = /*istanbul ignore start*/
        (0, /*istanbul ignore end*/
        /*istanbul ignore start*/
        _params.generateOptions)(options, {
          ignoreWhitespace: true
        });
        return wordDiff.diff(oldStr, newStr, options);
      }
      function diffWordsWithSpace(oldStr, newStr, options) {
        return wordDiff.diff(oldStr, newStr, options);
      }
    }
  });

  // package-external:@wordpress/block-serialization-default-parser
  var require_block_serialization_default_parser = __commonJS({
    "package-external:@wordpress/block-serialization-default-parser"(exports, module) {
      module.exports = window.wp.blockSerializationDefaultParser;
    }
  });

  // package-external:@wordpress/rich-text
  var require_rich_text = __commonJS({
    "package-external:@wordpress/rich-text"(exports, module) {
      module.exports = window.wp.richText;
    }
  });

  // package-external:@wordpress/commands
  var require_commands = __commonJS({
    "package-external:@wordpress/commands"(exports, module) {
      module.exports = window.wp.commands;
    }
  });

  // package-external:@wordpress/keyboard-shortcuts
  var require_keyboard_shortcuts = __commonJS({
    "package-external:@wordpress/keyboard-shortcuts"(exports, module) {
      module.exports = window.wp.keyboardShortcuts;
    }
  });

  // node_modules/fast-deep-equal/index.js
  var require_fast_deep_equal = __commonJS({
    "node_modules/fast-deep-equal/index.js"(exports, module) {
      "use strict";
      module.exports = function equal(a3, b3) {
        if (a3 === b3) return true;
        if (a3 && b3 && typeof a3 == "object" && typeof b3 == "object") {
          if (a3.constructor !== b3.constructor) return false;
          var length2, i3, keys;
          if (Array.isArray(a3)) {
            length2 = a3.length;
            if (length2 != b3.length) return false;
            for (i3 = length2; i3-- !== 0; )
              if (!equal(a3[i3], b3[i3])) return false;
            return true;
          }
          if (a3.constructor === RegExp) return a3.source === b3.source && a3.flags === b3.flags;
          if (a3.valueOf !== Object.prototype.valueOf) return a3.valueOf() === b3.valueOf();
          if (a3.toString !== Object.prototype.toString) return a3.toString() === b3.toString();
          keys = Object.keys(a3);
          length2 = keys.length;
          if (length2 !== Object.keys(b3).length) return false;
          for (i3 = length2; i3-- !== 0; )
            if (!Object.prototype.hasOwnProperty.call(b3, keys[i3])) return false;
          for (i3 = length2; i3-- !== 0; ) {
            var key = keys[i3];
            if (!equal(a3[key], b3[key])) return false;
          }
          return true;
        }
        return a3 !== a3 && b3 !== b3;
      };
    }
  });

  // package-external:@wordpress/dom
  var require_dom = __commonJS({
    "package-external:@wordpress/dom"(exports, module) {
      module.exports = window.wp.dom;
    }
  });

  // node_modules/react-is/cjs/react-is.development.js
  var require_react_is_development = __commonJS({
    "node_modules/react-is/cjs/react-is.development.js"(exports) {
      "use strict";
      if (true) {
        (function() {
          "use strict";
          var hasSymbol = typeof Symbol === "function" && Symbol.for;
          var REACT_ELEMENT_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
          var REACT_PORTAL_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.portal") : 60106;
          var REACT_FRAGMENT_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.fragment") : 60107;
          var REACT_STRICT_MODE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.strict_mode") : 60108;
          var REACT_PROFILER_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.profiler") : 60114;
          var REACT_PROVIDER_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.provider") : 60109;
          var REACT_CONTEXT_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.context") : 60110;
          var REACT_ASYNC_MODE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.async_mode") : 60111;
          var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.concurrent_mode") : 60111;
          var REACT_FORWARD_REF_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.forward_ref") : 60112;
          var REACT_SUSPENSE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.suspense") : 60113;
          var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.suspense_list") : 60120;
          var REACT_MEMO_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.memo") : 60115;
          var REACT_LAZY_TYPE2 = hasSymbol ? /* @__PURE__ */ Symbol.for("react.lazy") : 60116;
          var REACT_BLOCK_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.block") : 60121;
          var REACT_FUNDAMENTAL_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.fundamental") : 60117;
          var REACT_RESPONDER_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.responder") : 60118;
          var REACT_SCOPE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.scope") : 60119;
          function isValidElementType(type) {
            return typeof type === "string" || typeof type === "function" || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
            type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE2 || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
          }
          function typeOf(object) {
            if (typeof object === "object" && object !== null) {
              var $$typeof = object.$$typeof;
              switch ($$typeof) {
                case REACT_ELEMENT_TYPE:
                  var type = object.type;
                  switch (type) {
                    case REACT_ASYNC_MODE_TYPE:
                    case REACT_CONCURRENT_MODE_TYPE:
                    case REACT_FRAGMENT_TYPE:
                    case REACT_PROFILER_TYPE:
                    case REACT_STRICT_MODE_TYPE:
                    case REACT_SUSPENSE_TYPE:
                      return type;
                    default:
                      var $$typeofType = type && type.$$typeof;
                      switch ($$typeofType) {
                        case REACT_CONTEXT_TYPE:
                        case REACT_FORWARD_REF_TYPE:
                        case REACT_LAZY_TYPE2:
                        case REACT_MEMO_TYPE:
                        case REACT_PROVIDER_TYPE:
                          return $$typeofType;
                        default:
                          return $$typeof;
                      }
                  }
                case REACT_PORTAL_TYPE:
                  return $$typeof;
              }
            }
            return void 0;
          }
          var AsyncMode = REACT_ASYNC_MODE_TYPE;
          var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
          var ContextConsumer = REACT_CONTEXT_TYPE;
          var ContextProvider = REACT_PROVIDER_TYPE;
          var Element2 = REACT_ELEMENT_TYPE;
          var ForwardRef = REACT_FORWARD_REF_TYPE;
          var Fragment115 = REACT_FRAGMENT_TYPE;
          var Lazy = REACT_LAZY_TYPE2;
          var Memo = REACT_MEMO_TYPE;
          var Portal = REACT_PORTAL_TYPE;
          var Profiler = REACT_PROFILER_TYPE;
          var StrictMode = REACT_STRICT_MODE_TYPE;
          var Suspense = REACT_SUSPENSE_TYPE;
          var hasWarnedAboutDeprecatedIsAsyncMode = false;
          function isAsyncMode(object) {
            {
              if (!hasWarnedAboutDeprecatedIsAsyncMode) {
                hasWarnedAboutDeprecatedIsAsyncMode = true;
                console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.");
              }
            }
            return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
          }
          function isConcurrentMode(object) {
            return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
          }
          function isContextConsumer(object) {
            return typeOf(object) === REACT_CONTEXT_TYPE;
          }
          function isContextProvider(object) {
            return typeOf(object) === REACT_PROVIDER_TYPE;
          }
          function isElement(object) {
            return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
          }
          function isForwardRef(object) {
            return typeOf(object) === REACT_FORWARD_REF_TYPE;
          }
          function isFragment(object) {
            return typeOf(object) === REACT_FRAGMENT_TYPE;
          }
          function isLazy(object) {
            return typeOf(object) === REACT_LAZY_TYPE2;
          }
          function isMemo(object) {
            return typeOf(object) === REACT_MEMO_TYPE;
          }
          function isPortal(object) {
            return typeOf(object) === REACT_PORTAL_TYPE;
          }
          function isProfiler(object) {
            return typeOf(object) === REACT_PROFILER_TYPE;
          }
          function isStrictMode(object) {
            return typeOf(object) === REACT_STRICT_MODE_TYPE;
          }
          function isSuspense(object) {
            return typeOf(object) === REACT_SUSPENSE_TYPE;
          }
          exports.AsyncMode = AsyncMode;
          exports.ConcurrentMode = ConcurrentMode;
          exports.ContextConsumer = ContextConsumer;
          exports.ContextProvider = ContextProvider;
          exports.Element = Element2;
          exports.ForwardRef = ForwardRef;
          exports.Fragment = Fragment115;
          exports.Lazy = Lazy;
          exports.Memo = Memo;
          exports.Portal = Portal;
          exports.Profiler = Profiler;
          exports.StrictMode = StrictMode;
          exports.Suspense = Suspense;
          exports.isAsyncMode = isAsyncMode;
          exports.isConcurrentMode = isConcurrentMode;
          exports.isContextConsumer = isContextConsumer;
          exports.isContextProvider = isContextProvider;
          exports.isElement = isElement;
          exports.isForwardRef = isForwardRef;
          exports.isFragment = isFragment;
          exports.isLazy = isLazy;
          exports.isMemo = isMemo;
          exports.isPortal = isPortal;
          exports.isProfiler = isProfiler;
          exports.isStrictMode = isStrictMode;
          exports.isSuspense = isSuspense;
          exports.isValidElementType = isValidElementType;
          exports.typeOf = typeOf;
        })();
      }
    }
  });

  // node_modules/react-is/index.js
  var require_react_is = __commonJS({
    "node_modules/react-is/index.js"(exports, module) {
      "use strict";
      if (false) {
        module.exports = null;
      } else {
        module.exports = require_react_is_development();
      }
    }
  });

  // node_modules/object-assign/index.js
  var require_object_assign = __commonJS({
    "node_modules/object-assign/index.js"(exports, module) {
      "use strict";
      var getOwnPropertySymbols = Object.getOwnPropertySymbols;
      var hasOwnProperty2 = Object.prototype.hasOwnProperty;
      var propIsEnumerable = Object.prototype.propertyIsEnumerable;
      function toObject(val) {
        if (val === null || val === void 0) {
          throw new TypeError("Object.assign cannot be called with null or undefined");
        }
        return Object(val);
      }
      function shouldUseNative() {
        try {
          if (!Object.assign) {
            return false;
          }
          var test1 = new String("abc");
          test1[5] = "de";
          if (Object.getOwnPropertyNames(test1)[0] === "5") {
            return false;
          }
          var test2 = {};
          for (var i3 = 0; i3 < 10; i3++) {
            test2["_" + String.fromCharCode(i3)] = i3;
          }
          var order2 = Object.getOwnPropertyNames(test2).map(function(n3) {
            return test2[n3];
          });
          if (order2.join("") !== "0123456789") {
            return false;
          }
          var test3 = {};
          "abcdefghijklmnopqrst".split("").forEach(function(letter) {
            test3[letter] = letter;
          });
          if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
            return false;
          }
          return true;
        } catch (err) {
          return false;
        }
      }
      module.exports = shouldUseNative() ? Object.assign : function(target, source) {
        var from;
        var to2 = toObject(target);
        var symbols;
        for (var s3 = 1; s3 < arguments.length; s3++) {
          from = Object(arguments[s3]);
          for (var key in from) {
            if (hasOwnProperty2.call(from, key)) {
              to2[key] = from[key];
            }
          }
          if (getOwnPropertySymbols) {
            symbols = getOwnPropertySymbols(from);
            for (var i3 = 0; i3 < symbols.length; i3++) {
              if (propIsEnumerable.call(from, symbols[i3])) {
                to2[symbols[i3]] = from[symbols[i3]];
              }
            }
          }
        }
        return to2;
      };
    }
  });

  // node_modules/prop-types/lib/ReactPropTypesSecret.js
  var require_ReactPropTypesSecret = __commonJS({
    "node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
      "use strict";
      var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
      module.exports = ReactPropTypesSecret;
    }
  });

  // node_modules/prop-types/lib/has.js
  var require_has = __commonJS({
    "node_modules/prop-types/lib/has.js"(exports, module) {
      module.exports = Function.call.bind(Object.prototype.hasOwnProperty);
    }
  });

  // node_modules/prop-types/checkPropTypes.js
  var require_checkPropTypes = __commonJS({
    "node_modules/prop-types/checkPropTypes.js"(exports, module) {
      "use strict";
      var printWarning = function() {
      };
      if (true) {
        ReactPropTypesSecret = require_ReactPropTypesSecret();
        loggedTypeFailures = {};
        has = require_has();
        printWarning = function(text) {
          var message2 = "Warning: " + text;
          if (typeof console !== "undefined") {
            console.error(message2);
          }
          try {
            throw new Error(message2);
          } catch (x2) {
          }
        };
      }
      var ReactPropTypesSecret;
      var loggedTypeFailures;
      var has;
      function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
        if (true) {
          for (var typeSpecName in typeSpecs) {
            if (has(typeSpecs, typeSpecName)) {
              var error2;
              try {
                if (typeof typeSpecs[typeSpecName] !== "function") {
                  var err = Error(
                    (componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
                  );
                  err.name = "Invariant Violation";
                  throw err;
                }
                error2 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
              } catch (ex) {
                error2 = ex;
              }
              if (error2 && !(error2 instanceof Error)) {
                printWarning(
                  (componentName || "React class") + ": type specification of " + location + " `" + typeSpecName + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof error2 + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."
                );
              }
              if (error2 instanceof Error && !(error2.message in loggedTypeFailures)) {
                loggedTypeFailures[error2.message] = true;
                var stack = getStack ? getStack() : "";
                printWarning(
                  "Failed " + location + " type: " + error2.message + (stack != null ? stack : "")
                );
              }
            }
          }
        }
      }
      checkPropTypes.resetWarningCache = function() {
        if (true) {
          loggedTypeFailures = {};
        }
      };
      module.exports = checkPropTypes;
    }
  });

  // node_modules/prop-types/factoryWithTypeCheckers.js
  var require_factoryWithTypeCheckers = __commonJS({
    "node_modules/prop-types/factoryWithTypeCheckers.js"(exports, module) {
      "use strict";
      var ReactIs = require_react_is();
      var assign2 = require_object_assign();
      var ReactPropTypesSecret = require_ReactPropTypesSecret();
      var has = require_has();
      var checkPropTypes = require_checkPropTypes();
      var printWarning = function() {
      };
      if (true) {
        printWarning = function(text) {
          var message2 = "Warning: " + text;
          if (typeof console !== "undefined") {
            console.error(message2);
          }
          try {
            throw new Error(message2);
          } catch (x2) {
          }
        };
      }
      function emptyFunctionThatReturnsNull() {
        return null;
      }
      module.exports = function(isValidElement5, throwOnDirectAccess) {
        var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
        var FAUX_ITERATOR_SYMBOL = "@@iterator";
        function getIteratorFn(maybeIterable) {
          var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
          if (typeof iteratorFn === "function") {
            return iteratorFn;
          }
        }
        var ANONYMOUS = "<<anonymous>>";
        var ReactPropTypes = {
          array: createPrimitiveTypeChecker("array"),
          bigint: createPrimitiveTypeChecker("bigint"),
          bool: createPrimitiveTypeChecker("boolean"),
          func: createPrimitiveTypeChecker("function"),
          number: createPrimitiveTypeChecker("number"),
          object: createPrimitiveTypeChecker("object"),
          string: createPrimitiveTypeChecker("string"),
          symbol: createPrimitiveTypeChecker("symbol"),
          any: createAnyTypeChecker(),
          arrayOf: createArrayOfTypeChecker,
          element: createElementTypeChecker(),
          elementType: createElementTypeTypeChecker(),
          instanceOf: createInstanceTypeChecker,
          node: createNodeChecker(),
          objectOf: createObjectOfTypeChecker,
          oneOf: createEnumTypeChecker,
          oneOfType: createUnionTypeChecker,
          shape: createShapeTypeChecker,
          exact: createStrictShapeTypeChecker
        };
        function is2(x2, y3) {
          if (x2 === y3) {
            return x2 !== 0 || 1 / x2 === 1 / y3;
          } else {
            return x2 !== x2 && y3 !== y3;
          }
        }
        function PropTypeError(message2, data) {
          this.message = message2;
          this.data = data && typeof data === "object" ? data : {};
          this.stack = "";
        }
        PropTypeError.prototype = Error.prototype;
        function createChainableTypeChecker(validate) {
          if (true) {
            var manualPropTypeCallCache = {};
            var manualPropTypeWarningCount = 0;
          }
          function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
            componentName = componentName || ANONYMOUS;
            propFullName = propFullName || propName;
            if (secret !== ReactPropTypesSecret) {
              if (throwOnDirectAccess) {
                var err = new Error(
                  "Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types"
                );
                err.name = "Invariant Violation";
                throw err;
              } else if (typeof console !== "undefined") {
                var cacheKey2 = componentName + ":" + propName;
                if (!manualPropTypeCallCache[cacheKey2] && // Avoid spamming the console because they are often not actionable except for lib authors
                manualPropTypeWarningCount < 3) {
                  printWarning(
                    "You are manually calling a React.PropTypes validation function for the `" + propFullName + "` prop on `" + componentName + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."
                  );
                  manualPropTypeCallCache[cacheKey2] = true;
                  manualPropTypeWarningCount++;
                }
              }
            }
            if (props[propName] == null) {
              if (isRequired) {
                if (props[propName] === null) {
                  return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
                }
                return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
              }
              return null;
            } else {
              return validate(props, propName, componentName, location, propFullName);
            }
          }
          var chainedCheckType = checkType.bind(null, false);
          chainedCheckType.isRequired = checkType.bind(null, true);
          return chainedCheckType;
        }
        function createPrimitiveTypeChecker(expectedType) {
          function validate(props, propName, componentName, location, propFullName, secret) {
            var propValue = props[propName];
            var propType = getPropType(propValue);
            if (propType !== expectedType) {
              var preciseType = getPreciseType(propValue);
              return new PropTypeError(
                "Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."),
                { expectedType }
              );
            }
            return null;
          }
          return createChainableTypeChecker(validate);
        }
        function createAnyTypeChecker() {
          return createChainableTypeChecker(emptyFunctionThatReturnsNull);
        }
        function createArrayOfTypeChecker(typeChecker) {
          function validate(props, propName, componentName, location, propFullName) {
            if (typeof typeChecker !== "function") {
              return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf.");
            }
            var propValue = props[propName];
            if (!Array.isArray(propValue)) {
              var propType = getPropType(propValue);
              return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array."));
            }
            for (var i3 = 0; i3 < propValue.length; i3++) {
              var error2 = typeChecker(propValue, i3, componentName, location, propFullName + "[" + i3 + "]", ReactPropTypesSecret);
              if (error2 instanceof Error) {
                return error2;
              }
            }
            return null;
          }
          return createChainableTypeChecker(validate);
        }
        function createElementTypeChecker() {
          function validate(props, propName, componentName, location, propFullName) {
            var propValue = props[propName];
            if (!isValidElement5(propValue)) {
              var propType = getPropType(propValue);
              return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement."));
            }
            return null;
          }
          return createChainableTypeChecker(validate);
        }
        function createElementTypeTypeChecker() {
          function validate(props, propName, componentName, location, propFullName) {
            var propValue = props[propName];
            if (!ReactIs.isValidElementType(propValue)) {
              var propType = getPropType(propValue);
              return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement type."));
            }
            return null;
          }
          return createChainableTypeChecker(validate);
        }
        function createInstanceTypeChecker(expectedClass) {
          function validate(props, propName, componentName, location, propFullName) {
            if (!(props[propName] instanceof expectedClass)) {
              var expectedClassName = expectedClass.name || ANONYMOUS;
              var actualClassName = getClassName(props[propName]);
              return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
            }
            return null;
          }
          return createChainableTypeChecker(validate);
        }
        function createEnumTypeChecker(expectedValues) {
          if (!Array.isArray(expectedValues)) {
            if (true) {
              if (arguments.length > 1) {
                printWarning(
                  "Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."
                );
              } else {
                printWarning("Invalid argument supplied to oneOf, expected an array.");
              }
            }
            return emptyFunctionThatReturnsNull;
          }
          function validate(props, propName, componentName, location, propFullName) {
            var propValue = props[propName];
            for (var i3 = 0; i3 < expectedValues.length; i3++) {
              if (is2(propValue, expectedValues[i3])) {
                return null;
              }
            }
            var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
              var type = getPreciseType(value);
              if (type === "symbol") {
                return String(value);
              }
              return value;
            });
            return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + String(propValue) + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + "."));
          }
          return createChainableTypeChecker(validate);
        }
        function createObjectOfTypeChecker(typeChecker) {
          function validate(props, propName, componentName, location, propFullName) {
            if (typeof typeChecker !== "function") {
              return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf.");
            }
            var propValue = props[propName];
            var propType = getPropType(propValue);
            if (propType !== "object") {
              return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object."));
            }
            for (var key in propValue) {
              if (has(propValue, key)) {
                var error2 = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
                if (error2 instanceof Error) {
                  return error2;
                }
              }
            }
            return null;
          }
          return createChainableTypeChecker(validate);
        }
        function createUnionTypeChecker(arrayOfTypeCheckers) {
          if (!Array.isArray(arrayOfTypeCheckers)) {
            true ? printWarning("Invalid argument supplied to oneOfType, expected an instance of array.") : void 0;
            return emptyFunctionThatReturnsNull;
          }
          for (var i3 = 0; i3 < arrayOfTypeCheckers.length; i3++) {
            var checker = arrayOfTypeCheckers[i3];
            if (typeof checker !== "function") {
              printWarning(
                "Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + getPostfixForTypeWarning(checker) + " at index " + i3 + "."
              );
              return emptyFunctionThatReturnsNull;
            }
          }
          function validate(props, propName, componentName, location, propFullName) {
            var expectedTypes = [];
            for (var i4 = 0; i4 < arrayOfTypeCheckers.length; i4++) {
              var checker2 = arrayOfTypeCheckers[i4];
              var checkerResult = checker2(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
              if (checkerResult == null) {
                return null;
              }
              if (checkerResult.data && has(checkerResult.data, "expectedType")) {
                expectedTypes.push(checkerResult.data.expectedType);
              }
            }
            var expectedTypesMessage = expectedTypes.length > 0 ? ", expected one of type [" + expectedTypes.join(", ") + "]" : "";
            return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`" + expectedTypesMessage + "."));
          }
          return createChainableTypeChecker(validate);
        }
        function createNodeChecker() {
          function validate(props, propName, componentName, location, propFullName) {
            if (!isNode(props[propName])) {
              return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode."));
            }
            return null;
          }
          return createChainableTypeChecker(validate);
        }
        function invalidValidatorError(componentName, location, propFullName, key, type) {
          return new PropTypeError(
            (componentName || "React class") + ": " + location + " type `" + propFullName + "." + key + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + type + "`."
          );
        }
        function createShapeTypeChecker(shapeTypes) {
          function validate(props, propName, componentName, location, propFullName) {
            var propValue = props[propName];
            var propType = getPropType(propValue);
            if (propType !== "object") {
              return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
            }
            for (var key in shapeTypes) {
              var checker = shapeTypes[key];
              if (typeof checker !== "function") {
                return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
              }
              var error2 = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
              if (error2) {
                return error2;
              }
            }
            return null;
          }
          return createChainableTypeChecker(validate);
        }
        function createStrictShapeTypeChecker(shapeTypes) {
          function validate(props, propName, componentName, location, propFullName) {
            var propValue = props[propName];
            var propType = getPropType(propValue);
            if (propType !== "object") {
              return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
            }
            var allKeys = assign2({}, props[propName], shapeTypes);
            for (var key in allKeys) {
              var checker = shapeTypes[key];
              if (has(shapeTypes, key) && typeof checker !== "function") {
                return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
              }
              if (!checker) {
                return new PropTypeError(
                  "Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, "  ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, "  ")
                );
              }
              var error2 = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
              if (error2) {
                return error2;
              }
            }
            return null;
          }
          return createChainableTypeChecker(validate);
        }
        function isNode(propValue) {
          switch (typeof propValue) {
            case "number":
            case "string":
            case "undefined":
              return true;
            case "boolean":
              return !propValue;
            case "object":
              if (Array.isArray(propValue)) {
                return propValue.every(isNode);
              }
              if (propValue === null || isValidElement5(propValue)) {
                return true;
              }
              var iteratorFn = getIteratorFn(propValue);
              if (iteratorFn) {
                var iterator = iteratorFn.call(propValue);
                var step;
                if (iteratorFn !== propValue.entries) {
                  while (!(step = iterator.next()).done) {
                    if (!isNode(step.value)) {
                      return false;
                    }
                  }
                } else {
                  while (!(step = iterator.next()).done) {
                    var entry = step.value;
                    if (entry) {
                      if (!isNode(entry[1])) {
                        return false;
                      }
                    }
                  }
                }
              } else {
                return false;
              }
              return true;
            default:
              return false;
          }
        }
        function isSymbol(propType, propValue) {
          if (propType === "symbol") {
            return true;
          }
          if (!propValue) {
            return false;
          }
          if (propValue["@@toStringTag"] === "Symbol") {
            return true;
          }
          if (typeof Symbol === "function" && propValue instanceof Symbol) {
            return true;
          }
          return false;
        }
        function getPropType(propValue) {
          var propType = typeof propValue;
          if (Array.isArray(propValue)) {
            return "array";
          }
          if (propValue instanceof RegExp) {
            return "object";
          }
          if (isSymbol(propType, propValue)) {
            return "symbol";
          }
          return propType;
        }
        function getPreciseType(propValue) {
          if (typeof propValue === "undefined" || propValue === null) {
            return "" + propValue;
          }
          var propType = getPropType(propValue);
          if (propType === "object") {
            if (propValue instanceof Date) {
              return "date";
            } else if (propValue instanceof RegExp) {
              return "regexp";
            }
          }
          return propType;
        }
        function getPostfixForTypeWarning(value) {
          var type = getPreciseType(value);
          switch (type) {
            case "array":
            case "object":
              return "an " + type;
            case "boolean":
            case "date":
            case "regexp":
              return "a " + type;
            default:
              return type;
          }
        }
        function getClassName(propValue) {
          if (!propValue.constructor || !propValue.constructor.name) {
            return ANONYMOUS;
          }
          return propValue.constructor.name;
        }
        ReactPropTypes.checkPropTypes = checkPropTypes;
        ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
        ReactPropTypes.PropTypes = ReactPropTypes;
        return ReactPropTypes;
      };
    }
  });

  // node_modules/prop-types/index.js
  var require_prop_types = __commonJS({
    "node_modules/prop-types/index.js"(exports, module) {
      if (true) {
        ReactIs = require_react_is();
        throwOnDirectAccess = true;
        module.exports = require_factoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
      } else {
        module.exports = null();
      }
      var ReactIs;
      var throwOnDirectAccess;
    }
  });

  // node_modules/autosize/dist/autosize.js
  var require_autosize = __commonJS({
    "node_modules/autosize/dist/autosize.js"(exports, module) {
      (function(global, factory) {
        if (typeof define === "function" && define.amd) {
          define(["module", "exports"], factory);
        } else if (typeof exports !== "undefined") {
          factory(module, exports);
        } else {
          var mod = {
            exports: {}
          };
          factory(mod, mod.exports);
          global.autosize = mod.exports;
        }
      })(exports, function(module2, exports2) {
        "use strict";
        var map = typeof Map === "function" ? /* @__PURE__ */ new Map() : /* @__PURE__ */ (function() {
          var keys = [];
          var values = [];
          return {
            has: function has(key) {
              return keys.indexOf(key) > -1;
            },
            get: function get(key) {
              return values[keys.indexOf(key)];
            },
            set: function set5(key, value) {
              if (keys.indexOf(key) === -1) {
                keys.push(key);
                values.push(value);
              }
            },
            delete: function _delete(key) {
              var index = keys.indexOf(key);
              if (index > -1) {
                keys.splice(index, 1);
                values.splice(index, 1);
              }
            }
          };
        })();
        var createEvent = function createEvent2(name2) {
          return new Event(name2, { bubbles: true });
        };
        try {
          new Event("test");
        } catch (e3) {
          createEvent = function createEvent2(name2) {
            var evt = document.createEvent("Event");
            evt.initEvent(name2, true, false);
            return evt;
          };
        }
        function assign2(ta) {
          if (!ta || !ta.nodeName || ta.nodeName !== "TEXTAREA" || map.has(ta)) return;
          var heightOffset = null;
          var clientWidth = null;
          var cachedHeight = null;
          function init2() {
            var style = window.getComputedStyle(ta, null);
            if (style.resize === "vertical") {
              ta.style.resize = "none";
            } else if (style.resize === "both") {
              ta.style.resize = "horizontal";
            }
            if (style.boxSizing === "content-box") {
              heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
            } else {
              heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
            }
            if (isNaN(heightOffset)) {
              heightOffset = 0;
            }
            update5();
          }
          function changeOverflow(value) {
            {
              var width = ta.style.width;
              ta.style.width = "0px";
              ta.offsetWidth;
              ta.style.width = width;
            }
            ta.style.overflowY = value;
          }
          function getParentOverflows(el) {
            var arr = [];
            while (el && el.parentNode && el.parentNode instanceof Element) {
              if (el.parentNode.scrollTop) {
                arr.push({
                  node: el.parentNode,
                  scrollTop: el.parentNode.scrollTop
                });
              }
              el = el.parentNode;
            }
            return arr;
          }
          function resize() {
            if (ta.scrollHeight === 0) {
              return;
            }
            var overflows = getParentOverflows(ta);
            var docTop = document.documentElement && document.documentElement.scrollTop;
            ta.style.height = "";
            ta.style.height = ta.scrollHeight + heightOffset + "px";
            clientWidth = ta.clientWidth;
            overflows.forEach(function(el) {
              el.node.scrollTop = el.scrollTop;
            });
            if (docTop) {
              document.documentElement.scrollTop = docTop;
            }
          }
          function update5() {
            resize();
            var styleHeight = Math.round(parseFloat(ta.style.height));
            var computed = window.getComputedStyle(ta, null);
            var actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
            if (actualHeight < styleHeight) {
              if (computed.overflowY === "hidden") {
                changeOverflow("scroll");
                resize();
                actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
              }
            } else {
              if (computed.overflowY !== "hidden") {
                changeOverflow("hidden");
                resize();
                actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
              }
            }
            if (cachedHeight !== actualHeight) {
              cachedHeight = actualHeight;
              var evt = createEvent("autosize:resized");
              try {
                ta.dispatchEvent(evt);
              } catch (err) {
              }
            }
          }
          var pageResize = function pageResize2() {
            if (ta.clientWidth !== clientWidth) {
              update5();
            }
          };
          var destroy2 = function(style) {
            window.removeEventListener("resize", pageResize, false);
            ta.removeEventListener("input", update5, false);
            ta.removeEventListener("keyup", update5, false);
            ta.removeEventListener("autosize:destroy", destroy2, false);
            ta.removeEventListener("autosize:update", update5, false);
            Object.keys(style).forEach(function(key) {
              ta.style[key] = style[key];
            });
            map.delete(ta);
          }.bind(ta, {
            height: ta.style.height,
            resize: ta.style.resize,
            overflowY: ta.style.overflowY,
            overflowX: ta.style.overflowX,
            wordWrap: ta.style.wordWrap
          });
          ta.addEventListener("autosize:destroy", destroy2, false);
          if ("onpropertychange" in ta && "oninput" in ta) {
            ta.addEventListener("keyup", update5, false);
          }
          window.addEventListener("resize", pageResize, false);
          ta.addEventListener("input", update5, false);
          ta.addEventListener("autosize:update", update5, false);
          ta.style.overflowX = "hidden";
          ta.style.wordWrap = "break-word";
          map.set(ta, {
            destroy: destroy2,
            update: update5
          });
          init2();
        }
        function destroy(ta) {
          var methods = map.get(ta);
          if (methods) {
            methods.destroy();
          }
        }
        function update4(ta) {
          var methods = map.get(ta);
          if (methods) {
            methods.update();
          }
        }
        var autosize = null;
        if (typeof window === "undefined" || typeof window.getComputedStyle !== "function") {
          autosize = function autosize2(el) {
            return el;
          };
          autosize.destroy = function(el) {
            return el;
          };
          autosize.update = function(el) {
            return el;
          };
        } else {
          autosize = function autosize2(el, options) {
            if (el) {
              Array.prototype.forEach.call(el.length ? el : [el], function(x2) {
                return assign2(x2, options);
              });
            }
            return el;
          };
          autosize.destroy = function(el) {
            if (el) {
              Array.prototype.forEach.call(el.length ? el : [el], destroy);
            }
            return el;
          };
          autosize.update = function(el) {
            if (el) {
              Array.prototype.forEach.call(el.length ? el : [el], update4);
            }
            return el;
          };
        }
        exports2.default = autosize;
        module2.exports = exports2["default"];
      });
    }
  });

  // node_modules/computed-style/dist/computedStyle.commonjs.js
  var require_computedStyle_commonjs = __commonJS({
    "node_modules/computed-style/dist/computedStyle.commonjs.js"(exports, module) {
      var computedStyle = function(el, prop, getComputedStyle2) {
        getComputedStyle2 = window.getComputedStyle;
        return (
          // If we have getComputedStyle
          (getComputedStyle2 ? (
            // Query it
            // TODO: From CSS-Query notes, we might need (node, null) for FF
            getComputedStyle2(el)
          ) : (
            // Otherwise, we are in IE and use currentStyle
            el.currentStyle
          ))[
            // Switch to camelCase for CSSOM
            // DEV: Grabbed from jQuery
            // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
            // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
            prop.replace(/-(\w)/gi, function(word, letter) {
              return letter.toUpperCase();
            })
          ]
        );
      };
      module.exports = computedStyle;
    }
  });

  // node_modules/line-height/lib/line-height.js
  var require_line_height = __commonJS({
    "node_modules/line-height/lib/line-height.js"(exports, module) {
      var computedStyle = require_computedStyle_commonjs();
      function lineHeight(node) {
        var lnHeightStr = computedStyle(node, "line-height");
        var lnHeight = parseFloat(lnHeightStr, 10);
        if (lnHeightStr === lnHeight + "") {
          var _lnHeightStyle = node.style.lineHeight;
          node.style.lineHeight = lnHeightStr + "em";
          lnHeightStr = computedStyle(node, "line-height");
          lnHeight = parseFloat(lnHeightStr, 10);
          if (_lnHeightStyle) {
            node.style.lineHeight = _lnHeightStyle;
          } else {
            delete node.style.lineHeight;
          }
        }
        if (lnHeightStr.indexOf("pt") !== -1) {
          lnHeight *= 4;
          lnHeight /= 3;
        } else if (lnHeightStr.indexOf("mm") !== -1) {
          lnHeight *= 96;
          lnHeight /= 25.4;
        } else if (lnHeightStr.indexOf("cm") !== -1) {
          lnHeight *= 96;
          lnHeight /= 2.54;
        } else if (lnHeightStr.indexOf("in") !== -1) {
          lnHeight *= 96;
        } else if (lnHeightStr.indexOf("pc") !== -1) {
          lnHeight *= 16;
        }
        lnHeight = Math.round(lnHeight);
        if (lnHeightStr === "normal") {
          var nodeName = node.nodeName;
          var _node = document.createElement(nodeName);
          _node.innerHTML = "&nbsp;";
          if (nodeName.toUpperCase() === "TEXTAREA") {
            _node.setAttribute("rows", "1");
          }
          var fontSizeStr = computedStyle(node, "font-size");
          _node.style.fontSize = fontSizeStr;
          _node.style.padding = "0px";
          _node.style.border = "0px";
          var body = document.body;
          body.appendChild(_node);
          var height = _node.offsetHeight;
          lnHeight = height;
          body.removeChild(_node);
        }
        return lnHeight;
      }
      module.exports = lineHeight;
    }
  });

  // node_modules/react-autosize-textarea/lib/TextareaAutosize.js
  var require_TextareaAutosize = __commonJS({
    "node_modules/react-autosize-textarea/lib/TextareaAutosize.js"(exports) {
      "use strict";
      var __extends = exports && exports.__extends || (function() {
        var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) {
          d3.__proto__ = b3;
        } || function(d3, b3) {
          for (var p4 in b3) if (b3.hasOwnProperty(p4)) d3[p4] = b3[p4];
        };
        return function(d3, b3) {
          extendStatics(d3, b3);
          function __314() {
            this.constructor = d3;
          }
          d3.prototype = b3 === null ? Object.create(b3) : (__314.prototype = b3.prototype, new __314());
        };
      })();
      var __assign2 = exports && exports.__assign || Object.assign || function(t4) {
        for (var s3, i3 = 1, n3 = arguments.length; i3 < n3; i3++) {
          s3 = arguments[i3];
          for (var p4 in s3) if (Object.prototype.hasOwnProperty.call(s3, p4))
            t4[p4] = s3[p4];
        }
        return t4;
      };
      var __rest = exports && exports.__rest || function(s3, e3) {
        var t4 = {};
        for (var p4 in s3) if (Object.prototype.hasOwnProperty.call(s3, p4) && e3.indexOf(p4) < 0)
          t4[p4] = s3[p4];
        if (s3 != null && typeof Object.getOwnPropertySymbols === "function") {
          for (var i3 = 0, p4 = Object.getOwnPropertySymbols(s3); i3 < p4.length; i3++) if (e3.indexOf(p4[i3]) < 0)
            t4[p4[i3]] = s3[p4[i3]];
        }
        return t4;
      };
      exports.__esModule = true;
      var React27 = require_react();
      var PropTypes = require_prop_types();
      var autosize = require_autosize();
      var _getLineHeight = require_line_height();
      var getLineHeight = _getLineHeight;
      var RESIZED = "autosize:resized";
      var TextareaAutosizeClass = (
        /** @class */
        (function(_super) {
          __extends(TextareaAutosizeClass2, _super);
          function TextareaAutosizeClass2() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.state = {
              lineHeight: null
            };
            _this.textarea = null;
            _this.onResize = function(e3) {
              if (_this.props.onResize) {
                _this.props.onResize(e3);
              }
            };
            _this.updateLineHeight = function() {
              if (_this.textarea) {
                _this.setState({
                  lineHeight: getLineHeight(_this.textarea)
                });
              }
            };
            _this.onChange = function(e3) {
              var onChange = _this.props.onChange;
              _this.currentValue = e3.currentTarget.value;
              onChange && onChange(e3);
            };
            return _this;
          }
          TextareaAutosizeClass2.prototype.componentDidMount = function() {
            var _this = this;
            var _a = this.props, maxRows = _a.maxRows, async = _a.async;
            if (typeof maxRows === "number") {
              this.updateLineHeight();
            }
            if (typeof maxRows === "number" || async) {
              setTimeout(function() {
                return _this.textarea && autosize(_this.textarea);
              });
            } else {
              this.textarea && autosize(this.textarea);
            }
            if (this.textarea) {
              this.textarea.addEventListener(RESIZED, this.onResize);
            }
          };
          TextareaAutosizeClass2.prototype.componentWillUnmount = function() {
            if (this.textarea) {
              this.textarea.removeEventListener(RESIZED, this.onResize);
              autosize.destroy(this.textarea);
            }
          };
          TextareaAutosizeClass2.prototype.render = function() {
            var _this = this;
            var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight;
            var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
            return React27.createElement("textarea", __assign2({}, props, { onChange: this.onChange, style: maxHeight ? __assign2({}, style, { maxHeight }) : style, ref: function(element) {
              _this.textarea = element;
              if (typeof _this.props.innerRef === "function") {
                _this.props.innerRef(element);
              } else if (_this.props.innerRef) {
                _this.props.innerRef.current = element;
              }
            } }), children);
          };
          TextareaAutosizeClass2.prototype.componentDidUpdate = function() {
            this.textarea && autosize.update(this.textarea);
          };
          TextareaAutosizeClass2.defaultProps = {
            rows: 1,
            async: false
          };
          TextareaAutosizeClass2.propTypes = {
            rows: PropTypes.number,
            maxRows: PropTypes.number,
            onResize: PropTypes.func,
            innerRef: PropTypes.any,
            async: PropTypes.bool
          };
          return TextareaAutosizeClass2;
        })(React27.Component)
      );
      exports.TextareaAutosize = React27.forwardRef(function(props, ref) {
        return React27.createElement(TextareaAutosizeClass, __assign2({}, props, { innerRef: ref }));
      });
    }
  });

  // node_modules/react-autosize-textarea/lib/index.js
  var require_lib = __commonJS({
    "node_modules/react-autosize-textarea/lib/index.js"(exports, module) {
      "use strict";
      var TextareaAutosize_1 = require_TextareaAutosize();
      module.exports = TextareaAutosize_1.TextareaAutosize;
    }
  });

  // package-external:@wordpress/server-side-render
  var require_server_side_render = __commonJS({
    "package-external:@wordpress/server-side-render"(exports, module) {
      module.exports = window.wp.serverSideRender;
    }
  });

  // packages/editor/build-module/index.mjs
  var index_exports = {};
  __export(index_exports, {
    AlignmentToolbar: () => AlignmentToolbar,
    Autocomplete: () => Autocomplete,
    AutosaveMonitor: () => autosave_monitor_default,
    BlockAlignmentToolbar: () => BlockAlignmentToolbar,
    BlockControls: () => BlockControls,
    BlockEdit: () => BlockEdit,
    BlockEditorKeyboardShortcuts: () => BlockEditorKeyboardShortcuts2,
    BlockFormatControls: () => BlockFormatControls,
    BlockIcon: () => BlockIcon3,
    BlockInspector: () => BlockInspector,
    BlockList: () => BlockList4,
    BlockMover: () => BlockMover,
    BlockNavigationDropdown: () => BlockNavigationDropdown,
    BlockSelectionClearer: () => BlockSelectionClearer,
    BlockSettingsMenu: () => BlockSettingsMenu,
    BlockTitle: () => BlockTitle,
    BlockToolbar: () => BlockToolbar,
    CharacterCount: () => CharacterCount,
    ColorPalette: () => ColorPalette2,
    ContrastChecker: () => ContrastChecker,
    CopyHandler: () => CopyHandler,
    DefaultBlockAppender: () => DefaultBlockAppender,
    DocumentBar: () => DocumentBar,
    DocumentOutline: () => DocumentOutline,
    DocumentOutlineCheck: () => DocumentOutlineCheck,
    EditorHistoryRedo: () => redo_default2,
    EditorHistoryUndo: () => undo_default2,
    EditorKeyboardShortcuts: () => EditorKeyboardShortcuts,
    EditorKeyboardShortcutsRegister: () => register_shortcuts_default,
    EditorNotices: () => editor_notices_default,
    EditorProvider: () => provider_default,
    EditorSnackbars: () => EditorSnackbars,
    EntitiesSavedStates: () => EntitiesSavedStates,
    ErrorBoundary: () => error_boundary_default,
    FontSizePicker: () => FontSizePicker,
    InnerBlocks: () => InnerBlocks,
    Inserter: () => Inserter,
    InspectorAdvancedControls: () => InspectorAdvancedControls,
    InspectorControls: () => InspectorControls,
    LocalAutosaveMonitor: () => local_autosave_monitor_default,
    MediaPlaceholder: () => MediaPlaceholder,
    MediaUpload: () => MediaUpload3,
    MediaUploadCheck: () => MediaUploadCheck2,
    MultiSelectScrollIntoView: () => MultiSelectScrollIntoView,
    NavigableToolbar: () => NavigableToolbar,
    ObserveTyping: () => ObserveTyping,
    PageAttributesCheck: () => check_default2,
    PageAttributesOrder: () => PageAttributesOrderWithChecks,
    PageAttributesPanel: () => PageAttributesPanel,
    PageAttributesParent: () => parent_default2,
    PageTemplate: () => classic_theme_default,
    PanelColorSettings: () => PanelColorSettings,
    PlainText: () => PlainText,
    PluginBlockSettingsMenuItem: () => plugin_block_settings_menu_item_default,
    PluginDocumentSettingPanel: () => plugin_document_setting_panel_default,
    PluginMoreMenuItem: () => PluginMoreMenuItem,
    PluginPostPublishPanel: () => plugin_post_publish_panel_default,
    PluginPostStatusInfo: () => plugin_post_status_info_default,
    PluginPrePublishPanel: () => plugin_pre_publish_panel_default,
    PluginPreviewMenuItem: () => PluginPreviewMenuItem,
    PluginSidebar: () => PluginSidebar,
    PluginSidebarMoreMenuItem: () => PluginSidebarMoreMenuItem,
    PostAuthor: () => post_author_default,
    PostAuthorCheck: () => PostAuthorCheck,
    PostAuthorPanel: () => panel_default,
    PostComments: () => post_comments_default,
    PostDiscussionPanel: () => PostDiscussionPanel,
    PostExcerpt: () => PostExcerpt,
    PostExcerptCheck: () => check_default3,
    PostExcerptPanel: () => PostExcerptPanel,
    PostFeaturedImage: () => post_featured_image_default,
    PostFeaturedImageCheck: () => check_default4,
    PostFeaturedImagePanel: () => PostFeaturedImagePanel,
    PostFormat: () => PostFormat,
    PostFormatCheck: () => PostFormatCheck,
    PostLastRevision: () => post_last_revision_default,
    PostLastRevisionCheck: () => check_default5,
    PostLastRevisionPanel: () => panel_default2,
    PostLockedModal: () => post_locked_modal_default,
    PostPendingStatus: () => post_pending_status_default,
    PostPendingStatusCheck: () => check_default6,
    PostPingbacks: () => post_pingbacks_default,
    PostPreviewButton: () => PostPreviewButton,
    PostPublishButton: () => post_publish_button_default,
    PostPublishButtonLabel: () => PublishButtonLabel,
    PostPublishPanel: () => post_publish_panel_default,
    PostSavedState: () => PostSavedState,
    PostSchedule: () => PostSchedule,
    PostScheduleCheck: () => PostScheduleCheck,
    PostScheduleLabel: () => PostScheduleLabel,
    PostSchedulePanel: () => PostSchedulePanel,
    PostSticky: () => PostSticky,
    PostStickyCheck: () => PostStickyCheck,
    PostSwitchToDraftButton: () => PostSwitchToDraftButton,
    PostSyncStatus: () => PostSyncStatus,
    PostTaxonomies: () => post_taxonomies_default,
    PostTaxonomiesCheck: () => PostTaxonomiesCheck,
    PostTaxonomiesFlatTermSelector: () => FlatTermSelector,
    PostTaxonomiesHierarchicalTermSelector: () => HierarchicalTermSelector,
    PostTaxonomiesPanel: () => PostTaxonomies2,
    PostTemplatePanel: () => PostTemplatePanel,
    PostTextEditor: () => PostTextEditor,
    PostTitle: () => post_title_default,
    PostTitleRaw: () => post_title_raw_default,
    PostTrash: () => PostTrash,
    PostTrashCheck: () => PostTrashCheck,
    PostTypeSupportCheck: () => post_type_support_check_default,
    PostURL: () => PostURL,
    PostURLCheck: () => PostURLCheck,
    PostURLLabel: () => PostURLLabel,
    PostURLPanel: () => PostURLPanel,
    PostVisibility: () => PostVisibility,
    PostVisibilityCheck: () => PostVisibilityCheck,
    PostVisibilityLabel: () => PostVisibilityLabel,
    RichText: () => RichText,
    RichTextShortcut: () => RichTextShortcut,
    RichTextToolbarButton: () => RichTextToolbarButton,
    ServerSideRender: () => import_server_side_render.default,
    SkipToSelectedBlock: () => SkipToSelectedBlock,
    TableOfContents: () => table_of_contents_default,
    TextEditorGlobalKeyboardShortcuts: () => TextEditorGlobalKeyboardShortcuts,
    ThemeSupportCheck: () => ThemeSupportCheck,
    TimeToRead: () => TimeToRead,
    URLInput: () => URLInput,
    URLInputButton: () => URLInputButton,
    URLPopover: () => URLPopover,
    UnsavedChangesWarning: () => UnsavedChangesWarning,
    VisualEditorGlobalKeyboardShortcuts: () => VisualEditorGlobalKeyboardShortcuts,
    Warning: () => Warning,
    WordCount: () => WordCount,
    WritingFlow: () => WritingFlow,
    __unstableRichTextInputEvent: () => __unstableRichTextInputEvent,
    cleanForSlug: () => cleanForSlug3,
    createCustomColorsHOC: () => createCustomColorsHOC,
    getColorClassName: () => getColorClassName2,
    getColorObjectByAttributeValues: () => getColorObjectByAttributeValues,
    getColorObjectByColorValue: () => getColorObjectByColorValue,
    getFontSize: () => getFontSize,
    getFontSizeClass: () => getFontSizeClass,
    getTemplatePartIcon: () => getTemplatePartIcon,
    linkAutocompleter: () => link_default2,
    mediaUpload: () => mediaUpload,
    privateApis: () => privateApis19,
    registerEntityAction: () => registerEntityAction2,
    registerEntityField: () => registerEntityField2,
    store: () => store3,
    storeConfig: () => storeConfig,
    transformStyles: () => import_block_editor110.transformStyles,
    unregisterEntityAction: () => unregisterEntityAction2,
    unregisterEntityField: () => unregisterEntityField2,
    useEntitiesSavedStatesIsDirty: () => useIsDirty,
    usePostScheduleLabel: () => usePostScheduleLabel,
    usePostURLLabel: () => usePostURLLabel,
    usePostVisibilityLabel: () => usePostVisibilityLabel,
    userAutocompleter: () => user_default,
    withColorContext: () => withColorContext,
    withColors: () => withColors,
    withFontSizes: () => withFontSizes
  });

  // packages/editor/build-module/hooks/custom-sources-backwards-compatibility.mjs
  var import_data82 = __toESM(require_data(), 1);
  var import_core_data56 = __toESM(require_core_data(), 1);
  var import_element179 = __toESM(require_element(), 1);
  var import_compose31 = __toESM(require_compose(), 1);
  var import_hooks39 = __toESM(require_hooks(), 1);

  // packages/editor/build-module/store/index.mjs
  var import_data81 = __toESM(require_data(), 1);

  // packages/editor/build-module/store/reducer.mjs
  var import_data2 = __toESM(require_data(), 1);

  // packages/editor/build-module/store/defaults.mjs
  var import_block_editor = __toESM(require_block_editor(), 1);
  var EDITOR_SETTINGS_DEFAULTS = {
    ...import_block_editor.SETTINGS_DEFAULTS,
    richEditingEnabled: true,
    codeEditingEnabled: true,
    fontLibraryEnabled: true,
    enableCustomFields: void 0,
    defaultRenderingMode: "post-only"
  };

  // packages/editor/build-module/dataviews/store/reducer.mjs
  var import_data = __toESM(require_data(), 1);
  function isReady(state = {}, action) {
    switch (action.type) {
      case "SET_IS_READY":
        return {
          ...state,
          [action.kind]: {
            ...state[action.kind],
            [action.name]: true
          }
        };
    }
    return state;
  }
  function actions(state = {}, action) {
    switch (action.type) {
      case "REGISTER_ENTITY_ACTION":
        return {
          ...state,
          [action.kind]: {
            ...state[action.kind],
            [action.name]: [
              ...(state[action.kind]?.[action.name] ?? []).filter(
                (_action) => _action.id !== action.config.id
              ),
              action.config
            ]
          }
        };
      case "UNREGISTER_ENTITY_ACTION": {
        return {
          ...state,
          [action.kind]: {
            ...state[action.kind],
            [action.name]: (state[action.kind]?.[action.name] ?? []).filter((_action) => _action.id !== action.actionId)
          }
        };
      }
    }
    return state;
  }
  function fields(state = {}, action) {
    switch (action.type) {
      case "REGISTER_ENTITY_FIELD":
        return {
          ...state,
          [action.kind]: {
            ...state[action.kind],
            [action.name]: [
              ...(state[action.kind]?.[action.name] ?? []).filter(
                (_field) => _field.id !== action.config.id
              ),
              action.config
            ]
          }
        };
      case "UNREGISTER_ENTITY_FIELD":
        return {
          ...state,
          [action.kind]: {
            ...state[action.kind],
            [action.name]: (state[action.kind]?.[action.name] ?? []).filter((_field) => _field.id !== action.fieldId)
          }
        };
    }
    return state;
  }
  var reducer_default = (0, import_data.combineReducers)({
    actions,
    fields,
    isReady
  });

  // packages/editor/build-module/store/reducer.mjs
  function getPostRawValue(value) {
    if (value && "object" === typeof value && "raw" in value) {
      return value.raw;
    }
    return value;
  }
  function postId(state = null, action) {
    switch (action.type) {
      case "SET_EDITED_POST":
        return action.postId;
    }
    return state;
  }
  function templateId(state = null, action) {
    switch (action.type) {
      case "SET_CURRENT_TEMPLATE_ID":
        return action.id;
    }
    return state;
  }
  function postType(state = null, action) {
    switch (action.type) {
      case "SET_EDITED_POST":
        return action.postType;
    }
    return state;
  }
  function template(state = { isValid: true }, action) {
    switch (action.type) {
      case "SET_TEMPLATE_VALIDITY":
        return {
          ...state,
          isValid: action.isValid
        };
    }
    return state;
  }
  function saving(state = {}, action) {
    switch (action.type) {
      case "REQUEST_POST_UPDATE_START":
      case "REQUEST_POST_UPDATE_FINISH":
        return {
          pending: action.type === "REQUEST_POST_UPDATE_START",
          options: action.options || {}
        };
    }
    return state;
  }
  function deleting(state = {}, action) {
    switch (action.type) {
      case "REQUEST_POST_DELETE_START":
      case "REQUEST_POST_DELETE_FINISH":
        return {
          pending: action.type === "REQUEST_POST_DELETE_START"
        };
    }
    return state;
  }
  function postLock(state = { isLocked: false }, action) {
    switch (action.type) {
      case "UPDATE_POST_LOCK":
        return action.lock;
    }
    return state;
  }
  function postSavingLock(state = {}, action) {
    switch (action.type) {
      case "LOCK_POST_SAVING":
        return { ...state, [action.lockName]: true };
      case "UNLOCK_POST_SAVING": {
        const { [action.lockName]: removedLockName, ...restState } = state;
        return restState;
      }
    }
    return state;
  }
  function postAutosavingLock(state = {}, action) {
    switch (action.type) {
      case "LOCK_POST_AUTOSAVING":
        return { ...state, [action.lockName]: true };
      case "UNLOCK_POST_AUTOSAVING": {
        const { [action.lockName]: removedLockName, ...restState } = state;
        return restState;
      }
    }
    return state;
  }
  function editorSettings(state = EDITOR_SETTINGS_DEFAULTS, action) {
    switch (action.type) {
      case "UPDATE_EDITOR_SETTINGS":
        return {
          ...state,
          ...action.settings
        };
    }
    return state;
  }
  function renderingMode(state = "post-only", action) {
    switch (action.type) {
      case "SET_RENDERING_MODE":
        return action.mode;
    }
    return state;
  }
  function deviceType(state = "Desktop", action) {
    switch (action.type) {
      case "SET_DEVICE_TYPE":
        return action.deviceType;
    }
    return state;
  }
  function removedPanels(state = [], action) {
    switch (action.type) {
      case "REMOVE_PANEL":
        if (!state.includes(action.panelName)) {
          return [...state, action.panelName];
        }
    }
    return state;
  }
  function blockInserterPanel(state = false, action) {
    switch (action.type) {
      case "SET_IS_LIST_VIEW_OPENED":
        return action.isOpen ? false : state;
      case "SET_IS_INSERTER_OPENED":
        return action.value;
    }
    return state;
  }
  function listViewPanel(state = false, action) {
    switch (action.type) {
      case "SET_IS_INSERTER_OPENED":
        return action.value ? false : state;
      case "SET_IS_LIST_VIEW_OPENED":
        return action.isOpen;
    }
    return state;
  }
  function listViewToggleRef(state = { current: null }) {
    return state;
  }
  function inserterSidebarToggleRef(state = { current: null }) {
    return state;
  }
  function publishSidebarActive(state = false, action) {
    switch (action.type) {
      case "OPEN_PUBLISH_SIDEBAR":
        return true;
      case "CLOSE_PUBLISH_SIDEBAR":
        return false;
      case "TOGGLE_PUBLISH_SIDEBAR":
        return !state;
    }
    return state;
  }
  function stylesPath(state = "/", action) {
    switch (action.type) {
      case "SET_STYLES_PATH":
        return action.path;
      case "RESET_STYLES_NAVIGATION":
        return "/";
    }
    return state;
  }
  function showStylebook(state = false, action) {
    switch (action.type) {
      case "SET_SHOW_STYLEBOOK":
        return action.show;
      case "RESET_STYLES_NAVIGATION":
        return false;
    }
    return state;
  }
  function revisionId(state = null, action) {
    switch (action.type) {
      case "SET_CURRENT_REVISION_ID":
        return action.revisionId;
    }
    return state;
  }
  function showRevisionDiff(state = true, action) {
    switch (action.type) {
      case "SET_SHOW_REVISION_DIFF":
        return action.showDiff;
      case "SET_CURRENT_REVISION_ID":
        return !action.revisionId ? true : state;
    }
    return state;
  }
  function selectedNote(state = {}, action) {
    switch (action.type) {
      case "SELECT_NOTE":
        return { noteId: action.noteId, options: action.options };
    }
    return state;
  }
  var reducer_default2 = (0, import_data2.combineReducers)({
    postId,
    postType,
    templateId,
    saving,
    deleting,
    postLock,
    template,
    postSavingLock,
    editorSettings,
    postAutosavingLock,
    renderingMode,
    deviceType,
    removedPanels,
    blockInserterPanel,
    inserterSidebarToggleRef,
    listViewPanel,
    listViewToggleRef,
    publishSidebarActive,
    stylesPath,
    showStylebook,
    revisionId,
    showRevisionDiff,
    selectedNote,
    dataviews: reducer_default
  });

  // packages/editor/build-module/store/selectors.mjs
  var selectors_exports = {};
  __export(selectors_exports, {
    __experimentalGetDefaultTemplatePartAreas: () => __experimentalGetDefaultTemplatePartAreas,
    __experimentalGetDefaultTemplateType: () => __experimentalGetDefaultTemplateType,
    __experimentalGetDefaultTemplateTypes: () => __experimentalGetDefaultTemplateTypes,
    __experimentalGetTemplateInfo: () => __experimentalGetTemplateInfo,
    __unstableIsEditorReady: () => __unstableIsEditorReady,
    canInsertBlockType: () => canInsertBlockType,
    canUserUseUnfilteredHTML: () => canUserUseUnfilteredHTML,
    didPostSaveRequestFail: () => didPostSaveRequestFail,
    didPostSaveRequestSucceed: () => didPostSaveRequestSucceed,
    getActivePostLock: () => getActivePostLock,
    getAdjacentBlockClientId: () => getAdjacentBlockClientId,
    getAutosaveAttribute: () => getAutosaveAttribute,
    getBlock: () => getBlock,
    getBlockAttributes: () => getBlockAttributes,
    getBlockCount: () => getBlockCount,
    getBlockHierarchyRootClientId: () => getBlockHierarchyRootClientId,
    getBlockIndex: () => getBlockIndex,
    getBlockInsertionPoint: () => getBlockInsertionPoint,
    getBlockListSettings: () => getBlockListSettings,
    getBlockMode: () => getBlockMode,
    getBlockName: () => getBlockName,
    getBlockOrder: () => getBlockOrder,
    getBlockRootClientId: () => getBlockRootClientId,
    getBlockSelectionEnd: () => getBlockSelectionEnd,
    getBlockSelectionStart: () => getBlockSelectionStart,
    getBlocks: () => getBlocks,
    getBlocksByClientId: () => getBlocksByClientId,
    getClientIdsOfDescendants: () => getClientIdsOfDescendants,
    getClientIdsWithDescendants: () => getClientIdsWithDescendants,
    getCurrentPost: () => getCurrentPost,
    getCurrentPostAttribute: () => getCurrentPostAttribute,
    getCurrentPostId: () => getCurrentPostId,
    getCurrentPostLastRevisionId: () => getCurrentPostLastRevisionId,
    getCurrentPostRevisionsCount: () => getCurrentPostRevisionsCount,
    getCurrentPostType: () => getCurrentPostType,
    getCurrentTemplateId: () => getCurrentTemplateId,
    getDeviceType: () => getDeviceType,
    getEditedPostAttribute: () => getEditedPostAttribute,
    getEditedPostContent: () => getEditedPostContent,
    getEditedPostPreviewLink: () => getEditedPostPreviewLink,
    getEditedPostSlug: () => getEditedPostSlug,
    getEditedPostVisibility: () => getEditedPostVisibility,
    getEditorBlocks: () => getEditorBlocks,
    getEditorMode: () => getEditorMode,
    getEditorSelection: () => getEditorSelection,
    getEditorSelectionEnd: () => getEditorSelectionEnd,
    getEditorSelectionStart: () => getEditorSelectionStart,
    getEditorSettings: () => getEditorSettings,
    getFirstMultiSelectedBlockClientId: () => getFirstMultiSelectedBlockClientId,
    getGlobalBlockCount: () => getGlobalBlockCount,
    getInserterItems: () => getInserterItems,
    getLastMultiSelectedBlockClientId: () => getLastMultiSelectedBlockClientId,
    getMultiSelectedBlockClientIds: () => getMultiSelectedBlockClientIds,
    getMultiSelectedBlocks: () => getMultiSelectedBlocks,
    getMultiSelectedBlocksEndClientId: () => getMultiSelectedBlocksEndClientId,
    getMultiSelectedBlocksStartClientId: () => getMultiSelectedBlocksStartClientId,
    getNextBlockClientId: () => getNextBlockClientId,
    getPermalink: () => getPermalink,
    getPermalinkParts: () => getPermalinkParts,
    getPostEdits: () => getPostEdits,
    getPostLockUser: () => getPostLockUser,
    getPostTypeLabel: () => getPostTypeLabel,
    getPreviousBlockClientId: () => getPreviousBlockClientId,
    getRenderingMode: () => getRenderingMode,
    getSelectedBlock: () => getSelectedBlock,
    getSelectedBlockClientId: () => getSelectedBlockClientId,
    getSelectedBlockCount: () => getSelectedBlockCount,
    getSelectedBlocksInitialCaretPosition: () => getSelectedBlocksInitialCaretPosition,
    getStateBeforeOptimisticTransaction: () => getStateBeforeOptimisticTransaction,
    getSuggestedPostFormat: () => getSuggestedPostFormat,
    getTemplate: () => getTemplate,
    getTemplateLock: () => getTemplateLock,
    hasChangedContent: () => hasChangedContent,
    hasEditorRedo: () => hasEditorRedo,
    hasEditorUndo: () => hasEditorUndo,
    hasInserterItems: () => hasInserterItems,
    hasMultiSelection: () => hasMultiSelection,
    hasNonPostEntityChanges: () => hasNonPostEntityChanges,
    hasSelectedBlock: () => hasSelectedBlock,
    hasSelectedInnerBlock: () => hasSelectedInnerBlock,
    inSomeHistory: () => inSomeHistory,
    isAncestorMultiSelected: () => isAncestorMultiSelected,
    isAutosavingPost: () => isAutosavingPost,
    isBlockInsertionPointVisible: () => isBlockInsertionPointVisible,
    isBlockMultiSelected: () => isBlockMultiSelected,
    isBlockSelected: () => isBlockSelected,
    isBlockValid: () => isBlockValid,
    isBlockWithinSelection: () => isBlockWithinSelection,
    isCaretWithinFormattedText: () => isCaretWithinFormattedText,
    isCleanNewPost: () => isCleanNewPost,
    isCollaborationEnabledForCurrentPost: () => isCollaborationEnabledForCurrentPost,
    isCurrentPostPending: () => isCurrentPostPending,
    isCurrentPostPublished: () => isCurrentPostPublished,
    isCurrentPostScheduled: () => isCurrentPostScheduled,
    isDeletingPost: () => isDeletingPost,
    isEditedPostAutosaveable: () => isEditedPostAutosaveable,
    isEditedPostBeingScheduled: () => isEditedPostBeingScheduled,
    isEditedPostDateFloating: () => isEditedPostDateFloating,
    isEditedPostDirty: () => isEditedPostDirty,
    isEditedPostEmpty: () => isEditedPostEmpty,
    isEditedPostNew: () => isEditedPostNew,
    isEditedPostPublishable: () => isEditedPostPublishable,
    isEditedPostSaveable: () => isEditedPostSaveable,
    isEditorPanelEnabled: () => isEditorPanelEnabled,
    isEditorPanelOpened: () => isEditorPanelOpened,
    isEditorPanelRemoved: () => isEditorPanelRemoved,
    isFirstMultiSelectedBlock: () => isFirstMultiSelectedBlock,
    isInserterOpened: () => isInserterOpened,
    isListViewOpened: () => isListViewOpened,
    isMultiSelecting: () => isMultiSelecting,
    isPermalinkEditable: () => isPermalinkEditable,
    isPostAutosavingLocked: () => isPostAutosavingLocked,
    isPostLockTakeover: () => isPostLockTakeover,
    isPostLocked: () => isPostLocked,
    isPostSavingLocked: () => isPostSavingLocked,
    isPreviewingPost: () => isPreviewingPost,
    isPublishSidebarEnabled: () => isPublishSidebarEnabled,
    isPublishSidebarOpened: () => isPublishSidebarOpened,
    isPublishingPost: () => isPublishingPost,
    isSavingNonPostEntityChanges: () => isSavingNonPostEntityChanges,
    isSavingPost: () => isSavingPost,
    isSelectionEnabled: () => isSelectionEnabled,
    isTyping: () => isTyping,
    isValidTemplate: () => isValidTemplate
  });
  var import_blocks = __toESM(require_blocks(), 1);
  var import_date = __toESM(require_date(), 1);
  var import_url = __toESM(require_url(), 1);
  var import_data3 = __toESM(require_data(), 1);
  var import_deprecated = __toESM(require_deprecated(), 1);
  var import_element2 = __toESM(require_element(), 1);
  var import_block_editor2 = __toESM(require_block_editor(), 1);
  var import_core_data = __toESM(require_core_data(), 1);
  var import_preferences = __toESM(require_preferences(), 1);

  // packages/editor/build-module/store/constants.mjs
  var EDIT_MERGE_PROPERTIES = /* @__PURE__ */ new Set(["meta"]);
  var STORE_NAME = "core/editor";
  var PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
  var ONE_MINUTE_IN_MS = 60 * 1e3;
  var AUTOSAVE_PROPERTIES = ["title", "excerpt", "content"];
  var TEMPLATE_POST_TYPE = "wp_template";
  var TEMPLATE_PART_POST_TYPE = "wp_template_part";
  var PATTERN_POST_TYPE = "wp_block";
  var NAVIGATION_POST_TYPE = "wp_navigation";
  var ATTACHMENT_POST_TYPE = "attachment";
  var TEMPLATE_ORIGINS = {
    custom: "custom",
    theme: "theme",
    plugin: "plugin"
  };
  var TEMPLATE_POST_TYPES = ["wp_template", "wp_template_part"];
  var GLOBAL_POST_TYPES = [
    ...TEMPLATE_POST_TYPES,
    "wp_block",
    "wp_navigation"
  ];
  var DESIGN_POST_TYPES = [
    TEMPLATE_POST_TYPE,
    TEMPLATE_PART_POST_TYPE,
    PATTERN_POST_TYPE,
    NAVIGATION_POST_TYPE
  ];

  // packages/icons/build-module/icon/index.mjs
  var import_element = __toESM(require_element(), 1);
  var icon_default = (0, import_element.forwardRef)(
    ({ icon, size = 24, ...props }, ref) => {
      return (0, import_element.cloneElement)(icon, {
        width: size,
        height: size,
        ...props,
        ref
      });
    }
  );

  // packages/icons/build-module/library/add-template.mjs
  var import_primitives = __toESM(require_primitives(), 1);
  var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
  var add_template_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18.5 5.5V8H20V5.5H22.5V4H20V1.5H18.5V4H16V5.5H18.5ZM13.9624 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V10.0391H18.5V18C18.5 18.2761 18.2761 18.5 18 18.5H10L10 10.4917L16.4589 10.5139L16.4641 9.01389L5.5 8.97618V6C5.5 5.72386 5.72386 5.5 6 5.5H13.9624V4ZM5.5 10.4762V18C5.5 18.2761 5.72386 18.5 6 18.5H8.5L8.5 10.4865L5.5 10.4762Z" }) });

  // packages/icons/build-module/library/archive.mjs
  var import_primitives2 = __toESM(require_primitives(), 1);
  var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
  var archive_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M11.934 7.406a1 1 0 0 0 .914.594H19a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5h5.764a.5.5 0 0 1 .447.276l.723 1.63Zm1.064-1.216a.5.5 0 0 0 .462.31H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h5.764a2 2 0 0 1 1.789 1.106l.445 1.084ZM8.5 10.5h7V12h-7v-1.5Zm7 3.5h-7v1.5h7V14Z" }) });

  // packages/icons/build-module/library/arrow-down.mjs
  var import_primitives3 = __toESM(require_primitives(), 1);
  var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
  var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.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" }) });

  // packages/icons/build-module/library/arrow-left.mjs
  var import_primitives4 = __toESM(require_primitives(), 1);
  var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
  var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });

  // packages/icons/build-module/library/arrow-right.mjs
  var import_primitives5 = __toESM(require_primitives(), 1);
  var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
  var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });

  // packages/icons/build-module/library/arrow-up.mjs
  var import_primitives6 = __toESM(require_primitives(), 1);
  var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
  var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });

  // packages/icons/build-module/library/audio.mjs
  var import_primitives7 = __toESM(require_primitives(), 1);
  var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
  var audio_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.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" }) });

  // packages/icons/build-module/library/background.mjs
  var import_primitives8 = __toESM(require_primitives(), 1);
  var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
  var background_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M11.53 4.47a.75.75 0 1 0-1.06 1.06l8 8a.75.75 0 1 0 1.06-1.06l-8-8Zm5 1a.75.75 0 1 0-1.06 1.06l2 2a.75.75 0 1 0 1.06-1.06l-2-2Zm-11.06 10a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-2-2a.75.75 0 0 1 0-1.06Zm.06-5a.75.75 0 0 0-1.06 1.06l8 8a.75.75 0 1 0 1.06-1.06l-8-8Zm-.06-3a.75.75 0 0 1 1.06 0l10 10a.75.75 0 1 1-1.06 1.06l-10-10a.75.75 0 0 1 0-1.06Zm3.06-2a.75.75 0 0 0-1.06 1.06l10 10a.75.75 0 1 0 1.06-1.06l-10-10Z" }) });

  // packages/icons/build-module/library/backup.mjs
  var import_primitives9 = __toESM(require_primitives(), 1);
  var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
  var backup_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "M5.5 12h1.75l-2.5 3-2.5-3H4a8 8 0 113.134 6.35l.907-1.194A6.5 6.5 0 105.5 12zm9.53 1.97l-2.28-2.28V8.5a.75.75 0 00-1.5 0V12a.747.747 0 00.218.529l1.282-.84-1.28.842 2.5 2.5a.75.75 0 101.06-1.061z" }) });

  // packages/icons/build-module/library/block-default.mjs
  var import_primitives10 = __toESM(require_primitives(), 1);
  var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
  var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) });

  // packages/icons/build-module/library/block-table.mjs
  var import_primitives11 = __toESM(require_primitives(), 1);
  var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
  var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.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" }) });

  // packages/icons/build-module/library/category.mjs
  var import_primitives12 = __toESM(require_primitives(), 1);
  var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
  var category_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.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" }) });

  // packages/icons/build-module/library/check.mjs
  var import_primitives13 = __toESM(require_primitives(), 1);
  var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
  var check_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });

  // packages/icons/build-module/library/chevron-down.mjs
  var import_primitives14 = __toESM(require_primitives(), 1);
  var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
  var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });

  // packages/icons/build-module/library/chevron-left-small.mjs
  var import_primitives15 = __toESM(require_primitives(), 1);
  var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
  var chevron_left_small_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z" }) });

  // packages/icons/build-module/library/chevron-left.mjs
  var import_primitives16 = __toESM(require_primitives(), 1);
  var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
  var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });

  // packages/icons/build-module/library/chevron-right-small.mjs
  var import_primitives17 = __toESM(require_primitives(), 1);
  var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
  var chevron_right_small_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.Path, { d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" }) });

  // packages/icons/build-module/library/chevron-right.mjs
  var import_primitives18 = __toESM(require_primitives(), 1);
  var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
  var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });

  // packages/icons/build-module/library/chevron-up.mjs
  var import_primitives19 = __toESM(require_primitives(), 1);
  var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
  var chevron_up_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.Path, { d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" }) });

  // packages/icons/build-module/library/close-small.mjs
  var import_primitives20 = __toESM(require_primitives(), 1);
  var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
  var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.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" }) });

  // packages/icons/build-module/library/close.mjs
  var import_primitives21 = __toESM(require_primitives(), 1);
  var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
  var close_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.Path, { d: "m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z" }) });

  // packages/icons/build-module/library/cloud-upload.mjs
  var import_primitives22 = __toESM(require_primitives(), 1);
  var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
  var cloud_upload_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { d: "M17.3 10.1C17.3 7.60001 15.2 5.70001 12.5 5.70001C10.3 5.70001 8.4 7.10001 7.9 9.00001H7.7C5.7 9.00001 4 10.7 4 12.8C4 14.9 5.7 16.6 7.7 16.6H9.5V15.2H7.7C6.5 15.2 5.5 14.1 5.5 12.9C5.5 11.7 6.5 10.5 7.7 10.5H9L9.3 9.40001C9.7 8.10001 11 7.20001 12.5 7.20001C14.3 7.20001 15.8 8.50001 15.8 10.1V11.4L17.1 11.6C17.9 11.7 18.5 12.5 18.5 13.4C18.5 14.4 17.7 15.2 16.8 15.2H14.5V16.6H16.7C18.5 16.6 19.9 15.1 19.9 13.3C20 11.7 18.8 10.4 17.3 10.1Z M14.1245 14.2426L15.1852 13.182L12.0032 10L8.82007 13.1831L9.88072 14.2438L11.25 12.8745V18H12.75V12.8681L14.1245 14.2426Z" }) });

  // packages/icons/build-module/library/cloud.mjs
  var import_primitives23 = __toESM(require_primitives(), 1);
  var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
  var cloud_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-9c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4h1.3l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8-.1 1-.9 1.8-1.8 1.8z" }) });

  // packages/icons/build-module/library/code.mjs
  var import_primitives24 = __toESM(require_primitives(), 1);
  var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
  var code_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.Path, { d: "M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z" }) });

  // packages/icons/build-module/library/cog.mjs
  var import_primitives25 = __toESM(require_primitives(), 1);
  var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
  var cog_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.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" }) });

  // packages/icons/build-module/library/color.mjs
  var import_primitives26 = __toESM(require_primitives(), 1);
  var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
  var color_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.Path, { d: "M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z" }) });

  // packages/icons/build-module/library/comment-author-avatar.mjs
  var import_primitives27 = __toESM(require_primitives(), 1);
  var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
  var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.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" }) });

  // packages/icons/build-module/library/comment.mjs
  var import_primitives28 = __toESM(require_primitives(), 1);
  var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
  var comment_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.Path, { d: "M18 4H6c-1.1 0-2 .9-2 2v12.9c0 .6.5 1.1 1.1 1.1.3 0 .5-.1.8-.3L8.5 17H18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 11c0 .3-.2.5-.5.5H7.9l-2.4 2.4V6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v9z" }) });

  // packages/icons/build-module/library/copy-small.mjs
  var import_primitives29 = __toESM(require_primitives(), 1);
  var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
  var copy_small_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5.625 5.5h9.75c.069 0 .125.056.125.125v9.75a.125.125 0 0 1-.125.125h-9.75a.125.125 0 0 1-.125-.125v-9.75c0-.069.056-.125.125-.125ZM4 5.625C4 4.728 4.728 4 5.625 4h9.75C16.273 4 17 4.728 17 5.625v9.75c0 .898-.727 1.625-1.625 1.625h-9.75A1.625 1.625 0 0 1 4 15.375v-9.75Zm14.5 11.656v-9H20v9C20 18.8 18.77 20 17.251 20H6.25v-1.5h11.001c.69 0 1.249-.528 1.249-1.219Z" }) });

  // packages/icons/build-module/library/desktop.mjs
  var import_primitives30 = __toESM(require_primitives(), 1);
  var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
  var desktop_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.Path, { d: "M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z" }) });

  // packages/icons/build-module/library/download.mjs
  var import_primitives31 = __toESM(require_primitives(), 1);
  var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
  var download_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives31.Path, { d: "M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z" }) });

  // packages/icons/build-module/library/drafts.mjs
  var import_primitives32 = __toESM(require_primitives(), 1);
  var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
  var drafts_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives32.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives32.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 0Zm8 4a4 4 0 0 0 4-4H8a4 4 0 0 0 4 4Z" }) });

  // packages/icons/build-module/library/drawer-left.mjs
  var import_primitives33 = __toESM(require_primitives(), 1);
  var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
  var drawer_left_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives33.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives33.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z" }) });

  // packages/icons/build-module/library/drawer-right.mjs
  var import_primitives34 = __toESM(require_primitives(), 1);
  var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
  var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives34.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives34.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z" }) });

  // packages/icons/build-module/library/envelope.mjs
  var import_primitives35 = __toESM(require_primitives(), 1);
  var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
  var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives35.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives35.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" }) });

  // packages/icons/build-module/library/error.mjs
  var import_primitives36 = __toESM(require_primitives(), 1);
  var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
  var error_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives36.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives36.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" }) });

  // packages/icons/build-module/library/external.mjs
  var import_primitives37 = __toESM(require_primitives(), 1);
  var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
  var external_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives37.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives37.Path, { d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" }) });

  // packages/icons/build-module/library/file.mjs
  var import_primitives38 = __toESM(require_primitives(), 1);
  var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
  var file_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives38.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives38.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" }) });

  // packages/icons/build-module/library/flip-horizontal.mjs
  var import_primitives39 = __toESM(require_primitives(), 1);
  var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
  var flip_horizontal_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives39.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives39.Path, { d: "M4 6v12c0 1.1.9 2 2 2h3v-1.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h3V4H6c-1.1 0-2 .9-2 2zm7.2 16h1.5V2h-1.5v20zM15 5.5h1.5V4H15v1.5zm3.5.5H20c0-1.1-.9-2-2-2v1.5c.3 0 .5.2.5.5zm0 10.5H20v-2h-1.5v2zm0-3.5H20v-2h-1.5v2zm-.5 5.5V20c1.1 0 2-.9 2-2h-1.5c0 .3-.2.5-.5.5zM15 20h1.5v-1.5H15V20zm3.5-10.5H20v-2h-1.5v2z" }) });

  // packages/icons/build-module/library/flip-vertical.mjs
  var import_primitives40 = __toESM(require_primitives(), 1);
  var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
  var flip_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives40.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives40.Path, { d: "M2 11.2v1.5h20v-1.5H2zM5.5 6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v3H20V6c0-1.1-.9-2-2-2H6c-1.1 0-2 .9-2 2v3h1.5V6zm2 14h2v-1.5h-2V20zm3.5 0h2v-1.5h-2V20zm7-1.5V20c1.1 0 2-.9 2-2h-1.5c0 .3-.2.5-.5.5zm.5-2H20V15h-1.5v1.5zM5.5 18H4c0 1.1.9 2 2 2v-1.5c-.3 0-.5-.2-.5-.5zm0-3H4v1.5h1.5V15zm9 5h2v-1.5h-2V20z" }) });

  // packages/icons/build-module/library/footer.mjs
  var import_primitives41 = __toESM(require_primitives(), 1);
  var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
  var footer_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives41.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives41.Path, { fillRule: "evenodd", d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });

  // packages/icons/build-module/library/format-list-bullets-rtl.mjs
  var import_primitives42 = __toESM(require_primitives(), 1);
  var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
  var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives42.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives42.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" }) });

  // packages/icons/build-module/library/format-list-bullets.mjs
  var import_primitives43 = __toESM(require_primitives(), 1);
  var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
  var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives43.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives43.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" }) });

  // packages/icons/build-module/library/funnel.mjs
  var import_primitives44 = __toESM(require_primitives(), 1);
  var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
  var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives44.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives44.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });

  // packages/icons/build-module/library/header.mjs
  var import_primitives45 = __toESM(require_primitives(), 1);
  var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
  var header_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives45.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives45.Path, { d: "M18.5 10.5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });

  // packages/icons/build-module/library/info.mjs
  var import_primitives46 = __toESM(require_primitives(), 1);
  var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
  var info_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives46.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives46.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z" }) });

  // packages/icons/build-module/library/keyboard.mjs
  var import_primitives47 = __toESM(require_primitives(), 1);
  var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
  var keyboard_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_primitives47.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [
    /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives47.Path, { d: "m16 15.5h-8v-1.5h8zm-7.5-2.5h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm-9-3h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2z" }),
    /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives47.Path, { d: "m18.5 6.5h-13a.5.5 0 0 0 -.5.5v9.5a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9.5a.5.5 0 0 0 -.5-.5zm-13-1.5h13a2 2 0 0 1 2 2v9.5a2 2 0 0 1 -2 2h-13a2 2 0 0 1 -2-2v-9.5a2 2 0 0 1 2-2z" })
  ] });

  // packages/icons/build-module/library/layout.mjs
  var import_primitives48 = __toESM(require_primitives(), 1);
  var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
  var layout_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives48.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives48.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });

  // packages/icons/build-module/library/link.mjs
  var import_primitives49 = __toESM(require_primitives(), 1);
  var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
  var link_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives49.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives49.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" }) });

  // packages/icons/build-module/library/list-view.mjs
  var import_primitives50 = __toESM(require_primitives(), 1);
  var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
  var list_view_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives50.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives50.Path, { d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" }) });

  // packages/icons/build-module/library/lock-small.mjs
  var import_primitives51 = __toESM(require_primitives(), 1);
  var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
  var lock_small_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives51.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives51.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M15 11h-.2V9c0-1.5-1.2-2.8-2.8-2.8S9.2 7.5 9.2 9v2H9c-.6 0-1 .4-1 1v4c0 .6.4 1 1 1h6c.6 0 1-.4 1-1v-4c0-.6-.4-1-1-1zm-1.8 0h-2.5V9c0-.7.6-1.2 1.2-1.2s1.2.6 1.2 1.2v2z" }) });

  // packages/icons/build-module/library/mobile.mjs
  var import_primitives52 = __toESM(require_primitives(), 1);
  var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
  var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives52.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives52.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" }) });

  // packages/icons/build-module/library/more-vertical.mjs
  var import_primitives53 = __toESM(require_primitives(), 1);
  var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
  var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives53.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives53.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });

  // packages/icons/build-module/library/navigation-overlay.mjs
  var import_primitives54 = __toESM(require_primitives(), 1);
  var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
  var navigation_overlay_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives54.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives54.Path, { d: "M18.5 10a1.5 1.5 0 0 1 1.5 1.5v7a1.5 1.5 0 0 1-1.5 1.5h-7a1.5 1.5 0 0 1-1.5-1.5v-7a1.5 1.5 0 0 1 1.5-1.5zM16 4a2 2 0 0 1 2 2v2h-1.5V6a.5.5 0 0 0-.5-.5H6a.5.5 0 0 0-.5.5v3H8v1.5H5.5V16a.5.5 0 0 0 .5.5h2V18H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z" }) });

  // packages/icons/build-module/library/navigation.mjs
  var import_primitives55 = __toESM(require_primitives(), 1);
  var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
  var navigation_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives55.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives55.Path, { d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z" }) });

  // packages/icons/build-module/library/next.mjs
  var import_primitives56 = __toESM(require_primitives(), 1);
  var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
  var next_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives56.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives56.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" }) });

  // packages/icons/build-module/library/not-allowed.mjs
  var import_primitives57 = __toESM(require_primitives(), 1);
  var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
  var not_allowed_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives57.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives57.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5A6.5 6.5 0 0 1 6.93 7.931l9.139 9.138A6.473 6.473 0 0 1 12 18.5Zm5.123-2.498a6.5 6.5 0 0 0-9.124-9.124l9.124 9.124ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Z" }) });

  // packages/icons/build-module/library/page.mjs
  var import_primitives58 = __toESM(require_primitives(), 1);
  var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
  var page_default = /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_primitives58.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [
    /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives58.Path, { d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" }),
    /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives58.Path, { d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z" })
  ] });

  // packages/icons/build-module/library/pencil.mjs
  var import_primitives59 = __toESM(require_primitives(), 1);
  var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
  var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives59.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives59.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) });

  // packages/icons/build-module/library/pending.mjs
  var import_primitives60 = __toESM(require_primitives(), 1);
  var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
  var pending_default = /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives60.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives60.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 0Zm8 4a4 4 0 0 1-4-4h4V8a4 4 0 0 1 0 8Z" }) });

  // packages/icons/build-module/library/plus.mjs
  var import_primitives61 = __toESM(require_primitives(), 1);
  var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
  var plus_default = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives61.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives61.Path, { d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" }) });

  // packages/icons/build-module/library/post.mjs
  var import_primitives62 = __toESM(require_primitives(), 1);
  var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
  var post_default = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives62.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives62.Path, { d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z" }) });

  // packages/icons/build-module/library/previous.mjs
  var import_primitives63 = __toESM(require_primitives(), 1);
  var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
  var previous_default = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives63.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives63.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" }) });

  // packages/icons/build-module/library/published.mjs
  var import_primitives64 = __toESM(require_primitives(), 1);
  var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
  var published_default = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives64.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives64.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 0Zm11.53-1.47-1.06-1.06L11 12.94l-1.47-1.47-1.06 1.06L11 15.06l4.53-4.53Z" }) });

  // packages/icons/build-module/library/redo.mjs
  var import_primitives65 = __toESM(require_primitives(), 1);
  var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
  var redo_default = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives65.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives65.Path, { d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z" }) });

  // packages/icons/build-module/library/reset.mjs
  var import_primitives66 = __toESM(require_primitives(), 1);
  var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
  var reset_default = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives66.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives66.Path, { d: "M7 11.5h10V13H7z" }) });

  // packages/icons/build-module/library/rotate-left.mjs
  var import_primitives67 = __toESM(require_primitives(), 1);
  var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
  var rotate_left_default = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives67.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives67.Path, { d: "M12 4V2.2L9 4.8l3 2.5V5.5c3.6 0 6.5 2.9 6.5 6.5 0 2.9-1.9 5.3-4.5 6.2v.2l-.1-.2c-.4.1-.7.2-1.1.2l.2 1.5c.3 0 .6-.1 1-.2 3.5-.9 6-4 6-7.7 0-4.4-3.6-8-8-8zm-7.9 7l1.5.2c.1-1.2.5-2.3 1.2-3.2l-1.1-.9C4.8 8.2 4.3 9.6 4.1 11zm1.5 1.8l-1.5.2c.1.7.3 1.4.5 2 .3.7.6 1.3 1 1.8l1.2-.8c-.3-.5-.6-1-.8-1.5s-.4-1.1-.4-1.7zm1.5 5.5c1.1.9 2.4 1.4 3.8 1.6l.2-1.5c-1.1-.1-2.2-.5-3.1-1.2l-.9 1.1z" }) });

  // packages/icons/build-module/library/rotate-right.mjs
  var import_primitives68 = __toESM(require_primitives(), 1);
  var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
  var rotate_right_default = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_primitives68.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_primitives68.Path, { d: "M15.1 4.8l-3-2.5V4c-4.4 0-8 3.6-8 8 0 3.7 2.5 6.9 6 7.7.3.1.6.1 1 .2l.2-1.5c-.4 0-.7-.1-1.1-.2l-.1.2v-.2c-2.6-.8-4.5-3.3-4.5-6.2 0-3.6 2.9-6.5 6.5-6.5v1.8l3-2.5zM20 11c-.2-1.4-.7-2.7-1.6-3.8l-1.2.8c.7.9 1.1 2 1.3 3.1L20 11zm-1.5 1.8c-.1.5-.2 1.1-.4 1.6s-.5 1-.8 1.5l1.2.9c.4-.5.8-1.1 1-1.8s.5-1.3.5-2l-1.5-.2zm-5.6 5.6l.2 1.5c1.4-.2 2.7-.7 3.8-1.6l-.9-1.1c-.9.7-2 1.1-3.1 1.2z" }) });

  // packages/icons/build-module/library/scheduled.mjs
  var import_primitives69 = __toESM(require_primitives(), 1);
  var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
  var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_primitives69.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_primitives69.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" }) });

  // packages/icons/build-module/library/search.mjs
  var import_primitives70 = __toESM(require_primitives(), 1);
  var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
  var search_default = /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_primitives70.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_primitives70.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" }) });

  // packages/icons/build-module/library/seen.mjs
  var import_primitives71 = __toESM(require_primitives(), 1);
  var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
  var seen_default = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_primitives71.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_primitives71.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" }) });

  // packages/icons/build-module/library/settings.mjs
  var import_primitives72 = __toESM(require_primitives(), 1);
  var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
  var settings_default = /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_primitives72.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [
    /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_primitives72.Path, { d: "m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z" }),
    /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_primitives72.Path, { d: "m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z" })
  ] });

  // packages/icons/build-module/library/shadow.mjs
  var import_primitives73 = __toESM(require_primitives(), 1);
  var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
  var shadow_default = /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_primitives73.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_primitives73.Path, { d: "M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6.5c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5zM12.8 3h-1.5v3h1.5V3zm-1.6 18h1.5v-3h-1.5v3zm6.8-9.8v1.5h3v-1.5h-3zm-12 0H3v1.5h3v-1.5zm9.7 5.6 2.1 2.1 1.1-1.1-2.1-2.1-1.1 1.1zM8.3 7.2 6.2 5.1 5.1 6.2l2.1 2.1 1.1-1.1zM5.1 17.8l1.1 1.1 2.1-2.1-1.1-1.1-2.1 2.1zM18.9 6.2l-1.1-1.1-2.1 2.1 1.1 1.1 2.1-2.1z" }) });

  // packages/icons/build-module/library/shuffle.mjs
  var import_primitives74 = __toESM(require_primitives(), 1);
  var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
  var shuffle_default = /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_primitives74.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_primitives74.Path, { d: "M17.192 6.75L15.47 5.03l1.06-1.06 3.537 3.53-3.537 3.53-1.06-1.06 1.723-1.72h-3.19c-.602 0-.993.202-1.28.498-.309.319-.538.792-.695 1.383-.13.488-.222 1.023-.296 1.508-.034.664-.116 1.413-.303 2.117-.193.721-.513 1.467-1.068 2.04-.575.594-1.359.954-2.357.954H4v-1.5h4.003c.601 0 .993-.202 1.28-.498.308-.319.538-.792.695-1.383.149-.557.216-1.093.288-1.662l.039-.31a9.653 9.653 0 0 1 .272-1.653c.193-.722.513-1.467 1.067-2.04.576-.594 1.36-.954 2.358-.954h3.19zM8.004 6.75c.8 0 1.46.23 1.988.628a6.24 6.24 0 0 0-.684 1.396 1.725 1.725 0 0 0-.024-.026c-.287-.296-.679-.498-1.28-.498H4v-1.5h4.003zM12.699 14.726c-.161.459-.38.94-.684 1.396.527.397 1.188.628 1.988.628h3.19l-1.722 1.72 1.06 1.06L20.067 16l-3.537-3.53-1.06 1.06 1.723 1.72h-3.19c-.602 0-.993-.202-1.28-.498a1.96 1.96 0 0 1-.024-.026z" }) });

  // packages/icons/build-module/library/sidebar.mjs
  var import_primitives75 = __toESM(require_primitives(), 1);
  var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
  var sidebar_default = /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_primitives75.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_primitives75.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });

  // packages/icons/build-module/library/square.mjs
  var import_primitives76 = __toESM(require_primitives(), 1);
  var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
  var square_default = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_primitives76.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_primitives76.Path, { fill: "none", d: "M5.75 12.75V18.25H11.25M12.75 5.75H18.25V11.25", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "square" }) });

  // packages/icons/build-module/library/star-empty.mjs
  var import_primitives77 = __toESM(require_primitives(), 1);
  var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
  var star_empty_default = /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_primitives77.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_primitives77.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z" }) });

  // packages/icons/build-module/library/star-filled.mjs
  var import_primitives78 = __toESM(require_primitives(), 1);
  var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
  var star_filled_default = /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_primitives78.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_primitives78.Path, { d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" }) });

  // packages/icons/build-module/library/styles.mjs
  var import_primitives79 = __toESM(require_primitives(), 1);
  var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
  var styles_default = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_primitives79.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_primitives79.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 0 1-6.5 6.5v-13a6.5 6.5 0 0 1 6.5 6.5Z" }) });

  // packages/icons/build-module/library/symbol-filled.mjs
  var import_primitives80 = __toESM(require_primitives(), 1);
  var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
  var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_primitives80.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_primitives80.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) });

  // packages/icons/build-module/library/symbol.mjs
  var import_primitives81 = __toESM(require_primitives(), 1);
  var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
  var symbol_default = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_primitives81.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_primitives81.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) });

  // packages/icons/build-module/library/tablet.mjs
  var import_primitives82 = __toESM(require_primitives(), 1);
  var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
  var tablet_default = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_primitives82.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_primitives82.Path, { d: "M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z" }) });

  // packages/icons/build-module/library/trash.mjs
  var import_primitives83 = __toESM(require_primitives(), 1);
  var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
  var trash_default = /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_primitives83.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_primitives83.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" }) });

  // packages/icons/build-module/library/typography.mjs
  var import_primitives84 = __toESM(require_primitives(), 1);
  var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
  var typography_default = /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_primitives84.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_primitives84.Path, { d: "m8.6 7 3.9 10.8h-1.7l-1-2.8H5.7l-1 2.8H3L6.9 7h1.7Zm-2.4 6.6h3L7.7 9.3l-1.5 4.3ZM17.691 8.879c.473 0 .88.055 1.221.165.352.1.643.264.875.495.274.253.456.572.544.957.088.374.132.83.132 1.37v4.554c0 .274.033.472.099.593.077.11.198.166.363.166.11 0 .215-.028.313-.083.11-.055.237-.137.38-.247l.165.28a3.304 3.304 0 0 1-.71.446c-.23.11-.527.165-.89.165-.352 0-.639-.055-.858-.165-.22-.11-.386-.27-.495-.479-.1-.209-.149-.468-.149-.775-.286.462-.627.814-1.023 1.056-.396.242-.858.363-1.386.363-.462 0-.858-.088-1.188-.264a1.752 1.752 0 0 1-.742-.726 2.201 2.201 0 0 1-.248-1.056c0-.484.11-.875.33-1.172.22-.308.5-.556.841-.742.352-.187.721-.341 1.106-.462.396-.132.765-.253 1.106-.363.351-.121.637-.259.857-.413.232-.154.347-.357.347-.61V10.81c0-.396-.066-.71-.198-.941a1.05 1.05 0 0 0-.511-.511 1.763 1.763 0 0 0-.76-.149c-.253 0-.522.039-.808.116a1.165 1.165 0 0 0-.677.412 1.1 1.1 0 0 1 .595.396c.165.187.247.424.247.71 0 .307-.104.55-.313.726-.198.176-.451.263-.76.263-.34 0-.594-.104-.758-.313a1.231 1.231 0 0 1-.248-.759c0-.297.072-.539.214-.726.154-.187.352-.363.595-.528.264-.176.6-.324 1.006-.445.418-.121.88-.182 1.386-.182Zm.99 3.729a1.57 1.57 0 0 1-.528.462c-.231.121-.479.248-.742.38a5.377 5.377 0 0 0-.76.462c-.23.165-.423.38-.577.643-.154.264-.231.6-.231 1.007 0 .429.11.77.33 1.023.22.242.517.363.891.363.308 0 .594-.088.858-.264.275-.176.528-.44.759-.792v-3.284Z" }) });

  // packages/icons/build-module/library/undo.mjs
  var import_primitives85 = __toESM(require_primitives(), 1);
  var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
  var undo_default = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_primitives85.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_primitives85.Path, { d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z" }) });

  // packages/icons/build-module/library/unseen.mjs
  var import_primitives86 = __toESM(require_primitives(), 1);
  var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
  var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_primitives86.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_primitives86.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" }) });

  // packages/icons/build-module/library/verse.mjs
  var import_primitives87 = __toESM(require_primitives(), 1);
  var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
  var verse_default = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_primitives87.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_primitives87.Path, { d: "M17.8 2l-.9.3c-.1 0-3.6 1-5.2 2.1C10 5.5 9.3 6.5 8.9 7.1c-.6.9-1.7 4.7-1.7 6.3l-.9 2.3c-.2.4 0 .8.4 1 .1 0 .2.1.3.1.3 0 .6-.2.7-.5l.6-1.5c.3 0 .7-.1 1.2-.2.7-.1 1.4-.3 2.2-.5.8-.2 1.6-.5 2.4-.8.7-.3 1.4-.7 1.9-1.2s.8-1.2 1-1.9c.2-.7.3-1.6.4-2.4.1-.8.1-1.7.2-2.5 0-.8.1-1.5.2-2.1V2zm-1.9 5.6c-.1.8-.2 1.5-.3 2.1-.2.6-.4 1-.6 1.3-.3.3-.8.6-1.4.9-.7.3-1.4.5-2.2.8-.6.2-1.3.3-1.8.4L15 7.5c.3-.3.6-.7 1-1.1 0 .4 0 .8-.1 1.2zM6 20h8v-1.5H6V20z" }) });

  // packages/icons/build-module/library/video.mjs
  var import_primitives88 = __toESM(require_primitives(), 1);
  var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
  var video_default = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_primitives88.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_primitives88.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" }) });

  // packages/icons/build-module/library/wordpress.mjs
  var import_primitives89 = __toESM(require_primitives(), 1);
  var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
  var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_primitives89.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_primitives89.Path, { d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" }) });

  // packages/editor/build-module/utils/get-template-part-icon.mjs
  function getTemplatePartIcon(areaOrIconName) {
    if ("header" === areaOrIconName) {
      return header_default;
    } else if ("footer" === areaOrIconName) {
      return footer_default;
    } else if ("sidebar" === areaOrIconName) {
      return sidebar_default;
    } else if ("navigation-overlay" === areaOrIconName) {
      return navigation_overlay_default;
    }
    return symbol_filled_default;
  }

  // packages/editor/build-module/lock-unlock.mjs
  var import_private_apis = __toESM(require_private_apis(), 1);
  var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
    "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
    "@wordpress/editor"
  );

  // packages/editor/build-module/utils/get-template-info.mjs
  var EMPTY_OBJECT = {};
  var getTemplateInfo = (params) => {
    if (!params) {
      return EMPTY_OBJECT;
    }
    const { templateTypes, templateAreas, template: template2 } = params;
    const { description, slug, title, area } = template2;
    const { title: defaultTitle, description: defaultDescription } = Object.values(templateTypes).find((type) => type.slug === slug) ?? EMPTY_OBJECT;
    const templateTitle = typeof title === "string" ? title : title?.rendered;
    const templateDescription = typeof description === "string" ? description : description?.raw;
    const templateAreasWithIcon = templateAreas?.map((item) => ({
      ...item,
      icon: getTemplatePartIcon(item.icon)
    }));
    const templateIcon = templateAreasWithIcon?.find((item) => area === item.area)?.icon || layout_default;
    return {
      title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
      description: templateDescription || defaultDescription,
      icon: templateIcon
    };
  };

  // packages/editor/build-module/store/selectors.mjs
  var EMPTY_OBJECT2 = {};
  var hasEditorUndo = (0, import_data3.createRegistrySelector)((select7) => () => {
    return select7(import_core_data.store).hasUndo();
  });
  var hasEditorRedo = (0, import_data3.createRegistrySelector)((select7) => () => {
    return select7(import_core_data.store).hasRedo();
  });
  function isEditedPostNew(state) {
    return getCurrentPost(state).status === "auto-draft";
  }
  function hasChangedContent(state) {
    const edits = getPostEdits(state);
    return "content" in edits;
  }
  var isEditedPostDirty = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      const postType2 = getCurrentPostType(state);
      const postId2 = getCurrentPostId(state);
      return select7(import_core_data.store).hasEditsForEntityRecord(
        "postType",
        postType2,
        postId2
      );
    }
  );
  var hasNonPostEntityChanges = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      const dirtyEntityRecords = select7(import_core_data.store).__experimentalGetDirtyEntityRecords();
      const { type, id } = getCurrentPost(state);
      return dirtyEntityRecords.some(
        (entityRecord) => entityRecord.kind !== "postType" || entityRecord.name !== type || entityRecord.key !== id
      );
    }
  );
  function isCleanNewPost(state) {
    return !isEditedPostDirty(state) && isEditedPostNew(state);
  }
  var getCurrentPost = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      const postId2 = getCurrentPostId(state);
      const postType2 = getCurrentPostType(state);
      const post2 = select7(import_core_data.store).getRawEntityRecord(
        "postType",
        postType2,
        postId2
      );
      if (post2) {
        return post2;
      }
      return EMPTY_OBJECT2;
    }
  );
  function getCurrentPostType(state) {
    return state.postType;
  }
  function getCurrentPostId(state) {
    return state.postId;
  }
  function getCurrentTemplateId(state) {
    return state.templateId;
  }
  function getCurrentPostRevisionsCount(state) {
    return getCurrentPost(state)._links?.["version-history"]?.[0]?.count ?? 0;
  }
  function getCurrentPostLastRevisionId(state) {
    return getCurrentPost(state)._links?.["predecessor-version"]?.[0]?.id ?? null;
  }
  var getPostEdits = (0, import_data3.createRegistrySelector)((select7) => (state) => {
    const postType2 = getCurrentPostType(state);
    const postId2 = getCurrentPostId(state);
    return select7(import_core_data.store).getEntityRecordEdits(
      "postType",
      postType2,
      postId2
    ) || EMPTY_OBJECT2;
  });
  function getCurrentPostAttribute(state, attributeName) {
    switch (attributeName) {
      case "type":
        return getCurrentPostType(state);
      case "id":
        return getCurrentPostId(state);
      default:
        const post2 = getCurrentPost(state);
        if (!post2.hasOwnProperty(attributeName)) {
          break;
        }
        return getPostRawValue(post2[attributeName]);
    }
  }
  var getNestedEditedPostProperty = (0, import_data3.createSelector)(
    (state, attributeName) => {
      const edits = getPostEdits(state);
      if (!edits.hasOwnProperty(attributeName)) {
        return getCurrentPostAttribute(state, attributeName);
      }
      return {
        ...getCurrentPostAttribute(state, attributeName),
        ...edits[attributeName]
      };
    },
    (state, attributeName) => [
      getCurrentPostAttribute(state, attributeName),
      getPostEdits(state)[attributeName]
    ]
  );
  function getEditedPostAttribute(state, attributeName) {
    switch (attributeName) {
      case "content":
        return getEditedPostContent(state);
    }
    const edits = getPostEdits(state);
    if (!edits.hasOwnProperty(attributeName)) {
      return getCurrentPostAttribute(state, attributeName);
    }
    if (EDIT_MERGE_PROPERTIES.has(attributeName)) {
      return getNestedEditedPostProperty(state, attributeName);
    }
    return edits[attributeName];
  }
  var getAutosaveAttribute = (0, import_data3.createRegistrySelector)(
    (select7) => (state, attributeName) => {
      if (!AUTOSAVE_PROPERTIES.includes(attributeName) && attributeName !== "preview_link") {
        return;
      }
      const postType2 = getCurrentPostType(state);
      const postId2 = getCurrentPostId(state);
      const currentUserId = select7(import_core_data.store).getCurrentUser()?.id;
      const autosave2 = select7(import_core_data.store).getAutosave(
        postType2,
        postId2,
        currentUserId
      );
      if (autosave2) {
        return getPostRawValue(autosave2[attributeName]);
      }
    }
  );
  function getEditedPostVisibility(state) {
    const status = getEditedPostAttribute(state, "status");
    if (status === "private") {
      return "private";
    }
    const password = getEditedPostAttribute(state, "password");
    if (password) {
      return "password";
    }
    return "public";
  }
  function isCurrentPostPending(state) {
    return getCurrentPost(state).status === "pending";
  }
  function isCurrentPostPublished(state, currentPost) {
    const post2 = currentPost || getCurrentPost(state);
    return ["publish", "private"].indexOf(post2.status) !== -1 || post2.status === "future" && !(0, import_date.isInTheFuture)(
      new Date(Number((0, import_date.getDate)(post2.date)) - ONE_MINUTE_IN_MS)
    );
  }
  function isCurrentPostScheduled(state) {
    return getCurrentPost(state).status === "future" && !isCurrentPostPublished(state);
  }
  function isEditedPostPublishable(state) {
    const post2 = getCurrentPost(state);
    if (post2.type === ATTACHMENT_POST_TYPE) {
      return isEditedPostDirty(state);
    }
    return isEditedPostDirty(state) || ["publish", "private", "future"].indexOf(post2.status) === -1;
  }
  function isEditedPostSaveable(state) {
    if (isSavingPost(state)) {
      return false;
    }
    return !!getEditedPostAttribute(state, "title") || !!getEditedPostAttribute(state, "excerpt") || !isEditedPostEmpty(state) || import_element2.Platform.OS === "native";
  }
  var isEditedPostEmpty = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      const postId2 = getCurrentPostId(state);
      const postType2 = getCurrentPostType(state);
      const record = select7(import_core_data.store).getEditedEntityRecord(
        "postType",
        postType2,
        postId2
      );
      if (typeof record.content !== "function") {
        return !record.content;
      }
      const blocks = getEditedPostAttribute(state, "blocks");
      if (blocks.length === 0) {
        return true;
      }
      if (blocks.length > 1) {
        return false;
      }
      const blockName = blocks[0].name;
      if (blockName !== (0, import_blocks.getDefaultBlockName)() && blockName !== (0, import_blocks.getFreeformContentHandlerName)()) {
        return false;
      }
      return !getEditedPostContent(state);
    }
  );
  var isEditedPostAutosaveable = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      if (!isEditedPostSaveable(state)) {
        return false;
      }
      if (isPostAutosavingLocked(state)) {
        return false;
      }
      const postType2 = getCurrentPostType(state);
      const postTypeObject = select7(import_core_data.store).getPostType(postType2);
      if (!postTypeObject?.supports?.autosave) {
        return false;
      }
      const postId2 = getCurrentPostId(state);
      const hasFetchedAutosave = select7(import_core_data.store).hasFetchedAutosaves(
        postType2,
        postId2
      );
      const currentUserId = select7(import_core_data.store).getCurrentUser()?.id;
      const autosave2 = select7(import_core_data.store).getAutosave(
        postType2,
        postId2,
        currentUserId
      );
      if (!hasFetchedAutosave) {
        return false;
      }
      if (!autosave2) {
        return true;
      }
      if (hasChangedContent(state)) {
        return true;
      }
      return ["title", "excerpt", "meta"].some(
        (field) => getPostRawValue(autosave2[field]) !== getEditedPostAttribute(state, field)
      );
    }
  );
  function isEditedPostBeingScheduled(state) {
    const date = getEditedPostAttribute(state, "date");
    const checkedDate = new Date(
      Number((0, import_date.getDate)(date)) - ONE_MINUTE_IN_MS
    );
    return (0, import_date.isInTheFuture)(checkedDate);
  }
  function isEditedPostDateFloating(state) {
    const date = getEditedPostAttribute(state, "date");
    const modified = getEditedPostAttribute(state, "modified");
    const status = getCurrentPost(state).status;
    if (status === "draft" || status === "auto-draft" || status === "pending") {
      return date === modified || date === null;
    }
    return false;
  }
  function isDeletingPost(state) {
    return !!state.deleting.pending;
  }
  function isSavingPost(state) {
    return !!state.saving.pending;
  }
  var isSavingNonPostEntityChanges = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      const entitiesBeingSaved = select7(import_core_data.store).__experimentalGetEntitiesBeingSaved();
      const { type, id } = getCurrentPost(state);
      return entitiesBeingSaved.some(
        (entityRecord) => entityRecord.kind !== "postType" || entityRecord.name !== type || entityRecord.key !== id
      );
    }
  );
  var didPostSaveRequestSucceed = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      const postType2 = getCurrentPostType(state);
      const postId2 = getCurrentPostId(state);
      return !select7(import_core_data.store).getLastEntitySaveError(
        "postType",
        postType2,
        postId2
      );
    }
  );
  var didPostSaveRequestFail = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      const postType2 = getCurrentPostType(state);
      const postId2 = getCurrentPostId(state);
      return !!select7(import_core_data.store).getLastEntitySaveError(
        "postType",
        postType2,
        postId2
      );
    }
  );
  function isAutosavingPost(state) {
    return isSavingPost(state) && Boolean(state.saving.options?.isAutosave);
  }
  function isPreviewingPost(state) {
    return isSavingPost(state) && Boolean(state.saving.options?.isPreview);
  }
  function getEditedPostPreviewLink(state) {
    if (state.saving.pending || isSavingPost(state)) {
      return;
    }
    let previewLink = getAutosaveAttribute(state, "preview_link");
    if (!previewLink || "draft" === getCurrentPost(state).status) {
      previewLink = getEditedPostAttribute(state, "link");
      if (previewLink) {
        previewLink = (0, import_url.addQueryArgs)(previewLink, { preview: true });
      }
    }
    const featuredImageId = getEditedPostAttribute(state, "featured_media");
    if (previewLink && featuredImageId) {
      return (0, import_url.addQueryArgs)(previewLink, { _thumbnail_id: featuredImageId });
    }
    return previewLink;
  }
  var getSuggestedPostFormat = (0, import_data3.createRegistrySelector)(
    (select7) => () => {
      const blocks = select7(import_block_editor2.store).getBlocks();
      if (blocks.length > 2) {
        return null;
      }
      let name2;
      if (blocks.length === 1) {
        name2 = blocks[0].name;
        if (name2 === "core/embed") {
          const provider = blocks[0].attributes?.providerNameSlug;
          if (["youtube", "vimeo"].includes(provider)) {
            name2 = "core/video";
          } else if (["spotify", "soundcloud"].includes(provider)) {
            name2 = "core/audio";
          }
        }
      }
      if (blocks.length === 2 && blocks[1].name === "core/paragraph") {
        name2 = blocks[0].name;
      }
      switch (name2) {
        case "core/image":
          return "image";
        case "core/quote":
        case "core/pullquote":
          return "quote";
        case "core/gallery":
          return "gallery";
        case "core/video":
          return "video";
        case "core/audio":
          return "audio";
        default:
          return null;
      }
    }
  );
  var getEditedPostContent = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      const postId2 = getCurrentPostId(state);
      const postType2 = getCurrentPostType(state);
      const record = select7(import_core_data.store).getEditedEntityRecord(
        "postType",
        postType2,
        postId2
      );
      if (record) {
        if (typeof record.content === "function") {
          return record.content(record);
        } else if (record.blocks) {
          return (0, import_blocks.__unstableSerializeAndClean)(record.blocks);
        } else if (record.content) {
          return record.content;
        }
      }
      return "";
    }
  );
  function isPublishingPost(state) {
    return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, "status") === "publish";
  }
  function isPermalinkEditable(state) {
    const permalinkTemplate = getEditedPostAttribute(
      state,
      "permalink_template"
    );
    return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
  }
  function getPermalink(state) {
    const permalinkParts = getPermalinkParts(state);
    if (!permalinkParts) {
      return null;
    }
    const { prefix: prefix2, postName, suffix } = permalinkParts;
    if (isPermalinkEditable(state)) {
      return prefix2 + postName + suffix;
    }
    return prefix2;
  }
  function getEditedPostSlug(state) {
    return getEditedPostAttribute(state, "slug") || (0, import_url.cleanForSlug)(getEditedPostAttribute(state, "title")) || getCurrentPostId(state);
  }
  function getPermalinkParts(state) {
    const permalinkTemplate = getEditedPostAttribute(
      state,
      "permalink_template"
    );
    if (!permalinkTemplate) {
      return null;
    }
    const postName = getEditedPostAttribute(state, "slug") || getEditedPostAttribute(state, "generated_slug");
    const [prefix2, suffix] = permalinkTemplate.split(
      PERMALINK_POSTNAME_REGEX
    );
    return {
      prefix: prefix2,
      postName,
      suffix
    };
  }
  function isPostLocked(state) {
    return state.postLock.isLocked;
  }
  function isPostSavingLocked(state) {
    return Object.keys(state.postSavingLock).length > 0;
  }
  function isPostAutosavingLocked(state) {
    return Object.keys(state.postAutosavingLock).length > 0;
  }
  function isPostLockTakeover(state) {
    return state.postLock.isTakeover;
  }
  function getPostLockUser(state) {
    return state.postLock.user;
  }
  function getActivePostLock(state) {
    return state.postLock.activePostLock;
  }
  function canUserUseUnfilteredHTML(state) {
    return Boolean(
      getCurrentPost(state)._links?.hasOwnProperty(
        "wp:action-unfiltered-html"
      )
    );
  }
  var isPublishSidebarEnabled = (0, import_data3.createRegistrySelector)(
    (select7) => () => !!select7(import_preferences.store).get("core", "isPublishSidebarEnabled")
  );
  var getEditorBlocks = (0, import_data3.createSelector)(
    (state) => {
      return getEditedPostAttribute(state, "blocks") || (0, import_blocks.parse)(getEditedPostContent(state));
    },
    (state) => [
      getEditedPostAttribute(state, "blocks"),
      getEditedPostContent(state)
    ]
  );
  function isEditorPanelRemoved(state, panelName) {
    return state.removedPanels.includes(panelName);
  }
  var isEditorPanelEnabled = (0, import_data3.createRegistrySelector)(
    (select7) => (state, panelName) => {
      const inactivePanels = select7(import_preferences.store).get(
        "core",
        "inactivePanels"
      );
      return !isEditorPanelRemoved(state, panelName) && !inactivePanels?.includes(panelName);
    }
  );
  var isEditorPanelOpened = (0, import_data3.createRegistrySelector)(
    (select7) => (state, panelName) => {
      const openPanels = select7(import_preferences.store).get(
        "core",
        "openPanels"
      );
      return !!openPanels?.includes(panelName);
    }
  );
  function getEditorSelectionStart(state) {
    (0, import_deprecated.default)("select('core/editor').getEditorSelectionStart", {
      since: "5.8",
      alternative: "select('core/editor').getEditorSelection"
    });
    return getEditedPostAttribute(state, "selection")?.selectionStart;
  }
  function getEditorSelectionEnd(state) {
    (0, import_deprecated.default)("select('core/editor').getEditorSelectionStart", {
      since: "5.8",
      alternative: "select('core/editor').getEditorSelection"
    });
    return getEditedPostAttribute(state, "selection")?.selectionEnd;
  }
  function getEditorSelection(state) {
    return getEditedPostAttribute(state, "selection");
  }
  function __unstableIsEditorReady(state) {
    return !!state.postId;
  }
  function getEditorSettings(state) {
    return state.editorSettings;
  }
  function getRenderingMode(state) {
    return state.renderingMode;
  }
  var getDeviceType = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      const isZoomOut = unlock(select7(import_block_editor2.store)).isZoomOut();
      if (isZoomOut) {
        return "Desktop";
      }
      return state.deviceType;
    }
  );
  function isListViewOpened(state) {
    return state.listViewPanel;
  }
  function isInserterOpened(state) {
    return !!state.blockInserterPanel;
  }
  var getEditorMode = (0, import_data3.createRegistrySelector)(
    (select7) => () => select7(import_preferences.store).get("core", "editorMode") ?? "visual"
  );
  function getStateBeforeOptimisticTransaction() {
    (0, import_deprecated.default)("select('core/editor').getStateBeforeOptimisticTransaction", {
      since: "5.7",
      hint: "No state history is kept on this store anymore"
    });
    return null;
  }
  function inSomeHistory() {
    (0, import_deprecated.default)("select('core/editor').inSomeHistory", {
      since: "5.7",
      hint: "No state history is kept on this store anymore"
    });
    return false;
  }
  function getBlockEditorSelector(name2) {
    return (0, import_data3.createRegistrySelector)((select7) => (state, ...args) => {
      (0, import_deprecated.default)("`wp.data.select( 'core/editor' )." + name2 + "`", {
        since: "5.3",
        alternative: "`wp.data.select( 'core/block-editor' )." + name2 + "`",
        version: "6.2"
      });
      return select7(import_block_editor2.store)[name2](...args);
    });
  }
  var getBlockName = getBlockEditorSelector("getBlockName");
  var isBlockValid = getBlockEditorSelector("isBlockValid");
  var getBlockAttributes = getBlockEditorSelector("getBlockAttributes");
  var getBlock = getBlockEditorSelector("getBlock");
  var getBlocks = getBlockEditorSelector("getBlocks");
  var getClientIdsOfDescendants = getBlockEditorSelector(
    "getClientIdsOfDescendants"
  );
  var getClientIdsWithDescendants = getBlockEditorSelector(
    "getClientIdsWithDescendants"
  );
  var getGlobalBlockCount = getBlockEditorSelector(
    "getGlobalBlockCount"
  );
  var getBlocksByClientId = getBlockEditorSelector(
    "getBlocksByClientId"
  );
  var getBlockCount = getBlockEditorSelector("getBlockCount");
  var getBlockSelectionStart = getBlockEditorSelector(
    "getBlockSelectionStart"
  );
  var getBlockSelectionEnd = getBlockEditorSelector(
    "getBlockSelectionEnd"
  );
  var getSelectedBlockCount = getBlockEditorSelector(
    "getSelectedBlockCount"
  );
  var hasSelectedBlock = getBlockEditorSelector("hasSelectedBlock");
  var getSelectedBlockClientId = getBlockEditorSelector(
    "getSelectedBlockClientId"
  );
  var getSelectedBlock = getBlockEditorSelector("getSelectedBlock");
  var getBlockRootClientId = getBlockEditorSelector(
    "getBlockRootClientId"
  );
  var getBlockHierarchyRootClientId = getBlockEditorSelector(
    "getBlockHierarchyRootClientId"
  );
  var getAdjacentBlockClientId = getBlockEditorSelector(
    "getAdjacentBlockClientId"
  );
  var getPreviousBlockClientId = getBlockEditorSelector(
    "getPreviousBlockClientId"
  );
  var getNextBlockClientId = getBlockEditorSelector(
    "getNextBlockClientId"
  );
  var getSelectedBlocksInitialCaretPosition = getBlockEditorSelector(
    "getSelectedBlocksInitialCaretPosition"
  );
  var getMultiSelectedBlockClientIds = getBlockEditorSelector(
    "getMultiSelectedBlockClientIds"
  );
  var getMultiSelectedBlocks = getBlockEditorSelector(
    "getMultiSelectedBlocks"
  );
  var getFirstMultiSelectedBlockClientId = getBlockEditorSelector(
    "getFirstMultiSelectedBlockClientId"
  );
  var getLastMultiSelectedBlockClientId = getBlockEditorSelector(
    "getLastMultiSelectedBlockClientId"
  );
  var isFirstMultiSelectedBlock = getBlockEditorSelector(
    "isFirstMultiSelectedBlock"
  );
  var isBlockMultiSelected = getBlockEditorSelector(
    "isBlockMultiSelected"
  );
  var isAncestorMultiSelected = getBlockEditorSelector(
    "isAncestorMultiSelected"
  );
  var getMultiSelectedBlocksStartClientId = getBlockEditorSelector(
    "getMultiSelectedBlocksStartClientId"
  );
  var getMultiSelectedBlocksEndClientId = getBlockEditorSelector(
    "getMultiSelectedBlocksEndClientId"
  );
  var getBlockOrder = getBlockEditorSelector("getBlockOrder");
  var getBlockIndex = getBlockEditorSelector("getBlockIndex");
  var isBlockSelected = getBlockEditorSelector("isBlockSelected");
  var hasSelectedInnerBlock = getBlockEditorSelector(
    "hasSelectedInnerBlock"
  );
  var isBlockWithinSelection = getBlockEditorSelector(
    "isBlockWithinSelection"
  );
  var hasMultiSelection = getBlockEditorSelector("hasMultiSelection");
  var isMultiSelecting = getBlockEditorSelector("isMultiSelecting");
  var isSelectionEnabled = getBlockEditorSelector("isSelectionEnabled");
  var getBlockMode = getBlockEditorSelector("getBlockMode");
  var isTyping = getBlockEditorSelector("isTyping");
  var isCaretWithinFormattedText = getBlockEditorSelector(
    "isCaretWithinFormattedText"
  );
  var getBlockInsertionPoint = getBlockEditorSelector(
    "getBlockInsertionPoint"
  );
  var isBlockInsertionPointVisible = getBlockEditorSelector(
    "isBlockInsertionPointVisible"
  );
  var isValidTemplate = getBlockEditorSelector("isValidTemplate");
  var getTemplate = getBlockEditorSelector("getTemplate");
  var getTemplateLock = getBlockEditorSelector("getTemplateLock");
  var canInsertBlockType = getBlockEditorSelector("canInsertBlockType");
  var getInserterItems = getBlockEditorSelector("getInserterItems");
  var hasInserterItems = getBlockEditorSelector("hasInserterItems");
  var getBlockListSettings = getBlockEditorSelector(
    "getBlockListSettings"
  );
  var __experimentalGetDefaultTemplateTypes = (0, import_data3.createRegistrySelector)(
    (select7) => () => {
      (0, import_deprecated.default)(
        "select('core/editor').__experimentalGetDefaultTemplateTypes",
        {
          since: "6.8",
          alternative: "select('core/core-data').getCurrentTheme()?.default_template_types"
        }
      );
      return select7(import_core_data.store).getCurrentTheme()?.default_template_types;
    }
  );
  var __experimentalGetDefaultTemplatePartAreas = (0, import_data3.createRegistrySelector)(
    (select7) => (0, import_data3.createSelector)(() => {
      (0, import_deprecated.default)(
        "select('core/editor').__experimentalGetDefaultTemplatePartAreas",
        {
          since: "6.8",
          alternative: "select('core/core-data').getCurrentTheme()?.default_template_part_areas"
        }
      );
      const areas = select7(import_core_data.store).getCurrentTheme()?.default_template_part_areas || [];
      return areas.map((item) => {
        return { ...item, icon: getTemplatePartIcon(item.icon) };
      });
    })
  );
  var __experimentalGetDefaultTemplateType = (0, import_data3.createRegistrySelector)(
    (select7) => (0, import_data3.createSelector)((state, slug) => {
      (0, import_deprecated.default)(
        "select('core/editor').__experimentalGetDefaultTemplateType",
        {
          since: "6.8"
        }
      );
      const templateTypes = select7(import_core_data.store).getCurrentTheme()?.default_template_types;
      if (!templateTypes) {
        return EMPTY_OBJECT2;
      }
      return Object.values(templateTypes).find(
        (type) => type.slug === slug
      ) ?? EMPTY_OBJECT2;
    })
  );
  var __experimentalGetTemplateInfo = (0, import_data3.createRegistrySelector)(
    (select7) => (0, import_data3.createSelector)((state, template2) => {
      (0, import_deprecated.default)("select('core/editor').__experimentalGetTemplateInfo", {
        since: "6.8"
      });
      if (!template2) {
        return EMPTY_OBJECT2;
      }
      const currentTheme = select7(import_core_data.store).getCurrentTheme();
      const templateTypes = currentTheme?.default_template_types || [];
      const templateAreas = currentTheme?.default_template_part_areas || [];
      return getTemplateInfo({
        template: template2,
        templateAreas,
        templateTypes
      });
    })
  );
  var getPostTypeLabel = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      const currentPostType = getCurrentPostType(state);
      const postType2 = select7(import_core_data.store).getPostType(currentPostType);
      return postType2?.labels?.singular_name;
    }
  );
  function isPublishSidebarOpened(state) {
    return state.publishSidebarActive;
  }
  var isCollaborationEnabledForCurrentPost = (0, import_data3.createRegistrySelector)(
    (select7) => (state) => {
      if (!unlock(select7(import_core_data.store)).isCollaborationSupported()) {
        return false;
      }
      const currentPostType = getCurrentPostType(state);
      const entityConfig = select7(import_core_data.store).getEntityConfig(
        "postType",
        currentPostType
      );
      return Boolean(
        entityConfig?.syncConfig && window._wpCollaborationEnabled
      );
    }
  );

  // packages/editor/build-module/store/actions.mjs
  var actions_exports = {};
  __export(actions_exports, {
    __experimentalTearDownEditor: () => __experimentalTearDownEditor,
    __unstableSaveForPreview: () => __unstableSaveForPreview,
    autosave: () => autosave,
    clearSelectedBlock: () => clearSelectedBlock,
    closePublishSidebar: () => closePublishSidebar,
    createUndoLevel: () => createUndoLevel,
    disablePublishSidebar: () => disablePublishSidebar,
    editPost: () => editPost,
    enablePublishSidebar: () => enablePublishSidebar,
    enterFormattedText: () => enterFormattedText,
    exitFormattedText: () => exitFormattedText,
    hideInsertionPoint: () => hideInsertionPoint,
    insertBlock: () => insertBlock,
    insertBlocks: () => insertBlocks,
    insertDefaultBlock: () => insertDefaultBlock,
    lockPostAutosaving: () => lockPostAutosaving,
    lockPostSaving: () => lockPostSaving,
    mergeBlocks: () => mergeBlocks,
    moveBlockToPosition: () => moveBlockToPosition,
    moveBlocksDown: () => moveBlocksDown,
    moveBlocksUp: () => moveBlocksUp,
    multiSelect: () => multiSelect,
    openPublishSidebar: () => openPublishSidebar,
    receiveBlocks: () => receiveBlocks,
    redo: () => redo,
    refreshPost: () => refreshPost,
    removeBlock: () => removeBlock,
    removeBlocks: () => removeBlocks,
    removeEditorPanel: () => removeEditorPanel,
    replaceBlock: () => replaceBlock,
    replaceBlocks: () => replaceBlocks,
    resetBlocks: () => resetBlocks,
    resetEditorBlocks: () => resetEditorBlocks,
    resetPost: () => resetPost,
    savePost: () => savePost,
    selectBlock: () => selectBlock,
    setDeviceType: () => setDeviceType,
    setEditedPost: () => setEditedPost,
    setIsInserterOpened: () => setIsInserterOpened,
    setIsListViewOpened: () => setIsListViewOpened,
    setRenderingMode: () => setRenderingMode,
    setTemplateValidity: () => setTemplateValidity,
    setupEditor: () => setupEditor,
    setupEditorState: () => setupEditorState,
    showInsertionPoint: () => showInsertionPoint,
    startMultiSelect: () => startMultiSelect,
    startTyping: () => startTyping,
    stopMultiSelect: () => stopMultiSelect,
    stopTyping: () => stopTyping,
    switchEditorMode: () => switchEditorMode,
    synchronizeTemplate: () => synchronizeTemplate,
    toggleBlockMode: () => toggleBlockMode,
    toggleDistractionFree: () => toggleDistractionFree,
    toggleEditorPanelEnabled: () => toggleEditorPanelEnabled,
    toggleEditorPanelOpened: () => toggleEditorPanelOpened,
    togglePublishSidebar: () => togglePublishSidebar,
    toggleSelection: () => toggleSelection,
    toggleSpotlightMode: () => toggleSpotlightMode,
    toggleTopToolbar: () => toggleTopToolbar,
    trashPost: () => trashPost,
    undo: () => undo,
    unlockPostAutosaving: () => unlockPostAutosaving,
    unlockPostSaving: () => unlockPostSaving,
    updateBlock: () => updateBlock,
    updateBlockAttributes: () => updateBlockAttributes,
    updateBlockListSettings: () => updateBlockListSettings,
    updateEditorSettings: () => updateEditorSettings,
    updatePost: () => updatePost,
    updatePostLock: () => updatePostLock
  });
  var import_a11y = __toESM(require_a11y(), 1);
  var import_api_fetch = __toESM(require_api_fetch(), 1);
  var import_deprecated2 = __toESM(require_deprecated(), 1);
  var import_blocks2 = __toESM(require_blocks(), 1);
  var import_notices = __toESM(require_notices(), 1);
  var import_core_data2 = __toESM(require_core_data(), 1);
  var import_block_editor3 = __toESM(require_block_editor(), 1);
  var import_hooks = __toESM(require_hooks(), 1);
  var import_preferences2 = __toESM(require_preferences(), 1);
  var import_i18n2 = __toESM(require_i18n(), 1);

  // packages/editor/build-module/store/local-autosave.mjs
  function postKey(postId2, isPostNew) {
    return `wp-autosave-block-editor-post-${isPostNew ? "auto-draft" : postId2}`;
  }
  function localAutosaveGet(postId2, isPostNew) {
    return window.sessionStorage.getItem(postKey(postId2, isPostNew));
  }
  function localAutosaveSet(postId2, isPostNew, title, content, excerpt) {
    window.sessionStorage.setItem(
      postKey(postId2, isPostNew),
      JSON.stringify({
        post_title: title,
        content,
        excerpt
      })
    );
  }
  function localAutosaveClear(postId2, isPostNew) {
    window.sessionStorage.removeItem(postKey(postId2, isPostNew));
  }

  // packages/editor/build-module/store/utils/notice-builder.mjs
  var import_i18n = __toESM(require_i18n(), 1);
  function getNotificationArgumentsForSaveSuccess(data) {
    const { previousPost, post: post2, postType: postType2 } = data;
    if (data.options?.isAutosave) {
      return [];
    }
    const publishStatus = ["publish", "private", "future"];
    const isPublished = publishStatus.includes(previousPost.status);
    const willPublish = publishStatus.includes(post2.status);
    const willTrash = post2.status === "trash" && previousPost.status !== "trash";
    let noticeMessage;
    let shouldShowLink = postType2?.viewable ?? false;
    let isDraft;
    if (willTrash) {
      noticeMessage = postType2.labels.item_trashed;
      shouldShowLink = false;
    } else if (post2.type === ATTACHMENT_POST_TYPE) {
      noticeMessage = (0, import_i18n.__)("Media updated.");
      shouldShowLink = false;
    } else if (!isPublished && !willPublish) {
      noticeMessage = (0, import_i18n.__)("Draft saved.");
      isDraft = true;
    } else if (isPublished && !willPublish) {
      noticeMessage = postType2.labels.item_reverted_to_draft;
      shouldShowLink = false;
    } else if (!isPublished && willPublish) {
      noticeMessage = {
        publish: postType2.labels.item_published,
        private: postType2.labels.item_published_privately,
        future: postType2.labels.item_scheduled
      }[post2.status];
    } else {
      noticeMessage = postType2.labels.item_updated;
    }
    const actions2 = [];
    if (shouldShowLink) {
      actions2.push({
        label: isDraft ? (0, import_i18n.__)("View Preview") : postType2.labels.view_item,
        url: post2.link,
        openInNewTab: true
      });
    }
    return [
      noticeMessage,
      {
        id: "editor-save",
        type: "snackbar",
        actions: actions2
      }
    ];
  }
  function getNotificationArgumentsForSaveFail(data) {
    const { post: post2, edits, error: error2 } = data;
    if (error2 && "rest_autosave_no_changes" === error2.code) {
      return [];
    }
    const publishStatus = ["publish", "private", "future"];
    const isPublished = publishStatus.indexOf(post2.status) !== -1;
    if (error2.code === "offline_error") {
      const messages2 = {
        publish: (0, import_i18n.__)(
          "Publishing failed because you were offline. Please verify your connection and try again."
        ),
        private: (0, import_i18n.__)(
          "Publishing failed because you were offline. Please verify your connection and try again."
        ),
        future: (0, import_i18n.__)(
          "Scheduling failed because you were offline. Please verify your connection and try again."
        ),
        default: (0, import_i18n.__)(
          "Updating failed because you were offline. Please verify your connection and try again."
        )
      };
      const noticeMessage2 = !isPublished && edits.status in messages2 ? messages2[edits.status] : messages2.default;
      return [noticeMessage2, { id: "editor-save" }];
    }
    const messages = {
      publish: (0, import_i18n.__)("Publishing failed."),
      private: (0, import_i18n.__)("Publishing failed."),
      future: (0, import_i18n.__)("Scheduling failed."),
      default: (0, import_i18n.__)("Updating failed.")
    };
    let noticeMessage = !isPublished && edits.status in messages ? messages[edits.status] : messages.default;
    if (error2.message && !/<\/?[^>]*>/.test(error2.message)) {
      noticeMessage = [noticeMessage, error2.message].join(" ");
    }
    return [
      noticeMessage,
      {
        id: "editor-save"
      }
    ];
  }
  function getNotificationArgumentsForTrashFail(data) {
    return [
      data.error.message && data.error.code !== "unknown_error" ? data.error.message : (0, import_i18n.__)("Trashing failed"),
      {
        id: "editor-trash-fail"
      }
    ];
  }

  // packages/editor/build-module/store/actions.mjs
  var setupEditor = (post2, edits, template2) => ({ dispatch: dispatch7 }) => {
    dispatch7.setEditedPost(post2.type, post2.id);
    const isNewPost = post2.status === "auto-draft";
    if (isNewPost && template2) {
      let content;
      if ("content" in edits) {
        content = edits.content;
      } else {
        content = post2.content.raw;
      }
      let blocks = (0, import_blocks2.parse)(content);
      blocks = (0, import_blocks2.synchronizeBlocksWithTemplate)(blocks, template2);
      dispatch7.resetEditorBlocks(blocks, {
        __unstableShouldCreateUndoLevel: false
      });
    }
    if (edits && Object.entries(edits).some(
      ([key, edit]) => edit !== (post2[key]?.raw ?? post2[key])
    )) {
      dispatch7.editPost(edits);
    }
  };
  function __experimentalTearDownEditor() {
    (0, import_deprecated2.default)(
      "wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor",
      {
        since: "6.5"
      }
    );
    return { type: "DO_NOTHING" };
  }
  function resetPost() {
    (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).resetPost", {
      since: "6.0",
      version: "6.3",
      alternative: "Initialize the editor with the setupEditorState action"
    });
    return { type: "DO_NOTHING" };
  }
  function updatePost() {
    (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).updatePost", {
      since: "5.7",
      alternative: "Use the core entities store instead"
    });
    return {
      type: "DO_NOTHING"
    };
  }
  function setupEditorState(post2) {
    (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).setupEditorState", {
      since: "6.5",
      alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost"
    });
    return setEditedPost(post2.type, post2.id);
  }
  function setEditedPost(postType2, postId2) {
    return {
      type: "SET_EDITED_POST",
      postType: postType2,
      postId: postId2
    };
  }
  var editPost = (edits, options) => ({ select: select7, registry }) => {
    const { id, type } = select7.getCurrentPost();
    registry.dispatch(import_core_data2.store).editEntityRecord("postType", type, id, edits, options);
  };
  var savePost = (options = {}) => async ({ select: select7, dispatch: dispatch7, registry }) => {
    if (!select7.isEditedPostSaveable()) {
      return;
    }
    const content = select7.getEditedPostContent();
    dispatch7.editPost({ content }, { undoIgnore: true });
    const previousRecord = select7.getCurrentPost();
    let edits = {
      id: previousRecord.id,
      ...registry.select(import_core_data2.store).getEntityRecordNonTransientEdits(
        "postType",
        previousRecord.type,
        previousRecord.id
      ),
      content
    };
    dispatch7({ type: "REQUEST_POST_UPDATE_START", options });
    let error2 = false;
    try {
      edits = await (0, import_hooks.applyFiltersAsync)(
        "editor.preSavePost",
        edits,
        options
      );
    } catch (err) {
      error2 = err;
    }
    if (!error2) {
      try {
        await registry.dispatch(import_core_data2.store).saveEntityRecord(
          "postType",
          previousRecord.type,
          edits,
          options
        );
      } catch (err) {
        error2 = err.message && err.code !== "unknown_error" ? err.message : (0, import_i18n2.__)("An error occurred while updating.");
      }
    }
    if (!error2) {
      error2 = registry.select(import_core_data2.store).getLastEntitySaveError(
        "postType",
        previousRecord.type,
        previousRecord.id
      );
    }
    if (!error2) {
      try {
        await (0, import_hooks.applyFilters)(
          "editor.__unstableSavePost",
          Promise.resolve(),
          options
        );
      } catch (err) {
        error2 = err;
      }
    }
    if (!error2) {
      try {
        await (0, import_hooks.doActionAsync)(
          "editor.savePost",
          { id: previousRecord.id, type: previousRecord.type },
          options
        );
      } catch (err) {
        error2 = err;
      }
    }
    dispatch7({ type: "REQUEST_POST_UPDATE_FINISH", options });
    if (typeof window !== "undefined" && window.__experimentalTemplateActivate && !options.isAutosave && previousRecord.type === "wp_template" && (typeof previousRecord.id === "number" || /^\d+$/.test(previousRecord.id))) {
      templateActivationNotice({ select: select7, dispatch: dispatch7, registry });
    }
    if (error2) {
      const args = getNotificationArgumentsForSaveFail({
        post: previousRecord,
        edits,
        error: error2
      });
      if (args.length) {
        registry.dispatch(import_notices.store).createErrorNotice(...args);
      }
    } else {
      const updatedRecord = select7.getCurrentPost();
      const args = getNotificationArgumentsForSaveSuccess({
        previousPost: previousRecord,
        post: updatedRecord,
        postType: await registry.resolveSelect(import_core_data2.store).getPostType(updatedRecord.type),
        options
      });
      if (args.length) {
        registry.dispatch(import_notices.store).createSuccessNotice(...args);
      }
      if (!options.isAutosave) {
        registry.dispatch(import_block_editor3.store).__unstableMarkLastChangeAsPersistent();
      }
    }
  };
  async function templateActivationNotice({ select: select7, registry }) {
    const editorSettings2 = select7.getEditorSettings();
    if (editorSettings2.onNavigateToPreviousEntityRecord) {
      return;
    }
    const { id, slug } = select7.getCurrentPost();
    const site = await registry.select(import_core_data2.store).getEntityRecord("root", "site");
    if (site.active_templates[slug] === id) {
      return;
    }
    const currentTheme = await registry.resolveSelect(import_core_data2.store).getCurrentTheme();
    const templateType = currentTheme?.default_template_types.find(
      (type) => type.slug === slug
    );
    await registry.dispatch(import_notices.store).createNotice(
      "info",
      (0, import_i18n2.sprintf)(
        // translators: %s: The name (or slug) of the type of template.
        (0, import_i18n2.__)('Do you want to activate this "%s" template?'),
        templateType?.title ?? slug
      ),
      {
        id: "template-activate-notice",
        actions: [
          {
            label: (0, import_i18n2.__)("Activate"),
            onClick: async () => {
              await registry.dispatch(import_notices.store).createNotice(
                "info",
                (0, import_i18n2.__)("Activating template\u2026"),
                { id: "template-activate-notice" }
              );
              try {
                const currentSite = await registry.select(import_core_data2.store).getEntityRecord("root", "site");
                await registry.dispatch(import_core_data2.store).saveEntityRecord(
                  "root",
                  "site",
                  {
                    active_templates: {
                      ...currentSite.active_templates,
                      [slug]: id
                    }
                  },
                  { throwOnError: true }
                );
                await registry.dispatch(import_notices.store).createSuccessNotice(
                  (0, import_i18n2.__)("Template activated."),
                  { id: "template-activate-notice" }
                );
              } catch (error2) {
                await registry.dispatch(import_notices.store).createErrorNotice(
                  (0, import_i18n2.__)("Template activation failed."),
                  { id: "template-activate-notice" }
                );
                throw error2;
              }
            }
          }
        ]
      }
    );
  }
  function refreshPost() {
    (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).refreshPost", {
      since: "6.0",
      version: "6.3",
      alternative: "Use the core entities store instead"
    });
    return { type: "DO_NOTHING" };
  }
  var trashPost = () => async ({ select: select7, dispatch: dispatch7, registry }) => {
    const postTypeSlug = select7.getCurrentPostType();
    const postType2 = await registry.resolveSelect(import_core_data2.store).getPostType(postTypeSlug);
    const { rest_base: restBase, rest_namespace: restNamespace = "wp/v2" } = postType2;
    dispatch7({ type: "REQUEST_POST_DELETE_START" });
    try {
      const post2 = select7.getCurrentPost();
      await (0, import_api_fetch.default)({
        path: `/${restNamespace}/${restBase}/${post2.id}`,
        method: "DELETE"
      });
      await dispatch7.savePost();
    } catch (error2) {
      registry.dispatch(import_notices.store).createErrorNotice(
        ...getNotificationArgumentsForTrashFail({ error: error2 })
      );
    }
    dispatch7({ type: "REQUEST_POST_DELETE_FINISH" });
  };
  var autosave = ({ local = false, ...options } = {}) => async ({ select: select7, dispatch: dispatch7 }) => {
    const post2 = select7.getCurrentPost();
    if (local) {
      const isPostNew = select7.isEditedPostNew();
      const title = select7.getEditedPostAttribute("title");
      const content = select7.getEditedPostAttribute("content");
      const excerpt = select7.getEditedPostAttribute("excerpt");
      localAutosaveSet(post2.id, isPostNew, title, content, excerpt);
    } else {
      await dispatch7.savePost({ isAutosave: true, ...options });
    }
  };
  var __unstableSaveForPreview = ({ forceIsAutosaveable } = {}) => async ({ select: select7, dispatch: dispatch7 }) => {
    if ((forceIsAutosaveable || select7.isEditedPostAutosaveable()) && !select7.isPostLocked()) {
      const isDraft = ["draft", "auto-draft"].includes(
        select7.getEditedPostAttribute("status")
      );
      if (isDraft) {
        await dispatch7.savePost({ isPreview: true });
      } else {
        await dispatch7.autosave({ isPreview: true });
      }
    }
    return select7.getEditedPostPreviewLink();
  };
  var redo = () => ({ registry }) => {
    registry.dispatch(import_core_data2.store).redo();
  };
  var undo = () => ({ registry }) => {
    registry.dispatch(import_core_data2.store).undo();
  };
  function createUndoLevel() {
    (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).createUndoLevel", {
      since: "6.0",
      version: "6.3",
      alternative: "Use the core entities store instead"
    });
    return { type: "DO_NOTHING" };
  }
  function updatePostLock(lock7) {
    return {
      type: "UPDATE_POST_LOCK",
      lock: lock7
    };
  }
  var enablePublishSidebar = () => ({ registry }) => {
    registry.dispatch(import_preferences2.store).set("core", "isPublishSidebarEnabled", true);
  };
  var disablePublishSidebar = () => ({ registry }) => {
    registry.dispatch(import_preferences2.store).set("core", "isPublishSidebarEnabled", false);
  };
  function lockPostSaving(lockName) {
    return {
      type: "LOCK_POST_SAVING",
      lockName
    };
  }
  function unlockPostSaving(lockName) {
    return {
      type: "UNLOCK_POST_SAVING",
      lockName
    };
  }
  function lockPostAutosaving(lockName) {
    return {
      type: "LOCK_POST_AUTOSAVING",
      lockName
    };
  }
  function unlockPostAutosaving(lockName) {
    return {
      type: "UNLOCK_POST_AUTOSAVING",
      lockName
    };
  }
  var resetEditorBlocks = (blocks, options = {}) => ({ select: select7, dispatch: dispatch7, registry }) => {
    const { __unstableShouldCreateUndoLevel, selection } = options;
    const edits = { blocks, selection };
    if (__unstableShouldCreateUndoLevel !== false) {
      const { id, type } = select7.getCurrentPost();
      const noChange = registry.select(import_core_data2.store).getEditedEntityRecord("postType", type, id).blocks === edits.blocks;
      if (noChange) {
        registry.dispatch(import_core_data2.store).__unstableCreateUndoLevel("postType", type, id);
        return;
      }
      edits.content = ({ blocks: blocksForSerialization = [] }) => (0, import_blocks2.__unstableSerializeAndClean)(blocksForSerialization);
    }
    dispatch7.editPost(edits);
  };
  function updateEditorSettings(settings) {
    return {
      type: "UPDATE_EDITOR_SETTINGS",
      settings
    };
  }
  var setRenderingMode = (mode) => ({ dispatch: dispatch7, registry, select: select7 }) => {
    if (select7.__unstableIsEditorReady() && !select7.getEditorSettings().isPreviewMode) {
      registry.dispatch(import_block_editor3.store).clearSelectedBlock();
    }
    dispatch7({
      type: "SET_RENDERING_MODE",
      mode
    });
  };
  function setDeviceType(deviceType2) {
    return {
      type: "SET_DEVICE_TYPE",
      deviceType: deviceType2
    };
  }
  var toggleEditorPanelEnabled = (panelName) => ({ registry }) => {
    const inactivePanels = registry.select(import_preferences2.store).get("core", "inactivePanels") ?? [];
    const isPanelInactive = !!inactivePanels?.includes(panelName);
    let updatedInactivePanels;
    if (isPanelInactive) {
      updatedInactivePanels = inactivePanels.filter(
        (invactivePanelName) => invactivePanelName !== panelName
      );
    } else {
      updatedInactivePanels = [...inactivePanels, panelName];
    }
    registry.dispatch(import_preferences2.store).set("core", "inactivePanels", updatedInactivePanels);
  };
  var toggleEditorPanelOpened = (panelName) => ({ registry }) => {
    const openPanels = registry.select(import_preferences2.store).get("core", "openPanels") ?? [];
    const isPanelOpen = !!openPanels?.includes(panelName);
    let updatedOpenPanels;
    if (isPanelOpen) {
      updatedOpenPanels = openPanels.filter(
        (openPanelName) => openPanelName !== panelName
      );
    } else {
      updatedOpenPanels = [...openPanels, panelName];
    }
    registry.dispatch(import_preferences2.store).set("core", "openPanels", updatedOpenPanels);
  };
  function removeEditorPanel(panelName) {
    return {
      type: "REMOVE_PANEL",
      panelName
    };
  }
  var setIsInserterOpened = (value) => ({ dispatch: dispatch7, registry }) => {
    if (typeof value === "object" && value.hasOwnProperty("rootClientId") && value.hasOwnProperty("insertionIndex")) {
      unlock(registry.dispatch(import_block_editor3.store)).setInsertionPoint({
        rootClientId: value.rootClientId,
        index: value.insertionIndex
      });
    }
    dispatch7({
      type: "SET_IS_INSERTER_OPENED",
      value
    });
  };
  function setIsListViewOpened(isOpen2) {
    return {
      type: "SET_IS_LIST_VIEW_OPENED",
      isOpen: isOpen2
    };
  }
  var toggleDistractionFree = ({ createNotice = true } = {}) => ({ dispatch: dispatch7, registry }) => {
    const isDistractionFree = registry.select(import_preferences2.store).get("core", "distractionFree");
    if (isDistractionFree) {
      registry.dispatch(import_preferences2.store).set("core", "fixedToolbar", false);
    }
    if (!isDistractionFree) {
      registry.batch(() => {
        registry.dispatch(import_preferences2.store).set("core", "fixedToolbar", true);
        dispatch7.setIsInserterOpened(false);
        dispatch7.setIsListViewOpened(false);
        unlock(
          registry.dispatch(import_block_editor3.store)
        ).resetZoomLevel();
      });
    }
    registry.batch(() => {
      registry.dispatch(import_preferences2.store).set("core", "distractionFree", !isDistractionFree);
      if (createNotice) {
        registry.dispatch(import_notices.store).createInfoNotice(
          isDistractionFree ? (0, import_i18n2.__)("Distraction free mode deactivated.") : (0, import_i18n2.__)("Distraction free mode activated."),
          {
            id: "core/editor/distraction-free-mode/notice",
            type: "snackbar",
            actions: [
              {
                label: (0, import_i18n2.__)("Undo"),
                onClick: () => {
                  registry.batch(() => {
                    registry.dispatch(import_preferences2.store).set(
                      "core",
                      "fixedToolbar",
                      isDistractionFree
                    );
                    registry.dispatch(import_preferences2.store).toggle(
                      "core",
                      "distractionFree"
                    );
                  });
                }
              }
            ]
          }
        );
      }
    });
  };
  var toggleSpotlightMode = () => ({ registry }) => {
    registry.dispatch(import_preferences2.store).toggle("core", "focusMode");
    const isFocusMode = registry.select(import_preferences2.store).get("core", "focusMode");
    registry.dispatch(import_notices.store).createInfoNotice(
      isFocusMode ? (0, import_i18n2.__)("Spotlight mode activated.") : (0, import_i18n2.__)("Spotlight mode deactivated."),
      {
        id: "core/editor/toggle-spotlight-mode/notice",
        type: "snackbar",
        actions: [
          {
            label: (0, import_i18n2.__)("Undo"),
            onClick: () => {
              registry.dispatch(import_preferences2.store).toggle("core", "focusMode");
            }
          }
        ]
      }
    );
  };
  var toggleTopToolbar = () => ({ registry }) => {
    registry.dispatch(import_preferences2.store).toggle("core", "fixedToolbar");
    const isTopToolbar = registry.select(import_preferences2.store).get("core", "fixedToolbar");
    registry.dispatch(import_notices.store).createInfoNotice(
      isTopToolbar ? (0, import_i18n2.__)("Top toolbar activated.") : (0, import_i18n2.__)("Top toolbar deactivated."),
      {
        id: "core/editor/toggle-top-toolbar/notice",
        type: "snackbar",
        actions: [
          {
            label: (0, import_i18n2.__)("Undo"),
            onClick: () => {
              registry.dispatch(import_preferences2.store).toggle("core", "fixedToolbar");
            }
          }
        ]
      }
    );
  };
  var switchEditorMode = (mode) => ({ dispatch: dispatch7, registry }) => {
    registry.dispatch(import_preferences2.store).set("core", "editorMode", mode);
    if (mode !== "visual") {
      registry.dispatch(import_block_editor3.store).clearSelectedBlock();
      unlock(registry.dispatch(import_block_editor3.store)).resetZoomLevel();
    }
    if (mode === "visual") {
      (0, import_a11y.speak)((0, import_i18n2.__)("Visual editor selected"), "assertive");
    } else if (mode === "text") {
      const isDistractionFree = registry.select(import_preferences2.store).get("core", "distractionFree");
      if (isDistractionFree) {
        dispatch7.toggleDistractionFree();
      }
      (0, import_a11y.speak)((0, import_i18n2.__)("Code editor selected"), "assertive");
    }
  };
  function openPublishSidebar() {
    return {
      type: "OPEN_PUBLISH_SIDEBAR"
    };
  }
  function closePublishSidebar() {
    return {
      type: "CLOSE_PUBLISH_SIDEBAR"
    };
  }
  function togglePublishSidebar() {
    return {
      type: "TOGGLE_PUBLISH_SIDEBAR"
    };
  }
  var getBlockEditorAction = (name2) => (...args) => ({ registry }) => {
    (0, import_deprecated2.default)("`wp.data.dispatch( 'core/editor' )." + name2 + "`", {
      since: "5.3",
      alternative: "`wp.data.dispatch( 'core/block-editor' )." + name2 + "`",
      version: "6.2"
    });
    registry.dispatch(import_block_editor3.store)[name2](...args);
  };
  var resetBlocks = getBlockEditorAction("resetBlocks");
  var receiveBlocks = getBlockEditorAction("receiveBlocks");
  var updateBlock = getBlockEditorAction("updateBlock");
  var updateBlockAttributes = getBlockEditorAction(
    "updateBlockAttributes"
  );
  var selectBlock = getBlockEditorAction("selectBlock");
  var startMultiSelect = getBlockEditorAction("startMultiSelect");
  var stopMultiSelect = getBlockEditorAction("stopMultiSelect");
  var multiSelect = getBlockEditorAction("multiSelect");
  var clearSelectedBlock = getBlockEditorAction("clearSelectedBlock");
  var toggleSelection = getBlockEditorAction("toggleSelection");
  var replaceBlocks = getBlockEditorAction("replaceBlocks");
  var replaceBlock = getBlockEditorAction("replaceBlock");
  var moveBlocksDown = getBlockEditorAction("moveBlocksDown");
  var moveBlocksUp = getBlockEditorAction("moveBlocksUp");
  var moveBlockToPosition = getBlockEditorAction(
    "moveBlockToPosition"
  );
  var insertBlock = getBlockEditorAction("insertBlock");
  var insertBlocks = getBlockEditorAction("insertBlocks");
  var showInsertionPoint = getBlockEditorAction("showInsertionPoint");
  var hideInsertionPoint = getBlockEditorAction("hideInsertionPoint");
  var setTemplateValidity = getBlockEditorAction(
    "setTemplateValidity"
  );
  var synchronizeTemplate = getBlockEditorAction(
    "synchronizeTemplate"
  );
  var mergeBlocks = getBlockEditorAction("mergeBlocks");
  var removeBlocks = getBlockEditorAction("removeBlocks");
  var removeBlock = getBlockEditorAction("removeBlock");
  var toggleBlockMode = getBlockEditorAction("toggleBlockMode");
  var startTyping = getBlockEditorAction("startTyping");
  var stopTyping = getBlockEditorAction("stopTyping");
  var enterFormattedText = getBlockEditorAction("enterFormattedText");
  var exitFormattedText = getBlockEditorAction("exitFormattedText");
  var insertDefaultBlock = getBlockEditorAction("insertDefaultBlock");
  var updateBlockListSettings = getBlockEditorAction(
    "updateBlockListSettings"
  );

  // packages/editor/build-module/store/private-actions.mjs
  var private_actions_exports = {};
  __export(private_actions_exports, {
    createTemplate: () => createTemplate,
    hideBlockTypes: () => hideBlockTypes,
    registerEntityAction: () => registerEntityAction,
    registerEntityField: () => registerEntityField,
    registerPostTypeSchema: () => registerPostTypeSchema,
    removeTemplates: () => removeTemplates,
    resetStylesNavigation: () => resetStylesNavigation,
    restoreRevision: () => restoreRevision,
    revertTemplate: () => revertTemplate2,
    saveDirtyEntities: () => saveDirtyEntities,
    selectNote: () => selectNote,
    setCurrentRevisionId: () => setCurrentRevisionId,
    setCurrentTemplateId: () => setCurrentTemplateId,
    setDefaultRenderingMode: () => setDefaultRenderingMode,
    setIsReady: () => setIsReady,
    setShowRevisionDiff: () => setShowRevisionDiff,
    setShowStylebook: () => setShowStylebook,
    setStylesPath: () => setStylesPath,
    showBlockTypes: () => showBlockTypes,
    unregisterEntityAction: () => unregisterEntityAction,
    unregisterEntityField: () => unregisterEntityField
  });
  var import_core_data54 = __toESM(require_core_data(), 1);
  var import_i18n185 = __toESM(require_i18n(), 1);
  var import_notices18 = __toESM(require_notices(), 1);
  var import_block_editor36 = __toESM(require_block_editor(), 1);
  var import_preferences9 = __toESM(require_preferences(), 1);
  var import_url13 = __toESM(require_url(), 1);
  var import_api_fetch6 = __toESM(require_api_fetch(), 1);
  var import_blocks20 = __toESM(require_blocks(), 1);
  var import_html_entities10 = __toESM(require_html_entities(), 1);
  var import_date16 = __toESM(require_date(), 1);

  // packages/editor/build-module/store/utils/is-template-revertable.mjs
  function isTemplateRevertable(templateOrTemplatePart) {
    if (!templateOrTemplatePart) {
      return false;
    }
    return templateOrTemplatePart.source === TEMPLATE_ORIGINS.custom && (Boolean(templateOrTemplatePart?.plugin) || templateOrTemplatePart?.has_theme_file);
  }

  // packages/editor/build-module/dataviews/store/private-actions.mjs
  var import_core_data53 = __toESM(require_core_data(), 1);
  var import_hooks38 = __toESM(require_hooks(), 1);

  // packages/fields/build-module/fields/slug/index.mjs
  var import_i18n5 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/slug/slug-edit.mjs
  var import_components = __toESM(require_components(), 1);
  var import_compose = __toESM(require_compose(), 1);
  var import_data4 = __toESM(require_data(), 1);
  var import_element3 = __toESM(require_element(), 1);
  var import_notices2 = __toESM(require_notices(), 1);
  var import_url3 = __toESM(require_url(), 1);
  var import_i18n4 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/slug/utils.mjs
  var import_url2 = __toESM(require_url(), 1);

  // packages/fields/build-module/actions/utils.mjs
  var import_html_entities = __toESM(require_html_entities(), 1);
  var import_i18n3 = __toESM(require_i18n(), 1);
  function isTemplate(post2) {
    return post2.type === "wp_template";
  }
  function isTemplatePart(post2) {
    return post2.type === "wp_template_part";
  }
  function isTemplateOrTemplatePart(p4) {
    return p4.type === "wp_template" || p4.type === "wp_template_part";
  }
  function getItemTitle(item, fallback = (0, import_i18n3.__)("(no title)")) {
    let title = "";
    if (typeof item.title === "string") {
      title = (0, import_html_entities.decodeEntities)(item.title);
    } else if (item.title && "rendered" in item.title) {
      title = (0, import_html_entities.decodeEntities)(item.title.rendered);
    } else if (item.title && "raw" in item.title) {
      title = (0, import_html_entities.decodeEntities)(item.title.raw);
    }
    return title || fallback;
  }
  function isTemplateRemovable(template2) {
    if (!template2) {
      return false;
    }
    return [template2.source, template2.source].includes("custom") && !Boolean(template2.type === "wp_template" && template2?.plugin) && !template2.has_theme_file;
  }

  // packages/fields/build-module/fields/slug/utils.mjs
  var getSlug = (item) => {
    if (typeof item !== "object") {
      return "";
    }
    return item.slug || (0, import_url2.cleanForSlug)(getItemTitle(item)) || item.id.toString();
  };

  // packages/fields/build-module/fields/slug/slug-edit.mjs
  var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
  var SlugEdit = ({
    field,
    onChange,
    data
  }) => {
    const { id } = field;
    const slug = field.getValue({ item: data }) || getSlug(data);
    const permalinkTemplate = data.permalink_template || "";
    const PERMALINK_POSTNAME_REGEX2 = /%(?:postname|pagename)%/;
    const [prefix2, suffix] = permalinkTemplate.split(
      PERMALINK_POSTNAME_REGEX2
    );
    const permalinkPrefix = prefix2;
    const permalinkSuffix = suffix;
    const isEditable = PERMALINK_POSTNAME_REGEX2.test(permalinkTemplate);
    const originalSlugRef = (0, import_element3.useRef)(slug);
    const slugToDisplay = slug || originalSlugRef.current;
    const permalink = isEditable ? `${permalinkPrefix}${slugToDisplay}${permalinkSuffix}` : (0, import_url3.safeDecodeURIComponent)(data.link || "");
    (0, import_element3.useEffect)(() => {
      if (slug && originalSlugRef.current === void 0) {
        originalSlugRef.current = slug;
      }
    }, [slug]);
    const onChangeControl = (0, import_element3.useCallback)(
      (newValue) => onChange({
        [id]: newValue
      }),
      [id, onChange]
    );
    const { createNotice } = (0, import_data4.useDispatch)(import_notices2.store);
    const copyButtonRef = (0, import_compose.useCopyToClipboard)(permalink, () => {
      createNotice("info", (0, import_i18n4.__)("Copied Permalink to clipboard."), {
        isDismissible: true,
        type: "snackbar"
      });
    });
    const postUrlSlugDescriptionId = "editor-post-url__slug-description-" + (0, import_compose.useInstanceId)(SlugEdit);
    return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("fieldset", { className: "fields-controls__slug", children: [
      isEditable && /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_components.__experimentalVStack, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_components.__experimentalVStack, { spacing: "0px", children: [
          /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { children: (0, import_i18n4.__)(
            "Customize the last part of the Permalink."
          ) }),
          /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components.ExternalLink, { href: "https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink", children: (0, import_i18n4.__)("Learn more") })
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
          import_components.__experimentalInputControl,
          {
            __next40pxDefaultSize: true,
            prefix: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components.__experimentalInputControlPrefixWrapper, { children: "/" }),
            suffix: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
              import_components.Button,
              {
                size: "small",
                icon: copy_small_default,
                ref: copyButtonRef,
                label: (0, import_i18n4.__)("Copy")
              }
            ) }),
            label: (0, import_i18n4.__)("Link"),
            hideLabelFromVision: true,
            value: slug,
            autoComplete: "off",
            spellCheck: "false",
            type: "text",
            className: "fields-controls__slug-input",
            onChange: (newValue) => {
              onChangeControl(newValue);
            },
            onBlur: () => {
              if (slug === "") {
                onChangeControl(originalSlugRef.current);
              }
            },
            "aria-describedby": postUrlSlugDescriptionId
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "fields-controls__slug-help", children: [
          /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "fields-controls__slug-help-visual-label", children: (0, import_i18n4.__)("Permalink:") }),
          /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
            import_components.ExternalLink,
            {
              className: "fields-controls__slug-help-link",
              href: permalink,
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "fields-controls__slug-help-prefix", children: permalinkPrefix }),
                /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "fields-controls__slug-help-slug", children: slugToDisplay }),
                /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "fields-controls__slug-help-suffix", children: permalinkSuffix })
              ]
            }
          )
        ] })
      ] }),
      !isEditable && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
        import_components.ExternalLink,
        {
          className: "fields-controls__slug-help",
          href: permalink,
          children: permalink
        }
      )
    ] });
  };
  var slug_edit_default = SlugEdit;

  // packages/fields/build-module/fields/slug/slug-view.mjs
  var import_element4 = __toESM(require_element(), 1);
  var SlugView = ({ item }) => {
    const slug = getSlug(item);
    const originalSlugRef = (0, import_element4.useRef)(slug);
    (0, import_element4.useEffect)(() => {
      if (slug && originalSlugRef.current === void 0) {
        originalSlugRef.current = slug;
      }
    }, [slug]);
    const slugToDisplay = slug || originalSlugRef.current;
    return `${slugToDisplay}`;
  };
  var slug_view_default = SlugView;

  // packages/fields/build-module/fields/slug/index.mjs
  var slugField = {
    id: "slug",
    type: "text",
    label: (0, import_i18n5.__)("Slug"),
    Edit: slug_edit_default,
    render: slug_view_default,
    filterBy: false
  };
  var slug_default = slugField;

  // packages/fields/build-module/fields/title/index.mjs
  var import_i18n7 = __toESM(require_i18n(), 1);

  // node_modules/clsx/dist/clsx.mjs
  function r(e3) {
    var t4, f3, n3 = "";
    if ("string" == typeof e3 || "number" == typeof e3) n3 += e3;
    else if ("object" == typeof e3) if (Array.isArray(e3)) {
      var o4 = e3.length;
      for (t4 = 0; t4 < o4; t4++) e3[t4] && (f3 = r(e3[t4])) && (n3 && (n3 += " "), n3 += f3);
    } else for (f3 in e3) e3[f3] && (n3 && (n3 += " "), n3 += f3);
    return n3;
  }
  function clsx() {
    for (var e3, t4, f3 = 0, n3 = "", o4 = arguments.length; f3 < o4; f3++) (e3 = arguments[f3]) && (t4 = r(e3)) && (n3 && (n3 += " "), n3 += t4);
    return n3;
  }
  var clsx_default = clsx;

  // packages/fields/build-module/fields/title/view.mjs
  var import_components2 = __toESM(require_components(), 1);
  var import_i18n6 = __toESM(require_i18n(), 1);
  var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
  function BaseTitleView({
    item,
    className,
    children
  }) {
    const renderedTitle = getItemTitle(item);
    return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
      import_components2.__experimentalHStack,
      {
        className: clsx_default("fields-field__title", className),
        alignment: "center",
        justify: "flex-start",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { children: renderedTitle || (0, import_i18n6.__)("(no title)") }),
          children
        ]
      }
    );
  }
  function TitleView({ item }) {
    return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(BaseTitleView, { item });
  }

  // packages/fields/build-module/fields/title/index.mjs
  var titleField = {
    type: "text",
    id: "title",
    label: (0, import_i18n7.__)("Title"),
    placeholder: (0, import_i18n7.__)("No title"),
    getValue: ({ item }) => getItemTitle(item),
    render: TitleView,
    enableHiding: true,
    enableGlobalSearch: true,
    filterBy: false
  };
  var title_default = titleField;

  // packages/fields/build-module/fields/page-title/index.mjs
  var import_i18n9 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/page-title/view.mjs
  var import_i18n8 = __toESM(require_i18n(), 1);
  var import_data5 = __toESM(require_data(), 1);
  var import_core_data3 = __toESM(require_core_data(), 1);
  var import_components3 = __toESM(require_components(), 1);

  // packages/fields/build-module/lock-unlock.mjs
  var import_private_apis2 = __toESM(require_private_apis(), 1);
  var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
    "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
    "@wordpress/fields"
  );

  // packages/fields/build-module/fields/page-title/view.mjs
  var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
  var { Badge: WCBadge } = unlock2(import_components3.privateApis);
  function PageTitleView({ item }) {
    const { frontPageId, postsPageId } = (0, import_data5.useSelect)((select7) => {
      const { getEntityRecord } = select7(import_core_data3.store);
      const siteSettings = getEntityRecord(
        "root",
        "site"
      );
      return {
        frontPageId: siteSettings?.page_on_front,
        postsPageId: siteSettings?.page_for_posts
      };
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(BaseTitleView, { item, className: "fields-field__page-title", children: [frontPageId, postsPageId].includes(item.id) && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(WCBadge, { children: item.id === frontPageId ? (0, import_i18n8.__)("Homepage") : (0, import_i18n8.__)("Posts Page") }) });
  }

  // packages/fields/build-module/fields/page-title/index.mjs
  var pageTitleField = {
    type: "text",
    id: "title",
    label: (0, import_i18n9.__)("Title"),
    placeholder: (0, import_i18n9.__)("No title"),
    getValue: ({ item }) => getItemTitle(item),
    render: PageTitleView,
    enableHiding: false,
    enableGlobalSearch: true,
    filterBy: false
  };
  var page_title_default = pageTitleField;

  // packages/fields/build-module/fields/template-title/index.mjs
  var import_i18n10 = __toESM(require_i18n(), 1);
  var templateTitleField = {
    type: "text",
    label: (0, import_i18n10.__)("Template"),
    placeholder: (0, import_i18n10.__)("No title"),
    id: "title",
    getValue: ({ item }) => getItemTitle(item),
    render: TitleView,
    enableHiding: false,
    enableGlobalSearch: true,
    filterBy: false
  };
  var template_title_default = templateTitleField;

  // packages/fields/build-module/fields/pattern-title/index.mjs
  var import_i18n12 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/pattern-title/view.mjs
  var import_i18n11 = __toESM(require_i18n(), 1);
  var import_components4 = __toESM(require_components(), 1);
  var import_patterns = __toESM(require_patterns(), 1);
  var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
  var { PATTERN_TYPES } = unlock2(import_patterns.privateApis);
  function PatternTitleView({ item }) {
    return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(BaseTitleView, { item, className: "fields-field__pattern-title", children: item.type === PATTERN_TYPES.theme && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
      import_components4.Tooltip,
      {
        placement: "top",
        text: (0, import_i18n11.__)("This pattern cannot be edited."),
        children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(icon_default, { icon: lock_small_default, size: 24 })
      }
    ) });
  }

  // packages/fields/build-module/fields/pattern-title/index.mjs
  var patternTitleField = {
    type: "text",
    id: "title",
    label: (0, import_i18n12.__)("Title"),
    placeholder: (0, import_i18n12.__)("No title"),
    getValue: ({ item }) => getItemTitle(item),
    render: PatternTitleView,
    enableHiding: false,
    enableGlobalSearch: true,
    filterBy: false
  };
  var pattern_title_default = patternTitleField;

  // packages/fields/build-module/fields/featured-image/index.mjs
  var import_i18n14 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/components/media-edit/index.mjs
  var import_components5 = __toESM(require_components(), 1);
  var import_blob = __toESM(require_blob(), 1);
  var import_core_data4 = __toESM(require_core_data(), 1);
  var import_data6 = __toESM(require_data(), 1);
  var import_element24 = __toESM(require_element(), 1);
  var import_i18n13 = __toESM(require_i18n(), 1);

  // packages/ui/build-module/badge/badge.mjs
  var import_element6 = __toESM(require_element(), 1);

  // node_modules/@base-ui/utils/esm/useControlled.js
  var React = __toESM(require_react(), 1);

  // node_modules/@base-ui/utils/esm/error.js
  var set;
  if (true) {
    set = /* @__PURE__ */ new Set();
  }
  function error(...messages) {
    if (true) {
      const messageKey = messages.join(" ");
      if (!set.has(messageKey)) {
        set.add(messageKey);
        console.error(`Base UI: ${messageKey}`);
      }
    }
  }

  // node_modules/@base-ui/utils/esm/useControlled.js
  function useControlled({
    controlled,
    default: defaultProp,
    name: name2,
    state = "value"
  }) {
    const {
      current: isControlled
    } = React.useRef(controlled !== void 0);
    const [valueState, setValue] = React.useState(defaultProp);
    const value = isControlled ? controlled : valueState;
    if (true) {
      React.useEffect(() => {
        if (isControlled !== (controlled !== void 0)) {
          error([`A component is changing the ${isControlled ? "" : "un"}controlled ${state} state of ${name2} to be ${isControlled ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled ${name2} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join("\n"));
        }
      }, [state, name2, controlled]);
      const {
        current: defaultValue2
      } = React.useRef(defaultProp);
      React.useEffect(() => {
        if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) {
          error([`A component is changing the default ${state} state of an uncontrolled ${name2} after being initialized. To suppress this warning opt to use a controlled ${name2}.`].join("\n"));
        }
      }, [defaultProp]);
    }
    const setValueIfUncontrolled = React.useCallback((newValue) => {
      if (!isControlled) {
        setValue(newValue);
      }
    }, []);
    return [value, setValueIfUncontrolled];
  }
  function serializeToDevModeString(input) {
    let nextId2 = 0;
    const seen = /* @__PURE__ */ new WeakMap();
    try {
      const result = JSON.stringify(input, function replacer(key, value) {
        if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) {
          return void 0;
        }
        if (typeof value === "bigint") {
          return `__bigint__:${value}`;
        }
        if (value !== null && typeof value === "object") {
          const id = seen.get(value);
          if (id !== void 0) {
            return `__object__:${id}`;
          }
          seen.set(value, nextId2);
          nextId2 += 1;
        }
        return value;
      });
      return result ?? `__top__:${typeof input}`;
    } catch {
      return "__unserializable__";
    }
  }

  // node_modules/@base-ui/utils/esm/useStableCallback.js
  var React3 = __toESM(require_react(), 1);

  // node_modules/@base-ui/utils/esm/useRefWithInit.js
  var React2 = __toESM(require_react(), 1);
  var UNINITIALIZED = {};
  function useRefWithInit(init2, initArg) {
    const ref = React2.useRef(UNINITIALIZED);
    if (ref.current === UNINITIALIZED) {
      ref.current = init2(initArg);
    }
    return ref;
  }

  // node_modules/@base-ui/utils/esm/useStableCallback.js
  var useInsertionEffect = React3[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
  var useSafeInsertionEffect = (
    // React 17 doesn't have useInsertionEffect.
    useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
    useInsertionEffect !== React3.useLayoutEffect ? useInsertionEffect : (fn) => fn()
  );
  function useStableCallback(callback) {
    const stable = useRefWithInit(createStableCallback).current;
    stable.next = callback;
    useSafeInsertionEffect(stable.effect);
    return stable.trampoline;
  }
  function createStableCallback() {
    const stable = {
      next: void 0,
      callback: assertNotCalled,
      trampoline: (...args) => stable.callback?.(...args),
      effect: () => {
        stable.callback = stable.next;
      }
    };
    return stable;
  }
  function assertNotCalled() {
    if (true) {
      throw (
        /* minify-error-disabled */
        new Error("Base UI: Cannot call an event handler while rendering.")
      );
    }
  }

  // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
  var React4 = __toESM(require_react(), 1);
  var noop = () => {
  };
  var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;

  // node_modules/@base-ui/utils/esm/warn.js
  var set2;
  if (true) {
    set2 = /* @__PURE__ */ new Set();
  }
  function warn(...messages) {
    if (true) {
      const messageKey = messages.join(" ");
      if (!set2.has(messageKey)) {
        set2.add(messageKey);
        console.warn(`Base UI: ${messageKey}`);
      }
    }
  }

  // node_modules/@base-ui/react/esm/internals/useRenderElement.js
  var React7 = __toESM(require_react(), 1);

  // node_modules/@base-ui/utils/esm/useMergedRefs.js
  function useMergedRefs(a3, b3, c6, d3) {
    const forkRef = useRefWithInit(createForkRef).current;
    if (didChange(forkRef, a3, b3, c6, d3)) {
      update(forkRef, [a3, b3, c6, d3]);
    }
    return forkRef.callback;
  }
  function useMergedRefsN(refs) {
    const forkRef = useRefWithInit(createForkRef).current;
    if (didChangeN(forkRef, refs)) {
      update(forkRef, refs);
    }
    return forkRef.callback;
  }
  function createForkRef() {
    return {
      callback: null,
      cleanup: null,
      refs: []
    };
  }
  function didChange(forkRef, a3, b3, c6, d3) {
    return forkRef.refs[0] !== a3 || forkRef.refs[1] !== b3 || forkRef.refs[2] !== c6 || forkRef.refs[3] !== d3;
  }
  function didChangeN(forkRef, newRefs) {
    return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
  }
  function update(forkRef, refs) {
    forkRef.refs = refs;
    if (refs.every((ref) => ref == null)) {
      forkRef.callback = null;
      return;
    }
    forkRef.callback = (instance) => {
      if (forkRef.cleanup) {
        forkRef.cleanup();
        forkRef.cleanup = null;
      }
      if (instance != null) {
        const cleanupCallbacks = Array(refs.length).fill(null);
        for (let i3 = 0; i3 < refs.length; i3 += 1) {
          const ref = refs[i3];
          if (ref == null) {
            continue;
          }
          switch (typeof ref) {
            case "function": {
              const refCleanup = ref(instance);
              if (typeof refCleanup === "function") {
                cleanupCallbacks[i3] = refCleanup;
              }
              break;
            }
            case "object": {
              ref.current = instance;
              break;
            }
            default:
          }
        }
        forkRef.cleanup = () => {
          for (let i3 = 0; i3 < refs.length; i3 += 1) {
            const ref = refs[i3];
            if (ref == null) {
              continue;
            }
            switch (typeof ref) {
              case "function": {
                const cleanupCallback = cleanupCallbacks[i3];
                if (typeof cleanupCallback === "function") {
                  cleanupCallback();
                } else {
                  ref(null);
                }
                break;
              }
              case "object": {
                ref.current = null;
                break;
              }
              default:
            }
          }
        };
      }
    };
  }

  // node_modules/@base-ui/utils/esm/getReactElementRef.js
  var React6 = __toESM(require_react(), 1);

  // node_modules/@base-ui/utils/esm/reactVersion.js
  var React5 = __toESM(require_react(), 1);
  var majorVersion = parseInt(React5.version, 10);
  function isReactVersionAtLeast(reactVersionToCheck) {
    return majorVersion >= reactVersionToCheck;
  }

  // node_modules/@base-ui/utils/esm/getReactElementRef.js
  function getReactElementRef(element) {
    if (!/* @__PURE__ */ React6.isValidElement(element)) {
      return null;
    }
    const reactElement = element;
    const propsWithRef = reactElement.props;
    return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
  }

  // node_modules/@base-ui/utils/esm/mergeObjects.js
  function mergeObjects(a3, b3) {
    if (a3 && !b3) {
      return a3;
    }
    if (!a3 && b3) {
      return b3;
    }
    if (a3 || b3) {
      return {
        ...a3,
        ...b3
      };
    }
    return void 0;
  }

  // node_modules/@base-ui/utils/esm/empty.js
  var EMPTY_ARRAY = Object.freeze([]);
  var EMPTY_OBJECT3 = Object.freeze({});

  // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
  function getStateAttributesProps(state, customMapping) {
    const props = {};
    for (const key in state) {
      const value = state[key];
      if (customMapping?.hasOwnProperty(key)) {
        const customProps = customMapping[key](value);
        if (customProps != null) {
          Object.assign(props, customProps);
        }
        continue;
      }
      if (value === true) {
        props[`data-${key.toLowerCase()}`] = "";
      } else if (value) {
        props[`data-${key.toLowerCase()}`] = value.toString();
      }
    }
    return props;
  }

  // node_modules/@base-ui/react/esm/utils/resolveClassName.js
  function resolveClassName(className, state) {
    return typeof className === "function" ? className(state) : className;
  }

  // node_modules/@base-ui/react/esm/utils/resolveStyle.js
  function resolveStyle(style, state) {
    return typeof style === "function" ? style(state) : style;
  }

  // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
  var EMPTY_PROPS = {};
  function mergeProps(a3, b3, c6, d3, e3) {
    if (!c6 && !d3 && !e3 && !a3) {
      return createInitialMergedProps(b3);
    }
    let merged = createInitialMergedProps(a3);
    if (b3) {
      merged = mergeInto(merged, b3);
    }
    if (c6) {
      merged = mergeInto(merged, c6);
    }
    if (d3) {
      merged = mergeInto(merged, d3);
    }
    if (e3) {
      merged = mergeInto(merged, e3);
    }
    return merged;
  }
  function mergePropsN(props) {
    if (props.length === 0) {
      return EMPTY_PROPS;
    }
    if (props.length === 1) {
      return createInitialMergedProps(props[0]);
    }
    let merged = createInitialMergedProps(props[0]);
    for (let i3 = 1; i3 < props.length; i3 += 1) {
      merged = mergeInto(merged, props[i3]);
    }
    return merged;
  }
  function createInitialMergedProps(inputProps) {
    if (isPropsGetter(inputProps)) {
      return {
        ...resolvePropsGetter(inputProps, EMPTY_PROPS)
      };
    }
    return copyInitialProps(inputProps);
  }
  function mergeInto(merged, inputProps) {
    if (isPropsGetter(inputProps)) {
      return resolvePropsGetter(inputProps, merged);
    }
    return mutablyMergeInto(merged, inputProps);
  }
  function copyInitialProps(inputProps) {
    const copiedProps = {
      ...inputProps
    };
    for (const propName in copiedProps) {
      const propValue = copiedProps[propName];
      if (isEventHandler(propName, propValue)) {
        copiedProps[propName] = wrapEventHandler(propValue);
      }
    }
    return copiedProps;
  }
  function mutablyMergeInto(mergedProps, externalProps) {
    if (!externalProps) {
      return mergedProps;
    }
    for (const propName in externalProps) {
      const externalPropValue = externalProps[propName];
      switch (propName) {
        case "style": {
          mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
          break;
        }
        case "className": {
          mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
          break;
        }
        default: {
          if (isEventHandler(propName, externalPropValue)) {
            mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
          } else {
            mergedProps[propName] = externalPropValue;
          }
        }
      }
    }
    return mergedProps;
  }
  function isEventHandler(key, value) {
    const code0 = key.charCodeAt(0);
    const code1 = key.charCodeAt(1);
    const code2 = key.charCodeAt(2);
    return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
  }
  function isPropsGetter(inputProps) {
    return typeof inputProps === "function";
  }
  function resolvePropsGetter(inputProps, previousProps) {
    if (isPropsGetter(inputProps)) {
      return inputProps(previousProps);
    }
    return inputProps ?? EMPTY_PROPS;
  }
  function mergeEventHandlers(ourHandler, theirHandler) {
    if (!theirHandler) {
      return ourHandler;
    }
    if (!ourHandler) {
      return wrapEventHandler(theirHandler);
    }
    return (...args) => {
      const event = args[0];
      if (isSyntheticEvent(event)) {
        const baseUIEvent = event;
        makeEventPreventable(baseUIEvent);
        const result2 = theirHandler(...args);
        if (!baseUIEvent.baseUIHandlerPrevented) {
          ourHandler?.(...args);
        }
        return result2;
      }
      const result = theirHandler(...args);
      ourHandler?.(...args);
      return result;
    };
  }
  function wrapEventHandler(handler) {
    if (!handler) {
      return handler;
    }
    return (...args) => {
      const event = args[0];
      if (isSyntheticEvent(event)) {
        makeEventPreventable(event);
      }
      return handler(...args);
    };
  }
  function makeEventPreventable(event) {
    event.preventBaseUIHandler = () => {
      event.baseUIHandlerPrevented = true;
    };
    return event;
  }
  function mergeClassNames(ourClassName, theirClassName) {
    if (theirClassName) {
      if (ourClassName) {
        return theirClassName + " " + ourClassName;
      }
      return theirClassName;
    }
    return ourClassName;
  }
  function isSyntheticEvent(event) {
    return event != null && typeof event === "object" && "nativeEvent" in event;
  }

  // node_modules/@base-ui/react/esm/internals/useRenderElement.js
  var import_react = __toESM(require_react(), 1);
  function useRenderElement(element, componentProps, params = {}) {
    const renderProp = componentProps.render;
    const outProps = useRenderElementProps(componentProps, params);
    if (params.enabled === false) {
      return null;
    }
    const state = params.state ?? EMPTY_OBJECT3;
    return evaluateRenderProp(element, renderProp, outProps, state);
  }
  function useRenderElementProps(componentProps, params = {}) {
    const {
      className: classNameProp,
      style: styleProp,
      render: renderProp
    } = componentProps;
    const {
      state = EMPTY_OBJECT3,
      ref,
      props,
      stateAttributesMapping: stateAttributesMapping2,
      enabled = true
    } = params;
    const className = enabled ? resolveClassName(classNameProp, state) : void 0;
    const style = enabled ? resolveStyle(styleProp, state) : void 0;
    const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping2) : EMPTY_OBJECT3;
    const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
    const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT3;
    if (typeof document !== "undefined") {
      if (!enabled) {
        useMergedRefs(null, null);
      } else if (Array.isArray(ref)) {
        outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
      } else {
        outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
      }
    }
    if (!enabled) {
      return EMPTY_OBJECT3;
    }
    if (className !== void 0) {
      outProps.className = mergeClassNames(outProps.className, className);
    }
    if (style !== void 0) {
      outProps.style = mergeObjects(outProps.style, style);
    }
    return outProps;
  }
  function resolveRenderFunctionProps(props) {
    if (Array.isArray(props)) {
      return mergePropsN(props);
    }
    return mergeProps(void 0, props);
  }
  var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
  var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
  var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
  function evaluateRenderProp(element, render4, props, state) {
    if (render4) {
      if (typeof render4 === "function") {
        if (true) {
          warnIfRenderPropLooksLikeComponent(render4);
        }
        return render4(props, state);
      }
      const mergedProps = mergeProps(props, render4.props);
      mergedProps.ref = props.ref;
      let newElement = render4;
      if (newElement?.$$typeof === REACT_LAZY_TYPE) {
        const children = React7.Children.toArray(render4);
        newElement = children[0];
      }
      if (true) {
        if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
          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"));
        }
      }
      return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
    }
    if (element) {
      if (typeof element === "string") {
        return renderTag(element, props);
      }
    }
    throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
  }
  function warnIfRenderPropLooksLikeComponent(renderFn) {
    const functionName = renderFn.name;
    if (functionName.length === 0) {
      return;
    }
    if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
      return;
    }
    if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
      return;
    }
    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");
  }
  function renderTag(Tag, props) {
    if (Tag === "button") {
      return /* @__PURE__ */ (0, import_react.createElement)("button", {
        type: "button",
        ...props,
        key: props.key
      });
    }
    if (Tag === "img") {
      return /* @__PURE__ */ (0, import_react.createElement)("img", {
        alt: "",
        ...props,
        key: props.key
      });
    }
    return /* @__PURE__ */ React7.createElement(Tag, props);
  }

  // node_modules/@base-ui/react/esm/internals/reason-parts.js
  var reason_parts_exports = {};
  __export(reason_parts_exports, {
    cancelOpen: () => cancelOpen,
    chipRemovePress: () => chipRemovePress,
    clearPress: () => clearPress,
    closePress: () => closePress,
    closeWatcher: () => closeWatcher,
    decrementPress: () => decrementPress,
    disabled: () => disabled,
    drag: () => drag,
    escapeKey: () => escapeKey,
    focusOut: () => focusOut,
    imperativeAction: () => imperativeAction,
    incrementPress: () => incrementPress,
    inputBlur: () => inputBlur,
    inputChange: () => inputChange,
    inputClear: () => inputClear,
    inputPaste: () => inputPaste,
    inputPress: () => inputPress,
    itemPress: () => itemPress,
    keyboard: () => keyboard,
    linkPress: () => linkPress,
    listNavigation: () => listNavigation,
    none: () => none,
    outsidePress: () => outsidePress,
    pointer: () => pointer,
    scrub: () => scrub,
    siblingOpen: () => siblingOpen,
    swipe: () => swipe,
    trackPress: () => trackPress,
    triggerFocus: () => triggerFocus,
    triggerHover: () => triggerHover,
    triggerPress: () => triggerPress,
    wheel: () => wheel,
    windowResize: () => windowResize
  });
  var none = "none";
  var triggerPress = "trigger-press";
  var triggerHover = "trigger-hover";
  var triggerFocus = "trigger-focus";
  var outsidePress = "outside-press";
  var itemPress = "item-press";
  var closePress = "close-press";
  var linkPress = "link-press";
  var clearPress = "clear-press";
  var chipRemovePress = "chip-remove-press";
  var trackPress = "track-press";
  var incrementPress = "increment-press";
  var decrementPress = "decrement-press";
  var inputChange = "input-change";
  var inputClear = "input-clear";
  var inputBlur = "input-blur";
  var inputPaste = "input-paste";
  var inputPress = "input-press";
  var focusOut = "focus-out";
  var escapeKey = "escape-key";
  var closeWatcher = "close-watcher";
  var listNavigation = "list-navigation";
  var keyboard = "keyboard";
  var pointer = "pointer";
  var drag = "drag";
  var wheel = "wheel";
  var scrub = "scrub";
  var cancelOpen = "cancel-open";
  var siblingOpen = "sibling-open";
  var disabled = "disabled";
  var imperativeAction = "imperative-action";
  var swipe = "swipe";
  var windowResize = "window-resize";

  // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
  function createChangeEventDetails(reason, event, trigger, customProperties) {
    let canceled = false;
    let allowPropagation = false;
    const custom = customProperties ?? EMPTY_OBJECT3;
    const details = {
      reason,
      event: event ?? new Event("base-ui"),
      cancel() {
        canceled = true;
      },
      allowPropagation() {
        allowPropagation = true;
      },
      get isCanceled() {
        return canceled;
      },
      get isPropagationAllowed() {
        return allowPropagation;
      },
      trigger,
      ...custom
    };
    return details;
  }

  // node_modules/@base-ui/utils/esm/useId.js
  var React9 = __toESM(require_react(), 1);

  // node_modules/@base-ui/utils/esm/safeReact.js
  var React8 = __toESM(require_react(), 1);
  var SafeReact = {
    ...React8
  };

  // node_modules/@base-ui/utils/esm/useId.js
  var globalId = 0;
  function useGlobalId(idOverride, prefix2 = "mui") {
    const [defaultId, setDefaultId] = React9.useState(idOverride);
    const id = idOverride || defaultId;
    React9.useEffect(() => {
      if (defaultId == null) {
        globalId += 1;
        setDefaultId(`${prefix2}-${globalId}`);
      }
    }, [defaultId, prefix2]);
    return id;
  }
  var maybeReactUseId = SafeReact.useId;
  function useId(idOverride, prefix2) {
    if (maybeReactUseId !== void 0) {
      const reactId = maybeReactUseId();
      return idOverride ?? (prefix2 ? `${prefix2}-${reactId}` : reactId);
    }
    return useGlobalId(idOverride, prefix2);
  }

  // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
  function useBaseUiId(idOverride) {
    return useId(idOverride, "base-ui");
  }

  // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
  var React12 = __toESM(require_react(), 1);

  // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
  var ReactDOM = __toESM(require_react_dom(), 1);

  // node_modules/@base-ui/utils/esm/useOnMount.js
  var React10 = __toESM(require_react(), 1);
  var EMPTY = [];
  function useOnMount(fn) {
    React10.useEffect(fn, EMPTY);
  }

  // node_modules/@base-ui/utils/esm/useAnimationFrame.js
  var EMPTY2 = null;
  var LAST_RAF = globalThis.requestAnimationFrame;
  var Scheduler = class {
    /* This implementation uses an array as a backing data-structure for frame callbacks.
     * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
     * never calls the native `cancelAnimationFrame` if there are no frames left. This can
     * be much more efficient if there is a call pattern that alterns as
     * "request-cancel-request-cancel-…".
     * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
     * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
    callbacks = [];
    callbacksCount = 0;
    nextId = 1;
    startId = 1;
    isScheduled = false;
    tick = (timestamp) => {
      this.isScheduled = false;
      const currentCallbacks = this.callbacks;
      const currentCallbacksCount = this.callbacksCount;
      this.callbacks = [];
      this.callbacksCount = 0;
      this.startId = this.nextId;
      if (currentCallbacksCount > 0) {
        for (let i3 = 0; i3 < currentCallbacks.length; i3 += 1) {
          currentCallbacks[i3]?.(timestamp);
        }
      }
    };
    request(fn) {
      const id = this.nextId;
      this.nextId += 1;
      this.callbacks.push(fn);
      this.callbacksCount += 1;
      const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
      if (!this.isScheduled || didRAFChange) {
        requestAnimationFrame(this.tick);
        this.isScheduled = true;
      }
      return id;
    }
    cancel(id) {
      const index = id - this.startId;
      if (index < 0 || index >= this.callbacks.length) {
        return;
      }
      this.callbacks[index] = null;
      this.callbacksCount -= 1;
    }
  };
  var scheduler = new Scheduler();
  var AnimationFrame = class _AnimationFrame {
    static create() {
      return new _AnimationFrame();
    }
    static request(fn) {
      return scheduler.request(fn);
    }
    static cancel(id) {
      return scheduler.cancel(id);
    }
    currentId = EMPTY2;
    /**
     * Executes `fn` after `delay`, clearing any previously scheduled call.
     */
    request(fn) {
      this.cancel();
      this.currentId = scheduler.request(() => {
        this.currentId = EMPTY2;
        fn();
      });
    }
    cancel = () => {
      if (this.currentId !== EMPTY2) {
        scheduler.cancel(this.currentId);
        this.currentId = EMPTY2;
      }
    };
    disposeEffect = () => {
      return this.cancel;
    };
  };
  function useAnimationFrame() {
    const timeout = useRefWithInit(AnimationFrame.create).current;
    useOnMount(timeout.disposeEffect);
    return timeout;
  }

  // node_modules/@base-ui/react/esm/utils/resolveRef.js
  function resolveRef(maybeRef) {
    if (maybeRef == null) {
      return maybeRef;
    }
    return "current" in maybeRef ? maybeRef.current : maybeRef;
  }

  // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
  var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
    TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
    TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
    return TransitionStatusDataAttributes2;
  })({});
  var STARTING_HOOK = {
    [TransitionStatusDataAttributes.startingStyle]: ""
  };
  var ENDING_HOOK = {
    [TransitionStatusDataAttributes.endingStyle]: ""
  };
  var transitionStatusMapping = {
    transitionStatus(value) {
      if (value === "starting") {
        return STARTING_HOOK;
      }
      if (value === "ending") {
        return ENDING_HOOK;
      }
      return null;
    }
  };

  // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
  function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
    const frame = useAnimationFrame();
    return useStableCallback((fnToExecute, signal = null) => {
      frame.cancel();
      const element = resolveRef(elementOrRef);
      if (element == null) {
        return;
      }
      const resolvedElement = element;
      const done = () => {
        ReactDOM.flushSync(fnToExecute);
      };
      if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
        fnToExecute();
        return;
      }
      function exec() {
        Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
          if (!signal?.aborted) {
            done();
          }
        }).catch(() => {
          if (treatAbortedAsFinished) {
            if (!signal?.aborted) {
              done();
            }
            return;
          }
          const currentAnimations = resolvedElement.getAnimations();
          if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
            exec();
          }
        });
      }
      if (waitForStartingStyleRemoved) {
        const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
        if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
          frame.request(exec);
          return;
        }
        const attributeObserver = new MutationObserver(() => {
          if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
            attributeObserver.disconnect();
            exec();
          }
        });
        attributeObserver.observe(resolvedElement, {
          attributes: true,
          attributeFilter: [startingStyleAttribute]
        });
        signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
          once: true
        });
        return;
      }
      frame.request(exec);
    });
  }

  // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
  var React11 = __toESM(require_react(), 1);
  function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
    const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
    const [mounted, setMounted] = React11.useState(open);
    if (open && !mounted) {
      setMounted(true);
      setTransitionStatus("starting");
    }
    if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
      setTransitionStatus("ending");
    }
    if (!open && !mounted && transitionStatus === "ending") {
      setTransitionStatus(void 0);
    }
    useIsoLayoutEffect(() => {
      if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
        const frame = AnimationFrame.request(() => {
          setTransitionStatus("ending");
        });
        return () => {
          AnimationFrame.cancel(frame);
        };
      }
      return void 0;
    }, [open, mounted, transitionStatus, deferEndingState]);
    useIsoLayoutEffect(() => {
      if (!open || enableIdleState) {
        return void 0;
      }
      const frame = AnimationFrame.request(() => {
        setTransitionStatus(void 0);
      });
      return () => {
        AnimationFrame.cancel(frame);
      };
    }, [enableIdleState, open]);
    useIsoLayoutEffect(() => {
      if (!open || !enableIdleState) {
        return void 0;
      }
      if (open && mounted && transitionStatus !== "idle") {
        setTransitionStatus("starting");
      }
      const frame = AnimationFrame.request(() => {
        setTransitionStatus("idle");
      });
      return () => {
        AnimationFrame.cancel(frame);
      };
    }, [enableIdleState, open, mounted, transitionStatus]);
    return {
      mounted,
      setMounted,
      transitionStatus
    };
  }

  // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
  function useCollapsibleRoot(parameters) {
    const {
      open: openParam,
      defaultOpen,
      onOpenChange,
      disabled: disabled2
    } = parameters;
    const isControlled = openParam !== void 0;
    const [open, setOpen] = useControlled({
      controlled: openParam,
      default: defaultOpen,
      name: "Collapsible",
      state: "open"
    });
    const {
      mounted,
      setMounted,
      transitionStatus
    } = useTransitionStatus(open, true, true);
    const [visible, setVisible] = React12.useState(open);
    const [{
      height,
      width
    }, setDimensions] = React12.useState({
      height: void 0,
      width: void 0
    });
    const defaultPanelId = useBaseUiId();
    const [panelIdState, setPanelIdState] = React12.useState();
    const panelId = panelIdState ?? defaultPanelId;
    const [hiddenUntilFound, setHiddenUntilFound] = React12.useState(false);
    const [keepMounted, setKeepMounted] = React12.useState(false);
    const abortControllerRef = React12.useRef(null);
    const animationTypeRef = React12.useRef(null);
    const transitionDimensionRef = React12.useRef(null);
    const panelRef = React12.useRef(null);
    const runOnceAnimationsFinish = useAnimationsFinished(panelRef, false);
    const handleTrigger = useStableCallback((event) => {
      const nextOpen = !open;
      const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent);
      onOpenChange(nextOpen, eventDetails);
      if (eventDetails.isCanceled) {
        return;
      }
      const panel = panelRef.current;
      if (animationTypeRef.current === "css-animation" && panel != null) {
        panel.style.removeProperty("animation-name");
      }
      if (!hiddenUntilFound && !keepMounted) {
        if (animationTypeRef.current != null && animationTypeRef.current !== "css-animation") {
          if (!mounted && nextOpen) {
            setMounted(true);
          }
        }
        if (animationTypeRef.current === "css-animation") {
          if (!visible && nextOpen) {
            setVisible(true);
          }
          if (!mounted && nextOpen) {
            setMounted(true);
          }
        }
      }
      setOpen(nextOpen);
      if (animationTypeRef.current === "none" && mounted && !nextOpen) {
        setMounted(false);
      }
    });
    useIsoLayoutEffect(() => {
      if (isControlled && animationTypeRef.current === "none" && !open) {
        setMounted(false);
      }
    }, [isControlled, open, openParam, setMounted]);
    return React12.useMemo(() => ({
      abortControllerRef,
      animationTypeRef,
      disabled: disabled2,
      handleTrigger,
      height,
      mounted,
      open,
      panelId,
      panelRef,
      runOnceAnimationsFinish,
      setDimensions,
      setHiddenUntilFound,
      setKeepMounted,
      setMounted,
      setOpen,
      setPanelIdState,
      setVisible,
      transitionDimensionRef,
      transitionStatus,
      visible,
      width
    }), [abortControllerRef, animationTypeRef, disabled2, handleTrigger, height, mounted, open, panelId, panelRef, runOnceAnimationsFinish, setDimensions, setHiddenUntilFound, setKeepMounted, setMounted, setOpen, setVisible, transitionDimensionRef, transitionStatus, visible, width]);
  }

  // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRootContext.js
  var React13 = __toESM(require_react(), 1);
  var CollapsibleRootContext = /* @__PURE__ */ React13.createContext(void 0);
  if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext";
  function useCollapsibleRootContext() {
    const context = React13.useContext(CollapsibleRootContext);
    if (context === void 0) {
      throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15));
    }
    return context;
  }

  // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelDataAttributes.js
  var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) {
    CollapsiblePanelDataAttributes2["open"] = "data-open";
    CollapsiblePanelDataAttributes2["closed"] = "data-closed";
    CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
    CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
    return CollapsiblePanelDataAttributes2;
  })({});

  // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTriggerDataAttributes.js
  var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) {
    CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open";
    return CollapsibleTriggerDataAttributes2;
  })({});

  // node_modules/@base-ui/react/esm/utils/collapsibleOpenStateMapping.js
  var PANEL_OPEN_HOOK = {
    [CollapsiblePanelDataAttributes.open]: ""
  };
  var PANEL_CLOSED_HOOK = {
    [CollapsiblePanelDataAttributes.closed]: ""
  };
  var triggerOpenStateMapping = {
    open(value) {
      if (value) {
        return {
          [CollapsibleTriggerDataAttributes.panelOpen]: ""
        };
      }
      return null;
    }
  };
  var collapsibleOpenStateMapping = {
    open(value) {
      if (value) {
        return PANEL_OPEN_HOOK;
      }
      return PANEL_CLOSED_HOOK;
    }
  };

  // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
  var React16 = __toESM(require_react(), 1);

  // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
  function hasWindow() {
    return typeof window !== "undefined";
  }
  function getWindow(node) {
    var _node$ownerDocument;
    return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
  }
  function isHTMLElement(value) {
    if (!hasWindow()) {
      return false;
    }
    return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
  }

  // node_modules/@base-ui/react/esm/internals/composite/root/CompositeRootContext.js
  var React14 = __toESM(require_react(), 1);
  var CompositeRootContext = /* @__PURE__ */ React14.createContext(void 0);
  if (true) CompositeRootContext.displayName = "CompositeRootContext";
  function useCompositeRootContext(optional = false) {
    const context = React14.useContext(CompositeRootContext);
    if (context === void 0 && !optional) {
      throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
    }
    return context;
  }

  // node_modules/@base-ui/react/esm/utils/useFocusableWhenDisabled.js
  var React15 = __toESM(require_react(), 1);
  function useFocusableWhenDisabled(parameters) {
    const {
      focusableWhenDisabled,
      disabled: disabled2,
      composite = false,
      tabIndex: tabIndexProp = 0,
      isNativeButton
    } = parameters;
    const isFocusableComposite = composite && focusableWhenDisabled !== false;
    const isNonFocusableComposite = composite && focusableWhenDisabled === false;
    const props = React15.useMemo(() => {
      const additionalProps = {
        // allow Tabbing away from focusableWhenDisabled elements
        onKeyDown(event) {
          if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
            event.preventDefault();
          }
        }
      };
      if (!composite) {
        additionalProps.tabIndex = tabIndexProp;
        if (!isNativeButton && disabled2) {
          additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
        }
      }
      if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
        additionalProps["aria-disabled"] = disabled2;
      }
      if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
        additionalProps.disabled = disabled2;
      }
      return additionalProps;
    }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
    return {
      props
    };
  }

  // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
  function useButton(parameters = {}) {
    const {
      disabled: disabled2 = false,
      focusableWhenDisabled,
      tabIndex = 0,
      native: isNativeButton = true,
      composite: compositeProp
    } = parameters;
    const elementRef = React16.useRef(null);
    const compositeRootContext = useCompositeRootContext(true);
    const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
    const {
      props: focusableWhenDisabledProps
    } = useFocusableWhenDisabled({
      focusableWhenDisabled,
      disabled: disabled2,
      composite: isCompositeItem,
      tabIndex,
      isNativeButton
    });
    if (true) {
      React16.useEffect(() => {
        if (!elementRef.current) {
          return;
        }
        const isButtonTag = isButtonElement(elementRef.current);
        if (isNativeButton) {
          if (!isButtonTag) {
            const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
            const message2 = "A component that acts as a button expected a native <button> because the `nativeButton` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the `render` prop, or set `nativeButton` to `false`.";
            error(`${message2}${ownerStackMessage}`);
          }
        } else if (isButtonTag) {
          const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
          const message2 = "A component that acts as a button expected a non-<button> because the `nativeButton` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as `role` or `aria-disabled`). Use a non-<button> in the `render` prop, or set `nativeButton` to `true`.";
          error(`${message2}${ownerStackMessage}`);
        }
      }, [isNativeButton]);
    }
    const updateDisabled = React16.useCallback(() => {
      const element = elementRef.current;
      if (!isButtonElement(element)) {
        return;
      }
      if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
        element.disabled = false;
      }
    }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
    useIsoLayoutEffect(updateDisabled, [updateDisabled]);
    const getButtonProps = React16.useCallback((externalProps = {}) => {
      const {
        onClick: externalOnClick,
        onMouseDown: externalOnMouseDown,
        onKeyUp: externalOnKeyUp,
        onKeyDown: externalOnKeyDown,
        onPointerDown: externalOnPointerDown,
        ...otherExternalProps
      } = externalProps;
      const type = isNativeButton ? "button" : void 0;
      return mergeProps({
        type,
        onClick(event) {
          if (disabled2) {
            event.preventDefault();
            return;
          }
          externalOnClick?.(event);
        },
        onMouseDown(event) {
          if (!disabled2) {
            externalOnMouseDown?.(event);
          }
        },
        onKeyDown(event) {
          if (disabled2) {
            return;
          }
          makeEventPreventable(event);
          externalOnKeyDown?.(event);
          if (event.baseUIHandlerPrevented) {
            return;
          }
          const isCurrentTarget = event.target === event.currentTarget;
          const currentTarget = event.currentTarget;
          const isButton2 = isButtonElement(currentTarget);
          const isLink = !isNativeButton && isValidLinkElement(currentTarget);
          const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink);
          const isEnterKey = event.key === "Enter";
          const isSpaceKey = event.key === " ";
          const role = currentTarget.getAttribute("role");
          const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
          if (isCurrentTarget && isCompositeItem && isSpaceKey) {
            if (event.defaultPrevented && isTextNavigationRole) {
              return;
            }
            event.preventDefault();
            if (isLink || isNativeButton && isButton2) {
              currentTarget.click();
              event.preventBaseUIHandler();
            } else if (shouldClick) {
              externalOnClick?.(event);
              event.preventBaseUIHandler();
            }
            return;
          }
          if (shouldClick) {
            if (!isNativeButton && (isSpaceKey || isEnterKey)) {
              event.preventDefault();
            }
            if (!isNativeButton && isEnterKey) {
              externalOnClick?.(event);
            }
          }
        },
        onKeyUp(event) {
          if (disabled2) {
            return;
          }
          makeEventPreventable(event);
          externalOnKeyUp?.(event);
          if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
            event.preventDefault();
            return;
          }
          if (event.baseUIHandlerPrevented) {
            return;
          }
          if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
            externalOnClick?.(event);
          }
        },
        onPointerDown(event) {
          if (disabled2) {
            event.preventDefault();
            return;
          }
          externalOnPointerDown?.(event);
        }
      }, !isNativeButton ? {
        role: "button"
      } : void 0, focusableWhenDisabledProps, otherExternalProps);
    }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
    const buttonRef = useStableCallback((element) => {
      elementRef.current = element;
      updateDisabled();
    });
    return {
      getButtonProps,
      buttonRef
    };
  }
  function isButtonElement(elem) {
    return isHTMLElement(elem) && elem.tagName === "BUTTON";
  }
  function isValidLinkElement(elem) {
    return Boolean(elem?.tagName === "A" && elem?.href);
  }

  // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
  var React17 = __toESM(require_react(), 1);

  // node_modules/@base-ui/utils/esm/addEventListener.js
  function addEventListener(target, type, listener, options) {
    target.addEventListener(type, listener, options);
    return () => {
      target.removeEventListener(type, listener, options);
    };
  }

  // node_modules/@base-ui/react/esm/accordion/root/AccordionRootDataAttributes.js
  var AccordionRootDataAttributes = /* @__PURE__ */ (function(AccordionRootDataAttributes2) {
    AccordionRootDataAttributes2["disabled"] = "data-disabled";
    AccordionRootDataAttributes2["orientation"] = "data-orientation";
    return AccordionRootDataAttributes2;
  })({});

  // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
  function useCollapsiblePanel(parameters) {
    const {
      abortControllerRef,
      animationTypeRef,
      externalRef,
      height,
      hiddenUntilFound,
      keepMounted,
      id: idParam,
      mounted,
      onOpenChange,
      open,
      panelRef,
      runOnceAnimationsFinish,
      setDimensions,
      setMounted,
      setOpen,
      setVisible,
      transitionDimensionRef,
      visible,
      width
    } = parameters;
    const isBeforeMatchRef = React17.useRef(false);
    const latestAnimationNameRef = React17.useRef(null);
    const shouldCancelInitialOpenAnimationRef = React17.useRef(open);
    const shouldCancelInitialOpenTransitionRef = React17.useRef(open);
    const endingStyleFrame = useAnimationFrame();
    const hidden = React17.useMemo(() => {
      if (animationTypeRef.current === "css-animation") {
        return !visible;
      }
      return !open && !mounted;
    }, [open, mounted, visible, animationTypeRef]);
    const handlePanelRef = useStableCallback((element) => {
      if (!element) {
        return void 0;
      }
      if (animationTypeRef.current == null || transitionDimensionRef.current == null) {
        const panelStyles = getComputedStyle(element);
        const hasAnimation = panelStyles.animationName !== "none" && panelStyles.animationName !== "";
        const hasTransition = panelStyles.transitionDuration !== "0s" && panelStyles.transitionDuration !== "";
        if (hasAnimation && hasTransition) {
          if (true) {
            warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
          }
        } else if (panelStyles.animationName === "none" && panelStyles.transitionDuration !== "0s") {
          animationTypeRef.current = "css-transition";
        } else if (panelStyles.animationName !== "none" && panelStyles.transitionDuration === "0s") {
          animationTypeRef.current = "css-animation";
        } else {
          animationTypeRef.current = "none";
        }
        if (element.getAttribute(AccordionRootDataAttributes.orientation) === "horizontal" || panelStyles.transitionProperty.indexOf("width") > -1) {
          transitionDimensionRef.current = "width";
        } else {
          transitionDimensionRef.current = "height";
        }
      }
      if (animationTypeRef.current !== "css-transition") {
        return void 0;
      }
      if (height === void 0 || width === void 0) {
        setDimensions({
          height: element.scrollHeight,
          width: element.scrollWidth
        });
        if (shouldCancelInitialOpenTransitionRef.current) {
          element.style.setProperty("transition-duration", "0s");
        }
      }
      let frame = -1;
      let nextFrame = -1;
      frame = AnimationFrame.request(() => {
        shouldCancelInitialOpenTransitionRef.current = false;
        nextFrame = AnimationFrame.request(() => {
          setTimeout(() => {
            element.style.removeProperty("transition-duration");
          });
        });
      });
      return () => {
        AnimationFrame.cancel(frame);
        AnimationFrame.cancel(nextFrame);
      };
    });
    const mergedPanelRef = useMergedRefs(externalRef, panelRef, handlePanelRef);
    useIsoLayoutEffect(() => {
      if (animationTypeRef.current !== "css-transition") {
        return void 0;
      }
      const panel = panelRef.current;
      if (!panel) {
        return void 0;
      }
      let resizeFrame = -1;
      if (abortControllerRef.current != null) {
        abortControllerRef.current.abort();
        abortControllerRef.current = null;
      }
      if (open) {
        const originalLayoutStyles = {
          "justify-content": panel.style.justifyContent,
          "align-items": panel.style.alignItems,
          "align-content": panel.style.alignContent,
          "justify-items": panel.style.justifyItems
        };
        Object.keys(originalLayoutStyles).forEach((key) => {
          panel.style.setProperty(key, "initial", "important");
        });
        if (!shouldCancelInitialOpenTransitionRef.current && !keepMounted) {
          panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, "");
        }
        setDimensions({
          height: panel.scrollHeight,
          width: panel.scrollWidth
        });
        resizeFrame = AnimationFrame.request(() => {
          Object.entries(originalLayoutStyles).forEach(([key, value]) => {
            if (value === "") {
              panel.style.removeProperty(key);
            } else {
              panel.style.setProperty(key, value);
            }
          });
        });
      } else {
        if (panel.scrollHeight === 0 && panel.scrollWidth === 0) {
          return void 0;
        }
        setDimensions({
          height: panel.scrollHeight,
          width: panel.scrollWidth
        });
        const abortController = new AbortController();
        abortControllerRef.current = abortController;
        const signal = abortController.signal;
        let attributeObserver = null;
        const endingStyleAttribute = CollapsiblePanelDataAttributes.endingStyle;
        attributeObserver = new MutationObserver((mutationList) => {
          const hasEndingStyle = mutationList.some((mutation) => mutation.type === "attributes" && mutation.attributeName === endingStyleAttribute);
          if (hasEndingStyle) {
            attributeObserver?.disconnect();
            attributeObserver = null;
            runOnceAnimationsFinish(() => {
              setDimensions({
                height: 0,
                width: 0
              });
              panel.style.removeProperty("content-visibility");
              setMounted(false);
              if (abortControllerRef.current === abortController) {
                abortControllerRef.current = null;
              }
            }, signal);
          }
        });
        attributeObserver.observe(panel, {
          attributes: true,
          attributeFilter: [endingStyleAttribute]
        });
        return () => {
          attributeObserver?.disconnect();
          endingStyleFrame.cancel();
          if (abortControllerRef.current === abortController) {
            abortController.abort();
            abortControllerRef.current = null;
          }
        };
      }
      return () => {
        AnimationFrame.cancel(resizeFrame);
      };
    }, [abortControllerRef, animationTypeRef, endingStyleFrame, hiddenUntilFound, keepMounted, mounted, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted]);
    useIsoLayoutEffect(() => {
      if (animationTypeRef.current !== "css-animation") {
        return;
      }
      const panel = panelRef.current;
      if (!panel) {
        return;
      }
      latestAnimationNameRef.current = panel.style.animationName || latestAnimationNameRef.current;
      panel.style.setProperty("animation-name", "none");
      setDimensions({
        height: panel.scrollHeight,
        width: panel.scrollWidth
      });
      if (!shouldCancelInitialOpenAnimationRef.current && !isBeforeMatchRef.current) {
        panel.style.removeProperty("animation-name");
      }
      if (open) {
        if (abortControllerRef.current != null) {
          abortControllerRef.current.abort();
          abortControllerRef.current = null;
        }
        setMounted(true);
        setVisible(true);
      } else {
        abortControllerRef.current = new AbortController();
        runOnceAnimationsFinish(() => {
          setMounted(false);
          setVisible(false);
          abortControllerRef.current = null;
        }, abortControllerRef.current.signal);
      }
    }, [abortControllerRef, animationTypeRef, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted, setVisible, visible]);
    useOnMount(() => {
      const frame = AnimationFrame.request(() => {
        shouldCancelInitialOpenAnimationRef.current = false;
      });
      return () => AnimationFrame.cancel(frame);
    });
    useIsoLayoutEffect(() => {
      if (!hiddenUntilFound) {
        return void 0;
      }
      const panel = panelRef.current;
      if (!panel) {
        return void 0;
      }
      let frame = -1;
      let nextFrame = -1;
      if (open && isBeforeMatchRef.current) {
        panel.style.transitionDuration = "0s";
        setDimensions({
          height: panel.scrollHeight,
          width: panel.scrollWidth
        });
        frame = AnimationFrame.request(() => {
          isBeforeMatchRef.current = false;
          nextFrame = AnimationFrame.request(() => {
            setTimeout(() => {
              panel.style.removeProperty("transition-duration");
            });
          });
        });
      }
      return () => {
        AnimationFrame.cancel(frame);
        AnimationFrame.cancel(nextFrame);
      };
    }, [hiddenUntilFound, open, panelRef, setDimensions]);
    useIsoLayoutEffect(() => {
      const panel = panelRef.current;
      if (panel && hiddenUntilFound && hidden) {
        panel.setAttribute("hidden", "until-found");
        if (animationTypeRef.current === "css-transition") {
          panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, "");
        }
      }
    }, [hiddenUntilFound, hidden, animationTypeRef, panelRef]);
    React17.useEffect(function registerBeforeMatchListener() {
      const panel = panelRef.current;
      if (!panel) {
        return void 0;
      }
      function handleBeforeMatch(event) {
        isBeforeMatchRef.current = true;
        setOpen(true);
        onOpenChange(true, createChangeEventDetails(reason_parts_exports.none, event));
      }
      return addEventListener(panel, "beforematch", handleBeforeMatch);
    }, [onOpenChange, panelRef, setOpen]);
    return React17.useMemo(() => ({
      props: {
        hidden,
        id: idParam,
        ref: mergedPanelRef
      }
    }), [hidden, idParam, mergedPanelRef]);
  }

  // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
  var React18 = __toESM(require_react(), 1);
  function useOpenChangeComplete(parameters) {
    const {
      enabled = true,
      open,
      ref,
      onComplete: onCompleteParam
    } = parameters;
    const onComplete = useStableCallback(onCompleteParam);
    const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
    React18.useEffect(() => {
      if (!enabled) {
        return void 0;
      }
      const abortController = new AbortController();
      runOnceAnimationsFinish(onComplete, abortController.signal);
      return () => {
        abortController.abort();
      };
    }, [enabled, open, onComplete, runOnceAnimationsFinish]);
  }

  // node_modules/@base-ui/react/esm/collapsible/index.parts.js
  var index_parts_exports = {};
  __export(index_parts_exports, {
    Panel: () => CollapsiblePanel,
    Root: () => CollapsibleRoot,
    Trigger: () => CollapsibleTrigger
  });

  // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
  var React19 = __toESM(require_react(), 1);

  // node_modules/@base-ui/react/esm/collapsible/root/stateAttributesMapping.js
  var collapsibleStateAttributesMapping = {
    ...collapsibleOpenStateMapping,
    ...transitionStatusMapping
  };

  // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
  var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
  var CollapsibleRoot = /* @__PURE__ */ React19.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) {
    const {
      render: render4,
      className,
      defaultOpen = false,
      disabled: disabled2 = false,
      onOpenChange: onOpenChangeProp,
      open,
      style,
      ...elementProps
    } = componentProps;
    const onOpenChange = useStableCallback(onOpenChangeProp);
    const collapsible = useCollapsibleRoot({
      open,
      defaultOpen,
      onOpenChange,
      disabled: disabled2
    });
    const state = React19.useMemo(() => ({
      open: collapsible.open,
      disabled: collapsible.disabled,
      transitionStatus: collapsible.transitionStatus
    }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]);
    const contextValue = React19.useMemo(() => ({
      ...collapsible,
      onOpenChange,
      state
    }), [collapsible, onOpenChange, state]);
    const element = useRenderElement("div", componentProps, {
      state,
      ref: forwardedRef,
      props: elementProps,
      stateAttributesMapping: collapsibleStateAttributesMapping
    });
    return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(CollapsibleRootContext.Provider, {
      value: contextValue,
      children: element
    });
  });
  if (true) CollapsibleRoot.displayName = "CollapsibleRoot";

  // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTrigger.js
  var React20 = __toESM(require_react(), 1);
  var stateAttributesMapping = {
    ...triggerOpenStateMapping,
    ...transitionStatusMapping
  };
  var CollapsibleTrigger = /* @__PURE__ */ React20.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
    const {
      panelId,
      open,
      handleTrigger,
      state,
      disabled: contextDisabled
    } = useCollapsibleRootContext();
    const {
      className,
      disabled: disabled2 = contextDisabled,
      id,
      render: render4,
      nativeButton = true,
      style,
      ...elementProps
    } = componentProps;
    const {
      getButtonProps,
      buttonRef
    } = useButton({
      disabled: disabled2,
      focusableWhenDisabled: true,
      native: nativeButton
    });
    const props = React20.useMemo(() => ({
      "aria-controls": open ? panelId : void 0,
      "aria-expanded": open,
      onClick: handleTrigger
    }), [panelId, open, handleTrigger]);
    const element = useRenderElement("button", componentProps, {
      state,
      ref: [forwardedRef, buttonRef],
      props: [props, elementProps, getButtonProps],
      stateAttributesMapping
    });
    return element;
  });
  if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger";

  // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
  var React21 = __toESM(require_react(), 1);

  // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelCssVars.js
  var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) {
    CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height";
    CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width";
    return CollapsiblePanelCssVars2;
  })({});

  // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
  var CollapsiblePanel = /* @__PURE__ */ React21.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) {
    const {
      className,
      hiddenUntilFound: hiddenUntilFoundProp,
      keepMounted: keepMountedProp,
      render: render4,
      id: idProp,
      style,
      ...elementProps
    } = componentProps;
    if (true) {
      useIsoLayoutEffect(() => {
        if (hiddenUntilFoundProp && keepMountedProp === false) {
          warn("The `keepMounted={false}` prop on a Collapsible will be ignored when using `hiddenUntilFound` since it requires the Panel to remain mounted even when closed.");
        }
      }, [hiddenUntilFoundProp, keepMountedProp]);
    }
    const {
      abortControllerRef,
      animationTypeRef,
      height,
      mounted,
      onOpenChange,
      open,
      panelId,
      panelRef,
      runOnceAnimationsFinish,
      setDimensions,
      setHiddenUntilFound,
      setKeepMounted,
      setMounted,
      setPanelIdState,
      setOpen,
      setVisible,
      state,
      transitionDimensionRef,
      visible,
      width,
      transitionStatus
    } = useCollapsibleRootContext();
    const hiddenUntilFound = hiddenUntilFoundProp ?? false;
    const keepMounted = keepMountedProp ?? false;
    useIsoLayoutEffect(() => {
      if (idProp) {
        setPanelIdState(idProp);
        return () => {
          setPanelIdState(void 0);
        };
      }
      return void 0;
    }, [idProp, setPanelIdState]);
    useIsoLayoutEffect(() => {
      setHiddenUntilFound(hiddenUntilFound);
    }, [setHiddenUntilFound, hiddenUntilFound]);
    useIsoLayoutEffect(() => {
      setKeepMounted(keepMounted);
    }, [setKeepMounted, keepMounted]);
    const {
      props
    } = useCollapsiblePanel({
      abortControllerRef,
      animationTypeRef,
      externalRef: forwardedRef,
      height,
      hiddenUntilFound,
      id: panelId,
      keepMounted,
      mounted,
      onOpenChange,
      open,
      panelRef,
      runOnceAnimationsFinish,
      setDimensions,
      setMounted,
      setOpen,
      setVisible,
      transitionDimensionRef,
      visible,
      width
    });
    useOpenChangeComplete({
      open: open && transitionStatus === "idle",
      ref: panelRef,
      onComplete() {
        if (!open) {
          return;
        }
        setDimensions({
          height: void 0,
          width: void 0
        });
      }
    });
    const panelState = React21.useMemo(() => ({
      ...state,
      transitionStatus
    }), [state, transitionStatus]);
    const element = useRenderElement("div", componentProps, {
      state: panelState,
      ref: [forwardedRef, panelRef],
      props: [props, {
        style: {
          [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `${height}px`,
          [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `${width}px`
        }
      }, elementProps],
      stateAttributesMapping: collapsibleStateAttributesMapping
    });
    const shouldRender = keepMounted || hiddenUntilFound || mounted;
    if (!shouldRender) {
      return null;
    }
    return element;
  });
  if (true) CollapsiblePanel.displayName = "CollapsiblePanel";

  // node_modules/@base-ui/react/esm/use-render/useRender.js
  function useRender(params) {
    return useRenderElement(params.defaultTagName ?? "div", params, params);
  }

  // packages/ui/build-module/text/text.mjs
  var import_element5 = __toESM(require_element(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='4130d64bea']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "4130d64bea");
    style.appendChild(document.createTextNode('@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}'));
    document.head.appendChild(style);
  }
  var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='1fb29d3a3c']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "1fb29d3a3c");
    style.appendChild(document.createTextNode("._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}"));
    document.head.appendChild(style);
  }
  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" };
  var Text = (0, import_element5.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
    const element = useRender({
      render: render4,
      defaultTagName: "span",
      ref,
      props: mergeProps(props, {
        className: clsx_default(
          style_default.text,
          global_css_defense_default.heading,
          global_css_defense_default.p,
          style_default[variant],
          className
        )
      })
    });
    return element;
  });

  // packages/ui/build-module/badge/badge.mjs
  var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='d6a685e1aa']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "d6a685e1aa");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-bg-surface-error,#f6e6e3);color:var(--wpds-color-fg-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-bg-surface-warning,#fde6be);color:var(--wpds-color-fg-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-bg-surface-caution,#fee995);color:var(--wpds-color-fg-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-bg-surface-success,#c6f7cd);color:var(--wpds-color-fg-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-bg-surface-info,#deebfa);color:var(--wpds-color-fg-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-fg-content-neutral,#1e1e1e);padding-block:calc(var(--wpds-dimension-padding-xs, 4px) - var(--wpds-border-width-xs, 1px));padding-inline:calc(var(--wpds-dimension-padding-sm, 8px) - var(--wpds-border-width-xs, 1px))}}"));
    document.head.appendChild(style);
  }
  var style_default2 = { "badge": "_96e6251aad1a6136__badge", "is-high-intent": "_99f7158cb520f750__is-high-intent", "is-medium-intent": "c20ebef2365bc8b7__is-medium-intent", "is-low-intent": "_365e1626c6202e52__is-low-intent", "is-stable-intent": "_33f8198127ddf4ef__is-stable-intent", "is-informational-intent": "_04c1aca8fc449412__is-informational-intent", "is-draft-intent": "_90726e69d495ec19__is-draft-intent", "is-none-intent": "_898f4a544993bd39__is-none-intent" };
  var Badge = (0, import_element6.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
    return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
      Text,
      {
        ref,
        className: clsx_default(
          style_default2.badge,
          style_default2[`is-${intent}-intent`],
          className
        ),
        ...props,
        variant: "body-sm"
      }
    );
  });

  // packages/ui/build-module/icon/icon.mjs
  var import_element7 = __toESM(require_element(), 1);
  var import_primitives90 = __toESM(require_primitives(), 1);
  var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
  var Icon = (0, import_element7.forwardRef)(function Icon2({ icon, size = 24, ...restProps }, ref) {
    return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
      import_primitives90.SVG,
      {
        ref,
        fill: "currentColor",
        ...icon.props,
        ...restProps,
        width: size,
        height: size
      }
    );
  });

  // packages/ui/build-module/card/index.mjs
  var card_exports = {};
  __export(card_exports, {
    Content: () => Content,
    FullBleed: () => FullBleed,
    Header: () => Header,
    Root: () => Root,
    Title: () => Title
  });

  // packages/ui/build-module/card/root.mjs
  var import_element8 = __toESM(require_element(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='e3ae230cea']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "e3ae230cea");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}"));
    document.head.appendChild(style);
  }
  var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "14f5e9ddeb");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
    document.head.appendChild(style);
  }
  var style_default3 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
  var Root = (0, import_element8.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
    const mergedClassName = clsx_default(style_default3.root, resets_default["box-sizing"]);
    const element = useRender({
      defaultTagName: "div",
      render: render4,
      ref,
      props: mergeProps({ className: mergedClassName }, restProps)
    });
    return element;
  });

  // packages/ui/build-module/card/header.mjs
  var import_element9 = __toESM(require_element(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "14f5e9ddeb");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
    document.head.appendChild(style);
  }
  var style_default4 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
  var Header = (0, import_element9.forwardRef)(
    function CardHeader({ render: render4, ...props }, ref) {
      const element = useRender({
        defaultTagName: "div",
        render: render4,
        ref,
        props: mergeProps({ className: style_default4.header }, props)
      });
      return element;
    }
  );

  // packages/ui/build-module/card/content.mjs
  var import_element10 = __toESM(require_element(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "14f5e9ddeb");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
    document.head.appendChild(style);
  }
  var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
  var Content = (0, import_element10.forwardRef)(
    function CardContent({ render: render4, ...props }, ref) {
      const element = useRender({
        defaultTagName: "div",
        render: render4,
        ref,
        props: mergeProps({ className: style_default5.content }, props)
      });
      return element;
    }
  );

  // packages/ui/build-module/card/full-bleed.mjs
  var import_element11 = __toESM(require_element(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "14f5e9ddeb");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
    document.head.appendChild(style);
  }
  var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
  var FullBleed = (0, import_element11.forwardRef)(
    function CardFullBleed({ render: render4, ...props }, ref) {
      const element = useRender({
        defaultTagName: "div",
        render: render4,
        ref,
        props: mergeProps(
          { className: style_default6.fullbleed },
          props
        )
      });
      return element;
    }
  );

  // packages/ui/build-module/card/title.mjs
  var import_element12 = __toESM(require_element(), 1);
  var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
  var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", {});
  var Title = (0, import_element12.forwardRef)(
    function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
      return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
        Text,
        {
          ref,
          variant: "heading-lg",
          render: render4,
          ...props,
          children
        }
      );
    }
  );

  // packages/ui/build-module/collapsible/panel.mjs
  var import_element13 = __toESM(require_element(), 1);
  var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
  var Panel = (0, import_element13.forwardRef)(
    function CollapsiblePanel3(props, forwardedRef) {
      return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
    }
  );

  // packages/ui/build-module/collapsible/root.mjs
  var import_element14 = __toESM(require_element(), 1);
  var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
  var Root2 = (0, import_element14.forwardRef)(
    function CollapsibleRoot3(props, forwardedRef) {
      return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
    }
  );

  // packages/ui/build-module/collapsible/trigger.mjs
  var import_element15 = __toESM(require_element(), 1);
  var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
  var Trigger = (0, import_element15.forwardRef)(
    function CollapsibleTrigger3(props, forwardedRef) {
      return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
    }
  );

  // packages/ui/build-module/collapsible-card/index.mjs
  var collapsible_card_exports = {};
  __export(collapsible_card_exports, {
    Content: () => Content2,
    Header: () => Header2,
    HeaderDescription: () => HeaderDescription,
    Root: () => Root3
  });

  // packages/ui/build-module/collapsible-card/root.mjs
  var import_element16 = __toESM(require_element(), 1);
  var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
  var Root3 = (0, import_element16.forwardRef)(
    function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
      return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
        Root2,
        {
          ref,
          render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Root, { render: render4 }),
          ...restProps
        }
      );
    }
  );

  // packages/ui/build-module/collapsible-card/header.mjs
  var import_element18 = __toESM(require_element(), 1);

  // packages/ui/build-module/collapsible-card/context.mjs
  var import_element17 = __toESM(require_element(), 1);
  var HeaderDescriptionIdContext = (0, import_element17.createContext)({
    setDescriptionId: () => {
    }
  });

  // packages/ui/build-module/collapsible-card/header.mjs
  var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='b49ef575a8']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "b49ef575a8");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}"));
    document.head.appendChild(style);
  }
  var style_default7 = { "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='1fb29d3a3c']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "1fb29d3a3c");
    style.appendChild(document.createTextNode("._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}"));
    document.head.appendChild(style);
  }
  var global_css_defense_default2 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='2a5ab8f3a7']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "2a5ab8f3a7");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}"));
    document.head.appendChild(style);
  }
  var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible" };
  var Header2 = (0, import_element18.forwardRef)(
    function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) {
      const [descriptionId, setDescriptionId] = (0, import_element18.useState)();
      const contextValue = (0, import_element18.useMemo)(
        () => ({ setDescriptionId }),
        [setDescriptionId]
      );
      return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(
        Trigger,
        {
          className: clsx_default(style_default7.header, className),
          render: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
            Header,
            {
              ref,
              render: render4,
              ...restProps
            }
          ),
          nativeButton: false,
          "aria-describedby": descriptionId,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: style_default7["header-content"], children }),
            /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
              "div",
              {
                className: clsx_default(
                  style_default7["header-trigger-positioner"]
                ),
                children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
                  "div",
                  {
                    className: clsx_default(
                      style_default7["header-trigger-wrapper"],
                      global_css_defense_default2.div,
                      // While the interactive trigger element is the whole header,
                      // the focus ring will be displayed only on the icon to visually
                      // emulate it being the button.
                      focus_default["outset-ring--focus-parent-visible"]
                    ),
                    children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
                      Icon,
                      {
                        icon: chevron_down_default,
                        className: style_default7["header-trigger"]
                      }
                    )
                  }
                )
              }
            )
          ]
        }
      ) });
    }
  );

  // packages/ui/build-module/collapsible-card/header-description.mjs
  var import_element19 = __toESM(require_element(), 1);
  var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
  var HeaderDescription = (0, import_element19.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) {
    const descriptionId = (0, import_element19.useId)();
    const { setDescriptionId } = (0, import_element19.useContext)(HeaderDescriptionIdContext);
    (0, import_element19.useEffect)(() => {
      setDescriptionId(descriptionId);
      return () => setDescriptionId(void 0);
    }, [descriptionId, setDescriptionId]);
    return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
      "div",
      {
        ref,
        id: descriptionId,
        "aria-hidden": "true",
        className,
        ...restProps,
        children
      }
    );
  });

  // packages/ui/build-module/collapsible-card/content.mjs
  var import_element20 = __toESM(require_element(), 1);
  var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='b49ef575a8']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "b49ef575a8");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}"));
    document.head.appendChild(style);
  }
  var style_default8 = { "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
  var Content2 = (0, import_element20.forwardRef)(
    function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
      return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
        Panel,
        {
          ref,
          className: (state) => clsx_default(
            style_default8.content,
            state.open && state.transitionStatus === "idle" && style_default8.overflowVisible,
            className
          ),
          hiddenUntilFound,
          ...restProps,
          children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
            Content,
            {
              className: style_default8["content-inner"],
              render: render4,
              children
            }
          )
        }
      );
    }
  );

  // packages/ui/build-module/stack/stack.mjs
  var import_element21 = __toESM(require_element(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='b51ff41489']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "b51ff41489");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}"));
    document.head.appendChild(style);
  }
  var style_default9 = { "stack": "_19ce0419607e1896__stack" };
  var gapTokens = {
    xs: "var(--wpds-dimension-gap-xs, 4px)",
    sm: "var(--wpds-dimension-gap-sm, 8px)",
    md: "var(--wpds-dimension-gap-md, 12px)",
    lg: "var(--wpds-dimension-gap-lg, 16px)",
    xl: "var(--wpds-dimension-gap-xl, 24px)",
    "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
    "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
  };
  var Stack = (0, import_element21.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
    const style = {
      gap: gap && gapTokens[gap],
      alignItems: align,
      justifyContent: justify,
      flexDirection: direction,
      flexWrap: wrap
    };
    const element = useRender({
      render: render4,
      ref,
      props: mergeProps(props, { style, className: style_default9.stack })
    });
    return element;
  });

  // packages/ui/build-module/visually-hidden/visually-hidden.mjs
  var import_element22 = __toESM(require_element(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='c46e8cb841']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "c46e8cb841");
    style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}"));
    document.head.appendChild(style);
  }
  var style_default10 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
  var VisuallyHidden = (0, import_element22.forwardRef)(
    function VisuallyHidden2({ render: render4, ...restProps }, ref) {
      const element = useRender({
        render: render4,
        ref,
        props: mergeProps(
          { className: style_default10["visually-hidden"] },
          restProps,
          {
            // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
            "data-visually-hidden": ""
          }
        )
      });
      return element;
    }
  );

  // packages/fields/build-module/components/media-edit/index.mjs
  var import_media_utils = __toESM(require_media_utils(), 1);
  var import_notices3 = __toESM(require_notices(), 1);

  // node_modules/@react-spring/rafz/dist/react-spring-rafz.esm.js
  var updateQueue = makeQueue();
  var raf = (fn) => schedule(fn, updateQueue);
  var writeQueue = makeQueue();
  raf.write = (fn) => schedule(fn, writeQueue);
  var onStartQueue = makeQueue();
  raf.onStart = (fn) => schedule(fn, onStartQueue);
  var onFrameQueue = makeQueue();
  raf.onFrame = (fn) => schedule(fn, onFrameQueue);
  var onFinishQueue = makeQueue();
  raf.onFinish = (fn) => schedule(fn, onFinishQueue);
  var timeouts = [];
  raf.setTimeout = (handler, ms) => {
    let time = raf.now() + ms;
    let cancel = () => {
      let i3 = timeouts.findIndex((t4) => t4.cancel == cancel);
      if (~i3) timeouts.splice(i3, 1);
      pendingCount -= ~i3 ? 1 : 0;
    };
    let timeout = {
      time,
      handler,
      cancel
    };
    timeouts.splice(findTimeout(time), 0, timeout);
    pendingCount += 1;
    start();
    return timeout;
  };
  var findTimeout = (time) => ~(~timeouts.findIndex((t4) => t4.time > time) || ~timeouts.length);
  raf.cancel = (fn) => {
    onStartQueue.delete(fn);
    onFrameQueue.delete(fn);
    onFinishQueue.delete(fn);
    updateQueue.delete(fn);
    writeQueue.delete(fn);
  };
  raf.sync = (fn) => {
    sync = true;
    raf.batchedUpdates(fn);
    sync = false;
  };
  raf.throttle = (fn) => {
    let lastArgs;
    function queuedFn() {
      try {
        fn(...lastArgs);
      } finally {
        lastArgs = null;
      }
    }
    function throttled(...args) {
      lastArgs = args;
      raf.onStart(queuedFn);
    }
    throttled.handler = fn;
    throttled.cancel = () => {
      onStartQueue.delete(queuedFn);
      lastArgs = null;
    };
    return throttled;
  };
  var nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : () => {
  };
  raf.use = (impl) => nativeRaf = impl;
  raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now;
  raf.batchedUpdates = (fn) => fn();
  raf.catch = console.error;
  raf.frameLoop = "always";
  raf.advance = () => {
    if (raf.frameLoop !== "demand") {
      console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand");
    } else {
      update2();
    }
  };
  var ts = -1;
  var pendingCount = 0;
  var sync = false;
  function schedule(fn, queue) {
    if (sync) {
      queue.delete(fn);
      fn(0);
    } else {
      queue.add(fn);
      start();
    }
  }
  function start() {
    if (ts < 0) {
      ts = 0;
      if (raf.frameLoop !== "demand") {
        nativeRaf(loop);
      }
    }
  }
  function stop() {
    ts = -1;
  }
  function loop() {
    if (~ts) {
      nativeRaf(loop);
      raf.batchedUpdates(update2);
    }
  }
  function update2() {
    let prevTs = ts;
    ts = raf.now();
    let count = findTimeout(ts);
    if (count) {
      eachSafely(timeouts.splice(0, count), (t4) => t4.handler());
      pendingCount -= count;
    }
    if (!pendingCount) {
      stop();
      return;
    }
    onStartQueue.flush();
    updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
    onFrameQueue.flush();
    writeQueue.flush();
    onFinishQueue.flush();
  }
  function makeQueue() {
    let next = /* @__PURE__ */ new Set();
    let current = next;
    return {
      add(fn) {
        pendingCount += current == next && !next.has(fn) ? 1 : 0;
        next.add(fn);
      },
      delete(fn) {
        pendingCount -= current == next && next.has(fn) ? 1 : 0;
        return next.delete(fn);
      },
      flush(arg) {
        if (current.size) {
          next = /* @__PURE__ */ new Set();
          pendingCount -= current.size;
          eachSafely(current, (fn) => fn(arg) && next.add(fn));
          pendingCount += next.size;
          current = next;
        }
      }
    };
  }
  function eachSafely(values, each2) {
    values.forEach((value) => {
      try {
        each2(value);
      } catch (e3) {
        raf.catch(e3);
      }
    });
  }

  // node_modules/@react-spring/shared/dist/react-spring-shared.esm.js
  var import_react9 = __toESM(require_react());
  function noop2() {
  }
  var defineHidden = (obj, key, value) => Object.defineProperty(obj, key, {
    value,
    writable: true,
    configurable: true
  });
  var is = {
    arr: Array.isArray,
    obj: (a3) => !!a3 && a3.constructor.name === "Object",
    fun: (a3) => typeof a3 === "function",
    str: (a3) => typeof a3 === "string",
    num: (a3) => typeof a3 === "number",
    und: (a3) => a3 === void 0
  };
  function isEqual(a3, b3) {
    if (is.arr(a3)) {
      if (!is.arr(b3) || a3.length !== b3.length) return false;
      for (let i3 = 0; i3 < a3.length; i3++) {
        if (a3[i3] !== b3[i3]) return false;
      }
      return true;
    }
    return a3 === b3;
  }
  var each = (obj, fn) => obj.forEach(fn);
  function eachProp(obj, fn, ctx9) {
    if (is.arr(obj)) {
      for (let i3 = 0; i3 < obj.length; i3++) {
        fn.call(ctx9, obj[i3], `${i3}`);
      }
      return;
    }
    for (const key in obj) {
      if (obj.hasOwnProperty(key)) {
        fn.call(ctx9, obj[key], key);
      }
    }
  }
  var toArray = (a3) => is.und(a3) ? [] : is.arr(a3) ? a3 : [a3];
  function flush(queue, iterator) {
    if (queue.size) {
      const items = Array.from(queue);
      queue.clear();
      each(items, iterator);
    }
  }
  var flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args));
  var isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
  var createStringInterpolator$1;
  var to;
  var colors$1 = null;
  var skipAnimation = false;
  var willAdvance = noop2;
  var assign = (globals2) => {
    if (globals2.to) to = globals2.to;
    if (globals2.now) raf.now = globals2.now;
    if (globals2.colors !== void 0) colors$1 = globals2.colors;
    if (globals2.skipAnimation != null) skipAnimation = globals2.skipAnimation;
    if (globals2.createStringInterpolator) createStringInterpolator$1 = globals2.createStringInterpolator;
    if (globals2.requestAnimationFrame) raf.use(globals2.requestAnimationFrame);
    if (globals2.batchedUpdates) raf.batchedUpdates = globals2.batchedUpdates;
    if (globals2.willAdvance) willAdvance = globals2.willAdvance;
    if (globals2.frameLoop) raf.frameLoop = globals2.frameLoop;
  };
  var globals = /* @__PURE__ */ Object.freeze({
    __proto__: null,
    get createStringInterpolator() {
      return createStringInterpolator$1;
    },
    get to() {
      return to;
    },
    get colors() {
      return colors$1;
    },
    get skipAnimation() {
      return skipAnimation;
    },
    get willAdvance() {
      return willAdvance;
    },
    assign
  });
  var startQueue = /* @__PURE__ */ new Set();
  var currentFrame = [];
  var prevFrame = [];
  var priority = 0;
  var frameLoop = {
    get idle() {
      return !startQueue.size && !currentFrame.length;
    },
    start(animation) {
      if (priority > animation.priority) {
        startQueue.add(animation);
        raf.onStart(flushStartQueue);
      } else {
        startSafely(animation);
        raf(advance);
      }
    },
    advance,
    sort(animation) {
      if (priority) {
        raf.onFrame(() => frameLoop.sort(animation));
      } else {
        const prevIndex = currentFrame.indexOf(animation);
        if (~prevIndex) {
          currentFrame.splice(prevIndex, 1);
          startUnsafely(animation);
        }
      }
    },
    clear() {
      currentFrame = [];
      startQueue.clear();
    }
  };
  function flushStartQueue() {
    startQueue.forEach(startSafely);
    startQueue.clear();
    raf(advance);
  }
  function startSafely(animation) {
    if (!currentFrame.includes(animation)) startUnsafely(animation);
  }
  function startUnsafely(animation) {
    currentFrame.splice(findIndex(currentFrame, (other) => other.priority > animation.priority), 0, animation);
  }
  function advance(dt) {
    const nextFrame = prevFrame;
    for (let i3 = 0; i3 < currentFrame.length; i3++) {
      const animation = currentFrame[i3];
      priority = animation.priority;
      if (!animation.idle) {
        willAdvance(animation);
        animation.advance(dt);
        if (!animation.idle) {
          nextFrame.push(animation);
        }
      }
    }
    priority = 0;
    prevFrame = currentFrame;
    prevFrame.length = 0;
    currentFrame = nextFrame;
    return currentFrame.length > 0;
  }
  function findIndex(arr, test) {
    const index = arr.findIndex(test);
    return index < 0 ? arr.length : index;
  }
  var colors = {
    transparent: 0,
    aliceblue: 4042850303,
    antiquewhite: 4209760255,
    aqua: 16777215,
    aquamarine: 2147472639,
    azure: 4043309055,
    beige: 4126530815,
    bisque: 4293182719,
    black: 255,
    blanchedalmond: 4293643775,
    blue: 65535,
    blueviolet: 2318131967,
    brown: 2771004159,
    burlywood: 3736635391,
    burntsienna: 3934150143,
    cadetblue: 1604231423,
    chartreuse: 2147418367,
    chocolate: 3530104575,
    coral: 4286533887,
    cornflowerblue: 1687547391,
    cornsilk: 4294499583,
    crimson: 3692313855,
    cyan: 16777215,
    darkblue: 35839,
    darkcyan: 9145343,
    darkgoldenrod: 3095792639,
    darkgray: 2846468607,
    darkgreen: 6553855,
    darkgrey: 2846468607,
    darkkhaki: 3182914559,
    darkmagenta: 2332068863,
    darkolivegreen: 1433087999,
    darkorange: 4287365375,
    darkorchid: 2570243327,
    darkred: 2332033279,
    darksalmon: 3918953215,
    darkseagreen: 2411499519,
    darkslateblue: 1211993087,
    darkslategray: 793726975,
    darkslategrey: 793726975,
    darkturquoise: 13554175,
    darkviolet: 2483082239,
    deeppink: 4279538687,
    deepskyblue: 12582911,
    dimgray: 1768516095,
    dimgrey: 1768516095,
    dodgerblue: 512819199,
    firebrick: 2988581631,
    floralwhite: 4294635775,
    forestgreen: 579543807,
    fuchsia: 4278255615,
    gainsboro: 3705462015,
    ghostwhite: 4177068031,
    gold: 4292280575,
    goldenrod: 3668254975,
    gray: 2155905279,
    green: 8388863,
    greenyellow: 2919182335,
    grey: 2155905279,
    honeydew: 4043305215,
    hotpink: 4285117695,
    indianred: 3445382399,
    indigo: 1258324735,
    ivory: 4294963455,
    khaki: 4041641215,
    lavender: 3873897215,
    lavenderblush: 4293981695,
    lawngreen: 2096890111,
    lemonchiffon: 4294626815,
    lightblue: 2916673279,
    lightcoral: 4034953471,
    lightcyan: 3774873599,
    lightgoldenrodyellow: 4210742015,
    lightgray: 3553874943,
    lightgreen: 2431553791,
    lightgrey: 3553874943,
    lightpink: 4290167295,
    lightsalmon: 4288707327,
    lightseagreen: 548580095,
    lightskyblue: 2278488831,
    lightslategray: 2005441023,
    lightslategrey: 2005441023,
    lightsteelblue: 2965692159,
    lightyellow: 4294959359,
    lime: 16711935,
    limegreen: 852308735,
    linen: 4210091775,
    magenta: 4278255615,
    maroon: 2147483903,
    mediumaquamarine: 1724754687,
    mediumblue: 52735,
    mediumorchid: 3126187007,
    mediumpurple: 2473647103,
    mediumseagreen: 1018393087,
    mediumslateblue: 2070474495,
    mediumspringgreen: 16423679,
    mediumturquoise: 1221709055,
    mediumvioletred: 3340076543,
    midnightblue: 421097727,
    mintcream: 4127193855,
    mistyrose: 4293190143,
    moccasin: 4293178879,
    navajowhite: 4292783615,
    navy: 33023,
    oldlace: 4260751103,
    olive: 2155872511,
    olivedrab: 1804477439,
    orange: 4289003775,
    orangered: 4282712319,
    orchid: 3664828159,
    palegoldenrod: 4008225535,
    palegreen: 2566625535,
    paleturquoise: 2951671551,
    palevioletred: 3681588223,
    papayawhip: 4293907967,
    peachpuff: 4292524543,
    peru: 3448061951,
    pink: 4290825215,
    plum: 3718307327,
    powderblue: 2967529215,
    purple: 2147516671,
    rebeccapurple: 1714657791,
    red: 4278190335,
    rosybrown: 3163525119,
    royalblue: 1097458175,
    saddlebrown: 2336560127,
    salmon: 4202722047,
    sandybrown: 4104413439,
    seagreen: 780883967,
    seashell: 4294307583,
    sienna: 2689740287,
    silver: 3233857791,
    skyblue: 2278484991,
    slateblue: 1784335871,
    slategray: 1887473919,
    slategrey: 1887473919,
    snow: 4294638335,
    springgreen: 16744447,
    steelblue: 1182971135,
    tan: 3535047935,
    teal: 8421631,
    thistle: 3636451583,
    tomato: 4284696575,
    turquoise: 1088475391,
    violet: 4001558271,
    wheat: 4125012991,
    white: 4294967295,
    whitesmoke: 4126537215,
    yellow: 4294902015,
    yellowgreen: 2597139199
  };
  var NUMBER = "[-+]?\\d*\\.?\\d+";
  var PERCENTAGE = NUMBER + "%";
  function call(...parts) {
    return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)";
  }
  var rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER));
  var rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER));
  var hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE));
  var hsla = new RegExp("hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
  var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
  var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
  var hex6 = /^#([0-9a-fA-F]{6})$/;
  var hex8 = /^#([0-9a-fA-F]{8})$/;
  function normalizeColor(color) {
    let match3;
    if (typeof color === "number") {
      return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null;
    }
    if (match3 = hex6.exec(color)) return parseInt(match3[1] + "ff", 16) >>> 0;
    if (colors$1 && colors$1[color] !== void 0) {
      return colors$1[color];
    }
    if (match3 = rgb.exec(color)) {
      return (parse255(match3[1]) << 24 | parse255(match3[2]) << 16 | parse255(match3[3]) << 8 | 255) >>> 0;
    }
    if (match3 = rgba.exec(color)) {
      return (parse255(match3[1]) << 24 | parse255(match3[2]) << 16 | parse255(match3[3]) << 8 | parse1(match3[4])) >>> 0;
    }
    if (match3 = hex3.exec(color)) {
      return parseInt(match3[1] + match3[1] + match3[2] + match3[2] + match3[3] + match3[3] + "ff", 16) >>> 0;
    }
    if (match3 = hex8.exec(color)) return parseInt(match3[1], 16) >>> 0;
    if (match3 = hex4.exec(color)) {
      return parseInt(match3[1] + match3[1] + match3[2] + match3[2] + match3[3] + match3[3] + match3[4] + match3[4], 16) >>> 0;
    }
    if (match3 = hsl.exec(color)) {
      return (hslToRgb(parse360(match3[1]), parsePercentage(match3[2]), parsePercentage(match3[3])) | 255) >>> 0;
    }
    if (match3 = hsla.exec(color)) {
      return (hslToRgb(parse360(match3[1]), parsePercentage(match3[2]), parsePercentage(match3[3])) | parse1(match3[4])) >>> 0;
    }
    return null;
  }
  function hue2rgb(p4, q, t4) {
    if (t4 < 0) t4 += 1;
    if (t4 > 1) t4 -= 1;
    if (t4 < 1 / 6) return p4 + (q - p4) * 6 * t4;
    if (t4 < 1 / 2) return q;
    if (t4 < 2 / 3) return p4 + (q - p4) * (2 / 3 - t4) * 6;
    return p4;
  }
  function hslToRgb(h3, s3, l3) {
    const q = l3 < 0.5 ? l3 * (1 + s3) : l3 + s3 - l3 * s3;
    const p4 = 2 * l3 - q;
    const r4 = hue2rgb(p4, q, h3 + 1 / 3);
    const g3 = hue2rgb(p4, q, h3);
    const b3 = hue2rgb(p4, q, h3 - 1 / 3);
    return Math.round(r4 * 255) << 24 | Math.round(g3 * 255) << 16 | Math.round(b3 * 255) << 8;
  }
  function parse255(str3) {
    const int = parseInt(str3, 10);
    if (int < 0) return 0;
    if (int > 255) return 255;
    return int;
  }
  function parse360(str3) {
    const int = parseFloat(str3);
    return (int % 360 + 360) % 360 / 360;
  }
  function parse1(str3) {
    const num = parseFloat(str3);
    if (num < 0) return 0;
    if (num > 1) return 255;
    return Math.round(num * 255);
  }
  function parsePercentage(str3) {
    const int = parseFloat(str3);
    if (int < 0) return 0;
    if (int > 100) return 1;
    return int / 100;
  }
  function colorToRgba(input) {
    let int32Color = normalizeColor(input);
    if (int32Color === null) return input;
    int32Color = int32Color || 0;
    let r4 = (int32Color & 4278190080) >>> 24;
    let g3 = (int32Color & 16711680) >>> 16;
    let b3 = (int32Color & 65280) >>> 8;
    let a3 = (int32Color & 255) / 255;
    return `rgba(${r4}, ${g3}, ${b3}, ${a3})`;
  }
  var createInterpolator = (range, output, extrapolate) => {
    if (is.fun(range)) {
      return range;
    }
    if (is.arr(range)) {
      return createInterpolator({
        range,
        output,
        extrapolate
      });
    }
    if (is.str(range.output[0])) {
      return createStringInterpolator$1(range);
    }
    const config2 = range;
    const outputRange = config2.output;
    const inputRange = config2.range || [0, 1];
    const extrapolateLeft = config2.extrapolateLeft || config2.extrapolate || "extend";
    const extrapolateRight = config2.extrapolateRight || config2.extrapolate || "extend";
    const easing = config2.easing || ((t4) => t4);
    return (input) => {
      const range2 = findRange(input, inputRange);
      return interpolate(input, inputRange[range2], inputRange[range2 + 1], outputRange[range2], outputRange[range2 + 1], easing, extrapolateLeft, extrapolateRight, config2.map);
    };
  };
  function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
    let result = map ? map(input) : input;
    if (result < inputMin) {
      if (extrapolateLeft === "identity") return result;
      else if (extrapolateLeft === "clamp") result = inputMin;
    }
    if (result > inputMax) {
      if (extrapolateRight === "identity") return result;
      else if (extrapolateRight === "clamp") result = inputMax;
    }
    if (outputMin === outputMax) return outputMin;
    if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax;
    if (inputMin === -Infinity) result = -result;
    else if (inputMax === Infinity) result = result - inputMin;
    else result = (result - inputMin) / (inputMax - inputMin);
    result = easing(result);
    if (outputMin === -Infinity) result = -result;
    else if (outputMax === Infinity) result = result + outputMin;
    else result = result * (outputMax - outputMin) + outputMin;
    return result;
  }
  function findRange(input, inputRange) {
    for (var i3 = 1; i3 < inputRange.length - 1; ++i3) if (inputRange[i3] >= input) break;
    return i3 - 1;
  }
  function _extends() {
    _extends = Object.assign ? Object.assign.bind() : function(target) {
      for (var i3 = 1; i3 < arguments.length; i3++) {
        var source = arguments[i3];
        for (var key in source) {
          if (Object.prototype.hasOwnProperty.call(source, key)) {
            target[key] = source[key];
          }
        }
      }
      return target;
    };
    return _extends.apply(this, arguments);
  }
  var $get = /* @__PURE__ */ Symbol.for("FluidValue.get");
  var $observers = /* @__PURE__ */ Symbol.for("FluidValue.observers");
  var hasFluidValue = (arg) => Boolean(arg && arg[$get]);
  var getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg;
  var getFluidObservers = (target) => target[$observers] || null;
  function callFluidObserver(observer, event) {
    if (observer.eventObserved) {
      observer.eventObserved(event);
    } else {
      observer(event);
    }
  }
  function callFluidObservers(target, event) {
    let observers = target[$observers];
    if (observers) {
      observers.forEach((observer) => {
        callFluidObserver(observer, event);
      });
    }
  }
  var FluidValue = class {
    constructor(get) {
      this[$get] = void 0;
      this[$observers] = void 0;
      if (!get && !(get = this.get)) {
        throw Error("Unknown getter");
      }
      setFluidGetter(this, get);
    }
  };
  var setFluidGetter = (target, get) => setHidden(target, $get, get);
  function addFluidObserver(target, observer) {
    if (target[$get]) {
      let observers = target[$observers];
      if (!observers) {
        setHidden(target, $observers, observers = /* @__PURE__ */ new Set());
      }
      if (!observers.has(observer)) {
        observers.add(observer);
        if (target.observerAdded) {
          target.observerAdded(observers.size, observer);
        }
      }
    }
    return observer;
  }
  function removeFluidObserver(target, observer) {
    let observers = target[$observers];
    if (observers && observers.has(observer)) {
      const count = observers.size - 1;
      if (count) {
        observers.delete(observer);
      } else {
        target[$observers] = null;
      }
      if (target.observerRemoved) {
        target.observerRemoved(count, observer);
      }
    }
  }
  var setHidden = (target, key, value) => Object.defineProperty(target, key, {
    value,
    writable: true,
    configurable: true
  });
  var numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
  var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
  var unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, "i");
  var rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
  var cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
  var variableToRgba = (input) => {
    const [token, fallback] = parseCSSVariable(input);
    if (!token || isSSR()) {
      return input;
    }
    const value = window.getComputedStyle(document.documentElement).getPropertyValue(token);
    if (value) {
      return value.trim();
    } else if (fallback && fallback.startsWith("--")) {
      const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback);
      if (_value) {
        return _value;
      } else {
        return input;
      }
    } else if (fallback && cssVariableRegex.test(fallback)) {
      return variableToRgba(fallback);
    } else if (fallback) {
      return fallback;
    }
    return input;
  };
  var parseCSSVariable = (current) => {
    const match3 = cssVariableRegex.exec(current);
    if (!match3) return [,];
    const [, token, fallback] = match3;
    return [token, fallback];
  };
  var namedColorRegex;
  var rgbaRound = (_, p1, p22, p32, p4) => `rgba(${Math.round(p1)}, ${Math.round(p22)}, ${Math.round(p32)}, ${p4})`;
  var createStringInterpolator = (config2) => {
    if (!namedColorRegex) namedColorRegex = colors$1 ? new RegExp(`(${Object.keys(colors$1).join("|")})(?!\\w)`, "g") : /^\b$/;
    const output = config2.output.map((value) => {
      return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba);
    });
    const keyframes = output.map((value) => value.match(numberRegex).map(Number));
    const outputRanges = keyframes[0].map((_, i3) => keyframes.map((values) => {
      if (!(i3 in values)) {
        throw Error('The arity of each "output" value must be equal');
      }
      return values[i3];
    }));
    const interpolators = outputRanges.map((output2) => createInterpolator(_extends({}, config2, {
      output: output2
    })));
    return (input) => {
      var _output$find;
      const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find((value) => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, ""));
      let i3 = 0;
      return output[0].replace(numberRegex, () => `${interpolators[i3++](input)}${missingUnit || ""}`).replace(rgbaRegex, rgbaRound);
    };
  };
  var prefix = "react-spring: ";
  var once = (fn) => {
    const func = fn;
    let called = false;
    if (typeof func != "function") {
      throw new TypeError(`${prefix}once requires a function parameter`);
    }
    return (...args) => {
      if (!called) {
        func(...args);
        called = true;
      }
    };
  };
  var warnInterpolate = once(console.warn);
  function deprecateInterpolate() {
    warnInterpolate(`${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`);
  }
  var warnDirectCall = once(console.warn);
  function isAnimatedString(value) {
    return is.str(value) && (value[0] == "#" || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {}));
  }
  var useIsomorphicLayoutEffect = isSSR() ? import_react9.useEffect : import_react9.useLayoutEffect;
  var useIsMounted = () => {
    const isMounted = (0, import_react9.useRef)(false);
    useIsomorphicLayoutEffect(() => {
      isMounted.current = true;
      return () => {
        isMounted.current = false;
      };
    }, []);
    return isMounted;
  };
  function useForceUpdate() {
    const update4 = (0, import_react9.useState)()[1];
    const isMounted = useIsMounted();
    return () => {
      if (isMounted.current) {
        update4(Math.random());
      }
    };
  }
  function useMemoOne(getResult, inputs) {
    const [initial] = (0, import_react9.useState)(() => ({
      inputs,
      result: getResult()
    }));
    const committed = (0, import_react9.useRef)();
    const prevCache = committed.current;
    let cache = prevCache;
    if (cache) {
      const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs));
      if (!useCache) {
        cache = {
          inputs,
          result: getResult()
        };
      }
    } else {
      cache = initial;
    }
    (0, import_react9.useEffect)(() => {
      committed.current = cache;
      if (prevCache == initial) {
        initial.inputs = initial.result = void 0;
      }
    }, [cache]);
    return cache.result;
  }
  function areInputsEqual(next, prev) {
    if (next.length !== prev.length) {
      return false;
    }
    for (let i3 = 0; i3 < next.length; i3++) {
      if (next[i3] !== prev[i3]) {
        return false;
      }
    }
    return true;
  }
  var useOnce = (effect) => (0, import_react9.useEffect)(effect, emptyDeps);
  var emptyDeps = [];

  // node_modules/@react-spring/core/dist/react-spring-core.esm.js
  var React23 = __toESM(require_react());
  var import_react11 = __toESM(require_react());

  // node_modules/@react-spring/animated/dist/react-spring-animated.esm.js
  var React22 = __toESM(require_react());
  var import_react10 = __toESM(require_react());
  var $node = /* @__PURE__ */ Symbol.for("Animated:node");
  var isAnimated = (value) => !!value && value[$node] === value;
  var getAnimated = (owner) => owner && owner[$node];
  var setAnimated = (owner, node) => defineHidden(owner, $node, node);
  var getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload();
  var Animated = class {
    constructor() {
      this.payload = void 0;
      setAnimated(this, this);
    }
    getPayload() {
      return this.payload || [];
    }
  };
  var AnimatedValue = class _AnimatedValue extends Animated {
    constructor(_value) {
      super();
      this.done = true;
      this.elapsedTime = void 0;
      this.lastPosition = void 0;
      this.lastVelocity = void 0;
      this.v0 = void 0;
      this.durationProgress = 0;
      this._value = _value;
      if (is.num(this._value)) {
        this.lastPosition = this._value;
      }
    }
    static create(value) {
      return new _AnimatedValue(value);
    }
    getPayload() {
      return [this];
    }
    getValue() {
      return this._value;
    }
    setValue(value, step) {
      if (is.num(value)) {
        this.lastPosition = value;
        if (step) {
          value = Math.round(value / step) * step;
          if (this.done) {
            this.lastPosition = value;
          }
        }
      }
      if (this._value === value) {
        return false;
      }
      this._value = value;
      return true;
    }
    reset() {
      const {
        done
      } = this;
      this.done = false;
      if (is.num(this._value)) {
        this.elapsedTime = 0;
        this.durationProgress = 0;
        this.lastPosition = this._value;
        if (done) this.lastVelocity = null;
        this.v0 = null;
      }
    }
  };
  var AnimatedString = class _AnimatedString extends AnimatedValue {
    constructor(value) {
      super(0);
      this._string = null;
      this._toString = void 0;
      this._toString = createInterpolator({
        output: [value, value]
      });
    }
    static create(value) {
      return new _AnimatedString(value);
    }
    getValue() {
      let value = this._string;
      return value == null ? this._string = this._toString(this._value) : value;
    }
    setValue(value) {
      if (is.str(value)) {
        if (value == this._string) {
          return false;
        }
        this._string = value;
        this._value = 1;
      } else if (super.setValue(value)) {
        this._string = null;
      } else {
        return false;
      }
      return true;
    }
    reset(goal) {
      if (goal) {
        this._toString = createInterpolator({
          output: [this.getValue(), goal]
        });
      }
      this._value = 0;
      super.reset();
    }
  };
  var TreeContext = {
    dependencies: null
  };
  var AnimatedObject = class extends Animated {
    constructor(source) {
      super();
      this.source = source;
      this.setValue(source);
    }
    getValue(animated2) {
      const values = {};
      eachProp(this.source, (source, key) => {
        if (isAnimated(source)) {
          values[key] = source.getValue(animated2);
        } else if (hasFluidValue(source)) {
          values[key] = getFluidValue(source);
        } else if (!animated2) {
          values[key] = source;
        }
      });
      return values;
    }
    setValue(source) {
      this.source = source;
      this.payload = this._makePayload(source);
    }
    reset() {
      if (this.payload) {
        each(this.payload, (node) => node.reset());
      }
    }
    _makePayload(source) {
      if (source) {
        const payload = /* @__PURE__ */ new Set();
        eachProp(source, this._addToPayload, payload);
        return Array.from(payload);
      }
    }
    _addToPayload(source) {
      if (TreeContext.dependencies && hasFluidValue(source)) {
        TreeContext.dependencies.add(source);
      }
      const payload = getPayload(source);
      if (payload) {
        each(payload, (node) => this.add(node));
      }
    }
  };
  var AnimatedArray = class _AnimatedArray extends AnimatedObject {
    constructor(source) {
      super(source);
    }
    static create(source) {
      return new _AnimatedArray(source);
    }
    getValue() {
      return this.source.map((node) => node.getValue());
    }
    setValue(source) {
      const payload = this.getPayload();
      if (source.length == payload.length) {
        return payload.map((node, i3) => node.setValue(source[i3])).some(Boolean);
      }
      super.setValue(source.map(makeAnimated));
      return true;
    }
  };
  function makeAnimated(value) {
    const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
    return nodeType.create(value);
  }
  function getAnimatedType(value) {
    const parentNode = getAnimated(value);
    return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
  }
  function _extends2() {
    _extends2 = Object.assign ? Object.assign.bind() : function(target) {
      for (var i3 = 1; i3 < arguments.length; i3++) {
        var source = arguments[i3];
        for (var key in source) {
          if (Object.prototype.hasOwnProperty.call(source, key)) {
            target[key] = source[key];
          }
        }
      }
      return target;
    };
    return _extends2.apply(this, arguments);
  }
  var withAnimated = (Component6, host2) => {
    const hasInstance = !is.fun(Component6) || Component6.prototype && Component6.prototype.isReactComponent;
    return (0, import_react10.forwardRef)((givenProps, givenRef) => {
      const instanceRef = (0, import_react10.useRef)(null);
      const ref = hasInstance && (0, import_react10.useCallback)((value) => {
        instanceRef.current = updateRef(givenRef, value);
      }, [givenRef]);
      const [props, deps] = getAnimatedState(givenProps, host2);
      const forceUpdate = useForceUpdate();
      const callback = () => {
        const instance = instanceRef.current;
        if (hasInstance && !instance) {
          return;
        }
        const didUpdate = instance ? host2.applyAnimatedValues(instance, props.getValue(true)) : false;
        if (didUpdate === false) {
          forceUpdate();
        }
      };
      const observer = new PropsObserver(callback, deps);
      const observerRef = (0, import_react10.useRef)();
      useIsomorphicLayoutEffect(() => {
        observerRef.current = observer;
        each(deps, (dep) => addFluidObserver(dep, observer));
        return () => {
          if (observerRef.current) {
            each(observerRef.current.deps, (dep) => removeFluidObserver(dep, observerRef.current));
            raf.cancel(observerRef.current.update);
          }
        };
      });
      (0, import_react10.useEffect)(callback, []);
      useOnce(() => () => {
        const observer2 = observerRef.current;
        each(observer2.deps, (dep) => removeFluidObserver(dep, observer2));
      });
      const usedProps = host2.getComponentProps(props.getValue());
      return React22.createElement(Component6, _extends2({}, usedProps, {
        ref
      }));
    });
  };
  var PropsObserver = class {
    constructor(update4, deps) {
      this.update = update4;
      this.deps = deps;
    }
    eventObserved(event) {
      if (event.type == "change") {
        raf.write(this.update);
      }
    }
  };
  function getAnimatedState(props, host2) {
    const dependencies = /* @__PURE__ */ new Set();
    TreeContext.dependencies = dependencies;
    if (props.style) props = _extends2({}, props, {
      style: host2.createAnimatedStyle(props.style)
    });
    props = new AnimatedObject(props);
    TreeContext.dependencies = null;
    return [props, dependencies];
  }
  function updateRef(ref, value) {
    if (ref) {
      if (is.fun(ref)) ref(value);
      else ref.current = value;
    }
    return value;
  }
  var cacheKey = /* @__PURE__ */ Symbol.for("AnimatedComponent");
  var createHost = (components, {
    applyAnimatedValues: _applyAnimatedValues = () => false,
    createAnimatedStyle: _createAnimatedStyle = (style) => new AnimatedObject(style),
    getComponentProps: _getComponentProps = (props) => props
  } = {}) => {
    const hostConfig = {
      applyAnimatedValues: _applyAnimatedValues,
      createAnimatedStyle: _createAnimatedStyle,
      getComponentProps: _getComponentProps
    };
    const animated2 = (Component6) => {
      const displayName = getDisplayName(Component6) || "Anonymous";
      if (is.str(Component6)) {
        Component6 = animated2[Component6] || (animated2[Component6] = withAnimated(Component6, hostConfig));
      } else {
        Component6 = Component6[cacheKey] || (Component6[cacheKey] = withAnimated(Component6, hostConfig));
      }
      Component6.displayName = `Animated(${displayName})`;
      return Component6;
    };
    eachProp(components, (Component6, key) => {
      if (is.arr(components)) {
        key = getDisplayName(Component6);
      }
      animated2[key] = animated2(Component6);
    });
    return {
      animated: animated2
    };
  };
  var getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null;

  // node_modules/@react-spring/core/dist/react-spring-core.esm.js
  function _extends3() {
    _extends3 = Object.assign ? Object.assign.bind() : function(target) {
      for (var i3 = 1; i3 < arguments.length; i3++) {
        var source = arguments[i3];
        for (var key in source) {
          if (Object.prototype.hasOwnProperty.call(source, key)) {
            target[key] = source[key];
          }
        }
      }
      return target;
    };
    return _extends3.apply(this, arguments);
  }
  function callProp(value, ...args) {
    return is.fun(value) ? value(...args) : value;
  }
  var matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key)));
  var resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop;
  var getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
  var noopTransform = (value) => value;
  var getDefaultProps = (props, transform = noopTransform) => {
    let keys = DEFAULT_PROPS;
    if (props.default && props.default !== true) {
      props = props.default;
      keys = Object.keys(props);
    }
    const defaults2 = {};
    for (const key of keys) {
      const value = transform(props[key], key);
      if (!is.und(value)) {
        defaults2[key] = value;
      }
    }
    return defaults2;
  };
  var DEFAULT_PROPS = ["config", "onProps", "onStart", "onChange", "onPause", "onResume", "onRest"];
  var RESERVED_PROPS = {
    config: 1,
    from: 1,
    to: 1,
    ref: 1,
    loop: 1,
    reset: 1,
    pause: 1,
    cancel: 1,
    reverse: 1,
    immediate: 1,
    default: 1,
    delay: 1,
    onProps: 1,
    onStart: 1,
    onChange: 1,
    onPause: 1,
    onResume: 1,
    onRest: 1,
    onResolve: 1,
    items: 1,
    trail: 1,
    sort: 1,
    expires: 1,
    initial: 1,
    enter: 1,
    update: 1,
    leave: 1,
    children: 1,
    onDestroyed: 1,
    keys: 1,
    callId: 1,
    parentId: 1
  };
  function getForwardProps(props) {
    const forward = {};
    let count = 0;
    eachProp(props, (value, prop) => {
      if (!RESERVED_PROPS[prop]) {
        forward[prop] = value;
        count++;
      }
    });
    if (count) {
      return forward;
    }
  }
  function inferTo(props) {
    const to2 = getForwardProps(props);
    if (to2) {
      const out = {
        to: to2
      };
      eachProp(props, (val, key) => key in to2 || (out[key] = val));
      return out;
    }
    return _extends3({}, props);
  }
  function computeGoal(value) {
    value = getFluidValue(value);
    return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({
      range: [0, 1],
      output: [value, value]
    })(1) : value;
  }
  function isAsyncTo(to2) {
    return is.fun(to2) || is.arr(to2) && is.obj(to2[0]);
  }
  var config = {
    default: {
      tension: 170,
      friction: 26
    },
    gentle: {
      tension: 120,
      friction: 14
    },
    wobbly: {
      tension: 180,
      friction: 12
    },
    stiff: {
      tension: 210,
      friction: 20
    },
    slow: {
      tension: 280,
      friction: 60
    },
    molasses: {
      tension: 280,
      friction: 120
    }
  };
  var c1 = 1.70158;
  var c2 = c1 * 1.525;
  var c3 = c1 + 1;
  var c4 = 2 * Math.PI / 3;
  var c5 = 2 * Math.PI / 4.5;
  var bounceOut = (x2) => {
    const n1 = 7.5625;
    const d1 = 2.75;
    if (x2 < 1 / d1) {
      return n1 * x2 * x2;
    } else if (x2 < 2 / d1) {
      return n1 * (x2 -= 1.5 / d1) * x2 + 0.75;
    } else if (x2 < 2.5 / d1) {
      return n1 * (x2 -= 2.25 / d1) * x2 + 0.9375;
    } else {
      return n1 * (x2 -= 2.625 / d1) * x2 + 0.984375;
    }
  };
  var easings = {
    linear: (x2) => x2,
    easeInQuad: (x2) => x2 * x2,
    easeOutQuad: (x2) => 1 - (1 - x2) * (1 - x2),
    easeInOutQuad: (x2) => x2 < 0.5 ? 2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 2) / 2,
    easeInCubic: (x2) => x2 * x2 * x2,
    easeOutCubic: (x2) => 1 - Math.pow(1 - x2, 3),
    easeInOutCubic: (x2) => x2 < 0.5 ? 4 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 3) / 2,
    easeInQuart: (x2) => x2 * x2 * x2 * x2,
    easeOutQuart: (x2) => 1 - Math.pow(1 - x2, 4),
    easeInOutQuart: (x2) => x2 < 0.5 ? 8 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 4) / 2,
    easeInQuint: (x2) => x2 * x2 * x2 * x2 * x2,
    easeOutQuint: (x2) => 1 - Math.pow(1 - x2, 5),
    easeInOutQuint: (x2) => x2 < 0.5 ? 16 * x2 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 5) / 2,
    easeInSine: (x2) => 1 - Math.cos(x2 * Math.PI / 2),
    easeOutSine: (x2) => Math.sin(x2 * Math.PI / 2),
    easeInOutSine: (x2) => -(Math.cos(Math.PI * x2) - 1) / 2,
    easeInExpo: (x2) => x2 === 0 ? 0 : Math.pow(2, 10 * x2 - 10),
    easeOutExpo: (x2) => x2 === 1 ? 1 : 1 - Math.pow(2, -10 * x2),
    easeInOutExpo: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : x2 < 0.5 ? Math.pow(2, 20 * x2 - 10) / 2 : (2 - Math.pow(2, -20 * x2 + 10)) / 2,
    easeInCirc: (x2) => 1 - Math.sqrt(1 - Math.pow(x2, 2)),
    easeOutCirc: (x2) => Math.sqrt(1 - Math.pow(x2 - 1, 2)),
    easeInOutCirc: (x2) => x2 < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x2, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x2 + 2, 2)) + 1) / 2,
    easeInBack: (x2) => c3 * x2 * x2 * x2 - c1 * x2 * x2,
    easeOutBack: (x2) => 1 + c3 * Math.pow(x2 - 1, 3) + c1 * Math.pow(x2 - 1, 2),
    easeInOutBack: (x2) => x2 < 0.5 ? Math.pow(2 * x2, 2) * ((c2 + 1) * 2 * x2 - c2) / 2 : (Math.pow(2 * x2 - 2, 2) * ((c2 + 1) * (x2 * 2 - 2) + c2) + 2) / 2,
    easeInElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : -Math.pow(2, 10 * x2 - 10) * Math.sin((x2 * 10 - 10.75) * c4),
    easeOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : Math.pow(2, -10 * x2) * Math.sin((x2 * 10 - 0.75) * c4) + 1,
    easeInOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : x2 < 0.5 ? -(Math.pow(2, 20 * x2 - 10) * Math.sin((20 * x2 - 11.125) * c5)) / 2 : Math.pow(2, -20 * x2 + 10) * Math.sin((20 * x2 - 11.125) * c5) / 2 + 1,
    easeInBounce: (x2) => 1 - bounceOut(1 - x2),
    easeOutBounce: bounceOut,
    easeInOutBounce: (x2) => x2 < 0.5 ? (1 - bounceOut(1 - 2 * x2)) / 2 : (1 + bounceOut(2 * x2 - 1)) / 2
  };
  var defaults = _extends3({}, config.default, {
    mass: 1,
    damping: 1,
    easing: easings.linear,
    clamp: false
  });
  var AnimationConfig = class {
    constructor() {
      this.tension = void 0;
      this.friction = void 0;
      this.frequency = void 0;
      this.damping = void 0;
      this.mass = void 0;
      this.velocity = 0;
      this.restVelocity = void 0;
      this.precision = void 0;
      this.progress = void 0;
      this.duration = void 0;
      this.easing = void 0;
      this.clamp = void 0;
      this.bounce = void 0;
      this.decay = void 0;
      this.round = void 0;
      Object.assign(this, defaults);
    }
  };
  function mergeConfig(config2, newConfig, defaultConfig) {
    if (defaultConfig) {
      defaultConfig = _extends3({}, defaultConfig);
      sanitizeConfig(defaultConfig, newConfig);
      newConfig = _extends3({}, defaultConfig, newConfig);
    }
    sanitizeConfig(config2, newConfig);
    Object.assign(config2, newConfig);
    for (const key in defaults) {
      if (config2[key] == null) {
        config2[key] = defaults[key];
      }
    }
    let {
      mass,
      frequency,
      damping
    } = config2;
    if (!is.und(frequency)) {
      if (frequency < 0.01) frequency = 0.01;
      if (damping < 0) damping = 0;
      config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
      config2.friction = 4 * Math.PI * damping * mass / frequency;
    }
    return config2;
  }
  function sanitizeConfig(config2, props) {
    if (!is.und(props.decay)) {
      config2.duration = void 0;
    } else {
      const isTensionConfig = !is.und(props.tension) || !is.und(props.friction);
      if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) {
        config2.duration = void 0;
        config2.decay = void 0;
      }
      if (isTensionConfig) {
        config2.frequency = void 0;
      }
    }
  }
  var emptyArray = [];
  var Animation = class {
    constructor() {
      this.changed = false;
      this.values = emptyArray;
      this.toValues = null;
      this.fromValues = emptyArray;
      this.to = void 0;
      this.from = void 0;
      this.config = new AnimationConfig();
      this.immediate = false;
    }
  };
  function scheduleProps(callId, {
    key,
    props,
    defaultProps,
    state,
    actions: actions2
  }) {
    return new Promise((resolve, reject) => {
      var _props$cancel;
      let delay;
      let timeout;
      let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps == null ? void 0 : defaultProps.cancel, key);
      if (cancel) {
        onStart();
      } else {
        if (!is.und(props.pause)) {
          state.paused = matchProp(props.pause, key);
        }
        let pause = defaultProps == null ? void 0 : defaultProps.pause;
        if (pause !== true) {
          pause = state.paused || matchProp(pause, key);
        }
        delay = callProp(props.delay || 0, key);
        if (pause) {
          state.resumeQueue.add(onResume);
          actions2.pause();
        } else {
          actions2.resume();
          onResume();
        }
      }
      function onPause() {
        state.resumeQueue.add(onResume);
        state.timeouts.delete(timeout);
        timeout.cancel();
        delay = timeout.time - raf.now();
      }
      function onResume() {
        if (delay > 0 && !globals.skipAnimation) {
          state.delayed = true;
          timeout = raf.setTimeout(onStart, delay);
          state.pauseQueue.add(onPause);
          state.timeouts.add(timeout);
        } else {
          onStart();
        }
      }
      function onStart() {
        if (state.delayed) {
          state.delayed = false;
        }
        state.pauseQueue.delete(onPause);
        state.timeouts.delete(timeout);
        if (callId <= (state.cancelId || 0)) {
          cancel = true;
        }
        try {
          actions2.start(_extends3({}, props, {
            callId,
            cancel
          }), resolve);
        } catch (err) {
          reject(err);
        }
      }
    });
  }
  var getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some((result) => result.cancelled) ? getCancelledResult(target.get()) : results.every((result) => result.noop) ? getNoopResult(target.get()) : getFinishedResult(target.get(), results.every((result) => result.finished));
  var getNoopResult = (value) => ({
    value,
    noop: true,
    finished: true,
    cancelled: false
  });
  var getFinishedResult = (value, finished, cancelled = false) => ({
    value,
    finished,
    cancelled
  });
  var getCancelledResult = (value) => ({
    value,
    cancelled: true,
    finished: false
  });
  function runAsync(to2, props, state, target) {
    const {
      callId,
      parentId,
      onRest
    } = props;
    const {
      asyncTo: prevTo,
      promise: prevPromise
    } = state;
    if (!parentId && to2 === prevTo && !props.reset) {
      return prevPromise;
    }
    return state.promise = (async () => {
      state.asyncId = callId;
      state.asyncTo = to2;
      const defaultProps = getDefaultProps(props, (value, key) => key === "onRest" ? void 0 : value);
      let preventBail;
      let bail;
      const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject));
      const bailIfEnded = (bailSignal) => {
        const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false);
        if (bailResult) {
          bailSignal.result = bailResult;
          bail(bailSignal);
          throw bailSignal;
        }
      };
      const animate = (arg1, arg2) => {
        const bailSignal = new BailSignal();
        const skipAnimationSignal = new SkipAniamtionSignal();
        return (async () => {
          if (globals.skipAnimation) {
            stopAsync(state);
            skipAnimationSignal.result = getFinishedResult(target, false);
            bail(skipAnimationSignal);
            throw skipAnimationSignal;
          }
          bailIfEnded(bailSignal);
          const props2 = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, {
            to: arg1
          });
          props2.parentId = callId;
          eachProp(defaultProps, (value, key) => {
            if (is.und(props2[key])) {
              props2[key] = value;
            }
          });
          const result2 = await target.start(props2);
          bailIfEnded(bailSignal);
          if (state.paused) {
            await new Promise((resume) => {
              state.resumeQueue.add(resume);
            });
          }
          return result2;
        })();
      };
      let result;
      if (globals.skipAnimation) {
        stopAsync(state);
        return getFinishedResult(target, false);
      }
      try {
        let animating;
        if (is.arr(to2)) {
          animating = (async (queue) => {
            for (const props2 of queue) {
              await animate(props2);
            }
          })(to2);
        } else {
          animating = Promise.resolve(to2(animate, target.stop.bind(target)));
        }
        await Promise.all([animating.then(preventBail), bailPromise]);
        result = getFinishedResult(target.get(), true, false);
      } catch (err) {
        if (err instanceof BailSignal) {
          result = err.result;
        } else if (err instanceof SkipAniamtionSignal) {
          result = err.result;
        } else {
          throw err;
        }
      } finally {
        if (callId == state.asyncId) {
          state.asyncId = parentId;
          state.asyncTo = parentId ? prevTo : void 0;
          state.promise = parentId ? prevPromise : void 0;
        }
      }
      if (is.fun(onRest)) {
        raf.batchedUpdates(() => {
          onRest(result, target, target.item);
        });
      }
      return result;
    })();
  }
  function stopAsync(state, cancelId) {
    flush(state.timeouts, (t4) => t4.cancel());
    state.pauseQueue.clear();
    state.resumeQueue.clear();
    state.asyncId = state.asyncTo = state.promise = void 0;
    if (cancelId) state.cancelId = cancelId;
  }
  var BailSignal = class extends Error {
    constructor() {
      super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise.");
      this.result = void 0;
    }
  };
  var SkipAniamtionSignal = class extends Error {
    constructor() {
      super("SkipAnimationSignal");
      this.result = void 0;
    }
  };
  var isFrameValue = (value) => value instanceof FrameValue;
  var nextId$1 = 1;
  var FrameValue = class extends FluidValue {
    constructor(...args) {
      super(...args);
      this.id = nextId$1++;
      this.key = void 0;
      this._priority = 0;
    }
    get priority() {
      return this._priority;
    }
    set priority(priority2) {
      if (this._priority != priority2) {
        this._priority = priority2;
        this._onPriorityChange(priority2);
      }
    }
    get() {
      const node = getAnimated(this);
      return node && node.getValue();
    }
    to(...args) {
      return globals.to(this, args);
    }
    interpolate(...args) {
      deprecateInterpolate();
      return globals.to(this, args);
    }
    toJSON() {
      return this.get();
    }
    observerAdded(count) {
      if (count == 1) this._attach();
    }
    observerRemoved(count) {
      if (count == 0) this._detach();
    }
    _attach() {
    }
    _detach() {
    }
    _onChange(value, idle = false) {
      callFluidObservers(this, {
        type: "change",
        parent: this,
        value,
        idle
      });
    }
    _onPriorityChange(priority2) {
      if (!this.idle) {
        frameLoop.sort(this);
      }
      callFluidObservers(this, {
        type: "priority",
        parent: this,
        priority: priority2
      });
    }
  };
  var $P = /* @__PURE__ */ Symbol.for("SpringPhase");
  var HAS_ANIMATED = 1;
  var IS_ANIMATING = 2;
  var IS_PAUSED = 4;
  var hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0;
  var isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0;
  var isPaused = (target) => (target[$P] & IS_PAUSED) > 0;
  var setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING;
  var setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED;
  var SpringValue = class extends FrameValue {
    constructor(arg1, arg2) {
      super();
      this.key = void 0;
      this.animation = new Animation();
      this.queue = void 0;
      this.defaultProps = {};
      this._state = {
        paused: false,
        delayed: false,
        pauseQueue: /* @__PURE__ */ new Set(),
        resumeQueue: /* @__PURE__ */ new Set(),
        timeouts: /* @__PURE__ */ new Set()
      };
      this._pendingCalls = /* @__PURE__ */ new Set();
      this._lastCallId = 0;
      this._lastToId = 0;
      this._memoizedDuration = 0;
      if (!is.und(arg1) || !is.und(arg2)) {
        const props = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, {
          from: arg1
        });
        if (is.und(props.default)) {
          props.default = true;
        }
        this.start(props);
      }
    }
    get idle() {
      return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
    }
    get goal() {
      return getFluidValue(this.animation.to);
    }
    get velocity() {
      const node = getAnimated(this);
      return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0);
    }
    get hasAnimated() {
      return hasAnimated(this);
    }
    get isAnimating() {
      return isAnimating(this);
    }
    get isPaused() {
      return isPaused(this);
    }
    get isDelayed() {
      return this._state.delayed;
    }
    advance(dt) {
      let idle = true;
      let changed = false;
      const anim = this.animation;
      let {
        config: config2,
        toValues
      } = anim;
      const payload = getPayload(anim.to);
      if (!payload && hasFluidValue(anim.to)) {
        toValues = toArray(getFluidValue(anim.to));
      }
      anim.values.forEach((node2, i3) => {
        if (node2.done) return;
        const to2 = node2.constructor == AnimatedString ? 1 : payload ? payload[i3].lastPosition : toValues[i3];
        let finished = anim.immediate;
        let position = to2;
        if (!finished) {
          position = node2.lastPosition;
          if (config2.tension <= 0) {
            node2.done = true;
            return;
          }
          let elapsed = node2.elapsedTime += dt;
          const from = anim.fromValues[i3];
          const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i3] : config2.velocity;
          let velocity;
          const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3));
          if (!is.und(config2.duration)) {
            let p4 = 1;
            if (config2.duration > 0) {
              if (this._memoizedDuration !== config2.duration) {
                this._memoizedDuration = config2.duration;
                if (node2.durationProgress > 0) {
                  node2.elapsedTime = config2.duration * node2.durationProgress;
                  elapsed = node2.elapsedTime += dt;
                }
              }
              p4 = (config2.progress || 0) + elapsed / this._memoizedDuration;
              p4 = p4 > 1 ? 1 : p4 < 0 ? 0 : p4;
              node2.durationProgress = p4;
            }
            position = from + config2.easing(p4) * (to2 - from);
            velocity = (position - node2.lastPosition) / dt;
            finished = p4 == 1;
          } else if (config2.decay) {
            const decay = config2.decay === true ? 0.998 : config2.decay;
            const e3 = Math.exp(-(1 - decay) * elapsed);
            position = from + v0 / (1 - decay) * (1 - e3);
            finished = Math.abs(node2.lastPosition - position) <= precision;
            velocity = v0 * e3;
          } else {
            velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity;
            const restVelocity = config2.restVelocity || precision / 10;
            const bounceFactor = config2.clamp ? 0 : config2.bounce;
            const canBounce = !is.und(bounceFactor);
            const isGrowing = from == to2 ? node2.v0 > 0 : from < to2;
            let isMoving;
            let isBouncing = false;
            const step = 1;
            const numSteps = Math.ceil(dt / step);
            for (let n3 = 0; n3 < numSteps; ++n3) {
              isMoving = Math.abs(velocity) > restVelocity;
              if (!isMoving) {
                finished = Math.abs(to2 - position) <= precision;
                if (finished) {
                  break;
                }
              }
              if (canBounce) {
                isBouncing = position == to2 || position > to2 == isGrowing;
                if (isBouncing) {
                  velocity = -velocity * bounceFactor;
                  position = to2;
                }
              }
              const springForce = -config2.tension * 1e-6 * (position - to2);
              const dampingForce = -config2.friction * 1e-3 * velocity;
              const acceleration = (springForce + dampingForce) / config2.mass;
              velocity = velocity + acceleration * step;
              position = position + velocity * step;
            }
          }
          node2.lastVelocity = velocity;
          if (Number.isNaN(position)) {
            console.warn(`Got NaN while animating:`, this);
            finished = true;
          }
        }
        if (payload && !payload[i3].done) {
          finished = false;
        }
        if (finished) {
          node2.done = true;
        } else {
          idle = false;
        }
        if (node2.setValue(position, config2.round)) {
          changed = true;
        }
      });
      const node = getAnimated(this);
      const currVal = node.getValue();
      if (idle) {
        const finalVal = getFluidValue(anim.to);
        if ((currVal !== finalVal || changed) && !config2.decay) {
          node.setValue(finalVal);
          this._onChange(finalVal);
        } else if (changed && config2.decay) {
          this._onChange(currVal);
        }
        this._stop();
      } else if (changed) {
        this._onChange(currVal);
      }
    }
    set(value) {
      raf.batchedUpdates(() => {
        this._stop();
        this._focus(value);
        this._set(value);
      });
      return this;
    }
    pause() {
      this._update({
        pause: true
      });
    }
    resume() {
      this._update({
        pause: false
      });
    }
    finish() {
      if (isAnimating(this)) {
        const {
          to: to2,
          config: config2
        } = this.animation;
        raf.batchedUpdates(() => {
          this._onStart();
          if (!config2.decay) {
            this._set(to2, false);
          }
          this._stop();
        });
      }
      return this;
    }
    update(props) {
      const queue = this.queue || (this.queue = []);
      queue.push(props);
      return this;
    }
    start(to2, arg2) {
      let queue;
      if (!is.und(to2)) {
        queue = [is.obj(to2) ? to2 : _extends3({}, arg2, {
          to: to2
        })];
      } else {
        queue = this.queue || [];
        this.queue = [];
      }
      return Promise.all(queue.map((props) => {
        const up = this._update(props);
        return up;
      })).then((results) => getCombinedResult(this, results));
    }
    stop(cancel) {
      const {
        to: to2
      } = this.animation;
      this._focus(this.get());
      stopAsync(this._state, cancel && this._lastCallId);
      raf.batchedUpdates(() => this._stop(to2, cancel));
      return this;
    }
    reset() {
      this._update({
        reset: true
      });
    }
    eventObserved(event) {
      if (event.type == "change") {
        this._start();
      } else if (event.type == "priority") {
        this.priority = event.priority + 1;
      }
    }
    _prepareNode(props) {
      const key = this.key || "";
      let {
        to: to2,
        from
      } = props;
      to2 = is.obj(to2) ? to2[key] : to2;
      if (to2 == null || isAsyncTo(to2)) {
        to2 = void 0;
      }
      from = is.obj(from) ? from[key] : from;
      if (from == null) {
        from = void 0;
      }
      const range = {
        to: to2,
        from
      };
      if (!hasAnimated(this)) {
        if (props.reverse) [to2, from] = [from, to2];
        from = getFluidValue(from);
        if (!is.und(from)) {
          this._set(from);
        } else if (!getAnimated(this)) {
          this._set(to2);
        }
      }
      return range;
    }
    _update(_ref, isLoop) {
      let props = _extends3({}, _ref);
      const {
        key,
        defaultProps
      } = this;
      if (props.default) Object.assign(defaultProps, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value));
      mergeActiveFn(this, props, "onProps");
      sendEvent(this, "onProps", props, this);
      const range = this._prepareNode(props);
      if (Object.isFrozen(this)) {
        throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");
      }
      const state = this._state;
      return scheduleProps(++this._lastCallId, {
        key,
        props,
        defaultProps,
        state,
        actions: {
          pause: () => {
            if (!isPaused(this)) {
              setPausedBit(this, true);
              flushCalls(state.pauseQueue);
              sendEvent(this, "onPause", getFinishedResult(this, checkFinished(this, this.animation.to)), this);
            }
          },
          resume: () => {
            if (isPaused(this)) {
              setPausedBit(this, false);
              if (isAnimating(this)) {
                this._resume();
              }
              flushCalls(state.resumeQueue);
              sendEvent(this, "onResume", getFinishedResult(this, checkFinished(this, this.animation.to)), this);
            }
          },
          start: this._merge.bind(this, range)
        }
      }).then((result) => {
        if (props.loop && result.finished && !(isLoop && result.noop)) {
          const nextProps = createLoopUpdate(props);
          if (nextProps) {
            return this._update(nextProps, true);
          }
        }
        return result;
      });
    }
    _merge(range, props, resolve) {
      if (props.cancel) {
        this.stop(true);
        return resolve(getCancelledResult(this));
      }
      const hasToProp = !is.und(range.to);
      const hasFromProp = !is.und(range.from);
      if (hasToProp || hasFromProp) {
        if (props.callId > this._lastToId) {
          this._lastToId = props.callId;
        } else {
          return resolve(getCancelledResult(this));
        }
      }
      const {
        key,
        defaultProps,
        animation: anim
      } = this;
      const {
        to: prevTo,
        from: prevFrom
      } = anim;
      let {
        to: to2 = prevTo,
        from = prevFrom
      } = range;
      if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) {
        to2 = from;
      }
      if (props.reverse) [to2, from] = [from, to2];
      const hasFromChanged = !isEqual(from, prevFrom);
      if (hasFromChanged) {
        anim.from = from;
      }
      from = getFluidValue(from);
      const hasToChanged = !isEqual(to2, prevTo);
      if (hasToChanged) {
        this._focus(to2);
      }
      const hasAsyncTo = isAsyncTo(props.to);
      const {
        config: config2
      } = anim;
      const {
        decay,
        velocity
      } = config2;
      if (hasToProp || hasFromProp) {
        config2.velocity = 0;
      }
      if (props.config && !hasAsyncTo) {
        mergeConfig(config2, callProp(props.config, key), props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0);
      }
      let node = getAnimated(this);
      if (!node || is.und(to2)) {
        return resolve(getFinishedResult(this, true));
      }
      const reset = is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key);
      const value = reset ? from : this.get();
      const goal = computeGoal(to2);
      const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal);
      const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key));
      if (hasToChanged) {
        const nodeType = getAnimatedType(to2);
        if (nodeType !== node.constructor) {
          if (immediate) {
            node = this._set(goal);
          } else throw Error(`Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`);
        }
      }
      const goalType = node.constructor;
      let started = hasFluidValue(to2);
      let finished = false;
      if (!started) {
        const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
        if (hasToChanged || hasValueChanged) {
          finished = isEqual(computeGoal(value), goal);
          started = !finished;
        }
        if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) {
          started = true;
        }
      }
      if (finished && isAnimating(this)) {
        if (anim.changed && !reset) {
          started = true;
        } else if (!started) {
          this._stop(prevTo);
        }
      }
      if (!hasAsyncTo) {
        if (started || hasFluidValue(prevTo)) {
          anim.values = node.getPayload();
          anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal);
        }
        if (anim.immediate != immediate) {
          anim.immediate = immediate;
          if (!immediate && !reset) {
            this._set(prevTo);
          }
        }
        if (started) {
          const {
            onRest
          } = anim;
          each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type));
          const result = getFinishedResult(this, checkFinished(this, prevTo));
          flushCalls(this._pendingCalls, result);
          this._pendingCalls.add(resolve);
          if (anim.changed) raf.batchedUpdates(() => {
            anim.changed = !reset;
            onRest == null ? void 0 : onRest(result, this);
            if (reset) {
              callProp(defaultProps.onRest, result);
            } else {
              anim.onStart == null ? void 0 : anim.onStart(result, this);
            }
          });
        }
      }
      if (reset) {
        this._set(value);
      }
      if (hasAsyncTo) {
        resolve(runAsync(props.to, props, this._state, this));
      } else if (started) {
        this._start();
      } else if (isAnimating(this) && !hasToChanged) {
        this._pendingCalls.add(resolve);
      } else {
        resolve(getNoopResult(value));
      }
    }
    _focus(value) {
      const anim = this.animation;
      if (value !== anim.to) {
        if (getFluidObservers(this)) {
          this._detach();
        }
        anim.to = value;
        if (getFluidObservers(this)) {
          this._attach();
        }
      }
    }
    _attach() {
      let priority2 = 0;
      const {
        to: to2
      } = this.animation;
      if (hasFluidValue(to2)) {
        addFluidObserver(to2, this);
        if (isFrameValue(to2)) {
          priority2 = to2.priority + 1;
        }
      }
      this.priority = priority2;
    }
    _detach() {
      const {
        to: to2
      } = this.animation;
      if (hasFluidValue(to2)) {
        removeFluidObserver(to2, this);
      }
    }
    _set(arg, idle = true) {
      const value = getFluidValue(arg);
      if (!is.und(value)) {
        const oldNode = getAnimated(this);
        if (!oldNode || !isEqual(value, oldNode.getValue())) {
          const nodeType = getAnimatedType(value);
          if (!oldNode || oldNode.constructor != nodeType) {
            setAnimated(this, nodeType.create(value));
          } else {
            oldNode.setValue(value);
          }
          if (oldNode) {
            raf.batchedUpdates(() => {
              this._onChange(value, idle);
            });
          }
        }
      }
      return getAnimated(this);
    }
    _onStart() {
      const anim = this.animation;
      if (!anim.changed) {
        anim.changed = true;
        sendEvent(this, "onStart", getFinishedResult(this, checkFinished(this, anim.to)), this);
      }
    }
    _onChange(value, idle) {
      if (!idle) {
        this._onStart();
        callProp(this.animation.onChange, value, this);
      }
      callProp(this.defaultProps.onChange, value, this);
      super._onChange(value, idle);
    }
    _start() {
      const anim = this.animation;
      getAnimated(this).reset(getFluidValue(anim.to));
      if (!anim.immediate) {
        anim.fromValues = anim.values.map((node) => node.lastPosition);
      }
      if (!isAnimating(this)) {
        setActiveBit(this, true);
        if (!isPaused(this)) {
          this._resume();
        }
      }
    }
    _resume() {
      if (globals.skipAnimation) {
        this.finish();
      } else {
        frameLoop.start(this);
      }
    }
    _stop(goal, cancel) {
      if (isAnimating(this)) {
        setActiveBit(this, false);
        const anim = this.animation;
        each(anim.values, (node) => {
          node.done = true;
        });
        if (anim.toValues) {
          anim.onChange = anim.onPause = anim.onResume = void 0;
        }
        callFluidObservers(this, {
          type: "idle",
          parent: this
        });
        const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to));
        flushCalls(this._pendingCalls, result);
        if (anim.changed) {
          anim.changed = false;
          sendEvent(this, "onRest", result, this);
        }
      }
    }
  };
  function checkFinished(target, to2) {
    const goal = computeGoal(to2);
    const value = computeGoal(target.get());
    return isEqual(value, goal);
  }
  function createLoopUpdate(props, loop2 = props.loop, to2 = props.to) {
    let loopRet = callProp(loop2);
    if (loopRet) {
      const overrides = loopRet !== true && inferTo(loopRet);
      const reverse = (overrides || props).reverse;
      const reset = !overrides || overrides.reset;
      return createUpdate(_extends3({}, props, {
        loop: loop2,
        default: false,
        pause: void 0,
        to: !reverse || isAsyncTo(to2) ? to2 : void 0,
        from: reset ? props.from : void 0,
        reset
      }, overrides));
    }
  }
  function createUpdate(props) {
    const {
      to: to2,
      from
    } = props = inferTo(props);
    const keys = /* @__PURE__ */ new Set();
    if (is.obj(to2)) findDefined(to2, keys);
    if (is.obj(from)) findDefined(from, keys);
    props.keys = keys.size ? Array.from(keys) : null;
    return props;
  }
  function findDefined(values, keys) {
    eachProp(values, (value, key) => value != null && keys.add(key));
  }
  var ACTIVE_EVENTS = ["onStart", "onRest", "onChange", "onPause", "onResume"];
  function mergeActiveFn(target, props, type) {
    target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0;
  }
  function sendEvent(target, type, ...args) {
    var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps;
    (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args);
    (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args);
  }
  var BATCHED_EVENTS = ["onStart", "onChange", "onRest"];
  var nextId = 1;
  var Controller = class {
    constructor(props, flush2) {
      this.id = nextId++;
      this.springs = {};
      this.queue = [];
      this.ref = void 0;
      this._flush = void 0;
      this._initialProps = void 0;
      this._lastAsyncId = 0;
      this._active = /* @__PURE__ */ new Set();
      this._changed = /* @__PURE__ */ new Set();
      this._started = false;
      this._item = void 0;
      this._state = {
        paused: false,
        pauseQueue: /* @__PURE__ */ new Set(),
        resumeQueue: /* @__PURE__ */ new Set(),
        timeouts: /* @__PURE__ */ new Set()
      };
      this._events = {
        onStart: /* @__PURE__ */ new Map(),
        onChange: /* @__PURE__ */ new Map(),
        onRest: /* @__PURE__ */ new Map()
      };
      this._onFrame = this._onFrame.bind(this);
      if (flush2) {
        this._flush = flush2;
      }
      if (props) {
        this.start(_extends3({
          default: true
        }, props));
      }
    }
    get idle() {
      return !this._state.asyncTo && Object.values(this.springs).every((spring) => {
        return spring.idle && !spring.isDelayed && !spring.isPaused;
      });
    }
    get item() {
      return this._item;
    }
    set item(item) {
      this._item = item;
    }
    get() {
      const values = {};
      this.each((spring, key) => values[key] = spring.get());
      return values;
    }
    set(values) {
      for (const key in values) {
        const value = values[key];
        if (!is.und(value)) {
          this.springs[key].set(value);
        }
      }
    }
    update(props) {
      if (props) {
        this.queue.push(createUpdate(props));
      }
      return this;
    }
    start(props) {
      let {
        queue
      } = this;
      if (props) {
        queue = toArray(props).map(createUpdate);
      } else {
        this.queue = [];
      }
      if (this._flush) {
        return this._flush(this, queue);
      }
      prepareKeys(this, queue);
      return flushUpdateQueue(this, queue);
    }
    stop(arg, keys) {
      if (arg !== !!arg) {
        keys = arg;
      }
      if (keys) {
        const springs = this.springs;
        each(toArray(keys), (key) => springs[key].stop(!!arg));
      } else {
        stopAsync(this._state, this._lastAsyncId);
        this.each((spring) => spring.stop(!!arg));
      }
      return this;
    }
    pause(keys) {
      if (is.und(keys)) {
        this.start({
          pause: true
        });
      } else {
        const springs = this.springs;
        each(toArray(keys), (key) => springs[key].pause());
      }
      return this;
    }
    resume(keys) {
      if (is.und(keys)) {
        this.start({
          pause: false
        });
      } else {
        const springs = this.springs;
        each(toArray(keys), (key) => springs[key].resume());
      }
      return this;
    }
    each(iterator) {
      eachProp(this.springs, iterator);
    }
    _onFrame() {
      const {
        onStart,
        onChange,
        onRest
      } = this._events;
      const active = this._active.size > 0;
      const changed = this._changed.size > 0;
      if (active && !this._started || changed && !this._started) {
        this._started = true;
        flush(onStart, ([onStart2, result]) => {
          result.value = this.get();
          onStart2(result, this, this._item);
        });
      }
      const idle = !active && this._started;
      const values = changed || idle && onRest.size ? this.get() : null;
      if (changed && onChange.size) {
        flush(onChange, ([onChange2, result]) => {
          result.value = values;
          onChange2(result, this, this._item);
        });
      }
      if (idle) {
        this._started = false;
        flush(onRest, ([onRest2, result]) => {
          result.value = values;
          onRest2(result, this, this._item);
        });
      }
    }
    eventObserved(event) {
      if (event.type == "change") {
        this._changed.add(event.parent);
        if (!event.idle) {
          this._active.add(event.parent);
        }
      } else if (event.type == "idle") {
        this._active.delete(event.parent);
      } else return;
      raf.onFrame(this._onFrame);
    }
  };
  function flushUpdateQueue(ctrl, queue) {
    return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then((results) => getCombinedResult(ctrl, results));
  }
  async function flushUpdate(ctrl, props, isLoop) {
    const {
      keys,
      to: to2,
      from,
      loop: loop2,
      onRest,
      onResolve
    } = props;
    const defaults2 = is.obj(props.default) && props.default;
    if (loop2) {
      props.loop = false;
    }
    if (to2 === false) props.to = null;
    if (from === false) props.from = null;
    const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0;
    if (asyncTo) {
      props.to = void 0;
      props.onRest = void 0;
      if (defaults2) {
        defaults2.onRest = void 0;
      }
    } else {
      each(BATCHED_EVENTS, (key) => {
        const handler = props[key];
        if (is.fun(handler)) {
          const queue = ctrl["_events"][key];
          props[key] = ({
            finished,
            cancelled
          }) => {
            const result2 = queue.get(handler);
            if (result2) {
              if (!finished) result2.finished = false;
              if (cancelled) result2.cancelled = true;
            } else {
              queue.set(handler, {
                value: null,
                finished: finished || false,
                cancelled: cancelled || false
              });
            }
          };
          if (defaults2) {
            defaults2[key] = props[key];
          }
        }
      });
    }
    const state = ctrl["_state"];
    if (props.pause === !state.paused) {
      state.paused = props.pause;
      flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
    } else if (state.paused) {
      props.pause = true;
    }
    const promises = (keys || Object.keys(ctrl.springs)).map((key) => ctrl.springs[key].start(props));
    const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true;
    if (asyncTo || cancel && state.asyncId) {
      promises.push(scheduleProps(++ctrl["_lastAsyncId"], {
        props,
        state,
        actions: {
          pause: noop2,
          resume: noop2,
          start(props2, resolve) {
            if (cancel) {
              stopAsync(state, ctrl["_lastAsyncId"]);
              resolve(getCancelledResult(ctrl));
            } else {
              props2.onRest = onRest;
              resolve(runAsync(asyncTo, props2, state, ctrl));
            }
          }
        }
      }));
    }
    if (state.paused) {
      await new Promise((resume) => {
        state.resumeQueue.add(resume);
      });
    }
    const result = getCombinedResult(ctrl, await Promise.all(promises));
    if (loop2 && result.finished && !(isLoop && result.noop)) {
      const nextProps = createLoopUpdate(props, loop2, to2);
      if (nextProps) {
        prepareKeys(ctrl, [nextProps]);
        return flushUpdate(ctrl, nextProps, true);
      }
    }
    if (onResolve) {
      raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
    }
    return result;
  }
  function createSpring(key, observer) {
    const spring = new SpringValue();
    spring.key = key;
    if (observer) {
      addFluidObserver(spring, observer);
    }
    return spring;
  }
  function prepareSprings(springs, props, create6) {
    if (props.keys) {
      each(props.keys, (key) => {
        const spring = springs[key] || (springs[key] = create6(key));
        spring["_prepareNode"](props);
      });
    }
  }
  function prepareKeys(ctrl, queue) {
    each(queue, (props) => {
      prepareSprings(ctrl.springs, props, (key) => {
        return createSpring(key, ctrl);
      });
    });
  }
  function _objectWithoutPropertiesLoose(source, excluded) {
    if (source == null) return {};
    var target = {};
    var sourceKeys = Object.keys(source);
    var key, i3;
    for (i3 = 0; i3 < sourceKeys.length; i3++) {
      key = sourceKeys[i3];
      if (excluded.indexOf(key) >= 0) continue;
      target[key] = source[key];
    }
    return target;
  }
  var _excluded$3 = ["children"];
  var SpringContext = (_ref) => {
    let {
      children
    } = _ref, props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
    const inherited = (0, import_react11.useContext)(ctx);
    const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate;
    props = useMemoOne(() => ({
      pause,
      immediate
    }), [pause, immediate]);
    const {
      Provider
    } = ctx;
    return React23.createElement(Provider, {
      value: props
    }, children);
  };
  var ctx = makeContext(SpringContext, {});
  SpringContext.Provider = ctx.Provider;
  SpringContext.Consumer = ctx.Consumer;
  function makeContext(target, init2) {
    Object.assign(target, React23.createContext(init2));
    target.Provider._context = target;
    target.Consumer._context = target;
    return target;
  }
  var TransitionPhase;
  (function(TransitionPhase2) {
    TransitionPhase2["MOUNT"] = "mount";
    TransitionPhase2["ENTER"] = "enter";
    TransitionPhase2["UPDATE"] = "update";
    TransitionPhase2["LEAVE"] = "leave";
  })(TransitionPhase || (TransitionPhase = {}));
  var Interpolation = class extends FrameValue {
    constructor(source, args) {
      super();
      this.key = void 0;
      this.idle = true;
      this.calc = void 0;
      this._active = /* @__PURE__ */ new Set();
      this.source = source;
      this.calc = createInterpolator(...args);
      const value = this._get();
      const nodeType = getAnimatedType(value);
      setAnimated(this, nodeType.create(value));
    }
    advance(_dt) {
      const value = this._get();
      const oldValue = this.get();
      if (!isEqual(value, oldValue)) {
        getAnimated(this).setValue(value);
        this._onChange(value, this.idle);
      }
      if (!this.idle && checkIdle(this._active)) {
        becomeIdle(this);
      }
    }
    _get() {
      const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source));
      return this.calc(...inputs);
    }
    _start() {
      if (this.idle && !checkIdle(this._active)) {
        this.idle = false;
        each(getPayload(this), (node) => {
          node.done = false;
        });
        if (globals.skipAnimation) {
          raf.batchedUpdates(() => this.advance());
          becomeIdle(this);
        } else {
          frameLoop.start(this);
        }
      }
    }
    _attach() {
      let priority2 = 1;
      each(toArray(this.source), (source) => {
        if (hasFluidValue(source)) {
          addFluidObserver(source, this);
        }
        if (isFrameValue(source)) {
          if (!source.idle) {
            this._active.add(source);
          }
          priority2 = Math.max(priority2, source.priority + 1);
        }
      });
      this.priority = priority2;
      this._start();
    }
    _detach() {
      each(toArray(this.source), (source) => {
        if (hasFluidValue(source)) {
          removeFluidObserver(source, this);
        }
      });
      this._active.clear();
      becomeIdle(this);
    }
    eventObserved(event) {
      if (event.type == "change") {
        if (event.idle) {
          this.advance();
        } else {
          this._active.add(event.parent);
          this._start();
        }
      } else if (event.type == "idle") {
        this._active.delete(event.parent);
      } else if (event.type == "priority") {
        this.priority = toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0);
      }
    }
  };
  function isIdle(source) {
    return source.idle !== false;
  }
  function checkIdle(active) {
    return !active.size || Array.from(active).every(isIdle);
  }
  function becomeIdle(self2) {
    if (!self2.idle) {
      self2.idle = true;
      each(getPayload(self2), (node) => {
        node.done = true;
      });
      callFluidObservers(self2, {
        type: "idle",
        parent: self2
      });
    }
  }
  globals.assign({
    createStringInterpolator,
    to: (source, args) => new Interpolation(source, args)
  });
  var update3 = frameLoop.advance;

  // node_modules/@react-spring/web/dist/react-spring-web.esm.js
  var import_react_dom = __toESM(require_react_dom());
  function _objectWithoutPropertiesLoose2(source, excluded) {
    if (source == null) return {};
    var target = {};
    var sourceKeys = Object.keys(source);
    var key, i3;
    for (i3 = 0; i3 < sourceKeys.length; i3++) {
      key = sourceKeys[i3];
      if (excluded.indexOf(key) >= 0) continue;
      target[key] = source[key];
    }
    return target;
  }
  var _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"];
  var isCustomPropRE = /^--/;
  function dangerousStyleValue(name2, value) {
    if (value == null || typeof value === "boolean" || value === "") return "";
    if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name2) && !(isUnitlessNumber.hasOwnProperty(name2) && isUnitlessNumber[name2])) return value + "px";
    return ("" + value).trim();
  }
  var attributeCache = {};
  function applyAnimatedValues(instance, props) {
    if (!instance.nodeType || !instance.setAttribute) {
      return false;
    }
    const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter";
    const _ref = props, {
      style,
      children,
      scrollTop,
      scrollLeft
    } = _ref, attributes = _objectWithoutPropertiesLoose2(_ref, _excluded$2);
    const values = Object.values(attributes);
    const names = Object.keys(attributes).map((name2) => isFilterElement || instance.hasAttribute(name2) ? name2 : attributeCache[name2] || (attributeCache[name2] = name2.replace(/([A-Z])/g, (n3) => "-" + n3.toLowerCase())));
    if (children !== void 0) {
      instance.textContent = children;
    }
    for (let name2 in style) {
      if (style.hasOwnProperty(name2)) {
        const value = dangerousStyleValue(name2, style[name2]);
        if (isCustomPropRE.test(name2)) {
          instance.style.setProperty(name2, value);
        } else {
          instance.style[name2] = value;
        }
      }
    }
    names.forEach((name2, i3) => {
      instance.setAttribute(name2, values[i3]);
    });
    if (scrollTop !== void 0) {
      instance.scrollTop = scrollTop;
    }
    if (scrollLeft !== void 0) {
      instance.scrollLeft = scrollLeft;
    }
  }
  var isUnitlessNumber = {
    animationIterationCount: true,
    borderImageOutset: true,
    borderImageSlice: true,
    borderImageWidth: true,
    boxFlex: true,
    boxFlexGroup: true,
    boxOrdinalGroup: true,
    columnCount: true,
    columns: true,
    flex: true,
    flexGrow: true,
    flexPositive: true,
    flexShrink: true,
    flexNegative: true,
    flexOrder: true,
    gridRow: true,
    gridRowEnd: true,
    gridRowSpan: true,
    gridRowStart: true,
    gridColumn: true,
    gridColumnEnd: true,
    gridColumnSpan: true,
    gridColumnStart: true,
    fontWeight: true,
    lineClamp: true,
    lineHeight: true,
    opacity: true,
    order: true,
    orphans: true,
    tabSize: true,
    widows: true,
    zIndex: true,
    zoom: true,
    fillOpacity: true,
    floodOpacity: true,
    stopOpacity: true,
    strokeDasharray: true,
    strokeDashoffset: true,
    strokeMiterlimit: true,
    strokeOpacity: true,
    strokeWidth: true
  };
  var prefixKey = (prefix2, key) => prefix2 + key.charAt(0).toUpperCase() + key.substring(1);
  var prefixes = ["Webkit", "Ms", "Moz", "O"];
  isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
    prefixes.forEach((prefix2) => acc[prefixKey(prefix2, prop)] = acc[prop]);
    return acc;
  }, isUnitlessNumber);
  var _excluded$1 = ["x", "y", "z"];
  var domTransforms = /^(matrix|translate|scale|rotate|skew)/;
  var pxTransforms = /^(translate)/;
  var degTransforms = /^(rotate|skew)/;
  var addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value;
  var isValueIdentity = (value, id) => is.arr(value) ? value.every((v3) => isValueIdentity(v3, id)) : is.num(value) ? value === id : parseFloat(value) === id;
  var AnimatedStyle = class extends AnimatedObject {
    constructor(_ref) {
      let {
        x: x2,
        y: y3,
        z
      } = _ref, style = _objectWithoutPropertiesLoose2(_ref, _excluded$1);
      const inputs = [];
      const transforms = [];
      if (x2 || y3 || z) {
        inputs.push([x2 || 0, y3 || 0, z || 0]);
        transforms.push((xyz) => [`translate3d(${xyz.map((v3) => addUnit(v3, "px")).join(",")})`, isValueIdentity(xyz, 0)]);
      }
      eachProp(style, (value, key) => {
        if (key === "transform") {
          inputs.push([value || ""]);
          transforms.push((transform) => [transform, transform === ""]);
        } else if (domTransforms.test(key)) {
          delete style[key];
          if (is.und(value)) return;
          const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : "";
          inputs.push(toArray(value));
          transforms.push(key === "rotate3d" ? ([x3, y4, z2, deg]) => [`rotate3d(${x3},${y4},${z2},${addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : (input) => [`${key}(${input.map((v3) => addUnit(v3, unit)).join(",")})`, isValueIdentity(input, key.startsWith("scale") ? 1 : 0)]);
        }
      });
      if (inputs.length) {
        style.transform = new FluidTransform(inputs, transforms);
      }
      super(style);
    }
  };
  var FluidTransform = class extends FluidValue {
    constructor(inputs, transforms) {
      super();
      this._value = null;
      this.inputs = inputs;
      this.transforms = transforms;
    }
    get() {
      return this._value || (this._value = this._get());
    }
    _get() {
      let transform = "";
      let identity5 = true;
      each(this.inputs, (input, i3) => {
        const arg1 = getFluidValue(input[0]);
        const [t4, id] = this.transforms[i3](is.arr(arg1) ? arg1 : input.map(getFluidValue));
        transform += " " + t4;
        identity5 = identity5 && id;
      });
      return identity5 ? "none" : transform;
    }
    observerAdded(count) {
      if (count == 1) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && addFluidObserver(value, this)));
    }
    observerRemoved(count) {
      if (count == 0) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && removeFluidObserver(value, this)));
    }
    eventObserved(event) {
      if (event.type == "change") {
        this._value = null;
      }
      callFluidObservers(this, event);
    }
  };
  var primitives = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"];
  var _excluded = ["scrollTop", "scrollLeft"];
  globals.assign({
    batchedUpdates: import_react_dom.unstable_batchedUpdates,
    createStringInterpolator,
    colors
  });
  var host = createHost(primitives, {
    applyAnimatedValues,
    createAnimatedStyle: (style) => new AnimatedStyle(style),
    getComponentProps: (_ref) => {
      let props = _objectWithoutPropertiesLoose2(_ref, _excluded);
      return props;
    }
  });
  var animated = host.animated;

  // packages/fields/build-module/components/media-edit/use-moving-animation.mjs
  var import_element23 = __toESM(require_element(), 1);
  function getAbsolutePosition(element) {
    return {
      top: element.offsetTop,
      left: element.offsetLeft
    };
  }
  function useMovingAnimation(triggerAnimationOnChange) {
    const ref = (0, import_element23.useRef)(null);
    const previousRef = (0, import_element23.useRef)(void 0);
    if (ref.current) {
      previousRef.current = getAbsolutePosition(ref.current);
    }
    (0, import_element23.useLayoutEffect)(() => {
      const previous = previousRef.current;
      if (!previous || !ref.current) {
        return;
      }
      if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
        return;
      }
      const controller = new Controller({
        x: 0,
        y: 0,
        config: { mass: 5, tension: 2e3, friction: 200 },
        onChange({ value }) {
          if (!ref.current) {
            return;
          }
          let { x: x22, y: y22 } = value;
          x22 = Math.round(x22);
          y22 = Math.round(y22);
          const finishedMoving = x22 === 0 && y22 === 0;
          ref.current.style.transform = finishedMoving ? "" : `translate3d(${x22}px,${y22}px,0)`;
        }
      });
      ref.current.style.transform = "";
      const destination = getAbsolutePosition(ref.current);
      const x2 = Math.round(previous.left - destination.left);
      const y3 = Math.round(previous.top - destination.top);
      controller.start({ x: 0, y: 0, from: { x: x2, y: y3 } });
      return () => {
        controller.stop();
        controller.set({ x: 0, y: 0 });
      };
    }, [triggerAnimationOnChange]);
    return ref;
  }

  // packages/fields/build-module/components/media-edit/index.mjs
  var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
  var { MediaUploadModal } = unlock2(import_media_utils.privateApis);
  function AnimatedMediaItem({
    children,
    index,
    className
  }) {
    const ref = useMovingAnimation(index);
    return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { ref, className, children });
  }
  function normalizeValue(value) {
    if (Array.isArray(value)) {
      return value;
    }
    return value ? [value] : [];
  }
  function ConditionalMediaUpload({ render: render4, multiple, ...props }) {
    const [isModalOpen, setIsModalOpen] = (0, import_element24.useState)(false);
    if (window.__experimentalDataViewsMediaModal) {
      return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(import_jsx_runtime105.Fragment, { children: [
        render4 && render4({ open: () => setIsModalOpen(true) }),
        isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
          MediaUploadModal,
          {
            ...props,
            multiple,
            isOpen: isModalOpen,
            onClose: () => {
              setIsModalOpen(false);
              props.onClose?.();
            },
            onSelect: (media) => {
              setIsModalOpen(false);
              props.onSelect?.(media);
            }
          }
        )
      ] });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
      import_media_utils.MediaUpload,
      {
        ...props,
        render: render4,
        multiple: multiple ? "add" : void 0
      }
    );
  }
  function MediaPickerButton({
    open,
    children,
    label,
    showTooltip = false,
    onFilesDrop,
    attachment,
    isUploading = false
  }) {
    const isBlob = attachment && (0, import_blob.isBlobURL)(attachment.source_url);
    const mediaPickerButton = /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
      "div",
      {
        className: clsx_default("fields__media-edit-picker-button", {
          "has-attachment": attachment
        }),
        role: "button",
        tabIndex: 0,
        onClick: () => {
          if (!isUploading) {
            open();
          }
        },
        onKeyDown: (event) => {
          if (isUploading) {
            return;
          }
          if (event.key === "Enter" || event.key === " ") {
            event.preventDefault();
            open();
          }
        },
        "aria-label": label,
        "aria-disabled": isUploading,
        children: [
          children,
          isBlob && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("span", { className: "fields__media-edit-picker-button-spinner", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components5.Spinner, {}) }),
          !isUploading && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
            import_components5.DropZone,
            {
              onFilesDrop: (files) => onFilesDrop(files, attachment?.id)
            }
          )
        ]
      }
    );
    if (!showTooltip) {
      return mediaPickerButton;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components5.Tooltip, { text: label, placement: "top", children: mediaPickerButton });
  }
  var archiveMimeTypes = [
    "application/zip",
    "application/x-zip-compressed",
    "application/x-rar-compressed",
    "application/x-7z-compressed",
    "application/x-tar",
    "application/x-gzip"
  ];
  function MediaTitle({ attachment }) {
    return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components5.__experimentalTruncate, { className: "fields__media-edit-filename", children: attachment.title.rendered });
  }
  function MediaEditPlaceholder(props) {
    return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(MediaPickerButton, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("span", { className: "fields__media-edit-placeholder", children: props.label }) });
  }
  function MoveButtons({
    itemId,
    index,
    totalItems,
    isUploading,
    moveItem,
    orientation = "vertical"
  }) {
    const isHorizontal = orientation === "horizontal";
    return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(import_jsx_runtime105.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
        import_components5.Button,
        {
          __next40pxDefaultSize: true,
          icon: isHorizontal ? chevron_left_default : chevron_up_default,
          label: isHorizontal ? (0, import_i18n13.__)("Move left") : (0, import_i18n13.__)("Move up"),
          size: "small",
          disabled: isUploading || index === 0,
          accessibleWhenDisabled: true,
          tooltipPosition: "top",
          onClick: (event) => {
            event.stopPropagation();
            moveItem(itemId, "up");
          }
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
        import_components5.Button,
        {
          __next40pxDefaultSize: true,
          icon: isHorizontal ? chevron_right_default : chevron_down_default,
          label: isHorizontal ? (0, import_i18n13.__)("Move right") : (0, import_i18n13.__)("Move down"),
          size: "small",
          disabled: isUploading || index === totalItems - 1,
          accessibleWhenDisabled: true,
          tooltipPosition: "top",
          onClick: (event) => {
            event.stopPropagation();
            moveItem(itemId, "down");
          }
        }
      )
    ] });
  }
  function MediaPreview({ attachment }) {
    const url = attachment.source_url;
    const mimeType = attachment.mime_type || "";
    if (mimeType.startsWith("image")) {
      return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
        "img",
        {
          className: "fields__media-edit-thumbnail",
          alt: attachment.alt_text || "",
          src: url
        }
      );
    } else if (mimeType.startsWith("audio")) {
      return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components5.Icon, { icon: audio_default });
    } else if (mimeType.startsWith("video")) {
      return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components5.Icon, { icon: video_default });
    } else if (archiveMimeTypes.includes(mimeType)) {
      return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components5.Icon, { icon: archive_default });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components5.Icon, { icon: file_default });
  }
  function ExpandedMediaEditAttachments({
    allItems,
    addButtonLabel,
    multiple,
    removeItem,
    moveItem,
    open,
    onFilesDrop,
    isUploading,
    setTargetItemId
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
      "div",
      {
        className: clsx_default("fields__media-edit-expanded", {
          "is-multiple": multiple,
          "is-single": !multiple,
          "is-empty": !allItems?.length
        }),
        children: [
          allItems?.map((attachment, index) => {
            const hasPreviewImage = attachment.mime_type?.startsWith("image");
            const isBlob = (0, import_blob.isBlobURL)(attachment.source_url);
            const attachmentNumericId = attachment.id;
            return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
              AnimatedMediaItem,
              {
                index,
                className: clsx_default("fields__media-edit-expanded-item", {
                  "has-preview-image": hasPreviewImage
                }),
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                    MediaPickerButton,
                    {
                      open: () => {
                        setTargetItemId(attachmentNumericId);
                        open();
                      },
                      label: !isBlob ? (0, import_i18n13.sprintf)(
                        /* translators: %s: The title of the media item. */
                        (0, import_i18n13.__)("Replace %s"),
                        attachment.title.rendered
                      ) : (0, import_i18n13.__)("Replace"),
                      showTooltip: true,
                      onFilesDrop,
                      attachment,
                      isUploading,
                      children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "fields__media-edit-expanded-preview", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                        import_components5.__experimentalVStack,
                        {
                          spacing: 0,
                          alignment: "center",
                          justify: "center",
                          className: "fields__media-edit-expanded-preview-stack",
                          children: (!isBlob || hasPreviewImage) && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                            MediaPreview,
                            {
                              attachment
                            }
                          )
                        }
                      ) })
                    }
                  ),
                  !isBlob && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "fields__media-edit-expanded-overlay", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
                    import_components5.__experimentalHStack,
                    {
                      className: "fields__media-edit-expanded-actions",
                      spacing: 0,
                      alignment: "flex-end",
                      expanded: false,
                      children: [
                        multiple && allItems.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                          MoveButtons,
                          {
                            itemId: attachmentNumericId,
                            index,
                            totalItems: allItems.length,
                            isUploading,
                            moveItem,
                            orientation: "horizontal"
                          }
                        ),
                        /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                          import_components5.Button,
                          {
                            __next40pxDefaultSize: true,
                            icon: close_small_default,
                            label: (0, import_i18n13.__)("Remove"),
                            size: "small",
                            disabled: isUploading,
                            accessibleWhenDisabled: true,
                            tooltipPosition: "top",
                            onClick: (event) => {
                              event.stopPropagation();
                              removeItem(attachmentNumericId);
                            }
                          }
                        )
                      ]
                    }
                  ) })
                ]
              },
              attachment.id
            );
          }),
          (multiple || !allItems?.length) && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
            MediaEditPlaceholder,
            {
              open: () => {
                setTargetItemId(void 0);
                open();
              },
              label: addButtonLabel,
              onFilesDrop,
              isUploading
            }
          )
        ]
      }
    );
  }
  function CompactMediaEditAttachments({
    allItems,
    addButtonLabel,
    multiple,
    removeItem,
    moveItem,
    open,
    onFilesDrop,
    isUploading,
    setTargetItemId
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(import_jsx_runtime105.Fragment, { children: [
      !!allItems?.length && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
        "div",
        {
          className: clsx_default("fields__media-edit-compact-group", {
            "is-single": allItems.length === 1
          }),
          children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components5.__experimentalVStack, { spacing: 0, children: allItems.map((attachment, index) => {
            const isBlob = (0, import_blob.isBlobURL)(attachment.source_url);
            const showMoveButtons = multiple && allItems.length > 1;
            const attachmentNumericId = attachment.id;
            return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
              AnimatedMediaItem,
              {
                index,
                className: "fields__media-edit-compact",
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                    MediaPickerButton,
                    {
                      open: () => {
                        setTargetItemId(
                          attachmentNumericId
                        );
                        open();
                      },
                      label: (0, import_i18n13.__)("Replace"),
                      showTooltip: true,
                      onFilesDrop,
                      attachment,
                      isUploading,
                      children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(import_jsx_runtime105.Fragment, { children: [
                        /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                          MediaPreview,
                          {
                            attachment
                          }
                        ),
                        !isBlob && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                          MediaTitle,
                          {
                            attachment
                          }
                        )
                      ] })
                    }
                  ),
                  !isBlob && /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
                    import_components5.__experimentalHStack,
                    {
                      className: "fields__media-edit-compact-movers",
                      spacing: 0,
                      alignment: "flex-end",
                      expanded: false,
                      children: [
                        showMoveButtons && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                          MoveButtons,
                          {
                            itemId: attachmentNumericId,
                            index,
                            totalItems: allItems.length,
                            isUploading,
                            moveItem,
                            orientation: "vertical"
                          }
                        ),
                        /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                          import_components5.Button,
                          {
                            __next40pxDefaultSize: true,
                            icon: close_small_default,
                            label: (0, import_i18n13.__)("Remove"),
                            size: "small",
                            disabled: isUploading,
                            accessibleWhenDisabled: true,
                            tooltipPosition: "top",
                            onClick: (event) => {
                              event.stopPropagation();
                              removeItem(
                                attachmentNumericId
                              );
                            }
                          }
                        )
                      ]
                    }
                  )
                ]
              },
              attachment.id
            );
          }) })
        }
      ),
      (multiple || !allItems?.length) && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
        MediaEditPlaceholder,
        {
          open: () => {
            setTargetItemId(void 0);
            open();
          },
          label: addButtonLabel,
          onFilesDrop,
          isUploading
        }
      )
    ] });
  }
  function MediaEdit({
    data,
    field,
    onChange,
    hideLabelFromVision,
    allowedTypes = ["image"],
    multiple,
    isExpanded,
    validity
  }) {
    const value = field.getValue({ item: data });
    const [isTouched, setIsTouched] = (0, import_element24.useState)(false);
    const validityTargetRef = (0, import_element24.useRef)(null);
    const [customValidity, setCustomValidity] = (0, import_element24.useState)(void 0);
    (0, import_element24.useEffect)(() => {
      const validityTarget = validityTargetRef.current;
      const handler = () => {
        setIsTouched(true);
      };
      validityTarget?.addEventListener("invalid", handler);
      return () => validityTarget?.removeEventListener("invalid", handler);
    }, []);
    const attachments = (0, import_data6.useSelect)(
      (select7) => {
        if (!value) {
          return null;
        }
        const normalizedValue = normalizeValue(value);
        const sortedIds = normalizedValue.toSorted((a3, b3) => a3 - b3);
        const { getEntityRecords } = select7(import_core_data4.store);
        return getEntityRecords("postType", "attachment", {
          include: sortedIds
        });
      },
      [value]
    );
    const stableAttachmentsRef = (0, import_element24.useRef)(
      null
    );
    if (attachments !== null) {
      stableAttachmentsRef.current = attachments;
    }
    let stableAttachments = attachments;
    if (attachments === null && stableAttachmentsRef.current && value) {
      const stableIds = new Set(
        stableAttachmentsRef.current.map((a3) => a3.id)
      );
      if (normalizeValue(value).every((id) => stableIds.has(id))) {
        stableAttachments = stableAttachmentsRef.current;
      }
    }
    const orderedAttachments = (0, import_element24.useMemo)(() => {
      if (!stableAttachments) {
        return null;
      }
      const normalizedValue = normalizeValue(value);
      const attachmentMap = new Map(
        stableAttachments.map((a3) => [a3.id, a3])
      );
      return normalizedValue.map((id) => attachmentMap.get(id)).filter((a3) => a3 !== void 0);
    }, [stableAttachments, value]);
    const { createErrorNotice } = (0, import_data6.useDispatch)(import_notices3.store);
    const { receiveEntityRecords } = (0, import_data6.useDispatch)(import_core_data4.store);
    const [targetItemId, setTargetItemId] = (0, import_element24.useState)();
    const openModalRef = (0, import_element24.useRef)(void 0);
    const [pendingOpen, setPendingOpen] = (0, import_element24.useState)(false);
    const [blobs, setBlobs] = (0, import_element24.useState)([]);
    (0, import_element24.useEffect)(() => {
      if (pendingOpen) {
        setPendingOpen(false);
        openModalRef.current?.();
      }
    }, [pendingOpen]);
    const onChangeControl = (0, import_element24.useCallback)(
      (newValue) => onChange(field.setValue({ item: data, value: newValue })),
      [data, field, onChange]
    );
    const removeItem = (0, import_element24.useCallback)(
      (itemId) => {
        const currentIds = normalizeValue(value);
        const newIds = currentIds.filter((id) => id !== itemId);
        setIsTouched(true);
        onChangeControl(newIds.length ? newIds : void 0);
      },
      [value, onChangeControl]
    );
    const moveItem = (0, import_element24.useCallback)(
      (itemId, direction) => {
        if (!orderedAttachments) {
          return;
        }
        const currentIds = orderedAttachments.map((a3) => a3.id);
        const index = currentIds.indexOf(itemId);
        const newIndex = direction === "up" ? index - 1 : index + 1;
        [currentIds[index], currentIds[newIndex]] = [
          currentIds[newIndex],
          currentIds[index]
        ];
        onChangeControl(currentIds);
      },
      [orderedAttachments, onChangeControl]
    );
    const onFilesDrop = (0, import_element24.useCallback)(
      (files, _targetItemId) => {
        setTargetItemId(_targetItemId);
        (0, import_media_utils.uploadMedia)({
          allowedTypes: allowedTypes?.length ? allowedTypes : void 0,
          filesList: files,
          onFileChange(uploadedMedia) {
            const blobUrls = uploadedMedia.filter((item) => (0, import_blob.isBlobURL)(item.url)).map((item) => item.url);
            setBlobs(blobUrls);
            if (!!blobUrls.length) {
              return;
            }
            receiveEntityRecords(
              "postType",
              "attachment",
              [],
              void 0,
              true
            );
            const uploadedIds = uploadedMedia.map(
              (item) => item.id
            );
            if (!multiple) {
              onChangeControl(uploadedIds[0]);
              setTargetItemId(void 0);
              return;
            }
            const currentValue = normalizeValue(value);
            if (_targetItemId === void 0) {
              onChangeControl([...currentValue, ...uploadedIds]);
            } else {
              const newValue = [...currentValue];
              newValue.splice(
                currentValue.indexOf(_targetItemId),
                1,
                ...uploadedIds
              );
              onChangeControl(newValue);
            }
            setTargetItemId(void 0);
          },
          onError(error2) {
            setTargetItemId(void 0);
            setBlobs([]);
            createErrorNotice(error2.message, { type: "snackbar" });
          },
          multiple: !!multiple
        });
      },
      [
        allowedTypes,
        value,
        multiple,
        createErrorNotice,
        onChangeControl,
        receiveEntityRecords
      ]
    );
    const addButtonLabel = field.placeholder || (multiple ? (0, import_i18n13.__)("Choose files") : (0, import_i18n13.__)("Choose file"));
    const allItems = (0, import_element24.useMemo)(() => {
      if (!blobs.length) {
        return orderedAttachments;
      }
      const items = [
        ...orderedAttachments || []
      ];
      const blobItems = blobs.map((url) => ({
        id: url,
        source_url: url,
        mime_type: (0, import_blob.getBlobTypeByURL)(url)
      }));
      if (targetItemId !== void 0) {
        const targetIndex = items.findIndex(
          (a3) => a3.id === targetItemId
        );
        items.splice(targetIndex, 1, ...blobItems);
      } else {
        items.push(...blobItems);
      }
      return items;
    }, [orderedAttachments, targetItemId, blobs]);
    (0, import_element24.useEffect)(() => {
      if (!isTouched) {
        return;
      }
      const input = validityTargetRef.current;
      if (!input) {
        return;
      }
      if (validity) {
        const customValidityResult = validity?.custom;
        setCustomValidity(customValidityResult);
        if (customValidityResult?.type === "invalid") {
          input.setCustomValidity(
            customValidityResult.message || (0, import_i18n13.__)("Invalid")
          );
        } else {
          input.setCustomValidity("");
        }
      } else {
        input.setCustomValidity("");
        setCustomValidity(void 0);
      }
    }, [isTouched, field.isValid, validity]);
    const onBlur = (0, import_element24.useCallback)(
      (event) => {
        if (isTouched) {
          return;
        }
        if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
          setIsTouched(true);
        }
      },
      [isTouched]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)("div", { onBlur, children: [
      /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("fieldset", { className: "fields__media-edit", "data-field-id": field.id, children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
        ConditionalMediaUpload,
        {
          onSelect: (selectedMedia) => {
            if (!multiple) {
              onChangeControl(selectedMedia.id);
              setTargetItemId(void 0);
              return;
            }
            const newIds = Array.isArray(selectedMedia) ? selectedMedia.map((m2) => m2.id) : [selectedMedia.id];
            const currentValue = normalizeValue(value);
            if (!currentValue.length) {
              onChangeControl(newIds);
            } else if (targetItemId === void 0) {
              const existingItems = currentValue.filter(
                (id) => newIds.includes(id)
              );
              const newItems = newIds.filter(
                (id) => !currentValue.includes(id)
              );
              onChangeControl([
                ...existingItems,
                ...newItems
              ]);
            } else if (selectedMedia.id !== targetItemId) {
              const filtered = currentValue.filter(
                (id) => id !== selectedMedia.id
              );
              onChangeControl(
                filtered.map(
                  (id) => id === targetItemId ? selectedMedia.id : id
                )
              );
            }
            setTargetItemId(void 0);
          },
          onClose: () => setTargetItemId(void 0),
          allowedTypes,
          value: targetItemId !== void 0 ? targetItemId : value,
          multiple: multiple && targetItemId === void 0,
          title: field.label,
          render: ({ open }) => {
            openModalRef.current = open;
            const AttachmentsComponent = isExpanded ? ExpandedMediaEditAttachments : CompactMediaEditAttachments;
            return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(import_components5.__experimentalVStack, { spacing: 2, children: [
              field.label && (hideLabelFromVision ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("legend", {}), children: field.label }) : /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                import_components5.BaseControl.VisualLabel,
                {
                  as: "legend",
                  style: { marginBottom: 0 },
                  children: field.label
                }
              )),
              /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                AttachmentsComponent,
                {
                  allItems,
                  addButtonLabel,
                  multiple,
                  removeItem,
                  moveItem,
                  open: () => setPendingOpen(true),
                  onFilesDrop,
                  isUploading: !!blobs.length,
                  setTargetItemId
                }
              ),
              field.description && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
                import_components5.__experimentalText,
                {
                  variant: "muted",
                  className: "fields__media-edit-description",
                  children: field.description
                }
              )
            ] });
          }
        }
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
        "input",
        {
          type: "text",
          ref: validityTargetRef,
          value: value ?? "",
          tabIndex: -1,
          "aria-hidden": "true",
          onChange: () => {
          }
        }
      ) }),
      customValidity && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { "aria-live": "polite", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
        "p",
        {
          className: clsx_default(
            "components-validated-control__indicator",
            {
              "is-invalid": customValidity.type === "invalid",
              "is-valid": customValidity.type === "valid"
            }
          ),
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
              import_components5.Icon,
              {
                className: "components-validated-control__indicator-icon",
                icon: error_default,
                size: 16,
                fill: "currentColor"
              }
            ),
            customValidity.message
          ]
        }
      ) })
    ] });
  }

  // packages/fields/build-module/fields/featured-image/featured-image-view.mjs
  var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
  var FeaturedImageView = ({
    item,
    config: config2
  }) => {
    const media = item?._embedded?.["wp:featuredmedia"]?.[0];
    const url = media?.source_url;
    if (url) {
      return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
        "img",
        {
          className: "fields-controls__featured-image-image",
          src: url,
          alt: "",
          srcSet: media?.media_details?.sizes ? Object.values(media.media_details.sizes).map(
            (size) => `${size.source_url} ${size.width}w`
          ).join(", ") : void 0,
          sizes: config2?.sizes || "100vw"
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("span", { className: "fields-controls__featured-image-placeholder" });
  };

  // packages/fields/build-module/fields/featured-image/index.mjs
  var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
  var featuredImageField = {
    id: "featured_media",
    type: "media",
    label: (0, import_i18n14.__)("Featured Image"),
    placeholder: (0, import_i18n14.__)("Set featured image"),
    Edit: (props) => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(MediaEdit, { ...props, isExpanded: true }),
    render: FeaturedImageView,
    setValue: ({ value }) => ({
      featured_media: value ?? 0
    }),
    enableSorting: false,
    filterBy: false
  };
  var featured_image_default = featuredImageField;

  // packages/fields/build-module/fields/template/index.mjs
  var import_i18n17 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/template/template-edit.mjs
  var import_element25 = __toESM(require_element(), 1);
  var import_core_data6 = __toESM(require_core_data(), 1);
  var import_components6 = __toESM(require_components(), 1);
  var import_data8 = __toESM(require_data(), 1);
  var import_i18n15 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/template/hooks.mjs
  var import_data7 = __toESM(require_data(), 1);
  var import_core_data5 = __toESM(require_core_data(), 1);
  function useTemplateFieldMode(record) {
    const postType2 = record.type;
    const availableTemplates = record?.available_templates ?? {};
    const hasAvailableTemplates = Object.keys(availableTemplates).length > 0;
    return (0, import_data7.useSelect)(
      (select7) => {
        const isBlockTheme = !!select7(import_core_data5.store).getCurrentTheme()?.is_block_theme;
        const postTypeObj = select7(import_core_data5.store).getPostType(postType2);
        if (!postTypeObj?.viewable) {
          return null;
        }
        const canCreateTemplates = isBlockTheme && (select7(import_core_data5.store).canUser("create", {
          kind: "postType",
          name: "wp_template"
        }) ?? false);
        const isVisible2 = hasAvailableTemplates || canCreateTemplates;
        const canViewTemplates = isVisible2 ? !!select7(import_core_data5.store).canUser("read", {
          kind: "postType",
          name: "wp_template"
        }) : false;
        if ((!isBlockTheme || !canViewTemplates) && isVisible2) {
          return "classic";
        }
        if (isBlockTheme && canViewTemplates) {
          return "block-theme";
        }
        return null;
      },
      [postType2, hasAvailableTemplates]
    );
  }
  function getTemplateSlugToCheck(postType2, slug) {
    if (slug) {
      return postType2 === "page" ? `${postType2}-${slug}` : `single-${postType2}-${slug}`;
    }
    return postType2 === "page" ? "page" : `single-${postType2}`;
  }
  var NAME_NOT_FOUND = "";
  function useDefaultTemplateLabel(postType2, postId2, slug) {
    return (0, import_data7.useSelect)(
      (select7) => {
        if (!postType2 || !postId2) {
          return NAME_NOT_FOUND;
        }
        const postIdStr = String(postId2);
        const homePage = unlock2(select7(import_core_data5.store)).getHomePage();
        if (postType2 === "page" && homePage?.postType === "page" && homePage?.postId === postIdStr) {
          const templates = select7(
            import_core_data5.store
          ).getEntityRecords("postType", "wp_template", {
            per_page: -1
          });
          const frontPage = templates?.find(
            (t4) => t4.slug === "front-page"
          );
          if (frontPage) {
            return getItemTitle(frontPage);
          }
        }
        const postsPageId = unlock2(select7(import_core_data5.store)).getPostsPageId();
        if (postType2 === "page" && postsPageId === postIdStr) {
          const templateId22 = select7(import_core_data5.store).getDefaultTemplateId({
            slug: "home"
          });
          if (!templateId22) {
            return NAME_NOT_FOUND;
          }
          const template22 = select7(
            import_core_data5.store
          ).getEntityRecord(
            "postType",
            "wp_template",
            templateId22
          );
          return template22 ? getItemTitle(template22) : NAME_NOT_FOUND;
        }
        const slugToCheck = getTemplateSlugToCheck(postType2, slug);
        const templateId2 = select7(import_core_data5.store).getDefaultTemplateId({
          slug: slugToCheck
        });
        if (!templateId2) {
          return NAME_NOT_FOUND;
        }
        const template2 = select7(import_core_data5.store).getEntityRecord(
          "postType",
          "wp_template",
          templateId2
        );
        return template2 ? getItemTitle(template2) : NAME_NOT_FOUND;
      },
      [postType2, postId2, slug]
    );
  }

  // packages/fields/build-module/fields/template/template-edit.mjs
  var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
  var EMPTY_ARRAY2 = [];
  function ClassicTemplateEdit({
    data,
    field,
    onChange
  }) {
    const postId2 = typeof data.id === "number" ? data.id : parseInt(data.id, 10);
    const value = field.getValue({ item: data });
    const options = (0, import_element25.useMemo)(
      () => Object.entries(
        data?.available_templates ?? {}
      ).map(([templateSlug, title]) => ({
        label: title,
        value: templateSlug
      })),
      [data]
    );
    const canSwitchTemplate = (0, import_data8.useSelect)(
      (select7) => {
        const { getHomePage, getPostsPageId } = unlock2(
          select7(import_core_data6.store)
        );
        const singlePostId = String(postId2);
        const isPostsPage = getPostsPageId() === singlePostId;
        const isFrontPage = data.type === "page" && getHomePage()?.postId === singlePostId;
        return !isPostsPage && !isFrontPage;
      },
      [postId2, data.type]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
      import_components6.SelectControl,
      {
        __next40pxDefaultSize: true,
        label: (0, import_i18n15.__)("Template"),
        hideLabelFromVision: true,
        value,
        options,
        onChange,
        disabled: !canSwitchTemplate
      }
    );
  }
  function BlockThemeTemplateEdit({
    data,
    field,
    onChange
  }) {
    const postType2 = data.type;
    const postId2 = typeof data.id === "number" ? data.id : parseInt(data.id, 10);
    const slug = data.slug;
    const { templates, canSwitchTemplate } = (0, import_data8.useSelect)(
      (select7) => {
        const allTemplates = select7(import_core_data6.store).getEntityRecords(
          "postType",
          "wp_template",
          {
            per_page: -1,
            post_type: postType2
          }
        ) ?? EMPTY_ARRAY2;
        const { getHomePage, getPostsPageId } = unlock2(
          select7(import_core_data6.store)
        );
        const singlePostId = String(postId2);
        const isPostsPage = getPostsPageId() === singlePostId;
        const isFrontPage = postType2 === "page" && getHomePage()?.postId === singlePostId;
        return {
          templates: allTemplates,
          canSwitchTemplate: !isPostsPage && !isFrontPage
        };
      },
      [postId2, postType2]
    );
    const defaultTemplateLabel = useDefaultTemplateLabel(
      postType2,
      postId2,
      slug
    );
    const value = field.getValue({ item: data });
    const options = (0, import_element25.useMemo)(() => {
      const templateOptions = templates.map((template2) => ({
        label: getItemTitle(template2),
        value: template2.slug
      }));
      return [
        { label: defaultTemplateLabel, value: "" },
        ...templateOptions
      ];
    }, [templates, defaultTemplateLabel]);
    return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
      import_components6.SelectControl,
      {
        __next40pxDefaultSize: true,
        label: (0, import_i18n15.__)("Template"),
        hideLabelFromVision: true,
        value,
        options,
        onChange,
        disabled: !canSwitchTemplate
      }
    );
  }
  var TemplateEdit = ({
    data,
    field,
    onChange
  }) => {
    const onChangeControl = (0, import_element25.useCallback)(
      (newValue) => onChange({
        [field.id]: newValue
      }),
      [field.id, onChange]
    );
    const mode = useTemplateFieldMode(data);
    if (!mode || !["block-theme", "classic"].includes(mode)) {
      return null;
    }
    const Edit = mode === "classic" ? ClassicTemplateEdit : BlockThemeTemplateEdit;
    return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Edit, { data, field, onChange: onChangeControl });
  };

  // packages/fields/build-module/fields/template/template-view.mjs
  var import_data9 = __toESM(require_data(), 1);
  var import_core_data7 = __toESM(require_core_data(), 1);
  var import_i18n16 = __toESM(require_i18n(), 1);
  var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
  function ClassicTemplateView({
    item,
    field
  }) {
    const templateSlug = field.getValue({ item });
    const availableTemplates = item?.available_templates ?? {};
    const classicLabel = templateSlug && availableTemplates[templateSlug] ? availableTemplates[templateSlug] : (0, import_i18n16.__)("Default template");
    return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_jsx_runtime109.Fragment, { children: classicLabel });
  }
  function BlockThemeTemplateView({
    item,
    field
  }) {
    const postType2 = item.type;
    const slug = item.slug;
    const postId2 = item.id;
    const templateSlug = field.getValue({ item });
    const defaultTemplateLabel = useDefaultTemplateLabel(
      postType2,
      postId2,
      slug
    );
    const templateLabel = (0, import_data9.useSelect)(
      (select7) => {
        if (!templateSlug) {
          return;
        }
        const allTemplates = select7(
          import_core_data7.store
        ).getEntityRecords("postType", "wp_template", {
          per_page: -1,
          post_type: postType2
        });
        const match3 = allTemplates?.find(
          (t4) => t4.slug === templateSlug
        );
        return match3 ? getItemTitle(match3) : void 0;
      },
      [postType2, templateSlug]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_jsx_runtime109.Fragment, { children: templateLabel ?? defaultTemplateLabel });
  }
  var TemplateView = ({
    item,
    field
  }) => {
    const mode = useTemplateFieldMode(item);
    if (!mode || !["block-theme", "classic"].includes(mode)) {
      return null;
    }
    const View4 = mode === "classic" ? ClassicTemplateView : BlockThemeTemplateView;
    return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(View4, { item, field });
  };

  // packages/fields/build-module/fields/template/index.mjs
  var templateField = {
    id: "template",
    type: "text",
    label: (0, import_i18n17.__)("Template"),
    Edit: TemplateEdit,
    render: TemplateView,
    enableSorting: false,
    filterBy: false
  };
  var template_default = templateField;

  // packages/fields/build-module/fields/parent/index.mjs
  var import_i18n21 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/parent/parent-edit.mjs
  var import_remove_accents = __toESM(require_remove_accents(), 1);
  var import_components7 = __toESM(require_components(), 1);
  var import_data10 = __toESM(require_data(), 1);
  var import_element26 = __toESM(require_element(), 1);
  var import_core_data8 = __toESM(require_core_data(), 1);
  var import_compose2 = __toESM(require_compose(), 1);
  var import_html_entities3 = __toESM(require_html_entities(), 1);
  var import_i18n19 = __toESM(require_i18n(), 1);
  var import_url4 = __toESM(require_url(), 1);

  // packages/fields/build-module/fields/parent/utils.mjs
  var import_html_entities2 = __toESM(require_html_entities(), 1);
  var import_i18n18 = __toESM(require_i18n(), 1);
  function getTitleWithFallbackName(post2) {
    return typeof post2.title === "object" && "rendered" in post2.title && post2.title.rendered ? (0, import_html_entities2.decodeEntities)(post2.title.rendered) : `#${post2?.id} (${(0, import_i18n18.__)("no title")})`;
  }

  // packages/fields/build-module/fields/parent/parent-edit.mjs
  var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
  function buildTermsTree(flatTerms) {
    const flatTermsWithParentAndChildren = flatTerms.map((term) => {
      return {
        children: [],
        ...term
      };
    });
    if (flatTermsWithParentAndChildren.some(
      ({ parent }) => parent === null || parent === void 0
    )) {
      return flatTermsWithParentAndChildren;
    }
    const termsByParent = flatTermsWithParentAndChildren.reduce(
      (acc, term) => {
        const { parent } = term;
        if (!acc[parent]) {
          acc[parent] = [];
        }
        acc[parent].push(term);
        return acc;
      },
      {}
    );
    const fillWithChildren = (terms) => {
      return terms.map((term) => {
        const children = termsByParent[term.id];
        return {
          ...term,
          children: children && children.length ? fillWithChildren(children) : []
        };
      });
    };
    return fillWithChildren(termsByParent["0"] || []);
  }
  var getItemPriority = (name2, searchValue) => {
    const normalizedName = (0, import_remove_accents.default)(name2 || "").toLowerCase();
    const normalizedSearch = (0, import_remove_accents.default)(searchValue || "").toLowerCase();
    if (normalizedName === normalizedSearch) {
      return 0;
    }
    if (normalizedName.startsWith(normalizedSearch)) {
      return normalizedName.length;
    }
    return Infinity;
  };
  function PageAttributesParent({
    data,
    onChangeControl
  }) {
    const [fieldValue, setFieldValue] = (0, import_element26.useState)("");
    const pageId = data.parent;
    const postId2 = data.id;
    const postTypeSlug = data.type;
    const { parentPostTitle, pageItems, isHierarchical } = (0, import_data10.useSelect)(
      (select7) => {
        const { getEntityRecord, getEntityRecords, getPostType } = select7(import_core_data8.store);
        const postTypeInfo = getPostType(postTypeSlug);
        const postIsHierarchical = postTypeInfo?.hierarchical && postTypeInfo.viewable;
        const parentPost = pageId ? getEntityRecord(
          "postType",
          postTypeSlug,
          pageId
        ) : null;
        const query = {
          per_page: 100,
          exclude: postId2,
          parent_exclude: postId2,
          orderby: "menu_order",
          order: "asc",
          _fields: "id,title,parent",
          ...!!fieldValue && {
            // Perform a search by relevance when the field is changed.
            search: fieldValue,
            orderby: "relevance"
          }
        };
        return {
          isHierarchical: postIsHierarchical,
          parentPostTitle: parentPost ? getTitleWithFallbackName(parentPost) : "",
          pageItems: postIsHierarchical ? getEntityRecords(
            "postType",
            postTypeSlug,
            query
          ) : null
        };
      },
      [fieldValue, pageId, postId2, postTypeSlug]
    );
    const parentOptions = (0, import_element26.useMemo)(() => {
      const getOptionsFromTree = (tree2, level = 0) => {
        const mappedNodes = tree2.map((treeNode) => [
          {
            value: treeNode.id,
            label: "\u2014 ".repeat(level) + (0, import_html_entities3.decodeEntities)(treeNode.name),
            rawName: treeNode.name
          },
          ...getOptionsFromTree(treeNode.children || [], level + 1)
        ]);
        const sortedNodes = mappedNodes.sort(([a3], [b3]) => {
          const priorityA = getItemPriority(a3.rawName, fieldValue);
          const priorityB = getItemPriority(b3.rawName, fieldValue);
          return priorityA >= priorityB ? 1 : -1;
        });
        return sortedNodes.flat();
      };
      if (!pageItems) {
        return [];
      }
      let tree = pageItems.map((item) => ({
        id: item.id,
        parent: item.parent ?? null,
        name: getTitleWithFallbackName(item)
      }));
      if (!fieldValue) {
        tree = buildTermsTree(tree);
      }
      const opts = getOptionsFromTree(tree);
      const optsHasParent = opts.find((item) => item.value === pageId);
      if (pageId && parentPostTitle && !optsHasParent) {
        opts.unshift({
          value: pageId,
          label: parentPostTitle,
          rawName: ""
        });
      }
      return opts.map((option) => ({
        ...option,
        value: option.value.toString()
      }));
    }, [pageItems, fieldValue, parentPostTitle, pageId]);
    if (!isHierarchical) {
      return null;
    }
    const handleKeydown = (inputValue) => {
      setFieldValue(inputValue);
    };
    const handleChange = (selectedPostId) => {
      if (selectedPostId) {
        return onChangeControl(parseInt(selectedPostId, 10) ?? 0);
      }
      onChangeControl(0);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
      import_components7.ComboboxControl,
      {
        __next40pxDefaultSize: true,
        label: (0, import_i18n19.__)("Parent"),
        help: (0, import_i18n19.__)("Choose a parent page."),
        value: pageId?.toString(),
        options: parentOptions,
        onFilterValueChange: (0, import_compose2.debounce)(
          (value) => handleKeydown(value),
          300
        ),
        onChange: handleChange,
        hideLabelFromVision: true
      }
    );
  }
  var ParentEdit = ({
    data,
    field,
    onChange
  }) => {
    const { id } = field;
    const homeUrl = (0, import_data10.useSelect)((select7) => {
      return select7(import_core_data8.store).getEntityRecord("root", "__unstableBase")?.home;
    }, []);
    const onChangeControl = (0, import_element26.useCallback)(
      (newValue) => onChange({
        [id]: newValue
      }),
      [id, onChange]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("fieldset", { className: "fields-controls__parent", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { children: [
      (0, import_element26.createInterpolateElement)(
        (0, import_i18n19.sprintf)(
          /* translators: %1$s The home URL of the WordPress installation without the scheme. */
          (0, import_i18n19.__)(
            'Child pages inherit characteristics from their parent, such as URL structure. For instance, if "Pricing" is a child of "Services", its URL would be %1$s<wbr />/services<wbr />/pricing.'
          ),
          (0, import_url4.filterURLForDisplay)(homeUrl).replace(
            /([/.])/g,
            "<wbr />$1"
          )
        ),
        {
          wbr: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("wbr", {})
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("p", { children: (0, import_element26.createInterpolateElement)(
        (0, import_i18n19.__)(
          "They also show up as sub-items in the default navigation menu. <a>Learn more.</a>"
        ),
        {
          a: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
            import_components7.ExternalLink,
            {
              href: (0, import_i18n19.__)(
                "https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes"
              ),
              children: void 0
            }
          )
        }
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
        PageAttributesParent,
        {
          data,
          onChangeControl
        }
      )
    ] }) });
  };

  // packages/fields/build-module/fields/parent/parent-view.mjs
  var import_data11 = __toESM(require_data(), 1);
  var import_core_data9 = __toESM(require_core_data(), 1);
  var import_i18n20 = __toESM(require_i18n(), 1);
  var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
  var ParentView = ({
    item
  }) => {
    const parent = (0, import_data11.useSelect)(
      (select7) => {
        const { getEntityRecord } = select7(import_core_data9.store);
        return item?.parent ? getEntityRecord("postType", item.type, item.parent) : null;
      },
      [item.parent, item.type]
    );
    if (parent) {
      return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_jsx_runtime111.Fragment, { children: getTitleWithFallbackName(parent) });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_jsx_runtime111.Fragment, { children: (0, import_i18n20.__)("None") });
  };

  // packages/fields/build-module/fields/parent/index.mjs
  var parentField = {
    id: "parent",
    type: "text",
    label: (0, import_i18n21.__)("Parent"),
    Edit: ParentEdit,
    render: ParentView,
    enableSorting: true,
    filterBy: false
  };
  var parent_default = parentField;

  // packages/fields/build-module/fields/password/index.mjs
  var import_i18n23 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/password/edit.mjs
  var import_components8 = __toESM(require_components(), 1);
  var import_element27 = __toESM(require_element(), 1);
  var import_i18n22 = __toESM(require_i18n(), 1);
  var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
  function PasswordEdit({
    data,
    onChange,
    field
  }) {
    const [showPassword, setShowPassword] = (0, import_element27.useState)(
      !!field.getValue({ item: data })
    );
    const handleTogglePassword = (value) => {
      setShowPassword(value);
      if (!value) {
        onChange({ password: "" });
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
      import_components8.__experimentalVStack,
      {
        as: "fieldset",
        spacing: 4,
        className: "fields-controls__password",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
            import_components8.CheckboxControl,
            {
              label: (0, import_i18n22.__)("Password protected"),
              help: (0, import_i18n22.__)("Only visible to those who know the password"),
              checked: showPassword,
              onChange: handleTogglePassword
            }
          ),
          showPassword && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "fields-controls__password-input", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
            import_components8.TextControl,
            {
              label: (0, import_i18n22.__)("Password"),
              onChange: (value) => onChange({
                password: value
              }),
              value: field.getValue({ item: data }) || "",
              placeholder: (0, import_i18n22.__)("Use a secure password"),
              type: "text",
              __next40pxDefaultSize: true,
              maxLength: 255
            }
          ) })
        ]
      }
    );
  }
  var edit_default = PasswordEdit;

  // packages/fields/build-module/fields/password/index.mjs
  var passwordField = {
    id: "password",
    type: "text",
    label: (0, import_i18n23.__)("Password"),
    Edit: edit_default,
    enableSorting: false,
    enableHiding: false,
    isVisible: (item) => item.status !== "private",
    filterBy: false
  };
  var password_default = passwordField;

  // packages/fields/build-module/fields/status/index.mjs
  var import_i18n25 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/status/status-view.mjs
  var import_components9 = __toESM(require_components(), 1);

  // packages/fields/build-module/fields/status/status-elements.mjs
  var import_i18n24 = __toESM(require_i18n(), 1);
  var STATUSES = [
    {
      value: "draft",
      label: (0, import_i18n24.__)("Draft"),
      icon: drafts_default,
      description: (0, import_i18n24.__)("Not ready to publish.")
    },
    {
      value: "future",
      label: (0, import_i18n24.__)("Scheduled"),
      icon: scheduled_default,
      description: (0, import_i18n24.__)("Publish automatically on a chosen date.")
    },
    {
      value: "pending",
      label: (0, import_i18n24.__)("Pending Review"),
      icon: pending_default,
      description: (0, import_i18n24.__)("Waiting for review before publishing.")
    },
    {
      value: "private",
      label: (0, import_i18n24.__)("Private"),
      icon: not_allowed_default,
      description: (0, import_i18n24.__)("Only visible to site admins and editors.")
    },
    {
      value: "publish",
      label: (0, import_i18n24.__)("Published"),
      icon: published_default,
      description: (0, import_i18n24.__)("Visible to everyone.")
    },
    { value: "trash", label: (0, import_i18n24.__)("Trash"), icon: trash_default }
  ];
  var status_elements_default = STATUSES;

  // packages/fields/build-module/fields/status/status-view.mjs
  var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
  function StatusView({ item }) {
    const status = status_elements_default.find(({ value }) => value === item.status);
    const label = status?.label || item.status;
    const icon = status?.icon;
    return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(import_components9.__experimentalHStack, { alignment: "left", spacing: 0, children: [
      icon && /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("div", { className: "fields-controls__status-icon", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components9.Icon, { icon }) }),
      /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("span", { children: label })
    ] });
  }
  var status_view_default = StatusView;

  // packages/fields/build-module/fields/status/index.mjs
  var OPERATOR_IS_ANY = "isAny";
  var statusField = {
    label: (0, import_i18n25.__)("Status"),
    id: "status",
    type: "text",
    elements: status_elements_default,
    render: status_view_default,
    Edit: "radio",
    enableSorting: false,
    filterBy: {
      operators: [OPERATOR_IS_ANY]
    }
  };
  var status_default = statusField;

  // packages/fields/build-module/fields/comment-status/index.mjs
  var import_i18n26 = __toESM(require_i18n(), 1);
  var commentStatusField = {
    id: "comment_status",
    label: (0, import_i18n26.__)("Comments"),
    type: "text",
    Edit: "radio",
    enableSorting: false,
    enableHiding: false,
    filterBy: false,
    elements: [
      {
        value: "open",
        label: (0, import_i18n26.__)("Open"),
        description: (0, import_i18n26.__)("Visitors can add new comments and replies.")
      },
      {
        value: "closed",
        label: (0, import_i18n26.__)("Closed"),
        description: (0, import_i18n26.__)(
          "Visitors cannot add new comments or replies. Existing comments remain visible."
        )
      }
    ]
  };
  var comment_status_default = commentStatusField;

  // packages/fields/build-module/fields/ping-status/index.mjs
  var import_i18n27 = __toESM(require_i18n(), 1);
  var import_components10 = __toESM(require_components(), 1);
  var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
  function PingStatusEdit({
    data,
    onChange
  }) {
    const pingStatus = data?.ping_status ?? "open";
    const onTogglePingback = (checked) => {
      onChange({
        ...data,
        ping_status: checked ? "open" : "closed"
      });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
      import_components10.CheckboxControl,
      {
        label: (0, import_i18n27.__)("Enable pingbacks & trackbacks"),
        checked: pingStatus === "open",
        onChange: onTogglePingback,
        help: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
          import_components10.ExternalLink,
          {
            href: (0, import_i18n27.__)(
              "https://wordpress.org/documentation/article/trackbacks-and-pingbacks/"
            ),
            children: (0, import_i18n27.__)("Learn more about pingbacks & trackbacks")
          }
        )
      }
    );
  }
  var pingStatusField = {
    id: "ping_status",
    label: (0, import_i18n27.__)("Trackbacks & Pingbacks"),
    type: "text",
    Edit: PingStatusEdit,
    enableSorting: false,
    enableHiding: false,
    filterBy: false,
    elements: [
      {
        value: "open",
        label: (0, import_i18n27.__)("Allow"),
        description: (0, import_i18n27.__)(
          "Allow link notifications from other blogs (pingbacks and trackbacks) on new articles."
        )
      },
      {
        value: "closed",
        label: (0, import_i18n27.__)("Don't allow"),
        description: (0, import_i18n27.__)(
          "Don't allow link notifications from other blogs (pingbacks and trackbacks) on new articles."
        )
      }
    ]
  };
  var ping_status_default = pingStatusField;

  // packages/fields/build-module/fields/discussion/index.mjs
  var import_i18n28 = __toESM(require_i18n(), 1);
  var discussionField = {
    id: "discussion",
    label: (0, import_i18n28.__)("Discussion"),
    type: "text",
    render: ({ item }) => {
      const commentsOpen = item.comment_status === "open";
      const pingsOpen = item.ping_status === "open";
      if (commentsOpen && pingsOpen) {
        return (0, import_i18n28.__)("Open");
      }
      if (commentsOpen && !pingsOpen) {
        return (0, import_i18n28.__)("Comments only");
      }
      if (!commentsOpen && pingsOpen) {
        return (0, import_i18n28.__)("Pings only");
      }
      return (0, import_i18n28.__)("Closed");
    },
    filterBy: false
  };
  var discussion_default = discussionField;

  // packages/fields/build-module/fields/date/index.mjs
  var import_i18n30 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/date/date-view.mjs
  var import_i18n29 = __toESM(require_i18n(), 1);
  var import_element28 = __toESM(require_element(), 1);
  var import_date2 = __toESM(require_date(), 1);
  var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
  var getFormattedDate = (dateToDisplay) => (0, import_date2.dateI18n)(
    (0, import_date2.getSettings)().formats.datetimeAbbreviated,
    (0, import_date2.getDate)(dateToDisplay)
  );
  var DateView = ({ item }) => {
    const isDraftOrPrivate = ["draft", "private"].includes(
      item.status ?? ""
    );
    if (isDraftOrPrivate) {
      return (0, import_element28.createInterpolateElement)(
        (0, import_i18n29.sprintf)(
          /* translators: %s: page creation or modification date. */
          (0, import_i18n29.__)("<span>Modified: <time>%s</time></span>"),
          getFormattedDate(item.date ?? null)
        ),
        {
          span: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("span", {}),
          time: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("time", {})
        }
      );
    }
    const isScheduled = item.status === "future";
    if (isScheduled) {
      return (0, import_element28.createInterpolateElement)(
        (0, import_i18n29.sprintf)(
          /* translators: %s: page creation date */
          (0, import_i18n29.__)("<span>Scheduled: <time>%s</time></span>"),
          getFormattedDate(item.date ?? null)
        ),
        {
          span: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("span", {}),
          time: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("time", {})
        }
      );
    }
    const isPublished = item.status === "publish";
    if (isPublished) {
      return (0, import_element28.createInterpolateElement)(
        (0, import_i18n29.sprintf)(
          /* translators: %s: page creation time */
          (0, import_i18n29.__)("<span>Published: <time>%s</time></span>"),
          getFormattedDate(item.date ?? null)
        ),
        {
          span: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("span", {}),
          time: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("time", {})
        }
      );
    }
    const dateToDisplay = (0, import_date2.getDate)(item.modified ?? null) > (0, import_date2.getDate)(item.date ?? null) ? item.modified : item.date;
    const isPending = item.status === "pending";
    if (isPending) {
      return (0, import_element28.createInterpolateElement)(
        (0, import_i18n29.sprintf)(
          /* translators: %s: page creation or modification date. */
          (0, import_i18n29.__)("<span>Modified: <time>%s</time></span>"),
          getFormattedDate(dateToDisplay ?? null)
        ),
        {
          span: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("span", {}),
          time: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("time", {})
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("time", { children: getFormattedDate(item.date ?? null) });
  };
  var date_view_default = DateView;

  // packages/fields/build-module/fields/date/index.mjs
  var dateField = {
    id: "date",
    type: "datetime",
    label: (0, import_i18n30.__)("Date"),
    render: date_view_default,
    filterBy: {
      operators: ["before", "after"]
    }
  };
  var date_default = dateField;

  // packages/fields/build-module/fields/date/scheduled/index.mjs
  var import_i18n31 = __toESM(require_i18n(), 1);
  var scheduledDateField = {
    id: "scheduled_date",
    type: "datetime",
    label: (0, import_i18n31.__)("Scheduled Date"),
    getValue: ({ item }) => item.date,
    setValue: ({ value }) => ({ date: value }),
    isVisible: (item) => item.status === "future",
    Edit: {
      control: "datetime",
      compact: true
    },
    enableHiding: false,
    enableSorting: false,
    filterBy: false
  };
  var scheduled_default2 = scheduledDateField;

  // packages/fields/build-module/fields/author/index.mjs
  var import_i18n33 = __toESM(require_i18n(), 1);
  var import_data13 = __toESM(require_data(), 1);
  var import_core_data11 = __toESM(require_core_data(), 1);

  // packages/fields/build-module/fields/author/author-view.mjs
  var import_i18n32 = __toESM(require_i18n(), 1);
  var import_element29 = __toESM(require_element(), 1);
  var import_components11 = __toESM(require_components(), 1);
  var import_data12 = __toESM(require_data(), 1);
  var import_core_data10 = __toESM(require_core_data(), 1);
  var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
  function AuthorView({ item }) {
    const authorId = item?.author;
    const embeddedAuthorId = item?._embedded?.author?.[0]?.id;
    const shouldFetch = Boolean(
      authorId && (!embeddedAuthorId || authorId !== embeddedAuthorId)
    );
    const author = (0, import_data12.useSelect)(
      (select7) => {
        if (!shouldFetch) {
          return null;
        }
        const { getEntityRecord } = select7(import_core_data10.store);
        return authorId ? getEntityRecord("root", "user", authorId) : null;
      },
      [authorId, shouldFetch]
    );
    const text = author?.name || item?._embedded?.author?.[0]?.name;
    const imageUrl = author?.avatar_urls?.[48] || item?._embedded?.author?.[0]?.avatar_urls?.[48];
    const [isImageLoaded, setIsImageLoaded] = (0, import_element29.useState)(false);
    return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(import_components11.__experimentalHStack, { alignment: "left", spacing: 0, children: [
      !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
        "div",
        {
          className: clsx_default("fields-controls__author-avatar", {
            "is-loaded": isImageLoaded
          }),
          children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
            "img",
            {
              onLoad: () => setIsImageLoaded(true),
              alt: (0, import_i18n32.__)("Author avatar"),
              src: imageUrl
            }
          )
        }
      ),
      !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("div", { className: "fields-controls__author-icon", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components11.Icon, { icon: comment_author_avatar_default }) }),
      /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { className: "fields-controls__author-name", children: text })
    ] });
  }
  var author_view_default = AuthorView;

  // packages/fields/build-module/fields/author/index.mjs
  var authorField = {
    label: (0, import_i18n33.__)("Author"),
    id: "author",
    type: "integer",
    getElements: async () => {
      const authors = await (0, import_data13.resolveSelect)(import_core_data11.store).getEntityRecords(
        "root",
        "user",
        {
          per_page: -1,
          who: "authors",
          _fields: "id,name",
          context: "view"
        }
      ) ?? [];
      return authors.map(({ id, name: name2 }) => ({
        value: id,
        label: name2
      }));
    },
    setValue: ({ value }) => ({ author: Number(value) }),
    render: author_view_default,
    sort: (a3, b3, direction) => {
      const nameA = a3._embedded?.author?.[0]?.name || "";
      const nameB = b3._embedded?.author?.[0]?.name || "";
      return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
    },
    filterBy: {
      operators: ["isAny", "isNone"]
    }
  };
  var author_default = authorField;

  // packages/fields/build-module/fields/notes/index.mjs
  var import_i18n34 = __toESM(require_i18n(), 1);
  var notesField = {
    id: "notesCount",
    label: (0, import_i18n34.__)("Notes"),
    type: "integer",
    enableSorting: false,
    filterBy: false
  };
  var notes_default = notesField;

  // packages/fields/build-module/fields/excerpt/index.mjs
  var import_html_entities4 = __toESM(require_html_entities(), 1);
  var import_i18n35 = __toESM(require_i18n(), 1);
  var import_components12 = __toESM(require_components(), 1);
  var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
  var excerptField = {
    id: "excerpt",
    type: "text",
    label: (0, import_i18n35.__)("Excerpt"),
    placeholder: (0, import_i18n35.__)("Add an excerpt"),
    description: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
      import_components12.ExternalLink,
      {
        href: (0, import_i18n35.__)(
          "https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt"
        ),
        children: (0, import_i18n35.__)("Learn more about manual excerpts")
      }
    ),
    render: ({ item }) => {
      let excerpt;
      if (typeof item.excerpt === "string") {
        excerpt = !!item.excerpt ? (0, import_html_entities4.decodeEntities)(item.excerpt) : (0, import_i18n35.__)("Add an excerpt");
      } else {
        excerpt = (0, import_html_entities4.decodeEntities)(item.excerpt?.raw || "");
      }
      return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_components12.__experimentalText, { align: "left", numberOfLines: 3, truncate: true, children: excerpt });
    },
    Edit: {
      control: "textarea",
      rows: 4
    },
    enableSorting: false,
    filterBy: false
  };
  var excerpt_default = excerptField;

  // packages/fields/build-module/fields/format/index.mjs
  var import_i18n36 = __toESM(require_i18n(), 1);
  var import_data14 = __toESM(require_data(), 1);
  var import_core_data12 = __toESM(require_core_data(), 1);
  var POST_FORMATS = [
    { id: "aside", caption: (0, import_i18n36.__)("Aside") },
    { id: "audio", caption: (0, import_i18n36.__)("Audio") },
    { id: "chat", caption: (0, import_i18n36.__)("Chat") },
    { id: "gallery", caption: (0, import_i18n36.__)("Gallery") },
    { id: "image", caption: (0, import_i18n36.__)("Image") },
    { id: "link", caption: (0, import_i18n36.__)("Link") },
    { id: "quote", caption: (0, import_i18n36.__)("Quote") },
    { id: "standard", caption: (0, import_i18n36.__)("Standard") },
    { id: "status", caption: (0, import_i18n36.__)("Status") },
    { id: "video", caption: (0, import_i18n36.__)("Video") }
  ].sort((a3, b3) => {
    const normalizedA = a3.caption.toUpperCase();
    const normalizedB = b3.caption.toUpperCase();
    if (normalizedA < normalizedB) {
      return -1;
    }
    if (normalizedA > normalizedB) {
      return 1;
    }
    return 0;
  });
  var formatField = {
    id: "format",
    label: (0, import_i18n36.__)("Format"),
    type: "text",
    Edit: "radio",
    enableSorting: false,
    enableHiding: false,
    filterBy: false,
    getElements: async () => {
      const themeSupports = await (0, import_data14.resolveSelect)(import_core_data12.store).getThemeSupports();
      return POST_FORMATS.filter(
        (f3) => themeSupports?.formats?.includes(
          f3.id
        )
      ).map((f3) => ({ value: f3.id, label: f3.caption }));
    }
  };
  var format_default = formatField;

  // packages/fields/build-module/fields/post-content-info/index.mjs
  var import_i18n38 = __toESM(require_i18n(), 1);

  // packages/fields/build-module/fields/post-content-info/post-content-info-view.mjs
  var import_components13 = __toESM(require_components(), 1);
  var import_i18n37 = __toESM(require_i18n(), 1);
  var import_wordcount = __toESM(require_wordcount(), 1);
  var import_date3 = __toESM(require_date(), 1);
  var import_element30 = __toESM(require_element(), 1);
  var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
  var AVERAGE_READING_RATE = 189;
  function PostContentInfoView({
    item
  }) {
    let content = "";
    if (typeof item.content === "string") {
      content = item.content;
    } else if (typeof item.content === "function") {
      content = item.content(item);
    }
    const wordCountType = (0, import_i18n37._x)(
      "words",
      "Word count type. Do not translate!"
    );
    const wordsCounted = (0, import_element30.useMemo)(
      () => content ? (0, import_wordcount.count)(content, wordCountType) : 0,
      [content, wordCountType]
    );
    const modified = item.modified;
    if (!wordsCounted && !modified) {
      return null;
    }
    let contentInfoText;
    if (wordsCounted) {
      const readingTime = Math.round(wordsCounted / AVERAGE_READING_RATE);
      const wordsCountText = (0, import_i18n37.sprintf)(
        // translators: %s: the number of words in the post.
        (0, import_i18n37._n)("%s word", "%s words", wordsCounted),
        wordsCounted.toLocaleString()
      );
      const minutesText = readingTime <= 1 ? (0, import_i18n37.__)("1 minute") : (0, import_i18n37.sprintf)(
        /* translators: %s: the number of minutes to read the post. */
        (0, import_i18n37._n)("%s minute", "%s minutes", readingTime),
        readingTime.toLocaleString()
      );
      contentInfoText = (0, import_i18n37.sprintf)(
        /* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */
        (0, import_i18n37.__)("%1$s, %2$s read time."),
        wordsCountText,
        minutesText
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(import_components13.__experimentalVStack, { spacing: 1, children: [
      contentInfoText && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components13.__experimentalText, { variant: "muted", children: contentInfoText }),
      modified && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components13.__experimentalText, { variant: "muted", children: (0, import_i18n37.sprintf)(
        // translators: %s: Human-readable time difference, e.g. "2 days ago".
        (0, import_i18n37.__)("Last edited %s."),
        (0, import_date3.humanTimeDiff)(modified)
      ) })
    ] });
  }

  // packages/fields/build-module/fields/post-content-info/index.mjs
  var postContentInfoField = {
    label: (0, import_i18n38.__)("Post content information"),
    id: "post-content-info",
    type: "text",
    readOnly: true,
    render: PostContentInfoView,
    enableSorting: false,
    enableHiding: false,
    filterBy: false
  };
  var post_content_info_default = postContentInfoField;

  // packages/fields/build-module/fields/sticky/index.mjs
  var import_i18n39 = __toESM(require_i18n(), 1);
  var stickyField = {
    id: "sticky",
    type: "boolean",
    label: (0, import_i18n39.__)("Sticky"),
    description: (0, import_i18n39.__)("Pin this post to the top of the blog."),
    enableSorting: false,
    enableHiding: false,
    isVisible: (item) => !!item._links?.["wp:action-sticky"],
    filterBy: false
  };
  var sticky_default = stickyField;

  // packages/fields/build-module/actions/view-post.mjs
  var import_i18n40 = __toESM(require_i18n(), 1);
  var viewPost = {
    id: "view-post",
    label: (0, import_i18n40._x)("View", "verb"),
    isPrimary: true,
    icon: external_default,
    isEligible(post2) {
      return post2.status !== "trash";
    },
    callback(posts, { onActionPerformed }) {
      const post2 = posts[0];
      window.open(post2?.link, "_blank");
      if (onActionPerformed) {
        onActionPerformed(posts);
      }
    }
  };
  var view_post_default = viewPost;

  // packages/fields/build-module/actions/reorder-page.mjs
  var import_data15 = __toESM(require_data(), 1);
  var import_core_data13 = __toESM(require_core_data(), 1);
  var import_i18n41 = __toESM(require_i18n(), 1);
  var import_notices4 = __toESM(require_notices(), 1);
  var import_element31 = __toESM(require_element(), 1);
  var import_components14 = __toESM(require_components(), 1);
  var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
  function isItemValid(item) {
    return typeof item.menu_order === "number" && Number.isInteger(item.menu_order);
  }
  function ReorderModal({
    items,
    closeModal: closeModal2,
    onActionPerformed
  }) {
    const [item, setItem] = (0, import_element31.useState)(items[0]);
    const { editEntityRecord, saveEditedEntityRecord } = (0, import_data15.useDispatch)(import_core_data13.store);
    const { createSuccessNotice, createErrorNotice } = (0, import_data15.useDispatch)(import_notices4.store);
    const isValid2 = isItemValid(item);
    async function onOrder(event) {
      event.preventDefault();
      if (!isValid2) {
        return;
      }
      try {
        await editEntityRecord("postType", item.type, item.id, {
          menu_order: item.menu_order
        });
        closeModal2?.();
        await saveEditedEntityRecord("postType", item.type, item.id, {
          throwOnError: true
        });
        createSuccessNotice((0, import_i18n41.__)("Order updated."), {
          type: "snackbar"
        });
        onActionPerformed?.(items);
      } catch (error2) {
        const typedError = error2;
        const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n41.__)("An error occurred while updating the order");
        createErrorNotice(errorMessage, {
          type: "snackbar"
        });
      }
    }
    return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("form", { onSubmit: onOrder, children: /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(import_components14.__experimentalVStack, { spacing: "5", children: [
      /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { children: (0, import_i18n41.__)(
        "Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported."
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
        import_components14.__experimentalInputControl,
        {
          __next40pxDefaultSize: true,
          label: (0, import_i18n41.__)("Order"),
          type: "number",
          value: typeof item.menu_order === "number" && Number.isInteger(item.menu_order) ? String(item.menu_order) : "",
          onChange: (value) => {
            const parsed = parseInt(value, 10);
            setItem({
              ...item,
              menu_order: isNaN(parsed) ? void 0 : parsed
            });
          }
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(import_components14.__experimentalHStack, { justify: "right", children: [
        /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
          import_components14.Button,
          {
            __next40pxDefaultSize: true,
            variant: "tertiary",
            onClick: () => {
              closeModal2?.();
            },
            children: (0, import_i18n41.__)("Cancel")
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
          import_components14.Button,
          {
            __next40pxDefaultSize: true,
            variant: "primary",
            type: "submit",
            accessibleWhenDisabled: true,
            disabled: !isValid2,
            children: (0, import_i18n41.__)("Save")
          }
        )
      ] })
    ] }) });
  }
  var reorderPage = {
    id: "order-pages",
    label: (0, import_i18n41.__)("Order"),
    isEligible({ status }) {
      return status !== "trash";
    },
    modalFocusOnMount: "firstContentElement",
    RenderModal: ReorderModal
  };
  var reorder_page_default = reorderPage;

  // packages/fields/build-module/actions/duplicate-post.mjs
  var import_data16 = __toESM(require_data(), 1);
  var import_core_data14 = __toESM(require_core_data(), 1);
  var import_i18n42 = __toESM(require_i18n(), 1);
  var import_notices5 = __toESM(require_notices(), 1);
  var import_element32 = __toESM(require_element(), 1);
  var import_components15 = __toESM(require_components(), 1);
  var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
  var duplicatePost = {
    id: "duplicate-post",
    label: (0, import_i18n42._x)("Duplicate", "action label"),
    isEligible({ status }) {
      return status !== "trash";
    },
    modalFocusOnMount: "firstContentElement",
    RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
      const [item, setItem] = (0, import_element32.useState)({
        ...items[0],
        title: (0, import_i18n42.sprintf)(
          /* translators: %s: Existing post title */
          (0, import_i18n42._x)("%s (Copy)", "post"),
          getItemTitle(items[0])
        )
      });
      const [isCreatingPage, setIsCreatingPage] = (0, import_element32.useState)(false);
      const { saveEntityRecord } = (0, import_data16.useDispatch)(import_core_data14.store);
      const { createSuccessNotice, createErrorNotice } = (0, import_data16.useDispatch)(import_notices5.store);
      async function createPage(event) {
        event.preventDefault();
        if (isCreatingPage) {
          return;
        }
        const isTemplate2 = item.type === "wp_template";
        const newItemObject = {
          status: isTemplate2 ? "publish" : "draft",
          title: item.title,
          slug: isTemplate2 ? item.slug : item.title || (0, import_i18n42.__)("No title"),
          comment_status: item.comment_status,
          content: typeof item.content === "string" ? item.content : item.content.raw,
          excerpt: typeof item.excerpt === "string" ? item.excerpt : item.excerpt?.raw,
          meta: item.meta,
          parent: item.parent,
          password: item.password,
          template: item.template,
          format: item.format,
          featured_media: item.featured_media,
          menu_order: item.menu_order,
          ping_status: item.ping_status
        };
        const assignablePropertiesPrefix = "wp:action-assign-";
        const assignableProperties = Object.keys(item?._links || {}).filter(
          (property) => property.startsWith(assignablePropertiesPrefix)
        ).map(
          (property) => property.slice(assignablePropertiesPrefix.length)
        );
        assignableProperties.forEach((property) => {
          if (item.hasOwnProperty(property)) {
            newItemObject[property] = item[property];
          }
        });
        setIsCreatingPage(true);
        try {
          const newItem = await saveEntityRecord(
            "postType",
            item.type,
            newItemObject,
            { throwOnError: true }
          );
          createSuccessNotice(
            (0, import_i18n42.sprintf)(
              // translators: %s: Title of the created post, e.g: "Hello world".
              (0, import_i18n42.__)('"%s" successfully created.'),
              getItemTitle(newItem)
            ),
            {
              id: "duplicate-post-action",
              type: "snackbar"
            }
          );
          if (onActionPerformed) {
            onActionPerformed([newItem]);
          }
        } catch (error2) {
          const typedError = error2;
          const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n42.__)("An error occurred while duplicating the page.");
          createErrorNotice(errorMessage, {
            type: "snackbar"
          });
        } finally {
          setIsCreatingPage(false);
          closeModal2?.();
        }
      }
      return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("form", { onSubmit: createPage, children: /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_components15.__experimentalVStack, { spacing: 3, children: [
        typeof item.id === "string" && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("div", { children: (0, import_i18n42.__)(
          "You are about to duplicate a bundled template. Changes will not be live until you activate the new template."
        ) }),
        /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
          import_components15.__experimentalInputControl,
          {
            __next40pxDefaultSize: true,
            label: (0, import_i18n42.__)("Title"),
            placeholder: (0, import_i18n42.__)("No title"),
            value: getItemTitle(item),
            onChange: (value) => setItem((prev) => ({
              ...prev,
              title: value || (0, import_i18n42.__)("No title")
            }))
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_components15.__experimentalHStack, { spacing: 2, justify: "end", children: [
          /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
            import_components15.Button,
            {
              variant: "tertiary",
              onClick: closeModal2,
              __next40pxDefaultSize: true,
              children: (0, import_i18n42.__)("Cancel")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
            import_components15.Button,
            {
              variant: "primary",
              type: "submit",
              isBusy: isCreatingPage,
              "aria-disabled": isCreatingPage,
              __next40pxDefaultSize: true,
              children: (0, import_i18n42._x)("Duplicate", "action label")
            }
          )
        ] })
      ] }) });
    }
  };
  var duplicate_post_default = duplicatePost;

  // packages/fields/build-module/actions/rename-post.mjs
  var import_data17 = __toESM(require_data(), 1);
  var import_core_data15 = __toESM(require_core_data(), 1);
  var import_i18n43 = __toESM(require_i18n(), 1);
  var import_element33 = __toESM(require_element(), 1);
  var import_patterns2 = __toESM(require_patterns(), 1);
  var import_components16 = __toESM(require_components(), 1);
  var import_notices6 = __toESM(require_notices(), 1);
  var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
  var { PATTERN_TYPES: PATTERN_TYPES2 } = unlock2(import_patterns2.privateApis);
  var renamePost = {
    id: "rename-post",
    label: (0, import_i18n43.__)("Rename"),
    modalFocusOnMount: "firstContentElement",
    isEligible(post2) {
      if (post2.status === "trash") {
        return false;
      }
      if (post2.type === "wp_template" && typeof post2.id === "string" && window?.__experimentalTemplateActivate) {
        return false;
      }
      const specialChecks = ["wp_template", "wp_template_part"];
      if (!window?.__experimentalTemplateActivate) {
        specialChecks.push("wp_template");
      }
      if (!specialChecks.includes(post2.type)) {
        return post2.permissions?.update;
      }
      if (isTemplate(post2) && !window?.__experimentalTemplateActivate) {
        return isTemplateRemovable(post2) && post2.is_custom && post2.permissions?.update;
      }
      if (isTemplatePart(post2)) {
        return post2.source === "custom" && !post2?.has_theme_file && post2.permissions?.update;
      }
      return post2.type === PATTERN_TYPES2.user && post2.permissions?.update;
    },
    RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
      const [item] = items;
      const [title, setTitle] = (0, import_element33.useState)(() => getItemTitle(item, ""));
      const { editEntityRecord, saveEditedEntityRecord } = (0, import_data17.useDispatch)(import_core_data15.store);
      const { createSuccessNotice, createErrorNotice } = (0, import_data17.useDispatch)(import_notices6.store);
      async function onRename(event) {
        event.preventDefault();
        try {
          await editEntityRecord("postType", item.type, item.id, {
            title
          });
          setTitle("");
          closeModal2?.();
          await saveEditedEntityRecord("postType", item.type, item.id, {
            throwOnError: true
          });
          createSuccessNotice((0, import_i18n43.__)("Name updated"), {
            type: "snackbar"
          });
          onActionPerformed?.(items);
        } catch (error2) {
          const typedError = error2;
          const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n43.__)("An error occurred while updating the name");
          createErrorNotice(errorMessage, { type: "snackbar" });
        }
      }
      return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("form", { onSubmit: onRename, children: /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_components16.__experimentalVStack, { spacing: "5", children: [
        /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
          import_components16.TextControl,
          {
            __next40pxDefaultSize: true,
            label: (0, import_i18n43.__)("Name"),
            value: title,
            onChange: setTitle,
            required: true
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_components16.__experimentalHStack, { justify: "right", children: [
          /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
            import_components16.Button,
            {
              __next40pxDefaultSize: true,
              variant: "tertiary",
              onClick: () => {
                closeModal2?.();
              },
              children: (0, import_i18n43.__)("Cancel")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
            import_components16.Button,
            {
              __next40pxDefaultSize: true,
              variant: "primary",
              type: "submit",
              children: (0, import_i18n43.__)("Save")
            }
          )
        ] })
      ] }) });
    }
  };
  var rename_post_default = renamePost;

  // packages/fields/build-module/actions/reset-post.mjs
  var import_data18 = __toESM(require_data(), 1);
  var import_core_data16 = __toESM(require_core_data(), 1);
  var import_i18n44 = __toESM(require_i18n(), 1);
  var import_notices7 = __toESM(require_notices(), 1);
  var import_element34 = __toESM(require_element(), 1);
  var import_blocks3 = __toESM(require_blocks(), 1);
  var import_components17 = __toESM(require_components(), 1);
  var import_url5 = __toESM(require_url(), 1);
  var import_api_fetch2 = __toESM(require_api_fetch(), 1);
  var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
  var isTemplateRevertable2 = (templateOrTemplatePart) => {
    if (!templateOrTemplatePart) {
      return false;
    }
    return templateOrTemplatePart.source === "custom" && (Boolean(templateOrTemplatePart?.plugin) || templateOrTemplatePart?.has_theme_file);
  };
  var revertTemplate = async (template2, { allowUndo = true } = {}) => {
    const noticeId = "edit-site-template-reverted";
    (0, import_data18.dispatch)(import_notices7.store).removeNotice(noticeId);
    if (!isTemplateRevertable2(template2)) {
      (0, import_data18.dispatch)(import_notices7.store).createErrorNotice(
        (0, import_i18n44.__)("This template is not revertable."),
        {
          type: "snackbar"
        }
      );
      return;
    }
    try {
      const templateEntityConfig = (0, import_data18.select)(import_core_data16.store).getEntityConfig(
        "postType",
        template2.type
      );
      if (!templateEntityConfig) {
        (0, import_data18.dispatch)(import_notices7.store).createErrorNotice(
          (0, import_i18n44.__)(
            "The editor has encountered an unexpected error. Please reload."
          ),
          { type: "snackbar" }
        );
        return;
      }
      const fileTemplatePath = (0, import_url5.addQueryArgs)(
        `${templateEntityConfig.baseURL}/${template2.id}`,
        { context: "edit", source: template2.origin }
      );
      const fileTemplate = await (0, import_api_fetch2.default)({
        path: fileTemplatePath
      });
      if (!fileTemplate) {
        (0, import_data18.dispatch)(import_notices7.store).createErrorNotice(
          (0, import_i18n44.__)(
            "The editor has encountered an unexpected error. Please reload."
          ),
          { type: "snackbar" }
        );
        return;
      }
      const serializeBlocks = ({ blocks: blocksForSerialization = [] }) => (0, import_blocks3.__unstableSerializeAndClean)(blocksForSerialization);
      const edited = (0, import_data18.select)(import_core_data16.store).getEditedEntityRecord(
        "postType",
        template2.type,
        template2.id
      );
      (0, import_data18.dispatch)(import_core_data16.store).editEntityRecord(
        "postType",
        template2.type,
        template2.id,
        {
          content: serializeBlocks,
          // Required to make the `undo` behave correctly.
          blocks: edited.blocks,
          // Required to revert the blocks in the editor.
          source: "custom"
          // required to avoid turning the editor into a dirty state
        },
        {
          undoIgnore: true
          // Required to merge this edit with the last undo level.
        }
      );
      const blocks = (0, import_blocks3.parse)(fileTemplate?.content?.raw);
      (0, import_data18.dispatch)(import_core_data16.store).editEntityRecord(
        "postType",
        template2.type,
        fileTemplate.id,
        {
          content: serializeBlocks,
          blocks,
          source: "theme"
        }
      );
      if (allowUndo) {
        const undoRevert = () => {
          (0, import_data18.dispatch)(import_core_data16.store).editEntityRecord(
            "postType",
            template2.type,
            edited.id,
            {
              content: serializeBlocks,
              blocks: edited.blocks,
              source: "custom"
            }
          );
        };
        (0, import_data18.dispatch)(import_notices7.store).createSuccessNotice(
          (0, import_i18n44.__)("Template reset."),
          {
            type: "snackbar",
            id: noticeId,
            actions: [
              {
                label: (0, import_i18n44.__)("Undo"),
                onClick: undoRevert
              }
            ]
          }
        );
      }
    } catch (error2) {
      const errorMessage = error2.message && error2.code !== "unknown_error" ? error2.message : (0, import_i18n44.__)("Template revert failed. Please reload.");
      (0, import_data18.dispatch)(import_notices7.store).createErrorNotice(errorMessage, {
        type: "snackbar"
      });
    }
  };
  var resetPostAction = {
    id: "reset-post",
    label: (0, import_i18n44.__)("Reset"),
    isEligible: (item) => {
      if (window?.__experimentalTemplateActivate) {
        return item.type === "wp_template_part" && item?.source === "custom" && item?.has_theme_file;
      }
      return isTemplateOrTemplatePart(item) && item?.source === "custom" && (Boolean(item.type === "wp_template" && item?.plugin) || item?.has_theme_file);
    },
    icon: backup_default,
    supportsBulk: true,
    hideModalHeader: true,
    modalFocusOnMount: "firstContentElement",
    RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
      const [isBusy, setIsBusy] = (0, import_element34.useState)(false);
      const { saveEditedEntityRecord } = (0, import_data18.useDispatch)(import_core_data16.store);
      const { createSuccessNotice, createErrorNotice } = (0, import_data18.useDispatch)(import_notices7.store);
      const onConfirm = async () => {
        try {
          for (const template2 of items) {
            await revertTemplate(template2, {
              allowUndo: false
            });
            await saveEditedEntityRecord(
              "postType",
              template2.type,
              template2.id
            );
          }
          createSuccessNotice(
            items.length > 1 ? (0, import_i18n44.sprintf)(
              /* translators: %d: The number of items. */
              (0, import_i18n44.__)("%d items reset."),
              items.length
            ) : (0, import_i18n44.sprintf)(
              /* translators: %s: The template/part's name. */
              (0, import_i18n44.__)('"%s" reset.'),
              getItemTitle(items[0])
            ),
            {
              type: "snackbar",
              id: "revert-template-action"
            }
          );
        } catch (error2) {
          let fallbackErrorMessage;
          if (items[0].type === "wp_template") {
            fallbackErrorMessage = items.length === 1 ? (0, import_i18n44.__)(
              "An error occurred while reverting the template."
            ) : (0, import_i18n44.__)(
              "An error occurred while reverting the templates."
            );
          } else {
            fallbackErrorMessage = items.length === 1 ? (0, import_i18n44.__)(
              "An error occurred while reverting the template part."
            ) : (0, import_i18n44.__)(
              "An error occurred while reverting the template parts."
            );
          }
          const typedError = error2;
          const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : fallbackErrorMessage;
          createErrorNotice(errorMessage, { type: "snackbar" });
        }
      };
      return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(import_components17.__experimentalVStack, { spacing: "5", children: [
        /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components17.__experimentalText, { children: (0, import_i18n44.__)("Reset to default and clear all customizations?") }),
        /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(import_components17.__experimentalHStack, { justify: "right", children: [
          /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
            import_components17.Button,
            {
              __next40pxDefaultSize: true,
              variant: "tertiary",
              onClick: closeModal2,
              disabled: isBusy,
              accessibleWhenDisabled: true,
              children: (0, import_i18n44.__)("Cancel")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
            import_components17.Button,
            {
              __next40pxDefaultSize: true,
              variant: "primary",
              onClick: async () => {
                setIsBusy(true);
                await onConfirm();
                onActionPerformed?.(items);
                setIsBusy(false);
                closeModal2?.();
              },
              isBusy,
              disabled: isBusy,
              accessibleWhenDisabled: true,
              children: (0, import_i18n44.__)("Reset")
            }
          )
        ] })
      ] });
    }
  };
  var reset_post_default = resetPostAction;

  // packages/fields/build-module/actions/duplicate-pattern.mjs
  var import_i18n45 = __toESM(require_i18n(), 1);
  var import_patterns3 = __toESM(require_patterns(), 1);
  var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
  var { CreatePatternModalContents, useDuplicatePatternProps } = unlock2(import_patterns3.privateApis);
  var duplicatePattern = {
    id: "duplicate-pattern",
    label: (0, import_i18n45._x)("Duplicate", "action label"),
    isEligible: (item) => item.type !== "wp_template_part",
    modalHeader: (0, import_i18n45._x)("Duplicate pattern", "action label"),
    modalFocusOnMount: "firstContentElement",
    RenderModal: ({ items, closeModal: closeModal2 }) => {
      const [item] = items;
      const duplicatedProps = useDuplicatePatternProps({
        pattern: item,
        onSuccess: () => closeModal2?.()
      });
      return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
        CreatePatternModalContents,
        {
          onClose: closeModal2,
          confirmLabel: (0, import_i18n45._x)("Duplicate", "action label"),
          ...duplicatedProps
        }
      );
    }
  };
  var duplicate_pattern_default = duplicatePattern;

  // node_modules/tslib/tslib.es6.mjs
  var __assign = function() {
    __assign = Object.assign || function __assign2(t4) {
      for (var s3, i3 = 1, n3 = arguments.length; i3 < n3; i3++) {
        s3 = arguments[i3];
        for (var p4 in s3) if (Object.prototype.hasOwnProperty.call(s3, p4)) t4[p4] = s3[p4];
      }
      return t4;
    };
    return __assign.apply(this, arguments);
  };

  // node_modules/lower-case/dist.es2015/index.js
  function lowerCase(str3) {
    return str3.toLowerCase();
  }

  // node_modules/no-case/dist.es2015/index.js
  var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
  var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
  function noCase(input, options) {
    if (options === void 0) {
      options = {};
    }
    var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
    var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
    var start2 = 0;
    var end = result.length;
    while (result.charAt(start2) === "\0")
      start2++;
    while (result.charAt(end - 1) === "\0")
      end--;
    return result.slice(start2, end).split("\0").map(transform).join(delimiter);
  }
  function replace(input, re, value) {
    if (re instanceof RegExp)
      return input.replace(re, value);
    return re.reduce(function(input2, re2) {
      return input2.replace(re2, value);
    }, input);
  }

  // node_modules/dot-case/dist.es2015/index.js
  function dotCase(input, options) {
    if (options === void 0) {
      options = {};
    }
    return noCase(input, __assign({ delimiter: "." }, options));
  }

  // node_modules/param-case/dist.es2015/index.js
  function paramCase(input, options) {
    if (options === void 0) {
      options = {};
    }
    return dotCase(input, __assign({ delimiter: "-" }, options));
  }

  // node_modules/client-zip/index.js
  "stream" in Blob.prototype || Object.defineProperty(Blob.prototype, "stream", { value() {
    return new Response(this).body;
  } }), "setBigUint64" in DataView.prototype || Object.defineProperty(DataView.prototype, "setBigUint64", { value(e3, n3, t4) {
    const i3 = Number(0xffffffffn & n3), r4 = Number(n3 >> 32n);
    this.setUint32(e3 + (t4 ? 0 : 4), i3, t4), this.setUint32(e3 + (t4 ? 4 : 0), r4, t4);
  } });
  var e = (e3) => new DataView(new ArrayBuffer(e3));
  var n = (e3) => new Uint8Array(e3.buffer || e3);
  var t = (e3) => new TextEncoder().encode(String(e3));
  var i = (e3) => Math.min(4294967295, Number(e3));
  var r2 = (e3) => Math.min(65535, Number(e3));
  function f(e3, i3) {
    if (void 0 === i3 || i3 instanceof Date || (i3 = new Date(i3)), e3 instanceof File) return { isFile: 1, t: i3 || new Date(e3.lastModified), i: e3.stream() };
    if (e3 instanceof Response) return { isFile: 1, t: i3 || new Date(e3.headers.get("Last-Modified") || Date.now()), i: e3.body };
    if (void 0 === i3) i3 = /* @__PURE__ */ new Date();
    else if (isNaN(i3)) throw new Error("Invalid modification date.");
    if (void 0 === e3) return { isFile: 0, t: i3 };
    if ("string" == typeof e3) return { isFile: 1, t: i3, i: t(e3) };
    if (e3 instanceof Blob) return { isFile: 1, t: i3, i: e3.stream() };
    if (e3 instanceof Uint8Array || e3 instanceof ReadableStream) return { isFile: 1, t: i3, i: e3 };
    if (e3 instanceof ArrayBuffer || ArrayBuffer.isView(e3)) return { isFile: 1, t: i3, i: n(e3) };
    if (Symbol.asyncIterator in e3) return { isFile: 1, t: i3, i: o(e3[Symbol.asyncIterator]()) };
    throw new TypeError("Unsupported input format.");
  }
  function o(e3, n3 = e3) {
    return new ReadableStream({ async pull(n4) {
      let t4 = 0;
      for (; n4.desiredSize > t4; ) {
        const i3 = await e3.next();
        if (!i3.value) {
          n4.close();
          break;
        }
        {
          const e4 = a(i3.value);
          n4.enqueue(e4), t4 += e4.byteLength;
        }
      }
    }, cancel(e4) {
      n3.throw?.(e4);
    } });
  }
  function a(e3) {
    return "string" == typeof e3 ? t(e3) : e3 instanceof Uint8Array ? e3 : n(e3);
  }
  function s(e3, i3, r4) {
    let [f3, o4] = (function(e4) {
      return e4 ? e4 instanceof Uint8Array ? [e4, 1] : ArrayBuffer.isView(e4) || e4 instanceof ArrayBuffer ? [n(e4), 1] : [t(e4), 0] : [void 0, 0];
    })(i3);
    if (e3 instanceof File) return { o: d(f3 || t(e3.name)), u: BigInt(e3.size), l: o4 };
    if (e3 instanceof Response) {
      const n3 = e3.headers.get("content-disposition"), i4 = n3 && n3.match(/;\s*filename\*?=["']?(.*?)["']?$/i), a3 = i4 && i4[1] || e3.url && new URL(e3.url).pathname.split("/").findLast(Boolean), s3 = a3 && decodeURIComponent(a3), u3 = r4 || +e3.headers.get("content-length");
      return { o: d(f3 || t(s3)), u: BigInt(u3), l: o4 };
    }
    return f3 = d(f3, void 0 !== e3 || void 0 !== r4), "string" == typeof e3 ? { o: f3, u: BigInt(t(e3).length), l: o4 } : e3 instanceof Blob ? { o: f3, u: BigInt(e3.size), l: o4 } : e3 instanceof ArrayBuffer || ArrayBuffer.isView(e3) ? { o: f3, u: BigInt(e3.byteLength), l: o4 } : { o: f3, u: u(e3, r4), l: o4 };
  }
  function u(e3, n3) {
    return n3 > -1 ? BigInt(n3) : e3 ? void 0 : 0n;
  }
  function d(e3, n3 = 1) {
    if (!e3 || e3.every(((c6) => 47 === c6))) throw new Error("The file must have a name.");
    if (n3) for (; 47 === e3[e3.length - 1]; ) e3 = e3.subarray(0, -1);
    else 47 !== e3[e3.length - 1] && (e3 = new Uint8Array([...e3, 47]));
    return e3;
  }
  var l = new Uint32Array(256);
  for (let e3 = 0; e3 < 256; ++e3) {
    let n3 = e3;
    for (let e4 = 0; e4 < 8; ++e4) n3 = n3 >>> 1 ^ (1 & n3 && 3988292384);
    l[e3] = n3;
  }
  function y(e3, n3 = 0) {
    n3 ^= -1;
    for (var t4 = 0, i3 = e3.length; t4 < i3; t4++) n3 = n3 >>> 8 ^ l[255 & n3 ^ e3[t4]];
    return (-1 ^ n3) >>> 0;
  }
  function w(e3, n3, t4 = 0) {
    const i3 = e3.getSeconds() >> 1 | e3.getMinutes() << 5 | e3.getHours() << 11, r4 = e3.getDate() | e3.getMonth() + 1 << 5 | e3.getFullYear() - 1980 << 9;
    n3.setUint16(t4, i3, 1), n3.setUint16(t4 + 2, r4, 1);
  }
  function B({ o: e3, l: n3 }, t4) {
    return 8 * (!n3 || (t4 ?? (function(e4) {
      try {
        b.decode(e4);
      } catch {
        return 0;
      }
      return 1;
    })(e3)));
  }
  var b = new TextDecoder("utf8", { fatal: 1 });
  function p2(t4, i3 = 0) {
    const r4 = e(30);
    return r4.setUint32(0, 1347093252), r4.setUint32(4, 754976768 | i3), w(t4.t, r4, 10), r4.setUint16(26, t4.o.length, 1), n(r4);
  }
  async function* g(e3) {
    let { i: n3 } = e3;
    if ("then" in n3 && (n3 = await n3), n3 instanceof Uint8Array) yield n3, e3.m = y(n3, 0), e3.u = BigInt(n3.length);
    else {
      e3.u = 0n;
      const t4 = n3.getReader();
      for (; ; ) {
        const { value: n4, done: i3 } = await t4.read();
        if (i3) break;
        e3.m = y(n4, e3.m), e3.u += BigInt(n4.length), yield n4;
      }
    }
  }
  function I(t4, r4) {
    const f3 = e(16 + (r4 ? 8 : 0));
    return f3.setUint32(0, 1347094280), f3.setUint32(4, t4.isFile ? t4.m : 0, 1), r4 ? (f3.setBigUint64(8, t4.u, 1), f3.setBigUint64(16, t4.u, 1)) : (f3.setUint32(8, i(t4.u), 1), f3.setUint32(12, i(t4.u), 1)), n(f3);
  }
  function v(t4, r4, f3 = 0, o4 = 0) {
    const a3 = e(46);
    return a3.setUint32(0, 1347092738), a3.setUint32(4, 755182848), a3.setUint16(8, 2048 | f3), w(t4.t, a3, 12), a3.setUint32(16, t4.isFile ? t4.m : 0, 1), a3.setUint32(20, i(t4.u), 1), a3.setUint32(24, i(t4.u), 1), a3.setUint16(28, t4.o.length, 1), a3.setUint16(30, o4, 1), a3.setUint16(40, t4.isFile ? 33204 : 16893, 1), a3.setUint32(42, i(r4), 1), n(a3);
  }
  function h(t4, i3, r4) {
    const f3 = e(r4);
    return f3.setUint16(0, 1, 1), f3.setUint16(2, r4 - 4, 1), 16 & r4 && (f3.setBigUint64(4, t4.u, 1), f3.setBigUint64(12, t4.u, 1)), f3.setBigUint64(r4 - 8, i3, 1), n(f3);
  }
  function D(e3) {
    return e3 instanceof File || e3 instanceof Response ? [[e3], [e3]] : [[e3.input, e3.name, e3.size], [e3.input, e3.lastModified]];
  }
  var S = (e3) => (function(e4) {
    let n3 = BigInt(22), t4 = 0n, i3 = 0;
    for (const r4 of e4) {
      if (!r4.o) throw new Error("Every file must have a non-empty name.");
      if (void 0 === r4.u) throw new Error(`Missing size for file "${new TextDecoder().decode(r4.o)}".`);
      const e5 = r4.u >= 0xffffffffn, f3 = t4 >= 0xffffffffn;
      t4 += BigInt(46 + r4.o.length + (e5 && 8)) + r4.u, n3 += BigInt(r4.o.length + 46 + (12 * f3 | 28 * e5)), i3 || (i3 = e5);
    }
    return (i3 || t4 >= 0xffffffffn) && (n3 += BigInt(76)), n3 + t4;
  })((function* (e4) {
    for (const n3 of e4) yield s(...D(n3)[0]);
  })(e3));
  function A(e3, n3 = {}) {
    const t4 = { "Content-Type": "application/zip", "Content-Disposition": "attachment" };
    return ("bigint" == typeof n3.length || Number.isInteger(n3.length)) && n3.length > 0 && (t4["Content-Length"] = String(n3.length)), n3.metadata && (t4["Content-Length"] = String(S(n3.metadata))), new Response(N(e3, n3), { headers: t4 });
  }
  function N(t4, a3 = {}) {
    const u3 = (function(e3) {
      const n3 = e3[Symbol.iterator in e3 ? Symbol.iterator : Symbol.asyncIterator]();
      return { async next() {
        const e4 = await n3.next();
        if (e4.done) return e4;
        const [t5, i3] = D(e4.value);
        return { done: 0, value: Object.assign(f(...i3), s(...t5)) };
      }, throw: n3.throw?.bind(n3), [Symbol.asyncIterator]() {
        return this;
      } };
    })(t4);
    return o((async function* (t5, f3) {
      const o4 = [];
      let a4 = 0n, s3 = 0n, u4 = 0;
      for await (const e3 of t5) {
        const n3 = B(e3, f3.buffersAreUTF8);
        yield p2(e3, n3), yield new Uint8Array(e3.o), e3.isFile && (yield* g(e3));
        const t6 = e3.u >= 0xffffffffn, i3 = 12 * (a4 >= 0xffffffffn) | 28 * t6;
        yield I(e3, t6), o4.push(v(e3, a4, n3, i3)), o4.push(e3.o), i3 && o4.push(h(e3, a4, i3)), t6 && (a4 += 8n), s3++, a4 += BigInt(46 + e3.o.length) + e3.u, u4 || (u4 = t6);
      }
      let d3 = 0n;
      for (const e3 of o4) yield e3, d3 += BigInt(e3.length);
      if (u4 || a4 >= 0xffffffffn) {
        const t6 = e(76);
        t6.setUint32(0, 1347094022), t6.setBigUint64(4, BigInt(44), 1), t6.setUint32(12, 755182848), t6.setBigUint64(24, s3, 1), t6.setBigUint64(32, s3, 1), t6.setBigUint64(40, d3, 1), t6.setBigUint64(48, a4, 1), t6.setUint32(56, 1347094023), t6.setBigUint64(64, a4 + d3, 1), t6.setUint32(72, 1, 1), yield n(t6);
      }
      const l3 = e(22);
      l3.setUint32(0, 1347093766), l3.setUint16(8, r2(s3), 1), l3.setUint16(10, r2(s3), 1), l3.setUint32(12, i(d3), 1), l3.setUint32(16, i(a4), 1), yield n(l3);
    })(u3, a3), u3);
  }

  // packages/fields/build-module/actions/export-pattern.mjs
  var import_blob2 = __toESM(require_blob(), 1);
  var import_i18n46 = __toESM(require_i18n(), 1);
  function getJsonFromItem(item) {
    return JSON.stringify(
      {
        __file: item.type,
        title: getItemTitle(item),
        content: typeof item.content === "string" ? item.content : item.content?.raw,
        syncStatus: item.wp_pattern_sync_status
      },
      null,
      2
    );
  }
  var exportPattern = {
    id: "export-pattern",
    label: (0, import_i18n46.__)("Export as JSON"),
    icon: download_default,
    supportsBulk: true,
    isEligible: (item) => item.type === "wp_block",
    callback: async (items) => {
      if (items.length === 1) {
        return (0, import_blob2.downloadBlob)(
          `${paramCase(
            getItemTitle(items[0]) || items[0].slug
          )}.json`,
          getJsonFromItem(items[0]),
          "application/json"
        );
      }
      const nameCount = {};
      const filesToZip = items.map((item) => {
        const name2 = paramCase(getItemTitle(item) || item.slug);
        nameCount[name2] = (nameCount[name2] || 0) + 1;
        return {
          name: `${name2 + (nameCount[name2] > 1 ? "-" + (nameCount[name2] - 1) : "")}.json`,
          lastModified: /* @__PURE__ */ new Date(),
          input: getJsonFromItem(item)
        };
      });
      return (0, import_blob2.downloadBlob)(
        (0, import_i18n46.__)("patterns-export") + ".zip",
        await A(filesToZip).blob(),
        "application/zip"
      );
    }
  };
  var export_pattern_default = exportPattern;

  // packages/fields/build-module/actions/view-post-revisions.mjs
  var import_url6 = __toESM(require_url(), 1);
  var import_i18n47 = __toESM(require_i18n(), 1);
  var viewPostRevisions = {
    id: "view-post-revisions",
    context: "list",
    label(items) {
      const revisionsCount = items[0]._links?.["version-history"]?.[0]?.count ?? 0;
      return (0, import_i18n47.sprintf)(
        /* translators: %d: number of revisions. */
        (0, import_i18n47.__)("View revisions (%d)"),
        revisionsCount
      );
    },
    isEligible(post2) {
      if (post2.status === "trash") {
        return false;
      }
      const lastRevisionId = post2?._links?.["predecessor-version"]?.[0]?.id ?? null;
      const revisionsCount = post2?._links?.["version-history"]?.[0]?.count ?? 0;
      return !!lastRevisionId && revisionsCount > 1;
    },
    callback(posts, { onActionPerformed }) {
      const post2 = posts[0];
      const href = (0, import_url6.addQueryArgs)("revision.php", {
        revision: post2?._links?.["predecessor-version"]?.[0]?.id
      });
      document.location.href = href;
      if (onActionPerformed) {
        onActionPerformed(posts);
      }
    }
  };
  var view_post_revisions_default = viewPostRevisions;

  // packages/fields/build-module/actions/permanently-delete-post.mjs
  var import_core_data17 = __toESM(require_core_data(), 1);
  var import_i18n48 = __toESM(require_i18n(), 1);
  var import_notices8 = __toESM(require_notices(), 1);
  var import_element35 = __toESM(require_element(), 1);
  var import_data19 = __toESM(require_data(), 1);
  var import_components18 = __toESM(require_components(), 1);
  var import_html_entities5 = __toESM(require_html_entities(), 1);
  var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
  var permanentlyDeletePost = {
    id: "permanently-delete",
    label: (0, import_i18n48.__)("Permanently delete"),
    supportsBulk: true,
    icon: trash_default,
    isEligible(item) {
      if (isTemplateOrTemplatePart(item) || item.type === "wp_block") {
        return false;
      }
      const { status, permissions } = item;
      return status === "trash" && permissions?.delete;
    },
    hideModalHeader: true,
    modalFocusOnMount: "firstContentElement",
    RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
      const [isBusy, setIsBusy] = (0, import_element35.useState)(false);
      const { createSuccessNotice, createErrorNotice } = (0, import_data19.useDispatch)(import_notices8.store);
      const { deleteEntityRecord } = (0, import_data19.useDispatch)(import_core_data17.store);
      return /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(import_components18.__experimentalVStack, { spacing: "5", children: [
        /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components18.__experimentalText, { children: items.length > 1 ? (0, import_i18n48.sprintf)(
          // translators: %d: number of items to delete.
          (0, import_i18n48._n)(
            "Are you sure you want to permanently delete %d item?",
            "Are you sure you want to permanently delete %d items?",
            items.length
          ),
          items.length
        ) : (0, import_i18n48.sprintf)(
          // translators: %s: The post's title
          (0, import_i18n48.__)(
            'Are you sure you want to permanently delete "%s"?'
          ),
          (0, import_html_entities5.decodeEntities)(getItemTitle(items[0]))
        ) }),
        /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(import_components18.__experimentalHStack, { justify: "right", children: [
          /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
            import_components18.Button,
            {
              variant: "tertiary",
              onClick: closeModal2,
              disabled: isBusy,
              accessibleWhenDisabled: true,
              __next40pxDefaultSize: true,
              children: (0, import_i18n48.__)("Cancel")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
            import_components18.Button,
            {
              variant: "primary",
              onClick: async () => {
                setIsBusy(true);
                const promiseResult = await Promise.allSettled(
                  items.map(
                    (post2) => deleteEntityRecord(
                      "postType",
                      post2.type,
                      post2.id,
                      { force: true },
                      { throwOnError: true }
                    )
                  )
                );
                if (promiseResult.every(
                  ({ status }) => status === "fulfilled"
                )) {
                  let successMessage;
                  if (promiseResult.length === 1) {
                    successMessage = (0, import_i18n48.sprintf)(
                      /* translators: %s: The posts's title. */
                      (0, import_i18n48.__)('"%s" permanently deleted.'),
                      getItemTitle(items[0])
                    );
                  } else {
                    successMessage = (0, import_i18n48.__)(
                      "The items were permanently deleted."
                    );
                  }
                  createSuccessNotice(successMessage, {
                    type: "snackbar",
                    id: "permanently-delete-post-action"
                  });
                  onActionPerformed?.(items);
                } else {
                  let errorMessage;
                  if (promiseResult.length === 1) {
                    const typedError = promiseResult[0];
                    if (typedError.reason?.message) {
                      errorMessage = typedError.reason.message;
                    } else {
                      errorMessage = (0, import_i18n48.__)(
                        "An error occurred while permanently deleting the item."
                      );
                    }
                  } else {
                    const errorMessages = /* @__PURE__ */ new Set();
                    const failedPromises = promiseResult.filter(
                      ({ status }) => status === "rejected"
                    );
                    for (const failedPromise of failedPromises) {
                      const typedError = failedPromise;
                      if (typedError.reason?.message) {
                        errorMessages.add(
                          typedError.reason.message
                        );
                      }
                    }
                    if (errorMessages.size === 0) {
                      errorMessage = (0, import_i18n48.__)(
                        "An error occurred while permanently deleting the items."
                      );
                    } else if (errorMessages.size === 1) {
                      errorMessage = (0, import_i18n48.sprintf)(
                        /* translators: %s: an error message */
                        (0, import_i18n48.__)(
                          "An error occurred while permanently deleting the items: %s"
                        ),
                        [...errorMessages][0]
                      );
                    } else {
                      errorMessage = (0, import_i18n48.sprintf)(
                        /* translators: %s: a list of comma separated error messages */
                        (0, import_i18n48.__)(
                          "Some errors occurred while permanently deleting the items: %s"
                        ),
                        [...errorMessages].join(",")
                      );
                    }
                  }
                  createErrorNotice(errorMessage, {
                    type: "snackbar"
                  });
                }
                setIsBusy(false);
                closeModal2?.();
              },
              isBusy,
              disabled: isBusy,
              accessibleWhenDisabled: true,
              __next40pxDefaultSize: true,
              children: (0, import_i18n48.__)("Delete permanently")
            }
          )
        ] })
      ] });
    }
  };
  var permanently_delete_post_default = permanentlyDeletePost;

  // packages/fields/build-module/actions/restore-post.mjs
  var import_core_data18 = __toESM(require_core_data(), 1);
  var import_i18n49 = __toESM(require_i18n(), 1);
  var import_notices9 = __toESM(require_notices(), 1);
  var restorePost = {
    id: "restore",
    label: (0, import_i18n49.__)("Restore"),
    isPrimary: true,
    icon: backup_default,
    supportsBulk: true,
    isEligible(item) {
      return !isTemplateOrTemplatePart(item) && item.type !== "wp_block" && item.status === "trash" && item.permissions?.update;
    },
    async callback(posts, { registry, onActionPerformed }) {
      const { createSuccessNotice, createErrorNotice } = registry.dispatch(import_notices9.store);
      const { editEntityRecord, saveEditedEntityRecord } = registry.dispatch(import_core_data18.store);
      await Promise.allSettled(
        posts.map((post2) => {
          return editEntityRecord("postType", post2.type, post2.id, {
            status: "draft"
          });
        })
      );
      const promiseResult = await Promise.allSettled(
        posts.map((post2) => {
          return saveEditedEntityRecord("postType", post2.type, post2.id, {
            throwOnError: true
          });
        })
      );
      if (promiseResult.every(({ status }) => status === "fulfilled")) {
        let successMessage;
        if (posts.length === 1) {
          successMessage = (0, import_i18n49.sprintf)(
            /* translators: %s: The number of posts. */
            (0, import_i18n49.__)('"%s" has been restored.'),
            getItemTitle(posts[0])
          );
        } else if (posts[0].type === "page") {
          successMessage = (0, import_i18n49.sprintf)(
            /* translators: %d: The number of posts. */
            (0, import_i18n49.__)("%d pages have been restored."),
            posts.length
          );
        } else {
          successMessage = (0, import_i18n49.sprintf)(
            /* translators: %d: The number of posts. */
            (0, import_i18n49.__)("%d posts have been restored."),
            posts.length
          );
        }
        createSuccessNotice(successMessage, {
          type: "snackbar",
          id: "restore-post-action"
        });
        if (onActionPerformed) {
          onActionPerformed(posts);
        }
      } else {
        let errorMessage;
        if (promiseResult.length === 1) {
          const typedError = promiseResult[0];
          if (typedError.reason?.message) {
            errorMessage = typedError.reason.message;
          } else {
            errorMessage = (0, import_i18n49.__)(
              "An error occurred while restoring the post."
            );
          }
        } else {
          const errorMessages = /* @__PURE__ */ new Set();
          const failedPromises = promiseResult.filter(
            ({ status }) => status === "rejected"
          );
          for (const failedPromise of failedPromises) {
            const typedError = failedPromise;
            if (typedError.reason?.message) {
              errorMessages.add(typedError.reason.message);
            }
          }
          if (errorMessages.size === 0) {
            errorMessage = (0, import_i18n49.__)(
              "An error occurred while restoring the posts."
            );
          } else if (errorMessages.size === 1) {
            errorMessage = (0, import_i18n49.sprintf)(
              /* translators: %s: an error message */
              (0, import_i18n49.__)("An error occurred while restoring the posts: %s"),
              [...errorMessages][0]
            );
          } else {
            errorMessage = (0, import_i18n49.sprintf)(
              /* translators: %s: a list of comma separated error messages */
              (0, import_i18n49.__)(
                "Some errors occurred while restoring the posts: %s"
              ),
              [...errorMessages].join(",")
            );
          }
        }
        createErrorNotice(errorMessage, {
          type: "snackbar"
        });
      }
    }
  };
  var restore_post_default = restorePost;

  // packages/fields/build-module/actions/trash-post.mjs
  var import_data20 = __toESM(require_data(), 1);
  var import_core_data19 = __toESM(require_core_data(), 1);
  var import_i18n50 = __toESM(require_i18n(), 1);
  var import_notices10 = __toESM(require_notices(), 1);
  var import_element36 = __toESM(require_element(), 1);
  var import_components19 = __toESM(require_components(), 1);
  var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
  var trashPost2 = {
    id: "move-to-trash",
    label: (0, import_i18n50._x)("Trash", "verb"),
    isPrimary: true,
    icon: trash_default,
    isEligible(item) {
      if (item.type === "wp_template_part" || item.type === "wp_block") {
        return false;
      }
      if (item.type === "wp_template" && typeof item.id === "string") {
        return false;
      }
      return !!item.status && !["auto-draft", "trash"].includes(item.status) && item.permissions?.delete;
    },
    supportsBulk: true,
    hideModalHeader: true,
    modalFocusOnMount: "firstContentElement",
    RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
      const [isBusy, setIsBusy] = (0, import_element36.useState)(false);
      const { createSuccessNotice, createErrorNotice } = (0, import_data20.useDispatch)(import_notices10.store);
      const { deleteEntityRecord } = (0, import_data20.useDispatch)(import_core_data19.store);
      return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(import_components19.__experimentalVStack, { spacing: "5", children: [
        /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_components19.__experimentalText, { children: items.length === 1 ? (0, import_i18n50.sprintf)(
          // translators: %s: The item's title.
          (0, import_i18n50.__)(
            'Are you sure you want to move "%s" to the trash?'
          ),
          getItemTitle(items[0])
        ) : (0, import_i18n50.sprintf)(
          // translators: %d: The number of items (2 or more).
          (0, import_i18n50._n)(
            "Are you sure you want to move %d item to the trash ?",
            "Are you sure you want to move %d items to the trash ?",
            items.length
          ),
          items.length
        ) }),
        /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(import_components19.__experimentalHStack, { justify: "right", children: [
          /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
            import_components19.Button,
            {
              __next40pxDefaultSize: true,
              variant: "tertiary",
              onClick: closeModal2,
              disabled: isBusy,
              accessibleWhenDisabled: true,
              children: (0, import_i18n50.__)("Cancel")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
            import_components19.Button,
            {
              __next40pxDefaultSize: true,
              variant: "primary",
              onClick: async () => {
                setIsBusy(true);
                const promiseResult = await Promise.allSettled(
                  items.map(
                    (item) => deleteEntityRecord(
                      "postType",
                      item.type,
                      item.id.toString(),
                      {},
                      { throwOnError: true }
                    )
                  )
                );
                if (promiseResult.every(
                  ({ status }) => status === "fulfilled"
                )) {
                  let successMessage;
                  if (promiseResult.length === 1) {
                    successMessage = (0, import_i18n50.sprintf)(
                      /* translators: %s: The item's title. */
                      (0, import_i18n50.__)('"%s" moved to the trash.'),
                      getItemTitle(items[0])
                    );
                  } else {
                    successMessage = (0, import_i18n50.sprintf)(
                      /* translators: %d: The number of items. */
                      (0, import_i18n50._n)(
                        "%d item moved to the trash.",
                        "%d items moved to the trash.",
                        items.length
                      ),
                      items.length
                    );
                  }
                  createSuccessNotice(successMessage, {
                    type: "snackbar",
                    id: "move-to-trash-action"
                  });
                } else {
                  let errorMessage;
                  if (promiseResult.length === 1) {
                    const typedError = promiseResult[0];
                    if (typedError.reason?.message) {
                      errorMessage = typedError.reason.message;
                    } else {
                      errorMessage = (0, import_i18n50.__)(
                        "An error occurred while moving the item to the trash."
                      );
                    }
                  } else {
                    const errorMessages = /* @__PURE__ */ new Set();
                    const failedPromises = promiseResult.filter(
                      ({ status }) => status === "rejected"
                    );
                    for (const failedPromise of failedPromises) {
                      const typedError = failedPromise;
                      if (typedError.reason?.message) {
                        errorMessages.add(
                          typedError.reason.message
                        );
                      }
                    }
                    if (errorMessages.size === 0) {
                      errorMessage = (0, import_i18n50.__)(
                        "An error occurred while moving the items to the trash."
                      );
                    } else if (errorMessages.size === 1) {
                      errorMessage = (0, import_i18n50.sprintf)(
                        /* translators: %s: an error message */
                        (0, import_i18n50.__)(
                          "An error occurred while moving the item to the trash: %s"
                        ),
                        [...errorMessages][0]
                      );
                    } else {
                      errorMessage = (0, import_i18n50.sprintf)(
                        /* translators: %s: a list of comma separated error messages */
                        (0, import_i18n50.__)(
                          "Some errors occurred while moving the items to the trash: %s"
                        ),
                        [...errorMessages].join(",")
                      );
                    }
                  }
                  createErrorNotice(errorMessage, {
                    type: "snackbar"
                  });
                }
                if (onActionPerformed) {
                  onActionPerformed(items);
                }
                setIsBusy(false);
                closeModal2?.();
              },
              isBusy,
              disabled: isBusy,
              accessibleWhenDisabled: true,
              children: (0, import_i18n50._x)("Trash", "verb")
            }
          )
        ] })
      ] });
    }
  };
  var trash_post_default = trashPost2;

  // packages/fields/build-module/actions/delete-post.mjs
  var import_i18n51 = __toESM(require_i18n(), 1);
  var import_element37 = __toESM(require_element(), 1);
  var import_components20 = __toESM(require_components(), 1);
  var import_patterns4 = __toESM(require_patterns(), 1);
  var import_html_entities6 = __toESM(require_html_entities(), 1);

  // packages/fields/build-module/mutation/index.mjs
  var import_notices11 = __toESM(require_notices(), 1);
  var import_core_data20 = __toESM(require_core_data(), 1);
  var import_data21 = __toESM(require_data(), 1);
  function getErrorMessagesFromPromises(allSettledResults) {
    const errorMessages = /* @__PURE__ */ new Set();
    if (allSettledResults.length === 1) {
      const typedError = allSettledResults[0];
      if (typedError.reason?.message) {
        errorMessages.add(typedError.reason.message);
      }
    } else {
      const failedPromises = allSettledResults.filter(
        ({ status }) => status === "rejected"
      );
      for (const failedPromise of failedPromises) {
        const typedError = failedPromise;
        if (typedError.reason?.message) {
          errorMessages.add(typedError.reason.message);
        }
      }
    }
    return errorMessages;
  }
  var deletePostWithNotices = async (posts, notice, callbacks) => {
    const { createSuccessNotice, createErrorNotice } = (0, import_data21.dispatch)(import_notices11.store);
    const { deleteEntityRecord } = (0, import_data21.dispatch)(import_core_data20.store);
    const allSettledResults = await Promise.allSettled(
      posts.map((post2) => {
        return deleteEntityRecord(
          "postType",
          post2.type,
          post2.id,
          { force: true },
          { throwOnError: true }
        );
      })
    );
    if (allSettledResults.every(({ status }) => status === "fulfilled")) {
      let successMessage;
      if (allSettledResults.length === 1) {
        successMessage = notice.success.messages.getMessage(posts[0]);
      } else {
        successMessage = notice.success.messages.getBatchMessage(posts);
      }
      createSuccessNotice(successMessage, {
        type: notice.success.type ?? "snackbar",
        id: notice.success.id
      });
      callbacks.onActionPerformed?.(posts);
    } else {
      const errorMessages = getErrorMessagesFromPromises(allSettledResults);
      let errorMessage = "";
      if (allSettledResults.length === 1) {
        errorMessage = notice.error.messages.getMessage(errorMessages);
      } else {
        errorMessage = notice.error.messages.getBatchMessage(errorMessages);
      }
      createErrorNotice(errorMessage, {
        type: notice.error.type ?? "snackbar",
        id: notice.error.id
      });
      callbacks.onActionError?.();
    }
  };

  // packages/fields/build-module/actions/delete-post.mjs
  var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
  var { PATTERN_TYPES: PATTERN_TYPES3 } = unlock2(import_patterns4.privateApis);
  var deletePostAction = {
    id: "delete-post",
    label: (0, import_i18n51.__)("Delete"),
    isPrimary: true,
    icon: trash_default,
    isEligible(post2) {
      if (isTemplateOrTemplatePart(post2)) {
        return isTemplateRemovable(post2);
      }
      return post2.type === PATTERN_TYPES3.user;
    },
    supportsBulk: true,
    hideModalHeader: true,
    modalFocusOnMount: "firstContentElement",
    RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
      const [isBusy, setIsBusy] = (0, import_element37.useState)(false);
      const isResetting = items.every(
        (item) => isTemplateOrTemplatePart(item) && item?.has_theme_file
      );
      return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(import_components20.__experimentalVStack, { spacing: "5", children: [
        /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_components20.__experimentalText, { children: items.length > 1 ? (0, import_i18n51.sprintf)(
          // translators: %d: number of items to delete.
          (0, import_i18n51._n)(
            "Delete %d item?",
            "Delete %d items?",
            items.length
          ),
          items.length
        ) : (0, import_i18n51.sprintf)(
          // translators: %s: The template or template part's title
          (0, import_i18n51._x)('Delete "%s"?', "template part"),
          getItemTitle(items[0])
        ) }),
        /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(import_components20.__experimentalHStack, { justify: "right", children: [
          /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
            import_components20.Button,
            {
              variant: "tertiary",
              onClick: closeModal2,
              disabled: isBusy,
              accessibleWhenDisabled: true,
              __next40pxDefaultSize: true,
              children: (0, import_i18n51.__)("Cancel")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
            import_components20.Button,
            {
              variant: "primary",
              onClick: async () => {
                setIsBusy(true);
                const notice = {
                  success: {
                    messages: {
                      getMessage: (item) => {
                        return isResetting ? (0, import_i18n51.sprintf)(
                          /* translators: %s: The template/part's name. */
                          (0, import_i18n51.__)('"%s" reset.'),
                          (0, import_html_entities6.decodeEntities)(
                            getItemTitle(item)
                          )
                        ) : (0, import_i18n51.sprintf)(
                          /* translators: %s: The template/part's name. */
                          (0, import_i18n51._x)(
                            '"%s" deleted.',
                            "template part"
                          ),
                          (0, import_html_entities6.decodeEntities)(
                            getItemTitle(item)
                          )
                        );
                      },
                      getBatchMessage: () => {
                        return isResetting ? (0, import_i18n51.__)("Items reset.") : (0, import_i18n51.__)("Items deleted.");
                      }
                    }
                  },
                  error: {
                    messages: {
                      getMessage: (error2) => {
                        if (error2.size === 1) {
                          return [...error2][0];
                        }
                        return isResetting ? (0, import_i18n51.__)(
                          "An error occurred while reverting the item."
                        ) : (0, import_i18n51.__)(
                          "An error occurred while deleting the item."
                        );
                      },
                      getBatchMessage: (errors) => {
                        if (errors.size === 0) {
                          return isResetting ? (0, import_i18n51.__)(
                            "An error occurred while reverting the items."
                          ) : (0, import_i18n51.__)(
                            "An error occurred while deleting the items."
                          );
                        }
                        if (errors.size === 1) {
                          return isResetting ? (0, import_i18n51.sprintf)(
                            /* translators: %s: an error message */
                            (0, import_i18n51.__)(
                              "An error occurred while reverting the items: %s"
                            ),
                            [...errors][0]
                          ) : (0, import_i18n51.sprintf)(
                            /* translators: %s: an error message */
                            (0, import_i18n51.__)(
                              "An error occurred while deleting the items: %s"
                            ),
                            [...errors][0]
                          );
                        }
                        return isResetting ? (0, import_i18n51.sprintf)(
                          /* translators: %s: a list of comma separated error messages */
                          (0, import_i18n51.__)(
                            "Some errors occurred while reverting the items: %s"
                          ),
                          [...errors].join(
                            ","
                          )
                        ) : (0, import_i18n51.sprintf)(
                          /* translators: %s: a list of comma separated error messages */
                          (0, import_i18n51.__)(
                            "Some errors occurred while deleting the items: %s"
                          ),
                          [...errors].join(
                            ","
                          )
                        );
                      }
                    }
                  }
                };
                await deletePostWithNotices(items, notice, {
                  onActionPerformed
                });
                setIsBusy(false);
                closeModal2?.();
              },
              isBusy,
              disabled: isBusy,
              accessibleWhenDisabled: true,
              __next40pxDefaultSize: true,
              children: (0, import_i18n51.__)("Delete")
            }
          )
        ] })
      ] });
    }
  };
  var delete_post_default = deletePostAction;

  // packages/fields/build-module/actions/duplicate-template-part.mjs
  var import_data24 = __toESM(require_data(), 1);
  var import_i18n53 = __toESM(require_i18n(), 1);
  var import_notices13 = __toESM(require_notices(), 1);
  var import_element39 = __toESM(require_element(), 1);
  var import_blocks5 = __toESM(require_blocks(), 1);

  // packages/fields/build-module/components/create-template-part-modal/index.mjs
  var import_components21 = __toESM(require_components(), 1);
  var import_compose3 = __toESM(require_compose(), 1);
  var import_core_data22 = __toESM(require_core_data(), 1);
  var import_data23 = __toESM(require_data(), 1);
  var import_element38 = __toESM(require_element(), 1);
  var import_i18n52 = __toESM(require_i18n(), 1);
  var import_notices12 = __toESM(require_notices(), 1);
  var import_blocks4 = __toESM(require_blocks(), 1);

  // packages/fields/build-module/components/create-template-part-modal/utils.mjs
  var import_data22 = __toESM(require_data(), 1);
  var import_core_data21 = __toESM(require_core_data(), 1);
  var useExistingTemplateParts = () => {
    return (0, import_data22.useSelect)(
      (select7) => select7(import_core_data21.store).getEntityRecords(
        "postType",
        "wp_template_part",
        {
          per_page: -1
        }
      ),
      []
    ) ?? [];
  };
  var getUniqueTemplatePartTitle = (title, templateParts) => {
    const lowercaseTitle = title.toLowerCase();
    const existingTitles = templateParts.map(
      (templatePart) => templatePart.title.rendered.toLowerCase()
    );
    if (!existingTitles.includes(lowercaseTitle)) {
      return title;
    }
    let suffix = 2;
    while (existingTitles.includes(`${lowercaseTitle} ${suffix}`)) {
      suffix++;
    }
    return `${title} ${suffix}`;
  };
  var getCleanTemplatePartSlug = (title) => {
    return paramCase(title).replace(/[^\w-]+/g, "") || "wp-custom-part";
  };

  // packages/fields/build-module/components/create-template-part-modal/index.mjs
  var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
  function getAreaRadioId(value, instanceId) {
    return `fields-create-template-part-modal__area-option-${value}-${instanceId}`;
  }
  function getAreaRadioDescriptionId(value, instanceId) {
    return `fields-create-template-part-modal__area-option-description-${value}-${instanceId}`;
  }
  function CreateTemplatePartModal({
    modalTitle,
    ...restProps
  }) {
    const defaultModalTitle = (0, import_data23.useSelect)(
      (select7) => select7(import_core_data22.store).getPostType("wp_template_part")?.labels?.add_new_item,
      []
    );
    return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
      import_components21.Modal,
      {
        title: modalTitle || defaultModalTitle,
        onRequestClose: restProps.closeModal,
        overlayClassName: "fields-create-template-part-modal",
        focusOnMount: "firstContentElement",
        size: "medium",
        children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(CreateTemplatePartModalContents, { ...restProps })
      }
    );
  }
  var getTemplatePartIcon2 = (areaOrIconName) => {
    if ("header" === areaOrIconName) {
      return header_default;
    } else if ("footer" === areaOrIconName) {
      return footer_default;
    } else if ("sidebar" === areaOrIconName) {
      return sidebar_default;
    } else if ("navigation-overlay" === areaOrIconName) {
      return navigation_overlay_default;
    }
    return symbol_filled_default;
  };
  function CreateTemplatePartModalContents({
    defaultArea = "uncategorized",
    blocks = [],
    confirmLabel = (0, import_i18n52.__)("Add"),
    closeModal: closeModal2,
    onCreate,
    onError,
    defaultTitle = ""
  }) {
    const { createErrorNotice } = (0, import_data23.useDispatch)(import_notices12.store);
    const { saveEntityRecord } = (0, import_data23.useDispatch)(import_core_data22.store);
    const existingTemplateParts = useExistingTemplateParts();
    const [title, setTitle] = (0, import_element38.useState)(defaultTitle);
    const [area, setArea] = (0, import_element38.useState)(defaultArea);
    const [isSubmitting, setIsSubmitting] = (0, import_element38.useState)(false);
    const instanceId = (0, import_compose3.useInstanceId)(CreateTemplatePartModal);
    const defaultTemplatePartAreas = (0, import_data23.useSelect)(
      (select7) => select7(import_core_data22.store).getCurrentTheme()?.default_template_part_areas,
      []
    );
    async function createTemplatePart() {
      if (!title || isSubmitting) {
        return;
      }
      try {
        setIsSubmitting(true);
        const uniqueTitle = getUniqueTemplatePartTitle(
          title,
          existingTemplateParts
        );
        const cleanSlug = getCleanTemplatePartSlug(uniqueTitle);
        const templatePart = await saveEntityRecord(
          "postType",
          "wp_template_part",
          {
            slug: cleanSlug,
            title: uniqueTitle,
            content: (0, import_blocks4.serialize)(blocks),
            area
          },
          { throwOnError: true }
        );
        await onCreate(templatePart);
      } catch (error2) {
        const errorMessage = error2 instanceof Error && "code" in error2 && error2.message && error2.code !== "unknown_error" ? error2.message : (0, import_i18n52.__)(
          "An error occurred while creating the template part."
        );
        createErrorNotice(errorMessage, { type: "snackbar" });
        onError?.();
      } finally {
        setIsSubmitting(false);
      }
    }
    return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
      "form",
      {
        onSubmit: async (event) => {
          event.preventDefault();
          await createTemplatePart();
        },
        children: /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(import_components21.__experimentalVStack, { spacing: "4", children: [
          /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
            import_components21.TextControl,
            {
              __next40pxDefaultSize: true,
              label: (0, import_i18n52.__)("Name"),
              value: title,
              onChange: setTitle,
              required: true
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)("fieldset", { className: "fields-create-template-part-modal__area-fieldset", children: [
            /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(import_components21.BaseControl.VisualLabel, { as: "legend", children: (0, import_i18n52.__)("Area") }),
            /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("div", { className: "fields-create-template-part-modal__area-radio-group", children: (defaultTemplatePartAreas ?? []).map(
              (item) => {
                const icon = getTemplatePartIcon2(item.icon);
                return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(
                  "div",
                  {
                    className: "fields-create-template-part-modal__area-radio-wrapper",
                    children: [
                      /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
                        "input",
                        {
                          type: "radio",
                          id: getAreaRadioId(
                            item.area,
                            instanceId
                          ),
                          name: `fields-create-template-part-modal__area-${instanceId}`,
                          value: item.area,
                          checked: area === item.area,
                          onChange: () => {
                            setArea(item.area);
                          },
                          "aria-describedby": getAreaRadioDescriptionId(
                            item.area,
                            instanceId
                          )
                        }
                      ),
                      /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
                        import_components21.Icon,
                        {
                          icon,
                          className: "fields-create-template-part-modal__area-radio-icon"
                        }
                      ),
                      /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
                        "label",
                        {
                          htmlFor: getAreaRadioId(
                            item.area,
                            instanceId
                          ),
                          className: "fields-create-template-part-modal__area-radio-label",
                          children: item.label
                        }
                      ),
                      /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
                        import_components21.Icon,
                        {
                          icon: check_default,
                          className: "fields-create-template-part-modal__area-radio-checkmark"
                        }
                      ),
                      /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
                        "p",
                        {
                          className: "fields-create-template-part-modal__area-radio-description",
                          id: getAreaRadioDescriptionId(
                            item.area,
                            instanceId
                          ),
                          children: item.description
                        }
                      )
                    ]
                  },
                  item.area
                );
              }
            ) })
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(import_components21.__experimentalHStack, { justify: "right", children: [
            /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
              import_components21.Button,
              {
                __next40pxDefaultSize: true,
                variant: "tertiary",
                onClick: () => {
                  closeModal2();
                },
                children: (0, import_i18n52.__)("Cancel")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
              import_components21.Button,
              {
                __next40pxDefaultSize: true,
                variant: "primary",
                type: "submit",
                "aria-disabled": !title || isSubmitting,
                isBusy: isSubmitting,
                children: confirmLabel
              }
            )
          ] })
        ] })
      }
    );
  }

  // packages/fields/build-module/actions/duplicate-template-part.mjs
  var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
  var duplicateTemplatePart = {
    id: "duplicate-template-part",
    label: (0, import_i18n53._x)("Duplicate", "action label"),
    isEligible: (item) => item.type === "wp_template_part",
    modalHeader: (0, import_i18n53._x)("Duplicate template part", "action label"),
    modalFocusOnMount: "firstContentElement",
    RenderModal: ({ items, closeModal: closeModal2 }) => {
      const [item] = items;
      const blocks = (0, import_element39.useMemo)(() => {
        return item.blocks ?? (0, import_blocks5.parse)(
          typeof item.content === "string" ? item.content : item.content.raw,
          {
            __unstableSkipMigrationLogs: true
          }
        );
      }, [item.content, item.blocks]);
      const { createSuccessNotice } = (0, import_data24.useDispatch)(import_notices13.store);
      function onTemplatePartSuccess(templatePart) {
        createSuccessNotice(
          (0, import_i18n53.sprintf)(
            // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
            (0, import_i18n53._x)('"%s" duplicated.', "template part"),
            getItemTitle(templatePart)
          ),
          { type: "snackbar", id: "edit-site-patterns-success" }
        );
        closeModal2?.();
      }
      return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
        CreateTemplatePartModalContents,
        {
          blocks,
          defaultArea: item.area,
          defaultTitle: (0, import_i18n53.sprintf)(
            /* translators: %s: Existing template part title */
            (0, import_i18n53._x)("%s (Copy)", "template part"),
            getItemTitle(item)
          ),
          onCreate: onTemplatePartSuccess,
          onError: closeModal2,
          confirmLabel: (0, import_i18n53._x)("Duplicate", "action label"),
          closeModal: closeModal2 ?? (() => {
          })
        }
      );
    }
  };
  var duplicate_template_part_default = duplicateTemplatePart;

  // packages/media-fields/build-module/alt_text/index.mjs
  var import_i18n54 = __toESM(require_i18n(), 1);
  var import_components22 = __toESM(require_components(), 1);
  var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
  var altTextField = {
    id: "alt_text",
    type: "text",
    label: (0, import_i18n54.__)("Alt text"),
    isVisible: (item) => item?.media_type === "image",
    render: ({ item }) => item?.alt_text || "-",
    Edit: ({ field, onChange, data }) => {
      return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
        import_components22.TextareaControl,
        {
          label: field.label,
          value: data.alt_text || "",
          onChange: (value) => onChange({ alt_text: value }),
          rows: 2
        }
      );
    },
    enableSorting: false,
    filterBy: false
  };
  var alt_text_default = altTextField;

  // packages/media-fields/build-module/attached_to/index.mjs
  var import_i18n57 = __toESM(require_i18n(), 1);

  // packages/media-fields/build-module/attached_to/view.mjs
  var import_element40 = __toESM(require_element(), 1);
  var import_i18n55 = __toESM(require_i18n(), 1);

  // packages/media-fields/build-module/utils/get-rendered-content.mjs
  function getRenderedContent(content) {
    if (!content) {
      return "";
    }
    if (typeof content === "string") {
      return content;
    }
    if (typeof content === "object") {
      return content.rendered || content.raw || "";
    }
    return "";
  }

  // packages/media-fields/build-module/attached_to/view.mjs
  var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
  function MediaAttachedToView({
    item
  }) {
    const [attachedPostTitle, setAttachedPostTitle] = (0, import_element40.useState)(null);
    const parentId = item.post;
    const embeddedPostId = item._embedded?.["wp:attached-to"]?.[0]?.id;
    const embeddedPostTitle = item._embedded?.["wp:attached-to"]?.[0]?.title;
    (0, import_element40.useEffect)(() => {
      if (!!parentId && parentId === embeddedPostId) {
        setAttachedPostTitle(
          getRenderedContent(embeddedPostTitle) || embeddedPostId?.toString() || ""
        );
      }
      if (!parentId) {
        setAttachedPostTitle((0, import_i18n55.__)("(Unattached)"));
      }
    }, [parentId, embeddedPostId, embeddedPostTitle]);
    return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_jsx_runtime130.Fragment, { children: attachedPostTitle });
  }

  // packages/media-fields/build-module/attached_to/edit.mjs
  var import_core_data23 = __toESM(require_core_data(), 1);
  var import_components23 = __toESM(require_components(), 1);
  var import_i18n56 = __toESM(require_i18n(), 1);
  var import_element41 = __toESM(require_element(), 1);
  var import_compose4 = __toESM(require_compose(), 1);
  var import_data25 = __toESM(require_data(), 1);
  var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
  function MediaAttachedToEdit({
    data,
    onChange
  }) {
    const defaultPost = !!data.post && !!data?._embedded?.["wp:attached-to"]?.[0] ? [
      {
        label: getRenderedContent(
          data._embedded?.["wp:attached-to"]?.[0]?.title
        ),
        value: data.post.toString()
      }
    ] : [];
    const [options, setOptions] = (0, import_element41.useState)(defaultPost);
    const [searchResults, setSearchResults] = (0, import_element41.useState)(
      []
    );
    const [isLoading, setIsLoading] = (0, import_element41.useState)(false);
    const [value, setValue] = (0, import_element41.useState)(
      data?.post?.toString() ?? null
    );
    const postTypes = (0, import_data25.useSelect)(
      (select7) => select7(import_core_data23.store).getPostTypes(),
      []
    );
    const handleDetach = () => {
      onChange({
        post: 0,
        _embedded: { ...data?._embedded, "wp:attached-to": void 0 }
      });
      setOptions([]);
    };
    const onValueChange = async (filterValue) => {
      setIsLoading(true);
      const results = await (0, import_core_data23.__experimentalFetchLinkSuggestions)(
        filterValue,
        /*
         * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.
         * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.
         */
        { type: "post", isInitialSuggestions: true },
        {}
      );
      setSearchResults(results);
      const mappedSuggestions = results.map((result) => {
        return {
          label: result.title,
          value: result.id.toString()
        };
      });
      setOptions(mappedSuggestions);
      setIsLoading(false);
    };
    const handleSelectOption = (selectedPostId) => {
      if (!selectedPostId) {
        handleDetach();
        return;
      }
      setValue(selectedPostId);
      if (selectedPostId) {
        const selectedPost = searchResults.find(
          (result) => result.id === Number(selectedPostId)
        );
        if (selectedPost && postTypes) {
          const postType2 = postTypes.find(
            (_postType) => _postType.slug === selectedPost?.type
          );
          const attachedTo = {
            ...postType2 && { type: postType2.slug },
            id: Number(selectedPostId),
            title: {
              raw: selectedPost.title,
              rendered: selectedPost.title
            }
          };
          onChange({
            post: Number(selectedPostId),
            _embedded: {
              ...data?._embedded,
              "wp:attached-to": [attachedTo]
            }
          });
        }
      }
    };
    const help = !!data.post ? (0, import_element41.createInterpolateElement)(
      (0, import_i18n56.__)(
        "Search for a post or page to attach this media to or <button>detach current</button>."
      ),
      {
        button: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
          import_components23.Button,
          {
            __next40pxDefaultSize: true,
            onClick: handleDetach,
            variant: "link",
            accessibleWhenDisabled: true
          }
        )
      }
    ) : (0, import_i18n56.__)("Search for a post or page to attach this media to.");
    return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
      import_components23.ComboboxControl,
      {
        className: "dataviews-media-field__attached-to",
        __next40pxDefaultSize: true,
        isLoading,
        label: (0, import_i18n56.__)("Attached to"),
        help,
        value,
        options,
        onFilterValueChange: (0, import_compose4.debounce)(
          (filterValue) => onValueChange(filterValue),
          300
        ),
        onChange: handleSelectOption,
        hideLabelFromVision: true
      }
    );
  }

  // packages/media-fields/build-module/attached_to/index.mjs
  var attachedToField = {
    id: "attached_to",
    type: "text",
    label: (0, import_i18n57.__)("Attached to"),
    Edit: MediaAttachedToEdit,
    render: MediaAttachedToView,
    enableSorting: false,
    filterBy: false
  };
  var attached_to_default = attachedToField;

  // packages/media-fields/build-module/author/index.mjs
  var import_i18n59 = __toESM(require_i18n(), 1);
  var import_data26 = __toESM(require_data(), 1);
  var import_core_data24 = __toESM(require_core_data(), 1);

  // packages/media-fields/build-module/author/view.mjs
  var import_i18n58 = __toESM(require_i18n(), 1);
  var import_element42 = __toESM(require_element(), 1);
  var import_components24 = __toESM(require_components(), 1);
  var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
  function AuthorView2({
    item
  }) {
    const author = item?._embedded?.author?.[0];
    const text = author?.name;
    const imageUrl = author?.avatar_urls?.[48];
    const [loadingState, setLoadingState] = (0, import_element42.useState)("loading");
    (0, import_element42.useEffect)(() => {
      setLoadingState("loading");
    }, [imageUrl]);
    const imgRef = (0, import_element42.useCallback)((img) => {
      if (img?.complete) {
        setLoadingState("instant");
      }
    }, []);
    const handleLoad = () => {
      if (loadingState === "loading") {
        setLoadingState("loaded");
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_components24.__experimentalHStack, { alignment: "left", spacing: 0, children: [
      !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
        "div",
        {
          className: clsx_default("media-author-field__avatar", {
            "is-loading": loadingState === "loading",
            "is-loaded": loadingState === "loaded"
          }),
          children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
            "img",
            {
              ref: imgRef,
              onLoad: handleLoad,
              alt: (0, import_i18n58.__)("Author avatar"),
              src: imageUrl
            }
          )
        }
      ),
      !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "media-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_components24.Icon, { icon: comment_author_avatar_default }) }),
      /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "media-author-field__name", children: text })
    ] });
  }

  // packages/media-fields/build-module/author/index.mjs
  var authorField2 = {
    label: (0, import_i18n59.__)("Author"),
    id: "author",
    type: "integer",
    getElements: async () => {
      const authors = await (0, import_data26.resolveSelect)(import_core_data24.store).getEntityRecords(
        "root",
        "user",
        {
          per_page: -1,
          who: "authors",
          _fields: "id,name",
          context: "view"
        }
      ) ?? [];
      return authors.map(({ id, name: name2 }) => ({
        value: id,
        label: name2
      }));
    },
    render: AuthorView2,
    sort: (a3, b3, direction) => {
      const nameA = a3._embedded?.author?.[0]?.name || "";
      const nameB = b3._embedded?.author?.[0]?.name || "";
      return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
    },
    filterBy: {
      operators: ["isAny", "isNone"]
    },
    readOnly: true
  };
  var author_default2 = authorField2;

  // packages/media-fields/build-module/caption/index.mjs
  var import_i18n60 = __toESM(require_i18n(), 1);
  var import_components25 = __toESM(require_components(), 1);

  // packages/media-fields/build-module/utils/get-raw-content.mjs
  function getRawContent(content) {
    if (!content) {
      return "";
    }
    if (typeof content === "string") {
      return content;
    }
    if (typeof content === "object" && "raw" in content) {
      return content.raw || "";
    }
    return "";
  }

  // packages/media-fields/build-module/caption/index.mjs
  var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
  var captionField = {
    id: "caption",
    type: "text",
    label: (0, import_i18n60.__)("Caption"),
    getValue: ({ item }) => getRawContent(item?.caption),
    render: ({ item }) => getRawContent(item?.caption) || "-",
    Edit: ({ field, onChange, data }) => {
      return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
        import_components25.TextareaControl,
        {
          label: field.label,
          value: getRawContent(data.caption) || "",
          onChange: (value) => onChange({ caption: value }),
          rows: 2
        }
      );
    },
    enableSorting: false,
    filterBy: false
  };
  var caption_default = captionField;

  // packages/media-fields/build-module/date_added/index.mjs
  var import_i18n61 = __toESM(require_i18n(), 1);
  var import_date5 = __toESM(require_date(), 1);
  var dateAddedField = {
    id: "date",
    type: "datetime",
    label: (0, import_i18n61.__)("Date added"),
    filterBy: {
      operators: ["before", "after"]
    },
    format: {
      datetime: (0, import_date5.getSettings)().formats.datetimeAbbreviated
    },
    readOnly: true
  };
  var date_added_default = dateAddedField;

  // packages/media-fields/build-module/description/index.mjs
  var import_i18n62 = __toESM(require_i18n(), 1);
  var import_components26 = __toESM(require_components(), 1);
  var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
  var descriptionField = {
    id: "description",
    type: "text",
    label: (0, import_i18n62.__)("Description"),
    getValue: ({ item }) => getRawContent(item?.description),
    render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("div", { children: getRawContent(item?.description) || "-" }),
    Edit: ({ field, onChange, data }) => {
      return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
        import_components26.TextareaControl,
        {
          label: field.label,
          value: getRawContent(data.description) || "",
          onChange: (value) => onChange({ description: value }),
          rows: 5
        }
      );
    },
    enableSorting: false,
    filterBy: false
  };
  var description_default = descriptionField;

  // packages/media-fields/build-module/filename/index.mjs
  var import_i18n63 = __toESM(require_i18n(), 1);
  var import_url8 = __toESM(require_url(), 1);

  // packages/media-fields/build-module/filename/view.mjs
  var import_components27 = __toESM(require_components(), 1);
  var import_element43 = __toESM(require_element(), 1);
  var import_url7 = __toESM(require_url(), 1);
  var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
  var TRUNCATE_LENGTH = 15;
  function FileNameView({
    item
  }) {
    const fileName = (0, import_element43.useMemo)(
      () => item?.source_url ? (0, import_url7.getFilename)(item.source_url) : null,
      [item?.source_url]
    );
    if (!fileName) {
      return "";
    }
    return fileName.length > TRUNCATE_LENGTH ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_components27.Tooltip, { text: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_components27.__experimentalTruncate, { limit: TRUNCATE_LENGTH, ellipsizeMode: "tail", children: fileName }) }) : /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_jsx_runtime135.Fragment, { children: fileName });
  }

  // packages/media-fields/build-module/filename/index.mjs
  var filenameField = {
    id: "filename",
    type: "text",
    label: (0, import_i18n63.__)("File name"),
    getValue: ({ item }) => (0, import_url8.getFilename)(item?.source_url || ""),
    render: FileNameView,
    enableSorting: false,
    filterBy: false,
    readOnly: true
  };
  var filename_default = filenameField;

  // packages/media-fields/build-module/filesize/index.mjs
  var import_i18n64 = __toESM(require_i18n(), 1);
  var KB_IN_BYTES = 1024;
  var MB_IN_BYTES = 1024 * KB_IN_BYTES;
  var GB_IN_BYTES = 1024 * MB_IN_BYTES;
  var TB_IN_BYTES = 1024 * GB_IN_BYTES;
  var PB_IN_BYTES = 1024 * TB_IN_BYTES;
  var EB_IN_BYTES = 1024 * PB_IN_BYTES;
  var ZB_IN_BYTES = 1024 * EB_IN_BYTES;
  var YB_IN_BYTES = 1024 * ZB_IN_BYTES;
  function getBytesString(bytes, unitSymbol, decimals = 2) {
    return (0, import_i18n64.sprintf)(
      // translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).
      (0, import_i18n64._x)("%1$s %2$s", "file size"),
      bytes.toLocaleString(void 0, {
        minimumFractionDigits: 0,
        maximumFractionDigits: decimals
      }),
      unitSymbol
    );
  }
  function formatFileSize(bytes, decimals = 2) {
    if (bytes === 0) {
      return getBytesString(0, (0, import_i18n64._x)("B", "unit symbol"), decimals);
    }
    const quant = {
      /* translators: Unit symbol for yottabyte. */
      [(0, import_i18n64._x)("YB", "unit symbol")]: YB_IN_BYTES,
      /* translators: Unit symbol for zettabyte. */
      [(0, import_i18n64._x)("ZB", "unit symbol")]: ZB_IN_BYTES,
      /* translators: Unit symbol for exabyte. */
      [(0, import_i18n64._x)("EB", "unit symbol")]: EB_IN_BYTES,
      /* translators: Unit symbol for petabyte. */
      [(0, import_i18n64._x)("PB", "unit symbol")]: PB_IN_BYTES,
      /* translators: Unit symbol for terabyte. */
      [(0, import_i18n64._x)("TB", "unit symbol")]: TB_IN_BYTES,
      /* translators: Unit symbol for gigabyte. */
      [(0, import_i18n64._x)("GB", "unit symbol")]: GB_IN_BYTES,
      /* translators: Unit symbol for megabyte. */
      [(0, import_i18n64._x)("MB", "unit symbol")]: MB_IN_BYTES,
      /* translators: Unit symbol for kilobyte. */
      [(0, import_i18n64._x)("KB", "unit symbol")]: KB_IN_BYTES,
      /* translators: Unit symbol for byte. */
      [(0, import_i18n64._x)("B", "unit symbol")]: 1
    };
    for (const [unit, mag] of Object.entries(quant)) {
      if (bytes >= mag) {
        return getBytesString(bytes / mag, unit, decimals);
      }
    }
    return "";
  }
  var filesizeField = {
    id: "filesize",
    type: "text",
    label: (0, import_i18n64.__)("File size"),
    getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "",
    isVisible: (item) => {
      return !!item?.media_details?.filesize;
    },
    enableSorting: false,
    filterBy: false,
    readOnly: true
  };
  var filesize_default = filesizeField;

  // packages/media-fields/build-module/media_dimensions/index.mjs
  var import_i18n65 = __toESM(require_i18n(), 1);
  var mediaDimensionsField = {
    id: "media_dimensions",
    type: "text",
    label: (0, import_i18n65.__)("Dimensions"),
    getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, import_i18n65.sprintf)(
      // translators: 1: Width. 2: Height.
      (0, import_i18n65._x)("%1$s \xD7 %2$s", "image dimensions"),
      item?.media_details?.width?.toString(),
      item?.media_details?.height?.toString()
    ) : "",
    isVisible: (item) => {
      return !!(item?.media_details?.width && item?.media_details?.height);
    },
    enableSorting: false,
    filterBy: false,
    readOnly: true
  };
  var media_dimensions_default = mediaDimensionsField;

  // packages/media-fields/build-module/mime_type/index.mjs
  var import_i18n66 = __toESM(require_i18n(), 1);
  var mimeTypeField = {
    id: "mime_type",
    type: "text",
    label: (0, import_i18n66.__)("File type"),
    getValue: ({ item }) => item?.mime_type || "",
    render: ({ item }) => item?.mime_type || "-",
    // Disable sorting until REST API support for ordering my `mime_type` is added.
    // See: https://core.trac.wordpress.org/ticket/64073
    enableSorting: false,
    filterBy: false,
    readOnly: true
  };
  var mime_type_default = mimeTypeField;

  // packages/editor/build-module/dataviews/fields/content-preview/index.mjs
  var import_i18n184 = __toESM(require_i18n(), 1);

  // packages/editor/build-module/dataviews/fields/content-preview/content-preview-view.mjs
  var import_i18n183 = __toESM(require_i18n(), 1);
  var import_block_editor35 = __toESM(require_block_editor(), 1);
  var import_data79 = __toESM(require_data(), 1);
  var import_core_data52 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/provider/index.mjs
  var import_element144 = __toESM(require_element(), 1);
  var import_data63 = __toESM(require_data(), 1);
  var import_i18n136 = __toESM(require_i18n(), 1);
  var import_core_data38 = __toESM(require_core_data(), 1);
  var import_block_editor18 = __toESM(require_block_editor(), 1);
  var import_notices17 = __toESM(require_notices(), 1);
  var import_patterns7 = __toESM(require_patterns(), 1);
  var import_blocks14 = __toESM(require_blocks(), 1);

  // packages/editor/build-module/components/provider/with-registry-provider.mjs
  var import_element44 = __toESM(require_element(), 1);
  var import_data27 = __toESM(require_data(), 1);
  var import_compose5 = __toESM(require_compose(), 1);
  var import_block_editor4 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
  function getSubRegistry(subRegistries, registry, useSubRegistry) {
    if (!useSubRegistry) {
      return registry;
    }
    let subRegistry = subRegistries.get(registry);
    if (!subRegistry) {
      subRegistry = (0, import_data27.createRegistry)(
        {
          "core/block-editor": import_block_editor4.storeConfig
        },
        registry
      );
      subRegistry.registerStore("core/editor", storeConfig);
      subRegistries.set(registry, subRegistry);
    }
    return subRegistry;
  }
  var withRegistryProvider = (0, import_compose5.createHigherOrderComponent)(
    (WrappedComponent) => ({ useSubRegistry = true, ...props }) => {
      const registry = (0, import_data27.useRegistry)();
      const [subRegistries] = (0, import_element44.useState)(() => /* @__PURE__ */ new WeakMap());
      const subRegistry = getSubRegistry(
        subRegistries,
        registry,
        useSubRegistry
      );
      if (subRegistry === registry) {
        return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(WrappedComponent, { registry, ...props });
      }
      return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_data27.RegistryProvider, { value: subRegistry, children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(WrappedComponent, { registry: subRegistry, ...props }) });
    },
    "withRegistryProvider"
  );
  var with_registry_provider_default = withRegistryProvider;

  // packages/editor/build-module/components/provider/use-block-editor-settings.mjs
  var import_element129 = __toESM(require_element(), 1);
  var import_data45 = __toESM(require_data(), 1);
  var import_core_data30 = __toESM(require_core_data(), 1);
  var import_i18n126 = __toESM(require_i18n(), 1);
  var import_preferences6 = __toESM(require_preferences(), 1);
  var import_compose23 = __toESM(require_compose(), 1);
  var import_blocks8 = __toESM(require_blocks(), 1);
  var import_block_editor6 = __toESM(require_block_editor(), 1);

  // packages/media-editor/build-module/components/media-editor-provider/index.mjs
  var import_element45 = __toESM(require_element(), 1);
  var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
  var MediaEditorContext = (0, import_element45.createContext)(
    void 0
  );
  function MediaEditorProvider({
    value,
    onChange,
    settings = {},
    children
  }) {
    const contextValue = {
      media: value,
      onChange,
      fields: settings.fields || []
    };
    return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(MediaEditorContext.Provider, { value: contextValue, children });
  }
  function useMediaEditorContext() {
    const context = (0, import_element45.useContext)(MediaEditorContext);
    if (!context) {
      throw new Error(
        "useMediaEditorContext must be used within MediaEditorProvider"
      );
    }
    return context;
  }

  // packages/media-editor/build-module/components/media-preview/index.mjs
  var import_components28 = __toESM(require_components(), 1);
  var import_element46 = __toESM(require_element(), 1);
  var import_i18n67 = __toESM(require_i18n(), 1);

  // packages/media-editor/build-module/utils/get-media-type.mjs
  function getMediaTypeFromMimeType(mimeType) {
    if (!mimeType) {
      return { type: "application" };
    }
    if (mimeType.startsWith("image/")) {
      return { type: "image" };
    }
    if (mimeType.startsWith("video/")) {
      return { type: "video" };
    }
    if (mimeType.startsWith("audio/")) {
      return { type: "audio" };
    }
    return { type: "application" };
  }

  // packages/media-editor/build-module/components/media-preview/index.mjs
  var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
  function MediaPreviewContent({
    mediaType,
    mediaUrl,
    altText,
    displayTitle,
    mimeType,
    onLoad,
    onError,
    loadingState
  }) {
    switch (mediaType.type) {
      case "image":
        return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
          "img",
          {
            className: loadingState === "loaded" ? "loaded" : "",
            src: mediaUrl,
            alt: altText || "",
            onLoad,
            onError
          }
        );
      case "video":
        return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("video", { src: mediaUrl, controls: true, onError, children: displayTitle });
      case "audio":
        return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("audio", { src: mediaUrl, controls: true, onError, children: displayTitle });
      default:
        return /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)("div", { className: "media-editor-preview__file-info", children: [
          /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("p", { className: "media-editor-preview__file-name", children: displayTitle }),
          /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("p", { className: "media-editor-preview__mime-type", children: mimeType }),
          /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
            "a",
            {
              href: mediaUrl,
              target: "_blank",
              rel: "noopener",
              className: "media-editor-preview__download-link",
              children: (0, import_i18n67.__)("View file")
            }
          )
        ] });
    }
  }
  function MediaPreview2(props) {
    const [loadingState, setLoadingState] = (0, import_element46.useState)("loading");
    const { media } = useMediaEditorContext();
    const {
      source_url: mediaUrl,
      mime_type: mimeType,
      alt_text: altText,
      title
    } = media || {};
    const mediaType = getMediaTypeFromMimeType(mimeType);
    if (!mediaUrl) {
      return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "media-editor-preview media-editor-preview--empty", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("p", { children: (0, import_i18n67.__)("No media file available.") }) });
    }
    if (loadingState === "error") {
      return /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)("div", { className: "media-editor-preview media-editor-preview--error", children: [
        /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("p", { children: (0, import_i18n67.__)("Failed to load media file.") }),
        /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("p", { className: "media-editor-preview__url", children: mediaUrl })
      ] });
    }
    const displayTitle = typeof title === "string" ? title : title?.rendered || title?.raw;
    return /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(
      "div",
      {
        ...props,
        className: `media-editor-preview media-editor-preview--${mediaType.type}`,
        children: [
          mediaType.type === "image" && loadingState === "loading" && /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "media-editor-preview__spinner", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_components28.Spinner, {}) }),
          /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
            MediaPreviewContent,
            {
              mediaType,
              mediaUrl,
              altText,
              displayTitle,
              mimeType,
              onLoad: () => setLoadingState("loaded"),
              onError: () => setLoadingState("error"),
              loadingState
            }
          )
        ]
      }
    );
  }

  // packages/dataviews/build-module/dataviews/index.mjs
  var import_element102 = __toESM(require_element(), 1);
  var import_compose17 = __toESM(require_compose(), 1);

  // packages/dataviews/build-module/components/dataviews-context/index.mjs
  var import_element47 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/constants.mjs
  var import_i18n68 = __toESM(require_i18n(), 1);
  var OPERATOR_IS_ANY2 = "isAny";
  var OPERATOR_IS_NONE = "isNone";
  var OPERATOR_IS_ALL = "isAll";
  var OPERATOR_IS_NOT_ALL = "isNotAll";
  var OPERATOR_BETWEEN = "between";
  var OPERATOR_IN_THE_PAST = "inThePast";
  var OPERATOR_OVER = "over";
  var OPERATOR_IS = "is";
  var OPERATOR_IS_NOT = "isNot";
  var OPERATOR_LESS_THAN = "lessThan";
  var OPERATOR_GREATER_THAN = "greaterThan";
  var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
  var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
  var OPERATOR_BEFORE = "before";
  var OPERATOR_AFTER = "after";
  var OPERATOR_BEFORE_INC = "beforeInc";
  var OPERATOR_AFTER_INC = "afterInc";
  var OPERATOR_CONTAINS = "contains";
  var OPERATOR_NOT_CONTAINS = "notContains";
  var OPERATOR_STARTS_WITH = "startsWith";
  var OPERATOR_ON = "on";
  var OPERATOR_NOT_ON = "notOn";
  var SORTING_DIRECTIONS = ["asc", "desc"];
  var sortArrows = { asc: "\u2191", desc: "\u2193" };
  var sortValues = { asc: "ascending", desc: "descending" };
  var sortLabels = {
    asc: (0, import_i18n68.__)("Sort ascending"),
    desc: (0, import_i18n68.__)("Sort descending")
  };
  var sortIcons = {
    asc: arrow_up_default,
    desc: arrow_down_default
  };
  var LAYOUT_TABLE = "table";
  var LAYOUT_GRID = "grid";
  var LAYOUT_LIST = "list";
  var LAYOUT_ACTIVITY = "activity";
  var LAYOUT_PICKER_GRID = "pickerGrid";
  var LAYOUT_PICKER_TABLE = "pickerTable";

  // packages/dataviews/build-module/components/dataviews-context/index.mjs
  var DataViewsContext = (0, import_element47.createContext)({
    view: { type: LAYOUT_TABLE },
    onChangeView: () => {
    },
    fields: [],
    data: [],
    paginationInfo: {
      totalItems: 0,
      totalPages: 0
    },
    selection: [],
    onChangeSelection: () => {
    },
    setOpenedFilter: () => {
    },
    openedFilter: null,
    getItemId: (item) => item.id,
    isItemClickable: () => true,
    renderItemLink: void 0,
    containerWidth: 0,
    containerRef: (0, import_element47.createRef)(),
    resizeObserverRef: () => {
    },
    defaultLayouts: { list: {}, grid: {}, table: {} },
    filters: [],
    isShowingFilter: false,
    setIsShowingFilter: () => {
    },
    hasInitiallyLoaded: false,
    config: {
      perPageSizes: []
    },
    intersectionObserver: null
  });
  DataViewsContext.displayName = "DataViewsContext";
  var dataviews_context_default = DataViewsContext;

  // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
  var import_i18n88 = __toESM(require_i18n(), 1);

  // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
  var import_i18n76 = __toESM(require_i18n(), 1);
  var import_components34 = __toESM(require_components(), 1);
  var import_element55 = __toESM(require_element(), 1);
  var import_keycodes = __toESM(require_keycodes(), 1);

  // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
  var import_components29 = __toESM(require_components(), 1);
  var import_i18n69 = __toESM(require_i18n(), 1);
  var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
  function DataViewsSelectionCheckbox({
    selection,
    onChangeSelection,
    item,
    getItemId,
    titleField: titleField2,
    disabled: disabled2,
    ...extraProps
  }) {
    const id = getItemId(item);
    const isInSelectionArray = selection.includes(id);
    const checked = !disabled2 && isInSelectionArray;
    const selectionLabel = titleField2?.getValue?.({ item }) || (0, import_i18n69.__)("(no title)");
    return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
      import_components29.CheckboxControl,
      {
        className: "dataviews-selection-checkbox",
        "aria-label": selectionLabel,
        "aria-disabled": disabled2,
        checked,
        onChange: () => {
          if (disabled2) {
            return;
          }
          onChangeSelection(
            isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
          );
        },
        ...extraProps
      }
    );
  }

  // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
  var import_components30 = __toESM(require_components(), 1);
  var import_i18n70 = __toESM(require_i18n(), 1);
  var import_element48 = __toESM(require_element(), 1);
  var import_data28 = __toESM(require_data(), 1);
  var import_compose6 = __toESM(require_compose(), 1);

  // packages/dataviews/build-module/lock-unlock.mjs
  var import_private_apis3 = __toESM(require_private_apis(), 1);
  var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
    "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
    "@wordpress/dataviews"
  );

  // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
  var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
  var { Menu, kebabCase } = unlock3(import_components30.privateApis);
  function ButtonTrigger({
    action,
    onClick,
    items,
    variant
  }) {
    const label = typeof action.label === "string" ? action.label : action.label(items);
    return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
      import_components30.Button,
      {
        disabled: !!action.disabled,
        accessibleWhenDisabled: true,
        size: "compact",
        variant,
        onClick,
        children: label
      }
    );
  }
  function MenuItemTrigger({
    action,
    onClick,
    items
  }) {
    const label = typeof action.label === "string" ? action.label : action.label(items);
    return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(Menu.ItemLabel, { children: label }) });
  }
  function ActionModal({
    action,
    items,
    closeModal: closeModal2
  }) {
    const label = typeof action.label === "string" ? action.label : action.label(items);
    const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
    return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
      import_components30.Modal,
      {
        title: modalHeader || label,
        __experimentalHideHeader: !!action.hideModalHeader,
        onRequestClose: closeModal2,
        focusOnMount: action.modalFocusOnMount ?? true,
        size: action.modalSize || "medium",
        overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
          action.id
        )}`,
        children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(action.RenderModal, { items, closeModal: closeModal2 })
      }
    );
  }
  function ActionsMenuGroup({
    actions: actions2,
    item,
    registry,
    setActiveModalAction
  }) {
    const { primaryActions, regularActions } = (0, import_element48.useMemo)(() => {
      return actions2.reduce(
        (acc, action) => {
          (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
          return acc;
        },
        {
          primaryActions: [],
          regularActions: []
        }
      );
    }, [actions2]);
    const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
      MenuItemTrigger,
      {
        action,
        onClick: () => {
          if ("RenderModal" in action) {
            setActiveModalAction(action);
            return;
          }
          action.callback([item], { registry });
        },
        items: [item]
      },
      action.id
    ));
    return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(Menu.Group, { children: [
      renderActionGroup(primaryActions),
      renderActionGroup(regularActions)
    ] });
  }
  function ItemActions({
    item,
    actions: actions2,
    isCompact
  }) {
    const registry = (0, import_data28.useRegistry)();
    const { primaryActions, eligibleActions } = (0, import_element48.useMemo)(() => {
      const _eligibleActions = actions2.filter(
        (action) => !action.isEligible || action.isEligible(item)
      );
      const _primaryActions = _eligibleActions.filter(
        (action) => action.isPrimary
      );
      return {
        primaryActions: _primaryActions,
        eligibleActions: _eligibleActions
      };
    }, [actions2, item]);
    const isMobileViewport = (0, import_compose6.useViewportMatch)("medium", "<");
    if (isCompact) {
      return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
        CompactItemActions,
        {
          item,
          actions: eligibleActions,
          isSmall: true,
          registry
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
      Stack,
      {
        direction: "row",
        justify: "flex-end",
        className: "dataviews-item-actions",
        style: {
          flexShrink: 0,
          width: "auto"
        },
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
            PrimaryActions,
            {
              item,
              actions: primaryActions,
              registry
            }
          ),
          (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
          // there if there are any actions at all.
          isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
            CompactItemActions,
            {
              item,
              actions: eligibleActions,
              registry
            }
          )
        ]
      }
    );
  }
  function CompactItemActions({
    item,
    actions: actions2,
    isSmall,
    registry
  }) {
    const [activeModalAction, setActiveModalAction] = (0, import_element48.useState)(
      null
    );
    return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(import_jsx_runtime140.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(Menu, { placement: "bottom-end", children: [
        /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
          Menu.TriggerButton,
          {
            render: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
              import_components30.Button,
              {
                size: isSmall ? "small" : "compact",
                icon: more_vertical_default,
                label: (0, import_i18n70.__)("Actions"),
                accessibleWhenDisabled: true,
                disabled: !actions2.length,
                className: "dataviews-all-actions-button"
              }
            )
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
          ActionsMenuGroup,
          {
            actions: actions2,
            item,
            registry,
            setActiveModalAction
          }
        ) })
      ] }),
      !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
        ActionModal,
        {
          action: activeModalAction,
          items: [item],
          closeModal: () => setActiveModalAction(null)
        }
      )
    ] });
  }
  function PrimaryActions({
    item,
    actions: actions2,
    registry,
    buttonVariant
  }) {
    const [activeModalAction, setActiveModalAction] = (0, import_element48.useState)(null);
    const isMobileViewport = (0, import_compose6.useViewportMatch)("medium", "<");
    if (isMobileViewport) {
      return null;
    }
    if (!Array.isArray(actions2) || actions2.length === 0) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(import_jsx_runtime140.Fragment, { children: [
      actions2.map((action) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
        ButtonTrigger,
        {
          action,
          onClick: () => {
            if ("RenderModal" in action) {
              setActiveModalAction(action);
              return;
            }
            action.callback([item], { registry });
          },
          items: [item],
          variant: buttonVariant
        },
        action.id
      )),
      !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
        ActionModal,
        {
          action: activeModalAction,
          items: [item],
          closeModal: () => setActiveModalAction(null)
        }
      )
    ] });
  }

  // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
  var import_components31 = __toESM(require_components(), 1);
  var import_i18n72 = __toESM(require_i18n(), 1);
  var import_element49 = __toESM(require_element(), 1);
  var import_data29 = __toESM(require_data(), 1);
  var import_compose7 = __toESM(require_compose(), 1);

  // packages/dataviews/build-module/utils/get-footer-message.mjs
  var import_i18n71 = __toESM(require_i18n(), 1);
  function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
    if (selectionCount > 0) {
      return (0, import_i18n71.sprintf)(
        /* translators: %d: number of items. */
        (0, import_i18n71._n)("%d Item selected", "%d Items selected", selectionCount),
        selectionCount
      );
    }
    if (onlyTotalCount || totalItems <= itemsCount) {
      return (0, import_i18n71.sprintf)(
        /* translators: %d: number of items. */
        (0, import_i18n71._n)("%d Item", "%d Items", totalItems),
        totalItems
      );
    }
    return (0, import_i18n71.sprintf)(
      /* translators: %1$d: number of items. %2$d: total number of items. */
      (0, import_i18n71._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
      itemsCount,
      totalItems
    );
  }

  // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
  var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
  function ActionWithModal({
    action,
    items,
    ActionTriggerComponent
  }) {
    const [isModalOpen, setIsModalOpen] = (0, import_element49.useState)(false);
    const actionTriggerProps = {
      action,
      onClick: () => {
        setIsModalOpen(true);
      },
      items
    };
    return /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(import_jsx_runtime141.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
      isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
        ActionModal,
        {
          action,
          items,
          closeModal: () => setIsModalOpen(false)
        }
      )
    ] });
  }
  function useHasAPossibleBulkAction(actions2, item) {
    return (0, import_element49.useMemo)(() => {
      return actions2.some((action) => {
        return action.supportsBulk && (!action.isEligible || action.isEligible(item));
      });
    }, [actions2, item]);
  }
  function useSomeItemHasAPossibleBulkAction(actions2, data) {
    return (0, import_element49.useMemo)(() => {
      return data.some((item) => {
        return actions2.some((action) => {
          return action.supportsBulk && (!action.isEligible || action.isEligible(item));
        });
      });
    }, [actions2, data]);
  }
  function BulkSelectionCheckbox({
    selection,
    onChangeSelection,
    data,
    actions: actions2,
    getItemId,
    disableSelectAll = false
  }) {
    const selectableItems = (0, import_element49.useMemo)(() => {
      return data.filter((item) => {
        return actions2.some(
          (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
        );
      });
    }, [data, actions2]);
    const selectedItems = data.filter(
      (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
    );
    const hasSelection = selection.length > 0;
    const areAllSelected = selectedItems.length === selectableItems.length;
    if (disableSelectAll) {
      return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
        import_components31.CheckboxControl,
        {
          className: "dataviews-view-table-selection-checkbox",
          checked: hasSelection,
          disabled: !hasSelection,
          onChange: () => {
            onChangeSelection([]);
          },
          "aria-label": (0, import_i18n72.__)("Deselect all")
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
      import_components31.CheckboxControl,
      {
        className: "dataviews-view-table-selection-checkbox",
        checked: areAllSelected,
        indeterminate: !areAllSelected && !!selectedItems.length,
        onChange: () => {
          if (areAllSelected) {
            onChangeSelection([]);
          } else {
            onChangeSelection(
              selectableItems.map((item) => getItemId(item))
            );
          }
        },
        "aria-label": areAllSelected ? (0, import_i18n72.__)("Deselect all") : (0, import_i18n72.__)("Select all")
      }
    );
  }
  function ActionTrigger({
    action,
    onClick,
    isBusy,
    items
  }) {
    const label = typeof action.label === "string" ? action.label : action.label(items);
    const isMobile = (0, import_compose7.useViewportMatch)("medium", "<");
    if (isMobile) {
      return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
        import_components31.Button,
        {
          disabled: isBusy,
          accessibleWhenDisabled: true,
          label,
          icon: action.icon,
          size: "compact",
          onClick,
          isBusy
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
      import_components31.Button,
      {
        disabled: isBusy,
        accessibleWhenDisabled: true,
        size: "compact",
        onClick,
        isBusy,
        children: label
      }
    );
  }
  var EMPTY_ARRAY3 = [];
  function ActionButton({
    action,
    selectedItems,
    actionInProgress,
    setActionInProgress
  }) {
    const registry = (0, import_data29.useRegistry)();
    const selectedEligibleItems = (0, import_element49.useMemo)(() => {
      return selectedItems.filter((item) => {
        return !action.isEligible || action.isEligible(item);
      });
    }, [action, selectedItems]);
    if ("RenderModal" in action) {
      return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
        ActionWithModal,
        {
          action,
          items: selectedEligibleItems,
          ActionTriggerComponent: ActionTrigger
        },
        action.id
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
      ActionTrigger,
      {
        action,
        onClick: async () => {
          setActionInProgress(action.id);
          await action.callback(selectedItems, {
            registry
          });
          setActionInProgress(null);
        },
        items: selectedEligibleItems,
        isBusy: actionInProgress === action.id
      },
      action.id
    );
  }
  function renderFooterContent(data, actions2, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo2) {
    const message2 = getFooterMessage(
      selection.length,
      data.length,
      paginationInfo2.totalItems,
      isInfiniteScroll
    );
    return /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(
      Stack,
      {
        direction: "row",
        className: "dataviews-bulk-actions-footer__container",
        gap: "md",
        align: "center",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
            BulkSelectionCheckbox,
            {
              selection,
              onChangeSelection,
              data,
              actions: actions2,
              getItemId,
              disableSelectAll: isInfiniteScroll
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
          /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(
            Stack,
            {
              direction: "row",
              className: "dataviews-bulk-actions-footer__action-buttons",
              gap: "xs",
              children: [
                actionsToShow.map((action) => {
                  return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
                    ActionButton,
                    {
                      action,
                      selectedItems,
                      actionInProgress,
                      setActionInProgress
                    },
                    action.id
                  );
                }),
                selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
                  import_components31.Button,
                  {
                    icon: close_small_default,
                    showTooltip: true,
                    tooltipPosition: "top",
                    size: "compact",
                    label: (0, import_i18n72.__)("Cancel"),
                    disabled: !!actionInProgress,
                    accessibleWhenDisabled: false,
                    onClick: () => {
                      onChangeSelection(EMPTY_ARRAY3);
                    }
                  }
                )
              ]
            }
          )
        ]
      }
    );
  }
  function FooterContent({
    selection,
    actions: actions2,
    onChangeSelection,
    data,
    getItemId,
    isInfiniteScroll,
    paginationInfo: paginationInfo2
  }) {
    const [actionInProgress, setActionInProgress] = (0, import_element49.useState)(
      null
    );
    const footerContentRef = (0, import_element49.useRef)(void 0);
    const isMobile = (0, import_compose7.useViewportMatch)("medium", "<");
    const bulkActions = (0, import_element49.useMemo)(
      () => actions2.filter((action) => action.supportsBulk),
      [actions2]
    );
    const selectableItems = (0, import_element49.useMemo)(() => {
      return data.filter((item) => {
        return bulkActions.some(
          (action) => !action.isEligible || action.isEligible(item)
        );
      });
    }, [data, bulkActions]);
    const selectedItems = (0, import_element49.useMemo)(() => {
      return data.filter(
        (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
      );
    }, [selection, data, getItemId, selectableItems]);
    const actionsToShow = (0, import_element49.useMemo)(
      () => actions2.filter((action) => {
        return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
          (item) => !action.isEligible || action.isEligible(item)
        );
      }),
      [actions2, selectedItems, isMobile]
    );
    if (!actionInProgress) {
      if (footerContentRef.current) {
        footerContentRef.current = void 0;
      }
      return renderFooterContent(
        data,
        actions2,
        getItemId,
        isInfiniteScroll,
        selection,
        actionsToShow,
        selectedItems,
        actionInProgress,
        setActionInProgress,
        onChangeSelection,
        paginationInfo2
      );
    } else if (!footerContentRef.current) {
      footerContentRef.current = renderFooterContent(
        data,
        actions2,
        getItemId,
        isInfiniteScroll,
        selection,
        actionsToShow,
        selectedItems,
        actionInProgress,
        setActionInProgress,
        onChangeSelection,
        paginationInfo2
      );
    }
    return footerContentRef.current;
  }
  function BulkActionsFooter() {
    const {
      data,
      selection,
      actions: actions2 = EMPTY_ARRAY3,
      onChangeSelection,
      getItemId,
      paginationInfo: paginationInfo2,
      view: view2
    } = (0, import_element49.useContext)(dataviews_context_default);
    return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
      FooterContent,
      {
        selection,
        onChangeSelection,
        data,
        actions: actions2,
        getItemId,
        isInfiniteScroll: !!view2.infiniteScrollEnabled,
        paginationInfo: paginationInfo2
      }
    );
  }

  // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
  var import_i18n73 = __toESM(require_i18n(), 1);
  var import_components32 = __toESM(require_components(), 1);
  var import_element50 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/utils/get-hideable-fields.mjs
  function getHideableFields(view2, fields3) {
    const togglableFields = [
      view2?.titleField,
      view2?.mediaField,
      view2?.descriptionField
    ].filter(Boolean);
    return fields3.filter(
      (f3) => !togglableFields.includes(f3.id) && f3.type !== "media" && f3.enableHiding !== false
    );
  }

  // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
  var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
  var { Menu: Menu2 } = unlock3(import_components32.privateApis);
  function WithMenuSeparators({ children }) {
    return import_element50.Children.toArray(children).filter(Boolean).map((child, i3) => /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(import_element50.Fragment, { children: [
      i3 > 0 && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.Separator, {}),
      child
    ] }, i3));
  }
  var _HeaderMenu = (0, import_element50.forwardRef)(function HeaderMenu({
    fieldId,
    view: view2,
    fields: fields3,
    onChangeView,
    onHide,
    setOpenedFilter,
    canMove = true,
    canInsertLeft = true,
    canInsertRight = true
  }, ref) {
    const visibleFieldIds = view2.fields ?? [];
    const index = visibleFieldIds?.indexOf(fieldId);
    const isSorted = view2.sort?.field === fieldId;
    let isHidable = false;
    let isSortable = false;
    let canAddFilter = false;
    let operators = [];
    const field = fields3.find((f3) => f3.id === fieldId);
    const { setIsShowingFilter } = (0, import_element50.useContext)(dataviews_context_default);
    if (!field) {
      return null;
    }
    isHidable = field.enableHiding !== false;
    isSortable = field.enableSorting !== false;
    const header = field.header;
    operators = !!field.filterBy && field.filterBy?.operators || [];
    canAddFilter = !view2.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
    if (!isSortable && !canMove && !isHidable && !canAddFilter) {
      return header;
    }
    const hiddenFields = getHideableFields(view2, fields3).filter(
      (f3) => !visibleFieldIds.includes(f3.id)
    );
    const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
    const isRtl = (0, import_i18n73.isRTL)();
    return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(Menu2, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(
        Menu2.TriggerButton,
        {
          render: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
            import_components32.Button,
            {
              size: "compact",
              className: "dataviews-view-table-header-button",
              ref,
              variant: "tertiary"
            }
          ),
          children: [
            header,
            view2.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("span", { "aria-hidden": "true", children: sortArrows[view2.sort.direction] })
          ]
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(WithMenuSeparators, { children: [
        isSortable && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
          (direction) => {
            const isChecked = view2.sort && isSorted && view2.sort.direction === direction;
            const value = `${fieldId}-${direction}`;
            return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
              Menu2.RadioItem,
              {
                name: "view-table-sorting",
                value,
                checked: isChecked,
                onChange: () => {
                  onChangeView({
                    ...view2,
                    sort: {
                      field: fieldId,
                      direction
                    },
                    showLevels: false
                  });
                },
                children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
              },
              value
            );
          }
        ) }),
        canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
          Menu2.Item,
          {
            prefix: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components32.Icon, { icon: funnel_default }),
            onClick: () => {
              setOpenedFilter(fieldId);
              setIsShowingFilter(true);
              onChangeView({
                ...view2,
                page: 1,
                filters: [
                  ...view2.filters || [],
                  {
                    field: fieldId,
                    value: void 0,
                    operator: operators[0]
                  }
                ]
              });
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.ItemLabel, { children: (0, import_i18n73.__)("Add filter") })
          }
        ) }),
        (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(Menu2.Group, { children: [
          canMove && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
            Menu2.Item,
            {
              prefix: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components32.Icon, { icon: arrow_left_default }),
              disabled: isRtl ? index >= visibleFieldIds.length - 1 : index < 1,
              onClick: () => {
                const targetIndex = isRtl ? index + 1 : index - 1;
                const newFields = [
                  ...visibleFieldIds
                ];
                newFields.splice(index, 1);
                newFields.splice(
                  targetIndex,
                  0,
                  fieldId
                );
                onChangeView({
                  ...view2,
                  fields: newFields
                });
              },
              children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.ItemLabel, { children: (0, import_i18n73.__)("Move left") })
            }
          ),
          canMove && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
            Menu2.Item,
            {
              prefix: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components32.Icon, { icon: arrow_right_default }),
              disabled: isRtl ? index < 1 : index >= visibleFieldIds.length - 1,
              onClick: () => {
                const targetIndex = isRtl ? index - 1 : index + 1;
                const newFields = [
                  ...visibleFieldIds
                ];
                newFields.splice(index, 1);
                newFields.splice(
                  targetIndex,
                  0,
                  fieldId
                );
                onChangeView({
                  ...view2,
                  fields: newFields
                });
              },
              children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.ItemLabel, { children: (0, import_i18n73.__)("Move right") })
            }
          ),
          canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(Menu2, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.ItemLabel, { children: (0, import_i18n73.__)("Insert left") }) }),
            /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
              const insertIndex = isRtl ? index + 1 : index;
              return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
                Menu2.Item,
                {
                  onClick: () => {
                    onChangeView({
                      ...view2,
                      fields: [
                        ...visibleFieldIds.slice(
                          0,
                          insertIndex
                        ),
                        hiddenField.id,
                        ...visibleFieldIds.slice(
                          insertIndex
                        )
                      ]
                    });
                  },
                  children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
                },
                hiddenField.id
              );
            }) })
          ] }),
          canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(Menu2, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.ItemLabel, { children: (0, import_i18n73.__)("Insert right") }) }),
            /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
              const insertIndex = isRtl ? index : index + 1;
              return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
                Menu2.Item,
                {
                  onClick: () => {
                    onChangeView({
                      ...view2,
                      fields: [
                        ...visibleFieldIds.slice(
                          0,
                          insertIndex
                        ),
                        hiddenField.id,
                        ...visibleFieldIds.slice(
                          insertIndex
                        )
                      ]
                    });
                  },
                  children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
                },
                hiddenField.id
              );
            }) })
          ] }),
          isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
            Menu2.Item,
            {
              prefix: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components32.Icon, { icon: unseen_default }),
              onClick: () => {
                onHide(field);
                onChangeView({
                  ...view2,
                  fields: visibleFieldIds.filter(
                    (id) => id !== fieldId
                  )
                });
              },
              children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Menu2.ItemLabel, { children: (0, import_i18n73.__)("Hide column") })
            }
          )
        ] })
      ] }) })
    ] });
  });
  var ColumnHeaderMenu = _HeaderMenu;
  var column_header_menu_default = ColumnHeaderMenu;

  // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
  var import_element51 = __toESM(require_element(), 1);
  var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
  function getClickableItemProps({
    item,
    isItemClickable,
    onClickItem,
    className
  }) {
    if (!isItemClickable(item) || !onClickItem) {
      return { className };
    }
    return {
      className: className ? `${className} ${className}--clickable` : void 0,
      role: "button",
      tabIndex: 0,
      onClick: (event) => {
        event.stopPropagation();
        onClickItem(item);
      },
      onKeyDown: (event) => {
        if (event.key === "Enter" || event.key === "" || event.key === " ") {
          event.stopPropagation();
          onClickItem(item);
        }
      }
    };
  }
  function ItemClickWrapper({
    item,
    isItemClickable,
    onClickItem,
    renderItemLink,
    className,
    children,
    ...extraProps
  }) {
    if (!isItemClickable(item)) {
      return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("div", { className, ...extraProps, children });
    }
    if (renderItemLink) {
      const renderedElement = renderItemLink({
        item,
        className: `${className} ${className}--clickable`,
        ...extraProps,
        children
      });
      return (0, import_element51.cloneElement)(renderedElement, {
        onClick: (event) => {
          event.stopPropagation();
          if (renderedElement.props.onClick) {
            renderedElement.props.onClick(event);
          }
        },
        onKeyDown: (event) => {
          if (event.key === "Enter" || event.key === "" || event.key === " ") {
            event.stopPropagation();
            if (renderedElement.props.onKeyDown) {
              renderedElement.props.onKeyDown(event);
            }
          }
        }
      });
    }
    const clickProps = getClickableItemProps({
      item,
      isItemClickable,
      onClickItem,
      className
    });
    return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("div", { ...clickProps, ...extraProps, children });
  }

  // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
  var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
  function ColumnPrimary({
    item,
    level,
    titleField: titleField2,
    mediaField,
    descriptionField: descriptionField2,
    onClickItem,
    renderItemLink,
    isItemClickable
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
      mediaField && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
        ItemClickWrapper,
        {
          item,
          isItemClickable,
          onClickItem,
          renderItemLink,
          className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
          "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField2 ? titleField2.getValue?.({ item }) : void 0,
          children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
            mediaField.render,
            {
              item,
              field: mediaField,
              config: { sizes: "32px" }
            }
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(
        Stack,
        {
          direction: "column",
          align: "flex-start",
          className: "dataviews-view-table__primary-column-content",
          children: [
            titleField2 && /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(
              ItemClickWrapper,
              {
                item,
                isItemClickable,
                onClickItem,
                renderItemLink,
                className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
                children: [
                  level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)("span", { className: "dataviews-view-table__level", children: [
                    Array(level).fill("\u2014").join(" "),
                    "\xA0"
                  ] }),
                  /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(titleField2.render, { item, field: titleField2 })
                ]
              }
            ),
            descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
              descriptionField2.render,
              {
                item,
                field: descriptionField2
              }
            )
          ]
        }
      )
    ] });
  }
  var column_primary_default = ColumnPrimary;

  // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
  var import_element52 = __toESM(require_element(), 1);
  var import_i18n74 = __toESM(require_i18n(), 1);
  var isScrolledToEnd = (element) => {
    if ((0, import_i18n74.isRTL)()) {
      const scrollLeft = Math.abs(element.scrollLeft);
      return scrollLeft <= 1;
    }
    return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
  };
  function useScrollState({
    scrollContainerRef,
    enabledHorizontal = false
  }) {
    const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element52.useState)(false);
    const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element52.useState)(false);
    const handleScroll = (0, import_element52.useCallback)(() => {
      const scrollContainer = scrollContainerRef.current;
      if (!scrollContainer) {
        return;
      }
      if (enabledHorizontal) {
        setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
      }
      setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
    }, [scrollContainerRef, enabledHorizontal]);
    (0, import_element52.useEffect)(() => {
      if (typeof window === "undefined" || !scrollContainerRef.current) {
        return () => {
        };
      }
      const scrollContainer = scrollContainerRef.current;
      handleScroll();
      scrollContainer.addEventListener("scroll", handleScroll);
      window.addEventListener("resize", handleScroll);
      return () => {
        scrollContainer.removeEventListener("scroll", handleScroll);
        window.removeEventListener("resize", handleScroll);
      };
    }, [scrollContainerRef, enabledHorizontal, handleScroll]);
    return { isHorizontalScrollEnd, isVerticallyScrolled };
  }

  // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
  function getDataByGroup(data, groupByField) {
    return data.reduce((groups, item) => {
      const groupName = groupByField.getValue({ item });
      if (!groups.has(groupName)) {
        groups.set(groupName, []);
      }
      groups.get(groupName)?.push(item);
      return groups;
    }, /* @__PURE__ */ new Map());
  }

  // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
  var import_components33 = __toESM(require_components(), 1);
  var import_i18n75 = __toESM(require_i18n(), 1);
  var import_element53 = __toESM(require_element(), 1);
  var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1);
  function FieldItem({
    field,
    isVisible: isVisible2,
    onToggleVisibility
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components33.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
      /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components33.Icon, { icon: check_default }) }),
      /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
    ] }) });
  }
  function isDefined(item) {
    return !!item;
  }
  function PropertiesSection({
    showLabel = true
  }) {
    const { view: view2, fields: fields3, onChangeView } = (0, import_element53.useContext)(dataviews_context_default);
    const regularFields = getHideableFields(view2, fields3);
    if (!regularFields?.length) {
      return null;
    }
    const titleField2 = fields3.find((f3) => f3.id === view2.titleField);
    const previewField = fields3.find((f3) => f3.id === view2.mediaField);
    const descriptionField2 = fields3.find(
      (f3) => f3.id === view2.descriptionField
    );
    const lockedFields = [
      {
        field: titleField2,
        isVisibleFlag: "showTitle"
      },
      {
        field: previewField,
        isVisibleFlag: "showMedia"
      },
      {
        field: descriptionField2,
        isVisibleFlag: "showDescription"
      }
    ].filter(({ field }) => isDefined(field));
    const visibleFieldIds = view2.fields ?? [];
    const visibleRegularFieldsCount = regularFields.filter(
      (f3) => visibleFieldIds.includes(f3.id)
    ).length;
    const visibleLockedFields = lockedFields.filter(
      ({ isVisibleFlag }) => (
        // @ts-expect-error
        view2[isVisibleFlag] ?? true
      )
    );
    const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
    const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
    return /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
      showLabel && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components33.BaseControl.VisualLabel, { children: (0, import_i18n75.__)("Properties") }),
      /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
        Stack,
        {
          direction: "column",
          className: "dataviews-view-config__properties",
          children: /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_components33.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
            lockedFields.map(({ field, isVisibleFlag }) => {
              const isVisible2 = view2[isVisibleFlag] ?? true;
              const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
              return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
                FieldItem,
                {
                  field: fieldToRender,
                  isVisible: isVisible2,
                  onToggleVisibility: () => {
                    onChangeView({
                      ...view2,
                      [isVisibleFlag]: !isVisible2
                    });
                  }
                },
                field.id
              );
            }),
            regularFields.map((field) => {
              const isVisible2 = visibleFieldIds.includes(field.id);
              const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
              return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
                FieldItem,
                {
                  field: fieldToRender,
                  isVisible: isVisible2,
                  onToggleVisibility: () => {
                    onChangeView({
                      ...view2,
                      fields: isVisible2 ? visibleFieldIds.filter(
                        (fieldId) => fieldId !== field.id
                      ) : [...visibleFieldIds, field.id]
                    });
                  }
                },
                field.id
              );
            })
          ] })
        }
      )
    ] });
  }

  // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
  var import_element54 = __toESM(require_element(), 1);
  function useDelayedLoading(isLoading, options = { delay: 400 }) {
    const [showLoader, setShowLoader] = (0, import_element54.useState)(false);
    (0, import_element54.useEffect)(() => {
      if (!isLoading) {
        return;
      }
      const timeout = setTimeout(() => {
        setShowLoader(true);
      }, options.delay);
      return () => {
        clearTimeout(timeout);
        setShowLoader(false);
      };
    }, [isLoading, options.delay]);
    return showLoader;
  }

  // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
  var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1);
  function getEffectiveAlign(explicitAlign, fieldType) {
    if (explicitAlign) {
      return explicitAlign;
    }
    if (fieldType === "integer" || fieldType === "number") {
      return "end";
    }
    return void 0;
  }
  function TableColumnField({
    item,
    fields: fields3,
    column,
    align
  }) {
    const field = fields3.find((f3) => f3.id === column);
    if (!field) {
      return null;
    }
    const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
      "dataviews-view-table__cell-align-end": align === "end",
      "dataviews-view-table__cell-align-center": align === "center"
    });
    return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(field.render, { item, field }) });
  }
  function TableRow({
    hasBulkActions,
    item,
    level,
    actions: actions2,
    fields: fields3,
    id,
    view: view2,
    titleField: titleField2,
    mediaField,
    descriptionField: descriptionField2,
    selection,
    getItemId,
    isItemClickable,
    onClickItem,
    renderItemLink,
    onChangeSelection,
    isActionsColumnSticky,
    posinset
  }) {
    const { paginationInfo: paginationInfo2 } = (0, import_element55.useContext)(dataviews_context_default);
    const hasPossibleBulkAction = useHasAPossibleBulkAction(actions2, item);
    const isSelected2 = hasPossibleBulkAction && selection.includes(id);
    const {
      showTitle = true,
      showMedia = true,
      showDescription = true,
      infiniteScrollEnabled
    } = view2;
    const isTouchDeviceRef = (0, import_element55.useRef)(false);
    const columns = view2.fields ?? [];
    const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
    return /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(
      "tr",
      {
        className: clsx_default("dataviews-view-table__row", {
          "is-selected": hasPossibleBulkAction && isSelected2,
          "has-bulk-actions": hasPossibleBulkAction
        }),
        onTouchStart: () => {
          isTouchDeviceRef.current = true;
        },
        "aria-setsize": infiniteScrollEnabled ? paginationInfo2.totalItems : void 0,
        "aria-posinset": posinset,
        role: infiniteScrollEnabled ? "article" : void 0,
        onMouseDown: (event) => {
          const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
          if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
            event?.preventDefault();
          }
        },
        onClick: (event) => {
          if (!hasPossibleBulkAction) {
            return;
          }
          const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
          if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
            onChangeSelection(
              selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
            );
          }
        },
        children: [
          hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
            DataViewsSelectionCheckbox,
            {
              item,
              selection,
              onChangeSelection,
              getItemId,
              titleField: titleField2,
              disabled: !hasPossibleBulkAction
            }
          ) }) }),
          hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
            column_primary_default,
            {
              item,
              level,
              titleField: showTitle ? titleField2 : void 0,
              mediaField: showMedia ? mediaField : void 0,
              descriptionField: showDescription ? descriptionField2 : void 0,
              isItemClickable,
              onClickItem,
              renderItemLink
            }
          ) }),
          columns.map((column) => {
            const { width, maxWidth, minWidth, align } = view2.layout?.styles?.[column] ?? {};
            const field = fields3.find((f3) => f3.id === column);
            const effectiveAlign = getEffectiveAlign(align, field?.type);
            return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
              "td",
              {
                style: {
                  width,
                  maxWidth,
                  minWidth
                },
                children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
                  TableColumnField,
                  {
                    fields: fields3,
                    item,
                    column,
                    align: effectiveAlign
                  }
                )
              },
              column
            );
          }),
          !!actions2?.length && // Disable reason: we are not making the element interactive,
          // but preventing any click events from bubbling up to the
          // table row. This allows us to add a click handler to the row
          // itself (to toggle row selection) without erroneously
          // intercepting click events from ItemActions.
          /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
            "td",
            {
              className: clsx_default("dataviews-view-table__actions-column", {
                "dataviews-view-table__actions-column--sticky": true,
                "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
              }),
              onClick: (e3) => e3.stopPropagation(),
              children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(ItemActions, { item, actions: actions2 })
            }
          )
        ]
      }
    );
  }
  function ViewTable({
    actions: actions2,
    data,
    fields: fields3,
    getItemId,
    getItemLevel,
    isLoading = false,
    onChangeView,
    onChangeSelection,
    selection,
    setOpenedFilter,
    onClickItem,
    isItemClickable,
    renderItemLink,
    view: view2,
    className,
    empty
  }) {
    const { containerRef } = (0, import_element55.useContext)(dataviews_context_default);
    const isDelayedLoading = useDelayedLoading(isLoading);
    const headerMenuRefs = (0, import_element55.useRef)(/* @__PURE__ */ new Map());
    const headerMenuToFocusRef = (0, import_element55.useRef)(void 0);
    const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element55.useState)();
    const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element55.useState)(null);
    (0, import_element55.useEffect)(() => {
      if (headerMenuToFocusRef.current) {
        headerMenuToFocusRef.current.focus();
        headerMenuToFocusRef.current = void 0;
      }
    });
    const tableNoticeId = (0, import_element55.useId)();
    const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
      scrollContainerRef: containerRef,
      enabledHorizontal: !!actions2?.length
    });
    const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data);
    if (nextHeaderMenuToFocus) {
      headerMenuToFocusRef.current = nextHeaderMenuToFocus;
      setNextHeaderMenuToFocus(void 0);
      return;
    }
    const onHide = (field) => {
      const hidden = headerMenuRefs.current.get(field.id);
      const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
      setNextHeaderMenuToFocus(fallback?.node);
    };
    const handleHeaderContextMenu = (event) => {
      event.preventDefault();
      event.stopPropagation();
      const virtualAnchor = {
        getBoundingClientRect: () => ({
          x: event.clientX,
          y: event.clientY,
          top: event.clientY,
          left: event.clientX,
          right: event.clientX,
          bottom: event.clientY,
          width: 0,
          height: 0,
          toJSON: () => ({})
        })
      };
      window.requestAnimationFrame(() => {
        setContextMenuAnchor(virtualAnchor);
      });
    };
    const hasData = !!data?.length;
    const titleField2 = fields3.find((field) => field.id === view2.titleField);
    const mediaField = fields3.find((field) => field.id === view2.mediaField);
    const descriptionField2 = fields3.find(
      (field) => field.id === view2.descriptionField
    );
    const groupField = view2.groupBy?.field ? fields3.find((f3) => f3.id === view2.groupBy?.field) : null;
    const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
    const { showTitle = true, showMedia = true, showDescription = true } = view2;
    const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
    const columns = view2.fields ?? [];
    const headerMenuRef = (column, index) => (node) => {
      if (node) {
        headerMenuRefs.current.set(column, {
          node,
          fallback: columns[index > 0 ? index - 1 : 1]
        });
      } else {
        headerMenuRefs.current.delete(column);
      }
    };
    const isInfiniteScroll = view2.infiniteScrollEnabled && !dataByGroup;
    const isRtl = (0, import_i18n76.isRTL)();
    if (!hasData) {
      return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
        "div",
        {
          className: clsx_default("dataviews-no-results", {
            "is-refreshing": isDelayedLoading
          }),
          id: tableNoticeId,
          children: empty
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(import_jsx_runtime146.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(
        "table",
        {
          className: clsx_default("dataviews-view-table", className, {
            [`has-${view2.layout?.density}-density`]: view2.layout?.density && ["compact", "comfortable"].includes(
              view2.layout.density
            ),
            "has-bulk-actions": hasBulkActions,
            "is-refreshing": !isInfiniteScroll && isDelayedLoading
          }),
          "aria-busy": isLoading,
          "aria-describedby": tableNoticeId,
          role: isInfiniteScroll ? "feed" : void 0,
          inert: !isInfiniteScroll && isLoading ? "true" : void 0,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)("colgroup", { children: [
              hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
              hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
              columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
                "col",
                {
                  className: clsx_default(
                    `dataviews-view-table__col-${column}`,
                    {
                      "dataviews-view-table__col-expand": !hasPrimaryColumn && index === columns.length - 1
                    }
                  )
                },
                `col-${column}`
              )),
              !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("col", { className: "dataviews-view-table__col-actions" })
            ] }),
            contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
              import_components34.Popover,
              {
                anchor: contextMenuAnchor,
                onClose: () => setContextMenuAnchor(null),
                placement: "bottom-start",
                children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(PropertiesSection, { showLabel: false })
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
              "thead",
              {
                className: clsx_default({
                  "dataviews-view-table__thead--stuck": isVerticallyScrolled
                }),
                onContextMenu: handleHeaderContextMenu,
                children: /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)("tr", { className: "dataviews-view-table__row", children: [
                  hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
                    "th",
                    {
                      className: "dataviews-view-table__checkbox-column",
                      scope: "col",
                      onContextMenu: handleHeaderContextMenu,
                      children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
                        BulkSelectionCheckbox,
                        {
                          selection,
                          onChangeSelection,
                          data,
                          actions: actions2,
                          getItemId
                        }
                      )
                    }
                  ),
                  hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("th", { scope: "col", children: titleField2 && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
                    column_header_menu_default,
                    {
                      ref: headerMenuRef(
                        titleField2.id,
                        0
                      ),
                      fieldId: titleField2.id,
                      view: view2,
                      fields: fields3,
                      onChangeView,
                      onHide,
                      setOpenedFilter,
                      canMove: false,
                      canInsertLeft: isRtl ? view2.layout?.enableMoving ?? true : false,
                      canInsertRight: isRtl ? false : view2.layout?.enableMoving ?? true
                    }
                  ) }),
                  columns.map((column, index) => {
                    const { width, maxWidth, minWidth, align } = view2.layout?.styles?.[column] ?? {};
                    const field = fields3.find(
                      (f3) => f3.id === column
                    );
                    const effectiveAlign = getEffectiveAlign(
                      align,
                      field?.type
                    );
                    const canInsertOrMove = view2.layout?.enableMoving ?? true;
                    return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
                      "th",
                      {
                        style: {
                          width,
                          maxWidth,
                          minWidth,
                          textAlign: effectiveAlign
                        },
                        "aria-sort": view2.sort?.direction && view2.sort?.field === column ? sortValues[view2.sort.direction] : void 0,
                        scope: "col",
                        children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
                          column_header_menu_default,
                          {
                            ref: headerMenuRef(column, index),
                            fieldId: column,
                            view: view2,
                            fields: fields3,
                            onChangeView,
                            onHide,
                            setOpenedFilter,
                            canMove: canInsertOrMove,
                            canInsertLeft: canInsertOrMove,
                            canInsertRight: canInsertOrMove
                          }
                        )
                      },
                      column
                    );
                  }),
                  !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
                    "th",
                    {
                      className: clsx_default(
                        "dataviews-view-table__actions-column",
                        {
                          "dataviews-view-table__actions-column--sticky": true,
                          "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
                        }
                      ),
                      children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n76.__)("Actions") })
                    }
                  )
                ] })
              }
            ),
            hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
              ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)("tbody", { children: [
                /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
                  "td",
                  {
                    colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions2?.length ? 1 : 0),
                    className: "dataviews-view-table__group-header-cell",
                    children: view2.groupBy?.showLabel === false ? groupName : (0, import_i18n76.sprintf)(
                      // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
                      (0, import_i18n76.__)("%1$s: %2$s"),
                      groupField.label,
                      groupName
                    )
                  }
                ) }),
                groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
                  TableRow,
                  {
                    item,
                    level: view2.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
                    hasBulkActions,
                    actions: actions2,
                    fields: fields3,
                    id: getItemId(item) || index.toString(),
                    view: view2,
                    titleField: titleField2,
                    mediaField,
                    descriptionField: descriptionField2,
                    selection,
                    getItemId,
                    onChangeSelection,
                    onClickItem,
                    renderItemLink,
                    isItemClickable,
                    isActionsColumnSticky: !isHorizontalScrollEnd
                  },
                  getItemId(item)
                ))
              ] }, `group-${groupName}`)
            ) : /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
              TableRow,
              {
                item,
                level: view2.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
                hasBulkActions,
                actions: actions2,
                fields: fields3,
                id: getItemId(item) || index.toString(),
                view: view2,
                titleField: titleField2,
                mediaField,
                descriptionField: descriptionField2,
                selection,
                getItemId,
                onChangeSelection,
                onClickItem,
                renderItemLink,
                isItemClickable,
                isActionsColumnSticky: !isHorizontalScrollEnd,
                posinset: isInfiniteScroll ? index + 1 : void 0
              },
              getItemId(item)
            )) })
          ]
        }
      ),
      isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(import_components34.Spinner, {}) }) })
    ] });
  }
  var table_default = ViewTable;

  // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
  var import_components37 = __toESM(require_components(), 1);
  var import_i18n79 = __toESM(require_i18n(), 1);

  // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
  var import_components36 = __toESM(require_components(), 1);
  var import_i18n78 = __toESM(require_i18n(), 1);
  var import_compose8 = __toESM(require_compose(), 1);
  var import_keycodes2 = __toESM(require_keycodes(), 1);
  var import_element59 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
  var import_components35 = __toESM(require_components(), 1);
  var import_i18n77 = __toESM(require_i18n(), 1);
  var import_element56 = __toESM(require_element(), 1);
  var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1);
  var imageSizes = [
    {
      value: 120,
      breakpoint: 1
    },
    {
      value: 170,
      breakpoint: 1
    },
    {
      value: 230,
      breakpoint: 1
    },
    {
      value: 290,
      breakpoint: 1112
      // at minimum image width, 4 images display at this container size
    },
    {
      value: 350,
      breakpoint: 1636
      // at minimum image width, 6 images display at this container size
    },
    {
      value: 430,
      breakpoint: 588
      // at minimum image width, 2 images display at this container size
    }
  ];
  var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
  function useGridColumns() {
    const context = (0, import_element56.useContext)(dataviews_context_default);
    const view2 = context.view;
    return (0, import_element56.useMemo)(() => {
      const containerWidth = context.containerWidth;
      const gap = 32;
      const previewSize = view2.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
      const columns = Math.floor(
        (containerWidth + gap) / (previewSize + gap)
      );
      return Math.max(1, columns);
    }, [context.containerWidth, view2.layout?.previewSize]);
  }

  // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
  var import_element57 = __toESM(require_element(), 1);
  var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1);
  var GridItems = (0, import_element57.forwardRef)(({ className, previewSize, ...props }, ref) => {
    return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
      "div",
      {
        ref,
        className: clsx_default("dataviews-view-grid-items", className),
        style: {
          gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
        },
        ...props
      }
    );
  });

  // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
  var import_element58 = __toESM(require_element(), 1);
  function useIntersectionObserver(elementRef, posinset) {
    const { intersectionObserver } = (0, import_element58.useContext)(dataviews_context_default);
    (0, import_element58.useEffect)(() => {
      const element = elementRef.current;
      if (!element || posinset === void 0 || !intersectionObserver) {
        return;
      }
      intersectionObserver.observe(element);
      return () => {
        intersectionObserver.unobserve(element);
      };
    }, [elementRef, intersectionObserver, posinset]);
  }
  function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
    const hasData = !!data?.length;
    const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
    return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
  }

  // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
  var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1);
  var { Badge: WCBadge2 } = unlock3(import_components36.privateApis);
  function chunk(array, size) {
    const chunks = [];
    for (let i3 = 0, j2 = array.length; i3 < j2; i3 += size) {
      chunks.push(array.slice(i3, i3 + size));
    }
    return chunks;
  }
  var GridItem = (0, import_element59.forwardRef)(
    function GridItem2({
      view: view2,
      selection,
      onChangeSelection,
      onClickItem,
      isItemClickable,
      renderItemLink,
      getItemId,
      item,
      actions: actions2,
      mediaField,
      titleField: titleField2,
      descriptionField: descriptionField2,
      regularFields,
      badgeFields,
      hasBulkActions,
      config: config2,
      posinset,
      setsize,
      ...props
    }, forwardedRef) {
      const {
        showTitle = true,
        showMedia = true,
        showDescription = true
      } = view2;
      const hasBulkAction = useHasAPossibleBulkAction(actions2, item);
      const id = getItemId(item);
      const elementRef = (0, import_element59.useRef)(null);
      const setRefs = (0, import_element59.useCallback)(
        (node) => {
          elementRef.current = node;
          if (typeof forwardedRef === "function") {
            forwardedRef(node);
          } else if (forwardedRef) {
            forwardedRef.current = node;
          }
        },
        [forwardedRef]
      );
      useIntersectionObserver(elementRef, posinset);
      const instanceId = (0, import_compose8.useInstanceId)(GridItem2);
      const isSelected2 = selection.includes(id);
      const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime149.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
      const rendersMediaField = showMedia && mediaField?.render;
      const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
        mediaField.render,
        {
          item,
          field: mediaField,
          config: config2
        }
      ) : mediaPlaceholder;
      const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(titleField2.render, { item, field: titleField2 }) : null;
      let mediaA11yProps;
      let titleA11yProps;
      if (isItemClickable(item) && onClickItem) {
        if (renderedTitleField) {
          mediaA11yProps = {
            "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
          };
          titleA11yProps = {
            id: `dataviews-view-grid__title-field-${instanceId}`
          };
        } else {
          mediaA11yProps = {
            "aria-label": (0, import_i18n78.__)("Navigate to item")
          };
        }
      }
      return /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(
        Stack,
        {
          direction: "column",
          ...props,
          ref: setRefs,
          "aria-setsize": setsize,
          "aria-posinset": posinset,
          className: clsx_default(
            props.className,
            "dataviews-view-grid__row__gridcell",
            "dataviews-view-grid__card",
            {
              "is-selected": hasBulkAction && isSelected2
            }
          ),
          onClickCapture: (event) => {
            props.onClickCapture?.(event);
            if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
              event.stopPropagation();
              event.preventDefault();
              if (!hasBulkAction) {
                return;
              }
              onChangeSelection(
                isSelected2 ? selection.filter(
                  (itemId) => id !== itemId
                ) : [...selection, id]
              );
            }
          },
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
              ItemClickWrapper,
              {
                item,
                isItemClickable,
                onClickItem,
                renderItemLink,
                className: clsx_default("dataviews-view-grid__media", {
                  "dataviews-view-grid__media--placeholder": !rendersMediaField
                }),
                ...mediaA11yProps,
                children: renderedMediaField
              }
            ),
            hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
              DataViewsSelectionCheckbox,
              {
                item,
                selection,
                onChangeSelection,
                getItemId,
                titleField: titleField2,
                disabled: !hasBulkAction
              }
            ),
            !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
              ItemActions,
              {
                item,
                actions: actions2,
                isCompact: true
              }
            ) }),
            showTitle && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)("div", { className: "dataviews-view-grid__title", children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
              ItemClickWrapper,
              {
                item,
                isItemClickable,
                onClickItem,
                renderItemLink,
                className: "dataviews-view-grid__title-field dataviews-title-field",
                ...titleA11yProps,
                title: titleField2?.getValueFormatted({
                  item,
                  field: titleField2
                }) || void 0,
                children: renderedTitleField
              }
            ) }),
            /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(Stack, { direction: "column", gap: "xs", children: [
              showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                descriptionField2.render,
                {
                  item,
                  field: descriptionField2
                }
              ),
              !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                Stack,
                {
                  direction: "row",
                  className: "dataviews-view-grid__badge-fields",
                  gap: "sm",
                  wrap: "wrap",
                  align: "top",
                  justify: "flex-start",
                  children: badgeFields.map((field) => {
                    return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                      WCBadge2,
                      {
                        className: "dataviews-view-grid__field-value",
                        children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                          field.render,
                          {
                            item,
                            field
                          }
                        )
                      },
                      field.id
                    );
                  })
                }
              ),
              !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                Stack,
                {
                  direction: "column",
                  className: "dataviews-view-grid__fields",
                  gap: "xs",
                  children: regularFields.map((field) => {
                    return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                      import_components36.Flex,
                      {
                        className: "dataviews-view-grid__field",
                        gap: 1,
                        justify: "flex-start",
                        expanded: true,
                        style: { height: "auto" },
                        direction: "row",
                        children: /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(import_jsx_runtime149.Fragment, { children: [
                          /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_components36.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_components36.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }),
                          /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                            import_components36.FlexItem,
                            {
                              className: "dataviews-view-grid__field-value",
                              style: { maxHeight: "none" },
                              children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                                field.render,
                                {
                                  item,
                                  field
                                }
                              )
                            }
                          )
                        ] })
                      },
                      field.id
                    );
                  })
                }
              )
            ] })
          ]
        }
      );
    }
  );
  function CompositeGrid({
    data,
    isInfiniteScroll,
    className,
    inert,
    isLoading,
    view: view2,
    fields: fields3,
    selection,
    onChangeSelection,
    onClickItem,
    isItemClickable,
    renderItemLink,
    getItemId,
    actions: actions2
  }) {
    const { paginationInfo: paginationInfo2, resizeObserverRef } = (0, import_element59.useContext)(dataviews_context_default);
    const gridColumns = useGridColumns();
    const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data);
    const titleField2 = fields3.find(
      (field) => field.id === view2?.titleField
    );
    const mediaField = fields3.find(
      (field) => field.id === view2?.mediaField
    );
    const descriptionField2 = fields3.find(
      (field) => field.id === view2?.descriptionField
    );
    const otherFields = view2.fields ?? [];
    const { regularFields, badgeFields } = otherFields.reduce(
      (accumulator, fieldId) => {
        const field = fields3.find((f3) => f3.id === fieldId);
        if (!field) {
          return accumulator;
        }
        const key = view2.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
        accumulator[key].push(field);
        return accumulator;
      },
      { regularFields: [], badgeFields: [] }
    );
    const size = "900px";
    const totalRows = Math.ceil(data.length / gridColumns);
    const placeholdersNeeded = usePlaceholdersNeeded(
      data,
      isInfiniteScroll,
      gridColumns
    );
    return /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(import_jsx_runtime149.Fragment, {
      // Render infinite scroll layout (no rows, feed semantics)
      children: [
        isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(
          import_components36.Composite,
          {
            render: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
              GridItems,
              {
                className: clsx_default(
                  "dataviews-view-grid-infinite-scroll",
                  className,
                  {
                    [`has-${view2.layout?.density}-density`]: view2.layout?.density && [
                      "compact",
                      "comfortable"
                    ].includes(view2.layout.density)
                  }
                ),
                previewSize: view2.layout?.previewSize,
                "aria-busy": isLoading,
                ref: resizeObserverRef
              }
            ),
            role: "feed",
            focusWrap: true,
            inert,
            children: [
              Array.from({ length: placeholdersNeeded }).map(
                (_, index) => /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                  import_components36.Composite.Item,
                  {
                    render: (props) => /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                      Stack,
                      {
                        ...props,
                        direction: "column",
                        role: "article",
                        className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
                      }
                    ),
                    "aria-hidden": true,
                    tabIndex: -1
                  },
                  `placeholder-${index}`
                )
              ),
              data.map((item) => {
                const itemId = getItemId(item);
                const stablePosition = item.position;
                return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                  import_components36.Composite.Item,
                  {
                    render: (props) => /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                      GridItem,
                      {
                        ...props,
                        id: itemId,
                        role: "article",
                        view: view2,
                        selection,
                        onChangeSelection,
                        onClickItem,
                        isItemClickable,
                        renderItemLink,
                        getItemId,
                        item,
                        actions: actions2,
                        mediaField,
                        titleField: titleField2,
                        descriptionField: descriptionField2,
                        regularFields,
                        badgeFields,
                        hasBulkActions,
                        posinset: stablePosition,
                        setsize: paginationInfo2.totalItems,
                        config: {
                          sizes: size
                        }
                      }
                    )
                  },
                  itemId
                );
              })
            ]
          }
        ),
        // Render standard grid layout (with rows, grid semantics)
        !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
          import_components36.Composite,
          {
            role: "grid",
            className: clsx_default("dataviews-view-grid", className, {
              [`has-${view2.layout?.density}-density`]: view2.layout?.density && ["compact", "comfortable"].includes(
                view2.layout.density
              )
            }),
            focusWrap: true,
            "aria-busy": isLoading,
            "aria-rowcount": totalRows,
            ref: resizeObserverRef,
            inert,
            children: chunk(data, gridColumns).map((row, i3) => /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
              import_components36.Composite.Row,
              {
                render: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                  "div",
                  {
                    role: "row",
                    "aria-rowindex": i3 + 1,
                    "aria-label": (0, import_i18n78.sprintf)(
                      /* translators: %d: The row number in the grid */
                      (0, import_i18n78.__)("Row %d"),
                      i3 + 1
                    ),
                    className: "dataviews-view-grid__row",
                    style: {
                      gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
                    }
                  }
                ),
                children: row.map((item) => {
                  const itemId = getItemId(item);
                  return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                    import_components36.Composite.Item,
                    {
                      render: (props) => /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
                        GridItem,
                        {
                          ...props,
                          id: itemId,
                          role: "gridcell",
                          view: view2,
                          selection,
                          onChangeSelection,
                          onClickItem,
                          isItemClickable,
                          renderItemLink,
                          getItemId,
                          item,
                          actions: actions2,
                          mediaField,
                          titleField: titleField2,
                          descriptionField: descriptionField2,
                          regularFields,
                          badgeFields,
                          hasBulkActions,
                          config: {
                            sizes: size
                          }
                        }
                      )
                    },
                    itemId
                  );
                })
              },
              i3
            ))
          }
        )
      ]
    });
  }

  // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
  var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1);
  function ViewGrid({
    actions: actions2,
    data,
    fields: fields3,
    getItemId,
    isLoading,
    onChangeSelection,
    onClickItem,
    isItemClickable,
    renderItemLink,
    selection,
    view: view2,
    className,
    empty
  }) {
    const isDelayedLoading = useDelayedLoading(!!isLoading);
    const hasData = !!data?.length;
    const groupField = view2.groupBy?.field ? fields3.find((f3) => f3.id === view2.groupBy?.field) : null;
    const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
    const isInfiniteScroll = view2.infiniteScrollEnabled && !dataByGroup;
    if (!hasData) {
      return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
        "div",
        {
          className: clsx_default("dataviews-no-results", {
            "is-refreshing": isDelayedLoading
          }),
          children: empty
        }
      );
    }
    const gridProps = {
      className: clsx_default(className, {
        "is-refreshing": !isInfiniteScroll && isDelayedLoading
      }),
      inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
      isLoading,
      view: view2,
      fields: fields3,
      selection,
      onChangeSelection,
      onClickItem,
      isItemClickable,
      renderItemLink,
      getItemId,
      actions: actions2
    };
    return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_jsx_runtime150.Fragment, {
      // Render multiple groups.
      children: [
        hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
          ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
            Stack,
            {
              direction: "column",
              gap: "sm",
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view2.groupBy?.showLabel === false ? groupName : (0, import_i18n79.sprintf)(
                  // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
                  (0, import_i18n79.__)("%1$s: %2$s"),
                  groupField.label,
                  groupName
                ) }),
                /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
                  CompositeGrid,
                  {
                    ...gridProps,
                    data: groupItems,
                    isInfiniteScroll: false
                  }
                )
              ]
            },
            groupName
          )
        ) }),
        // Render a single grid with all data.
        !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
          CompositeGrid,
          {
            ...gridProps,
            data,
            isInfiniteScroll: !!isInfiniteScroll
          }
        ),
        isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_components37.Spinner, {}) })
      ]
    });
  }
  var grid_default = ViewGrid;

  // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
  var import_compose9 = __toESM(require_compose(), 1);
  var import_components38 = __toESM(require_components(), 1);
  var import_element60 = __toESM(require_element(), 1);
  var import_i18n80 = __toESM(require_i18n(), 1);
  var import_data30 = __toESM(require_data(), 1);
  var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1);
  var { Menu: Menu3 } = unlock3(import_components38.privateApis);
  function generateItemWrapperCompositeId(idPrefix) {
    return `${idPrefix}-item-wrapper`;
  }
  function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
    return `${idPrefix}-primary-action-${primaryActionId}`;
  }
  function generateDropdownTriggerCompositeId(idPrefix) {
    return `${idPrefix}-dropdown`;
  }
  function PrimaryActionGridCell({
    idPrefix,
    primaryAction,
    item
  }) {
    const registry = (0, import_data30.useRegistry)();
    const [isModalOpen, setIsModalOpen] = (0, import_element60.useState)(false);
    const compositeItemId = generatePrimaryActionCompositeId(
      idPrefix,
      primaryAction.id
    );
    const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
    return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
      import_components38.Composite.Item,
      {
        id: compositeItemId,
        render: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
          import_components38.Button,
          {
            disabled: !!primaryAction.disabled,
            accessibleWhenDisabled: true,
            text: label,
            size: "small",
            onClick: () => setIsModalOpen(true)
          }
        ),
        children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
          ActionModal,
          {
            action: primaryAction,
            items: [item],
            closeModal: () => setIsModalOpen(false)
          }
        )
      }
    ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
      import_components38.Composite.Item,
      {
        id: compositeItemId,
        render: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
          import_components38.Button,
          {
            disabled: !!primaryAction.disabled,
            accessibleWhenDisabled: true,
            size: "small",
            onClick: () => {
              primaryAction.callback([item], { registry });
            },
            children: label
          }
        )
      }
    ) }, primaryAction.id);
  }
  function ListItem({
    view: view2,
    actions: actions2,
    idPrefix,
    isSelected: isSelected2,
    item,
    titleField: titleField2,
    mediaField,
    descriptionField: descriptionField2,
    onSelect,
    otherFields,
    onDropdownTriggerKeyDown,
    posinset
  }) {
    const {
      showTitle = true,
      showMedia = true,
      showDescription = true,
      infiniteScrollEnabled
    } = view2;
    const itemRef = (0, import_element60.useRef)(null);
    const labelId = `${idPrefix}-label`;
    const descriptionId = `${idPrefix}-description`;
    const registry = (0, import_data30.useRegistry)();
    const [isHovered, setIsHovered] = (0, import_element60.useState)(false);
    const [activeModalAction, setActiveModalAction] = (0, import_element60.useState)(
      null
    );
    const handleHover = ({ type }) => {
      const isHover = type === "mouseenter";
      setIsHovered(isHover);
    };
    const { paginationInfo: paginationInfo2 } = (0, import_element60.useContext)(dataviews_context_default);
    (0, import_element60.useEffect)(() => {
      if (isSelected2) {
        itemRef.current?.scrollIntoView({
          behavior: "auto",
          block: "nearest",
          inline: "nearest"
        });
      }
    }, [isSelected2]);
    const { primaryAction, eligibleActions } = (0, import_element60.useMemo)(() => {
      const _eligibleActions = actions2.filter(
        (action) => !action.isEligible || action.isEligible(item)
      );
      const _primaryActions = _eligibleActions.filter(
        (action) => action.isPrimary
      );
      return {
        primaryAction: _primaryActions[0],
        eligibleActions: _eligibleActions
      };
    }, [actions2, item]);
    const hasOnlyOnePrimaryAction = primaryAction && actions2.length === 1;
    const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
      mediaField.render,
      {
        item,
        field: mediaField,
        config: { sizes: "52px" }
      }
    ) }) : null;
    const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(titleField2.render, { item, field: titleField2 }) : null;
    const renderDescription = showDescription && descriptionField2?.render;
    const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
    const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
      Stack,
      {
        direction: "row",
        gap: "md",
        className: "dataviews-view-list__item-actions",
        children: [
          primaryAction && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
            PrimaryActionGridCell,
            {
              idPrefix,
              primaryAction,
              item
            }
          ),
          !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("div", { role: "gridcell", children: [
            /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(Menu3, { placement: "bottom-end", children: [
              /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                Menu3.TriggerButton,
                {
                  render: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                    import_components38.Composite.Item,
                    {
                      id: generateDropdownTriggerCompositeId(
                        idPrefix
                      ),
                      render: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                        import_components38.Button,
                        {
                          size: "small",
                          icon: more_vertical_default,
                          label: (0, import_i18n80.__)("Actions"),
                          accessibleWhenDisabled: true,
                          disabled: !actions2.length,
                          onKeyDown: onDropdownTriggerKeyDown
                        }
                      )
                    }
                  )
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                ActionsMenuGroup,
                {
                  actions: eligibleActions,
                  item,
                  registry,
                  setActiveModalAction
                }
              ) })
            ] }),
            !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
              ActionModal,
              {
                action: activeModalAction,
                items: [item],
                closeModal: () => setActiveModalAction(null)
              }
            )
          ] })
        ]
      }
    );
    return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
      import_components38.Composite.Row,
      {
        ref: itemRef,
        render: (
          /* aria-posinset breaks Composite.Row if passed to it directly. */
          /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
            "div",
            {
              "aria-posinset": posinset,
              "aria-setsize": infiniteScrollEnabled ? paginationInfo2.totalItems : void 0
            }
          )
        ),
        role: infiniteScrollEnabled ? "article" : "row",
        className: clsx_default({
          "is-selected": isSelected2,
          "is-hovered": isHovered
        }),
        onMouseEnter: handleHover,
        onMouseLeave: handleHover,
        children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
          Stack,
          {
            direction: "row",
            className: "dataviews-view-list__item-wrapper",
            children: [
              /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                import_components38.Composite.Item,
                {
                  id: generateItemWrapperCompositeId(idPrefix),
                  "aria-pressed": isSelected2,
                  "aria-labelledby": labelId,
                  "aria-describedby": descriptionId,
                  className: "dataviews-view-list__item",
                  onClick: () => onSelect(item)
                }
              ) }),
              /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
                Stack,
                {
                  direction: "row",
                  gap: "md",
                  justify: "start",
                  align: hasOnlyMediaAndTitle ? "center" : "flex-start",
                  style: { flex: 1, minWidth: 0 },
                  children: [
                    renderedMediaField,
                    /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
                      Stack,
                      {
                        direction: "column",
                        gap: "xs",
                        className: "dataviews-view-list__field-wrapper",
                        children: [
                          /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(Stack, { direction: "row", align: "center", children: [
                            /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                              "div",
                              {
                                className: "dataviews-title-field dataviews-view-list__title-field",
                                id: labelId,
                                children: renderedTitleField
                              }
                            ),
                            usedActions
                          ] }),
                          renderDescription && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                            descriptionField2.render,
                            {
                              item,
                              field: descriptionField2
                            }
                          ) }),
                          /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                            "div",
                            {
                              className: "dataviews-view-list__fields",
                              id: descriptionId,
                              children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
                                "div",
                                {
                                  className: "dataviews-view-list__field",
                                  children: [
                                    /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                                      VisuallyHidden,
                                      {
                                        className: "dataviews-view-list__field-label",
                                        render: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("span", {}),
                                        children: field.label
                                      }
                                    ),
                                    /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                                      field.render,
                                      {
                                        item,
                                        field
                                      }
                                    ) })
                                  ]
                                },
                                field.id
                              ))
                            }
                          )
                        ]
                      }
                    )
                  ]
                }
              )
            ]
          }
        )
      }
    );
  }
  function isDefined2(item) {
    return !!item;
  }
  function ViewList(props) {
    const {
      actions: actions2,
      data,
      fields: fields3,
      getItemId,
      isLoading,
      onChangeSelection,
      selection,
      view: view2,
      className,
      empty
    } = props;
    const baseId = (0, import_compose9.useInstanceId)(ViewList, "view-list");
    const isDelayedLoading = useDelayedLoading(!!isLoading);
    const selectedItem = data?.findLast(
      (item) => selection.includes(getItemId(item))
    );
    const titleField2 = fields3.find((field) => field.id === view2.titleField);
    const mediaField = fields3.find((field) => field.id === view2.mediaField);
    const descriptionField2 = fields3.find(
      (field) => field.id === view2.descriptionField
    );
    const otherFields = (view2?.fields ?? []).map((fieldId) => fields3.find((f3) => fieldId === f3.id)).filter(isDefined2);
    const onSelect = (item) => onChangeSelection([getItemId(item)]);
    const generateCompositeItemIdPrefix = (0, import_element60.useCallback)(
      (item) => `${baseId}-${getItemId(item)}`,
      [baseId, getItemId]
    );
    const isActiveCompositeItem = (0, import_element60.useCallback)(
      (item, idToCheck) => {
        return idToCheck.startsWith(
          generateCompositeItemIdPrefix(item)
        );
      },
      [generateCompositeItemIdPrefix]
    );
    const [activeCompositeId, setActiveCompositeId] = (0, import_element60.useState)(void 0);
    const compositeRef = (0, import_element60.useRef)(null);
    (0, import_element60.useEffect)(() => {
      if (selectedItem) {
        setActiveCompositeId(
          generateItemWrapperCompositeId(
            generateCompositeItemIdPrefix(selectedItem)
          )
        );
      }
    }, [selectedItem, generateCompositeItemIdPrefix]);
    const activeItemIndex = data.findIndex(
      (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
    );
    const previousActiveItemIndex = (0, import_compose9.usePrevious)(activeItemIndex);
    const isActiveIdInList = activeItemIndex !== -1;
    const selectCompositeItem = (0, import_element60.useCallback)(
      (targetIndex, generateCompositeId) => {
        const clampedIndex = Math.min(
          data.length - 1,
          Math.max(0, targetIndex)
        );
        if (!data[clampedIndex]) {
          return;
        }
        const itemIdPrefix = generateCompositeItemIdPrefix(
          data[clampedIndex]
        );
        const targetCompositeItemId = generateCompositeId(itemIdPrefix);
        setActiveCompositeId(targetCompositeItemId);
        if (compositeRef.current?.contains(
          compositeRef.current.ownerDocument.activeElement
        )) {
          document.getElementById(targetCompositeItemId)?.focus();
        }
      },
      [data, generateCompositeItemIdPrefix]
    );
    (0, import_element60.useEffect)(() => {
      const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
      if (!isActiveIdInList && wasActiveIdInList) {
        selectCompositeItem(
          previousActiveItemIndex,
          generateItemWrapperCompositeId
        );
      }
    }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
    const onDropdownTriggerKeyDown = (0, import_element60.useCallback)(
      (event) => {
        if (event.key === "ArrowDown") {
          event.preventDefault();
          selectCompositeItem(
            activeItemIndex + 1,
            generateDropdownTriggerCompositeId
          );
        }
        if (event.key === "ArrowUp") {
          event.preventDefault();
          selectCompositeItem(
            activeItemIndex - 1,
            generateDropdownTriggerCompositeId
          );
        }
      },
      [selectCompositeItem, activeItemIndex]
    );
    const hasData = !!data?.length;
    const groupField = view2.groupBy?.field ? fields3.find((field) => field.id === view2.groupBy?.field) : null;
    const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
    const isInfiniteScroll = view2.infiniteScrollEnabled && !dataByGroup;
    if (!hasData) {
      return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
        "div",
        {
          className: clsx_default("dataviews-no-results", {
            "is-refreshing": isDelayedLoading
          }),
          children: empty
        }
      );
    }
    if (hasData && groupField && dataByGroup) {
      return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
        import_components38.Composite,
        {
          ref: compositeRef,
          id: `${baseId}`,
          render: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", {}),
          className: "dataviews-view-list__group",
          role: "grid",
          activeId: activeCompositeId,
          setActiveId: setActiveCompositeId,
          children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
            Stack,
            {
              direction: "column",
              gap: "lg",
              className: clsx_default("dataviews-view-list", className),
              children: Array.from(dataByGroup.entries()).map(
                ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
                  Stack,
                  {
                    direction: "column",
                    gap: "sm",
                    children: [
                      /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("h3", { className: "dataviews-view-list__group-header", children: view2.groupBy?.showLabel === false ? groupName : (0, import_i18n80.sprintf)(
                        // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
                        (0, import_i18n80.__)("%1$s: %2$s"),
                        groupField.label,
                        groupName
                      ) }),
                      groupItems.map((item) => {
                        const id = generateCompositeItemIdPrefix(item);
                        return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
                          ListItem,
                          {
                            view: view2,
                            idPrefix: id,
                            actions: actions2,
                            item,
                            isSelected: item === selectedItem,
                            onSelect,
                            mediaField,
                            titleField: titleField2,
                            descriptionField: descriptionField2,
                            otherFields,
                            onDropdownTriggerKeyDown
                          },
                          id
                        );
                      })
                    ]
                  },
                  groupName
                )
              )
            }
          )
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_jsx_runtime151.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
        import_components38.Composite,
        {
          ref: compositeRef,
          id: baseId,
          render: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", {}),
          className: clsx_default("dataviews-view-list", className, {
            [`has-${view2.layout?.density}-density`]: view2.layout?.density && ["compact", "comfortable"].includes(
              view2.layout.density
            ),
            "is-refreshing": !isInfiniteScroll && isDelayedLoading
          }),
          role: view2.infiniteScrollEnabled ? "feed" : "grid",
          activeId: activeCompositeId,
          setActiveId: setActiveCompositeId,
          inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
          children: data.map((item, index) => {
            const id = generateCompositeItemIdPrefix(item);
            return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
              ListItem,
              {
                view: view2,
                idPrefix: id,
                actions: actions2,
                item,
                isSelected: item === selectedItem,
                onSelect,
                mediaField,
                titleField: titleField2,
                descriptionField: descriptionField2,
                otherFields,
                onDropdownTriggerKeyDown,
                posinset: view2.infiniteScrollEnabled ? index + 1 : void 0
              },
              id
            );
          })
        }
      ),
      isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_components38.Spinner, {}) })
    ] });
  }

  // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
  var import_components39 = __toESM(require_components(), 1);

  // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
  var import_i18n81 = __toESM(require_i18n(), 1);
  var import_element61 = __toESM(require_element(), 1);
  var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1);
  function ActivityGroup({
    groupName,
    groupData,
    groupField,
    showLabel = true,
    children
  }) {
    const groupHeader = showLabel ? (0, import_element61.createInterpolateElement)(
      // translators: %s: The label of the field e.g. "Status".
      (0, import_i18n81.sprintf)((0, import_i18n81.__)("%s: <groupName />"), groupField.label).trim(),
      {
        groupName: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
          groupField.render,
          {
            item: groupData[0],
            field: groupField
          }
        )
      }
    ) : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(groupField.render, { item: groupData[0], field: groupField });
    return /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(
      Stack,
      {
        direction: "column",
        className: "dataviews-view-activity__group",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
          children
        ]
      },
      groupName
    );
  }

  // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
  var import_element62 = __toESM(require_element(), 1);
  var import_data31 = __toESM(require_data(), 1);
  var import_compose10 = __toESM(require_compose(), 1);
  var import_jsx_runtime153 = __toESM(require_jsx_runtime(), 1);
  function ActivityItem(props) {
    const {
      view: view2,
      actions: actions2,
      item,
      titleField: titleField2,
      mediaField,
      descriptionField: descriptionField2,
      otherFields,
      posinset,
      onClickItem,
      renderItemLink,
      isItemClickable
    } = props;
    const {
      showTitle = true,
      showMedia = true,
      showDescription = true,
      infiniteScrollEnabled
    } = view2;
    const itemRef = (0, import_element62.useRef)(null);
    const registry = (0, import_data31.useRegistry)();
    const { paginationInfo: paginationInfo2 } = (0, import_element62.useContext)(dataviews_context_default);
    const { primaryActions, eligibleActions } = (0, import_element62.useMemo)(() => {
      const _eligibleActions = actions2.filter(
        (action) => !action.isEligible || action.isEligible(item)
      );
      const _primaryActions = _eligibleActions.filter(
        (action) => action.isPrimary
      );
      return {
        primaryActions: _primaryActions,
        eligibleActions: _eligibleActions
      };
    }, [actions2, item]);
    const isMobileViewport = (0, import_compose10.useViewportMatch)("medium", "<");
    const density = view2.layout?.density ?? "balanced";
    const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
      mediaField.render,
      {
        item,
        field: mediaField,
        config: {
          sizes: density === "comfortable" ? "32px" : "24px"
        }
      }
    ) : null;
    const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
      "span",
      {
        className: "dataviews-view-activity__item-bullet",
        "aria-hidden": "true"
      }
    ) });
    const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(titleField2.render, { item, field: titleField2 }) : null;
    const verticalGap = (0, import_element62.useMemo)(() => {
      switch (density) {
        case "comfortable":
          return "md";
        default:
          return "sm";
      }
    }, [density]);
    return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
      "div",
      {
        ref: itemRef,
        role: infiniteScrollEnabled ? "article" : void 0,
        "aria-posinset": posinset,
        "aria-setsize": infiniteScrollEnabled ? paginationInfo2.totalItems : void 0,
        className: clsx_default(
          "dataviews-view-activity__item",
          density === "compact" && "is-compact",
          density === "balanced" && "is-balanced",
          density === "comfortable" && "is-comfortable"
        ),
        children: /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
          /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
            Stack,
            {
              direction: "column",
              gap: "xs",
              align: "center",
              className: "dataviews-view-activity__item-type",
              children: renderedMediaField
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
            Stack,
            {
              direction: "column",
              gap: verticalGap,
              align: "flex-start",
              className: "dataviews-view-activity__item-content",
              children: [
                renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
                  ItemClickWrapper,
                  {
                    item,
                    isItemClickable,
                    onClickItem,
                    renderItemLink,
                    className: "dataviews-view-activity__item-title",
                    children: renderedTitleField
                  }
                ),
                showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
                  descriptionField2.render,
                  {
                    item,
                    field: descriptionField2
                  }
                ) }),
                /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
                  "div",
                  {
                    className: "dataviews-view-activity__item-field",
                    children: [
                      /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
                        VisuallyHidden,
                        {
                          className: "dataviews-view-activity__item-field-label",
                          render: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("span", {}),
                          children: field.label
                        }
                      ),
                      /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
                        field.render,
                        {
                          item,
                          field
                        }
                      ) })
                    ]
                  },
                  field.id
                )) }),
                !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
                  PrimaryActions,
                  {
                    item,
                    actions: primaryActions,
                    registry,
                    buttonVariant: "secondary"
                  }
                )
              ]
            }
          ),
          (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
          // there if there are any actions at all.
          isMobileViewport && // At the same time, only show the menu if there are actions to show.
          eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
            ItemActions,
            {
              item,
              actions: eligibleActions,
              isCompact: true
            }
          ) })
        ] })
      }
    );
  }
  var activity_item_default = ActivityItem;

  // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
  var import_react12 = __toESM(require_react(), 1);
  function isDefined3(item) {
    return !!item;
  }
  function ActivityItems(props) {
    const { data, fields: fields3, getItemId, view: view2 } = props;
    const titleField2 = fields3.find((field) => field.id === view2.titleField);
    const mediaField = fields3.find((field) => field.id === view2.mediaField);
    const descriptionField2 = fields3.find(
      (field) => field.id === view2.descriptionField
    );
    const otherFields = (view2?.fields ?? []).map((fieldId) => fields3.find((f3) => fieldId === f3.id)).filter(isDefined3);
    return data.map((item, index) => {
      return /* @__PURE__ */ (0, import_react12.createElement)(
        activity_item_default,
        {
          ...props,
          key: getItemId(item),
          item,
          mediaField,
          titleField: titleField2,
          descriptionField: descriptionField2,
          otherFields,
          posinset: view2.infiniteScrollEnabled ? index + 1 : void 0
        }
      );
    });
  }

  // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
  var import_jsx_runtime154 = __toESM(require_jsx_runtime(), 1);
  function ViewActivity(props) {
    const { empty, data, fields: fields3, isLoading, view: view2, className } = props;
    const isDelayedLoading = useDelayedLoading(!!isLoading);
    const hasData = !!data?.length;
    const groupField = view2.groupBy?.field ? fields3.find((field) => field.id === view2.groupBy?.field) : null;
    const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
    const isInfiniteScroll = view2.infiniteScrollEnabled && !dataByGroup;
    if (!hasData) {
      return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
        "div",
        {
          className: clsx_default("dataviews-no-results", {
            "is-refreshing": isDelayedLoading
          }),
          children: empty
        }
      );
    }
    const isInert = !isInfiniteScroll && !!isLoading;
    const wrapperClassName = clsx_default("dataviews-view-activity", className, {
      "is-refreshing": !isInfiniteScroll && isDelayedLoading
    });
    const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
    if (hasData && groupField && dataByGroup) {
      return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
        Stack,
        {
          direction: "column",
          gap: "sm",
          className: wrapperClassName,
          inert: isInert ? "true" : void 0,
          children: groupedEntries.map(
            ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
              ActivityGroup,
              {
                groupName,
                groupData,
                groupField,
                showLabel: view2.groupBy?.showLabel !== false,
                children: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
                  ActivityItems,
                  {
                    ...props,
                    data: groupData
                  }
                )
              },
              groupName
            )
          )
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_jsx_runtime154.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
        "div",
        {
          className: wrapperClassName,
          role: view2.infiniteScrollEnabled ? "feed" : void 0,
          inert: isInert ? "true" : void 0,
          children: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(ActivityItems, { ...props })
        }
      ),
      isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(import_components39.Spinner, {}) })
    ] });
  }

  // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
  var import_components42 = __toESM(require_components(), 1);
  var import_i18n84 = __toESM(require_i18n(), 1);
  var import_compose11 = __toESM(require_compose(), 1);
  var import_element65 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
  var import_components41 = __toESM(require_components(), 1);
  var import_data32 = __toESM(require_data(), 1);
  var import_element64 = __toESM(require_element(), 1);
  var import_i18n83 = __toESM(require_i18n(), 1);

  // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
  var import_components40 = __toESM(require_components(), 1);
  var import_element63 = __toESM(require_element(), 1);
  var import_i18n82 = __toESM(require_i18n(), 1);
  var import_jsx_runtime155 = __toESM(require_jsx_runtime(), 1);
  function DataViewsPagination() {
    const {
      view: view2,
      onChangeView,
      paginationInfo: { totalItems = 0, totalPages }
    } = (0, import_element63.useContext)(dataviews_context_default);
    if (!totalItems || !totalPages || view2.infiniteScrollEnabled) {
      return null;
    }
    const currentPage = view2.page ?? 1;
    const pageSelectOptions = Array.from(Array(totalPages)).map(
      (_, i3) => {
        const page = i3 + 1;
        return {
          value: page.toString(),
          label: page.toString(),
          "aria-label": currentPage === page ? (0, import_i18n82.sprintf)(
            // translators: 1: current page number. 2: total number of pages.
            (0, import_i18n82.__)("Page %1$d of %2$d"),
            currentPage,
            totalPages
          ) : page.toString()
        };
      }
    );
    return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(
      Stack,
      {
        direction: "row",
        className: "dataviews-pagination",
        justify: "end",
        align: "center",
        gap: "xl",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
            Stack,
            {
              direction: "row",
              justify: "flex-start",
              align: "center",
              gap: "xs",
              className: "dataviews-pagination__page-select",
              children: (0, import_element63.createInterpolateElement)(
                (0, import_i18n82.sprintf)(
                  // translators: 1: Current page number, 2: Total number of pages.
                  (0, import_i18n82._x)(
                    "<div>Page</div>%1$s<div>of %2$d</div>",
                    "paging"
                  ),
                  "<CurrentPage />",
                  totalPages
                ),
                {
                  div: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)("div", { "aria-hidden": true }),
                  // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
                  CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
                    import_components40.SelectControl,
                    {
                      "aria-label": (0, import_i18n82.__)("Current page"),
                      value: currentPage.toString(),
                      options: pageSelectOptions,
                      onChange: (newValue) => {
                        onChangeView({
                          ...view2,
                          page: +newValue
                        });
                      },
                      size: "small",
                      variant: "minimal"
                    }
                  )
                }
              )
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
            /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
              import_components40.Button,
              {
                onClick: () => onChangeView({
                  ...view2,
                  page: currentPage - 1
                }),
                disabled: currentPage === 1,
                accessibleWhenDisabled: true,
                label: (0, import_i18n82.__)("Previous page"),
                icon: (0, import_i18n82.isRTL)() ? next_default : previous_default,
                showTooltip: true,
                size: "compact",
                tooltipPosition: "top"
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
              import_components40.Button,
              {
                onClick: () => onChangeView({ ...view2, page: currentPage + 1 }),
                disabled: currentPage >= totalPages,
                accessibleWhenDisabled: true,
                label: (0, import_i18n82.__)("Next page"),
                icon: (0, import_i18n82.isRTL)() ? previous_default : next_default,
                showTooltip: true,
                size: "compact",
                tooltipPosition: "top"
              }
            )
          ] })
        ]
      }
    );
  }
  var dataviews_pagination_default = (0, import_element63.memo)(DataViewsPagination);

  // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
  var import_jsx_runtime156 = __toESM(require_jsx_runtime(), 1);
  function useIsMultiselectPicker(actions2) {
    return (0, import_element64.useMemo)(() => {
      return actions2?.every((action) => action.supportsBulk);
    }, [actions2]);
  }

  // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
  var import_jsx_runtime157 = __toESM(require_jsx_runtime(), 1);
  var { Badge: WCBadge3 } = unlock3(import_components42.privateApis);
  function GridItem3({
    view: view2,
    multiselect,
    selection,
    onChangeSelection,
    getItemId,
    item,
    mediaField,
    titleField: titleField2,
    descriptionField: descriptionField2,
    regularFields,
    badgeFields,
    config: config2,
    posinset,
    setsize
  }) {
    const { showTitle = true, showMedia = true, showDescription = true } = view2;
    const id = getItemId(item);
    const elementRef = (0, import_element65.useRef)(null);
    const isSelected2 = selection.includes(id);
    useIntersectionObserver(elementRef, posinset);
    const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
      mediaField.render,
      {
        item,
        field: mediaField,
        config: config2
      }
    ) : null;
    const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(titleField2.render, { item, field: titleField2 }) : null;
    return /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(
      import_components42.Composite.Item,
      {
        ref: elementRef,
        "aria-label": titleField2 ? titleField2.getValue({ item }) || (0, import_i18n84.__)("(no title)") : void 0,
        render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Stack, { direction: "column", children, ...props }),
        role: "option",
        "aria-posinset": posinset,
        "aria-setsize": setsize,
        className: clsx_default("dataviews-view-picker-grid__card", {
          "is-selected": isSelected2
        }),
        "aria-selected": isSelected2,
        onClick: () => {
          if (isSelected2) {
            onChangeSelection(
              selection.filter((itemId) => id !== itemId)
            );
          } else {
            const newSelection = multiselect ? [...selection, id] : [id];
            onChangeSelection(newSelection);
          }
        },
        children: [
          showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
          showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
            DataViewsSelectionCheckbox,
            {
              item,
              selection,
              onChangeSelection,
              getItemId,
              titleField: titleField2,
              disabled: false,
              "aria-hidden": true,
              tabIndex: -1
            }
          ),
          showTitle && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
            Stack,
            {
              direction: "row",
              justify: "space-between",
              className: "dataviews-view-picker-grid__title-actions",
              children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(Stack, { direction: "column", gap: "xs", children: [
            showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
              descriptionField2.render,
              {
                item,
                field: descriptionField2
              }
            ),
            !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
              Stack,
              {
                direction: "row",
                className: "dataviews-view-picker-grid__badge-fields",
                gap: "sm",
                wrap: "wrap",
                align: "top",
                justify: "flex-start",
                children: badgeFields.map((field) => {
                  return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                    WCBadge3,
                    {
                      className: "dataviews-view-picker-grid__field-value",
                      children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                        field.render,
                        {
                          item,
                          field
                        }
                      )
                    },
                    field.id
                  );
                })
              }
            ),
            !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
              Stack,
              {
                direction: "column",
                className: "dataviews-view-picker-grid__fields",
                gap: "xs",
                children: regularFields.map((field) => {
                  return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                    import_components42.Flex,
                    {
                      className: "dataviews-view-picker-grid__field",
                      gap: 1,
                      justify: "flex-start",
                      expanded: true,
                      style: { height: "auto" },
                      direction: "row",
                      children: /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(import_jsx_runtime157.Fragment, { children: [
                        /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(import_components42.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
                        /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                          import_components42.FlexItem,
                          {
                            className: "dataviews-view-picker-grid__field-value",
                            style: { maxHeight: "none" },
                            children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                              field.render,
                              {
                                item,
                                field
                              }
                            )
                          }
                        )
                      ] })
                    },
                    field.id
                  );
                })
              }
            )
          ] })
        ]
      },
      id
    );
  }
  function GridGroup({
    groupName,
    groupField,
    showLabel = true,
    children
  }) {
    const headerId = (0, import_compose11.useInstanceId)(
      GridGroup,
      "dataviews-view-picker-grid-group__header"
    );
    return /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(
      Stack,
      {
        direction: "column",
        gap: "sm",
        role: "group",
        "aria-labelledby": headerId,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
            "h3",
            {
              className: "dataviews-view-picker-grid-group__header",
              id: headerId,
              children: showLabel ? (0, import_i18n84.sprintf)(
                // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
                (0, import_i18n84.__)("%1$s: %2$s"),
                groupField.label,
                groupName
              ) : groupName
            }
          ),
          children
        ]
      },
      groupName
    );
  }
  function ViewPickerGrid({
    actions: actions2,
    data,
    fields: fields3,
    getItemId,
    isLoading,
    onChangeSelection,
    selection,
    view: view2,
    className,
    empty
  }) {
    const { resizeObserverRef, paginationInfo: paginationInfo2, itemListLabel } = (0, import_element65.useContext)(dataviews_context_default);
    const titleField2 = fields3.find(
      (field) => field.id === view2?.titleField
    );
    const mediaField = fields3.find(
      (field) => field.id === view2?.mediaField
    );
    const descriptionField2 = fields3.find(
      (field) => field.id === view2?.descriptionField
    );
    const otherFields = view2.fields ?? [];
    const { regularFields, badgeFields } = otherFields.reduce(
      (accumulator, fieldId) => {
        const field = fields3.find((f3) => f3.id === fieldId);
        if (!field) {
          return accumulator;
        }
        const key = view2.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
        accumulator[key].push(field);
        return accumulator;
      },
      { regularFields: [], badgeFields: [] }
    );
    const hasData = !!data?.length;
    const usedPreviewSize = view2.layout?.previewSize;
    const isMultiselect = useIsMultiselectPicker(actions2);
    const size = "900px";
    const groupField = view2.groupBy?.field ? fields3.find((f3) => f3.id === view2.groupBy?.field) : null;
    const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
    const isInfiniteScroll = (view2.infiniteScrollEnabled && !dataByGroup) ?? false;
    const currentPage = view2?.page ?? 1;
    const perPage = view2?.perPage ?? 0;
    const setSize = isInfiniteScroll ? paginationInfo2?.totalItems : void 0;
    const gridColumns = useGridColumns();
    const placeholdersNeeded = usePlaceholdersNeeded(
      data,
      isInfiniteScroll,
      gridColumns
    );
    return /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(import_jsx_runtime157.Fragment, {
      // Render multiple groups.
      children: [
        hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
          import_components42.Composite,
          {
            virtualFocus: true,
            orientation: "horizontal",
            role: "listbox",
            "aria-multiselectable": isMultiselect,
            className: clsx_default(
              "dataviews-view-picker-grid",
              className,
              {
                [`has-${view2.layout?.density}-density`]: view2.layout?.density && ["compact", "comfortable"].includes(
                  view2.layout.density
                )
              }
            ),
            "aria-label": itemListLabel,
            render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
              Stack,
              {
                direction: "column",
                gap: "lg",
                children,
                ...props
              }
            ),
            children: Array.from(dataByGroup.entries()).map(
              ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                GridGroup,
                {
                  groupName,
                  groupField,
                  showLabel: view2.groupBy?.showLabel !== false,
                  children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                    GridItems,
                    {
                      previewSize: usedPreviewSize,
                      style: {
                        gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
                      },
                      "aria-busy": isLoading,
                      ref: resizeObserverRef,
                      children: groupItems.map((item) => {
                        const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
                        return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                          GridItem3,
                          {
                            view: view2,
                            multiselect: isMultiselect,
                            selection,
                            onChangeSelection,
                            getItemId,
                            item,
                            mediaField,
                            titleField: titleField2,
                            descriptionField: descriptionField2,
                            regularFields,
                            badgeFields,
                            config: {
                              sizes: size
                            },
                            posinset: posInSet,
                            setsize: setSize
                          },
                          getItemId(item)
                        );
                      })
                    }
                  )
                },
                groupName
              )
            )
          }
        ),
        // Render a single grid with all data.
        hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(
          import_components42.Composite,
          {
            render: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
              GridItems,
              {
                className: clsx_default(
                  "dataviews-view-picker-grid",
                  className,
                  {
                    [`has-${view2.layout?.density}-density`]: view2.layout?.density && [
                      "compact",
                      "comfortable"
                    ].includes(view2.layout.density)
                  }
                ),
                previewSize: usedPreviewSize,
                "aria-busy": isLoading,
                ref: resizeObserverRef
              }
            ),
            virtualFocus: true,
            orientation: "horizontal",
            role: "listbox",
            "aria-multiselectable": isMultiselect,
            "aria-label": itemListLabel,
            children: [
              Array.from({ length: placeholdersNeeded }).map(
                (_, index) => /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                  import_components42.Composite.Item,
                  {
                    render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                      Stack,
                      {
                        direction: "column",
                        children,
                        ...props
                      }
                    ),
                    role: "option",
                    "aria-hidden": true,
                    tabIndex: -1,
                    className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
                  },
                  `placeholder-${index}`
                )
              ),
              data.map((item) => {
                const posinset = item.position;
                return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
                  GridItem3,
                  {
                    view: view2,
                    multiselect: isMultiselect,
                    selection,
                    onChangeSelection,
                    getItemId,
                    item,
                    mediaField,
                    titleField: titleField2,
                    descriptionField: descriptionField2,
                    regularFields,
                    badgeFields,
                    config: {
                      sizes: size
                    },
                    posinset,
                    setsize: setSize
                  },
                  getItemId(item)
                );
              })
            ]
          }
        ),
        // Render empty state.
        !hasData && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
          "div",
          {
            className: clsx_default({
              "dataviews-loading": isLoading,
              "dataviews-no-results": !isLoading
            }),
            children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(import_components42.Spinner, {}) }) : empty
          }
        ),
        hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(import_components42.Spinner, {}) })
      ]
    });
  }
  var picker_grid_default = ViewPickerGrid;

  // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
  var import_i18n85 = __toESM(require_i18n(), 1);
  var import_components43 = __toESM(require_components(), 1);
  var import_element66 = __toESM(require_element(), 1);
  var import_jsx_runtime158 = __toESM(require_jsx_runtime(), 1);
  function TableColumnField2({
    item,
    fields: fields3,
    column,
    align
  }) {
    const field = fields3.find((f3) => f3.id === column);
    if (!field) {
      return null;
    }
    const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
      "dataviews-view-table__cell-align-end": align === "end",
      "dataviews-view-table__cell-align-center": align === "center"
    });
    return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(field.render, { item, field }) });
  }
  function TableRow2({
    item,
    fields: fields3,
    id,
    view: view2,
    titleField: titleField2,
    mediaField,
    descriptionField: descriptionField2,
    selection,
    getItemId,
    onChangeSelection,
    multiselect,
    posinset
  }) {
    const { paginationInfo: paginationInfo2 } = (0, import_element66.useContext)(dataviews_context_default);
    const isSelected2 = selection.includes(id);
    const [isHovered, setIsHovered] = (0, import_element66.useState)(false);
    const elementRef = (0, import_element66.useRef)(null);
    useIntersectionObserver(elementRef, posinset);
    const {
      showTitle = true,
      showMedia = true,
      showDescription = true,
      infiniteScrollEnabled
    } = view2;
    const handleMouseEnter = () => {
      setIsHovered(true);
    };
    const handleMouseLeave = () => {
      setIsHovered(false);
    };
    const columns = view2.fields ?? [];
    const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
    return /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
      import_components43.Composite.Item,
      {
        ref: elementRef,
        render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
          "tr",
          {
            className: clsx_default("dataviews-view-table__row", {
              "is-selected": isSelected2,
              "is-hovered": isHovered
            }),
            onMouseEnter: handleMouseEnter,
            onMouseLeave: handleMouseLeave,
            children,
            ...props
          }
        ),
        "aria-selected": isSelected2,
        "aria-setsize": paginationInfo2.totalItems || void 0,
        "aria-posinset": posinset,
        role: infiniteScrollEnabled ? "article" : "option",
        onClick: () => {
          if (isSelected2) {
            onChangeSelection(
              selection.filter((itemId) => id !== itemId)
            );
          } else {
            const newSelection = multiselect ? [...selection, id] : [id];
            onChangeSelection(newSelection);
          }
        },
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
            "td",
            {
              className: "dataviews-view-table__checkbox-column",
              role: "presentation",
              children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                DataViewsSelectionCheckbox,
                {
                  item,
                  selection,
                  onChangeSelection,
                  getItemId,
                  titleField: titleField2,
                  disabled: false,
                  "aria-hidden": true,
                  tabIndex: -1
                }
              ) })
            }
          ),
          hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
            "td",
            {
              role: "presentation",
              children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                column_primary_default,
                {
                  item,
                  titleField: showTitle ? titleField2 : void 0,
                  mediaField: showMedia ? mediaField : void 0,
                  descriptionField: showDescription ? descriptionField2 : void 0,
                  isItemClickable: () => false
                }
              )
            }
          ),
          columns.map((column) => {
            const { width, maxWidth, minWidth, align } = view2.layout?.styles?.[column] ?? {};
            return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
              "td",
              {
                style: {
                  width,
                  maxWidth,
                  minWidth
                },
                role: "presentation",
                children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                  TableColumnField2,
                  {
                    fields: fields3,
                    item,
                    column,
                    align
                  }
                )
              },
              column
            );
          })
        ]
      },
      id
    );
  }
  function ViewPickerTable({
    actions: actions2,
    data,
    fields: fields3,
    getItemId,
    isLoading = false,
    onChangeView,
    onChangeSelection,
    selection,
    setOpenedFilter,
    view: view2,
    className,
    empty
  }) {
    const headerMenuRefs = (0, import_element66.useRef)(/* @__PURE__ */ new Map());
    const headerMenuToFocusRef = (0, import_element66.useRef)(void 0);
    const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element66.useState)();
    const isMultiselect = useIsMultiselectPicker(actions2) ?? false;
    (0, import_element66.useEffect)(() => {
      if (headerMenuToFocusRef.current) {
        headerMenuToFocusRef.current.focus();
        headerMenuToFocusRef.current = void 0;
      }
    });
    const groupField = view2.groupBy?.field ? fields3.find((f3) => f3.id === view2.groupBy?.field) : null;
    const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
    const isInfiniteScroll = view2.infiniteScrollEnabled && !dataByGroup;
    const tableNoticeId = (0, import_element66.useId)();
    if (nextHeaderMenuToFocus) {
      headerMenuToFocusRef.current = nextHeaderMenuToFocus;
      setNextHeaderMenuToFocus(void 0);
      return;
    }
    const onHide = (field) => {
      const hidden = headerMenuRefs.current.get(field.id);
      const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
      setNextHeaderMenuToFocus(fallback?.node);
    };
    const hasData = !!data?.length;
    const titleField2 = fields3.find((field) => field.id === view2.titleField);
    const mediaField = fields3.find((field) => field.id === view2.mediaField);
    const descriptionField2 = fields3.find(
      (field) => field.id === view2.descriptionField
    );
    const { showTitle = true, showMedia = true, showDescription = true } = view2;
    const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
    const columns = view2.fields ?? [];
    const headerMenuRef = (column, index) => (node) => {
      if (node) {
        headerMenuRefs.current.set(column, {
          node,
          fallback: columns[index > 0 ? index - 1 : 1]
        });
      } else {
        headerMenuRefs.current.delete(column);
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_jsx_runtime158.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
        "table",
        {
          className: clsx_default(
            "dataviews-view-table",
            "dataviews-view-picker-table",
            className,
            {
              [`has-${view2.layout?.density}-density`]: view2.layout?.density && ["compact", "comfortable"].includes(
                view2.layout.density
              )
            }
          ),
          "aria-busy": isLoading,
          "aria-describedby": tableNoticeId,
          role: isInfiniteScroll ? "feed" : "listbox",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
              "tr",
              {
                className: "dataviews-view-table__row",
                role: "presentation",
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                    BulkSelectionCheckbox,
                    {
                      selection,
                      onChangeSelection,
                      data,
                      actions: actions2,
                      getItemId,
                      disableSelectAll: isInfiniteScroll
                    }
                  ) }),
                  hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("th", { children: titleField2 && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                    column_header_menu_default,
                    {
                      ref: headerMenuRef(
                        titleField2.id,
                        0
                      ),
                      fieldId: titleField2.id,
                      view: view2,
                      fields: fields3,
                      onChangeView,
                      onHide,
                      setOpenedFilter,
                      canMove: false
                    }
                  ) }),
                  columns.map((column, index) => {
                    const { width, maxWidth, minWidth, align } = view2.layout?.styles?.[column] ?? {};
                    return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                      "th",
                      {
                        style: {
                          width,
                          maxWidth,
                          minWidth,
                          textAlign: align
                        },
                        "aria-sort": view2.sort?.direction && view2.sort?.field === column ? sortValues[view2.sort.direction] : void 0,
                        scope: "col",
                        children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                          column_header_menu_default,
                          {
                            ref: headerMenuRef(column, index),
                            fieldId: column,
                            view: view2,
                            fields: fields3,
                            onChangeView,
                            onHide,
                            setOpenedFilter,
                            canMove: view2.layout?.enableMoving ?? true
                          }
                        )
                      },
                      column
                    );
                  })
                ]
              }
            ) }),
            hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
              ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
                import_components43.Composite,
                {
                  virtualFocus: true,
                  orientation: "vertical",
                  render: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("tbody", { role: "group" }),
                  children: [
                    /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                      "tr",
                      {
                        className: "dataviews-view-table__group-header-row",
                        role: "presentation",
                        children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                          "td",
                          {
                            colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
                            className: "dataviews-view-table__group-header-cell",
                            role: "presentation",
                            children: view2.groupBy?.showLabel === false ? groupName : (0, import_i18n85.sprintf)(
                              // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
                              (0, import_i18n85.__)("%1$s: %2$s"),
                              groupField.label,
                              groupName
                            )
                          }
                        )
                      }
                    ),
                    groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                      TableRow2,
                      {
                        item,
                        fields: fields3,
                        id: getItemId(item) || index.toString(),
                        view: view2,
                        titleField: titleField2,
                        mediaField,
                        descriptionField: descriptionField2,
                        selection,
                        getItemId,
                        onChangeSelection,
                        multiselect: isMultiselect
                      },
                      getItemId(item)
                    ))
                  ]
                },
                `group-${groupName}`
              )
            ) : /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
              import_components43.Composite,
              {
                render: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("tbody", { role: "presentation" }),
                virtualFocus: true,
                orientation: "vertical",
                children: hasData && data.map((item, index) => {
                  const itemId = getItemId(item);
                  const posinset = item.position;
                  return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
                    TableRow2,
                    {
                      item,
                      fields: fields3,
                      id: itemId || index.toString(),
                      view: view2,
                      titleField: titleField2,
                      mediaField,
                      descriptionField: descriptionField2,
                      selection,
                      getItemId,
                      onChangeSelection,
                      multiselect: isMultiselect,
                      posinset
                    },
                    itemId
                  );
                })
              }
            )
          ]
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
        "div",
        {
          className: clsx_default({
            "dataviews-loading": isLoading,
            "dataviews-no-results": !hasData && !isLoading
          }),
          id: tableNoticeId,
          children: [
            !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components43.Spinner, {}) }) : empty),
            hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components43.Spinner, {}) })
          ]
        }
      )
    ] });
  }
  var picker_table_default = ViewPickerTable;

  // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
  var import_components44 = __toESM(require_components(), 1);
  var import_i18n86 = __toESM(require_i18n(), 1);
  var import_element67 = __toESM(require_element(), 1);
  var import_jsx_runtime159 = __toESM(require_jsx_runtime(), 1);
  function DensityPicker() {
    const context = (0, import_element67.useContext)(dataviews_context_default);
    const view2 = context.view;
    return /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(
      import_components44.__experimentalToggleGroupControl,
      {
        size: "__unstable-large",
        label: (0, import_i18n86.__)("Density"),
        value: view2.layout?.density || "balanced",
        onChange: (value) => {
          context.onChangeView({
            ...view2,
            layout: {
              ...view2.layout,
              density: value
            }
          });
        },
        isBlock: true,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
            import_components44.__experimentalToggleGroupControlOption,
            {
              value: "comfortable",
              label: (0, import_i18n86._x)(
                "Comfortable",
                "Density option for DataView layout"
              )
            },
            "comfortable"
          ),
          /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
            import_components44.__experimentalToggleGroupControlOption,
            {
              value: "balanced",
              label: (0, import_i18n86._x)("Balanced", "Density option for DataView layout")
            },
            "balanced"
          ),
          /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
            import_components44.__experimentalToggleGroupControlOption,
            {
              value: "compact",
              label: (0, import_i18n86._x)("Compact", "Density option for DataView layout")
            },
            "compact"
          )
        ]
      }
    );
  }

  // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
  var import_components45 = __toESM(require_components(), 1);
  var import_i18n87 = __toESM(require_i18n(), 1);
  var import_element68 = __toESM(require_element(), 1);
  var import_jsx_runtime160 = __toESM(require_jsx_runtime(), 1);
  var imageSizes2 = [
    {
      value: 120,
      breakpoint: 1
    },
    {
      value: 170,
      breakpoint: 1
    },
    {
      value: 230,
      breakpoint: 1
    },
    {
      value: 290,
      breakpoint: 1112
      // at minimum image width, 4 images display at this container size
    },
    {
      value: 350,
      breakpoint: 1636
      // at minimum image width, 6 images display at this container size
    },
    {
      value: 430,
      breakpoint: 588
      // at minimum image width, 2 images display at this container size
    }
  ];
  function PreviewSizePicker() {
    const context = (0, import_element68.useContext)(dataviews_context_default);
    const view2 = context.view;
    const breakValues = imageSizes2.filter((size) => {
      return context.containerWidth >= size.breakpoint;
    });
    const layoutPreviewSize = view2.layout?.previewSize ?? 230;
    const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a3, b3) => b3.value - a3.value)[0]?.index ?? 0;
    const marks = breakValues.map((size, index) => {
      return {
        value: index
      };
    });
    return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
      import_components45.RangeControl,
      {
        __next40pxDefaultSize: true,
        showTooltip: false,
        label: (0, import_i18n87.__)("Preview size"),
        value: previewSizeToUse,
        min: 0,
        max: breakValues.length - 1,
        withInputField: false,
        onChange: (value = 0) => {
          context.onChangeView({
            ...view2,
            layout: {
              ...view2.layout,
              previewSize: breakValues[value].value
            }
          });
        },
        step: 1,
        marks
      }
    );
  }

  // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
  var import_jsx_runtime161 = __toESM(require_jsx_runtime(), 1);
  function GridConfigOptions() {
    return /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_jsx_runtime161.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(DensityPicker, {}),
      /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(PreviewSizePicker, {})
    ] });
  }

  // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
  var VIEW_LAYOUTS = [
    {
      type: LAYOUT_TABLE,
      label: (0, import_i18n88.__)("Table"),
      component: table_default,
      icon: block_table_default,
      viewConfigOptions: DensityPicker
    },
    {
      type: LAYOUT_GRID,
      label: (0, import_i18n88.__)("Grid"),
      component: grid_default,
      icon: category_default,
      viewConfigOptions: GridConfigOptions
    },
    {
      type: LAYOUT_LIST,
      label: (0, import_i18n88.__)("List"),
      component: ViewList,
      icon: (0, import_i18n88.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
      viewConfigOptions: DensityPicker
    },
    {
      type: LAYOUT_ACTIVITY,
      label: (0, import_i18n88.__)("Activity"),
      component: ViewActivity,
      icon: scheduled_default,
      viewConfigOptions: DensityPicker
    },
    {
      type: LAYOUT_PICKER_GRID,
      label: (0, import_i18n88.__)("Grid"),
      component: picker_grid_default,
      icon: category_default,
      viewConfigOptions: GridConfigOptions,
      isPicker: true
    },
    {
      type: LAYOUT_PICKER_TABLE,
      label: (0, import_i18n88.__)("Table"),
      component: picker_table_default,
      icon: block_table_default,
      viewConfigOptions: DensityPicker,
      isPicker: true
    }
  ];

  // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
  var import_element76 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
  var import_components48 = __toESM(require_components(), 1);
  var import_i18n91 = __toESM(require_i18n(), 1);
  var import_element73 = __toESM(require_element(), 1);

  // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
  function noop3(..._) {
  }
  function applyState(argument, currentValue) {
    if (isUpdater(argument)) {
      const value = isLazyValue(currentValue) ? currentValue() : currentValue;
      return argument(value);
    }
    return argument;
  }
  function isUpdater(argument) {
    return typeof argument === "function";
  }
  function isLazyValue(value) {
    return typeof value === "function";
  }
  function hasOwnProperty(object, prop) {
    if (typeof Object.hasOwn === "function") {
      return Object.hasOwn(object, prop);
    }
    return Object.prototype.hasOwnProperty.call(object, prop);
  }
  function chain(...fns) {
    return (...args) => {
      for (const fn of fns) {
        if (typeof fn === "function") {
          fn(...args);
        }
      }
    };
  }
  function normalizeString(str3) {
    return str3.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
  }
  function omit(object, keys) {
    const result = { ...object };
    for (const key of keys) {
      if (hasOwnProperty(result, key)) {
        delete result[key];
      }
    }
    return result;
  }
  function pick(object, paths) {
    const result = {};
    for (const key of paths) {
      if (hasOwnProperty(object, key)) {
        result[key] = object[key];
      }
    }
    return result;
  }
  function identity(value) {
    return value;
  }
  function invariant(condition, message2) {
    if (condition) return;
    if (typeof message2 !== "string") throw new Error("Invariant failed");
    throw new Error(message2);
  }
  function getKeys(obj) {
    return Object.keys(obj);
  }
  function isFalsyBooleanCallback(booleanOrCallback, ...args) {
    const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
    if (result == null) return false;
    return !result;
  }
  function disabledFromProps(props) {
    return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
  }
  function removeUndefinedValues(obj) {
    const result = {};
    for (const key in obj) {
      if (obj[key] !== void 0) {
        result[key] = obj[key];
      }
    }
    return result;
  }
  function defaultValue(...values) {
    for (const value of values) {
      if (value !== void 0) return value;
    }
    return void 0;
  }

  // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
  var import_react13 = __toESM(require_react(), 1);
  function setRef(ref, value) {
    if (typeof ref === "function") {
      ref(value);
    } else if (ref) {
      ref.current = value;
    }
  }
  function isValidElementWithRef(element) {
    if (!element) return false;
    if (!(0, import_react13.isValidElement)(element)) return false;
    if ("ref" in element.props) return true;
    if ("ref" in element) return true;
    return false;
  }
  function getRefProperty(element) {
    if (!isValidElementWithRef(element)) return null;
    const props = { ...element.props };
    return props.ref || element.ref;
  }
  function mergeProps2(base, overrides) {
    const props = { ...base };
    for (const key in overrides) {
      if (!hasOwnProperty(overrides, key)) continue;
      if (key === "className") {
        const prop = "className";
        props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
        continue;
      }
      if (key === "style") {
        const prop = "style";
        props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
        continue;
      }
      const overrideValue = overrides[key];
      if (typeof overrideValue === "function" && key.startsWith("on")) {
        const baseValue = base[key];
        if (typeof baseValue === "function") {
          props[key] = (...args) => {
            overrideValue(...args);
            baseValue(...args);
          };
          continue;
        }
      }
      props[key] = overrideValue;
    }
    return props;
  }

  // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
  var canUseDOM = checkIsBrowser();
  function checkIsBrowser() {
    var _a;
    return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
  }
  function getDocument(node) {
    if (!node) return document;
    if ("self" in node) return node.document;
    return node.ownerDocument || document;
  }
  function getActiveElement(node, activeDescendant = false) {
    var _a;
    const { activeElement } = getDocument(node);
    if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
      return null;
    }
    if (isFrame(activeElement) && ((_a = activeElement.contentDocument) == null ? void 0 : _a.body)) {
      return getActiveElement(
        activeElement.contentDocument.body,
        activeDescendant
      );
    }
    if (activeDescendant) {
      const id = activeElement.getAttribute("aria-activedescendant");
      if (id) {
        const element = getDocument(activeElement).getElementById(id);
        if (element) {
          return element;
        }
      }
    }
    return activeElement;
  }
  function contains(parent, child) {
    return parent === child || parent.contains(child);
  }
  function isFrame(element) {
    return element.tagName === "IFRAME";
  }
  function isButton(element) {
    const tagName = element.tagName.toLowerCase();
    if (tagName === "button") return true;
    if (tagName === "input" && element.type) {
      return buttonInputTypes.indexOf(element.type) !== -1;
    }
    return false;
  }
  var buttonInputTypes = [
    "button",
    "color",
    "file",
    "image",
    "reset",
    "submit"
  ];
  function isVisible(element) {
    if (typeof element.checkVisibility === "function") {
      return element.checkVisibility();
    }
    const htmlElement = element;
    return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
  }
  function isTextField(element) {
    try {
      const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
      const isTextArea = element.tagName === "TEXTAREA";
      return isTextInput || isTextArea || false;
    } catch (_error) {
      return false;
    }
  }
  function isTextbox(element) {
    return element.isContentEditable || isTextField(element);
  }
  function getTextboxValue(element) {
    if (isTextField(element)) {
      return element.value;
    }
    if (element.isContentEditable) {
      const range = getDocument(element).createRange();
      range.selectNodeContents(element);
      return range.toString();
    }
    return "";
  }
  function getTextboxSelection(element) {
    let start2 = 0;
    let end = 0;
    if (isTextField(element)) {
      start2 = element.selectionStart || 0;
      end = element.selectionEnd || 0;
    } else if (element.isContentEditable) {
      const selection = getDocument(element).getSelection();
      if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
        const range = selection.getRangeAt(0);
        const nextRange = range.cloneRange();
        nextRange.selectNodeContents(element);
        nextRange.setEnd(range.startContainer, range.startOffset);
        start2 = nextRange.toString().length;
        nextRange.setEnd(range.endContainer, range.endOffset);
        end = nextRange.toString().length;
      }
    }
    return { start: start2, end };
  }
  function getPopupRole(element, fallback) {
    const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
    const role = element == null ? void 0 : element.getAttribute("role");
    if (role && allowedPopupRoles.indexOf(role) !== -1) {
      return role;
    }
    return fallback;
  }
  function getScrollingElement(element) {
    if (!element) return null;
    const isScrollableOverflow = (overflow) => {
      if (overflow === "auto") return true;
      if (overflow === "scroll") return true;
      return false;
    };
    if (element.clientHeight && element.scrollHeight > element.clientHeight) {
      const { overflowY } = getComputedStyle(element);
      if (isScrollableOverflow(overflowY)) return element;
    } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
      const { overflowX } = getComputedStyle(element);
      if (isScrollableOverflow(overflowX)) return element;
    }
    return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
  }
  function setSelectionRange(element, ...args) {
    if (/text|search|password|tel|url/i.test(element.type)) {
      element.setSelectionRange(...args);
    }
  }
  function sortBasedOnDOMPosition(items, getElement) {
    const pairs = items.map((item, index) => [index, item]);
    let isOrderDifferent = false;
    pairs.sort(([indexA, a3], [indexB, b3]) => {
      const elementA = getElement(a3);
      const elementB = getElement(b3);
      if (elementA === elementB) return 0;
      if (!elementA || !elementB) return 0;
      if (isElementPreceding(elementA, elementB)) {
        if (indexA > indexB) {
          isOrderDifferent = true;
        }
        return -1;
      }
      if (indexA < indexB) {
        isOrderDifferent = true;
      }
      return 1;
    });
    if (isOrderDifferent) {
      return pairs.map(([_, item]) => item);
    }
    return items;
  }
  function isElementPreceding(a3, b3) {
    return Boolean(
      b3.compareDocumentPosition(a3) & Node.DOCUMENT_POSITION_PRECEDING
    );
  }

  // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
  function isTouchDevice() {
    return canUseDOM && !!navigator.maxTouchPoints;
  }
  function isApple() {
    if (!canUseDOM) return false;
    return /mac|iphone|ipad|ipod/i.test(navigator.platform);
  }
  function isSafari() {
    return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
  }
  function isFirefox() {
    return canUseDOM && /firefox\//i.test(navigator.userAgent);
  }

  // node_modules/@ariakit/core/esm/utils/events.js
  function isPortalEvent(event) {
    return Boolean(
      event.currentTarget && !contains(event.currentTarget, event.target)
    );
  }
  function isSelfTarget(event) {
    return event.target === event.currentTarget;
  }
  function isOpeningInNewTab(event) {
    const element = event.currentTarget;
    if (!element) return false;
    const isAppleDevice = isApple();
    if (isAppleDevice && !event.metaKey) return false;
    if (!isAppleDevice && !event.ctrlKey) return false;
    const tagName = element.tagName.toLowerCase();
    if (tagName === "a") return true;
    if (tagName === "button" && element.type === "submit") return true;
    if (tagName === "input" && element.type === "submit") return true;
    return false;
  }
  function isDownloading(event) {
    const element = event.currentTarget;
    if (!element) return false;
    const tagName = element.tagName.toLowerCase();
    if (!event.altKey) return false;
    if (tagName === "a") return true;
    if (tagName === "button" && element.type === "submit") return true;
    if (tagName === "input" && element.type === "submit") return true;
    return false;
  }
  function fireBlurEvent(element, eventInit) {
    const event = new FocusEvent("blur", eventInit);
    const defaultAllowed = element.dispatchEvent(event);
    const bubbleInit = { ...eventInit, bubbles: true };
    element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
    return defaultAllowed;
  }
  function fireKeyboardEvent(element, type, eventInit) {
    const event = new KeyboardEvent(type, eventInit);
    return element.dispatchEvent(event);
  }
  function fireClickEvent(element, eventInit) {
    const event = new MouseEvent("click", eventInit);
    return element.dispatchEvent(event);
  }
  function isFocusEventOutside(event, container) {
    const containerElement = container || event.currentTarget;
    const relatedTarget = event.relatedTarget;
    return !relatedTarget || !contains(containerElement, relatedTarget);
  }
  function queueBeforeEvent(element, type, callback, timeout) {
    const createTimer = (callback2) => {
      if (timeout) {
        const timerId2 = setTimeout(callback2, timeout);
        return () => clearTimeout(timerId2);
      }
      const timerId = requestAnimationFrame(callback2);
      return () => cancelAnimationFrame(timerId);
    };
    const cancelTimer = createTimer(() => {
      element.removeEventListener(type, callSync, true);
      callback();
    });
    const callSync = () => {
      cancelTimer();
      callback();
    };
    element.addEventListener(type, callSync, { once: true, capture: true });
    return cancelTimer;
  }
  function addGlobalEventListener(type, listener, options, scope = window) {
    const children = [];
    try {
      scope.document.addEventListener(type, listener, options);
      for (const frame of Array.from(scope.frames)) {
        children.push(addGlobalEventListener(type, listener, options, frame));
      }
    } catch (e3) {
    }
    const removeEventListener = () => {
      try {
        scope.document.removeEventListener(type, listener, options);
      } catch (e3) {
      }
      for (const remove of children) {
        remove();
      }
    };
    return removeEventListener;
  }

  // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
  var React24 = __toESM(require_react(), 1);
  var import_react14 = __toESM(require_react(), 1);
  var _React = { ...React24 };
  var useReactId = _React.useId;
  var useReactDeferredValue = _React.useDeferredValue;
  var useReactInsertionEffect = _React.useInsertionEffect;
  var useSafeLayoutEffect = canUseDOM ? import_react14.useLayoutEffect : import_react14.useEffect;
  function useInitialValue(value) {
    const [initialValue] = (0, import_react14.useState)(value);
    return initialValue;
  }
  function useLiveRef(value) {
    const ref = (0, import_react14.useRef)(value);
    useSafeLayoutEffect(() => {
      ref.current = value;
    });
    return ref;
  }
  function useEvent(callback) {
    const ref = (0, import_react14.useRef)(() => {
      throw new Error("Cannot call an event handler while rendering.");
    });
    if (useReactInsertionEffect) {
      useReactInsertionEffect(() => {
        ref.current = callback;
      });
    } else {
      ref.current = callback;
    }
    return (0, import_react14.useCallback)((...args) => {
      var _a;
      return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
    }, []);
  }
  function useTransactionState(callback) {
    const [state, setState] = (0, import_react14.useState)(null);
    useSafeLayoutEffect(() => {
      if (state == null) return;
      if (!callback) return;
      let prevState = null;
      callback((prev) => {
        prevState = prev;
        return state;
      });
      return () => {
        callback(prevState);
      };
    }, [state, callback]);
    return [state, setState];
  }
  function useMergeRefs(...refs) {
    return (0, import_react14.useMemo)(() => {
      if (!refs.some(Boolean)) return;
      return (value) => {
        for (const ref of refs) {
          setRef(ref, value);
        }
      };
    }, refs);
  }
  function useId5(defaultId) {
    if (useReactId) {
      const reactId = useReactId();
      if (defaultId) return defaultId;
      return reactId;
    }
    const [id, setId] = (0, import_react14.useState)(defaultId);
    useSafeLayoutEffect(() => {
      if (defaultId || id) return;
      const random2 = Math.random().toString(36).slice(2, 8);
      setId(`id-${random2}`);
    }, [defaultId, id]);
    return defaultId || id;
  }
  function useTagName(refOrElement, type) {
    const stringOrUndefined = (type2) => {
      if (typeof type2 !== "string") return;
      return type2;
    };
    const [tagName, setTagName] = (0, import_react14.useState)(() => stringOrUndefined(type));
    useSafeLayoutEffect(() => {
      const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
      setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
    }, [refOrElement, type]);
    return tagName;
  }
  function useAttribute(refOrElement, attributeName, defaultValue2) {
    const initialValue = useInitialValue(defaultValue2);
    const [attribute, setAttribute] = (0, import_react14.useState)(initialValue);
    (0, import_react14.useEffect)(() => {
      const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
      if (!element) return;
      const callback = () => {
        const value = element.getAttribute(attributeName);
        setAttribute(value == null ? initialValue : value);
      };
      const observer = new MutationObserver(callback);
      observer.observe(element, { attributeFilter: [attributeName] });
      callback();
      return () => observer.disconnect();
    }, [refOrElement, attributeName, initialValue]);
    return attribute;
  }
  function useUpdateEffect(effect, deps) {
    const mounted = (0, import_react14.useRef)(false);
    (0, import_react14.useEffect)(() => {
      if (mounted.current) {
        return effect();
      }
      mounted.current = true;
    }, deps);
    (0, import_react14.useEffect)(
      () => () => {
        mounted.current = false;
      },
      []
    );
  }
  function useUpdateLayoutEffect(effect, deps) {
    const mounted = (0, import_react14.useRef)(false);
    useSafeLayoutEffect(() => {
      if (mounted.current) {
        return effect();
      }
      mounted.current = true;
    }, deps);
    useSafeLayoutEffect(
      () => () => {
        mounted.current = false;
      },
      []
    );
  }
  function useForceUpdate2() {
    return (0, import_react14.useReducer)(() => [], []);
  }
  function useBooleanEvent(booleanOrCallback) {
    return useEvent(
      typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
    );
  }
  function useWrapElement(props, callback, deps = []) {
    const wrapElement = (0, import_react14.useCallback)(
      (element) => {
        if (props.wrapElement) {
          element = props.wrapElement(element);
        }
        return callback(element);
      },
      [...deps, props.wrapElement]
    );
    return { ...props, wrapElement };
  }
  function useMetadataProps(props, key, value) {
    const parent = props.onLoadedMetadataCapture;
    const onLoadedMetadataCapture = (0, import_react14.useMemo)(() => {
      return Object.assign(() => {
      }, { ...parent, [key]: value });
    }, [parent, key, value]);
    return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
  }
  var hasInstalledGlobalEventListeners = false;
  function useIsMouseMoving() {
    (0, import_react14.useEffect)(() => {
      if (hasInstalledGlobalEventListeners) return;
      addGlobalEventListener("mousemove", setMouseMoving, true);
      addGlobalEventListener("mousedown", resetMouseMoving, true);
      addGlobalEventListener("mouseup", resetMouseMoving, true);
      addGlobalEventListener("keydown", resetMouseMoving, true);
      addGlobalEventListener("scroll", resetMouseMoving, true);
      hasInstalledGlobalEventListeners = true;
    }, []);
    const isMouseMoving = useEvent(() => mouseMoving);
    return isMouseMoving;
  }
  var mouseMoving = false;
  var previousScreenX = 0;
  var previousScreenY = 0;
  function hasMouseMovement(event) {
    const movementX = event.movementX || event.screenX - previousScreenX;
    const movementY = event.movementY || event.screenY - previousScreenY;
    previousScreenX = event.screenX;
    previousScreenY = event.screenY;
    return movementX || movementY || false;
  }
  function setMouseMoving(event) {
    if (!hasMouseMovement(event)) return;
    mouseMoving = true;
  }
  function resetMouseMoving() {
    mouseMoving = false;
  }

  // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
  var React25 = __toESM(require_react(), 1);
  var import_jsx_runtime162 = __toESM(require_jsx_runtime(), 1);
  function forwardRef27(render4) {
    const Role = React25.forwardRef(
      // @ts-ignore Incompatible with React 19 types. Ignore for now.
      (props, ref) => render4({ ...props, ref })
    );
    Role.displayName = render4.displayName || render4.name;
    return Role;
  }
  function memo22(Component6, propsAreEqual) {
    return React25.memo(Component6, propsAreEqual);
  }
  function createElement5(Type, props) {
    const { wrapElement, render: render4, ...rest } = props;
    const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
    let element;
    if (React25.isValidElement(render4)) {
      const renderProps = {
        // @ts-ignore Incompatible with React 19 types. Ignore for now.
        ...render4.props,
        ref: mergedRef
      };
      element = React25.cloneElement(render4, mergeProps2(rest, renderProps));
    } else if (render4) {
      element = render4(rest);
    } else {
      element = /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Type, { ...rest });
    }
    if (wrapElement) {
      return wrapElement(element);
    }
    return element;
  }
  function createHook(useProps) {
    const useRole = (props = {}) => {
      return useProps(props);
    };
    useRole.displayName = useProps.name;
    return useRole;
  }
  function createStoreContext(providers = [], scopedProviders = []) {
    const context = React25.createContext(void 0);
    const scopedContext = React25.createContext(void 0);
    const useContext210 = () => React25.useContext(context);
    const useScopedContext = (onlyScoped = false) => {
      const scoped = React25.useContext(scopedContext);
      const store4 = useContext210();
      if (onlyScoped) return scoped;
      return scoped || store4;
    };
    const useProviderContext = () => {
      const scoped = React25.useContext(scopedContext);
      const store4 = useContext210();
      if (scoped && scoped === store4) return;
      return store4;
    };
    const ContextProvider = (props) => {
      return providers.reduceRight(
        (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Provider, { ...props, children }),
        /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(context.Provider, { ...props })
      );
    };
    const ScopedContextProvider = (props) => {
      return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
        (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Provider, { ...props, children }),
        /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(scopedContext.Provider, { ...props })
      ) });
    };
    return {
      context,
      scopedContext,
      useContext: useContext210,
      useScopedContext,
      useProviderContext,
      ContextProvider,
      ScopedContextProvider
    };
  }

  // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
  var ctx2 = createStoreContext();
  var useCollectionContext = ctx2.useContext;
  var useCollectionScopedContext = ctx2.useScopedContext;
  var useCollectionProviderContext = ctx2.useProviderContext;
  var CollectionContextProvider = ctx2.ContextProvider;
  var CollectionScopedContextProvider = ctx2.ScopedContextProvider;

  // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
  var import_react15 = __toESM(require_react(), 1);
  var ctx3 = createStoreContext(
    [CollectionContextProvider],
    [CollectionScopedContextProvider]
  );
  var useCompositeContext = ctx3.useContext;
  var useCompositeScopedContext = ctx3.useScopedContext;
  var useCompositeProviderContext = ctx3.useProviderContext;
  var CompositeContextProvider = ctx3.ContextProvider;
  var CompositeScopedContextProvider = ctx3.ScopedContextProvider;
  var CompositeItemContext = (0, import_react15.createContext)(
    void 0
  );
  var CompositeRowContext = (0, import_react15.createContext)(
    void 0
  );

  // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
  function findFirstEnabledItem(items, excludeId) {
    return items.find((item) => {
      if (excludeId) {
        return !item.disabled && item.id !== excludeId;
      }
      return !item.disabled;
    });
  }
  function getEnabledItem(store4, id) {
    if (!id) return null;
    return store4.item(id) || null;
  }
  function groupItemsByRows(items) {
    const rows = [];
    for (const item of items) {
      const row = rows.find((currentRow) => {
        var _a;
        return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
      });
      if (row) {
        row.push(item);
      } else {
        rows.push([item]);
      }
    }
    return rows;
  }
  function selectTextField(element, collapseToEnd = false) {
    if (isTextField(element)) {
      element.setSelectionRange(
        collapseToEnd ? element.value.length : 0,
        element.value.length
      );
    } else if (element.isContentEditable) {
      const selection = getDocument(element).getSelection();
      selection == null ? void 0 : selection.selectAllChildren(element);
      if (collapseToEnd) {
        selection == null ? void 0 : selection.collapseToEnd();
      }
    }
  }
  var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
  function focusSilently(element) {
    element[FOCUS_SILENTLY] = true;
    element.focus({ preventScroll: true });
  }
  function silentlyFocused(element) {
    const isSilentlyFocused = element[FOCUS_SILENTLY];
    delete element[FOCUS_SILENTLY];
    return isSilentlyFocused;
  }
  function isItem(store4, element, exclude) {
    if (!element) return false;
    if (element === exclude) return false;
    const item = store4.item(element.id);
    if (!item) return false;
    if (exclude && item.element === exclude) return false;
    return true;
  }

  // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
  var import_react16 = __toESM(require_react(), 1);
  var TagName = "div";
  var useCollectionItem = createHook(
    function useCollectionItem2({
      store: store4,
      shouldRegisterItem = true,
      getItem = identity,
      // @ts-expect-error This prop may come from a collection renderer.
      element,
      ...props
    }) {
      const context = useCollectionContext();
      store4 = store4 || context;
      const id = useId5(props.id);
      const ref = (0, import_react16.useRef)(element);
      (0, import_react16.useEffect)(() => {
        const element2 = ref.current;
        if (!id) return;
        if (!element2) return;
        if (!shouldRegisterItem) return;
        const item = getItem({ id, element: element2 });
        return store4 == null ? void 0 : store4.renderItem(item);
      }, [id, shouldRegisterItem, getItem, store4]);
      props = {
        ...props,
        ref: useMergeRefs(ref, props.ref)
      };
      return removeUndefinedValues(props);
    }
  );
  var CollectionItem = forwardRef27(function CollectionItem2(props) {
    const htmlProps = useCollectionItem(props);
    return createElement5(TagName, htmlProps);
  });

  // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
  var import_react17 = __toESM(require_react(), 1);
  var FocusableContext = (0, import_react17.createContext)(true);

  // node_modules/@ariakit/core/esm/utils/focus.js
  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'])";
  function isFocusable(element) {
    if (!element.matches(selector)) return false;
    if (!isVisible(element)) return false;
    if (element.closest("[inert]")) return false;
    return true;
  }
  function getClosestFocusable(element) {
    while (element && !isFocusable(element)) {
      element = element.closest(selector);
    }
    return element || null;
  }
  function hasFocus(element) {
    const activeElement = getActiveElement(element);
    if (!activeElement) return false;
    if (activeElement === element) return true;
    const activeDescendant = activeElement.getAttribute("aria-activedescendant");
    if (!activeDescendant) return false;
    return activeDescendant === element.id;
  }
  function hasFocusWithin(element) {
    const activeElement = getActiveElement(element);
    if (!activeElement) return false;
    if (contains(element, activeElement)) return true;
    const activeDescendant = activeElement.getAttribute("aria-activedescendant");
    if (!activeDescendant) return false;
    if (!("id" in element)) return false;
    if (activeDescendant === element.id) return true;
    return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
  }
  function focusIfNeeded(element) {
    if (!hasFocusWithin(element) && isFocusable(element)) {
      element.focus();
    }
  }
  function focusIntoView(element, options) {
    if (!("scrollIntoView" in element)) {
      element.focus();
    } else {
      element.focus({ preventScroll: true });
      element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
    }
  }

  // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
  var import_react18 = __toESM(require_react(), 1);
  var TagName2 = "div";
  var isSafariBrowser = isSafari();
  var alwaysFocusVisibleInputTypes = [
    "text",
    "search",
    "url",
    "tel",
    "email",
    "password",
    "number",
    "date",
    "month",
    "week",
    "time",
    "datetime",
    "datetime-local"
  ];
  var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
  function markSafariFocusAncestor(element, value) {
    if (!element) return;
    element[safariFocusAncestorSymbol] = value;
  }
  function isAlwaysFocusVisible(element) {
    const { tagName, readOnly, type } = element;
    if (tagName === "TEXTAREA" && !readOnly) return true;
    if (tagName === "SELECT" && !readOnly) return true;
    if (tagName === "INPUT" && !readOnly) {
      return alwaysFocusVisibleInputTypes.includes(type);
    }
    if (element.isContentEditable) return true;
    const role = element.getAttribute("role");
    if (role === "combobox" && element.dataset.name) {
      return true;
    }
    return false;
  }
  function getLabels(element) {
    if ("labels" in element) {
      return element.labels;
    }
    return null;
  }
  function isNativeCheckboxOrRadio(element) {
    const tagName = element.tagName.toLowerCase();
    if (tagName === "input" && element.type) {
      return element.type === "radio" || element.type === "checkbox";
    }
    return false;
  }
  function isNativeTabbable(tagName) {
    if (!tagName) return true;
    return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
  }
  function supportsDisabledAttribute(tagName) {
    if (!tagName) return true;
    return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
  }
  function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
    if (!focusable) {
      return tabIndexProp;
    }
    if (trulyDisabled) {
      if (nativeTabbable && !supportsDisabled) {
        return -1;
      }
      return;
    }
    if (nativeTabbable) {
      return tabIndexProp;
    }
    return tabIndexProp || 0;
  }
  function useDisableEvent(onEvent, disabled2) {
    return useEvent((event) => {
      onEvent == null ? void 0 : onEvent(event);
      if (event.defaultPrevented) return;
      if (disabled2) {
        event.stopPropagation();
        event.preventDefault();
      }
    });
  }
  var hasInstalledGlobalEventListeners2 = false;
  var isKeyboardModality = true;
  function onGlobalMouseDown(event) {
    const target = event.target;
    if (target && "hasAttribute" in target) {
      if (!target.hasAttribute("data-focus-visible")) {
        isKeyboardModality = false;
      }
    }
  }
  function onGlobalKeyDown(event) {
    if (event.metaKey) return;
    if (event.ctrlKey) return;
    if (event.altKey) return;
    isKeyboardModality = true;
  }
  var useFocusable = createHook(
    function useFocusable2({
      focusable = true,
      accessibleWhenDisabled,
      autoFocus,
      onFocusVisible,
      ...props
    }) {
      const ref = (0, import_react18.useRef)(null);
      (0, import_react18.useEffect)(() => {
        if (!focusable) return;
        if (hasInstalledGlobalEventListeners2) return;
        addGlobalEventListener("mousedown", onGlobalMouseDown, true);
        addGlobalEventListener("keydown", onGlobalKeyDown, true);
        hasInstalledGlobalEventListeners2 = true;
      }, [focusable]);
      if (isSafariBrowser) {
        (0, import_react18.useEffect)(() => {
          if (!focusable) return;
          const element = ref.current;
          if (!element) return;
          if (!isNativeCheckboxOrRadio(element)) return;
          const labels = getLabels(element);
          if (!labels) return;
          const onMouseUp = () => queueMicrotask(() => element.focus());
          for (const label of labels) {
            label.addEventListener("mouseup", onMouseUp);
          }
          return () => {
            for (const label of labels) {
              label.removeEventListener("mouseup", onMouseUp);
            }
          };
        }, [focusable]);
      }
      const disabled2 = focusable && disabledFromProps(props);
      const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
      const [focusVisible, setFocusVisible] = (0, import_react18.useState)(false);
      (0, import_react18.useEffect)(() => {
        if (!focusable) return;
        if (trulyDisabled && focusVisible) {
          setFocusVisible(false);
        }
      }, [focusable, trulyDisabled, focusVisible]);
      (0, import_react18.useEffect)(() => {
        if (!focusable) return;
        if (!focusVisible) return;
        const element = ref.current;
        if (!element) return;
        if (typeof IntersectionObserver === "undefined") return;
        const observer = new IntersectionObserver(() => {
          if (!isFocusable(element)) {
            setFocusVisible(false);
          }
        });
        observer.observe(element);
        return () => observer.disconnect();
      }, [focusable, focusVisible]);
      const onKeyPressCapture = useDisableEvent(
        props.onKeyPressCapture,
        disabled2
      );
      const onMouseDownCapture = useDisableEvent(
        props.onMouseDownCapture,
        disabled2
      );
      const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
      const onMouseDownProp = props.onMouseDown;
      const onMouseDown = useEvent((event) => {
        onMouseDownProp == null ? void 0 : onMouseDownProp(event);
        if (event.defaultPrevented) return;
        if (!focusable) return;
        const element = event.currentTarget;
        if (!isSafariBrowser) return;
        if (isPortalEvent(event)) return;
        if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
        let receivedFocus = false;
        const onFocus = () => {
          receivedFocus = true;
        };
        const options = { capture: true, once: true };
        element.addEventListener("focusin", onFocus, options);
        const focusableContainer = getClosestFocusable(element.parentElement);
        markSafariFocusAncestor(focusableContainer, true);
        queueBeforeEvent(element, "mouseup", () => {
          element.removeEventListener("focusin", onFocus, true);
          markSafariFocusAncestor(focusableContainer, false);
          if (receivedFocus) return;
          focusIfNeeded(element);
        });
      });
      const handleFocusVisible = (event, currentTarget) => {
        if (currentTarget) {
          event.currentTarget = currentTarget;
        }
        if (!focusable) return;
        const element = event.currentTarget;
        if (!element) return;
        if (!hasFocus(element)) return;
        onFocusVisible == null ? void 0 : onFocusVisible(event);
        if (event.defaultPrevented) return;
        element.dataset.focusVisible = "true";
        setFocusVisible(true);
      };
      const onKeyDownCaptureProp = props.onKeyDownCapture;
      const onKeyDownCapture = useEvent((event) => {
        onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
        if (event.defaultPrevented) return;
        if (!focusable) return;
        if (focusVisible) return;
        if (event.metaKey) return;
        if (event.altKey) return;
        if (event.ctrlKey) return;
        if (!isSelfTarget(event)) return;
        const element = event.currentTarget;
        const applyFocusVisible = () => handleFocusVisible(event, element);
        queueBeforeEvent(element, "focusout", applyFocusVisible);
      });
      const onFocusCaptureProp = props.onFocusCapture;
      const onFocusCapture = useEvent((event) => {
        onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
        if (event.defaultPrevented) return;
        if (!focusable) return;
        if (!isSelfTarget(event)) {
          setFocusVisible(false);
          return;
        }
        const element = event.currentTarget;
        const applyFocusVisible = () => handleFocusVisible(event, element);
        if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
          queueBeforeEvent(event.target, "focusout", applyFocusVisible);
        } else {
          setFocusVisible(false);
        }
      });
      const onBlurProp = props.onBlur;
      const onBlur = useEvent((event) => {
        onBlurProp == null ? void 0 : onBlurProp(event);
        if (!focusable) return;
        if (!isFocusEventOutside(event)) return;
        event.currentTarget.removeAttribute("data-focus-visible");
        setFocusVisible(false);
      });
      const autoFocusOnShow = (0, import_react18.useContext)(FocusableContext);
      const autoFocusRef = useEvent((element) => {
        if (!focusable) return;
        if (!autoFocus) return;
        if (!element) return;
        if (!autoFocusOnShow) return;
        queueMicrotask(() => {
          if (hasFocus(element)) return;
          if (!isFocusable(element)) return;
          element.focus();
        });
      });
      const tagName = useTagName(ref);
      const nativeTabbable = focusable && isNativeTabbable(tagName);
      const supportsDisabled = focusable && supportsDisabledAttribute(tagName);
      const styleProp = props.style;
      const style = (0, import_react18.useMemo)(() => {
        if (trulyDisabled) {
          return { pointerEvents: "none", ...styleProp };
        }
        return styleProp;
      }, [trulyDisabled, styleProp]);
      props = {
        "data-focus-visible": focusable && focusVisible || void 0,
        "data-autofocus": autoFocus || void 0,
        "aria-disabled": disabled2 || void 0,
        ...props,
        ref: useMergeRefs(ref, autoFocusRef, props.ref),
        style,
        tabIndex: getTabIndex(
          focusable,
          trulyDisabled,
          nativeTabbable,
          supportsDisabled,
          props.tabIndex
        ),
        disabled: supportsDisabled && trulyDisabled ? true : void 0,
        // TODO: Test Focusable contentEditable.
        contentEditable: disabled2 ? void 0 : props.contentEditable,
        onKeyPressCapture,
        onClickCapture,
        onMouseDownCapture,
        onMouseDown,
        onKeyDownCapture,
        onFocusCapture,
        onBlur
      };
      return removeUndefinedValues(props);
    }
  );
  var Focusable = forwardRef27(function Focusable2(props) {
    const htmlProps = useFocusable(props);
    return createElement5(TagName2, htmlProps);
  });

  // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
  var import_react19 = __toESM(require_react(), 1);
  var TagName3 = "button";
  function isNativeClick(event) {
    if (!event.isTrusted) return false;
    const element = event.currentTarget;
    if (event.key === "Enter") {
      return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
    }
    if (event.key === " ") {
      return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
    }
    return false;
  }
  var symbol = /* @__PURE__ */ Symbol("command");
  var useCommand = createHook(
    function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
      const ref = (0, import_react19.useRef)(null);
      const [isNativeButton, setIsNativeButton] = (0, import_react19.useState)(false);
      (0, import_react19.useEffect)(() => {
        if (!ref.current) return;
        setIsNativeButton(isButton(ref.current));
      }, []);
      const [active, setActive] = (0, import_react19.useState)(false);
      const activeRef = (0, import_react19.useRef)(false);
      const disabled2 = disabledFromProps(props);
      const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
      const onKeyDownProp = props.onKeyDown;
      const onKeyDown = useEvent((event) => {
        onKeyDownProp == null ? void 0 : onKeyDownProp(event);
        const element = event.currentTarget;
        if (event.defaultPrevented) return;
        if (isDuplicate) return;
        if (disabled2) return;
        if (!isSelfTarget(event)) return;
        if (isTextField(element)) return;
        if (element.isContentEditable) return;
        const isEnter = clickOnEnter && event.key === "Enter";
        const isSpace = clickOnSpace && event.key === " ";
        const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
        const shouldPreventSpace = event.key === " " && !clickOnSpace;
        if (shouldPreventEnter || shouldPreventSpace) {
          event.preventDefault();
          return;
        }
        if (isEnter || isSpace) {
          const nativeClick = isNativeClick(event);
          if (isEnter) {
            if (!nativeClick) {
              event.preventDefault();
              const { view: view2, ...eventInit } = event;
              const click = () => fireClickEvent(element, eventInit);
              if (isFirefox()) {
                queueBeforeEvent(element, "keyup", click);
              } else {
                queueMicrotask(click);
              }
            }
          } else if (isSpace) {
            activeRef.current = true;
            if (!nativeClick) {
              event.preventDefault();
              setActive(true);
            }
          }
        }
      });
      const onKeyUpProp = props.onKeyUp;
      const onKeyUp = useEvent((event) => {
        onKeyUpProp == null ? void 0 : onKeyUpProp(event);
        if (event.defaultPrevented) return;
        if (isDuplicate) return;
        if (disabled2) return;
        if (event.metaKey) return;
        const isSpace = clickOnSpace && event.key === " ";
        if (activeRef.current && isSpace) {
          activeRef.current = false;
          if (!isNativeClick(event)) {
            event.preventDefault();
            setActive(false);
            const element = event.currentTarget;
            const { view: view2, ...eventInit } = event;
            queueMicrotask(() => fireClickEvent(element, eventInit));
          }
        }
      });
      props = {
        "data-active": active || void 0,
        type: isNativeButton ? "button" : void 0,
        ...metadataProps,
        ...props,
        ref: useMergeRefs(ref, props.ref),
        onKeyDown,
        onKeyUp
      };
      props = useFocusable(props);
      return props;
    }
  );
  var Command = forwardRef27(function Command2(props) {
    const htmlProps = useCommand(props);
    return createElement5(TagName3, htmlProps);
  });

  // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
  function getInternal(store4, key) {
    const internals = store4.__unstableInternals;
    invariant(internals, "Invalid store");
    return internals[key];
  }
  function createStore(initialState, ...stores) {
    let state = initialState;
    let prevStateBatch = state;
    let lastUpdate = /* @__PURE__ */ Symbol();
    let destroy = noop3;
    const instances = /* @__PURE__ */ new Set();
    const updatedKeys = /* @__PURE__ */ new Set();
    const setups = /* @__PURE__ */ new Set();
    const listeners = /* @__PURE__ */ new Set();
    const batchListeners = /* @__PURE__ */ new Set();
    const disposables = /* @__PURE__ */ new WeakMap();
    const listenerKeys = /* @__PURE__ */ new WeakMap();
    const storeSetup = (callback) => {
      setups.add(callback);
      return () => setups.delete(callback);
    };
    const storeInit = () => {
      const initialized = instances.size;
      const instance = /* @__PURE__ */ Symbol();
      instances.add(instance);
      const maybeDestroy = () => {
        instances.delete(instance);
        if (instances.size) return;
        destroy();
      };
      if (initialized) return maybeDestroy;
      const desyncs = getKeys(state).map(
        (key) => chain(
          ...stores.map((store4) => {
            var _a;
            const storeState = (_a = store4 == null ? void 0 : store4.getState) == null ? void 0 : _a.call(store4);
            if (!storeState) return;
            if (!hasOwnProperty(storeState, key)) return;
            return sync2(store4, [key], (state2) => {
              setState(
                key,
                state2[key],
                // @ts-expect-error - Not public API. This is just to prevent
                // infinite loops.
                true
              );
            });
          })
        )
      );
      const teardowns = [];
      for (const setup2 of setups) {
        teardowns.push(setup2());
      }
      const cleanups = stores.map(init);
      destroy = chain(...desyncs, ...teardowns, ...cleanups);
      return maybeDestroy;
    };
    const sub3 = (keys, listener, set5 = listeners) => {
      set5.add(listener);
      listenerKeys.set(listener, keys);
      return () => {
        var _a;
        (_a = disposables.get(listener)) == null ? void 0 : _a();
        disposables.delete(listener);
        listenerKeys.delete(listener);
        set5.delete(listener);
      };
    };
    const storeSubscribe = (keys, listener) => sub3(keys, listener);
    const storeSync = (keys, listener) => {
      disposables.set(listener, listener(state, state));
      return sub3(keys, listener);
    };
    const storeBatch = (keys, listener) => {
      disposables.set(listener, listener(state, prevStateBatch));
      return sub3(keys, listener, batchListeners);
    };
    const storePick = (keys) => createStore(pick(state, keys), finalStore);
    const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
    const getState = () => state;
    const setState = (key, value, fromStores = false) => {
      var _a;
      if (!hasOwnProperty(state, key)) return;
      const nextValue = applyState(value, state[key]);
      if (nextValue === state[key]) return;
      if (!fromStores) {
        for (const store4 of stores) {
          (_a = store4 == null ? void 0 : store4.setState) == null ? void 0 : _a.call(store4, key, nextValue);
        }
      }
      const prevState = state;
      state = { ...state, [key]: nextValue };
      const thisUpdate = /* @__PURE__ */ Symbol();
      lastUpdate = thisUpdate;
      updatedKeys.add(key);
      const run = (listener, prev, uKeys) => {
        var _a2;
        const keys = listenerKeys.get(listener);
        const updated = (k2) => uKeys ? uKeys.has(k2) : k2 === key;
        if (!keys || keys.some(updated)) {
          (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
          disposables.set(listener, listener(state, prev));
        }
      };
      for (const listener of listeners) {
        run(listener, prevState);
      }
      queueMicrotask(() => {
        if (lastUpdate !== thisUpdate) return;
        const snapshot = state;
        for (const listener of batchListeners) {
          run(listener, prevStateBatch, updatedKeys);
        }
        prevStateBatch = snapshot;
        updatedKeys.clear();
      });
    };
    const finalStore = {
      getState,
      setState,
      __unstableInternals: {
        setup: storeSetup,
        init: storeInit,
        subscribe: storeSubscribe,
        sync: storeSync,
        batch: storeBatch,
        pick: storePick,
        omit: storeOmit
      }
    };
    return finalStore;
  }
  function setup(store4, ...args) {
    if (!store4) return;
    return getInternal(store4, "setup")(...args);
  }
  function init(store4, ...args) {
    if (!store4) return;
    return getInternal(store4, "init")(...args);
  }
  function subscribe(store4, ...args) {
    if (!store4) return;
    return getInternal(store4, "subscribe")(...args);
  }
  function sync2(store4, ...args) {
    if (!store4) return;
    return getInternal(store4, "sync")(...args);
  }
  function batch(store4, ...args) {
    if (!store4) return;
    return getInternal(store4, "batch")(...args);
  }
  function omit2(store4, ...args) {
    if (!store4) return;
    return getInternal(store4, "omit")(...args);
  }
  function pick2(store4, ...args) {
    if (!store4) return;
    return getInternal(store4, "pick")(...args);
  }
  function mergeStore(...stores) {
    var _a;
    const initialState = {};
    for (const store22 of stores) {
      const nextState = (_a = store22 == null ? void 0 : store22.getState) == null ? void 0 : _a.call(store22);
      if (nextState) {
        Object.assign(initialState, nextState);
      }
    }
    const store4 = createStore(initialState, ...stores);
    return Object.assign({}, ...stores, store4);
  }
  function throwOnConflictingProps(props, store4) {
    if (false) return;
    if (!store4) return;
    const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
      var _a;
      const stateKey = key.replace("default", "");
      return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
    });
    if (!defaultKeys.length) return;
    const storeState = store4.getState();
    const conflictingProps = defaultKeys.filter(
      (key) => hasOwnProperty(storeState, key)
    );
    if (!conflictingProps.length) return;
    throw new Error(
      `Passing a store prop in conjunction with a default state is not supported.

const store = useSelectStore();
<SelectProvider store={store} defaultValue="Apple" />
                ^             ^

Instead, pass the default state to the topmost store:

const store = useSelectStore({ defaultValue: "Apple" });
<SelectProvider store={store} />

See https://github.com/ariakit/ariakit/pull/2745 for more details.

If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
`
    );
  }

  // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
  var React26 = __toESM(require_react(), 1);
  var import_shim = __toESM(require_shim(), 1);
  var { useSyncExternalStore } = import_shim.default;
  var noopSubscribe = () => () => {
  };
  function useStoreState(store4, keyOrSelector = identity) {
    const storeSubscribe = React26.useCallback(
      (callback) => {
        if (!store4) return noopSubscribe();
        return subscribe(store4, null, callback);
      },
      [store4]
    );
    const getSnapshot = () => {
      const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
      const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
      const state = store4 == null ? void 0 : store4.getState();
      if (selector2) return selector2(state);
      if (!state) return;
      if (!key) return;
      if (!hasOwnProperty(state, key)) return;
      return state[key];
    };
    return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
  }
  function useStoreStateObject(store4, object) {
    const objRef = React26.useRef(
      {}
    );
    const storeSubscribe = React26.useCallback(
      (callback) => {
        if (!store4) return noopSubscribe();
        return subscribe(store4, null, callback);
      },
      [store4]
    );
    const getSnapshot = () => {
      const state = store4 == null ? void 0 : store4.getState();
      let updated = false;
      const obj = objRef.current;
      for (const prop in object) {
        const keyOrSelector = object[prop];
        if (typeof keyOrSelector === "function") {
          const value = keyOrSelector(state);
          if (value !== obj[prop]) {
            obj[prop] = value;
            updated = true;
          }
        }
        if (typeof keyOrSelector === "string") {
          if (!state) continue;
          if (!hasOwnProperty(state, keyOrSelector)) continue;
          const value = state[keyOrSelector];
          if (value !== obj[prop]) {
            obj[prop] = value;
            updated = true;
          }
        }
      }
      if (updated) {
        objRef.current = { ...obj };
      }
      return objRef.current;
    };
    return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
  }
  function useStoreProps(store4, props, key, setKey) {
    const value = hasOwnProperty(props, key) ? props[key] : void 0;
    const setValue = setKey ? props[setKey] : void 0;
    const propsRef = useLiveRef({ value, setValue });
    useSafeLayoutEffect(() => {
      return sync2(store4, [key], (state, prev) => {
        const { value: value2, setValue: setValue2 } = propsRef.current;
        if (!setValue2) return;
        if (state[key] === prev[key]) return;
        if (state[key] === value2) return;
        setValue2(state[key]);
      });
    }, [store4, key]);
    useSafeLayoutEffect(() => {
      if (value === void 0) return;
      store4.setState(key, value);
      return batch(store4, [key], () => {
        if (value === void 0) return;
        store4.setState(key, value);
      });
    });
  }
  function useStore(createStore2, props) {
    const [store4, setStore] = React26.useState(() => createStore2(props));
    useSafeLayoutEffect(() => init(store4), [store4]);
    const useState210 = React26.useCallback(
      (keyOrSelector) => useStoreState(store4, keyOrSelector),
      [store4]
    );
    const memoizedStore = React26.useMemo(
      () => ({ ...store4, useState: useState210 }),
      [store4, useState210]
    );
    const updateStore = useEvent(() => {
      setStore((store22) => createStore2({ ...props, ...store22.getState() }));
    });
    return [memoizedStore, updateStore];
  }

  // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
  var import_react20 = __toESM(require_react(), 1);
  var import_jsx_runtime163 = __toESM(require_jsx_runtime(), 1);
  var TagName4 = "button";
  function isEditableElement(element) {
    if (isTextbox(element)) return true;
    return element.tagName === "INPUT" && !isButton(element);
  }
  function getNextPageOffset(scrollingElement, pageUp = false) {
    const height = scrollingElement.clientHeight;
    const { top } = scrollingElement.getBoundingClientRect();
    const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
    const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
    if (scrollingElement.tagName === "HTML") {
      return pageOffset + scrollingElement.scrollTop;
    }
    return pageOffset;
  }
  function getItemOffset(itemElement, pageUp = false) {
    const { top } = itemElement.getBoundingClientRect();
    if (pageUp) {
      return top + itemElement.clientHeight;
    }
    return top;
  }
  function findNextPageItemId(element, store4, next, pageUp = false) {
    var _a;
    if (!store4) return;
    if (!next) return;
    const { renderedItems } = store4.getState();
    const scrollingElement = getScrollingElement(element);
    if (!scrollingElement) return;
    const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
    let id;
    let prevDifference;
    for (let i3 = 0; i3 < renderedItems.length; i3 += 1) {
      const previousId = id;
      id = next(i3);
      if (!id) break;
      if (id === previousId) continue;
      const itemElement = (_a = getEnabledItem(store4, id)) == null ? void 0 : _a.element;
      if (!itemElement) continue;
      const itemOffset = getItemOffset(itemElement, pageUp);
      const difference = itemOffset - nextPageOffset;
      const absDifference = Math.abs(difference);
      if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
        if (prevDifference !== void 0 && prevDifference < absDifference) {
          id = previousId;
        }
        break;
      }
      prevDifference = absDifference;
    }
    return id;
  }
  function targetIsAnotherItem(event, store4) {
    if (isSelfTarget(event)) return false;
    return isItem(store4, event.target);
  }
  var useCompositeItem = createHook(
    function useCompositeItem2({
      store: store4,
      rowId: rowIdProp,
      preventScrollOnKeyDown = false,
      moveOnKeyPress = true,
      tabbable = false,
      getItem: getItemProp,
      "aria-setsize": ariaSetSizeProp,
      "aria-posinset": ariaPosInSetProp,
      ...props
    }) {
      const context = useCompositeContext();
      store4 = store4 || context;
      const id = useId5(props.id);
      const ref = (0, import_react20.useRef)(null);
      const row = (0, import_react20.useContext)(CompositeRowContext);
      const disabled2 = disabledFromProps(props);
      const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
      const {
        rowId,
        baseElement,
        isActiveItem,
        ariaSetSize,
        ariaPosInSet,
        isTabbable
      } = useStoreStateObject(store4, {
        rowId(state) {
          if (rowIdProp) return rowIdProp;
          if (!state) return;
          if (!(row == null ? void 0 : row.baseElement)) return;
          if (row.baseElement !== state.baseElement) return;
          return row.id;
        },
        baseElement(state) {
          return (state == null ? void 0 : state.baseElement) || void 0;
        },
        isActiveItem(state) {
          return !!state && state.activeId === id;
        },
        ariaSetSize(state) {
          if (ariaSetSizeProp != null) return ariaSetSizeProp;
          if (!state) return;
          if (!(row == null ? void 0 : row.ariaSetSize)) return;
          if (row.baseElement !== state.baseElement) return;
          return row.ariaSetSize;
        },
        ariaPosInSet(state) {
          if (ariaPosInSetProp != null) return ariaPosInSetProp;
          if (!state) return;
          if (!(row == null ? void 0 : row.ariaPosInSet)) return;
          if (row.baseElement !== state.baseElement) return;
          const itemsInRow = state.renderedItems.filter(
            (item) => item.rowId === rowId
          );
          return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
        },
        isTabbable(state) {
          if (!(state == null ? void 0 : state.renderedItems.length)) return true;
          if (state.virtualFocus) return false;
          if (tabbable) return true;
          if (state.activeId === null) return false;
          const item = store4 == null ? void 0 : store4.item(state.activeId);
          if (item == null ? void 0 : item.disabled) return true;
          if (!(item == null ? void 0 : item.element)) return true;
          return state.activeId === id;
        }
      });
      const getItem = (0, import_react20.useCallback)(
        (item) => {
          var _a;
          const nextItem = {
            ...item,
            id: id || item.id,
            rowId,
            disabled: !!trulyDisabled,
            children: (_a = item.element) == null ? void 0 : _a.textContent
          };
          if (getItemProp) {
            return getItemProp(nextItem);
          }
          return nextItem;
        },
        [id, rowId, trulyDisabled, getItemProp]
      );
      const onFocusProp = props.onFocus;
      const hasFocusedComposite = (0, import_react20.useRef)(false);
      const onFocus = useEvent((event) => {
        onFocusProp == null ? void 0 : onFocusProp(event);
        if (event.defaultPrevented) return;
        if (isPortalEvent(event)) return;
        if (!id) return;
        if (!store4) return;
        if (targetIsAnotherItem(event, store4)) return;
        const { virtualFocus, baseElement: baseElement2 } = store4.getState();
        store4.setActiveId(id);
        if (isTextbox(event.currentTarget)) {
          selectTextField(event.currentTarget);
        }
        if (!virtualFocus) return;
        if (!isSelfTarget(event)) return;
        if (isEditableElement(event.currentTarget)) return;
        if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
        if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) {
          event.currentTarget.scrollIntoView({
            block: "nearest",
            inline: "nearest"
          });
        }
        hasFocusedComposite.current = true;
        const fromComposite = event.relatedTarget === baseElement2 || isItem(store4, event.relatedTarget);
        if (fromComposite) {
          focusSilently(baseElement2);
        } else {
          baseElement2.focus();
        }
      });
      const onBlurCaptureProp = props.onBlurCapture;
      const onBlurCapture = useEvent((event) => {
        onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
        if (event.defaultPrevented) return;
        const state = store4 == null ? void 0 : store4.getState();
        if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
          hasFocusedComposite.current = false;
          event.preventDefault();
          event.stopPropagation();
        }
      });
      const onKeyDownProp = props.onKeyDown;
      const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
      const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
      const onKeyDown = useEvent((event) => {
        onKeyDownProp == null ? void 0 : onKeyDownProp(event);
        if (event.defaultPrevented) return;
        if (!isSelfTarget(event)) return;
        if (!store4) return;
        const { currentTarget } = event;
        const state = store4.getState();
        const item = store4.item(id);
        const isGrid2 = !!(item == null ? void 0 : item.rowId);
        const isVertical = state.orientation !== "horizontal";
        const isHorizontal = state.orientation !== "vertical";
        const canHomeEnd = () => {
          if (isGrid2) return true;
          if (isHorizontal) return true;
          if (!state.baseElement) return true;
          if (!isTextField(state.baseElement)) return true;
          return false;
        };
        const keyMap = {
          ArrowUp: (isGrid2 || isVertical) && store4.up,
          ArrowRight: (isGrid2 || isHorizontal) && store4.next,
          ArrowDown: (isGrid2 || isVertical) && store4.down,
          ArrowLeft: (isGrid2 || isHorizontal) && store4.previous,
          Home: () => {
            if (!canHomeEnd()) return;
            if (!isGrid2 || event.ctrlKey) {
              return store4 == null ? void 0 : store4.first();
            }
            return store4 == null ? void 0 : store4.previous(-1);
          },
          End: () => {
            if (!canHomeEnd()) return;
            if (!isGrid2 || event.ctrlKey) {
              return store4 == null ? void 0 : store4.last();
            }
            return store4 == null ? void 0 : store4.next(-1);
          },
          PageUp: () => {
            return findNextPageItemId(currentTarget, store4, store4 == null ? void 0 : store4.up, true);
          },
          PageDown: () => {
            return findNextPageItemId(currentTarget, store4, store4 == null ? void 0 : store4.down);
          }
        };
        const action = keyMap[event.key];
        if (action) {
          if (isTextbox(currentTarget)) {
            const selection = getTextboxSelection(currentTarget);
            const isLeft = isHorizontal && event.key === "ArrowLeft";
            const isRight = isHorizontal && event.key === "ArrowRight";
            const isUp = isVertical && event.key === "ArrowUp";
            const isDown = isVertical && event.key === "ArrowDown";
            if (isRight || isDown) {
              const { length: valueLength } = getTextboxValue(currentTarget);
              if (selection.end !== valueLength) return;
            } else if ((isLeft || isUp) && selection.start !== 0) return;
          }
          const nextId2 = action();
          if (preventScrollOnKeyDownProp(event) || nextId2 !== void 0) {
            if (!moveOnKeyPressProp(event)) return;
            event.preventDefault();
            store4.move(nextId2);
          }
        }
      });
      const providerValue = (0, import_react20.useMemo)(
        () => ({ id, baseElement }),
        [id, baseElement]
      );
      props = useWrapElement(
        props,
        (element) => /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
        [providerValue]
      );
      props = {
        id,
        "data-active-item": isActiveItem || void 0,
        ...props,
        ref: useMergeRefs(ref, props.ref),
        tabIndex: isTabbable ? props.tabIndex : -1,
        onFocus,
        onBlurCapture,
        onKeyDown
      };
      props = useCommand(props);
      props = useCollectionItem({
        store: store4,
        ...props,
        getItem,
        shouldRegisterItem: id ? props.shouldRegisterItem : false
      });
      return removeUndefinedValues({
        ...props,
        "aria-setsize": ariaSetSize,
        "aria-posinset": ariaPosInSet
      });
    }
  );
  var CompositeItem = memo22(
    forwardRef27(function CompositeItem2(props) {
      const htmlProps = useCompositeItem(props);
      return createElement5(TagName4, htmlProps);
    })
  );

  // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
  function toArray2(arg) {
    if (Array.isArray(arg)) {
      return arg;
    }
    return typeof arg !== "undefined" ? [arg] : [];
  }
  function flatten2DArray(array) {
    const flattened = [];
    for (const row of array) {
      flattened.push(...row);
    }
    return flattened;
  }
  function reverseArray(array) {
    return array.slice().reverse();
  }

  // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
  var import_react21 = __toESM(require_react(), 1);
  var import_jsx_runtime164 = __toESM(require_jsx_runtime(), 1);
  var TagName5 = "div";
  function isGrid(items) {
    return items.some((item) => !!item.rowId);
  }
  function isPrintableKey(event) {
    const target = event.target;
    if (target && !isTextField(target)) return false;
    return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
  }
  function isModifierKey(event) {
    return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
  }
  function useKeyboardEventProxy(store4, onKeyboardEvent, previousElementRef) {
    return useEvent((event) => {
      var _a;
      onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
      if (event.defaultPrevented) return;
      if (event.isPropagationStopped()) return;
      if (!isSelfTarget(event)) return;
      if (isModifierKey(event)) return;
      if (isPrintableKey(event)) return;
      const state = store4.getState();
      const activeElement = (_a = getEnabledItem(store4, state.activeId)) == null ? void 0 : _a.element;
      if (!activeElement) return;
      const { view: view2, ...eventInit } = event;
      const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
      if (activeElement !== previousElement) {
        activeElement.focus();
      }
      if (!fireKeyboardEvent(activeElement, event.type, eventInit)) {
        event.preventDefault();
      }
      if (event.currentTarget.contains(activeElement)) {
        event.stopPropagation();
      }
    });
  }
  function findFirstEnabledItemInTheLastRow(items) {
    return findFirstEnabledItem(
      flatten2DArray(reverseArray(groupItemsByRows(items)))
    );
  }
  function useScheduleFocus(store4) {
    const [scheduled, setScheduled] = (0, import_react21.useState)(false);
    const schedule2 = (0, import_react21.useCallback)(() => setScheduled(true), []);
    const activeItem = store4.useState(
      (state) => getEnabledItem(store4, state.activeId)
    );
    (0, import_react21.useEffect)(() => {
      const activeElement = activeItem == null ? void 0 : activeItem.element;
      if (!scheduled) return;
      if (!activeElement) return;
      setScheduled(false);
      activeElement.focus({ preventScroll: true });
    }, [activeItem, scheduled]);
    return schedule2;
  }
  var useComposite = createHook(
    function useComposite2({
      store: store4,
      composite = true,
      focusOnMove = composite,
      moveOnKeyPress = true,
      ...props
    }) {
      const context = useCompositeProviderContext();
      store4 = store4 || context;
      invariant(
        store4,
        "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
      );
      const ref = (0, import_react21.useRef)(null);
      const previousElementRef = (0, import_react21.useRef)(null);
      const scheduleFocus = useScheduleFocus(store4);
      const moves = store4.useState("moves");
      const [, setBaseElement] = useTransactionState(
        composite ? store4.setBaseElement : null
      );
      (0, import_react21.useEffect)(() => {
        var _a;
        if (!store4) return;
        if (!moves) return;
        if (!composite) return;
        if (!focusOnMove) return;
        const { activeId: activeId2 } = store4.getState();
        const itemElement = (_a = getEnabledItem(store4, activeId2)) == null ? void 0 : _a.element;
        if (!itemElement) return;
        focusIntoView(itemElement);
      }, [store4, moves, composite, focusOnMove]);
      useSafeLayoutEffect(() => {
        if (!store4) return;
        if (!moves) return;
        if (!composite) return;
        const { baseElement, activeId: activeId2 } = store4.getState();
        const isSelfAcive = activeId2 === null;
        if (!isSelfAcive) return;
        if (!baseElement) return;
        const previousElement = previousElementRef.current;
        previousElementRef.current = null;
        if (previousElement) {
          fireBlurEvent(previousElement, { relatedTarget: baseElement });
        }
        if (!hasFocus(baseElement)) {
          baseElement.focus();
        }
      }, [store4, moves, composite]);
      const activeId = store4.useState("activeId");
      const virtualFocus = store4.useState("virtualFocus");
      useSafeLayoutEffect(() => {
        var _a;
        if (!store4) return;
        if (!composite) return;
        if (!virtualFocus) return;
        const previousElement = previousElementRef.current;
        previousElementRef.current = null;
        if (!previousElement) return;
        const activeElement = (_a = getEnabledItem(store4, activeId)) == null ? void 0 : _a.element;
        const relatedTarget = activeElement || getActiveElement(previousElement);
        if (relatedTarget === previousElement) return;
        fireBlurEvent(previousElement, { relatedTarget });
      }, [store4, activeId, virtualFocus, composite]);
      const onKeyDownCapture = useKeyboardEventProxy(
        store4,
        props.onKeyDownCapture,
        previousElementRef
      );
      const onKeyUpCapture = useKeyboardEventProxy(
        store4,
        props.onKeyUpCapture,
        previousElementRef
      );
      const onFocusCaptureProp = props.onFocusCapture;
      const onFocusCapture = useEvent((event) => {
        onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
        if (event.defaultPrevented) return;
        if (!store4) return;
        const { virtualFocus: virtualFocus2 } = store4.getState();
        if (!virtualFocus2) return;
        const previousActiveElement = event.relatedTarget;
        const isSilentlyFocused = silentlyFocused(event.currentTarget);
        if (isSelfTarget(event) && isSilentlyFocused) {
          event.stopPropagation();
          previousElementRef.current = previousActiveElement;
        }
      });
      const onFocusProp = props.onFocus;
      const onFocus = useEvent((event) => {
        onFocusProp == null ? void 0 : onFocusProp(event);
        if (event.defaultPrevented) return;
        if (!composite) return;
        if (!store4) return;
        const { relatedTarget } = event;
        const { virtualFocus: virtualFocus2 } = store4.getState();
        if (virtualFocus2) {
          if (isSelfTarget(event) && !isItem(store4, relatedTarget)) {
            queueMicrotask(scheduleFocus);
          }
        } else if (isSelfTarget(event)) {
          store4.setActiveId(null);
        }
      });
      const onBlurCaptureProp = props.onBlurCapture;
      const onBlurCapture = useEvent((event) => {
        var _a;
        onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
        if (event.defaultPrevented) return;
        if (!store4) return;
        const { virtualFocus: virtualFocus2, activeId: activeId2 } = store4.getState();
        if (!virtualFocus2) return;
        const activeElement = (_a = getEnabledItem(store4, activeId2)) == null ? void 0 : _a.element;
        const nextActiveElement = event.relatedTarget;
        const nextActiveElementIsItem = isItem(store4, nextActiveElement);
        const previousElement = previousElementRef.current;
        previousElementRef.current = null;
        if (isSelfTarget(event) && nextActiveElementIsItem) {
          if (nextActiveElement === activeElement) {
            if (previousElement && previousElement !== nextActiveElement) {
              fireBlurEvent(previousElement, event);
            }
          } else if (activeElement) {
            fireBlurEvent(activeElement, event);
          } else if (previousElement) {
            fireBlurEvent(previousElement, event);
          }
          event.stopPropagation();
        } else {
          const targetIsItem = isItem(store4, event.target);
          if (!targetIsItem && activeElement) {
            fireBlurEvent(activeElement, event);
          }
        }
      });
      const onKeyDownProp = props.onKeyDown;
      const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
      const onKeyDown = useEvent((event) => {
        var _a;
        onKeyDownProp == null ? void 0 : onKeyDownProp(event);
        if (event.nativeEvent.isComposing) return;
        if (event.defaultPrevented) return;
        if (!store4) return;
        if (!isSelfTarget(event)) return;
        const { orientation, renderedItems, activeId: activeId2 } = store4.getState();
        const activeItem = getEnabledItem(store4, activeId2);
        if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
        const isVertical = orientation !== "horizontal";
        const isHorizontal = orientation !== "vertical";
        const grid = isGrid(renderedItems);
        const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
        if (isHorizontalKey && isTextField(event.currentTarget)) return;
        const up = () => {
          if (grid) {
            const item = findFirstEnabledItemInTheLastRow(renderedItems);
            return item == null ? void 0 : item.id;
          }
          return store4 == null ? void 0 : store4.last();
        };
        const keyMap = {
          ArrowUp: (grid || isVertical) && up,
          ArrowRight: (grid || isHorizontal) && store4.first,
          ArrowDown: (grid || isVertical) && store4.first,
          ArrowLeft: (grid || isHorizontal) && store4.last,
          Home: store4.first,
          End: store4.last,
          PageUp: store4.first,
          PageDown: store4.last
        };
        const action = keyMap[event.key];
        if (action) {
          const id = action();
          if (id !== void 0) {
            if (!moveOnKeyPressProp(event)) return;
            event.preventDefault();
            store4.move(id);
          }
        }
      });
      props = useWrapElement(
        props,
        (element) => /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(CompositeContextProvider, { value: store4, children: element }),
        [store4]
      );
      const activeDescendant = store4.useState((state) => {
        var _a;
        if (!store4) return;
        if (!composite) return;
        if (!state.virtualFocus) return;
        return (_a = getEnabledItem(store4, state.activeId)) == null ? void 0 : _a.id;
      });
      props = {
        "aria-activedescendant": activeDescendant,
        ...props,
        ref: useMergeRefs(ref, setBaseElement, props.ref),
        onKeyDownCapture,
        onKeyUpCapture,
        onFocusCapture,
        onFocus,
        onBlurCapture,
        onKeyDown
      };
      const focusable = store4.useState(
        (state) => composite && (state.virtualFocus || state.activeId === null)
      );
      props = useFocusable({ focusable, ...props });
      return props;
    }
  );
  var Composite5 = forwardRef27(function Composite22(props) {
    const htmlProps = useComposite(props);
    return createElement5(TagName5, htmlProps);
  });

  // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
  var ctx4 = createStoreContext();
  var useDisclosureContext = ctx4.useContext;
  var useDisclosureScopedContext = ctx4.useScopedContext;
  var useDisclosureProviderContext = ctx4.useProviderContext;
  var DisclosureContextProvider = ctx4.ContextProvider;
  var DisclosureScopedContextProvider = ctx4.ScopedContextProvider;

  // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
  var import_react22 = __toESM(require_react(), 1);
  var ctx5 = createStoreContext(
    [DisclosureContextProvider],
    [DisclosureScopedContextProvider]
  );
  var useDialogContext = ctx5.useContext;
  var useDialogScopedContext = ctx5.useScopedContext;
  var useDialogProviderContext = ctx5.useProviderContext;
  var DialogContextProvider = ctx5.ContextProvider;
  var DialogScopedContextProvider = ctx5.ScopedContextProvider;
  var DialogHeadingContext = (0, import_react22.createContext)(void 0);
  var DialogDescriptionContext = (0, import_react22.createContext)(void 0);

  // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
  var import_react23 = __toESM(require_react(), 1);
  var import_react_dom2 = __toESM(require_react_dom(), 1);
  var import_jsx_runtime165 = __toESM(require_jsx_runtime(), 1);
  var TagName6 = "div";
  function afterTimeout(timeoutMs, cb) {
    const timeoutId = setTimeout(cb, timeoutMs);
    return () => clearTimeout(timeoutId);
  }
  function afterPaint2(cb) {
    let raf2 = requestAnimationFrame(() => {
      raf2 = requestAnimationFrame(cb);
    });
    return () => cancelAnimationFrame(raf2);
  }
  function parseCSSTime(...times) {
    return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
      const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
      const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
      if (currentTime > longestTime) return currentTime;
      return longestTime;
    }, 0);
  }
  function isHidden(mounted, hidden, alwaysVisible) {
    return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
  }
  var useDisclosureContent = createHook(function useDisclosureContent2({ store: store4, alwaysVisible, ...props }) {
    const context = useDisclosureProviderContext();
    store4 = store4 || context;
    invariant(
      store4,
      "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
    );
    const ref = (0, import_react23.useRef)(null);
    const id = useId5(props.id);
    const [transition, setTransition] = (0, import_react23.useState)(null);
    const open = store4.useState("open");
    const mounted = store4.useState("mounted");
    const animated2 = store4.useState("animated");
    const contentElement = store4.useState("contentElement");
    const otherElement = useStoreState(store4.disclosure, "contentElement");
    useSafeLayoutEffect(() => {
      if (!ref.current) return;
      store4 == null ? void 0 : store4.setContentElement(ref.current);
    }, [store4]);
    useSafeLayoutEffect(() => {
      let previousAnimated;
      store4 == null ? void 0 : store4.setState("animated", (animated22) => {
        previousAnimated = animated22;
        return true;
      });
      return () => {
        if (previousAnimated === void 0) return;
        store4 == null ? void 0 : store4.setState("animated", previousAnimated);
      };
    }, [store4]);
    useSafeLayoutEffect(() => {
      if (!animated2) return;
      if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
        setTransition(null);
        return;
      }
      return afterPaint2(() => {
        setTransition(open ? "enter" : mounted ? "leave" : null);
      });
    }, [animated2, contentElement, open, mounted]);
    useSafeLayoutEffect(() => {
      if (!store4) return;
      if (!animated2) return;
      if (!transition) return;
      if (!contentElement) return;
      const stopAnimation = () => store4 == null ? void 0 : store4.setState("animating", false);
      const stopAnimationSync = () => (0, import_react_dom2.flushSync)(stopAnimation);
      if (transition === "leave" && open) return;
      if (transition === "enter" && !open) return;
      if (typeof animated2 === "number") {
        const timeout2 = animated2;
        return afterTimeout(timeout2, stopAnimationSync);
      }
      const {
        transitionDuration,
        animationDuration,
        transitionDelay,
        animationDelay
      } = getComputedStyle(contentElement);
      const {
        transitionDuration: transitionDuration2 = "0",
        animationDuration: animationDuration2 = "0",
        transitionDelay: transitionDelay2 = "0",
        animationDelay: animationDelay2 = "0"
      } = otherElement ? getComputedStyle(otherElement) : {};
      const delay = parseCSSTime(
        transitionDelay,
        animationDelay,
        transitionDelay2,
        animationDelay2
      );
      const duration = parseCSSTime(
        transitionDuration,
        animationDuration,
        transitionDuration2,
        animationDuration2
      );
      const timeout = delay + duration;
      if (!timeout) {
        if (transition === "enter") {
          store4.setState("animated", false);
        }
        stopAnimation();
        return;
      }
      const frameRate = 1e3 / 60;
      const maxTimeout = Math.max(timeout - frameRate, 0);
      return afterTimeout(maxTimeout, stopAnimationSync);
    }, [store4, animated2, contentElement, otherElement, open, transition]);
    props = useWrapElement(
      props,
      (element) => /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(DialogScopedContextProvider, { value: store4, children: element }),
      [store4]
    );
    const hidden = isHidden(mounted, props.hidden, alwaysVisible);
    const styleProp = props.style;
    const style = (0, import_react23.useMemo)(() => {
      if (hidden) {
        return { ...styleProp, display: "none" };
      }
      return styleProp;
    }, [hidden, styleProp]);
    props = {
      id,
      "data-open": open || void 0,
      "data-enter": transition === "enter" || void 0,
      "data-leave": transition === "leave" || void 0,
      hidden,
      ...props,
      ref: useMergeRefs(id ? store4.setContentElement : null, ref, props.ref),
      style
    };
    return removeUndefinedValues(props);
  });
  var DisclosureContentImpl = forwardRef27(function DisclosureContentImpl2(props) {
    const htmlProps = useDisclosureContent(props);
    return createElement5(TagName6, htmlProps);
  });
  var DisclosureContent = forwardRef27(function DisclosureContent2({
    unmountOnHide,
    ...props
  }) {
    const context = useDisclosureProviderContext();
    const store4 = props.store || context;
    const mounted = useStoreState(
      store4,
      (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
    );
    if (mounted === false) return null;
    return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(DisclosureContentImpl, { ...props });
  });

  // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
  function createDisclosureStore(props = {}) {
    const store4 = mergeStore(
      props.store,
      omit2(props.disclosure, ["contentElement", "disclosureElement"])
    );
    throwOnConflictingProps(props, store4);
    const syncState = store4 == null ? void 0 : store4.getState();
    const open = defaultValue(
      props.open,
      syncState == null ? void 0 : syncState.open,
      props.defaultOpen,
      false
    );
    const animated2 = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
    const initialState = {
      open,
      animated: animated2,
      animating: !!animated2 && open,
      mounted: open,
      contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
      disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
    };
    const disclosure = createStore(initialState, store4);
    setup(
      disclosure,
      () => sync2(disclosure, ["animated", "animating"], (state) => {
        if (state.animated) return;
        disclosure.setState("animating", false);
      })
    );
    setup(
      disclosure,
      () => subscribe(disclosure, ["open"], () => {
        if (!disclosure.getState().animated) return;
        disclosure.setState("animating", true);
      })
    );
    setup(
      disclosure,
      () => sync2(disclosure, ["open", "animating"], (state) => {
        disclosure.setState("mounted", state.open || state.animating);
      })
    );
    return {
      ...disclosure,
      disclosure: props.disclosure,
      setOpen: (value) => disclosure.setState("open", value),
      show: () => disclosure.setState("open", true),
      hide: () => disclosure.setState("open", false),
      toggle: () => disclosure.setState("open", (open2) => !open2),
      stopAnimation: () => disclosure.setState("animating", false),
      setContentElement: (value) => disclosure.setState("contentElement", value),
      setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
    };
  }

  // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
  function useDisclosureStoreProps(store4, update4, props) {
    useUpdateEffect(update4, [props.store, props.disclosure]);
    useStoreProps(store4, props, "open", "setOpen");
    useStoreProps(store4, props, "mounted", "setMounted");
    useStoreProps(store4, props, "animated");
    return Object.assign(store4, { disclosure: props.disclosure });
  }

  // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
  var ctx6 = createStoreContext(
    [DialogContextProvider],
    [DialogScopedContextProvider]
  );
  var usePopoverContext = ctx6.useContext;
  var usePopoverScopedContext = ctx6.useScopedContext;
  var usePopoverProviderContext = ctx6.useProviderContext;
  var PopoverContextProvider = ctx6.ContextProvider;
  var PopoverScopedContextProvider = ctx6.ScopedContextProvider;

  // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
  function getCommonParent(items) {
    var _a;
    const firstItem = items.find((item) => !!item.element);
    const lastItem = [...items].reverse().find((item) => !!item.element);
    let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
    while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
      const parent = parentElement;
      if (lastItem && parent.contains(lastItem.element)) {
        return parentElement;
      }
      parentElement = parentElement.parentElement;
    }
    return getDocument(parentElement).body;
  }
  function getPrivateStore(store4) {
    return store4 == null ? void 0 : store4.__unstablePrivateStore;
  }
  function createCollectionStore(props = {}) {
    var _a;
    throwOnConflictingProps(props, props.store);
    const syncState = (_a = props.store) == null ? void 0 : _a.getState();
    const items = defaultValue(
      props.items,
      syncState == null ? void 0 : syncState.items,
      props.defaultItems,
      []
    );
    const itemsMap = new Map(items.map((item) => [item.id, item]));
    const initialState = {
      items,
      renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
    };
    const syncPrivateStore = getPrivateStore(props.store);
    const privateStore = createStore(
      { items, renderedItems: initialState.renderedItems },
      syncPrivateStore
    );
    const collection = createStore(initialState, props.store);
    const sortItems = (renderedItems) => {
      const sortedItems = sortBasedOnDOMPosition(renderedItems, (i3) => i3.element);
      privateStore.setState("renderedItems", sortedItems);
      collection.setState("renderedItems", sortedItems);
    };
    setup(collection, () => init(privateStore));
    setup(privateStore, () => {
      return batch(privateStore, ["items"], (state) => {
        collection.setState("items", state.items);
      });
    });
    setup(privateStore, () => {
      return batch(privateStore, ["renderedItems"], (state) => {
        let firstRun = true;
        let raf2 = requestAnimationFrame(() => {
          const { renderedItems } = collection.getState();
          if (state.renderedItems === renderedItems) return;
          sortItems(state.renderedItems);
        });
        if (typeof IntersectionObserver !== "function") {
          return () => cancelAnimationFrame(raf2);
        }
        const ioCallback = () => {
          if (firstRun) {
            firstRun = false;
            return;
          }
          cancelAnimationFrame(raf2);
          raf2 = requestAnimationFrame(() => sortItems(state.renderedItems));
        };
        const root = getCommonParent(state.renderedItems);
        const observer = new IntersectionObserver(ioCallback, { root });
        for (const item of state.renderedItems) {
          if (!item.element) continue;
          observer.observe(item.element);
        }
        return () => {
          cancelAnimationFrame(raf2);
          observer.disconnect();
        };
      });
    });
    const mergeItem = (item, setItems, canDeleteFromMap = false) => {
      let prevItem;
      setItems((items2) => {
        const index = items2.findIndex(({ id }) => id === item.id);
        const nextItems = items2.slice();
        if (index !== -1) {
          prevItem = items2[index];
          const nextItem = { ...prevItem, ...item };
          nextItems[index] = nextItem;
          itemsMap.set(item.id, nextItem);
        } else {
          nextItems.push(item);
          itemsMap.set(item.id, item);
        }
        return nextItems;
      });
      const unmergeItem = () => {
        setItems((items2) => {
          if (!prevItem) {
            if (canDeleteFromMap) {
              itemsMap.delete(item.id);
            }
            return items2.filter(({ id }) => id !== item.id);
          }
          const index = items2.findIndex(({ id }) => id === item.id);
          if (index === -1) return items2;
          const nextItems = items2.slice();
          nextItems[index] = prevItem;
          itemsMap.set(item.id, prevItem);
          return nextItems;
        });
      };
      return unmergeItem;
    };
    const registerItem = (item) => mergeItem(
      item,
      (getItems) => privateStore.setState("items", getItems),
      true
    );
    return {
      ...collection,
      registerItem,
      renderItem: (item) => chain(
        registerItem(item),
        mergeItem(
          item,
          (getItems) => privateStore.setState("renderedItems", getItems)
        )
      ),
      item: (id) => {
        if (!id) return null;
        let item = itemsMap.get(id);
        if (!item) {
          const { items: items2 } = privateStore.getState();
          item = items2.find((item2) => item2.id === id);
          if (item) {
            itemsMap.set(id, item);
          }
        }
        return item || null;
      },
      // @ts-expect-error Internal
      __unstablePrivateStore: privateStore
    };
  }

  // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
  function useCollectionStoreProps(store4, update4, props) {
    useUpdateEffect(update4, [props.store]);
    useStoreProps(store4, props, "items", "setItems");
    return store4;
  }

  // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
  var NULL_ITEM = { id: null };
  function findFirstEnabledItem2(items, excludeId) {
    return items.find((item) => {
      if (excludeId) {
        return !item.disabled && item.id !== excludeId;
      }
      return !item.disabled;
    });
  }
  function getEnabledItems(items, excludeId) {
    return items.filter((item) => {
      if (excludeId) {
        return !item.disabled && item.id !== excludeId;
      }
      return !item.disabled;
    });
  }
  function getItemsInRow(items, rowId) {
    return items.filter((item) => item.rowId === rowId);
  }
  function flipItems(items, activeId, shouldInsertNullItem = false) {
    const index = items.findIndex((item) => item.id === activeId);
    return [
      ...items.slice(index + 1),
      ...shouldInsertNullItem ? [NULL_ITEM] : [],
      ...items.slice(0, index)
    ];
  }
  function groupItemsByRows2(items) {
    const rows = [];
    for (const item of items) {
      const row = rows.find((currentRow) => {
        var _a;
        return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
      });
      if (row) {
        row.push(item);
      } else {
        rows.push([item]);
      }
    }
    return rows;
  }
  function getMaxRowLength(array) {
    let maxLength = 0;
    for (const { length: length2 } of array) {
      if (length2 > maxLength) {
        maxLength = length2;
      }
    }
    return maxLength;
  }
  function createEmptyItem(rowId) {
    return {
      id: "__EMPTY_ITEM__",
      disabled: true,
      rowId
    };
  }
  function normalizeRows(rows, activeId, focusShift) {
    const maxLength = getMaxRowLength(rows);
    for (const row of rows) {
      for (let i3 = 0; i3 < maxLength; i3 += 1) {
        const item = row[i3];
        if (!item || focusShift && item.disabled) {
          const isFirst = i3 === 0;
          const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i3 - 1];
          row[i3] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
        }
      }
    }
    return rows;
  }
  function verticalizeItems(items) {
    const rows = groupItemsByRows2(items);
    const maxLength = getMaxRowLength(rows);
    const verticalized = [];
    for (let i3 = 0; i3 < maxLength; i3 += 1) {
      for (const row of rows) {
        const item = row[i3];
        if (item) {
          verticalized.push({
            ...item,
            // If there's no rowId, it means that it's not a grid composite, but
            // a single row instead. So, instead of verticalizing it, that is,
            // assigning a different rowId based on the column index, we keep it
            // undefined so they will be part of the same row. This is useful
            // when using up/down on one-dimensional composites.
            rowId: item.rowId ? `${i3}` : void 0
          });
        }
      }
    }
    return verticalized;
  }
  function createCompositeStore(props = {}) {
    var _a;
    const syncState = (_a = props.store) == null ? void 0 : _a.getState();
    const collection = createCollectionStore(props);
    const activeId = defaultValue(
      props.activeId,
      syncState == null ? void 0 : syncState.activeId,
      props.defaultActiveId
    );
    const initialState = {
      ...collection.getState(),
      id: defaultValue(
        props.id,
        syncState == null ? void 0 : syncState.id,
        `id-${Math.random().toString(36).slice(2, 8)}`
      ),
      activeId,
      baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
      includesBaseElement: defaultValue(
        props.includesBaseElement,
        syncState == null ? void 0 : syncState.includesBaseElement,
        activeId === null
      ),
      moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
      orientation: defaultValue(
        props.orientation,
        syncState == null ? void 0 : syncState.orientation,
        "both"
      ),
      rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
      virtualFocus: defaultValue(
        props.virtualFocus,
        syncState == null ? void 0 : syncState.virtualFocus,
        false
      ),
      focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
      focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
      focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
    };
    const composite = createStore(initialState, collection, props.store);
    setup(
      composite,
      () => sync2(composite, ["renderedItems", "activeId"], (state) => {
        composite.setState("activeId", (activeId2) => {
          var _a2;
          if (activeId2 !== void 0) return activeId2;
          return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
        });
      })
    );
    const getNextId = (direction = "next", options = {}) => {
      var _a2, _b;
      const defaultState = composite.getState();
      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;
      const isVerticalDirection = direction === "up" || direction === "down";
      const isNextDirection = direction === "next" || direction === "down";
      const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
      const canShift = focusShift && !skip;
      let items = !isVerticalDirection ? renderedItems : flatten2DArray(
        normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
      );
      items = canReverse ? reverseArray(items) : items;
      items = isVerticalDirection ? verticalizeItems(items) : items;
      if (activeId2 == null) {
        return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
      }
      const activeItem = items.find((item) => item.id === activeId2);
      if (!activeItem) {
        return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
      }
      const isGrid2 = items.some((item) => item.rowId);
      const activeIndex = items.indexOf(activeItem);
      const nextItems = items.slice(activeIndex + 1);
      const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
      if (skip) {
        const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
        const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
        nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
        return nextItem2 == null ? void 0 : nextItem2.id;
      }
      const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
      const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
      const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
      if (canLoop) {
        const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
        const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
        const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
        return nextItem2 == null ? void 0 : nextItem2.id;
      }
      if (canWrap) {
        const nextItem2 = findFirstEnabledItem2(
          // We can use nextItems, which contains all the next items, including
          // items from other rows, to wrap between rows. However, if there is a
          // null item (the composite container), we'll only use the next items in
          // the row. So moving next from the last item will focus on the
          // composite container. On grid composites, horizontal navigation never
          // focuses on the composite container, only vertical.
          hasNullItem ? nextItemsInRow : nextItems,
          activeId2
        );
        const nextId2 = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
        return nextId2;
      }
      const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
      if (!nextItem && hasNullItem) {
        return null;
      }
      return nextItem == null ? void 0 : nextItem.id;
    };
    return {
      ...collection,
      ...composite,
      setBaseElement: (element) => composite.setState("baseElement", element),
      setActiveId: (id) => composite.setState("activeId", id),
      move: (id) => {
        if (id === void 0) return;
        composite.setState("activeId", id);
        composite.setState("moves", (moves) => moves + 1);
      },
      first: () => {
        var _a2;
        return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
      },
      last: () => {
        var _a2;
        return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
      },
      next: (options) => {
        if (options !== void 0 && typeof options === "number") {
          options = { skip: options };
        }
        return getNextId("next", options);
      },
      previous: (options) => {
        if (options !== void 0 && typeof options === "number") {
          options = { skip: options };
        }
        return getNextId("previous", options);
      },
      down: (options) => {
        if (options !== void 0 && typeof options === "number") {
          options = { skip: options };
        }
        return getNextId("down", options);
      },
      up: (options) => {
        if (options !== void 0 && typeof options === "number") {
          options = { skip: options };
        }
        return getNextId("up", options);
      }
    };
  }

  // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
  function useCompositeStoreOptions(props) {
    const id = useId5(props.id);
    return { id, ...props };
  }
  function useCompositeStoreProps(store4, update4, props) {
    store4 = useCollectionStoreProps(store4, update4, props);
    useStoreProps(store4, props, "activeId", "setActiveId");
    useStoreProps(store4, props, "includesBaseElement");
    useStoreProps(store4, props, "virtualFocus");
    useStoreProps(store4, props, "orientation");
    useStoreProps(store4, props, "rtl");
    useStoreProps(store4, props, "focusLoop");
    useStoreProps(store4, props, "focusWrap");
    useStoreProps(store4, props, "focusShift");
    return store4;
  }

  // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
  var import_react24 = __toESM(require_react(), 1);
  var ComboboxListRoleContext = (0, import_react24.createContext)(
    void 0
  );
  var ctx7 = createStoreContext(
    [PopoverContextProvider, CompositeContextProvider],
    [PopoverScopedContextProvider, CompositeScopedContextProvider]
  );
  var useComboboxContext = ctx7.useContext;
  var useComboboxScopedContext = ctx7.useScopedContext;
  var useComboboxProviderContext = ctx7.useProviderContext;
  var ComboboxContextProvider = ctx7.ContextProvider;
  var ComboboxScopedContextProvider = ctx7.ScopedContextProvider;
  var ComboboxItemValueContext = (0, import_react24.createContext)(
    void 0
  );
  var ComboboxItemCheckedContext = (0, import_react24.createContext)(false);

  // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
  function createDialogStore(props = {}) {
    return createDisclosureStore(props);
  }

  // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
  function useDialogStoreProps(store4, update4, props) {
    return useDisclosureStoreProps(store4, update4, props);
  }

  // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
  function createPopoverStore({
    popover: otherPopover,
    ...props
  } = {}) {
    const store4 = mergeStore(
      props.store,
      omit2(otherPopover, [
        "arrowElement",
        "anchorElement",
        "contentElement",
        "popoverElement",
        "disclosureElement"
      ])
    );
    throwOnConflictingProps(props, store4);
    const syncState = store4 == null ? void 0 : store4.getState();
    const dialog = createDialogStore({ ...props, store: store4 });
    const placement = defaultValue(
      props.placement,
      syncState == null ? void 0 : syncState.placement,
      "bottom"
    );
    const initialState = {
      ...dialog.getState(),
      placement,
      currentPlacement: placement,
      anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
      popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
      arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
      rendered: /* @__PURE__ */ Symbol("rendered")
    };
    const popover = createStore(initialState, dialog, store4);
    return {
      ...dialog,
      ...popover,
      setAnchorElement: (element) => popover.setState("anchorElement", element),
      setPopoverElement: (element) => popover.setState("popoverElement", element),
      setArrowElement: (element) => popover.setState("arrowElement", element),
      render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
    };
  }

  // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
  function usePopoverStoreProps(store4, update4, props) {
    useUpdateEffect(update4, [props.popover]);
    useStoreProps(store4, props, "placement");
    return useDialogStoreProps(store4, update4, props);
  }

  // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
  var TagName7 = "div";
  var usePopoverAnchor = createHook(
    function usePopoverAnchor2({ store: store4, ...props }) {
      const context = usePopoverProviderContext();
      store4 = store4 || context;
      props = {
        ...props,
        ref: useMergeRefs(store4 == null ? void 0 : store4.setAnchorElement, props.ref)
      };
      return props;
    }
  );
  var PopoverAnchor = forwardRef27(function PopoverAnchor2(props) {
    const htmlProps = usePopoverAnchor(props);
    return createElement5(TagName7, htmlProps);
  });

  // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
  var import_react25 = __toESM(require_react(), 1);
  var TagName8 = "div";
  function getMouseDestination(event) {
    const relatedTarget = event.relatedTarget;
    if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
      return relatedTarget;
    }
    return null;
  }
  function hoveringInside(event) {
    const nextElement = getMouseDestination(event);
    if (!nextElement) return false;
    return contains(event.currentTarget, nextElement);
  }
  var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
  function movingToAnotherItem(event) {
    let dest = getMouseDestination(event);
    if (!dest) return false;
    do {
      if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
      dest = dest.parentElement;
    } while (dest);
    return false;
  }
  var useCompositeHover = createHook(
    function useCompositeHover2({
      store: store4,
      focusOnHover = true,
      blurOnHoverEnd = !!focusOnHover,
      ...props
    }) {
      const context = useCompositeContext();
      store4 = store4 || context;
      invariant(
        store4,
        "CompositeHover must be wrapped in a Composite component."
      );
      const isMouseMoving = useIsMouseMoving();
      const onMouseMoveProp = props.onMouseMove;
      const focusOnHoverProp = useBooleanEvent(focusOnHover);
      const onMouseMove = useEvent((event) => {
        onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
        if (event.defaultPrevented) return;
        if (!isMouseMoving()) return;
        if (!focusOnHoverProp(event)) return;
        if (!hasFocusWithin(event.currentTarget)) {
          const baseElement = store4 == null ? void 0 : store4.getState().baseElement;
          if (baseElement && !hasFocus(baseElement)) {
            baseElement.focus();
          }
        }
        store4 == null ? void 0 : store4.setActiveId(event.currentTarget.id);
      });
      const onMouseLeaveProp = props.onMouseLeave;
      const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
      const onMouseLeave = useEvent((event) => {
        var _a;
        onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
        if (event.defaultPrevented) return;
        if (!isMouseMoving()) return;
        if (hoveringInside(event)) return;
        if (movingToAnotherItem(event)) return;
        if (!focusOnHoverProp(event)) return;
        if (!blurOnHoverEndProp(event)) return;
        store4 == null ? void 0 : store4.setActiveId(null);
        (_a = store4 == null ? void 0 : store4.getState().baseElement) == null ? void 0 : _a.focus();
      });
      const ref = (0, import_react25.useCallback)((element) => {
        if (!element) return;
        element[symbol2] = true;
      }, []);
      props = {
        ...props,
        ref: useMergeRefs(ref, props.ref),
        onMouseMove,
        onMouseLeave
      };
      return removeUndefinedValues(props);
    }
  );
  var CompositeHover = memo22(
    forwardRef27(function CompositeHover2(props) {
      const htmlProps = useCompositeHover(props);
      return createElement5(TagName8, htmlProps);
    })
  );

  // node_modules/@ariakit/react-core/esm/combobox/combobox.js
  var import_react26 = __toESM(require_react(), 1);
  var TagName9 = "input";
  function isFirstItemAutoSelected(items, activeValue, autoSelect) {
    if (!autoSelect) return false;
    const firstItem = items.find((item) => !item.disabled && item.value);
    return (firstItem == null ? void 0 : firstItem.value) === activeValue;
  }
  function hasCompletionString(value, activeValue) {
    if (!activeValue) return false;
    if (value == null) return false;
    value = normalizeString(value);
    return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
  }
  function isInputEvent(event) {
    return event.type === "input";
  }
  function isAriaAutoCompleteValue(value) {
    return value === "inline" || value === "list" || value === "both" || value === "none";
  }
  function getDefaultAutoSelectId(items) {
    const item = items.find((item2) => {
      var _a;
      if (item2.disabled) return false;
      return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
    });
    return item == null ? void 0 : item.id;
  }
  var useCombobox = createHook(
    function useCombobox2({
      store: store4,
      focusable = true,
      autoSelect: autoSelectProp = false,
      getAutoSelectId,
      setValueOnChange,
      showMinLength = 0,
      showOnChange,
      showOnMouseDown,
      showOnClick = showOnMouseDown,
      showOnKeyDown,
      showOnKeyPress = showOnKeyDown,
      blurActiveItemOnClick,
      setValueOnClick = true,
      moveOnKeyPress = true,
      autoComplete = "list",
      ...props
    }) {
      const context = useComboboxProviderContext();
      store4 = store4 || context;
      invariant(
        store4,
        "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
      );
      const ref = (0, import_react26.useRef)(null);
      const [valueUpdated, forceValueUpdate] = useForceUpdate2();
      const canAutoSelectRef = (0, import_react26.useRef)(false);
      const composingRef = (0, import_react26.useRef)(false);
      const autoSelect = store4.useState(
        (state) => state.virtualFocus && autoSelectProp
      );
      const inline = autoComplete === "inline" || autoComplete === "both";
      const [canInline, setCanInline] = (0, import_react26.useState)(inline);
      useUpdateLayoutEffect(() => {
        if (!inline) return;
        setCanInline(true);
      }, [inline]);
      const storeValue = store4.useState("value");
      const prevSelectedValueRef = (0, import_react26.useRef)(void 0);
      (0, import_react26.useEffect)(() => {
        return sync2(store4, ["selectedValue", "activeId"], (_, prev) => {
          prevSelectedValueRef.current = prev.selectedValue;
        });
      }, []);
      const inlineActiveValue = store4.useState((state) => {
        var _a;
        if (!inline) return;
        if (!canInline) return;
        if (state.activeValue && Array.isArray(state.selectedValue)) {
          if (state.selectedValue.includes(state.activeValue)) return;
          if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
        }
        return state.activeValue;
      });
      const items = store4.useState("renderedItems");
      const open = store4.useState("open");
      const contentElement = store4.useState("contentElement");
      const value = (0, import_react26.useMemo)(() => {
        if (!inline) return storeValue;
        if (!canInline) return storeValue;
        const firstItemAutoSelected = isFirstItemAutoSelected(
          items,
          inlineActiveValue,
          autoSelect
        );
        if (firstItemAutoSelected) {
          if (hasCompletionString(storeValue, inlineActiveValue)) {
            const slice2 = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
            return storeValue + slice2;
          }
          return storeValue;
        }
        return inlineActiveValue || storeValue;
      }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]);
      (0, import_react26.useEffect)(() => {
        const element = ref.current;
        if (!element) return;
        const onCompositeItemMove = () => setCanInline(true);
        element.addEventListener("combobox-item-move", onCompositeItemMove);
        return () => {
          element.removeEventListener("combobox-item-move", onCompositeItemMove);
        };
      }, []);
      (0, import_react26.useEffect)(() => {
        if (!inline) return;
        if (!canInline) return;
        if (!inlineActiveValue) return;
        const firstItemAutoSelected = isFirstItemAutoSelected(
          items,
          inlineActiveValue,
          autoSelect
        );
        if (!firstItemAutoSelected) return;
        if (!hasCompletionString(storeValue, inlineActiveValue)) return;
        let cleanup = noop3;
        queueMicrotask(() => {
          const element = ref.current;
          if (!element) return;
          const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
          const nextStart = storeValue.length;
          const nextEnd = inlineActiveValue.length;
          setSelectionRange(element, nextStart, nextEnd);
          cleanup = () => {
            if (!hasFocus(element)) return;
            const { start: start2, end } = getTextboxSelection(element);
            if (start2 !== nextStart) return;
            if (end !== nextEnd) return;
            setSelectionRange(element, prevStart, prevEnd);
          };
        });
        return () => cleanup();
      }, [
        valueUpdated,
        inline,
        canInline,
        inlineActiveValue,
        items,
        autoSelect,
        storeValue
      ]);
      const scrollingElementRef = (0, import_react26.useRef)(null);
      const getAutoSelectIdProp = useEvent(getAutoSelectId);
      const autoSelectIdRef = (0, import_react26.useRef)(null);
      (0, import_react26.useEffect)(() => {
        if (!open) return;
        if (!contentElement) return;
        const scrollingElement = getScrollingElement(contentElement);
        if (!scrollingElement) return;
        scrollingElementRef.current = scrollingElement;
        const onUserScroll = () => {
          canAutoSelectRef.current = false;
        };
        const onScroll = () => {
          if (!store4) return;
          if (!canAutoSelectRef.current) return;
          const { activeId } = store4.getState();
          if (activeId === null) return;
          if (activeId === autoSelectIdRef.current) return;
          canAutoSelectRef.current = false;
        };
        const options = { passive: true, capture: true };
        scrollingElement.addEventListener("wheel", onUserScroll, options);
        scrollingElement.addEventListener("touchmove", onUserScroll, options);
        scrollingElement.addEventListener("scroll", onScroll, options);
        return () => {
          scrollingElement.removeEventListener("wheel", onUserScroll, true);
          scrollingElement.removeEventListener("touchmove", onUserScroll, true);
          scrollingElement.removeEventListener("scroll", onScroll, true);
        };
      }, [open, contentElement, store4]);
      useSafeLayoutEffect(() => {
        if (!storeValue) return;
        if (composingRef.current) return;
        canAutoSelectRef.current = true;
      }, [storeValue]);
      useSafeLayoutEffect(() => {
        if (autoSelect !== "always" && open) return;
        canAutoSelectRef.current = open;
      }, [autoSelect, open]);
      const resetValueOnSelect = store4.useState("resetValueOnSelect");
      useUpdateEffect(() => {
        var _a, _b;
        const canAutoSelect = canAutoSelectRef.current;
        if (!store4) return;
        if (!open) return;
        if (!canAutoSelect && !resetValueOnSelect) return;
        const { baseElement, contentElement: contentElement2, activeId } = store4.getState();
        if (baseElement && !hasFocus(baseElement)) return;
        if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
          const observer = new MutationObserver(forceValueUpdate);
          observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
          return () => observer.disconnect();
        }
        if (autoSelect && canAutoSelect) {
          const userAutoSelectId = getAutoSelectIdProp(items);
          const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store4.first();
          autoSelectIdRef.current = autoSelectId;
          store4.move(autoSelectId != null ? autoSelectId : null);
        } else {
          const element = (_b = store4.item(activeId || store4.first())) == null ? void 0 : _b.element;
          if (element && "scrollIntoView" in element) {
            element.scrollIntoView({ block: "nearest", inline: "nearest" });
          }
        }
        return;
      }, [
        store4,
        open,
        valueUpdated,
        storeValue,
        autoSelect,
        resetValueOnSelect,
        getAutoSelectIdProp,
        items
      ]);
      (0, import_react26.useEffect)(() => {
        if (!inline) return;
        const combobox = ref.current;
        if (!combobox) return;
        const elements2 = [combobox, contentElement].filter(
          (value2) => !!value2
        );
        const onBlur2 = (event) => {
          if (elements2.every((el) => isFocusEventOutside(event, el))) {
            store4 == null ? void 0 : store4.setValue(value);
          }
        };
        for (const element of elements2) {
          element.addEventListener("focusout", onBlur2);
        }
        return () => {
          for (const element of elements2) {
            element.removeEventListener("focusout", onBlur2);
          }
        };
      }, [inline, contentElement, store4, value]);
      const canShow = (event) => {
        const currentTarget = event.currentTarget;
        return currentTarget.value.length >= showMinLength;
      };
      const onChangeProp = props.onChange;
      const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
      const setValueOnChangeProp = useBooleanEvent(
        // If the combobox is combined with tags, the value will be set by the tag
        // input component.
        setValueOnChange != null ? setValueOnChange : !store4.tag
      );
      const onChange = useEvent((event) => {
        onChangeProp == null ? void 0 : onChangeProp(event);
        if (event.defaultPrevented) return;
        if (!store4) return;
        const currentTarget = event.currentTarget;
        const { value: value2, selectionStart, selectionEnd } = currentTarget;
        const nativeEvent = event.nativeEvent;
        canAutoSelectRef.current = true;
        if (isInputEvent(nativeEvent)) {
          if (nativeEvent.isComposing) {
            canAutoSelectRef.current = false;
            composingRef.current = true;
          }
          if (inline) {
            const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
            const caretAtEnd = selectionStart === value2.length;
            setCanInline(textInserted && caretAtEnd);
          }
        }
        if (setValueOnChangeProp(event)) {
          const isSameValue = value2 === store4.getState().value;
          store4.setValue(value2);
          queueMicrotask(() => {
            setSelectionRange(currentTarget, selectionStart, selectionEnd);
          });
          if (inline && autoSelect && isSameValue) {
            forceValueUpdate();
          }
        }
        if (showOnChangeProp(event)) {
          store4.show();
        }
        if (!autoSelect || !canAutoSelectRef.current) {
          store4.setActiveId(null);
        }
      });
      const onCompositionEndProp = props.onCompositionEnd;
      const onCompositionEnd = useEvent((event) => {
        canAutoSelectRef.current = true;
        composingRef.current = false;
        onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
        if (event.defaultPrevented) return;
        if (!autoSelect) return;
        forceValueUpdate();
      });
      const onMouseDownProp = props.onMouseDown;
      const blurActiveItemOnClickProp = useBooleanEvent(
        blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store4 == null ? void 0 : store4.getState().includesBaseElement))
      );
      const setValueOnClickProp = useBooleanEvent(setValueOnClick);
      const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
      const onMouseDown = useEvent((event) => {
        onMouseDownProp == null ? void 0 : onMouseDownProp(event);
        if (event.defaultPrevented) return;
        if (event.button) return;
        if (event.ctrlKey) return;
        if (!store4) return;
        if (blurActiveItemOnClickProp(event)) {
          store4.setActiveId(null);
        }
        if (setValueOnClickProp(event)) {
          store4.setValue(value);
        }
        if (showOnClickProp(event)) {
          queueBeforeEvent(event.currentTarget, "mouseup", store4.show);
        }
      });
      const onKeyDownProp = props.onKeyDown;
      const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
      const onKeyDown = useEvent((event) => {
        onKeyDownProp == null ? void 0 : onKeyDownProp(event);
        if (!event.repeat) {
          canAutoSelectRef.current = false;
        }
        if (event.defaultPrevented) return;
        if (event.ctrlKey) return;
        if (event.altKey) return;
        if (event.shiftKey) return;
        if (event.metaKey) return;
        if (!store4) return;
        const { open: open2 } = store4.getState();
        if (open2) return;
        if (event.key === "ArrowUp" || event.key === "ArrowDown") {
          if (showOnKeyPressProp(event)) {
            event.preventDefault();
            store4.show();
          }
        }
      });
      const onBlurProp = props.onBlur;
      const onBlur = useEvent((event) => {
        canAutoSelectRef.current = false;
        onBlurProp == null ? void 0 : onBlurProp(event);
        if (event.defaultPrevented) return;
      });
      const id = useId5(props.id);
      const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
      const isActiveItem = store4.useState((state) => state.activeId === null);
      props = {
        id,
        role: "combobox",
        "aria-autocomplete": ariaAutoComplete,
        "aria-haspopup": getPopupRole(contentElement, "listbox"),
        "aria-expanded": open,
        "aria-controls": contentElement == null ? void 0 : contentElement.id,
        "data-active-item": isActiveItem || void 0,
        value,
        ...props,
        ref: useMergeRefs(ref, props.ref),
        onChange,
        onCompositionEnd,
        onMouseDown,
        onKeyDown,
        onBlur
      };
      props = useComposite({
        store: store4,
        focusable,
        ...props,
        // Enable inline autocomplete when the user moves from the combobox input
        // to an item.
        moveOnKeyPress: (event) => {
          if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
          if (inline) setCanInline(true);
          return true;
        }
      });
      props = usePopoverAnchor({ store: store4, ...props });
      return { autoComplete: "off", ...props };
    }
  );
  var Combobox = forwardRef27(function Combobox2(props) {
    const htmlProps = useCombobox(props);
    return createElement5(TagName9, htmlProps);
  });

  // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
  var import_react27 = __toESM(require_react(), 1);
  var import_jsx_runtime166 = __toESM(require_jsx_runtime(), 1);
  var TagName10 = "div";
  function isSelected(storeValue, itemValue) {
    if (itemValue == null) return;
    if (storeValue == null) return false;
    if (Array.isArray(storeValue)) {
      return storeValue.includes(itemValue);
    }
    return storeValue === itemValue;
  }
  function getItemRole(popupRole) {
    var _a;
    const itemRoleByPopupRole = {
      menu: "menuitem",
      listbox: "option",
      tree: "treeitem"
    };
    const key = popupRole;
    return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
  }
  var useComboboxItem = createHook(
    function useComboboxItem2({
      store: store4,
      value,
      hideOnClick,
      setValueOnClick,
      selectValueOnClick = true,
      resetValueOnSelect,
      focusOnHover = false,
      moveOnKeyPress = true,
      getItem: getItemProp,
      ...props
    }) {
      var _a;
      const context = useComboboxScopedContext();
      store4 = store4 || context;
      invariant(
        store4,
        "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
      );
      const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store4, {
        resetValueOnSelectState: "resetValueOnSelect",
        multiSelectable(state) {
          return Array.isArray(state.selectedValue);
        },
        selected(state) {
          return isSelected(state.selectedValue, value);
        }
      });
      const getItem = (0, import_react27.useCallback)(
        (item) => {
          const nextItem = { ...item, value };
          if (getItemProp) {
            return getItemProp(nextItem);
          }
          return nextItem;
        },
        [value, getItemProp]
      );
      setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
      hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
      const onClickProp = props.onClick;
      const setValueOnClickProp = useBooleanEvent(setValueOnClick);
      const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
      const resetValueOnSelectProp = useBooleanEvent(
        (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
      );
      const hideOnClickProp = useBooleanEvent(hideOnClick);
      const onClick = useEvent((event) => {
        onClickProp == null ? void 0 : onClickProp(event);
        if (event.defaultPrevented) return;
        if (isDownloading(event)) return;
        if (isOpeningInNewTab(event)) return;
        if (value != null) {
          if (selectValueOnClickProp(event)) {
            if (resetValueOnSelectProp(event)) {
              store4 == null ? void 0 : store4.resetValue();
            }
            store4 == null ? void 0 : store4.setSelectedValue((prevValue) => {
              if (!Array.isArray(prevValue)) return value;
              if (prevValue.includes(value)) {
                return prevValue.filter((v3) => v3 !== value);
              }
              return [...prevValue, value];
            });
          }
          if (setValueOnClickProp(event)) {
            store4 == null ? void 0 : store4.setValue(value);
          }
        }
        if (hideOnClickProp(event)) {
          store4 == null ? void 0 : store4.hide();
        }
      });
      const onKeyDownProp = props.onKeyDown;
      const onKeyDown = useEvent((event) => {
        onKeyDownProp == null ? void 0 : onKeyDownProp(event);
        if (event.defaultPrevented) return;
        const baseElement = store4 == null ? void 0 : store4.getState().baseElement;
        if (!baseElement) return;
        if (hasFocus(baseElement)) return;
        const printable = event.key.length === 1;
        if (printable || event.key === "Backspace" || event.key === "Delete") {
          queueMicrotask(() => baseElement.focus());
          if (isTextField(baseElement)) {
            store4 == null ? void 0 : store4.setValue(baseElement.value);
          }
        }
      });
      if (multiSelectable && selected != null) {
        props = {
          "aria-selected": selected,
          ...props
        };
      }
      props = useWrapElement(
        props,
        (element) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
        [value, selected]
      );
      const popupRole = (0, import_react27.useContext)(ComboboxListRoleContext);
      props = {
        role: getItemRole(popupRole),
        children: value,
        ...props,
        onClick,
        onKeyDown
      };
      const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
      props = useCompositeItem({
        store: store4,
        ...props,
        getItem,
        // Dispatch a custom event on the combobox input when moving to an item
        // with the keyboard so the Combobox component can enable inline
        // autocompletion.
        moveOnKeyPress: (event) => {
          if (!moveOnKeyPressProp(event)) return false;
          const moveEvent = new Event("combobox-item-move");
          const baseElement = store4 == null ? void 0 : store4.getState().baseElement;
          baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
          return true;
        }
      });
      props = useCompositeHover({ store: store4, focusOnHover, ...props });
      return props;
    }
  );
  var ComboboxItem = memo22(
    forwardRef27(function ComboboxItem2(props) {
      const htmlProps = useComboboxItem(props);
      return createElement5(TagName10, htmlProps);
    })
  );

  // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
  var import_react28 = __toESM(require_react(), 1);
  var import_jsx_runtime167 = __toESM(require_jsx_runtime(), 1);
  var TagName11 = "span";
  function normalizeValue2(value) {
    return normalizeString(value).toLowerCase();
  }
  function getOffsets(string, values) {
    const offsets = [];
    for (const value of values) {
      let pos = 0;
      const length2 = value.length;
      while (string.indexOf(value, pos) !== -1) {
        const index = string.indexOf(value, pos);
        if (index !== -1) {
          offsets.push([index, length2]);
        }
        pos = index + 1;
      }
    }
    return offsets;
  }
  function filterOverlappingOffsets(offsets) {
    return offsets.filter(([offset, length2], i3, arr) => {
      return !arr.some(
        ([o4, l3], j2) => j2 !== i3 && o4 <= offset && o4 + l3 >= offset + length2
      );
    });
  }
  function sortOffsets(offsets) {
    return offsets.sort(([a3], [b3]) => a3 - b3);
  }
  function splitValue(itemValue, userValue) {
    if (!itemValue) return itemValue;
    if (!userValue) return itemValue;
    const userValues = toArray2(userValue).filter(Boolean).map(normalizeValue2);
    const parts = [];
    const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
      "span",
      {
        "data-autocomplete-value": autocomplete ? "" : void 0,
        "data-user-value": autocomplete ? void 0 : "",
        children: value
      },
      parts.length
    );
    const offsets = sortOffsets(
      filterOverlappingOffsets(
        // Convert userValues into a set to avoid duplicates
        getOffsets(normalizeValue2(itemValue), new Set(userValues))
      )
    );
    if (!offsets.length) {
      parts.push(span(itemValue, true));
      return parts;
    }
    const [firstOffset] = offsets[0];
    const values = [
      itemValue.slice(0, firstOffset),
      ...offsets.flatMap(([offset, length2], i3) => {
        var _a;
        const value = itemValue.slice(offset, offset + length2);
        const nextOffset = (_a = offsets[i3 + 1]) == null ? void 0 : _a[0];
        const nextValue = itemValue.slice(offset + length2, nextOffset);
        return [value, nextValue];
      })
    ];
    values.forEach((value, i3) => {
      if (!value) return;
      parts.push(span(value, i3 % 2 === 0));
    });
    return parts;
  }
  var useComboboxItemValue = createHook(function useComboboxItemValue2({ store: store4, value, userValue, ...props }) {
    const context = useComboboxScopedContext();
    store4 = store4 || context;
    const itemContext = (0, import_react28.useContext)(ComboboxItemValueContext);
    const itemValue = value != null ? value : itemContext;
    const inputValue = useStoreState(store4, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
    const children = (0, import_react28.useMemo)(() => {
      if (!itemValue) return;
      if (!inputValue) return itemValue;
      return splitValue(itemValue, inputValue);
    }, [itemValue, inputValue]);
    props = {
      children,
      ...props
    };
    return removeUndefinedValues(props);
  });
  var ComboboxItemValue = forwardRef27(function ComboboxItemValue2(props) {
    const htmlProps = useComboboxItemValue(props);
    return createElement5(TagName11, htmlProps);
  });

  // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
  var TagName12 = "label";
  var useComboboxLabel = createHook(
    function useComboboxLabel2({ store: store4, ...props }) {
      const context = useComboboxProviderContext();
      store4 = store4 || context;
      invariant(
        store4,
        "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
      );
      const comboboxId = store4.useState((state) => {
        var _a;
        return (_a = state.baseElement) == null ? void 0 : _a.id;
      });
      props = {
        htmlFor: comboboxId,
        ...props
      };
      return removeUndefinedValues(props);
    }
  );
  var ComboboxLabel = memo22(
    forwardRef27(function ComboboxLabel2(props) {
      const htmlProps = useComboboxLabel(props);
      return createElement5(TagName12, htmlProps);
    })
  );

  // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
  var import_react29 = __toESM(require_react(), 1);
  var import_jsx_runtime168 = __toESM(require_jsx_runtime(), 1);
  var TagName13 = "div";
  var useComboboxList = createHook(
    function useComboboxList2({ store: store4, alwaysVisible, ...props }) {
      const scopedContext = useComboboxScopedContext(true);
      const context = useComboboxContext();
      store4 = store4 || context;
      const scopedContextSameStore = !!store4 && store4 === scopedContext;
      invariant(
        store4,
        "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
      );
      const ref = (0, import_react29.useRef)(null);
      const id = useId5(props.id);
      const mounted = store4.useState("mounted");
      const hidden = isHidden(mounted, props.hidden, alwaysVisible);
      const style = hidden ? { ...props.style, display: "none" } : props.style;
      const multiSelectable = store4.useState(
        (state) => Array.isArray(state.selectedValue)
      );
      const role = useAttribute(ref, "role", props.role);
      const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
      const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
      const [hasListboxInside, setHasListboxInside] = (0, import_react29.useState)(false);
      const contentElement = store4.useState("contentElement");
      useSafeLayoutEffect(() => {
        if (!mounted) return;
        const element = ref.current;
        if (!element) return;
        if (contentElement !== element) return;
        const callback = () => {
          setHasListboxInside(!!element.querySelector("[role='listbox']"));
        };
        const observer = new MutationObserver(callback);
        observer.observe(element, {
          subtree: true,
          childList: true,
          attributeFilter: ["role"]
        });
        callback();
        return () => observer.disconnect();
      }, [mounted, contentElement]);
      if (!hasListboxInside) {
        props = {
          role: "listbox",
          "aria-multiselectable": ariaMultiSelectable,
          ...props
        };
      }
      props = useWrapElement(
        props,
        (element) => /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(ComboboxScopedContextProvider, { value: store4, children: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
        [store4, role]
      );
      const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store4.setContentElement : null;
      props = {
        id,
        hidden,
        ...props,
        ref: useMergeRefs(setContentElement, ref, props.ref),
        style
      };
      return removeUndefinedValues(props);
    }
  );
  var ComboboxList = forwardRef27(function ComboboxList2(props) {
    const htmlProps = useComboboxList(props);
    return createElement5(TagName13, htmlProps);
  });

  // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
  var import_react30 = __toESM(require_react(), 1);
  var TagValueContext = (0, import_react30.createContext)(null);
  var TagRemoveIdContext = (0, import_react30.createContext)(
    null
  );
  var ctx8 = createStoreContext(
    [CompositeContextProvider],
    [CompositeScopedContextProvider]
  );
  var useTagContext = ctx8.useContext;
  var useTagScopedContext = ctx8.useScopedContext;
  var useTagProviderContext = ctx8.useProviderContext;
  var TagContextProvider = ctx8.ContextProvider;
  var TagScopedContextProvider = ctx8.ScopedContextProvider;

  // node_modules/@ariakit/core/esm/combobox/combobox-store.js
  var isTouchSafari = isSafari() && isTouchDevice();
  function createComboboxStore({
    tag,
    ...props
  } = {}) {
    const store4 = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
    throwOnConflictingProps(props, store4);
    const tagState = tag == null ? void 0 : tag.getState();
    const syncState = store4 == null ? void 0 : store4.getState();
    const activeId = defaultValue(
      props.activeId,
      syncState == null ? void 0 : syncState.activeId,
      props.defaultActiveId,
      null
    );
    const composite = createCompositeStore({
      ...props,
      activeId,
      includesBaseElement: defaultValue(
        props.includesBaseElement,
        syncState == null ? void 0 : syncState.includesBaseElement,
        true
      ),
      orientation: defaultValue(
        props.orientation,
        syncState == null ? void 0 : syncState.orientation,
        "vertical"
      ),
      focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
      focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
      virtualFocus: defaultValue(
        props.virtualFocus,
        syncState == null ? void 0 : syncState.virtualFocus,
        true
      )
    });
    const popover = createPopoverStore({
      ...props,
      placement: defaultValue(
        props.placement,
        syncState == null ? void 0 : syncState.placement,
        "bottom-start"
      )
    });
    const value = defaultValue(
      props.value,
      syncState == null ? void 0 : syncState.value,
      props.defaultValue,
      ""
    );
    const selectedValue = defaultValue(
      props.selectedValue,
      syncState == null ? void 0 : syncState.selectedValue,
      tagState == null ? void 0 : tagState.values,
      props.defaultSelectedValue,
      ""
    );
    const multiSelectable = Array.isArray(selectedValue);
    const initialState = {
      ...composite.getState(),
      ...popover.getState(),
      value,
      selectedValue,
      resetValueOnSelect: defaultValue(
        props.resetValueOnSelect,
        syncState == null ? void 0 : syncState.resetValueOnSelect,
        multiSelectable
      ),
      resetValueOnHide: defaultValue(
        props.resetValueOnHide,
        syncState == null ? void 0 : syncState.resetValueOnHide,
        multiSelectable && !tag
      ),
      activeValue: syncState == null ? void 0 : syncState.activeValue
    };
    const combobox = createStore(initialState, composite, popover, store4);
    if (isTouchSafari) {
      setup(
        combobox,
        () => sync2(combobox, ["virtualFocus"], () => {
          combobox.setState("virtualFocus", false);
        })
      );
    }
    setup(combobox, () => {
      if (!tag) return;
      return chain(
        sync2(combobox, ["selectedValue"], (state) => {
          if (!Array.isArray(state.selectedValue)) return;
          tag.setValues(state.selectedValue);
        }),
        sync2(tag, ["values"], (state) => {
          combobox.setState("selectedValue", state.values);
        })
      );
    });
    setup(
      combobox,
      () => sync2(combobox, ["resetValueOnHide", "mounted"], (state) => {
        if (!state.resetValueOnHide) return;
        if (state.mounted) return;
        combobox.setState("value", value);
      })
    );
    setup(
      combobox,
      () => sync2(combobox, ["open"], (state) => {
        if (state.open) return;
        combobox.setState("activeId", activeId);
        combobox.setState("moves", 0);
      })
    );
    setup(
      combobox,
      () => sync2(combobox, ["moves", "activeId"], (state, prevState) => {
        if (state.moves === prevState.moves) {
          combobox.setState("activeValue", void 0);
        }
      })
    );
    setup(
      combobox,
      () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
        if (state.moves === prev.moves) return;
        const { activeId: activeId2 } = combobox.getState();
        const activeItem = composite.item(activeId2);
        combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
      })
    );
    return {
      ...popover,
      ...composite,
      ...combobox,
      tag,
      setValue: (value2) => combobox.setState("value", value2),
      resetValue: () => combobox.setState("value", initialState.value),
      setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
    };
  }

  // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
  function useComboboxStoreOptions(props) {
    const tag = useTagContext();
    props = {
      ...props,
      tag: props.tag !== void 0 ? props.tag : tag
    };
    return useCompositeStoreOptions(props);
  }
  function useComboboxStoreProps(store4, update4, props) {
    useUpdateEffect(update4, [props.tag]);
    useStoreProps(store4, props, "value", "setValue");
    useStoreProps(store4, props, "selectedValue", "setSelectedValue");
    useStoreProps(store4, props, "resetValueOnHide");
    useStoreProps(store4, props, "resetValueOnSelect");
    return Object.assign(
      useCompositeStoreProps(
        usePopoverStoreProps(store4, update4, props),
        update4,
        props
      ),
      { tag: props.tag }
    );
  }
  function useComboboxStore(props = {}) {
    props = useComboboxStoreOptions(props);
    const [store4, update4] = useStore(createComboboxStore, props);
    return useComboboxStoreProps(store4, update4, props);
  }

  // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
  var import_jsx_runtime169 = __toESM(require_jsx_runtime(), 1);
  function ComboboxProvider(props = {}) {
    const store4 = useComboboxStore(props);
    return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(ComboboxContextProvider, { value: store4, children: props.children });
  }

  // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
  var import_remove_accents2 = __toESM(require_remove_accents(), 1);
  var import_compose12 = __toESM(require_compose(), 1);
  var import_i18n89 = __toESM(require_i18n(), 1);
  var import_element70 = __toESM(require_element(), 1);
  var import_components46 = __toESM(require_components(), 1);

  // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
  var EMPTY_ARRAY4 = [];
  var getCurrentValue = (filterDefinition, currentFilter) => {
    if (filterDefinition.singleSelection) {
      return currentFilter?.value;
    }
    if (Array.isArray(currentFilter?.value)) {
      return currentFilter.value;
    }
    if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
      return [currentFilter.value];
    }
    return EMPTY_ARRAY4;
  };

  // packages/dataviews/build-module/hooks/use-elements.mjs
  var import_element69 = __toESM(require_element(), 1);
  var EMPTY_ARRAY5 = [];
  function useElements({
    elements: elements2,
    getElements
  }) {
    const staticElements = Array.isArray(elements2) && elements2.length > 0 ? elements2 : EMPTY_ARRAY5;
    const [records, setRecords] = (0, import_element69.useState)(staticElements);
    const [isLoading, setIsLoading] = (0, import_element69.useState)(false);
    (0, import_element69.useEffect)(() => {
      if (!getElements) {
        setRecords(staticElements);
        return;
      }
      let cancelled = false;
      setIsLoading(true);
      getElements().then((fetchedElements) => {
        if (!cancelled) {
          const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
          setRecords(dynamicElements);
        }
      }).catch(() => {
        if (!cancelled) {
          setRecords(staticElements);
        }
      }).finally(() => {
        if (!cancelled) {
          setIsLoading(false);
        }
      });
      return () => {
        cancelled = true;
      };
    }, [getElements, staticElements]);
    return {
      elements: records,
      isLoading
    };
  }

  // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
  var import_jsx_runtime170 = __toESM(require_jsx_runtime(), 1);
  function normalizeSearchInput(input = "") {
    return (0, import_remove_accents2.default)(input.trim().toLowerCase());
  }
  var getNewValue = (filterDefinition, currentFilter, value) => {
    if (filterDefinition.singleSelection) {
      return value;
    }
    if (Array.isArray(currentFilter?.value)) {
      return currentFilter.value.includes(value) ? currentFilter.value.filter((v3) => v3 !== value) : [...currentFilter.value, value];
    }
    return [value];
  };
  function generateFilterElementCompositeItemId(prefix2, filterElementValue) {
    return `${prefix2}-${filterElementValue}`;
  }
  var MultiSelectionOption = ({ selected }) => {
    return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
      "span",
      {
        className: clsx_default(
          "dataviews-filters__search-widget-listitem-multi-selection",
          { "is-selected": selected }
        ),
        children: selected && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_components46.Icon, { icon: check_default })
      }
    );
  };
  var SingleSelectionOption = ({ selected }) => {
    return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
      "span",
      {
        className: clsx_default(
          "dataviews-filters__search-widget-listitem-single-selection",
          { "is-selected": selected }
        )
      }
    );
  };
  function ListBox({ view: view2, filter, onChangeView }) {
    const baseId = (0, import_compose12.useInstanceId)(ListBox, "dataviews-filter-list-box");
    const [activeCompositeId, setActiveCompositeId] = (0, import_element70.useState)(
      // When there are one or less operators, the first item is set as active
      // (by setting the initial `activeId` to `undefined`).
      // With 2 or more operators, the focus is moved on the operators control
      // (by setting the initial `activeId` to `null`), meaning that there won't
      // be an active item initially. Focus is then managed via the
      // `onFocusVisible` callback.
      filter.operators?.length === 1 ? void 0 : null
    );
    const currentFilter = view2.filters?.find(
      (f3) => f3.field === filter.field
    );
    const currentValue = getCurrentValue(filter, currentFilter);
    return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
      import_components46.Composite,
      {
        virtualFocus: true,
        focusLoop: true,
        activeId: activeCompositeId,
        setActiveId: setActiveCompositeId,
        role: "listbox",
        className: "dataviews-filters__search-widget-listbox",
        "aria-label": (0, import_i18n89.sprintf)(
          /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
          (0, import_i18n89.__)("List of: %1$s"),
          filter.name
        ),
        onFocusVisible: () => {
          if (!activeCompositeId && filter.elements.length) {
            setActiveCompositeId(
              generateFilterElementCompositeItemId(
                baseId,
                filter.elements[0].value
              )
            );
          }
        },
        render: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_components46.Composite.Typeahead, {}),
        children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(
          import_components46.Composite.Hover,
          {
            render: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
              import_components46.Composite.Item,
              {
                id: generateFilterElementCompositeItemId(
                  baseId,
                  element.value
                ),
                render: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
                  "div",
                  {
                    "aria-label": element.label,
                    role: "option",
                    className: "dataviews-filters__search-widget-listitem"
                  }
                ),
                onClick: () => {
                  const newFilters = currentFilter ? [
                    ...(view2.filters ?? []).map(
                      (_filter) => {
                        if (_filter.field === filter.field) {
                          return {
                            ..._filter,
                            operator: currentFilter.operator || filter.operators[0],
                            value: getNewValue(
                              filter,
                              currentFilter,
                              element.value
                            )
                          };
                        }
                        return _filter;
                      }
                    )
                  ] : [
                    ...view2.filters ?? [],
                    {
                      field: filter.field,
                      operator: filter.operators[0],
                      value: getNewValue(
                        filter,
                        currentFilter,
                        element.value
                      )
                    }
                  ];
                  onChangeView({
                    ...view2,
                    page: 1,
                    filters: newFilters
                  });
                }
              }
            ),
            children: [
              filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
                SingleSelectionOption,
                {
                  selected: currentValue === element.value
                }
              ),
              !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
                MultiSelectionOption,
                {
                  selected: currentValue.includes(element.value)
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
                "span",
                {
                  className: "dataviews-filters__search-widget-listitem-value",
                  title: element.label,
                  children: element.label
                }
              )
            ]
          },
          element.value
        ))
      }
    );
  }
  function ComboboxList22({ view: view2, filter, onChangeView }) {
    const [searchValue, setSearchValue] = (0, import_element70.useState)("");
    const deferredSearchValue = (0, import_element70.useDeferredValue)(searchValue);
    const currentFilter = view2.filters?.find(
      (_filter) => _filter.field === filter.field
    );
    const currentValue = getCurrentValue(filter, currentFilter);
    const matches = (0, import_element70.useMemo)(() => {
      const normalizedSearch = normalizeSearchInput(deferredSearchValue);
      return filter.elements.filter(
        (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
      );
    }, [filter.elements, deferredSearchValue]);
    return /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(
      ComboboxProvider,
      {
        selectedValue: currentValue,
        setSelectedValue: (value) => {
          const newFilters = currentFilter ? [
            ...(view2.filters ?? []).map((_filter) => {
              if (_filter.field === filter.field) {
                return {
                  ..._filter,
                  operator: currentFilter.operator || filter.operators[0],
                  value
                };
              }
              return _filter;
            })
          ] : [
            ...view2.filters ?? [],
            {
              field: filter.field,
              operator: filter.operators[0],
              value
            }
          ];
          onChangeView({
            ...view2,
            page: 1,
            filters: newFilters
          });
        },
        setValue: setSearchValue,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
            /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(ComboboxLabel, {}), children: (0, import_i18n89.__)("Search items") }),
            /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
              Combobox,
              {
                autoSelect: "always",
                placeholder: (0, import_i18n89.__)("Search"),
                className: "dataviews-filters__search-widget-filter-combobox__input"
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_components46.Icon, { icon: search_default }) })
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(
            ComboboxList,
            {
              className: "dataviews-filters__search-widget-filter-combobox-list",
              alwaysVisible: true,
              children: [
                matches.map((element) => {
                  return /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(
                    ComboboxItem,
                    {
                      resetValueOnSelect: false,
                      value: element.value,
                      className: "dataviews-filters__search-widget-listitem",
                      hideOnClick: false,
                      setValueOnClick: false,
                      focusOnHover: true,
                      children: [
                        filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
                          SingleSelectionOption,
                          {
                            selected: currentValue === element.value
                          }
                        ),
                        !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
                          MultiSelectionOption,
                          {
                            selected: currentValue.includes(
                              element.value
                            )
                          }
                        ),
                        /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(
                          "span",
                          {
                            className: "dataviews-filters__search-widget-listitem-value",
                            title: element.label,
                            children: [
                              /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
                                ComboboxItemValue,
                                {
                                  className: "dataviews-filters__search-widget-filter-combobox-item-value",
                                  value: element.label
                                }
                              ),
                              !!element.description && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
                            ]
                          }
                        )
                      ]
                    },
                    element.value
                  );
                }),
                !matches.length && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("p", { children: (0, import_i18n89.__)("No results found") })
              ]
            }
          )
        ]
      }
    );
  }
  function SearchWidget(props) {
    const { elements: elements2, isLoading } = useElements({
      elements: props.filter.elements,
      getElements: props.filter.getElements
    });
    if (isLoading) {
      return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_components46.Spinner, {}) });
    }
    if (elements2.length === 0) {
      return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n89.__)("No elements found") });
    }
    const Widget = elements2.length > 10 ? ComboboxList22 : ListBox;
    return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(Widget, { ...props, filter: { ...props.filter, elements: elements2 } });
  }

  // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
  var import_es6 = __toESM(require_es6(), 1);
  var import_compose13 = __toESM(require_compose(), 1);
  var import_element71 = __toESM(require_element(), 1);
  var import_components47 = __toESM(require_components(), 1);
  var import_jsx_runtime171 = __toESM(require_jsx_runtime(), 1);
  function InputWidget({
    filter,
    view: view2,
    onChangeView,
    fields: fields3
  }) {
    const currentFilter = view2.filters?.find(
      (f3) => f3.field === filter.field
    );
    const currentValue = getCurrentValue(filter, currentFilter);
    const field = (0, import_element71.useMemo)(() => {
      const currentField = fields3.find((f3) => f3.id === filter.field);
      if (currentField) {
        return {
          ...currentField,
          // Deactivate validation for filters.
          isValid: {},
          // Filter controls are always enabled.
          isDisabled: () => false,
          // Filter controls are always visible.
          isVisible: () => true,
          // Configure getValue/setValue as if Item was a plain object.
          getValue: ({ item }) => item[currentField.id],
          setValue: ({ value }) => ({
            [currentField.id]: value
          })
        };
      }
      return currentField;
    }, [fields3, filter.field]);
    const data = (0, import_element71.useMemo)(() => {
      return (view2.filters ?? []).reduce(
        (acc, activeFilter) => {
          acc[activeFilter.field] = activeFilter.value;
          return acc;
        },
        {}
      );
    }, [view2.filters]);
    const handleChange = (0, import_compose13.useEvent)((updatedData) => {
      if (!field || !currentFilter) {
        return;
      }
      const nextValue = field.getValue({ item: updatedData });
      if ((0, import_es6.default)(nextValue, currentValue)) {
        return;
      }
      onChangeView({
        ...view2,
        filters: (view2.filters ?? []).map(
          (_filter) => _filter.field === filter.field ? {
            ..._filter,
            operator: currentFilter.operator || filter.operators[0],
            // Consider empty strings as undefined:
            //
            // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
            // - empty string as value means "search empty string": returns only the records that have an empty string as value
            //
            // In practice, this means the filter will not be able to find an empty string as the value.
            value: nextValue === "" ? void 0 : nextValue
          } : _filter
        )
      });
    });
    if (!field || !field.Edit || !currentFilter) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
      import_components47.Flex,
      {
        className: "dataviews-filters__user-input-widget",
        gap: 2.5,
        direction: "column",
        children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
          field.Edit,
          {
            hideLabelFromVision: true,
            data,
            field,
            operator: currentFilter.operator,
            onChange: handleChange
          }
        )
      }
    );
  }

  // packages/dataviews/node_modules/date-fns/constants.js
  var daysInYear = 365.2425;
  var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
  var minTime = -maxTime;
  var millisecondsInWeek = 6048e5;
  var millisecondsInDay = 864e5;
  var secondsInHour = 3600;
  var secondsInDay = secondsInHour * 24;
  var secondsInWeek = secondsInDay * 7;
  var secondsInYear = secondsInDay * daysInYear;
  var secondsInMonth = secondsInYear / 12;
  var secondsInQuarter = secondsInMonth * 3;
  var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");

  // packages/dataviews/node_modules/date-fns/constructFrom.js
  function constructFrom(date, value) {
    if (typeof date === "function") return date(value);
    if (date && typeof date === "object" && constructFromSymbol in date)
      return date[constructFromSymbol](value);
    if (date instanceof Date) return new date.constructor(value);
    return new Date(value);
  }

  // packages/dataviews/node_modules/date-fns/toDate.js
  function toDate(argument, context) {
    return constructFrom(context || argument, argument);
  }

  // packages/dataviews/node_modules/date-fns/addDays.js
  function addDays(date, amount, options) {
    const _date = toDate(date, options?.in);
    if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
    if (!amount) return _date;
    _date.setDate(_date.getDate() + amount);
    return _date;
  }

  // packages/dataviews/node_modules/date-fns/addMonths.js
  function addMonths(date, amount, options) {
    const _date = toDate(date, options?.in);
    if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
    if (!amount) {
      return _date;
    }
    const dayOfMonth = _date.getDate();
    const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
    endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
    const daysInMonth = endOfDesiredMonth.getDate();
    if (dayOfMonth >= daysInMonth) {
      return endOfDesiredMonth;
    } else {
      _date.setFullYear(
        endOfDesiredMonth.getFullYear(),
        endOfDesiredMonth.getMonth(),
        dayOfMonth
      );
      return _date;
    }
  }

  // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
  var defaultOptions = {};
  function getDefaultOptions() {
    return defaultOptions;
  }

  // packages/dataviews/node_modules/date-fns/startOfWeek.js
  function startOfWeek(date, options) {
    const defaultOptions2 = getDefaultOptions();
    const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
    const _date = toDate(date, options?.in);
    const day = _date.getDay();
    const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
    _date.setDate(_date.getDate() - diff);
    _date.setHours(0, 0, 0, 0);
    return _date;
  }

  // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
  function startOfISOWeek(date, options) {
    return startOfWeek(date, { ...options, weekStartsOn: 1 });
  }

  // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
  function getISOWeekYear(date, options) {
    const _date = toDate(date, options?.in);
    const year = _date.getFullYear();
    const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
    fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
    fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
    const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
    const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
    fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
    fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
    const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
    if (_date.getTime() >= startOfNextYear.getTime()) {
      return year + 1;
    } else if (_date.getTime() >= startOfThisYear.getTime()) {
      return year;
    } else {
      return year - 1;
    }
  }

  // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
  function getTimezoneOffsetInMilliseconds(date) {
    const _date = toDate(date);
    const utcDate = new Date(
      Date.UTC(
        _date.getFullYear(),
        _date.getMonth(),
        _date.getDate(),
        _date.getHours(),
        _date.getMinutes(),
        _date.getSeconds(),
        _date.getMilliseconds()
      )
    );
    utcDate.setUTCFullYear(_date.getFullYear());
    return +date - +utcDate;
  }

  // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
  function normalizeDates(context, ...dates) {
    const normalize2 = constructFrom.bind(
      null,
      context || dates.find((date) => typeof date === "object")
    );
    return dates.map(normalize2);
  }

  // packages/dataviews/node_modules/date-fns/startOfDay.js
  function startOfDay(date, options) {
    const _date = toDate(date, options?.in);
    _date.setHours(0, 0, 0, 0);
    return _date;
  }

  // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
  function differenceInCalendarDays(laterDate, earlierDate, options) {
    const [laterDate_, earlierDate_] = normalizeDates(
      options?.in,
      laterDate,
      earlierDate
    );
    const laterStartOfDay = startOfDay(laterDate_);
    const earlierStartOfDay = startOfDay(earlierDate_);
    const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
    const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
    return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
  }

  // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
  function startOfISOWeekYear(date, options) {
    const year = getISOWeekYear(date, options);
    const fourthOfJanuary = constructFrom(options?.in || date, 0);
    fourthOfJanuary.setFullYear(year, 0, 4);
    fourthOfJanuary.setHours(0, 0, 0, 0);
    return startOfISOWeek(fourthOfJanuary);
  }

  // packages/dataviews/node_modules/date-fns/addWeeks.js
  function addWeeks(date, amount, options) {
    return addDays(date, amount * 7, options);
  }

  // packages/dataviews/node_modules/date-fns/addYears.js
  function addYears(date, amount, options) {
    return addMonths(date, amount * 12, options);
  }

  // packages/dataviews/node_modules/date-fns/isDate.js
  function isDate(value) {
    return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
  }

  // packages/dataviews/node_modules/date-fns/isValid.js
  function isValid(date) {
    return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
  }

  // packages/dataviews/node_modules/date-fns/startOfMonth.js
  function startOfMonth(date, options) {
    const _date = toDate(date, options?.in);
    _date.setDate(1);
    _date.setHours(0, 0, 0, 0);
    return _date;
  }

  // packages/dataviews/node_modules/date-fns/startOfYear.js
  function startOfYear(date, options) {
    const date_ = toDate(date, options?.in);
    date_.setFullYear(date_.getFullYear(), 0, 1);
    date_.setHours(0, 0, 0, 0);
    return date_;
  }

  // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
  var formatDistanceLocale = {
    lessThanXSeconds: {
      one: "less than a second",
      other: "less than {{count}} seconds"
    },
    xSeconds: {
      one: "1 second",
      other: "{{count}} seconds"
    },
    halfAMinute: "half a minute",
    lessThanXMinutes: {
      one: "less than a minute",
      other: "less than {{count}} minutes"
    },
    xMinutes: {
      one: "1 minute",
      other: "{{count}} minutes"
    },
    aboutXHours: {
      one: "about 1 hour",
      other: "about {{count}} hours"
    },
    xHours: {
      one: "1 hour",
      other: "{{count}} hours"
    },
    xDays: {
      one: "1 day",
      other: "{{count}} days"
    },
    aboutXWeeks: {
      one: "about 1 week",
      other: "about {{count}} weeks"
    },
    xWeeks: {
      one: "1 week",
      other: "{{count}} weeks"
    },
    aboutXMonths: {
      one: "about 1 month",
      other: "about {{count}} months"
    },
    xMonths: {
      one: "1 month",
      other: "{{count}} months"
    },
    aboutXYears: {
      one: "about 1 year",
      other: "about {{count}} years"
    },
    xYears: {
      one: "1 year",
      other: "{{count}} years"
    },
    overXYears: {
      one: "over 1 year",
      other: "over {{count}} years"
    },
    almostXYears: {
      one: "almost 1 year",
      other: "almost {{count}} years"
    }
  };
  var formatDistance = (token, count, options) => {
    let result;
    const tokenValue = formatDistanceLocale[token];
    if (typeof tokenValue === "string") {
      result = tokenValue;
    } else if (count === 1) {
      result = tokenValue.one;
    } else {
      result = tokenValue.other.replace("{{count}}", count.toString());
    }
    if (options?.addSuffix) {
      if (options.comparison && options.comparison > 0) {
        return "in " + result;
      } else {
        return result + " ago";
      }
    }
    return result;
  };

  // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
  function buildFormatLongFn(args) {
    return (options = {}) => {
      const width = options.width ? String(options.width) : args.defaultWidth;
      const format6 = args.formats[width] || args.formats[args.defaultWidth];
      return format6;
    };
  }

  // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
  var dateFormats = {
    full: "EEEE, MMMM do, y",
    long: "MMMM do, y",
    medium: "MMM d, y",
    short: "MM/dd/yyyy"
  };
  var timeFormats = {
    full: "h:mm:ss a zzzz",
    long: "h:mm:ss a z",
    medium: "h:mm:ss a",
    short: "h:mm a"
  };
  var dateTimeFormats = {
    full: "{{date}} 'at' {{time}}",
    long: "{{date}} 'at' {{time}}",
    medium: "{{date}}, {{time}}",
    short: "{{date}}, {{time}}"
  };
  var formatLong = {
    date: buildFormatLongFn({
      formats: dateFormats,
      defaultWidth: "full"
    }),
    time: buildFormatLongFn({
      formats: timeFormats,
      defaultWidth: "full"
    }),
    dateTime: buildFormatLongFn({
      formats: dateTimeFormats,
      defaultWidth: "full"
    })
  };

  // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
  var formatRelativeLocale = {
    lastWeek: "'last' eeee 'at' p",
    yesterday: "'yesterday at' p",
    today: "'today at' p",
    tomorrow: "'tomorrow at' p",
    nextWeek: "eeee 'at' p",
    other: "P"
  };
  var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];

  // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
  function buildLocalizeFn(args) {
    return (value, options) => {
      const context = options?.context ? String(options.context) : "standalone";
      let valuesArray;
      if (context === "formatting" && args.formattingValues) {
        const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
        const width = options?.width ? String(options.width) : defaultWidth;
        valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
      } else {
        const defaultWidth = args.defaultWidth;
        const width = options?.width ? String(options.width) : args.defaultWidth;
        valuesArray = args.values[width] || args.values[defaultWidth];
      }
      const index = args.argumentCallback ? args.argumentCallback(value) : value;
      return valuesArray[index];
    };
  }

  // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
  var eraValues = {
    narrow: ["B", "A"],
    abbreviated: ["BC", "AD"],
    wide: ["Before Christ", "Anno Domini"]
  };
  var quarterValues = {
    narrow: ["1", "2", "3", "4"],
    abbreviated: ["Q1", "Q2", "Q3", "Q4"],
    wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
  };
  var monthValues = {
    narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
    abbreviated: [
      "Jan",
      "Feb",
      "Mar",
      "Apr",
      "May",
      "Jun",
      "Jul",
      "Aug",
      "Sep",
      "Oct",
      "Nov",
      "Dec"
    ],
    wide: [
      "January",
      "February",
      "March",
      "April",
      "May",
      "June",
      "July",
      "August",
      "September",
      "October",
      "November",
      "December"
    ]
  };
  var dayValues = {
    narrow: ["S", "M", "T", "W", "T", "F", "S"],
    short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
    abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
    wide: [
      "Sunday",
      "Monday",
      "Tuesday",
      "Wednesday",
      "Thursday",
      "Friday",
      "Saturday"
    ]
  };
  var dayPeriodValues = {
    narrow: {
      am: "a",
      pm: "p",
      midnight: "mi",
      noon: "n",
      morning: "morning",
      afternoon: "afternoon",
      evening: "evening",
      night: "night"
    },
    abbreviated: {
      am: "AM",
      pm: "PM",
      midnight: "midnight",
      noon: "noon",
      morning: "morning",
      afternoon: "afternoon",
      evening: "evening",
      night: "night"
    },
    wide: {
      am: "a.m.",
      pm: "p.m.",
      midnight: "midnight",
      noon: "noon",
      morning: "morning",
      afternoon: "afternoon",
      evening: "evening",
      night: "night"
    }
  };
  var formattingDayPeriodValues = {
    narrow: {
      am: "a",
      pm: "p",
      midnight: "mi",
      noon: "n",
      morning: "in the morning",
      afternoon: "in the afternoon",
      evening: "in the evening",
      night: "at night"
    },
    abbreviated: {
      am: "AM",
      pm: "PM",
      midnight: "midnight",
      noon: "noon",
      morning: "in the morning",
      afternoon: "in the afternoon",
      evening: "in the evening",
      night: "at night"
    },
    wide: {
      am: "a.m.",
      pm: "p.m.",
      midnight: "midnight",
      noon: "noon",
      morning: "in the morning",
      afternoon: "in the afternoon",
      evening: "in the evening",
      night: "at night"
    }
  };
  var ordinalNumber = (dirtyNumber, _options) => {
    const number = Number(dirtyNumber);
    const rem100 = number % 100;
    if (rem100 > 20 || rem100 < 10) {
      switch (rem100 % 10) {
        case 1:
          return number + "st";
        case 2:
          return number + "nd";
        case 3:
          return number + "rd";
      }
    }
    return number + "th";
  };
  var localize = {
    ordinalNumber,
    era: buildLocalizeFn({
      values: eraValues,
      defaultWidth: "wide"
    }),
    quarter: buildLocalizeFn({
      values: quarterValues,
      defaultWidth: "wide",
      argumentCallback: (quarter) => quarter - 1
    }),
    month: buildLocalizeFn({
      values: monthValues,
      defaultWidth: "wide"
    }),
    day: buildLocalizeFn({
      values: dayValues,
      defaultWidth: "wide"
    }),
    dayPeriod: buildLocalizeFn({
      values: dayPeriodValues,
      defaultWidth: "wide",
      formattingValues: formattingDayPeriodValues,
      defaultFormattingWidth: "wide"
    })
  };

  // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
  function buildMatchFn(args) {
    return (string, options = {}) => {
      const width = options.width;
      const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
      const matchResult = string.match(matchPattern);
      if (!matchResult) {
        return null;
      }
      const matchedString = matchResult[0];
      const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
      const key = Array.isArray(parsePatterns) ? findIndex2(parsePatterns, (pattern) => pattern.test(matchedString)) : (
        // [TODO] -- I challenge you to fix the type
        findKey(parsePatterns, (pattern) => pattern.test(matchedString))
      );
      let value;
      value = args.valueCallback ? args.valueCallback(key) : key;
      value = options.valueCallback ? (
        // [TODO] -- I challenge you to fix the type
        options.valueCallback(value)
      ) : value;
      const rest = string.slice(matchedString.length);
      return { value, rest };
    };
  }
  function findKey(object, predicate) {
    for (const key in object) {
      if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
        return key;
      }
    }
    return void 0;
  }
  function findIndex2(array, predicate) {
    for (let key = 0; key < array.length; key++) {
      if (predicate(array[key])) {
        return key;
      }
    }
    return void 0;
  }

  // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
  function buildMatchPatternFn(args) {
    return (string, options = {}) => {
      const matchResult = string.match(args.matchPattern);
      if (!matchResult) return null;
      const matchedString = matchResult[0];
      const parseResult = string.match(args.parsePattern);
      if (!parseResult) return null;
      let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
      value = options.valueCallback ? options.valueCallback(value) : value;
      const rest = string.slice(matchedString.length);
      return { value, rest };
    };
  }

  // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
  var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
  var parseOrdinalNumberPattern = /\d+/i;
  var matchEraPatterns = {
    narrow: /^(b|a)/i,
    abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
    wide: /^(before christ|before common era|anno domini|common era)/i
  };
  var parseEraPatterns = {
    any: [/^b/i, /^(a|c)/i]
  };
  var matchQuarterPatterns = {
    narrow: /^[1234]/i,
    abbreviated: /^q[1234]/i,
    wide: /^[1234](th|st|nd|rd)? quarter/i
  };
  var parseQuarterPatterns = {
    any: [/1/i, /2/i, /3/i, /4/i]
  };
  var matchMonthPatterns = {
    narrow: /^[jfmasond]/i,
    abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
    wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
  };
  var parseMonthPatterns = {
    narrow: [
      /^j/i,
      /^f/i,
      /^m/i,
      /^a/i,
      /^m/i,
      /^j/i,
      /^j/i,
      /^a/i,
      /^s/i,
      /^o/i,
      /^n/i,
      /^d/i
    ],
    any: [
      /^ja/i,
      /^f/i,
      /^mar/i,
      /^ap/i,
      /^may/i,
      /^jun/i,
      /^jul/i,
      /^au/i,
      /^s/i,
      /^o/i,
      /^n/i,
      /^d/i
    ]
  };
  var matchDayPatterns = {
    narrow: /^[smtwf]/i,
    short: /^(su|mo|tu|we|th|fr|sa)/i,
    abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
    wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
  };
  var parseDayPatterns = {
    narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
    any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
  };
  var matchDayPeriodPatterns = {
    narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
    any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
  };
  var parseDayPeriodPatterns = {
    any: {
      am: /^a/i,
      pm: /^p/i,
      midnight: /^mi/i,
      noon: /^no/i,
      morning: /morning/i,
      afternoon: /afternoon/i,
      evening: /evening/i,
      night: /night/i
    }
  };
  var match = {
    ordinalNumber: buildMatchPatternFn({
      matchPattern: matchOrdinalNumberPattern,
      parsePattern: parseOrdinalNumberPattern,
      valueCallback: (value) => parseInt(value, 10)
    }),
    era: buildMatchFn({
      matchPatterns: matchEraPatterns,
      defaultMatchWidth: "wide",
      parsePatterns: parseEraPatterns,
      defaultParseWidth: "any"
    }),
    quarter: buildMatchFn({
      matchPatterns: matchQuarterPatterns,
      defaultMatchWidth: "wide",
      parsePatterns: parseQuarterPatterns,
      defaultParseWidth: "any",
      valueCallback: (index) => index + 1
    }),
    month: buildMatchFn({
      matchPatterns: matchMonthPatterns,
      defaultMatchWidth: "wide",
      parsePatterns: parseMonthPatterns,
      defaultParseWidth: "any"
    }),
    day: buildMatchFn({
      matchPatterns: matchDayPatterns,
      defaultMatchWidth: "wide",
      parsePatterns: parseDayPatterns,
      defaultParseWidth: "any"
    }),
    dayPeriod: buildMatchFn({
      matchPatterns: matchDayPeriodPatterns,
      defaultMatchWidth: "any",
      parsePatterns: parseDayPeriodPatterns,
      defaultParseWidth: "any"
    })
  };

  // packages/dataviews/node_modules/date-fns/locale/en-US.js
  var enUS = {
    code: "en-US",
    formatDistance,
    formatLong,
    formatRelative,
    localize,
    match,
    options: {
      weekStartsOn: 0,
      firstWeekContainsDate: 1
    }
  };

  // packages/dataviews/node_modules/date-fns/getDayOfYear.js
  function getDayOfYear(date, options) {
    const _date = toDate(date, options?.in);
    const diff = differenceInCalendarDays(_date, startOfYear(_date));
    const dayOfYear = diff + 1;
    return dayOfYear;
  }

  // packages/dataviews/node_modules/date-fns/getISOWeek.js
  function getISOWeek(date, options) {
    const _date = toDate(date, options?.in);
    const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
    return Math.round(diff / millisecondsInWeek) + 1;
  }

  // packages/dataviews/node_modules/date-fns/getWeekYear.js
  function getWeekYear(date, options) {
    const _date = toDate(date, options?.in);
    const year = _date.getFullYear();
    const defaultOptions2 = getDefaultOptions();
    const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
    const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
    firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
    firstWeekOfNextYear.setHours(0, 0, 0, 0);
    const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
    const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
    firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
    firstWeekOfThisYear.setHours(0, 0, 0, 0);
    const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
    if (+_date >= +startOfNextYear) {
      return year + 1;
    } else if (+_date >= +startOfThisYear) {
      return year;
    } else {
      return year - 1;
    }
  }

  // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
  function startOfWeekYear(date, options) {
    const defaultOptions2 = getDefaultOptions();
    const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
    const year = getWeekYear(date, options);
    const firstWeek = constructFrom(options?.in || date, 0);
    firstWeek.setFullYear(year, 0, firstWeekContainsDate);
    firstWeek.setHours(0, 0, 0, 0);
    const _date = startOfWeek(firstWeek, options);
    return _date;
  }

  // packages/dataviews/node_modules/date-fns/getWeek.js
  function getWeek(date, options) {
    const _date = toDate(date, options?.in);
    const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
    return Math.round(diff / millisecondsInWeek) + 1;
  }

  // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
  function addLeadingZeros(number, targetLength) {
    const sign = number < 0 ? "-" : "";
    const output = Math.abs(number).toString().padStart(targetLength, "0");
    return sign + output;
  }

  // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
  var lightFormatters = {
    // Year
    y(date, token) {
      const signedYear = date.getFullYear();
      const year = signedYear > 0 ? signedYear : 1 - signedYear;
      return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
    },
    // Month
    M(date, token) {
      const month = date.getMonth();
      return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
    },
    // Day of the month
    d(date, token) {
      return addLeadingZeros(date.getDate(), token.length);
    },
    // AM or PM
    a(date, token) {
      const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
      switch (token) {
        case "a":
        case "aa":
          return dayPeriodEnumValue.toUpperCase();
        case "aaa":
          return dayPeriodEnumValue;
        case "aaaaa":
          return dayPeriodEnumValue[0];
        case "aaaa":
        default:
          return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
      }
    },
    // Hour [1-12]
    h(date, token) {
      return addLeadingZeros(date.getHours() % 12 || 12, token.length);
    },
    // Hour [0-23]
    H(date, token) {
      return addLeadingZeros(date.getHours(), token.length);
    },
    // Minute
    m(date, token) {
      return addLeadingZeros(date.getMinutes(), token.length);
    },
    // Second
    s(date, token) {
      return addLeadingZeros(date.getSeconds(), token.length);
    },
    // Fraction of second
    S(date, token) {
      const numberOfDigits = token.length;
      const milliseconds = date.getMilliseconds();
      const fractionalSeconds = Math.trunc(
        milliseconds * Math.pow(10, numberOfDigits - 3)
      );
      return addLeadingZeros(fractionalSeconds, token.length);
    }
  };

  // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
  var dayPeriodEnum = {
    am: "am",
    pm: "pm",
    midnight: "midnight",
    noon: "noon",
    morning: "morning",
    afternoon: "afternoon",
    evening: "evening",
    night: "night"
  };
  var formatters = {
    // Era
    G: function(date, token, localize2) {
      const era = date.getFullYear() > 0 ? 1 : 0;
      switch (token) {
        // AD, BC
        case "G":
        case "GG":
        case "GGG":
          return localize2.era(era, { width: "abbreviated" });
        // A, B
        case "GGGGG":
          return localize2.era(era, { width: "narrow" });
        // Anno Domini, Before Christ
        case "GGGG":
        default:
          return localize2.era(era, { width: "wide" });
      }
    },
    // Year
    y: function(date, token, localize2) {
      if (token === "yo") {
        const signedYear = date.getFullYear();
        const year = signedYear > 0 ? signedYear : 1 - signedYear;
        return localize2.ordinalNumber(year, { unit: "year" });
      }
      return lightFormatters.y(date, token);
    },
    // Local week-numbering year
    Y: function(date, token, localize2, options) {
      const signedWeekYear = getWeekYear(date, options);
      const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
      if (token === "YY") {
        const twoDigitYear = weekYear % 100;
        return addLeadingZeros(twoDigitYear, 2);
      }
      if (token === "Yo") {
        return localize2.ordinalNumber(weekYear, { unit: "year" });
      }
      return addLeadingZeros(weekYear, token.length);
    },
    // ISO week-numbering year
    R: function(date, token) {
      const isoWeekYear = getISOWeekYear(date);
      return addLeadingZeros(isoWeekYear, token.length);
    },
    // Extended year. This is a single number designating the year of this calendar system.
    // The main difference between `y` and `u` localizers are B.C. years:
    // | Year | `y` | `u` |
    // |------|-----|-----|
    // | AC 1 |   1 |   1 |
    // | BC 1 |   1 |   0 |
    // | BC 2 |   2 |  -1 |
    // Also `yy` always returns the last two digits of a year,
    // while `uu` pads single digit years to 2 characters and returns other years unchanged.
    u: function(date, token) {
      const year = date.getFullYear();
      return addLeadingZeros(year, token.length);
    },
    // Quarter
    Q: function(date, token, localize2) {
      const quarter = Math.ceil((date.getMonth() + 1) / 3);
      switch (token) {
        // 1, 2, 3, 4
        case "Q":
          return String(quarter);
        // 01, 02, 03, 04
        case "QQ":
          return addLeadingZeros(quarter, 2);
        // 1st, 2nd, 3rd, 4th
        case "Qo":
          return localize2.ordinalNumber(quarter, { unit: "quarter" });
        // Q1, Q2, Q3, Q4
        case "QQQ":
          return localize2.quarter(quarter, {
            width: "abbreviated",
            context: "formatting"
          });
        // 1, 2, 3, 4 (narrow quarter; could be not numerical)
        case "QQQQQ":
          return localize2.quarter(quarter, {
            width: "narrow",
            context: "formatting"
          });
        // 1st quarter, 2nd quarter, ...
        case "QQQQ":
        default:
          return localize2.quarter(quarter, {
            width: "wide",
            context: "formatting"
          });
      }
    },
    // Stand-alone quarter
    q: function(date, token, localize2) {
      const quarter = Math.ceil((date.getMonth() + 1) / 3);
      switch (token) {
        // 1, 2, 3, 4
        case "q":
          return String(quarter);
        // 01, 02, 03, 04
        case "qq":
          return addLeadingZeros(quarter, 2);
        // 1st, 2nd, 3rd, 4th
        case "qo":
          return localize2.ordinalNumber(quarter, { unit: "quarter" });
        // Q1, Q2, Q3, Q4
        case "qqq":
          return localize2.quarter(quarter, {
            width: "abbreviated",
            context: "standalone"
          });
        // 1, 2, 3, 4 (narrow quarter; could be not numerical)
        case "qqqqq":
          return localize2.quarter(quarter, {
            width: "narrow",
            context: "standalone"
          });
        // 1st quarter, 2nd quarter, ...
        case "qqqq":
        default:
          return localize2.quarter(quarter, {
            width: "wide",
            context: "standalone"
          });
      }
    },
    // Month
    M: function(date, token, localize2) {
      const month = date.getMonth();
      switch (token) {
        case "M":
        case "MM":
          return lightFormatters.M(date, token);
        // 1st, 2nd, ..., 12th
        case "Mo":
          return localize2.ordinalNumber(month + 1, { unit: "month" });
        // Jan, Feb, ..., Dec
        case "MMM":
          return localize2.month(month, {
            width: "abbreviated",
            context: "formatting"
          });
        // J, F, ..., D
        case "MMMMM":
          return localize2.month(month, {
            width: "narrow",
            context: "formatting"
          });
        // January, February, ..., December
        case "MMMM":
        default:
          return localize2.month(month, { width: "wide", context: "formatting" });
      }
    },
    // Stand-alone month
    L: function(date, token, localize2) {
      const month = date.getMonth();
      switch (token) {
        // 1, 2, ..., 12
        case "L":
          return String(month + 1);
        // 01, 02, ..., 12
        case "LL":
          return addLeadingZeros(month + 1, 2);
        // 1st, 2nd, ..., 12th
        case "Lo":
          return localize2.ordinalNumber(month + 1, { unit: "month" });
        // Jan, Feb, ..., Dec
        case "LLL":
          return localize2.month(month, {
            width: "abbreviated",
            context: "standalone"
          });
        // J, F, ..., D
        case "LLLLL":
          return localize2.month(month, {
            width: "narrow",
            context: "standalone"
          });
        // January, February, ..., December
        case "LLLL":
        default:
          return localize2.month(month, { width: "wide", context: "standalone" });
      }
    },
    // Local week of year
    w: function(date, token, localize2, options) {
      const week = getWeek(date, options);
      if (token === "wo") {
        return localize2.ordinalNumber(week, { unit: "week" });
      }
      return addLeadingZeros(week, token.length);
    },
    // ISO week of year
    I: function(date, token, localize2) {
      const isoWeek = getISOWeek(date);
      if (token === "Io") {
        return localize2.ordinalNumber(isoWeek, { unit: "week" });
      }
      return addLeadingZeros(isoWeek, token.length);
    },
    // Day of the month
    d: function(date, token, localize2) {
      if (token === "do") {
        return localize2.ordinalNumber(date.getDate(), { unit: "date" });
      }
      return lightFormatters.d(date, token);
    },
    // Day of year
    D: function(date, token, localize2) {
      const dayOfYear = getDayOfYear(date);
      if (token === "Do") {
        return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
      }
      return addLeadingZeros(dayOfYear, token.length);
    },
    // Day of week
    E: function(date, token, localize2) {
      const dayOfWeek = date.getDay();
      switch (token) {
        // Tue
        case "E":
        case "EE":
        case "EEE":
          return localize2.day(dayOfWeek, {
            width: "abbreviated",
            context: "formatting"
          });
        // T
        case "EEEEE":
          return localize2.day(dayOfWeek, {
            width: "narrow",
            context: "formatting"
          });
        // Tu
        case "EEEEEE":
          return localize2.day(dayOfWeek, {
            width: "short",
            context: "formatting"
          });
        // Tuesday
        case "EEEE":
        default:
          return localize2.day(dayOfWeek, {
            width: "wide",
            context: "formatting"
          });
      }
    },
    // Local day of week
    e: function(date, token, localize2, options) {
      const dayOfWeek = date.getDay();
      const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
      switch (token) {
        // Numerical value (Nth day of week with current locale or weekStartsOn)
        case "e":
          return String(localDayOfWeek);
        // Padded numerical value
        case "ee":
          return addLeadingZeros(localDayOfWeek, 2);
        // 1st, 2nd, ..., 7th
        case "eo":
          return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
        case "eee":
          return localize2.day(dayOfWeek, {
            width: "abbreviated",
            context: "formatting"
          });
        // T
        case "eeeee":
          return localize2.day(dayOfWeek, {
            width: "narrow",
            context: "formatting"
          });
        // Tu
        case "eeeeee":
          return localize2.day(dayOfWeek, {
            width: "short",
            context: "formatting"
          });
        // Tuesday
        case "eeee":
        default:
          return localize2.day(dayOfWeek, {
            width: "wide",
            context: "formatting"
          });
      }
    },
    // Stand-alone local day of week
    c: function(date, token, localize2, options) {
      const dayOfWeek = date.getDay();
      const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
      switch (token) {
        // Numerical value (same as in `e`)
        case "c":
          return String(localDayOfWeek);
        // Padded numerical value
        case "cc":
          return addLeadingZeros(localDayOfWeek, token.length);
        // 1st, 2nd, ..., 7th
        case "co":
          return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
        case "ccc":
          return localize2.day(dayOfWeek, {
            width: "abbreviated",
            context: "standalone"
          });
        // T
        case "ccccc":
          return localize2.day(dayOfWeek, {
            width: "narrow",
            context: "standalone"
          });
        // Tu
        case "cccccc":
          return localize2.day(dayOfWeek, {
            width: "short",
            context: "standalone"
          });
        // Tuesday
        case "cccc":
        default:
          return localize2.day(dayOfWeek, {
            width: "wide",
            context: "standalone"
          });
      }
    },
    // ISO day of week
    i: function(date, token, localize2) {
      const dayOfWeek = date.getDay();
      const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
      switch (token) {
        // 2
        case "i":
          return String(isoDayOfWeek);
        // 02
        case "ii":
          return addLeadingZeros(isoDayOfWeek, token.length);
        // 2nd
        case "io":
          return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
        // Tue
        case "iii":
          return localize2.day(dayOfWeek, {
            width: "abbreviated",
            context: "formatting"
          });
        // T
        case "iiiii":
          return localize2.day(dayOfWeek, {
            width: "narrow",
            context: "formatting"
          });
        // Tu
        case "iiiiii":
          return localize2.day(dayOfWeek, {
            width: "short",
            context: "formatting"
          });
        // Tuesday
        case "iiii":
        default:
          return localize2.day(dayOfWeek, {
            width: "wide",
            context: "formatting"
          });
      }
    },
    // AM or PM
    a: function(date, token, localize2) {
      const hours = date.getHours();
      const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
      switch (token) {
        case "a":
        case "aa":
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "abbreviated",
            context: "formatting"
          });
        case "aaa":
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "abbreviated",
            context: "formatting"
          }).toLowerCase();
        case "aaaaa":
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "narrow",
            context: "formatting"
          });
        case "aaaa":
        default:
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "wide",
            context: "formatting"
          });
      }
    },
    // AM, PM, midnight, noon
    b: function(date, token, localize2) {
      const hours = date.getHours();
      let dayPeriodEnumValue;
      if (hours === 12) {
        dayPeriodEnumValue = dayPeriodEnum.noon;
      } else if (hours === 0) {
        dayPeriodEnumValue = dayPeriodEnum.midnight;
      } else {
        dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
      }
      switch (token) {
        case "b":
        case "bb":
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "abbreviated",
            context: "formatting"
          });
        case "bbb":
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "abbreviated",
            context: "formatting"
          }).toLowerCase();
        case "bbbbb":
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "narrow",
            context: "formatting"
          });
        case "bbbb":
        default:
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "wide",
            context: "formatting"
          });
      }
    },
    // in the morning, in the afternoon, in the evening, at night
    B: function(date, token, localize2) {
      const hours = date.getHours();
      let dayPeriodEnumValue;
      if (hours >= 17) {
        dayPeriodEnumValue = dayPeriodEnum.evening;
      } else if (hours >= 12) {
        dayPeriodEnumValue = dayPeriodEnum.afternoon;
      } else if (hours >= 4) {
        dayPeriodEnumValue = dayPeriodEnum.morning;
      } else {
        dayPeriodEnumValue = dayPeriodEnum.night;
      }
      switch (token) {
        case "B":
        case "BB":
        case "BBB":
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "abbreviated",
            context: "formatting"
          });
        case "BBBBB":
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "narrow",
            context: "formatting"
          });
        case "BBBB":
        default:
          return localize2.dayPeriod(dayPeriodEnumValue, {
            width: "wide",
            context: "formatting"
          });
      }
    },
    // Hour [1-12]
    h: function(date, token, localize2) {
      if (token === "ho") {
        let hours = date.getHours() % 12;
        if (hours === 0) hours = 12;
        return localize2.ordinalNumber(hours, { unit: "hour" });
      }
      return lightFormatters.h(date, token);
    },
    // Hour [0-23]
    H: function(date, token, localize2) {
      if (token === "Ho") {
        return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
      }
      return lightFormatters.H(date, token);
    },
    // Hour [0-11]
    K: function(date, token, localize2) {
      const hours = date.getHours() % 12;
      if (token === "Ko") {
        return localize2.ordinalNumber(hours, { unit: "hour" });
      }
      return addLeadingZeros(hours, token.length);
    },
    // Hour [1-24]
    k: function(date, token, localize2) {
      let hours = date.getHours();
      if (hours === 0) hours = 24;
      if (token === "ko") {
        return localize2.ordinalNumber(hours, { unit: "hour" });
      }
      return addLeadingZeros(hours, token.length);
    },
    // Minute
    m: function(date, token, localize2) {
      if (token === "mo") {
        return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
      }
      return lightFormatters.m(date, token);
    },
    // Second
    s: function(date, token, localize2) {
      if (token === "so") {
        return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
      }
      return lightFormatters.s(date, token);
    },
    // Fraction of second
    S: function(date, token) {
      return lightFormatters.S(date, token);
    },
    // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
    X: function(date, token, _localize) {
      const timezoneOffset = date.getTimezoneOffset();
      if (timezoneOffset === 0) {
        return "Z";
      }
      switch (token) {
        // Hours and optional minutes
        case "X":
          return formatTimezoneWithOptionalMinutes(timezoneOffset);
        // Hours, minutes and optional seconds without `:` delimiter
        // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
        // so this token always has the same output as `XX`
        case "XXXX":
        case "XX":
          return formatTimezone(timezoneOffset);
        // Hours, minutes and optional seconds with `:` delimiter
        // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
        // so this token always has the same output as `XXX`
        case "XXXXX":
        case "XXX":
        // Hours and minutes with `:` delimiter
        default:
          return formatTimezone(timezoneOffset, ":");
      }
    },
    // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
    x: function(date, token, _localize) {
      const timezoneOffset = date.getTimezoneOffset();
      switch (token) {
        // Hours and optional minutes
        case "x":
          return formatTimezoneWithOptionalMinutes(timezoneOffset);
        // Hours, minutes and optional seconds without `:` delimiter
        // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
        // so this token always has the same output as `xx`
        case "xxxx":
        case "xx":
          return formatTimezone(timezoneOffset);
        // Hours, minutes and optional seconds with `:` delimiter
        // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
        // so this token always has the same output as `xxx`
        case "xxxxx":
        case "xxx":
        // Hours and minutes with `:` delimiter
        default:
          return formatTimezone(timezoneOffset, ":");
      }
    },
    // Timezone (GMT)
    O: function(date, token, _localize) {
      const timezoneOffset = date.getTimezoneOffset();
      switch (token) {
        // Short
        case "O":
        case "OO":
        case "OOO":
          return "GMT" + formatTimezoneShort(timezoneOffset, ":");
        // Long
        case "OOOO":
        default:
          return "GMT" + formatTimezone(timezoneOffset, ":");
      }
    },
    // Timezone (specific non-location)
    z: function(date, token, _localize) {
      const timezoneOffset = date.getTimezoneOffset();
      switch (token) {
        // Short
        case "z":
        case "zz":
        case "zzz":
          return "GMT" + formatTimezoneShort(timezoneOffset, ":");
        // Long
        case "zzzz":
        default:
          return "GMT" + formatTimezone(timezoneOffset, ":");
      }
    },
    // Seconds timestamp
    t: function(date, token, _localize) {
      const timestamp = Math.trunc(+date / 1e3);
      return addLeadingZeros(timestamp, token.length);
    },
    // Milliseconds timestamp
    T: function(date, token, _localize) {
      return addLeadingZeros(+date, token.length);
    }
  };
  function formatTimezoneShort(offset, delimiter = "") {
    const sign = offset > 0 ? "-" : "+";
    const absOffset = Math.abs(offset);
    const hours = Math.trunc(absOffset / 60);
    const minutes = absOffset % 60;
    if (minutes === 0) {
      return sign + String(hours);
    }
    return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
  }
  function formatTimezoneWithOptionalMinutes(offset, delimiter) {
    if (offset % 60 === 0) {
      const sign = offset > 0 ? "-" : "+";
      return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
    }
    return formatTimezone(offset, delimiter);
  }
  function formatTimezone(offset, delimiter = "") {
    const sign = offset > 0 ? "-" : "+";
    const absOffset = Math.abs(offset);
    const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
    const minutes = addLeadingZeros(absOffset % 60, 2);
    return sign + hours + delimiter + minutes;
  }

  // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
  var dateLongFormatter = (pattern, formatLong2) => {
    switch (pattern) {
      case "P":
        return formatLong2.date({ width: "short" });
      case "PP":
        return formatLong2.date({ width: "medium" });
      case "PPP":
        return formatLong2.date({ width: "long" });
      case "PPPP":
      default:
        return formatLong2.date({ width: "full" });
    }
  };
  var timeLongFormatter = (pattern, formatLong2) => {
    switch (pattern) {
      case "p":
        return formatLong2.time({ width: "short" });
      case "pp":
        return formatLong2.time({ width: "medium" });
      case "ppp":
        return formatLong2.time({ width: "long" });
      case "pppp":
      default:
        return formatLong2.time({ width: "full" });
    }
  };
  var dateTimeLongFormatter = (pattern, formatLong2) => {
    const matchResult = pattern.match(/(P+)(p+)?/) || [];
    const datePattern = matchResult[1];
    const timePattern = matchResult[2];
    if (!timePattern) {
      return dateLongFormatter(pattern, formatLong2);
    }
    let dateTimeFormat;
    switch (datePattern) {
      case "P":
        dateTimeFormat = formatLong2.dateTime({ width: "short" });
        break;
      case "PP":
        dateTimeFormat = formatLong2.dateTime({ width: "medium" });
        break;
      case "PPP":
        dateTimeFormat = formatLong2.dateTime({ width: "long" });
        break;
      case "PPPP":
      default:
        dateTimeFormat = formatLong2.dateTime({ width: "full" });
        break;
    }
    return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
  };
  var longFormatters = {
    p: timeLongFormatter,
    P: dateTimeLongFormatter
  };

  // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
  var dayOfYearTokenRE = /^D+$/;
  var weekYearTokenRE = /^Y+$/;
  var throwTokens = ["D", "DD", "YY", "YYYY"];
  function isProtectedDayOfYearToken(token) {
    return dayOfYearTokenRE.test(token);
  }
  function isProtectedWeekYearToken(token) {
    return weekYearTokenRE.test(token);
  }
  function warnOrThrowProtectedError(token, format6, input) {
    const _message = message(token, format6, input);
    console.warn(_message);
    if (throwTokens.includes(token)) throw new RangeError(_message);
  }
  function message(token, format6, input) {
    const subject = token[0] === "Y" ? "years" : "days of the month";
    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`;
  }

  // packages/dataviews/node_modules/date-fns/format.js
  var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
  var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
  var escapedStringRegExp = /^'([^]*?)'?$/;
  var doubleQuoteRegExp = /''/g;
  var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
  function format(date, formatStr, options) {
    const defaultOptions2 = getDefaultOptions();
    const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
    const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
    const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
    const originalDate = toDate(date, options?.in);
    if (!isValid(originalDate)) {
      throw new RangeError("Invalid time value");
    }
    let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
      const firstCharacter = substring[0];
      if (firstCharacter === "p" || firstCharacter === "P") {
        const longFormatter = longFormatters[firstCharacter];
        return longFormatter(substring, locale.formatLong);
      }
      return substring;
    }).join("").match(formattingTokensRegExp).map((substring) => {
      if (substring === "''") {
        return { isToken: false, value: "'" };
      }
      const firstCharacter = substring[0];
      if (firstCharacter === "'") {
        return { isToken: false, value: cleanEscapedString(substring) };
      }
      if (formatters[firstCharacter]) {
        return { isToken: true, value: substring };
      }
      if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
        throw new RangeError(
          "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
        );
      }
      return { isToken: false, value: substring };
    });
    if (locale.localize.preprocessor) {
      parts = locale.localize.preprocessor(originalDate, parts);
    }
    const formatterOptions = {
      firstWeekContainsDate,
      weekStartsOn,
      locale
    };
    return parts.map((part) => {
      if (!part.isToken) return part.value;
      const token = part.value;
      if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
        warnOrThrowProtectedError(token, formatStr, String(date));
      }
      const formatter = formatters[token[0]];
      return formatter(originalDate, token, locale.localize, formatterOptions);
    }).join("");
  }
  function cleanEscapedString(input) {
    const matched = input.match(escapedStringRegExp);
    if (!matched) {
      return input;
    }
    return matched[1].replace(doubleQuoteRegExp, "'");
  }

  // packages/dataviews/node_modules/date-fns/subDays.js
  function subDays(date, amount, options) {
    return addDays(date, -amount, options);
  }

  // packages/dataviews/node_modules/date-fns/subMonths.js
  function subMonths(date, amount, options) {
    return addMonths(date, -amount, options);
  }

  // packages/dataviews/node_modules/date-fns/subWeeks.js
  function subWeeks(date, amount, options) {
    return addWeeks(date, -amount, options);
  }

  // packages/dataviews/node_modules/date-fns/subYears.js
  function subYears(date, amount, options) {
    return addYears(date, -amount, options);
  }

  // packages/dataviews/build-module/utils/operators.mjs
  var import_i18n90 = __toESM(require_i18n(), 1);
  var import_element72 = __toESM(require_element(), 1);
  var import_date6 = __toESM(require_date(), 1);
  var import_jsx_runtime172 = __toESM(require_jsx_runtime(), 1);
  var filterTextWrappers = {
    Name: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
    Value: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
  };
  function getRelativeDate(value, unit) {
    switch (unit) {
      case "days":
        return subDays(/* @__PURE__ */ new Date(), value);
      case "weeks":
        return subWeeks(/* @__PURE__ */ new Date(), value);
      case "months":
        return subMonths(/* @__PURE__ */ new Date(), value);
      case "years":
        return subYears(/* @__PURE__ */ new Date(), value);
      default:
        return /* @__PURE__ */ new Date();
    }
  }
  var isNoneOperatorDefinition = {
    /* translators: DataViews operator name */
    label: (0, import_i18n90.__)("Is none of"),
    filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
      (0, import_i18n90.sprintf)(
        /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
        (0, import_i18n90.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
        filter.name,
        activeElements.map((element) => element.label).join(", ")
      ),
      filterTextWrappers
    ),
    filter: ((item, field, filterValue) => {
      if (!filterValue?.length) {
        return true;
      }
      const fieldValue = field.getValue({ item });
      if (Array.isArray(fieldValue)) {
        return !filterValue.some(
          (fv) => fieldValue.includes(fv)
        );
      } else if (typeof fieldValue === "string") {
        return !filterValue.includes(fieldValue);
      }
      return false;
    }),
    selection: "multi"
  };
  var OPERATORS = [
    {
      name: OPERATOR_IS_ANY2,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Includes"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
          (0, import_i18n90.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements.map((element) => element.label).join(", ")
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (!filterValue?.length) {
          return true;
        }
        const fieldValue = field.getValue({ item });
        if (Array.isArray(fieldValue)) {
          return filterValue.some(
            (fv) => fieldValue.includes(fv)
          );
        } else if (typeof fieldValue === "string") {
          return filterValue.includes(fieldValue);
        }
        return false;
      },
      selection: "multi"
    },
    {
      name: OPERATOR_IS_NONE,
      ...isNoneOperatorDefinition
    },
    {
      name: OPERATOR_IS_ALL,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Includes all"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
          (0, import_i18n90.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements.map((element) => element.label).join(", ")
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (!filterValue?.length) {
          return true;
        }
        return filterValue.every((value) => {
          return field.getValue({ item })?.includes(value);
        });
      },
      selection: "multi"
    },
    {
      name: OPERATOR_IS_NOT_ALL,
      ...isNoneOperatorDefinition
    },
    {
      name: OPERATOR_BETWEEN,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Between (inc)"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* 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". */
          (0, import_i18n90.__)(
            "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
          ),
          filter.name,
          activeElements[0].label[0],
          activeElements[0].label[1]
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
          return true;
        }
        const fieldValue = field.getValue({ item });
        if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
          return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
        }
        return false;
      },
      selection: "custom"
    },
    {
      name: OPERATOR_IN_THE_PAST,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("In the past"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
          (0, import_i18n90.__)(
            "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
          ),
          filter.name,
          `${activeElements[0].value.value} ${activeElements[0].value.unit}`
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
          return true;
        }
        const targetDate = getRelativeDate(
          filterValue.value,
          filterValue.unit
        );
        const fieldValue = (0, import_date6.getDate)(field.getValue({ item }));
        return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
      },
      selection: "custom"
    },
    {
      name: OPERATOR_OVER,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Over"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
          (0, import_i18n90.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
          filter.name,
          `${activeElements[0].value.value} ${activeElements[0].value.unit}`
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
          return true;
        }
        const targetDate = getRelativeDate(
          filterValue.value,
          filterValue.unit
        );
        const fieldValue = (0, import_date6.getDate)(field.getValue({ item }));
        return fieldValue < targetDate;
      },
      selection: "custom"
    },
    {
      name: OPERATOR_IS,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Is"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
          (0, import_i18n90.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        return filterValue === field.getValue({ item }) || filterValue === void 0;
      },
      selection: "single"
    },
    {
      name: OPERATOR_IS_NOT,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Is not"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
          (0, import_i18n90.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        return filterValue !== field.getValue({ item });
      },
      selection: "single"
    },
    {
      name: OPERATOR_LESS_THAN,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Less than"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
          (0, import_i18n90.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const fieldValue = field.getValue({ item });
        return fieldValue < filterValue;
      },
      selection: "single"
    },
    {
      name: OPERATOR_GREATER_THAN,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Greater than"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
          (0, import_i18n90.__)(
            "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
          ),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const fieldValue = field.getValue({ item });
        return fieldValue > filterValue;
      },
      selection: "single"
    },
    {
      name: OPERATOR_LESS_THAN_OR_EQUAL,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Less than or equal"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
          (0, import_i18n90.__)(
            "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
          ),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const fieldValue = field.getValue({ item });
        return fieldValue <= filterValue;
      },
      selection: "single"
    },
    {
      name: OPERATOR_GREATER_THAN_OR_EQUAL,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Greater than or equal"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
          (0, import_i18n90.__)(
            "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
          ),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const fieldValue = field.getValue({ item });
        return fieldValue >= filterValue;
      },
      selection: "single"
    },
    {
      name: OPERATOR_BEFORE,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Before"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
          (0, import_i18n90.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const filterDate = (0, import_date6.getDate)(filterValue);
        const fieldDate = (0, import_date6.getDate)(field.getValue({ item }));
        return fieldDate < filterDate;
      },
      selection: "single"
    },
    {
      name: OPERATOR_AFTER,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("After"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
          (0, import_i18n90.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const filterDate = (0, import_date6.getDate)(filterValue);
        const fieldDate = (0, import_date6.getDate)(field.getValue({ item }));
        return fieldDate > filterDate;
      },
      selection: "single"
    },
    {
      name: OPERATOR_BEFORE_INC,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Before (inc)"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
          (0, import_i18n90.__)(
            "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
          ),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const filterDate = (0, import_date6.getDate)(filterValue);
        const fieldDate = (0, import_date6.getDate)(field.getValue({ item }));
        return fieldDate <= filterDate;
      },
      selection: "single"
    },
    {
      name: OPERATOR_AFTER_INC,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("After (inc)"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
          (0, import_i18n90.__)(
            "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
          ),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const filterDate = (0, import_date6.getDate)(filterValue);
        const fieldDate = (0, import_date6.getDate)(field.getValue({ item }));
        return fieldDate >= filterDate;
      },
      selection: "single"
    },
    {
      name: OPERATOR_CONTAINS,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Contains"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
          (0, import_i18n90.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const fieldValue = field.getValue({ item });
        return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
      },
      selection: "single"
    },
    {
      name: OPERATOR_NOT_CONTAINS,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Doesn't contain"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
          (0, import_i18n90.__)(
            "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
          ),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const fieldValue = field.getValue({ item });
        return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
      },
      selection: "single"
    },
    {
      name: OPERATOR_STARTS_WITH,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Starts with"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
          (0, import_i18n90.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const fieldValue = field.getValue({ item });
        return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
      },
      selection: "single"
    },
    {
      name: OPERATOR_ON,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("On"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
          (0, import_i18n90.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const filterDate = (0, import_date6.getDate)(filterValue);
        const fieldDate = (0, import_date6.getDate)(field.getValue({ item }));
        return filterDate.getTime() === fieldDate.getTime();
      },
      selection: "single"
    },
    {
      name: OPERATOR_NOT_ON,
      /* translators: DataViews operator name */
      label: (0, import_i18n90.__)("Not on"),
      filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
        (0, import_i18n90.sprintf)(
          /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
          (0, import_i18n90.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
          filter.name,
          activeElements[0].label
        ),
        filterTextWrappers
      ),
      filter(item, field, filterValue) {
        if (filterValue === void 0) {
          return true;
        }
        const filterDate = (0, import_date6.getDate)(filterValue);
        const fieldDate = (0, import_date6.getDate)(field.getValue({ item }));
        return filterDate.getTime() !== fieldDate.getTime();
      },
      selection: "single"
    }
  ];
  var getOperatorByName = (name2) => OPERATORS.find((op) => op.name === name2);
  var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
  var isSingleSelectionOperator = (name2) => OPERATORS.filter((op) => op.selection === "single").some(
    (op) => op.name === name2
  );
  var isRegisteredOperator = (name2) => OPERATORS.some((op) => op.name === name2);

  // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
  var import_jsx_runtime173 = __toESM(require_jsx_runtime(), 1);
  var ENTER = "Enter";
  var SPACE = " ";
  var FilterText = ({
    activeElements,
    filterInView,
    filter
  }) => {
    if (activeElements === void 0 || activeElements.length === 0) {
      return filter.name;
    }
    const operator = getOperatorByName(filterInView?.operator);
    if (operator !== void 0) {
      return operator.filterText(filter, activeElements);
    }
    return (0, import_i18n91.sprintf)(
      /* translators: 1: Filter name e.g.: "Unknown status for Author". */
      (0, import_i18n91.__)("Unknown status for %1$s"),
      filter.name
    );
  };
  function OperatorSelector({
    filter,
    view: view2,
    onChangeView
  }) {
    const operatorOptions = filter.operators?.map((operator) => ({
      value: operator,
      label: getOperatorByName(operator)?.label || operator
    }));
    const currentFilter = view2.filters?.find(
      (_filter) => _filter.field === filter.field
    );
    const value = currentFilter?.operator || filter.operators[0];
    return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(
      Stack,
      {
        direction: "row",
        gap: "sm",
        justify: "flex-start",
        className: "dataviews-filters__summary-operators-container",
        align: "center",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(import_components48.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
          /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
            import_components48.SelectControl,
            {
              className: "dataviews-filters__summary-operators-filter-select",
              label: (0, import_i18n91.__)("Conditions"),
              value,
              options: operatorOptions,
              onChange: (newValue) => {
                const newOperator = newValue;
                const currentOperator = currentFilter?.operator;
                const newFilters = currentFilter ? [
                  ...(view2.filters ?? []).map(
                    (_filter) => {
                      if (_filter.field === filter.field) {
                        const currentOpSelectionModel = getOperatorByName(
                          currentOperator
                        )?.selection;
                        const newOpSelectionModel = getOperatorByName(
                          newOperator
                        )?.selection;
                        const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
                          currentOpSelectionModel,
                          newOpSelectionModel
                        ].includes("custom");
                        return {
                          ..._filter,
                          value: shouldResetValue ? void 0 : _filter.value,
                          operator: newOperator
                        };
                      }
                      return _filter;
                    }
                  )
                ] : [
                  ...view2.filters ?? [],
                  {
                    field: filter.field,
                    operator: newOperator,
                    value: void 0
                  }
                ];
                onChangeView({
                  ...view2,
                  page: 1,
                  filters: newFilters
                });
              },
              size: "small",
              variant: "minimal",
              hideLabelFromVision: true
            }
          )
        ]
      }
    );
  }
  function Filter({
    addFilterRef,
    openedFilter,
    fields: fields3,
    ...commonProps
  }) {
    const toggleRef = (0, import_element73.useRef)(null);
    const { filter, view: view2, onChangeView } = commonProps;
    const filterInView = view2.filters?.find(
      (f3) => f3.field === filter.field
    );
    let activeElements = [];
    const field = (0, import_element73.useMemo)(() => {
      const currentField = fields3.find((f3) => f3.id === filter.field);
      if (currentField) {
        return {
          ...currentField,
          // Configure getValue as if Item was a plain object.
          // See related input-widget.tsx
          getValue: ({ item }) => item[currentField.id]
        };
      }
      return currentField;
    }, [fields3, filter.field]);
    const { elements: elements2 } = useElements({
      elements: filter.elements,
      getElements: filter.getElements
    });
    if (elements2.length > 0) {
      activeElements = elements2.filter((element) => {
        if (filter.singleSelection) {
          return element.value === filterInView?.value;
        }
        return filterInView?.value?.includes(element.value);
      });
    } else if (Array.isArray(filterInView?.value)) {
      const label = filterInView.value.map((v3) => {
        const formattedValue = field?.getValueFormatted({
          item: { [field.id]: v3 },
          field
        });
        return formattedValue || String(v3);
      });
      activeElements = [
        {
          value: filterInView.value,
          // @ts-ignore
          label
        }
      ];
    } else if (typeof filterInView?.value === "object") {
      activeElements = [
        { value: filterInView.value, label: filterInView.value }
      ];
    } else if (filterInView?.value !== void 0) {
      const label = field !== void 0 ? field.getValueFormatted({
        item: { [field.id]: filterInView.value },
        field
      }) : String(filterInView.value);
      activeElements = [
        {
          value: filterInView.value,
          label
        }
      ];
    }
    const isPrimary = filter.isPrimary;
    const isLocked = filterInView?.isLocked;
    const hasValues = !isLocked && filterInView?.value !== void 0;
    const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
    return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
      import_components48.Dropdown,
      {
        defaultOpen: openedFilter === filter.field,
        contentClassName: "dataviews-filters__summary-popover",
        popoverProps: { placement: "bottom-start", role: "dialog" },
        onClose: () => {
          toggleRef.current?.focus();
        },
        renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
          /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
            import_components48.Tooltip,
            {
              text: (0, import_i18n91.sprintf)(
                /* translators: 1: Filter name. */
                (0, import_i18n91.__)("Filter by: %1$s"),
                filter.name.toLowerCase()
              ),
              placement: "top",
              children: /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
                "div",
                {
                  className: clsx_default(
                    "dataviews-filters__summary-chip",
                    {
                      "has-reset": canResetOrRemove,
                      "has-values": hasValues,
                      "is-not-clickable": isLocked
                    }
                  ),
                  role: "button",
                  tabIndex: isLocked ? -1 : 0,
                  onClick: () => {
                    if (!isLocked) {
                      onToggle();
                    }
                  },
                  onKeyDown: (event) => {
                    if (!isLocked && [ENTER, SPACE].includes(event.key)) {
                      onToggle();
                      event.preventDefault();
                    }
                  },
                  "aria-disabled": isLocked,
                  "aria-pressed": isOpen2,
                  "aria-expanded": isOpen2,
                  ref: toggleRef,
                  children: /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
                    FilterText,
                    {
                      activeElements,
                      filterInView,
                      filter
                    }
                  )
                }
              )
            }
          ),
          canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
            import_components48.Tooltip,
            {
              text: isPrimary ? (0, import_i18n91.__)("Reset") : (0, import_i18n91.__)("Remove"),
              placement: "top",
              children: /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
                "button",
                {
                  className: clsx_default(
                    "dataviews-filters__summary-chip-remove",
                    { "has-values": hasValues }
                  ),
                  onClick: () => {
                    onChangeView({
                      ...view2,
                      page: 1,
                      filters: view2.filters?.filter(
                        (_filter) => _filter.field !== filter.field
                      )
                    });
                    if (!isPrimary) {
                      addFilterRef.current?.focus();
                    } else {
                      toggleRef.current?.focus();
                    }
                  },
                  children: /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(import_components48.Icon, { icon: close_small_default })
                }
              )
            }
          )
        ] }),
        renderContent: () => {
          return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
            /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(OperatorSelector, { ...commonProps }),
            commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
              SearchWidget,
              {
                ...commonProps,
                filter: {
                  ...commonProps.filter,
                  elements: elements2
                }
              }
            ) : /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(InputWidget, { ...commonProps, fields: fields3 })
          ] });
        }
      }
    );
  }

  // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
  var import_components49 = __toESM(require_components(), 1);
  var import_i18n92 = __toESM(require_i18n(), 1);
  var import_element74 = __toESM(require_element(), 1);
  var import_jsx_runtime174 = __toESM(require_jsx_runtime(), 1);
  var { Menu: Menu4 } = unlock3(import_components49.privateApis);
  function AddFilterMenu({
    filters,
    view: view2,
    onChangeView,
    setOpenedFilter,
    triggerProps
  }) {
    const inactiveFilters = filters.filter((filter) => !filter.isVisible);
    return /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(Menu4, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Menu4.TriggerButton, { ...triggerProps }),
      /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
        return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
          Menu4.Item,
          {
            onClick: () => {
              setOpenedFilter(filter.field);
              onChangeView({
                ...view2,
                page: 1,
                filters: [
                  ...view2.filters || [],
                  {
                    field: filter.field,
                    value: void 0,
                    operator: filter.operators[0]
                  }
                ]
              });
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Menu4.ItemLabel, { children: filter.name })
          },
          filter.field
        );
      }) })
    ] });
  }
  function AddFilter({ filters, view: view2, onChangeView, setOpenedFilter }, ref) {
    if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
      return null;
    }
    const inactiveFilters = filters.filter((filter) => !filter.isVisible);
    return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
      AddFilterMenu,
      {
        triggerProps: {
          render: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
            import_components49.Button,
            {
              accessibleWhenDisabled: true,
              size: "compact",
              className: "dataviews-filters-button",
              variant: "tertiary",
              disabled: !inactiveFilters.length,
              ref
            }
          ),
          children: (0, import_i18n92.__)("Add filter")
        },
        ...{ filters, view: view2, onChangeView, setOpenedFilter }
      }
    );
  }
  var add_filter_default = (0, import_element74.forwardRef)(AddFilter);

  // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
  var import_components50 = __toESM(require_components(), 1);
  var import_i18n93 = __toESM(require_i18n(), 1);
  var import_jsx_runtime175 = __toESM(require_jsx_runtime(), 1);
  function ResetFilter({
    filters,
    view: view2,
    onChangeView
  }) {
    const isPrimary = (field) => filters.some(
      (_filter) => _filter.field === field && _filter.isPrimary
    );
    const isDisabled = !view2.search && !view2.filters?.some(
      (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
    );
    return /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(
      import_components50.Button,
      {
        disabled: isDisabled,
        accessibleWhenDisabled: true,
        size: "compact",
        variant: "tertiary",
        className: "dataviews-filters__reset-button",
        onClick: () => {
          onChangeView({
            ...view2,
            page: 1,
            search: "",
            filters: view2.filters?.filter((f3) => !!f3.isLocked) || []
          });
        },
        children: (0, import_i18n93.__)("Reset")
      }
    );
  }

  // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
  var import_element75 = __toESM(require_element(), 1);
  function useFilters(fields3, view2) {
    return (0, import_element75.useMemo)(() => {
      const filters = [];
      fields3.forEach((field) => {
        if (field.filterBy === false || !field.hasElements && !field.Edit) {
          return;
        }
        const operators = field.filterBy.operators;
        const isPrimary = !!field.filterBy?.isPrimary;
        const isLocked = view2.filters?.some(
          (f3) => f3.field === field.id && !!f3.isLocked
        ) ?? false;
        filters.push({
          field: field.id,
          name: field.label,
          elements: field.elements,
          getElements: field.getElements,
          hasElements: field.hasElements,
          singleSelection: operators.some(
            (op) => isSingleSelectionOperator(op)
          ),
          operators,
          isVisible: isLocked || isPrimary || !!view2.filters?.some(
            (f3) => f3.field === field.id && isRegisteredOperator(f3.operator)
          ),
          isPrimary,
          isLocked
        });
      });
      filters.sort((a3, b3) => {
        if (a3.isLocked && !b3.isLocked) {
          return -1;
        }
        if (!a3.isLocked && b3.isLocked) {
          return 1;
        }
        if (a3.isPrimary && !b3.isPrimary) {
          return -1;
        }
        if (!a3.isPrimary && b3.isPrimary) {
          return 1;
        }
        return a3.name.localeCompare(b3.name);
      });
      return filters;
    }, [fields3, view2]);
  }
  var use_filters_default = useFilters;

  // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
  var import_jsx_runtime176 = __toESM(require_jsx_runtime(), 1);
  function Filters({ className }) {
    const { fields: fields3, view: view2, onChangeView, openedFilter, setOpenedFilter } = (0, import_element76.useContext)(dataviews_context_default);
    const addFilterRef = (0, import_element76.useRef)(null);
    const filters = use_filters_default(fields3, view2);
    const addFilter10 = /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
      add_filter_default,
      {
        filters,
        view: view2,
        onChangeView,
        ref: addFilterRef,
        setOpenedFilter
      },
      "add-filter"
    );
    const visibleFilters = filters.filter((filter) => filter.isVisible);
    if (visibleFilters.length === 0) {
      return null;
    }
    const filterComponents = [
      ...visibleFilters.map((filter) => {
        return /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
          Filter,
          {
            filter,
            view: view2,
            fields: fields3,
            onChangeView,
            addFilterRef,
            openedFilter
          },
          filter.field
        );
      }),
      addFilter10
    ];
    filterComponents.push(
      /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
        ResetFilter,
        {
          filters,
          view: view2,
          onChangeView
        },
        "reset-filters"
      )
    );
    return /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
      Stack,
      {
        direction: "row",
        justify: "flex-start",
        gap: "sm",
        style: { width: "fit-content" },
        wrap: "wrap",
        className,
        children: filterComponents
      }
    );
  }
  var filters_default = (0, import_element76.memo)(Filters);

  // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
  var import_element77 = __toESM(require_element(), 1);
  var import_components51 = __toESM(require_components(), 1);
  var import_i18n94 = __toESM(require_i18n(), 1);
  var import_jsx_runtime177 = __toESM(require_jsx_runtime(), 1);
  function FiltersToggle() {
    const {
      filters,
      view: view2,
      onChangeView,
      setOpenedFilter,
      isShowingFilter,
      setIsShowingFilter
    } = (0, import_element77.useContext)(dataviews_context_default);
    const buttonRef = (0, import_element77.useRef)(null);
    const onChangeViewWithFilterVisibility = (0, import_element77.useCallback)(
      (_view) => {
        onChangeView(_view);
        setIsShowingFilter(true);
      },
      [onChangeView, setIsShowingFilter]
    );
    if (filters.length === 0) {
      return null;
    }
    const hasVisibleFilters = filters.some((filter) => filter.isVisible);
    const addFilterButtonProps = {
      label: (0, import_i18n94.__)("Add filter"),
      "aria-expanded": false,
      isPressed: false
    };
    const toggleFiltersButtonProps = {
      label: (0, import_i18n94._x)("Filter", "verb"),
      "aria-expanded": isShowingFilter,
      isPressed: isShowingFilter,
      onClick: () => {
        if (!isShowingFilter) {
          setOpenedFilter(null);
        }
        setIsShowingFilter(!isShowingFilter);
      }
    };
    const hasPrimaryOrLockedFilters = filters.some(
      (filter) => filter.isPrimary || filter.isLocked
    );
    const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
      import_components51.Button,
      {
        ref: buttonRef,
        className: "dataviews-filters__visibility-toggle",
        size: "compact",
        icon: funnel_default,
        disabled: hasPrimaryOrLockedFilters,
        accessibleWhenDisabled: true,
        ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
      }
    );
    return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
      AddFilterMenu,
      {
        filters,
        view: view2,
        onChangeView: onChangeViewWithFilterVisibility,
        setOpenedFilter,
        triggerProps: { render: buttonComponent }
      }
    ) : /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
      FilterVisibilityToggle,
      {
        buttonRef,
        filtersCount: view2.filters?.length,
        children: buttonComponent
      }
    ) });
  }
  function FilterVisibilityToggle({
    buttonRef,
    filtersCount,
    children
  }) {
    (0, import_element77.useEffect)(
      () => () => {
        buttonRef.current?.focus();
      },
      [buttonRef]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)(import_jsx_runtime177.Fragment, { children: [
      children,
      !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
    ] });
  }
  var toggle_default = FiltersToggle;

  // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
  var import_element78 = __toESM(require_element(), 1);
  var import_jsx_runtime178 = __toESM(require_jsx_runtime(), 1);
  function FiltersToggled(props) {
    const { isShowingFilter } = (0, import_element78.useContext)(dataviews_context_default);
    if (!isShowingFilter) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(filters_default, { ...props });
  }
  var filters_toggled_default = FiltersToggled;

  // packages/dataviews/build-module/components/dataviews-layout/index.mjs
  var import_element79 = __toESM(require_element(), 1);
  var import_components52 = __toESM(require_components(), 1);
  var import_i18n95 = __toESM(require_i18n(), 1);
  var import_jsx_runtime179 = __toESM(require_jsx_runtime(), 1);
  function DataViewsLayout({ className }) {
    const {
      actions: actions2 = [],
      data,
      fields: fields3,
      getItemId,
      getItemLevel,
      hasInitiallyLoaded,
      isLoading,
      view: view2,
      onChangeView,
      selection,
      onChangeSelection,
      setOpenedFilter,
      onClickItem,
      isItemClickable,
      renderItemLink,
      defaultLayouts: defaultLayouts2,
      containerRef,
      empty = /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("p", { children: (0, import_i18n95.__)("No results") })
    } = (0, import_element79.useContext)(dataviews_context_default);
    const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
      delay: 200
    });
    if (!hasInitiallyLoaded) {
      if (!isDelayedInitialLoading) {
        return null;
      }
      return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(import_components52.Spinner, {}) }) });
    }
    const ViewComponent = VIEW_LAYOUTS.find(
      (v3) => v3.type === view2.type && defaultLayouts2[v3.type]
    )?.component;
    return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
      ViewComponent,
      {
        className,
        actions: actions2,
        data,
        fields: fields3,
        getItemId,
        getItemLevel,
        isLoading,
        onChangeView,
        onChangeSelection,
        selection,
        setOpenedFilter,
        onClickItem,
        renderItemLink,
        isItemClickable,
        view: view2,
        empty
      }
    ) });
  }

  // packages/dataviews/build-module/components/dataviews-footer/index.mjs
  var import_element80 = __toESM(require_element(), 1);
  var import_jsx_runtime180 = __toESM(require_jsx_runtime(), 1);
  var EMPTY_ARRAY6 = [];
  function DataViewsFooter() {
    const {
      view: view2,
      paginationInfo: { totalItems = 0, totalPages },
      data,
      actions: actions2 = EMPTY_ARRAY6,
      isLoading,
      hasInitiallyLoaded
    } = (0, import_element80.useContext)(dataviews_context_default);
    const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
    const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
    const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view2.type);
    if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
      return null;
    }
    return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
      "div",
      {
        className: "dataviews-footer",
        inert: isRefreshing ? "true" : void 0,
        children: /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(
          Stack,
          {
            direction: "row",
            justify: "end",
            align: "center",
            className: clsx_default("dataviews-footer__content", {
              "is-refreshing": isDelayedRefreshing
            }),
            gap: "sm",
            children: [
              hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(BulkActionsFooter, {}),
              /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(dataviews_pagination_default, {})
            ]
          }
        )
      }
    );
  }

  // packages/dataviews/build-module/components/dataviews-search/index.mjs
  var import_i18n96 = __toESM(require_i18n(), 1);
  var import_element81 = __toESM(require_element(), 1);
  var import_components53 = __toESM(require_components(), 1);
  var import_compose14 = __toESM(require_compose(), 1);
  var import_jsx_runtime181 = __toESM(require_jsx_runtime(), 1);
  var DataViewsSearch = (0, import_element81.memo)(function Search({ label }) {
    const { view: view2, onChangeView } = (0, import_element81.useContext)(dataviews_context_default);
    const [search, setSearch, debouncedSearch] = (0, import_compose14.useDebouncedInput)(
      view2.search
    );
    (0, import_element81.useEffect)(() => {
      if (view2.search !== debouncedSearch) {
        setSearch(view2.search ?? "");
      }
    }, [view2.search, setSearch]);
    const onChangeViewRef = (0, import_element81.useRef)(onChangeView);
    const viewRef = (0, import_element81.useRef)(view2);
    (0, import_element81.useEffect)(() => {
      onChangeViewRef.current = onChangeView;
      viewRef.current = view2;
    }, [onChangeView, view2]);
    (0, import_element81.useEffect)(() => {
      if (debouncedSearch !== viewRef.current?.search) {
        onChangeViewRef.current({
          ...viewRef.current,
          page: view2.page ? 1 : void 0,
          startPosition: view2.startPosition ? 1 : void 0,
          search: debouncedSearch
        });
      }
    }, [debouncedSearch]);
    const searchLabel = label || (0, import_i18n96.__)("Search");
    return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
      import_components53.SearchControl,
      {
        className: "dataviews-search",
        onChange: setSearch,
        value: search,
        label: searchLabel,
        placeholder: searchLabel,
        size: "compact"
      }
    );
  });
  var dataviews_search_default = DataViewsSearch;

  // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
  var import_components54 = __toESM(require_components(), 1);
  var import_i18n97 = __toESM(require_i18n(), 1);
  var import_element82 = __toESM(require_element(), 1);
  var import_warning = __toESM(require_warning(), 1);
  var import_compose15 = __toESM(require_compose(), 1);
  var import_jsx_runtime182 = __toESM(require_jsx_runtime(), 1);
  var { Menu: Menu5 } = unlock3(import_components54.privateApis);
  var DATAVIEWS_CONFIG_POPOVER_PROPS = {
    className: "dataviews-config__popover",
    placement: "bottom-end",
    offset: 9
  };
  function ViewTypeMenu() {
    const { view: view2, onChangeView, defaultLayouts: defaultLayouts2 } = (0, import_element82.useContext)(dataviews_context_default);
    const availableLayouts = Object.keys(defaultLayouts2);
    if (availableLayouts.length <= 1) {
      return null;
    }
    const activeView = VIEW_LAYOUTS.find((v3) => view2.type === v3.type);
    return /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)(Menu5, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
        Menu5.TriggerButton,
        {
          render: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
            import_components54.Button,
            {
              size: "compact",
              icon: activeView?.icon,
              label: (0, import_i18n97.__)("Layout")
            }
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
        const config2 = VIEW_LAYOUTS.find(
          (v3) => v3.type === layout
        );
        if (!config2) {
          return null;
        }
        return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
          Menu5.RadioItem,
          {
            value: layout,
            name: "view-actions-available-view",
            checked: layout === view2.type,
            hideOnClick: true,
            onChange: (e3) => {
              switch (e3.target.value) {
                case "list":
                case "grid":
                case "table":
                case "pickerGrid":
                case "pickerTable":
                case "activity":
                  const viewWithoutLayout = { ...view2 };
                  if ("layout" in viewWithoutLayout) {
                    delete viewWithoutLayout.layout;
                  }
                  return onChangeView({
                    ...viewWithoutLayout,
                    type: e3.target.value,
                    ...defaultLayouts2[e3.target.value]
                  });
              }
              (0, import_warning.default)("Invalid dataview");
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(Menu5.ItemLabel, { children: config2.label })
          },
          layout
        );
      }) })
    ] });
  }
  function SortFieldControl() {
    const { view: view2, fields: fields3, onChangeView } = (0, import_element82.useContext)(dataviews_context_default);
    const orderOptions = (0, import_element82.useMemo)(() => {
      const sortableFields = fields3.filter(
        (field) => field.enableSorting !== false
      );
      return sortableFields.map((field) => {
        return {
          label: field.label,
          value: field.id
        };
      });
    }, [fields3]);
    return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
      import_components54.SelectControl,
      {
        __next40pxDefaultSize: true,
        label: (0, import_i18n97.__)("Sort by"),
        value: view2.sort?.field,
        options: orderOptions,
        onChange: (value) => {
          onChangeView({
            ...view2,
            sort: {
              direction: view2?.sort?.direction || "desc",
              field: value
            },
            showLevels: false
          });
        }
      }
    );
  }
  function SortDirectionControl() {
    const { view: view2, fields: fields3, onChangeView } = (0, import_element82.useContext)(dataviews_context_default);
    const sortableFields = fields3.filter(
      (field) => field.enableSorting !== false
    );
    if (sortableFields.length === 0) {
      return null;
    }
    let value = view2.sort?.direction;
    if (!value && view2.sort?.field) {
      value = "desc";
    }
    return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
      import_components54.__experimentalToggleGroupControl,
      {
        className: "dataviews-view-config__sort-direction",
        __next40pxDefaultSize: true,
        isBlock: true,
        label: (0, import_i18n97.__)("Order"),
        value,
        onChange: (newDirection) => {
          if (newDirection === "asc" || newDirection === "desc") {
            onChangeView({
              ...view2,
              sort: {
                direction: newDirection,
                field: view2.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
                fields3.find(
                  (field) => field.enableSorting !== false
                )?.id || ""
              },
              showLevels: false
            });
            return;
          }
          (0, import_warning.default)("Invalid direction");
        },
        children: SORTING_DIRECTIONS.map((direction) => {
          return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
            import_components54.__experimentalToggleGroupControlOptionIcon,
            {
              value: direction,
              icon: sortIcons[direction],
              label: sortLabels[direction]
            },
            direction
          );
        })
      }
    );
  }
  function ItemsPerPageControl() {
    const { view: view2, config: config2, onChangeView } = (0, import_element82.useContext)(dataviews_context_default);
    const { infiniteScrollEnabled } = view2;
    if (!config2 || !config2.perPageSizes || config2.perPageSizes.length < 2 || config2.perPageSizes.length > 6 || infiniteScrollEnabled) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
      import_components54.__experimentalToggleGroupControl,
      {
        __next40pxDefaultSize: true,
        isBlock: true,
        label: (0, import_i18n97.__)("Items per page"),
        value: view2.perPage || 10,
        disabled: !view2?.sort?.field,
        onChange: (newItemsPerPage) => {
          const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
          onChangeView({
            ...view2,
            perPage: newItemsPerPageNumber,
            page: 1
          });
        },
        children: config2.perPageSizes.map((value) => {
          return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
            import_components54.__experimentalToggleGroupControlOption,
            {
              value,
              label: value.toString()
            },
            value
          );
        })
      }
    );
  }
  function ResetViewButton() {
    const { onReset } = (0, import_element82.useContext)(dataviews_context_default);
    if (onReset === void 0) {
      return null;
    }
    const isDisabled = onReset === false;
    return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
      import_components54.Button,
      {
        variant: "tertiary",
        size: "compact",
        disabled: isDisabled,
        accessibleWhenDisabled: true,
        className: "dataviews-view-config__reset-button",
        onClick: () => {
          if (typeof onReset === "function") {
            onReset();
          }
        },
        children: (0, import_i18n97.__)("Reset view")
      }
    );
  }
  function DataviewsViewConfigDropdown() {
    const { view: view2, onReset } = (0, import_element82.useContext)(dataviews_context_default);
    const popoverId = (0, import_compose15.useInstanceId)(
      _DataViewsViewConfig,
      "dataviews-view-config-dropdown"
    );
    const activeLayout = VIEW_LAYOUTS.find(
      (layout) => layout.type === view2.type
    );
    const isModified = typeof onReset === "function";
    return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
      import_components54.Dropdown,
      {
        expandOnMobile: true,
        popoverProps: {
          ...DATAVIEWS_CONFIG_POPOVER_PROPS,
          id: popoverId
        },
        renderToggle: ({ onToggle, isOpen: isOpen2 }) => {
          return /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
            /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
              import_components54.Button,
              {
                size: "compact",
                icon: cog_default,
                label: (0, import_i18n97._x)(
                  "View options",
                  "View is used as a noun"
                ),
                onClick: onToggle,
                "aria-expanded": isOpen2 ? "true" : "false",
                "aria-controls": popoverId
              }
            ),
            isModified && /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
          ] });
        },
        renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
          import_components54.__experimentalDropdownContentWrapper,
          {
            paddingSize: "medium",
            className: "dataviews-config__popover-content-wrapper",
            children: /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)(
              Stack,
              {
                direction: "column",
                className: "dataviews-view-config",
                gap: "xl",
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)(
                    Stack,
                    {
                      direction: "row",
                      justify: "space-between",
                      align: "center",
                      className: "dataviews-view-config__header",
                      children: [
                        /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
                          import_components54.__experimentalHeading,
                          {
                            level: 2,
                            className: "dataviews-settings-section__title",
                            children: (0, import_i18n97.__)("Appearance")
                          }
                        ),
                        /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(ResetViewButton, {})
                      ]
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)(Stack, { direction: "column", gap: "lg", children: [
                    /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)(
                      Stack,
                      {
                        direction: "row",
                        gap: "sm",
                        className: "dataviews-view-config__sort-controls",
                        children: [
                          /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(SortFieldControl, {}),
                          /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(SortDirectionControl, {})
                        ]
                      }
                    ),
                    !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(activeLayout.viewConfigOptions, {}),
                    /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(ItemsPerPageControl, {}),
                    /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(PropertiesSection, {})
                  ] })
                ]
              }
            )
          }
        )
      }
    );
  }
  function _DataViewsViewConfig() {
    return /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)(import_jsx_runtime182.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(ViewTypeMenu, {}),
      /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(DataviewsViewConfigDropdown, {})
    ] });
  }
  var DataViewsViewConfig = (0, import_element82.memo)(_DataViewsViewConfig);
  var dataviews_view_config_default = DataViewsViewConfig;

  // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
  var import_components55 = __toESM(require_components(), 1);
  var import_element83 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
  function getCustomValidity(isValid2, validity) {
    let customValidity;
    if (isValid2?.required && validity?.required) {
      customValidity = validity?.required?.message ? validity.required : void 0;
    } else if (isValid2?.pattern && validity?.pattern) {
      customValidity = validity.pattern;
    } else if (isValid2?.min && validity?.min) {
      customValidity = validity.min;
    } else if (isValid2?.max && validity?.max) {
      customValidity = validity.max;
    } else if (isValid2?.minLength && validity?.minLength) {
      customValidity = validity.minLength;
    } else if (isValid2?.maxLength && validity?.maxLength) {
      customValidity = validity.maxLength;
    } else if (isValid2?.elements && validity?.elements) {
      customValidity = validity.elements;
    } else if (validity?.custom) {
      customValidity = validity.custom;
    }
    return customValidity;
  }

  // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
  var import_jsx_runtime183 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedCheckboxControl } = unlock3(import_components55.privateApis);
  function Checkbox({
    field,
    onChange,
    data,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const { getValue: getValue2, setValue, label, description, isValid: isValid2 } = field;
    const disabled2 = field.isDisabled({ item: data, field });
    const onChangeControl = (0, import_element83.useCallback)(() => {
      onChange(
        setValue({ item: data, value: !getValue2({ item: data }) })
      );
    }, [data, getValue2, onChange, setValue]);
    return /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
      ValidatedCheckboxControl,
      {
        required: !!field.isValid?.required,
        markWhenOptional,
        customValidity: getCustomValidity(isValid2, validity),
        hidden: hideLabelFromVision,
        label,
        help: description,
        checked: getValue2({ item: data }),
        onChange: onChangeControl,
        disabled: disabled2
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
  var import_components56 = __toESM(require_components(), 1);
  var import_element84 = __toESM(require_element(), 1);
  var import_jsx_runtime184 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedComboboxControl } = unlock3(import_components56.privateApis);
  function Combobox3({
    data,
    field,
    onChange,
    hideLabelFromVision,
    validity
  }) {
    const { label, description, placeholder, getValue: getValue2, setValue, isValid: isValid2 } = field;
    const value = getValue2({ item: data }) ?? "";
    const onChangeControl = (0, import_element84.useCallback)(
      (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
      [data, onChange, setValue]
    );
    const { elements: elements2, isLoading } = useElements({
      elements: field.elements,
      getElements: field.getElements
    });
    if (isLoading) {
      return /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(import_components56.Spinner, {});
    }
    return /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
      ValidatedComboboxControl,
      {
        required: !!field.isValid?.required,
        customValidity: getCustomValidity(isValid2, validity),
        label,
        value,
        help: description,
        placeholder,
        options: elements2,
        onChange: onChangeControl,
        hideLabelFromVision,
        allowReset: true,
        expandOnFocus: true
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
  var import_components58 = __toESM(require_components(), 1);
  var import_element87 = __toESM(require_element(), 1);
  var import_i18n99 = __toESM(require_i18n(), 1);
  var import_date8 = __toESM(require_date(), 1);

  // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
  var import_components57 = __toESM(require_components(), 1);
  var import_element85 = __toESM(require_element(), 1);
  var import_i18n98 = __toESM(require_i18n(), 1);
  var import_jsx_runtime185 = __toESM(require_jsx_runtime(), 1);
  var TIME_UNITS_OPTIONS = {
    [OPERATOR_IN_THE_PAST]: [
      { value: "days", label: (0, import_i18n98.__)("Days") },
      { value: "weeks", label: (0, import_i18n98.__)("Weeks") },
      { value: "months", label: (0, import_i18n98.__)("Months") },
      { value: "years", label: (0, import_i18n98.__)("Years") }
    ],
    [OPERATOR_OVER]: [
      { value: "days", label: (0, import_i18n98.__)("Days ago") },
      { value: "weeks", label: (0, import_i18n98.__)("Weeks ago") },
      { value: "months", label: (0, import_i18n98.__)("Months ago") },
      { value: "years", label: (0, import_i18n98.__)("Years ago") }
    ]
  };
  function RelativeDateControl({
    className,
    data,
    field,
    onChange,
    hideLabelFromVision,
    operator
  }) {
    const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
    const { id, label, description, getValue: getValue2, setValue } = field;
    const disabled2 = field.isDisabled({ item: data, field });
    const fieldValue = getValue2({ item: data });
    const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
    const onChangeValue = (0, import_element85.useCallback)(
      (newValue) => onChange(
        setValue({
          item: data,
          value: { value: Number(newValue), unit }
        })
      ),
      [onChange, setValue, data, unit]
    );
    const onChangeUnit = (0, import_element85.useCallback)(
      (newUnit) => onChange(
        setValue({
          item: data,
          value: { value: relValue, unit: newUnit }
        })
      ),
      [onChange, setValue, data, relValue]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
      import_components57.BaseControl,
      {
        id,
        className: clsx_default(className, "dataviews-controls__relative-date"),
        label,
        hideLabelFromVision,
        help: description,
        children: /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(Stack, { direction: "row", gap: "sm", children: [
          /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
            import_components57.__experimentalNumberControl,
            {
              __next40pxDefaultSize: true,
              className: "dataviews-controls__relative-date-number",
              spinControls: "none",
              min: 1,
              step: 1,
              value: relValue,
              onChange: onChangeValue,
              disabled: disabled2
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
            import_components57.SelectControl,
            {
              className: "dataviews-controls__relative-date-unit",
              __next40pxDefaultSize: true,
              label: (0, import_i18n98.__)("Unit"),
              value: unit,
              options,
              onChange: onChangeUnit,
              hideLabelFromVision: true,
              disabled: disabled2
            }
          )
        ] })
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
  var import_element86 = __toESM(require_element(), 1);
  function useDisabledDateMatchers(isValid2, parseDateFn) {
    const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
    const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
    const disabledMatchers = (0, import_element86.useMemo)(() => {
      const matchers = [];
      if (minConstraint) {
        const minDate = parseDateFn(minConstraint);
        if (minDate) {
          matchers.push({ before: minDate });
        }
      }
      if (maxConstraint) {
        const maxDate = parseDateFn(maxConstraint);
        if (maxDate) {
          matchers.push({ after: maxDate });
        }
      }
      return matchers.length > 0 ? matchers : void 0;
    }, [minConstraint, maxConstraint, parseDateFn]);
    return { minConstraint, maxConstraint, disabledMatchers };
  }

  // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
  var import_date7 = __toESM(require_date(), 1);
  function parseDateTime(dateTimeString) {
    if (!dateTimeString) {
      return null;
    }
    const parsed = (0, import_date7.getDate)(dateTimeString);
    return parsed && isValid(parsed) ? parsed : null;
  }

  // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
  var import_jsx_runtime186 = __toESM(require_jsx_runtime(), 1);
  var { DateCalendar, ValidatedInputControl } = unlock3(import_components58.privateApis);
  var formatDateTime = (value) => {
    if (!value) {
      return "";
    }
    return (0, import_date8.dateI18n)("Y-m-d\\TH:i", (0, import_date8.getDate)(value));
  };
  function CalendarDateTimeControl({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity,
    config: config2
  }) {
    const { compact } = config2 || {};
    const { id, label, description, setValue, getValue: getValue2, isValid: isValid2 } = field;
    const disabled2 = field.isDisabled({ item: data, field });
    const fieldValue = getValue2({ item: data });
    const value = typeof fieldValue === "string" ? fieldValue : void 0;
    const [calendarMonth, setCalendarMonth] = (0, import_element87.useState)(() => {
      const parsedDate = parseDateTime(value);
      return parsedDate || /* @__PURE__ */ new Date();
    });
    const inputControlRef = (0, import_element87.useRef)(null);
    const validationTimeoutRef = (0, import_element87.useRef)(void 0);
    const previousFocusRef = (0, import_element87.useRef)(null);
    const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
    const onChangeCallback = (0, import_element87.useCallback)(
      (newValue) => onChange(setValue({ item: data, value: newValue })),
      [data, onChange, setValue]
    );
    (0, import_element87.useEffect)(() => {
      return () => {
        if (validationTimeoutRef.current) {
          clearTimeout(validationTimeoutRef.current);
        }
      };
    }, []);
    const onSelectDate = (0, import_element87.useCallback)(
      (newDate) => {
        let dateTimeValue;
        if (newDate) {
          const wpDate = (0, import_date8.dateI18n)("Y-m-d", newDate);
          let wpTime;
          if (value) {
            wpTime = (0, import_date8.dateI18n)("H:i", (0, import_date8.getDate)(value));
          } else {
            wpTime = (0, import_date8.dateI18n)("H:i", newDate);
          }
          const finalDateTime = (0, import_date8.getDate)(`${wpDate}T${wpTime}`);
          dateTimeValue = finalDateTime.toISOString();
          onChangeCallback(dateTimeValue);
          if (validationTimeoutRef.current) {
            clearTimeout(validationTimeoutRef.current);
          }
        } else {
          onChangeCallback(void 0);
        }
        previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
        validationTimeoutRef.current = setTimeout(() => {
          if (inputControlRef.current) {
            inputControlRef.current.focus();
            inputControlRef.current.blur();
            onChangeCallback(dateTimeValue);
            if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
              previousFocusRef.current.focus();
            }
          }
        }, 0);
      },
      [onChangeCallback, value]
    );
    const handleManualDateTimeChange = (0, import_element87.useCallback)(
      (newValue) => {
        if (newValue) {
          const dateTime = (0, import_date8.getDate)(newValue);
          onChangeCallback(dateTime.toISOString());
          const parsedDate = parseDateTime(dateTime.toISOString());
          if (parsedDate) {
            setCalendarMonth(parsedDate);
          }
        } else {
          onChangeCallback(void 0);
        }
      },
      [onChangeCallback]
    );
    const { format: fieldFormat } = field;
    const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date8.getSettings)().l10n.startOfWeek;
    const {
      timezone: { string: timezoneString }
    } = (0, import_date8.getSettings)();
    let displayLabel = label;
    if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
      displayLabel = `${label} (${(0, import_i18n99.__)("Required")})`;
    } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
      displayLabel = `${label} (${(0, import_i18n99.__)("Optional")})`;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
      import_components58.BaseControl,
      {
        id,
        label: displayLabel,
        help: description,
        hideLabelFromVision,
        children: /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(Stack, { direction: "column", gap: "lg", children: [
          /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
            ValidatedInputControl,
            {
              ref: inputControlRef,
              __next40pxDefaultSize: true,
              required: !!isValid2?.required,
              customValidity: getCustomValidity(isValid2, validity),
              type: "datetime-local",
              label: (0, import_i18n99.__)("Date time"),
              hideLabelFromVision: true,
              value: formatDateTime(value),
              onChange: handleManualDateTimeChange,
              disabled: disabled2,
              min: minConstraint ? formatDateTime(minConstraint) : void 0,
              max: maxConstraint ? formatDateTime(maxConstraint) : void 0
            }
          ),
          !compact && /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
            DateCalendar,
            {
              style: { width: "100%" },
              selected: value ? parseDateTime(value) || void 0 : void 0,
              onSelect: onSelectDate,
              month: calendarMonth,
              onMonthChange: setCalendarMonth,
              timeZone: timezoneString || void 0,
              weekStartsOn,
              disabled: disabled2 || disabledMatchers
            }
          )
        ] })
      }
    );
  }
  function DateTime({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    operator,
    validity,
    config: config2
  }) {
    if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
      return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
        RelativeDateControl,
        {
          className: "dataviews-controls__datetime",
          data,
          field,
          onChange,
          hideLabelFromVision,
          operator
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
      CalendarDateTimeControl,
      {
        data,
        field,
        onChange,
        hideLabelFromVision,
        markWhenOptional,
        validity,
        config: config2
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/date.mjs
  var import_components59 = __toESM(require_components(), 1);
  var import_element88 = __toESM(require_element(), 1);
  var import_i18n100 = __toESM(require_i18n(), 1);
  var import_date9 = __toESM(require_date(), 1);
  var import_jsx_runtime187 = __toESM(require_jsx_runtime(), 1);
  var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components59.privateApis);
  var DATE_PRESETS = [
    {
      id: "today",
      label: (0, import_i18n100.__)("Today"),
      getValue: () => (0, import_date9.getDate)(null)
    },
    {
      id: "yesterday",
      label: (0, import_i18n100.__)("Yesterday"),
      getValue: () => {
        const today = (0, import_date9.getDate)(null);
        return subDays(today, 1);
      }
    },
    {
      id: "past-week",
      label: (0, import_i18n100.__)("Past week"),
      getValue: () => {
        const today = (0, import_date9.getDate)(null);
        return subDays(today, 7);
      }
    },
    {
      id: "past-month",
      label: (0, import_i18n100.__)("Past month"),
      getValue: () => {
        const today = (0, import_date9.getDate)(null);
        return subMonths(today, 1);
      }
    }
  ];
  var DATE_RANGE_PRESETS = [
    {
      id: "last-7-days",
      label: (0, import_i18n100.__)("Last 7 days"),
      getValue: () => {
        const today = (0, import_date9.getDate)(null);
        return [subDays(today, 7), today];
      }
    },
    {
      id: "last-30-days",
      label: (0, import_i18n100.__)("Last 30 days"),
      getValue: () => {
        const today = (0, import_date9.getDate)(null);
        return [subDays(today, 30), today];
      }
    },
    {
      id: "month-to-date",
      label: (0, import_i18n100.__)("Month to date"),
      getValue: () => {
        const today = (0, import_date9.getDate)(null);
        return [startOfMonth(today), today];
      }
    },
    {
      id: "last-year",
      label: (0, import_i18n100.__)("Last year"),
      getValue: () => {
        const today = (0, import_date9.getDate)(null);
        return [subYears(today, 1), today];
      }
    },
    {
      id: "year-to-date",
      label: (0, import_i18n100.__)("Year to date"),
      getValue: () => {
        const today = (0, import_date9.getDate)(null);
        return [startOfYear(today), today];
      }
    }
  ];
  var parseDate = (dateString) => {
    if (!dateString) {
      return null;
    }
    const parsed = (0, import_date9.getDate)(dateString);
    return parsed && isValid(parsed) ? parsed : null;
  };
  var formatDate = (date) => {
    if (!date) {
      return "";
    }
    return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
  };
  function ValidatedDateControl({
    field,
    validity,
    inputRefs,
    isTouched,
    setIsTouched,
    children
  }) {
    const { isValid: isValid2 } = field;
    const [customValidity, setCustomValidity] = (0, import_element88.useState)(void 0);
    const validateRefs = (0, import_element88.useCallback)(() => {
      const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
      for (const ref of refs) {
        const input = ref.current;
        if (input && !input.validity.valid) {
          setCustomValidity({
            type: "invalid",
            message: input.validationMessage
          });
          return;
        }
      }
      setCustomValidity(void 0);
    }, [inputRefs]);
    (0, import_element88.useEffect)(() => {
      const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
      const result = validity ? getCustomValidity(isValid2, validity) : void 0;
      for (const ref of refs) {
        const input = ref.current;
        if (input) {
          input.setCustomValidity(
            result?.type === "invalid" && result.message ? result.message : ""
          );
        }
      }
    }, [inputRefs, isValid2, validity]);
    (0, import_element88.useEffect)(() => {
      const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
      const handleInvalid = (event) => {
        event.preventDefault();
        setIsTouched(true);
      };
      for (const ref of refs) {
        ref.current?.addEventListener("invalid", handleInvalid);
      }
      return () => {
        for (const ref of refs) {
          ref.current?.removeEventListener("invalid", handleInvalid);
        }
      };
    }, [inputRefs, setIsTouched]);
    (0, import_element88.useEffect)(() => {
      if (!isTouched) {
        return;
      }
      const result = validity ? getCustomValidity(isValid2, validity) : void 0;
      if (result) {
        setCustomValidity(result);
      } else {
        validateRefs();
      }
    }, [isTouched, isValid2, validity, validateRefs]);
    const onBlur = (event) => {
      if (isTouched) {
        return;
      }
      if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
        setIsTouched(true);
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)("div", { onBlur, children: [
      children,
      /* @__PURE__ */ (0, import_jsx_runtime187.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(
        "p",
        {
          className: clsx_default(
            "components-validated-control__indicator",
            customValidity.type === "invalid" ? "is-invalid" : void 0
          ),
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
              import_components59.Icon,
              {
                className: "components-validated-control__indicator-icon",
                icon: error_default,
                size: 16,
                fill: "currentColor"
              }
            ),
            customValidity.message
          ]
        }
      ) })
    ] });
  }
  function CalendarDateControl({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const {
      id,
      label,
      description,
      setValue,
      getValue: getValue2,
      isValid: isValid2,
      format: fieldFormat
    } = field;
    const disabled2 = field.isDisabled({ item: data, field });
    const [selectedPresetId, setSelectedPresetId] = (0, import_element88.useState)(
      null
    );
    const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date9.getSettings)().l10n.startOfWeek;
    const fieldValue = getValue2({ item: data });
    const value = typeof fieldValue === "string" ? fieldValue : void 0;
    const [calendarMonth, setCalendarMonth] = (0, import_element88.useState)(() => {
      const parsedDate = parseDate(value);
      return parsedDate || /* @__PURE__ */ new Date();
    });
    const [isTouched, setIsTouched] = (0, import_element88.useState)(false);
    const validityTargetRef = (0, import_element88.useRef)(null);
    const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
    const onChangeCallback = (0, import_element88.useCallback)(
      (newValue) => onChange(setValue({ item: data, value: newValue })),
      [data, onChange, setValue]
    );
    const onSelectDate = (0, import_element88.useCallback)(
      (newDate) => {
        const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
        onChangeCallback(dateValue);
        setSelectedPresetId(null);
        setIsTouched(true);
      },
      [onChangeCallback]
    );
    const handlePresetClick = (0, import_element88.useCallback)(
      (preset) => {
        const presetDate = preset.getValue();
        const dateValue = formatDate(presetDate);
        setCalendarMonth(presetDate);
        onChangeCallback(dateValue);
        setSelectedPresetId(preset.id);
        setIsTouched(true);
      },
      [onChangeCallback]
    );
    const handleManualDateChange = (0, import_element88.useCallback)(
      (newValue) => {
        onChangeCallback(newValue);
        if (newValue) {
          const parsedDate = parseDate(newValue);
          if (parsedDate) {
            setCalendarMonth(parsedDate);
          }
        }
        setSelectedPresetId(null);
        setIsTouched(true);
      },
      [onChangeCallback]
    );
    const {
      timezone: { string: timezoneString }
    } = (0, import_date9.getSettings)();
    let displayLabel = label;
    if (isValid2?.required && !markWhenOptional) {
      displayLabel = `${label} (${(0, import_i18n100.__)("Required")})`;
    } else if (!isValid2?.required && markWhenOptional) {
      displayLabel = `${label} (${(0, import_i18n100.__)("Optional")})`;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
      ValidatedDateControl,
      {
        field,
        validity,
        inputRefs: validityTargetRef,
        isTouched,
        setIsTouched,
        children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
          import_components59.BaseControl,
          {
            id,
            className: "dataviews-controls__date",
            label: displayLabel,
            help: description,
            hideLabelFromVision,
            children: /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Stack, { direction: "column", gap: "lg", children: [
              /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(
                Stack,
                {
                  direction: "row",
                  gap: "sm",
                  wrap: "wrap",
                  justify: "flex-start",
                  children: [
                    DATE_PRESETS.map((preset) => {
                      const isSelected2 = selectedPresetId === preset.id;
                      return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
                        import_components59.Button,
                        {
                          className: "dataviews-controls__date-preset",
                          variant: "tertiary",
                          isPressed: isSelected2,
                          size: "small",
                          disabled: disabled2,
                          accessibleWhenDisabled: true,
                          onClick: () => handlePresetClick(preset),
                          children: preset.label
                        },
                        preset.id
                      );
                    }),
                    /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
                      import_components59.Button,
                      {
                        className: "dataviews-controls__date-preset",
                        variant: "tertiary",
                        isPressed: !selectedPresetId,
                        size: "small",
                        disabled: !!selectedPresetId || disabled2,
                        accessibleWhenDisabled: true,
                        children: (0, import_i18n100.__)("Custom")
                      }
                    )
                  ]
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
                import_components59.__experimentalInputControl,
                {
                  __next40pxDefaultSize: true,
                  ref: validityTargetRef,
                  type: "date",
                  label: (0, import_i18n100.__)("Date"),
                  hideLabelFromVision: true,
                  value,
                  onChange: handleManualDateChange,
                  required: !!field.isValid?.required,
                  disabled: disabled2,
                  min: minConstraint,
                  max: maxConstraint
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
                DateCalendar2,
                {
                  style: { width: "100%" },
                  selected: value ? parseDate(value) || void 0 : void 0,
                  onSelect: onSelectDate,
                  month: calendarMonth,
                  onMonthChange: setCalendarMonth,
                  timeZone: timezoneString || void 0,
                  weekStartsOn,
                  disabled: disabled2 || disabledMatchers,
                  disableNavigation: disabled2
                }
              )
            ] })
          }
        )
      }
    );
  }
  function CalendarDateRangeControl({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const {
      id,
      label,
      description,
      getValue: getValue2,
      setValue,
      isValid: isValid2,
      format: fieldFormat
    } = field;
    const disabled2 = field.isDisabled({ item: data, field });
    let value;
    const fieldValue = getValue2({ item: data });
    if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
      value = fieldValue;
    }
    const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date9.getSettings)().l10n.startOfWeek;
    const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
    const onChangeCallback = (0, import_element88.useCallback)(
      (newValue) => {
        onChange(
          setValue({
            item: data,
            value: newValue
          })
        );
      },
      [data, onChange, setValue]
    );
    const [selectedPresetId, setSelectedPresetId] = (0, import_element88.useState)(
      null
    );
    const selectedRange = (0, import_element88.useMemo)(() => {
      if (!value) {
        return { from: void 0, to: void 0 };
      }
      const [from, to2] = value;
      return {
        from: parseDate(from) || void 0,
        to: parseDate(to2) || void 0
      };
    }, [value]);
    const [calendarMonth, setCalendarMonth] = (0, import_element88.useState)(() => {
      return selectedRange.from || /* @__PURE__ */ new Date();
    });
    const [isTouched, setIsTouched] = (0, import_element88.useState)(false);
    const fromInputRef = (0, import_element88.useRef)(null);
    const toInputRef = (0, import_element88.useRef)(null);
    const updateDateRange = (0, import_element88.useCallback)(
      (fromDate, toDate3) => {
        if (fromDate && toDate3) {
          onChangeCallback([
            formatDate(fromDate),
            formatDate(toDate3)
          ]);
        } else if (!fromDate && !toDate3) {
          onChangeCallback(void 0);
        }
      },
      [onChangeCallback]
    );
    const onSelectCalendarRange = (0, import_element88.useCallback)(
      (newRange) => {
        updateDateRange(newRange?.from, newRange?.to);
        setSelectedPresetId(null);
        setIsTouched(true);
      },
      [updateDateRange]
    );
    const handlePresetClick = (0, import_element88.useCallback)(
      (preset) => {
        const [startDate2, endDate] = preset.getValue();
        setCalendarMonth(startDate2);
        updateDateRange(startDate2, endDate);
        setSelectedPresetId(preset.id);
        setIsTouched(true);
      },
      [updateDateRange]
    );
    const handleManualDateChange = (0, import_element88.useCallback)(
      (fromOrTo, newValue) => {
        const [currentFrom, currentTo] = value || [
          void 0,
          void 0
        ];
        const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
        const updatedTo = fromOrTo === "to" ? newValue : currentTo;
        updateDateRange(updatedFrom, updatedTo);
        if (newValue) {
          const parsedDate = parseDate(newValue);
          if (parsedDate) {
            setCalendarMonth(parsedDate);
          }
        }
        setSelectedPresetId(null);
        setIsTouched(true);
      },
      [value, updateDateRange]
    );
    const { timezone } = (0, import_date9.getSettings)();
    let displayLabel = label;
    if (field.isValid?.required && !markWhenOptional) {
      displayLabel = `${label} (${(0, import_i18n100.__)("Required")})`;
    } else if (!field.isValid?.required && markWhenOptional) {
      displayLabel = `${label} (${(0, import_i18n100.__)("Optional")})`;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
      ValidatedDateControl,
      {
        field,
        validity,
        inputRefs: [fromInputRef, toInputRef],
        isTouched,
        setIsTouched,
        children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
          import_components59.BaseControl,
          {
            id,
            className: "dataviews-controls__date",
            label: displayLabel,
            help: description,
            hideLabelFromVision,
            children: /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Stack, { direction: "column", gap: "lg", children: [
              /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(
                Stack,
                {
                  direction: "row",
                  gap: "sm",
                  wrap: "wrap",
                  justify: "flex-start",
                  children: [
                    DATE_RANGE_PRESETS.map((preset) => {
                      const isSelected2 = selectedPresetId === preset.id;
                      return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
                        import_components59.Button,
                        {
                          className: "dataviews-controls__date-preset",
                          variant: "tertiary",
                          isPressed: isSelected2,
                          size: "small",
                          disabled: disabled2,
                          accessibleWhenDisabled: true,
                          onClick: () => handlePresetClick(preset),
                          children: preset.label
                        },
                        preset.id
                      );
                    }),
                    /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
                      import_components59.Button,
                      {
                        className: "dataviews-controls__date-preset",
                        variant: "tertiary",
                        isPressed: !selectedPresetId,
                        size: "small",
                        accessibleWhenDisabled: true,
                        disabled: !!selectedPresetId || disabled2,
                        children: (0, import_i18n100.__)("Custom")
                      }
                    )
                  ]
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(
                Stack,
                {
                  direction: "row",
                  gap: "sm",
                  justify: "space-between",
                  className: "dataviews-controls__date-range-inputs",
                  children: [
                    /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
                      import_components59.__experimentalInputControl,
                      {
                        __next40pxDefaultSize: true,
                        ref: fromInputRef,
                        type: "date",
                        label: (0, import_i18n100.__)("From"),
                        hideLabelFromVision: true,
                        value: value?.[0],
                        onChange: (newValue) => handleManualDateChange("from", newValue),
                        required: !!field.isValid?.required,
                        disabled: disabled2,
                        min: minConstraint,
                        max: maxConstraint
                      }
                    ),
                    /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
                      import_components59.__experimentalInputControl,
                      {
                        __next40pxDefaultSize: true,
                        ref: toInputRef,
                        type: "date",
                        label: (0, import_i18n100.__)("To"),
                        hideLabelFromVision: true,
                        value: value?.[1],
                        onChange: (newValue) => handleManualDateChange("to", newValue),
                        required: !!field.isValid?.required,
                        disabled: disabled2,
                        min: minConstraint,
                        max: maxConstraint
                      }
                    )
                  ]
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
                DateRangeCalendar,
                {
                  style: { width: "100%" },
                  selected: selectedRange,
                  onSelect: onSelectCalendarRange,
                  month: calendarMonth,
                  onMonthChange: setCalendarMonth,
                  timeZone: timezone.string || void 0,
                  weekStartsOn,
                  disabled: disabled2 || disabledMatchers
                }
              )
            ] })
          }
        )
      }
    );
  }
  function DateControl({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    operator,
    validity
  }) {
    if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
      return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
        RelativeDateControl,
        {
          className: "dataviews-controls__date",
          data,
          field,
          onChange,
          hideLabelFromVision,
          operator
        }
      );
    }
    if (operator === OPERATOR_BETWEEN) {
      return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
        CalendarDateRangeControl,
        {
          data,
          field,
          onChange,
          hideLabelFromVision,
          markWhenOptional,
          validity
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
      CalendarDateControl,
      {
        data,
        field,
        onChange,
        hideLabelFromVision,
        markWhenOptional,
        validity
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/select.mjs
  var import_components60 = __toESM(require_components(), 1);
  var import_element89 = __toESM(require_element(), 1);
  var import_jsx_runtime188 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedSelectControl } = unlock3(import_components60.privateApis);
  function Select({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const { type, label, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
    const disabled2 = field.isDisabled({ item: data, field });
    const isMultiple = type === "array";
    const value = getValue2({ item: data }) ?? (isMultiple ? [] : "");
    const onChangeControl = (0, import_element89.useCallback)(
      (newValue) => onChange(setValue({ item: data, value: newValue })),
      [data, onChange, setValue]
    );
    const { elements: elements2, isLoading } = useElements({
      elements: field.elements,
      getElements: field.getElements
    });
    if (isLoading) {
      return /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(import_components60.Spinner, {});
    }
    return /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
      ValidatedSelectControl,
      {
        required: !!field.isValid?.required,
        markWhenOptional,
        customValidity: getCustomValidity(isValid2, validity),
        label,
        value,
        help: description,
        options: elements2,
        onChange: onChangeControl,
        __next40pxDefaultSize: true,
        hideLabelFromVision,
        multiple: isMultiple,
        disabled: disabled2
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
  var import_jsx_runtime189 = __toESM(require_jsx_runtime(), 1);
  var ELEMENTS_THRESHOLD = 10;
  function AdaptiveSelect(props) {
    const { field } = props;
    const { elements: elements2 } = useElements({
      elements: field.elements,
      getElements: field.getElements
    });
    if (elements2.length >= ELEMENTS_THRESHOLD) {
      return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(Combobox3, { ...props });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(Select, { ...props });
  }

  // packages/dataviews/build-module/components/dataform-controls/email.mjs
  var import_components62 = __toESM(require_components(), 1);

  // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
  var import_components61 = __toESM(require_components(), 1);
  var import_element90 = __toESM(require_element(), 1);
  var import_jsx_runtime190 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components61.privateApis);
  function ValidatedText({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    type,
    prefix: prefix2,
    suffix,
    validity
  }) {
    const { label, placeholder, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
    const value = getValue2({ item: data });
    const disabled2 = field.isDisabled({ item: data, field });
    const onChangeControl = (0, import_element90.useCallback)(
      (newValue) => onChange(
        setValue({
          item: data,
          value: newValue
        })
      ),
      [data, setValue, onChange]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
      ValidatedInputControl2,
      {
        required: !!isValid2.required,
        markWhenOptional,
        customValidity: getCustomValidity(isValid2, validity),
        label,
        placeholder,
        value: value ?? "",
        help: description,
        onChange: onChangeControl,
        hideLabelFromVision,
        type,
        prefix: prefix2,
        suffix,
        disabled: disabled2,
        pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
        minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
        maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
        __next40pxDefaultSize: true
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/email.mjs
  var import_jsx_runtime191 = __toESM(require_jsx_runtime(), 1);
  function Email({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
      ValidatedText,
      {
        ...{
          data,
          field,
          onChange,
          hideLabelFromVision,
          markWhenOptional,
          validity,
          type: "email",
          prefix: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(import_components62.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(import_components62.Icon, { icon: envelope_default }) })
        }
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
  var import_components63 = __toESM(require_components(), 1);
  var import_jsx_runtime192 = __toESM(require_jsx_runtime(), 1);
  function Telephone({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(
      ValidatedText,
      {
        ...{
          data,
          field,
          onChange,
          hideLabelFromVision,
          markWhenOptional,
          validity,
          type: "tel",
          prefix: /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_components63.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_components63.Icon, { icon: mobile_default }) })
        }
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/url.mjs
  var import_components64 = __toESM(require_components(), 1);
  var import_jsx_runtime193 = __toESM(require_jsx_runtime(), 1);
  function Url({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
      ValidatedText,
      {
        ...{
          data,
          field,
          onChange,
          hideLabelFromVision,
          markWhenOptional,
          validity,
          type: "url",
          prefix: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components64.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components64.Icon, { icon: link_default }) })
        }
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
  var import_components65 = __toESM(require_components(), 1);
  var import_element91 = __toESM(require_element(), 1);
  var import_i18n101 = __toESM(require_i18n(), 1);
  var import_jsx_runtime194 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedNumberControl } = unlock3(import_components65.privateApis);
  function toNumberOrEmpty(value) {
    if (value === "" || value === void 0) {
      return "";
    }
    const number = Number(value);
    return Number.isFinite(number) ? number : "";
  }
  function BetweenControls({
    value,
    onChange,
    hideLabelFromVision,
    step
  }) {
    const [min2 = "", max2 = ""] = value;
    const onChangeMin = (0, import_element91.useCallback)(
      (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
      [onChange, max2]
    );
    const onChangeMax = (0, import_element91.useCallback)(
      (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
      [onChange, min2]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
      import_components65.BaseControl,
      {
        help: (0, import_i18n101.__)("The max. value must be greater than the min. value."),
        children: /* @__PURE__ */ (0, import_jsx_runtime194.jsxs)(import_components65.Flex, { direction: "row", gap: 4, children: [
          /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
            import_components65.__experimentalNumberControl,
            {
              label: (0, import_i18n101.__)("Min."),
              value: min2,
              max: max2 ? Number(max2) - step : void 0,
              onChange: onChangeMin,
              __next40pxDefaultSize: true,
              hideLabelFromVision,
              step
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
            import_components65.__experimentalNumberControl,
            {
              label: (0, import_i18n101.__)("Max."),
              value: max2,
              min: min2 ? Number(min2) + step : void 0,
              onChange: onChangeMax,
              __next40pxDefaultSize: true,
              hideLabelFromVision,
              step
            }
          )
        ] })
      }
    );
  }
  function ValidatedNumber({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    operator,
    validity
  }) {
    const decimals = field.format?.decimals ?? 0;
    const step = Math.pow(10, Math.abs(decimals) * -1);
    const { label, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
    const value = getValue2({ item: data }) ?? "";
    const disabled2 = field.isDisabled({ item: data, field });
    const onChangeControl = (0, import_element91.useCallback)(
      (newValue) => {
        onChange(
          setValue({
            item: data,
            // Do not convert an empty string or undefined to a number,
            // otherwise there's a mismatch between the UI control (empty)
            // and the data relied by onChange (0).
            value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
          })
        );
      },
      [data, onChange, setValue]
    );
    const onChangeBetweenControls = (0, import_element91.useCallback)(
      (newValue) => {
        onChange(
          setValue({
            item: data,
            value: newValue
          })
        );
      },
      [data, onChange, setValue]
    );
    if (operator === OPERATOR_BETWEEN) {
      let valueBetween = ["", ""];
      if (Array.isArray(value) && value.length === 2 && value.every(
        (element) => typeof element === "number" || element === ""
      )) {
        valueBetween = value;
      }
      return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
        BetweenControls,
        {
          value: valueBetween,
          onChange: onChangeBetweenControls,
          hideLabelFromVision,
          step
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
      ValidatedNumberControl,
      {
        required: !!isValid2.required,
        markWhenOptional,
        customValidity: getCustomValidity(isValid2, validity),
        label,
        help: description,
        value,
        onChange: onChangeControl,
        __next40pxDefaultSize: true,
        hideLabelFromVision,
        step,
        min: isValid2.min ? isValid2.min.constraint : void 0,
        max: isValid2.max ? isValid2.max.constraint : void 0,
        disabled: disabled2
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/integer.mjs
  var import_jsx_runtime195 = __toESM(require_jsx_runtime(), 1);
  function Integer(props) {
    return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(ValidatedNumber, { ...props });
  }

  // packages/dataviews/build-module/components/dataform-controls/number.mjs
  var import_jsx_runtime196 = __toESM(require_jsx_runtime(), 1);
  function Number2(props) {
    return /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(ValidatedNumber, { ...props });
  }

  // packages/dataviews/build-module/components/dataform-controls/radio.mjs
  var import_components66 = __toESM(require_components(), 1);
  var import_element92 = __toESM(require_element(), 1);
  var import_jsx_runtime197 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedRadioControl } = unlock3(import_components66.privateApis);
  function Radio({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const { label, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
    const disabled2 = field.isDisabled({ item: data, field });
    const { elements: elements2, isLoading } = useElements({
      elements: field.elements,
      getElements: field.getElements
    });
    const value = getValue2({ item: data });
    const onChangeControl = (0, import_element92.useCallback)(
      (newValue) => onChange(setValue({ item: data, value: newValue })),
      [data, onChange, setValue]
    );
    if (isLoading) {
      return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(import_components66.Spinner, {});
    }
    return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
      ValidatedRadioControl,
      {
        required: !!field.isValid?.required,
        markWhenOptional,
        customValidity: getCustomValidity(isValid2, validity),
        label,
        help: description,
        onChange: onChangeControl,
        options: elements2,
        selected: value,
        hideLabelFromVision,
        disabled: disabled2
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/text.mjs
  var import_element93 = __toESM(require_element(), 1);
  var import_jsx_runtime198 = __toESM(require_jsx_runtime(), 1);
  function Text3({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    config: config2,
    validity
  }) {
    const { prefix: prefix2, suffix } = config2 || {};
    return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
      ValidatedText,
      {
        ...{
          data,
          field,
          onChange,
          hideLabelFromVision,
          markWhenOptional,
          validity,
          prefix: prefix2 ? (0, import_element93.createElement)(prefix2) : void 0,
          suffix: suffix ? (0, import_element93.createElement)(suffix) : void 0
        }
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
  var import_components67 = __toESM(require_components(), 1);
  var import_element94 = __toESM(require_element(), 1);
  var import_jsx_runtime199 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedToggleControl } = unlock3(import_components67.privateApis);
  function Toggle({
    field,
    onChange,
    data,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const { label, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
    const disabled2 = field.isDisabled({ item: data, field });
    const onChangeControl = (0, import_element94.useCallback)(() => {
      onChange(
        setValue({ item: data, value: !getValue2({ item: data }) })
      );
    }, [onChange, setValue, data, getValue2]);
    return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
      ValidatedToggleControl,
      {
        required: !!isValid2.required,
        markWhenOptional,
        customValidity: getCustomValidity(isValid2, validity),
        hidden: hideLabelFromVision,
        label,
        help: description,
        checked: getValue2({ item: data }),
        onChange: onChangeControl,
        disabled: disabled2
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
  var import_components68 = __toESM(require_components(), 1);
  var import_element95 = __toESM(require_element(), 1);
  var import_jsx_runtime200 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedTextareaControl } = unlock3(import_components68.privateApis);
  function Textarea({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    config: config2,
    validity
  }) {
    const { rows = 4 } = config2 || {};
    const disabled2 = field.isDisabled({ item: data, field });
    const { label, placeholder, description, setValue, isValid: isValid2 } = field;
    const value = field.getValue({ item: data });
    const onChangeControl = (0, import_element95.useCallback)(
      (newValue) => onChange(setValue({ item: data, value: newValue })),
      [data, onChange, setValue]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime200.jsx)(
      ValidatedTextareaControl,
      {
        required: !!isValid2.required,
        markWhenOptional,
        customValidity: getCustomValidity(isValid2, validity),
        label,
        placeholder,
        value: value ?? "",
        help: description,
        onChange: onChangeControl,
        rows,
        disabled: disabled2,
        minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
        maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
        __next40pxDefaultSize: true,
        hideLabelFromVision
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
  var import_components69 = __toESM(require_components(), 1);
  var import_element96 = __toESM(require_element(), 1);
  var import_jsx_runtime201 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedToggleGroupControl } = unlock3(import_components69.privateApis);
  function ToggleGroup({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const { getValue: getValue2, setValue, isValid: isValid2 } = field;
    const disabled2 = field.isDisabled({ item: data, field });
    const value = getValue2({ item: data });
    const onChangeControl = (0, import_element96.useCallback)(
      (newValue) => onChange(setValue({ item: data, value: newValue })),
      [data, onChange, setValue]
    );
    const { elements: elements2, isLoading } = useElements({
      elements: field.elements,
      getElements: field.getElements
    });
    if (isLoading) {
      return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(import_components69.Spinner, {});
    }
    if (elements2.length === 0) {
      return null;
    }
    const selectedOption = elements2.find((el) => el.value === value);
    return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
      ValidatedToggleGroupControl,
      {
        required: !!field.isValid?.required,
        markWhenOptional,
        customValidity: getCustomValidity(isValid2, validity),
        __next40pxDefaultSize: true,
        isBlock: true,
        label: field.label,
        help: selectedOption?.description || field.description,
        onChange: onChangeControl,
        value,
        hideLabelFromVision,
        children: elements2.map((el) => /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
          import_components69.__experimentalToggleGroupControlOption,
          {
            label: el.label,
            value: el.value,
            disabled: disabled2
          },
          el.value
        ))
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/array.mjs
  var import_components70 = __toESM(require_components(), 1);
  var import_element97 = __toESM(require_element(), 1);
  var import_jsx_runtime202 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedFormTokenField } = unlock3(import_components70.privateApis);
  function ArrayControl({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const { label, placeholder, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
    const value = getValue2({ item: data });
    const disabled2 = field.isDisabled({ item: data, field });
    const { elements: elements2, isLoading } = useElements({
      elements: field.elements,
      getElements: field.getElements
    });
    const arrayValueAsElements = (0, import_element97.useMemo)(
      () => Array.isArray(value) ? value.map((token) => {
        const element = elements2?.find(
          (suggestion) => suggestion.value === token
        );
        return element || { value: token, label: token };
      }) : [],
      [value, elements2]
    );
    const onChangeControl = (0, import_element97.useCallback)(
      (tokens) => {
        const valueTokens = tokens.map((token) => {
          if (typeof token === "object" && "value" in token) {
            return token.value;
          }
          return token;
        });
        onChange(setValue({ item: data, value: valueTokens }));
      },
      [onChange, setValue, data]
    );
    if (isLoading) {
      return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(import_components70.Spinner, {});
    }
    return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
      ValidatedFormTokenField,
      {
        required: !!isValid2?.required,
        markWhenOptional,
        customValidity: getCustomValidity(isValid2, validity),
        label: hideLabelFromVision ? void 0 : label,
        value: arrayValueAsElements,
        onChange: onChangeControl,
        placeholder,
        suggestions: elements2?.map((element) => element.value),
        disabled: disabled2,
        __experimentalValidateInput: (token) => {
          if (field.isValid?.elements && elements2) {
            return elements2.some(
              (element) => element.value === token || element.label === token
            );
          }
          return true;
        },
        __experimentalExpandOnFocus: elements2 && elements2.length > 0,
        help: description ?? (field.isValid?.elements ? "" : void 0),
        displayTransform: (token) => {
          if (typeof token === "object" && "label" in token) {
            return token.label;
          }
          if (typeof token === "string" && elements2) {
            const element = elements2.find(
              (el) => el.value === token
            );
            return element?.label || token;
          }
          return token;
        },
        __experimentalRenderItem: ({ item }) => {
          if (typeof item === "string" && elements2) {
            const element = elements2.find(
              (el) => el.value === item
            );
            return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("span", { children: element?.label || item });
          }
          return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("span", { children: item });
        }
      }
    );
  }

  // node_modules/colord/index.mjs
  var r3 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
  var t2 = function(r4) {
    return "string" == typeof r4 ? r4.length > 0 : "number" == typeof r4;
  };
  var n2 = function(r4, t4, n3) {
    return void 0 === t4 && (t4 = 0), void 0 === n3 && (n3 = Math.pow(10, t4)), Math.round(n3 * r4) / n3 + 0;
  };
  var e2 = function(r4, t4, n3) {
    return void 0 === t4 && (t4 = 0), void 0 === n3 && (n3 = 1), r4 > n3 ? n3 : r4 > t4 ? r4 : t4;
  };
  var u2 = function(r4) {
    return (r4 = isFinite(r4) ? r4 % 360 : 0) > 0 ? r4 : r4 + 360;
  };
  var a2 = function(r4) {
    return { r: e2(r4.r, 0, 255), g: e2(r4.g, 0, 255), b: e2(r4.b, 0, 255), a: e2(r4.a) };
  };
  var o2 = function(r4) {
    return { r: n2(r4.r), g: n2(r4.g), b: n2(r4.b), a: n2(r4.a, 3) };
  };
  var i2 = /^#([0-9a-f]{3,8})$/i;
  var s2 = function(r4) {
    var t4 = r4.toString(16);
    return t4.length < 2 ? "0" + t4 : t4;
  };
  var h2 = function(r4) {
    var t4 = r4.r, n3 = r4.g, e3 = r4.b, u3 = r4.a, a3 = Math.max(t4, n3, e3), o4 = a3 - Math.min(t4, n3, e3), i3 = o4 ? a3 === t4 ? (n3 - e3) / o4 : a3 === n3 ? 2 + (e3 - t4) / o4 : 4 + (t4 - n3) / o4 : 0;
    return { h: 60 * (i3 < 0 ? i3 + 6 : i3), s: a3 ? o4 / a3 * 100 : 0, v: a3 / 255 * 100, a: u3 };
  };
  var b2 = function(r4) {
    var t4 = r4.h, n3 = r4.s, e3 = r4.v, u3 = r4.a;
    t4 = t4 / 360 * 6, n3 /= 100, e3 /= 100;
    var a3 = Math.floor(t4), o4 = e3 * (1 - n3), i3 = e3 * (1 - (t4 - a3) * n3), s3 = e3 * (1 - (1 - t4 + a3) * n3), h3 = a3 % 6;
    return { r: 255 * [e3, i3, o4, o4, s3, e3][h3], g: 255 * [s3, e3, e3, i3, o4, o4][h3], b: 255 * [o4, o4, s3, e3, e3, i3][h3], a: u3 };
  };
  var g2 = function(r4) {
    return { h: u2(r4.h), s: e2(r4.s, 0, 100), l: e2(r4.l, 0, 100), a: e2(r4.a) };
  };
  var d2 = function(r4) {
    return { h: n2(r4.h), s: n2(r4.s), l: n2(r4.l), a: n2(r4.a, 3) };
  };
  var f2 = function(r4) {
    return b2((n3 = (t4 = r4).s, { h: t4.h, s: (n3 *= ((e3 = t4.l) < 50 ? e3 : 100 - e3) / 100) > 0 ? 2 * n3 / (e3 + n3) * 100 : 0, v: e3 + n3, a: t4.a }));
    var t4, n3, e3;
  };
  var c = function(r4) {
    return { h: (t4 = h2(r4)).h, s: (u3 = (200 - (n3 = t4.s)) * (e3 = t4.v) / 100) > 0 && u3 < 200 ? n3 * e3 / 100 / (u3 <= 100 ? u3 : 200 - u3) * 100 : 0, l: u3 / 2, a: t4.a };
    var t4, n3, e3, u3;
  };
  var l2 = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
  var p3 = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
  var v2 = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
  var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
  var y2 = { string: [[function(r4) {
    var t4 = i2.exec(r4);
    return t4 ? (r4 = t4[1]).length <= 4 ? { r: parseInt(r4[0] + r4[0], 16), g: parseInt(r4[1] + r4[1], 16), b: parseInt(r4[2] + r4[2], 16), a: 4 === r4.length ? n2(parseInt(r4[3] + r4[3], 16) / 255, 2) : 1 } : 6 === r4.length || 8 === r4.length ? { r: parseInt(r4.substr(0, 2), 16), g: parseInt(r4.substr(2, 2), 16), b: parseInt(r4.substr(4, 2), 16), a: 8 === r4.length ? n2(parseInt(r4.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
  }, "hex"], [function(r4) {
    var t4 = v2.exec(r4) || m.exec(r4);
    return t4 ? t4[2] !== t4[4] || t4[4] !== t4[6] ? null : a2({ r: Number(t4[1]) / (t4[2] ? 100 / 255 : 1), g: Number(t4[3]) / (t4[4] ? 100 / 255 : 1), b: Number(t4[5]) / (t4[6] ? 100 / 255 : 1), a: void 0 === t4[7] ? 1 : Number(t4[7]) / (t4[8] ? 100 : 1) }) : null;
  }, "rgb"], [function(t4) {
    var n3 = l2.exec(t4) || p3.exec(t4);
    if (!n3) return null;
    var e3, u3, a3 = g2({ h: (e3 = n3[1], u3 = n3[2], void 0 === u3 && (u3 = "deg"), Number(e3) * (r3[u3] || 1)), s: Number(n3[3]), l: Number(n3[4]), a: void 0 === n3[5] ? 1 : Number(n3[5]) / (n3[6] ? 100 : 1) });
    return f2(a3);
  }, "hsl"]], object: [[function(r4) {
    var n3 = r4.r, e3 = r4.g, u3 = r4.b, o4 = r4.a, i3 = void 0 === o4 ? 1 : o4;
    return t2(n3) && t2(e3) && t2(u3) ? a2({ r: Number(n3), g: Number(e3), b: Number(u3), a: Number(i3) }) : null;
  }, "rgb"], [function(r4) {
    var n3 = r4.h, e3 = r4.s, u3 = r4.l, a3 = r4.a, o4 = void 0 === a3 ? 1 : a3;
    if (!t2(n3) || !t2(e3) || !t2(u3)) return null;
    var i3 = g2({ h: Number(n3), s: Number(e3), l: Number(u3), a: Number(o4) });
    return f2(i3);
  }, "hsl"], [function(r4) {
    var n3 = r4.h, a3 = r4.s, o4 = r4.v, i3 = r4.a, s3 = void 0 === i3 ? 1 : i3;
    if (!t2(n3) || !t2(a3) || !t2(o4)) return null;
    var h3 = (function(r5) {
      return { h: u2(r5.h), s: e2(r5.s, 0, 100), v: e2(r5.v, 0, 100), a: e2(r5.a) };
    })({ h: Number(n3), s: Number(a3), v: Number(o4), a: Number(s3) });
    return b2(h3);
  }, "hsv"]] };
  var N2 = function(r4, t4) {
    for (var n3 = 0; n3 < t4.length; n3++) {
      var e3 = t4[n3][0](r4);
      if (e3) return [e3, t4[n3][1]];
    }
    return [null, void 0];
  };
  var x = function(r4) {
    return "string" == typeof r4 ? N2(r4.trim(), y2.string) : "object" == typeof r4 && null !== r4 ? N2(r4, y2.object) : [null, void 0];
  };
  var M = function(r4, t4) {
    var n3 = c(r4);
    return { h: n3.h, s: e2(n3.s + 100 * t4, 0, 100), l: n3.l, a: n3.a };
  };
  var H = function(r4) {
    return (299 * r4.r + 587 * r4.g + 114 * r4.b) / 1e3 / 255;
  };
  var $ = function(r4, t4) {
    var n3 = c(r4);
    return { h: n3.h, s: n3.s, l: e2(n3.l + 100 * t4, 0, 100), a: n3.a };
  };
  var j = (function() {
    function r4(r5) {
      this.parsed = x(r5)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
    }
    return r4.prototype.isValid = function() {
      return null !== this.parsed;
    }, r4.prototype.brightness = function() {
      return n2(H(this.rgba), 2);
    }, r4.prototype.isDark = function() {
      return H(this.rgba) < 0.5;
    }, r4.prototype.isLight = function() {
      return H(this.rgba) >= 0.5;
    }, r4.prototype.toHex = function() {
      return r5 = o2(this.rgba), t4 = r5.r, e3 = r5.g, u3 = r5.b, i3 = (a3 = r5.a) < 1 ? s2(n2(255 * a3)) : "", "#" + s2(t4) + s2(e3) + s2(u3) + i3;
      var r5, t4, e3, u3, a3, i3;
    }, r4.prototype.toRgb = function() {
      return o2(this.rgba);
    }, r4.prototype.toRgbString = function() {
      return r5 = o2(this.rgba), t4 = r5.r, n3 = r5.g, e3 = r5.b, (u3 = r5.a) < 1 ? "rgba(" + t4 + ", " + n3 + ", " + e3 + ", " + u3 + ")" : "rgb(" + t4 + ", " + n3 + ", " + e3 + ")";
      var r5, t4, n3, e3, u3;
    }, r4.prototype.toHsl = function() {
      return d2(c(this.rgba));
    }, r4.prototype.toHslString = function() {
      return r5 = d2(c(this.rgba)), t4 = r5.h, n3 = r5.s, e3 = r5.l, (u3 = r5.a) < 1 ? "hsla(" + t4 + ", " + n3 + "%, " + e3 + "%, " + u3 + ")" : "hsl(" + t4 + ", " + n3 + "%, " + e3 + "%)";
      var r5, t4, n3, e3, u3;
    }, r4.prototype.toHsv = function() {
      return r5 = h2(this.rgba), { h: n2(r5.h), s: n2(r5.s), v: n2(r5.v), a: n2(r5.a, 3) };
      var r5;
    }, r4.prototype.invert = function() {
      return w2({ r: 255 - (r5 = this.rgba).r, g: 255 - r5.g, b: 255 - r5.b, a: r5.a });
      var r5;
    }, r4.prototype.saturate = function(r5) {
      return void 0 === r5 && (r5 = 0.1), w2(M(this.rgba, r5));
    }, r4.prototype.desaturate = function(r5) {
      return void 0 === r5 && (r5 = 0.1), w2(M(this.rgba, -r5));
    }, r4.prototype.grayscale = function() {
      return w2(M(this.rgba, -1));
    }, r4.prototype.lighten = function(r5) {
      return void 0 === r5 && (r5 = 0.1), w2($(this.rgba, r5));
    }, r4.prototype.darken = function(r5) {
      return void 0 === r5 && (r5 = 0.1), w2($(this.rgba, -r5));
    }, r4.prototype.rotate = function(r5) {
      return void 0 === r5 && (r5 = 15), this.hue(this.hue() + r5);
    }, r4.prototype.alpha = function(r5) {
      return "number" == typeof r5 ? w2({ r: (t4 = this.rgba).r, g: t4.g, b: t4.b, a: r5 }) : n2(this.rgba.a, 3);
      var t4;
    }, r4.prototype.hue = function(r5) {
      var t4 = c(this.rgba);
      return "number" == typeof r5 ? w2({ h: r5, s: t4.s, l: t4.l, a: t4.a }) : n2(t4.h);
    }, r4.prototype.isEqual = function(r5) {
      return this.toHex() === w2(r5).toHex();
    }, r4;
  })();
  var w2 = function(r4) {
    return r4 instanceof j ? r4 : new j(r4);
  };
  var S2 = [];
  var k = function(r4) {
    r4.forEach(function(r5) {
      S2.indexOf(r5) < 0 && (r5(j, y2), S2.push(r5));
    });
  };

  // packages/dataviews/build-module/components/dataform-controls/color.mjs
  var import_components71 = __toESM(require_components(), 1);
  var import_element98 = __toESM(require_element(), 1);
  var import_i18n102 = __toESM(require_i18n(), 1);
  var import_jsx_runtime203 = __toESM(require_jsx_runtime(), 1);
  var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components71.privateApis);
  var ColorPickerDropdown = ({
    color,
    onColorChange,
    disabled: disabled2
  }) => {
    const validColor = color && w2(color).isValid() ? color : "#ffffff";
    return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
      import_components71.Dropdown,
      {
        className: "dataviews-controls__color-picker-dropdown",
        popoverProps: { resize: false },
        renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
          import_components71.Button,
          {
            onClick: onToggle,
            "aria-label": (0, import_i18n102.__)("Open color picker"),
            size: "small",
            disabled: disabled2,
            accessibleWhenDisabled: true,
            icon: () => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_components71.ColorIndicator, { colorValue: validColor })
          }
        ),
        renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_components71.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
          import_components71.ColorPicker,
          {
            color: validColor,
            onChange: onColorChange,
            enableAlpha: true
          }
        ) })
      }
    );
  };
  function Color({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const { label, placeholder, description, setValue, isValid: isValid2 } = field;
    const disabled2 = field.isDisabled({ item: data, field });
    const value = field.getValue({ item: data }) || "";
    const handleColorChange = (0, import_element98.useCallback)(
      (newColor) => {
        onChange(setValue({ item: data, value: newColor }));
      },
      [data, onChange, setValue]
    );
    const handleInputChange = (0, import_element98.useCallback)(
      (newValue) => {
        onChange(setValue({ item: data, value: newValue || "" }));
      },
      [data, onChange, setValue]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
      ValidatedInputControl3,
      {
        required: !!field.isValid?.required,
        markWhenOptional,
        customValidity: getCustomValidity(isValid2, validity),
        label,
        placeholder,
        value,
        help: description,
        onChange: handleInputChange,
        hideLabelFromVision,
        type: "text",
        disabled: disabled2,
        prefix: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_components71.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
          ColorPickerDropdown,
          {
            color: value,
            onColorChange: handleColorChange,
            disabled: disabled2
          }
        ) })
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-controls/password.mjs
  var import_components72 = __toESM(require_components(), 1);
  var import_element99 = __toESM(require_element(), 1);
  var import_i18n103 = __toESM(require_i18n(), 1);
  var import_jsx_runtime204 = __toESM(require_jsx_runtime(), 1);
  function Password({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const [isVisible2, setIsVisible] = (0, import_element99.useState)(false);
    const disabled2 = field.isDisabled({ item: data, field });
    const toggleVisibility = (0, import_element99.useCallback)(() => {
      setIsVisible((prev) => !prev);
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(
      ValidatedText,
      {
        ...{
          data,
          field,
          onChange,
          hideLabelFromVision,
          markWhenOptional,
          validity,
          type: isVisible2 ? "text" : "password",
          suffix: /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(import_components72.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(
            import_components72.Button,
            {
              icon: isVisible2 ? unseen_default : seen_default,
              onClick: toggleVisibility,
              size: "small",
              label: isVisible2 ? (0, import_i18n103.__)("Hide password") : (0, import_i18n103.__)("Show password"),
              disabled: disabled2,
              accessibleWhenDisabled: true
            }
          ) })
        }
      }
    );
  }

  // packages/dataviews/build-module/field-types/utils/has-elements.mjs
  function hasElements(field) {
    return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
  }

  // packages/dataviews/build-module/components/dataform-controls/index.mjs
  var import_jsx_runtime205 = __toESM(require_jsx_runtime(), 1);
  var FORM_CONTROLS = {
    adaptiveSelect: AdaptiveSelect,
    array: ArrayControl,
    checkbox: Checkbox,
    color: Color,
    combobox: Combobox3,
    datetime: DateTime,
    date: DateControl,
    email: Email,
    telephone: Telephone,
    url: Url,
    integer: Integer,
    number: Number2,
    password: Password,
    radio: Radio,
    select: Select,
    text: Text3,
    toggle: Toggle,
    textarea: Textarea,
    toggleGroup: ToggleGroup
  };
  function isEditConfig(value) {
    return value && typeof value === "object" && typeof value.control === "string";
  }
  function createConfiguredControl(config2) {
    const { control, ...controlConfig } = config2;
    const BaseControlType = getControlByType(control);
    if (BaseControlType === null) {
      return null;
    }
    return function ConfiguredControl(props) {
      return /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(BaseControlType, { ...props, config: controlConfig });
    };
  }
  function getControl(field, fallback) {
    if (typeof field.Edit === "function") {
      return field.Edit;
    }
    if (typeof field.Edit === "string") {
      return getControlByType(field.Edit);
    }
    if (isEditConfig(field.Edit)) {
      return createConfiguredControl(field.Edit);
    }
    if (hasElements(field) && field.type !== "array") {
      return getControlByType("adaptiveSelect");
    }
    if (fallback === null) {
      return null;
    }
    return getControlByType(fallback);
  }
  function getControlByType(type) {
    if (Object.keys(FORM_CONTROLS).includes(type)) {
      return FORM_CONTROLS[type];
    }
    return null;
  }

  // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
  function getFilterBy(field, defaultOperators, validOperators) {
    if (field.filterBy === false) {
      return false;
    }
    const operators = field.filterBy?.operators?.filter(
      (op) => validOperators.includes(op)
    ) ?? defaultOperators;
    if (operators.length === 0) {
      return false;
    }
    return {
      isPrimary: !!field.filterBy?.isPrimary,
      operators
    };
  }
  var get_filter_by_default = getFilterBy;

  // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
  var getValueFromId = (id) => ({ item }) => {
    const path = id.split(".");
    let value = item;
    for (const segment of path) {
      if (value.hasOwnProperty(segment)) {
        value = value[segment];
      } else {
        value = void 0;
      }
    }
    return value;
  };
  var get_value_from_id_default = getValueFromId;

  // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
  var setValueFromId = (id) => ({ value }) => {
    const path = id.split(".");
    const result = {};
    let current = result;
    for (const segment of path.slice(0, -1)) {
      current[segment] = {};
      current = current[segment];
    }
    current[path.at(-1)] = value;
    return result;
  };
  var set_value_from_id_default = setValueFromId;

  // packages/dataviews/build-module/field-types/email.mjs
  var import_i18n104 = __toESM(require_i18n(), 1);

  // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
  function RenderFromElements({
    item,
    field
  }) {
    const { elements: elements2, isLoading } = useElements({
      elements: field.elements,
      getElements: field.getElements
    });
    const value = field.getValue({ item });
    if (isLoading) {
      return value;
    }
    if (elements2.length === 0) {
      return value;
    }
    return elements2?.find((element) => element.value === value)?.label || field.getValue({ item });
  }

  // packages/dataviews/build-module/field-types/utils/render-default.mjs
  var import_jsx_runtime206 = __toESM(require_jsx_runtime(), 1);
  function render({
    item,
    field
  }) {
    if (field.hasElements) {
      return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(RenderFromElements, { item, field });
    }
    return field.getValueFormatted({ item, field });
  }

  // packages/dataviews/build-module/field-types/utils/sort-text.mjs
  var sort_text_default = (a3, b3, direction) => {
    return direction === "asc" ? a3.localeCompare(b3) : b3.localeCompare(a3);
  };

  // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
  function isValidRequired(item, field) {
    const value = field.getValue({ item });
    return ![void 0, "", null].includes(value);
  }

  // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
  function isValidMinLength(item, field) {
    if (typeof field.isValid.minLength?.constraint !== "number") {
      return false;
    }
    const value = field.getValue({ item });
    if ([void 0, "", null].includes(value)) {
      return true;
    }
    return String(value).length >= field.isValid.minLength.constraint;
  }

  // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
  function isValidMaxLength(item, field) {
    if (typeof field.isValid.maxLength?.constraint !== "number") {
      return false;
    }
    const value = field.getValue({ item });
    if ([void 0, "", null].includes(value)) {
      return true;
    }
    return String(value).length <= field.isValid.maxLength.constraint;
  }

  // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
  function isValidPattern(item, field) {
    if (field.isValid.pattern?.constraint === void 0) {
      return true;
    }
    try {
      const regexp = new RegExp(field.isValid.pattern.constraint);
      const value = field.getValue({ item });
      if ([void 0, "", null].includes(value)) {
        return true;
      }
      return regexp.test(String(value));
    } catch {
      return false;
    }
  }

  // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
  function isValidElements(item, field) {
    const elements2 = field.elements ?? [];
    const validValues = elements2.map((el) => el.value);
    if (validValues.length === 0) {
      return true;
    }
    const value = field.getValue({ item });
    return [].concat(value).every((v3) => validValues.includes(v3));
  }

  // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
  function getValueFormatted({
    item,
    field
  }) {
    return field.getValue({ item });
  }
  var get_value_formatted_default_default = getValueFormatted;

  // packages/dataviews/build-module/field-types/email.mjs
  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])?)*$/;
  function isValidCustom(item, field) {
    const value = field.getValue({ item });
    if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
      return (0, import_i18n104.__)("Value must be a valid email address.");
    }
    return null;
  }
  var email_default = {
    type: "email",
    render,
    Edit: "email",
    sort: sort_text_default,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
    validOperators: [
      OPERATOR_IS,
      OPERATOR_IS_NOT,
      OPERATOR_CONTAINS,
      OPERATOR_NOT_CONTAINS,
      OPERATOR_STARTS_WITH,
      // Multiple selection
      OPERATOR_IS_ANY2,
      OPERATOR_IS_NONE,
      OPERATOR_IS_ALL,
      OPERATOR_IS_NOT_ALL
    ],
    format: {},
    getValueFormatted: get_value_formatted_default_default,
    validate: {
      required: isValidRequired,
      pattern: isValidPattern,
      minLength: isValidMinLength,
      maxLength: isValidMaxLength,
      elements: isValidElements,
      custom: isValidCustom
    }
  };

  // packages/dataviews/build-module/field-types/integer.mjs
  var import_i18n105 = __toESM(require_i18n(), 1);

  // packages/dataviews/build-module/field-types/utils/sort-number.mjs
  var sort_number_default = (a3, b3, direction) => {
    return direction === "asc" ? a3 - b3 : b3 - a3;
  };

  // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
  function isValidMin(item, field) {
    if (typeof field.isValid.min?.constraint !== "number") {
      return false;
    }
    const value = field.getValue({ item });
    if ([void 0, "", null].includes(value)) {
      return true;
    }
    return Number(value) >= field.isValid.min.constraint;
  }

  // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
  function isValidMax(item, field) {
    if (typeof field.isValid.max?.constraint !== "number") {
      return false;
    }
    const value = field.getValue({ item });
    if ([void 0, "", null].includes(value)) {
      return true;
    }
    return Number(value) <= field.isValid.max.constraint;
  }

  // packages/dataviews/build-module/field-types/integer.mjs
  var format2 = {
    separatorThousand: ","
  };
  function getValueFormatted2({
    item,
    field
  }) {
    let value = field.getValue({ item });
    if (value === null || value === void 0) {
      return "";
    }
    value = Number(value);
    if (!Number.isFinite(value)) {
      return String(value);
    }
    let formatInteger;
    if (field.type !== "integer") {
      formatInteger = format2;
    } else {
      formatInteger = field.format;
    }
    const { separatorThousand } = formatInteger;
    const integerValue = Math.trunc(value);
    if (!separatorThousand) {
      return String(integerValue);
    }
    return String(integerValue).replace(
      /\B(?=(\d{3})+(?!\d))/g,
      separatorThousand
    );
  }
  function isValidCustom2(item, field) {
    const value = field.getValue({ item });
    if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
      return (0, import_i18n105.__)("Value must be an integer.");
    }
    return null;
  }
  var integer_default = {
    type: "integer",
    render,
    Edit: "integer",
    sort: sort_number_default,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [
      OPERATOR_IS,
      OPERATOR_IS_NOT,
      OPERATOR_LESS_THAN,
      OPERATOR_GREATER_THAN,
      OPERATOR_LESS_THAN_OR_EQUAL,
      OPERATOR_GREATER_THAN_OR_EQUAL,
      OPERATOR_BETWEEN
    ],
    validOperators: [
      // Single-selection
      OPERATOR_IS,
      OPERATOR_IS_NOT,
      OPERATOR_LESS_THAN,
      OPERATOR_GREATER_THAN,
      OPERATOR_LESS_THAN_OR_EQUAL,
      OPERATOR_GREATER_THAN_OR_EQUAL,
      OPERATOR_BETWEEN,
      // Multiple-selection
      OPERATOR_IS_ANY2,
      OPERATOR_IS_NONE,
      OPERATOR_IS_ALL,
      OPERATOR_IS_NOT_ALL
    ],
    format: format2,
    getValueFormatted: getValueFormatted2,
    validate: {
      required: isValidRequired,
      min: isValidMin,
      max: isValidMax,
      elements: isValidElements,
      custom: isValidCustom2
    }
  };

  // packages/dataviews/build-module/field-types/number.mjs
  var import_i18n106 = __toESM(require_i18n(), 1);
  var format3 = {
    separatorThousand: ",",
    separatorDecimal: ".",
    decimals: 2
  };
  function getValueFormatted3({
    item,
    field
  }) {
    let value = field.getValue({ item });
    if (value === null || value === void 0) {
      return "";
    }
    value = Number(value);
    if (!Number.isFinite(value)) {
      return String(value);
    }
    let formatNumber;
    if (field.type !== "number") {
      formatNumber = format3;
    } else {
      formatNumber = field.format;
    }
    const { separatorThousand, separatorDecimal, decimals } = formatNumber;
    const fixedValue = value.toFixed(decimals);
    const [integerPart, decimalPart] = fixedValue.split(".");
    const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
    return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
  }
  function isEmpty2(value) {
    return value === "" || value === void 0 || value === null;
  }
  function isValidCustom3(item, field) {
    const value = field.getValue({ item });
    if (!isEmpty2(value) && !Number.isFinite(value)) {
      return (0, import_i18n106.__)("Value must be a number.");
    }
    return null;
  }
  var number_default = {
    type: "number",
    render,
    Edit: "number",
    sort: sort_number_default,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [
      OPERATOR_IS,
      OPERATOR_IS_NOT,
      OPERATOR_LESS_THAN,
      OPERATOR_GREATER_THAN,
      OPERATOR_LESS_THAN_OR_EQUAL,
      OPERATOR_GREATER_THAN_OR_EQUAL,
      OPERATOR_BETWEEN
    ],
    validOperators: [
      // Single-selection
      OPERATOR_IS,
      OPERATOR_IS_NOT,
      OPERATOR_LESS_THAN,
      OPERATOR_GREATER_THAN,
      OPERATOR_LESS_THAN_OR_EQUAL,
      OPERATOR_GREATER_THAN_OR_EQUAL,
      OPERATOR_BETWEEN,
      // Multiple-selection
      OPERATOR_IS_ANY2,
      OPERATOR_IS_NONE,
      OPERATOR_IS_ALL,
      OPERATOR_IS_NOT_ALL
    ],
    format: format3,
    getValueFormatted: getValueFormatted3,
    validate: {
      required: isValidRequired,
      min: isValidMin,
      max: isValidMax,
      elements: isValidElements,
      custom: isValidCustom3
    }
  };

  // packages/dataviews/build-module/field-types/text.mjs
  var text_default = {
    type: "text",
    render,
    Edit: "text",
    sort: sort_text_default,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
    validOperators: [
      // Single selection
      OPERATOR_IS,
      OPERATOR_IS_NOT,
      OPERATOR_CONTAINS,
      OPERATOR_NOT_CONTAINS,
      OPERATOR_STARTS_WITH,
      // Multiple selection
      OPERATOR_IS_ANY2,
      OPERATOR_IS_NONE,
      OPERATOR_IS_ALL,
      OPERATOR_IS_NOT_ALL
    ],
    format: {},
    getValueFormatted: get_value_formatted_default_default,
    validate: {
      required: isValidRequired,
      pattern: isValidPattern,
      minLength: isValidMinLength,
      maxLength: isValidMaxLength,
      elements: isValidElements
    }
  };

  // packages/dataviews/build-module/field-types/datetime.mjs
  var import_date12 = __toESM(require_date(), 1);

  // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
  var import_date11 = __toESM(require_date(), 1);
  function parseDateLike(value) {
    if (!value) {
      return null;
    }
    if (!isValid(new Date(value))) {
      return null;
    }
    const parsed = (0, import_date11.getDate)(value);
    return parsed && isValid(parsed) ? parsed : null;
  }
  function validateDateLikeBoundary(item, field, boundary) {
    const constraint = field.isValid[boundary]?.constraint;
    if (typeof constraint !== "string") {
      return false;
    }
    const value = field.getValue({ item });
    const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
    if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
      return true;
    }
    const parsedConstraint = parseDateLike(constraint);
    const parsedValue = parseDateLike(String(boundaryValue));
    return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
  }
  function isValidMinDate(item, field) {
    return validateDateLikeBoundary(item, field, "min");
  }
  function isValidMaxDate(item, field) {
    return validateDateLikeBoundary(item, field, "max");
  }

  // packages/dataviews/build-module/field-types/datetime.mjs
  var format4 = {
    datetime: (0, import_date12.getSettings)().formats.datetime,
    weekStartsOn: (0, import_date12.getSettings)().l10n.startOfWeek
  };
  function getValueFormatted4({
    item,
    field
  }) {
    const value = field.getValue({ item });
    if (["", void 0, null].includes(value)) {
      return "";
    }
    let formatDatetime;
    if (field.type !== "datetime") {
      formatDatetime = format4;
    } else {
      formatDatetime = field.format;
    }
    return (0, import_date12.dateI18n)(formatDatetime.datetime, (0, import_date12.getDate)(value));
  }
  var sort = (a3, b3, direction) => {
    const timeA = new Date(a3).getTime();
    const timeB = new Date(b3).getTime();
    return direction === "asc" ? timeA - timeB : timeB - timeA;
  };
  var datetime_default = {
    type: "datetime",
    render,
    Edit: "datetime",
    sort,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [
      OPERATOR_ON,
      OPERATOR_NOT_ON,
      OPERATOR_BEFORE,
      OPERATOR_AFTER,
      OPERATOR_BEFORE_INC,
      OPERATOR_AFTER_INC,
      OPERATOR_IN_THE_PAST,
      OPERATOR_OVER
    ],
    validOperators: [
      OPERATOR_ON,
      OPERATOR_NOT_ON,
      OPERATOR_BEFORE,
      OPERATOR_AFTER,
      OPERATOR_BEFORE_INC,
      OPERATOR_AFTER_INC,
      OPERATOR_IN_THE_PAST,
      OPERATOR_OVER
    ],
    format: format4,
    getValueFormatted: getValueFormatted4,
    validate: {
      required: isValidRequired,
      elements: isValidElements,
      min: isValidMinDate,
      max: isValidMaxDate
    }
  };

  // packages/dataviews/build-module/field-types/date.mjs
  var import_date13 = __toESM(require_date(), 1);
  var format5 = {
    date: (0, import_date13.getSettings)().formats.date,
    weekStartsOn: (0, import_date13.getSettings)().l10n.startOfWeek
  };
  function getValueFormatted5({
    item,
    field
  }) {
    const value = field.getValue({ item });
    if (["", void 0, null].includes(value)) {
      return "";
    }
    let formatDate2;
    if (field.type !== "date") {
      formatDate2 = format5;
    } else {
      formatDate2 = field.format;
    }
    return (0, import_date13.dateI18n)(formatDate2.date, (0, import_date13.getDate)(value));
  }
  var sort2 = (a3, b3, direction) => {
    const timeA = new Date(a3).getTime();
    const timeB = new Date(b3).getTime();
    return direction === "asc" ? timeA - timeB : timeB - timeA;
  };
  var date_default2 = {
    type: "date",
    render,
    Edit: "date",
    sort: sort2,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [
      OPERATOR_ON,
      OPERATOR_NOT_ON,
      OPERATOR_BEFORE,
      OPERATOR_AFTER,
      OPERATOR_BEFORE_INC,
      OPERATOR_AFTER_INC,
      OPERATOR_IN_THE_PAST,
      OPERATOR_OVER,
      OPERATOR_BETWEEN
    ],
    validOperators: [
      OPERATOR_ON,
      OPERATOR_NOT_ON,
      OPERATOR_BEFORE,
      OPERATOR_AFTER,
      OPERATOR_BEFORE_INC,
      OPERATOR_AFTER_INC,
      OPERATOR_IN_THE_PAST,
      OPERATOR_OVER,
      OPERATOR_BETWEEN
    ],
    format: format5,
    getValueFormatted: getValueFormatted5,
    validate: {
      required: isValidRequired,
      elements: isValidElements,
      min: isValidMinDate,
      max: isValidMaxDate
    }
  };

  // packages/dataviews/build-module/field-types/boolean.mjs
  var import_i18n107 = __toESM(require_i18n(), 1);

  // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
  function isValidRequiredForBool(item, field) {
    const value = field.getValue({ item });
    return value === true;
  }

  // packages/dataviews/build-module/field-types/boolean.mjs
  function getValueFormatted6({
    item,
    field
  }) {
    const value = field.getValue({ item });
    if (value === true) {
      return (0, import_i18n107.__)("True");
    }
    if (value === false) {
      return (0, import_i18n107.__)("False");
    }
    return "";
  }
  function isValidCustom4(item, field) {
    const value = field.getValue({ item });
    if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
      return (0, import_i18n107.__)("Value must be true, false, or undefined");
    }
    return null;
  }
  var sort3 = (a3, b3, direction) => {
    const boolA = Boolean(a3);
    const boolB = Boolean(b3);
    if (boolA === boolB) {
      return 0;
    }
    if (direction === "asc") {
      return boolA ? 1 : -1;
    }
    return boolA ? -1 : 1;
  };
  var boolean_default = {
    type: "boolean",
    render,
    Edit: "checkbox",
    sort: sort3,
    validate: {
      required: isValidRequiredForBool,
      elements: isValidElements,
      custom: isValidCustom4
    },
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
    validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
    format: {},
    getValueFormatted: getValueFormatted6
  };

  // packages/dataviews/build-module/field-types/media.mjs
  var media_default = {
    type: "media",
    render: () => null,
    Edit: null,
    sort: () => 0,
    enableSorting: false,
    enableGlobalSearch: false,
    defaultOperators: [],
    validOperators: [],
    format: {},
    getValueFormatted: get_value_formatted_default_default,
    // cannot validate any constraint, so
    // the only available validation for the field author
    // would be providing a custom validator.
    validate: {}
  };

  // packages/dataviews/build-module/field-types/array.mjs
  var import_i18n108 = __toESM(require_i18n(), 1);

  // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
  function isValidRequiredForArray(item, field) {
    const value = field.getValue({ item });
    return Array.isArray(value) && value.length > 0 && value.every(
      (element) => ![void 0, "", null].includes(element)
    );
  }

  // packages/dataviews/build-module/field-types/array.mjs
  function getValueFormatted7({
    item,
    field
  }) {
    const value = field.getValue({ item });
    const arr = Array.isArray(value) ? value : [];
    return arr.join(", ");
  }
  function render2({ item, field }) {
    return getValueFormatted7({ item, field });
  }
  function isValidCustom5(item, field) {
    const value = field.getValue({ item });
    if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
      return (0, import_i18n108.__)("Value must be an array.");
    }
    if (!value.every((v3) => typeof v3 === "string")) {
      return (0, import_i18n108.__)("Every value must be a string.");
    }
    return null;
  }
  var sort4 = (a3, b3, direction) => {
    const arrA = Array.isArray(a3) ? a3 : [];
    const arrB = Array.isArray(b3) ? b3 : [];
    if (arrA.length !== arrB.length) {
      return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
    }
    const joinedA = arrA.join(",");
    const joinedB = arrB.join(",");
    return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
  };
  var array_default = {
    type: "array",
    render: render2,
    Edit: "array",
    sort: sort4,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
    validOperators: [
      OPERATOR_IS_ANY2,
      OPERATOR_IS_NONE,
      OPERATOR_IS_ALL,
      OPERATOR_IS_NOT_ALL
    ],
    format: {},
    getValueFormatted: getValueFormatted7,
    validate: {
      required: isValidRequiredForArray,
      elements: isValidElements,
      custom: isValidCustom5
    }
  };

  // packages/dataviews/build-module/field-types/password.mjs
  function getValueFormatted8({
    item,
    field
  }) {
    return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
  }
  var password_default2 = {
    type: "password",
    render,
    Edit: "password",
    sort: () => 0,
    // Passwords should not be sortable for security reasons
    enableSorting: false,
    enableGlobalSearch: false,
    defaultOperators: [],
    validOperators: [],
    format: {},
    getValueFormatted: getValueFormatted8,
    validate: {
      required: isValidRequired,
      pattern: isValidPattern,
      minLength: isValidMinLength,
      maxLength: isValidMaxLength,
      elements: isValidElements
    }
  };

  // packages/dataviews/build-module/field-types/telephone.mjs
  var telephone_default = {
    type: "telephone",
    render,
    Edit: "telephone",
    sort: sort_text_default,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
    validOperators: [
      OPERATOR_IS,
      OPERATOR_IS_NOT,
      OPERATOR_CONTAINS,
      OPERATOR_NOT_CONTAINS,
      OPERATOR_STARTS_WITH,
      // Multiple selection
      OPERATOR_IS_ANY2,
      OPERATOR_IS_NONE,
      OPERATOR_IS_ALL,
      OPERATOR_IS_NOT_ALL
    ],
    format: {},
    getValueFormatted: get_value_formatted_default_default,
    validate: {
      required: isValidRequired,
      pattern: isValidPattern,
      minLength: isValidMinLength,
      maxLength: isValidMaxLength,
      elements: isValidElements
    }
  };

  // packages/dataviews/build-module/field-types/color.mjs
  var import_i18n109 = __toESM(require_i18n(), 1);
  var import_jsx_runtime207 = __toESM(require_jsx_runtime(), 1);
  function render3({ item, field }) {
    if (field.hasElements) {
      return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(RenderFromElements, { item, field });
    }
    const value = get_value_formatted_default_default({ item, field });
    if (!value || !w2(value).isValid()) {
      return value;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
      /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
        "div",
        {
          style: {
            width: "16px",
            height: "16px",
            borderRadius: "50%",
            backgroundColor: value,
            border: "1px solid #ddd",
            flexShrink: 0
          }
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { children: value })
    ] });
  }
  function isValidCustom6(item, field) {
    const value = field.getValue({ item });
    if (![void 0, "", null].includes(value) && !w2(value).isValid()) {
      return (0, import_i18n109.__)("Value must be a valid color.");
    }
    return null;
  }
  var sort5 = (a3, b3, direction) => {
    const colorA = w2(a3);
    const colorB = w2(b3);
    if (!colorA.isValid() && !colorB.isValid()) {
      return 0;
    }
    if (!colorA.isValid()) {
      return direction === "asc" ? 1 : -1;
    }
    if (!colorB.isValid()) {
      return direction === "asc" ? -1 : 1;
    }
    const hslA = colorA.toHsl();
    const hslB = colorB.toHsl();
    if (hslA.h !== hslB.h) {
      return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
    }
    if (hslA.s !== hslB.s) {
      return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
    }
    return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
  };
  var color_default2 = {
    type: "color",
    render: render3,
    Edit: "color",
    sort: sort5,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
    validOperators: [
      OPERATOR_IS,
      OPERATOR_IS_NOT,
      OPERATOR_IS_ANY2,
      OPERATOR_IS_NONE
    ],
    format: {},
    getValueFormatted: get_value_formatted_default_default,
    validate: {
      required: isValidRequired,
      elements: isValidElements,
      custom: isValidCustom6
    }
  };

  // packages/dataviews/build-module/field-types/url.mjs
  var url_default = {
    type: "url",
    render,
    Edit: "url",
    sort: sort_text_default,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
    validOperators: [
      OPERATOR_IS,
      OPERATOR_IS_NOT,
      OPERATOR_CONTAINS,
      OPERATOR_NOT_CONTAINS,
      OPERATOR_STARTS_WITH,
      // Multiple selection
      OPERATOR_IS_ANY2,
      OPERATOR_IS_NONE,
      OPERATOR_IS_ALL,
      OPERATOR_IS_NOT_ALL
    ],
    format: {},
    getValueFormatted: get_value_formatted_default_default,
    validate: {
      required: isValidRequired,
      pattern: isValidPattern,
      minLength: isValidMinLength,
      maxLength: isValidMaxLength,
      elements: isValidElements
    }
  };

  // packages/dataviews/build-module/field-types/no-type.mjs
  var sort6 = (a3, b3, direction) => {
    if (typeof a3 === "number" && typeof b3 === "number") {
      return sort_number_default(a3, b3, direction);
    }
    return sort_text_default(a3, b3, direction);
  };
  var no_type_default = {
    // type: no type for this one
    render,
    Edit: null,
    sort: sort6,
    enableSorting: true,
    enableGlobalSearch: false,
    defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
    validOperators: getAllOperatorNames(),
    format: {},
    getValueFormatted: get_value_formatted_default_default,
    validate: {
      required: isValidRequired,
      elements: isValidElements
    }
  };

  // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
  function supportsNumericRangeConstraint(type) {
    return type === "integer" || type === "number";
  }
  function supportsDateRangeConstraint(type) {
    return type === "date" || type === "datetime";
  }
  function normalizeRangeRule(value, fieldType, key) {
    const validator = fieldType.validate[key];
    if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
      return { constraint: value, validate: validator };
    }
    return void 0;
  }
  function getIsValid(field, fieldType) {
    const rules = field.isValid;
    let required;
    if (rules?.required === true && fieldType.validate.required !== void 0) {
      required = {
        constraint: true,
        validate: fieldType.validate.required
      };
    }
    let elements2;
    if ((rules?.elements === true || // elements is enabled unless the field opts-out
    rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
      elements2 = {
        constraint: true,
        validate: fieldType.validate.elements
      };
    }
    const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
    const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
    const minLengthValue = rules?.minLength;
    let minLength;
    if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
      minLength = {
        constraint: minLengthValue,
        validate: fieldType.validate.minLength
      };
    }
    const maxLengthValue = rules?.maxLength;
    let maxLength;
    if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
      maxLength = {
        constraint: maxLengthValue,
        validate: fieldType.validate.maxLength
      };
    }
    const patternValue = rules?.pattern;
    let pattern;
    if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
      pattern = {
        constraint: patternValue,
        validate: fieldType.validate.pattern
      };
    }
    const custom = rules?.custom ?? fieldType.validate.custom;
    return {
      required,
      elements: elements2,
      min: min2,
      max: max2,
      minLength,
      maxLength,
      pattern,
      custom
    };
  }

  // packages/dataviews/build-module/field-types/utils/get-filter.mjs
  function getFilter(fieldType) {
    return fieldType.validOperators.reduce((accumulator, operator) => {
      const operatorObj = getOperatorByName(operator);
      if (operatorObj?.filter) {
        accumulator[operator] = operatorObj.filter;
      }
      return accumulator;
    }, {});
  }

  // packages/dataviews/build-module/field-types/utils/get-format.mjs
  function getFormat(field, fieldType) {
    return {
      ...fieldType.format,
      ...field.format
    };
  }
  var get_format_default = getFormat;

  // packages/dataviews/build-module/field-types/index.mjs
  function getFieldTypeByName(type) {
    const found = [
      email_default,
      integer_default,
      number_default,
      text_default,
      datetime_default,
      date_default2,
      boolean_default,
      media_default,
      array_default,
      password_default2,
      telephone_default,
      color_default2,
      url_default
    ].find((fieldType) => fieldType?.type === type);
    if (!!found) {
      return found;
    }
    return no_type_default;
  }
  function normalizeFields(fields3) {
    return fields3.map((field) => {
      const fieldType = getFieldTypeByName(field.type);
      const getValue2 = field.getValue || get_value_from_id_default(field.id);
      const sort7 = function(a3, b3, direction) {
        const aValue = getValue2({ item: a3 });
        const bValue = getValue2({ item: b3 });
        return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
      };
      return {
        id: field.id,
        label: field.label || field.id,
        header: field.header || field.label || field.id,
        description: field.description,
        placeholder: field.placeholder,
        getValue: getValue2,
        setValue: field.setValue || set_value_from_id_default(field.id),
        elements: field.elements,
        getElements: field.getElements,
        hasElements: hasElements(field),
        isVisible: field.isVisible,
        isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
        enableHiding: field.enableHiding ?? true,
        readOnly: field.readOnly ?? false,
        // The type provides defaults for the following props
        type: fieldType.type,
        render: field.render ?? fieldType.render,
        Edit: getControl(field, fieldType.Edit),
        sort: sort7,
        enableSorting: field.enableSorting ?? fieldType.enableSorting,
        enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
        isValid: getIsValid(field, fieldType),
        filterBy: get_filter_by_default(
          field,
          fieldType.defaultOperators,
          fieldType.validOperators
        ),
        filter: getFilter(fieldType),
        format: get_format_default(field, fieldType),
        getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
      };
    });
  }

  // packages/dataviews/build-module/hooks/use-data.mjs
  var import_element100 = __toESM(require_element(), 1);
  function useData({
    view: view2,
    data: shownData,
    getItemId,
    isLoading,
    paginationInfo: paginationInfo2,
    selection
  }) {
    const isInfiniteScrollEnabled = view2.infiniteScrollEnabled;
    const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element100.useState)(
      !isLoading
    );
    (0, import_element100.useEffect)(() => {
      if (!isLoading) {
        setHasInitiallyLoaded(true);
      }
    }, [isLoading]);
    const previousDataRef = (0, import_element100.useRef)(shownData);
    const previousPaginationInfoRef = (0, import_element100.useRef)(paginationInfo2);
    (0, import_element100.useEffect)(() => {
      if (!isLoading) {
        previousDataRef.current = shownData;
        previousPaginationInfoRef.current = paginationInfo2;
      }
    }, [shownData, isLoading, paginationInfo2]);
    const [visibleEntries, setVisibleEntries] = (0, import_element100.useState)([]);
    const positionMapRef = (0, import_element100.useRef)(/* @__PURE__ */ new Map());
    const allLoadedRecordsRef = (0, import_element100.useRef)([]);
    const prevViewParamsRef = (0, import_element100.useRef)({
      search: void 0,
      filters: void 0,
      perPage: void 0
    });
    const scrollDirectionRef = (0, import_element100.useRef)(void 0);
    const prevStartPositionRef = (0, import_element100.useRef)(void 0);
    const hasInitializedRef = (0, import_element100.useRef)(false);
    const allLoadedRecords = (0, import_element100.useMemo)(() => {
      if (view2.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
        if (view2.startPosition < prevStartPositionRef.current) {
          scrollDirectionRef.current = "up";
        } else if (view2.startPosition > prevStartPositionRef.current) {
          scrollDirectionRef.current = "down";
        }
      }
      prevStartPositionRef.current = view2.startPosition;
      const currentFiltersKey = JSON.stringify(view2.filters ?? []);
      const prevFiltersKey = prevViewParamsRef.current.filters;
      const shouldReset = !hasInitializedRef.current || !view2.infiniteScrollEnabled || view2.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view2.perPage !== prevViewParamsRef.current.perPage;
      hasInitializedRef.current = true;
      prevViewParamsRef.current = {
        search: view2.search,
        filters: currentFiltersKey,
        perPage: view2.perPage
      };
      if (shouldReset) {
        positionMapRef.current.clear();
        scrollDirectionRef.current = void 0;
        const startPosition = view2.search ? 1 : view2.startPosition ?? 1;
        const records = shownData.map((record, index) => {
          const position = startPosition + index;
          positionMapRef.current.set(getItemId(record), position);
          return {
            ...record,
            position
          };
        });
        allLoadedRecordsRef.current = records;
        return records;
      }
      const prev = allLoadedRecordsRef.current;
      const shownDataIds = new Set(shownData.map(getItemId));
      const scrollDirection = scrollDirectionRef.current;
      const basePosition = view2.search ? 1 : view2.startPosition ?? 1;
      const newRecords = shownData.map((record, index) => {
        const itemId = getItemId(record);
        const position = view2.infiniteScrollEnabled ? basePosition + index : void 0;
        if (position !== void 0) {
          positionMapRef.current.set(itemId, position);
        }
        return {
          ...record,
          position
        };
      });
      if (newRecords.length === 0) {
        return prev;
      }
      const prevWithoutDuplicates = prev.filter(
        (record) => !shownDataIds.has(getItemId(record))
      );
      const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
      allRecords.sort((a3, b3) => {
        const posA = a3.position;
        const posB = b3.position;
        return posA - posB;
      });
      let result = allRecords;
      if (visibleEntries.length > 0) {
        const visibleMin = Math.min(...visibleEntries);
        const visibleMax = Math.max(...visibleEntries);
        const buffer = 20;
        const recordPositions = allRecords.map(
          (r4) => r4.position
        );
        const minRecordPos = Math.min(...recordPositions);
        const maxRecordPos = Math.max(...recordPositions);
        const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
        if (hasOverlap) {
          result = allRecords.filter((record) => {
            const itemId = getItemId(record);
            const isSelected2 = selection?.includes(itemId);
            if (isSelected2) {
              return true;
            }
            const itemPosition = record.position;
            if (scrollDirection === "up") {
              return itemPosition <= visibleMax + buffer;
            } else if (scrollDirection === "down") {
              return itemPosition >= visibleMin - buffer;
            }
            return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
          });
        }
      }
      allLoadedRecordsRef.current = result;
      return result;
    }, [
      shownData,
      view2.search,
      view2.filters,
      view2.perPage,
      view2.startPosition,
      view2.infiniteScrollEnabled,
      visibleEntries,
      selection,
      getItemId
    ]);
    if (!isInfiniteScrollEnabled) {
      const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
      return {
        data: dataToReturn.map((item) => ({
          ...item,
          position: void 0
        })),
        paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo2,
        hasInitiallyLoaded,
        setVisibleEntries: void 0
      };
    }
    return {
      data: allLoadedRecords,
      paginationInfo: paginationInfo2,
      hasInitiallyLoaded,
      setVisibleEntries
    };
  }

  // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
  var import_element101 = __toESM(require_element(), 1);
  var import_compose16 = __toESM(require_compose(), 1);
  function captureAnchorElement(container, anchorElementRef, direction) {
    const containerRect = container.getBoundingClientRect();
    const centerY = containerRect.top + containerRect.height / 2;
    const items = Array.from(container.querySelectorAll("[aria-posinset]"));
    if (items.length === 0) {
      return false;
    }
    const bestAnchor = items.reduce((best, item) => {
      const itemRect = item.getBoundingClientRect();
      const itemCenterY = itemRect.top + itemRect.height / 2;
      const distance2 = Math.abs(itemCenterY - centerY);
      const bestRect = best.getBoundingClientRect();
      const bestCenterY = bestRect.top + bestRect.height / 2;
      const bestDistance = Math.abs(bestCenterY - centerY);
      return distance2 < bestDistance ? item : best;
    });
    const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
    const anchorRect = bestAnchor.getBoundingClientRect();
    anchorElementRef.current = {
      posinset,
      viewportOffset: anchorRect.top - containerRect.top,
      direction
    };
    return true;
  }
  function useInfiniteScroll({
    view: view2,
    onChangeView,
    isLoading,
    paginationInfo: paginationInfo2,
    containerRef,
    setVisibleEntries
  }) {
    const anchorElementRef = (0, import_element101.useRef)(null);
    const viewRef = (0, import_element101.useRef)(view2);
    const isLoadingRef = (0, import_element101.useRef)(isLoading);
    const onChangeViewRef = (0, import_element101.useRef)(onChangeView);
    const totalItemsRef = (0, import_element101.useRef)(paginationInfo2.totalItems);
    (0, import_element101.useLayoutEffect)(() => {
      viewRef.current = view2;
      isLoadingRef.current = isLoading;
      onChangeViewRef.current = onChangeView;
      totalItemsRef.current = paginationInfo2.totalItems;
    }, [view2, isLoading, onChangeView, paginationInfo2.totalItems]);
    const intersectionObserverCallback = (0, import_element101.useCallback)(
      (entries) => {
        if (!setVisibleEntries) {
          return;
        }
        setVisibleEntries((prev) => {
          const newVisibleEntries = new Set(prev);
          let hasChanged = false;
          entries.forEach((entry) => {
            const posInSet = Number(
              entry.target?.attributes?.getNamedItem(
                "aria-posinset"
              )?.value
            );
            if (isNaN(posInSet)) {
              return;
            }
            if (entry.isIntersecting) {
              if (!newVisibleEntries.has(posInSet)) {
                newVisibleEntries.add(posInSet);
                hasChanged = true;
              }
            } else if (newVisibleEntries.has(posInSet)) {
              newVisibleEntries.delete(posInSet);
              hasChanged = true;
            }
          });
          return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
        });
      },
      [setVisibleEntries]
    );
    (0, import_element101.useLayoutEffect)(() => {
      const container = containerRef.current;
      const anchor = anchorElementRef.current;
      if (!container || !view2.infiniteScrollEnabled || !anchor || isLoading) {
        return;
      }
      const anchorElement = container.querySelector(
        `[aria-posinset="${anchor.posinset}"]`
      );
      if (anchorElement) {
        const containerRect = container.getBoundingClientRect();
        const anchorRect = anchorElement.getBoundingClientRect();
        const currentOffset = anchorRect.top - containerRect.top;
        const scrollAdjustment = currentOffset - anchor.viewportOffset;
        if (Math.abs(scrollAdjustment) > 1) {
          container.scrollTop += scrollAdjustment;
        }
      }
      anchorElementRef.current = null;
    }, [containerRef, isLoading, view2.infiniteScrollEnabled]);
    const intersectionObserverRef = (0, import_element101.useRef)(
      null
    );
    (0, import_element101.useEffect)(() => {
      if (!view2.infiniteScrollEnabled || !intersectionObserverCallback) {
        if (intersectionObserverRef.current) {
          intersectionObserverRef.current.disconnect();
          intersectionObserverRef.current = null;
        }
        return;
      }
      intersectionObserverRef.current = new IntersectionObserver(
        intersectionObserverCallback,
        { root: null, rootMargin: "0px", threshold: 0.1 }
      );
      return () => {
        if (intersectionObserverRef.current) {
          intersectionObserverRef.current.disconnect();
          intersectionObserverRef.current = null;
        }
      };
    }, [view2.infiniteScrollEnabled, intersectionObserverCallback]);
    (0, import_element101.useEffect)(() => {
      if (!view2.infiniteScrollEnabled || !containerRef.current) {
        return;
      }
      let lastScrollTop = 0;
      const BOTTOM_THRESHOLD = 600;
      const TOP_THRESHOLD = 800;
      const handleScroll = (0, import_compose16.throttle)((event) => {
        const currentView = viewRef.current;
        const totalItems = totalItemsRef.current;
        const target = event.target;
        const scrollTop = target.scrollTop;
        const scrollHeight = target.scrollHeight;
        const clientHeight = target.clientHeight;
        const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
        lastScrollTop = scrollTop;
        if (isLoadingRef.current) {
          return;
        }
        const currentStartPosition = currentView.startPosition || 1;
        const batchSize = currentView.perPage || 10;
        const currentEndPosition = Math.min(
          currentStartPosition + batchSize,
          totalItems
        );
        if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
          if (currentEndPosition < totalItems) {
            const newStartPosition = currentEndPosition;
            captureAnchorElement(target, anchorElementRef, "down");
            onChangeViewRef.current({
              ...currentView,
              startPosition: newStartPosition
            });
          }
        }
        if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
          if (currentStartPosition > 1) {
            const calculatedStartPosition = currentStartPosition - batchSize;
            const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
            captureAnchorElement(target, anchorElementRef, "up");
            onChangeViewRef.current({
              ...currentView,
              startPosition: newStartPosition
            });
          }
        }
      }, 50);
      const container = containerRef.current;
      container.addEventListener("scroll", handleScroll);
      return () => {
        container.removeEventListener("scroll", handleScroll);
        handleScroll.cancel();
      };
    }, [containerRef, view2.infiniteScrollEnabled]);
    return {
      intersectionObserver: intersectionObserverRef.current
    };
  }

  // packages/dataviews/build-module/dataviews/index.mjs
  var import_jsx_runtime208 = __toESM(require_jsx_runtime(), 1);
  var defaultGetItemId = (item) => item.id;
  var defaultIsItemClickable = () => true;
  var EMPTY_ARRAY7 = [];
  var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
  var dataViewsLayouts = VIEW_LAYOUTS.filter(
    (viewLayout) => !viewLayout.isPicker
  );
  function DefaultUI({
    header,
    search = true,
    searchLabel = void 0
  }) {
    const { view: view2 } = (0, import_element102.useContext)(dataviews_context_default);
    const isInfiniteScroll = view2.infiniteScrollEnabled;
    return /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(import_jsx_runtime208.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(
        Stack,
        {
          direction: "row",
          align: "top",
          justify: "space-between",
          className: clsx_default("dataviews__view-actions", {
            "dataviews__view-actions--infinite-scroll": isInfiniteScroll
          }),
          gap: "xs",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(
              Stack,
              {
                direction: "row",
                justify: "start",
                gap: "sm",
                className: "dataviews__search",
                children: [
                  search && /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(dataviews_search_default, { label: searchLabel }),
                  /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(toggle_default, {})
                ]
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
              /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(dataviews_view_config_default, {}),
              header
            ] })
          ]
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
      /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(DataViewsLayout, {}),
      /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(DataViewsFooter, {})
    ] });
  }
  function DataViews({
    view: view2,
    onChangeView,
    fields: fields3,
    search = true,
    searchLabel = void 0,
    actions: actions2 = EMPTY_ARRAY7,
    data,
    getItemId = defaultGetItemId,
    getItemLevel,
    isLoading = false,
    paginationInfo: paginationInfo2,
    defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
    selection: selectionProperty,
    onChangeSelection,
    onClickItem,
    renderItemLink,
    isItemClickable = defaultIsItemClickable,
    header,
    children,
    config: config2 = { perPageSizes: [10, 20, 50, 100] },
    empty,
    onReset
  }) {
    const [selectionState, setSelectionState] = (0, import_element102.useState)([]);
    const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
    const selection = isUncontrolled ? selectionState : selectionProperty;
    const {
      data: displayData,
      paginationInfo: displayPaginationInfo,
      hasInitiallyLoaded,
      setVisibleEntries
    } = useData({
      view: view2,
      data,
      getItemId,
      isLoading,
      selection,
      paginationInfo: paginationInfo2
    });
    const containerRef = (0, import_element102.useRef)(null);
    const [containerWidth, setContainerWidth] = (0, import_element102.useState)(0);
    const resizeObserverRef = (0, import_compose17.useResizeObserver)(
      (resizeObserverEntries) => {
        setContainerWidth(
          resizeObserverEntries[0].borderBoxSize[0].inlineSize
        );
      },
      { box: "border-box" }
    );
    const [openedFilter, setOpenedFilter] = (0, import_element102.useState)(null);
    function setSelectionWithChange(value) {
      const newValue = typeof value === "function" ? value(selection) : value;
      if (isUncontrolled) {
        setSelectionState(newValue);
      }
      if (onChangeSelection) {
        onChangeSelection(newValue);
      }
    }
    const _fields = (0, import_element102.useMemo)(() => normalizeFields(fields3), [fields3]);
    const _selection = (0, import_element102.useMemo)(() => {
      if (view2.infiniteScrollEnabled) {
        return selection;
      }
      return selection.filter(
        (id) => data.some((item) => getItemId(item) === id)
      );
    }, [selection, data, getItemId, view2.infiniteScrollEnabled]);
    const filters = use_filters_default(_fields, view2);
    const hasPrimaryOrLockedFilters = (0, import_element102.useMemo)(
      () => (filters || []).some(
        (filter) => filter.isPrimary || filter.isLocked
      ),
      [filters]
    );
    const [isShowingFilter, setIsShowingFilter] = (0, import_element102.useState)(
      hasPrimaryOrLockedFilters
    );
    const { intersectionObserver } = useInfiniteScroll({
      view: view2,
      onChangeView,
      isLoading,
      paginationInfo: paginationInfo2,
      containerRef,
      setVisibleEntries
    });
    (0, import_element102.useEffect)(() => {
      if (hasPrimaryOrLockedFilters && !isShowingFilter) {
        setIsShowingFilter(true);
      }
    }, [hasPrimaryOrLockedFilters, isShowingFilter]);
    const defaultLayouts2 = (0, import_element102.useMemo)(
      () => Object.fromEntries(
        Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
          return dataViewsLayouts.some(
            (viewLayout) => viewLayout.type === layoutType
          );
        }).map(([key, value]) => [
          key,
          value === true ? {} : value
        ])
      ),
      [defaultLayoutsProperty]
    );
    if (!defaultLayouts2[view2.type]) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(
      dataviews_context_default.Provider,
      {
        value: {
          view: view2,
          onChangeView,
          fields: _fields,
          actions: actions2,
          data: displayData,
          isLoading,
          paginationInfo: displayPaginationInfo,
          selection: _selection,
          onChangeSelection: setSelectionWithChange,
          openedFilter,
          setOpenedFilter,
          getItemId,
          getItemLevel,
          isItemClickable,
          onClickItem,
          renderItemLink,
          containerWidth,
          containerRef,
          resizeObserverRef,
          defaultLayouts: defaultLayouts2,
          filters,
          isShowingFilter,
          setIsShowingFilter,
          config: config2,
          empty,
          hasInitiallyLoaded,
          onReset,
          intersectionObserver
        },
        children: /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(
          DefaultUI,
          {
            header,
            search,
            searchLabel
          }
        ) })
      }
    );
  }
  var DataViewsSubComponents = DataViews;
  DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
  DataViewsSubComponents.Filters = filters_default;
  DataViewsSubComponents.FiltersToggled = filters_toggled_default;
  DataViewsSubComponents.FiltersToggle = toggle_default;
  DataViewsSubComponents.Layout = DataViewsLayout;
  DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
  DataViewsSubComponents.Pagination = DataViewsPagination;
  DataViewsSubComponents.Search = dataviews_search_default;
  DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
  DataViewsSubComponents.Footer = DataViewsFooter;
  var dataviews_default = DataViewsSubComponents;

  // packages/dataviews/build-module/dataform/index.mjs
  var import_element114 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/components/dataform-context/index.mjs
  var import_element103 = __toESM(require_element(), 1);
  var import_jsx_runtime209 = __toESM(require_jsx_runtime(), 1);
  var DataFormContext = (0, import_element103.createContext)({
    fields: []
  });
  DataFormContext.displayName = "DataFormContext";
  function DataFormProvider({
    fields: fields3,
    children
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(DataFormContext.Provider, { value: { fields: fields3 }, children });
  }
  var dataform_context_default = DataFormContext;

  // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
  var import_element113 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
  var import_element104 = __toESM(require_element(), 1);
  var import_components73 = __toESM(require_components(), 1);

  // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
  var import_i18n110 = __toESM(require_i18n(), 1);
  var DEFAULT_LAYOUT = {
    type: "regular",
    labelPosition: "top"
  };
  var normalizeCardSummaryField = (sum) => {
    if (typeof sum === "string") {
      return [{ id: sum, visibility: "when-collapsed" }];
    }
    return sum.map((item) => {
      if (typeof item === "string") {
        return { id: item, visibility: "when-collapsed" };
      }
      return { id: item.id, visibility: item.visibility };
    });
  };
  function normalizeLayout(layout) {
    let normalizedLayout = DEFAULT_LAYOUT;
    if (layout?.type === "regular") {
      normalizedLayout = {
        type: "regular",
        labelPosition: layout?.labelPosition ?? "top"
      };
    } else if (layout?.type === "panel") {
      const summary = layout.summary ?? [];
      const normalizedSummary = Array.isArray(summary) ? summary : [summary];
      const openAs = layout?.openAs;
      let normalizedOpenAs;
      if (typeof openAs === "object" && openAs.type === "modal") {
        normalizedOpenAs = {
          type: "modal",
          applyLabel: openAs.applyLabel?.trim() || (0, import_i18n110.__)("Apply"),
          cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n110.__)("Cancel")
        };
      } else if (openAs === "modal") {
        normalizedOpenAs = {
          type: "modal",
          applyLabel: (0, import_i18n110.__)("Apply"),
          cancelLabel: (0, import_i18n110.__)("Cancel")
        };
      } else {
        normalizedOpenAs = { type: "dropdown" };
      }
      normalizedLayout = {
        type: "panel",
        labelPosition: layout?.labelPosition ?? "side",
        openAs: normalizedOpenAs,
        summary: normalizedSummary,
        editVisibility: layout?.editVisibility ?? "on-hover"
      };
    } else if (layout?.type === "card") {
      if (layout.withHeader === false) {
        normalizedLayout = {
          type: "card",
          withHeader: false,
          isOpened: true,
          summary: [],
          isCollapsible: false
        };
      } else {
        const summary = layout.summary ?? [];
        normalizedLayout = {
          type: "card",
          withHeader: true,
          isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
          summary: normalizeCardSummaryField(summary),
          isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
        };
      }
    } else if (layout?.type === "row") {
      normalizedLayout = {
        type: "row",
        alignment: layout?.alignment ?? "center",
        styles: layout?.styles ?? {}
      };
    } else if (layout?.type === "details") {
      normalizedLayout = {
        type: "details",
        summary: layout?.summary ?? ""
      };
    }
    return normalizedLayout;
  }
  function normalizeForm(form) {
    const normalizedFormLayout = normalizeLayout(form?.layout);
    const normalizedFields = (form.fields ?? []).map(
      (field) => {
        if (typeof field === "string") {
          return {
            id: field,
            layout: normalizedFormLayout
          };
        }
        const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
        return {
          id: field.id,
          layout: fieldLayout,
          ...!!field.label && { label: field.label },
          ...!!field.description && {
            description: field.description
          },
          ..."children" in field && Array.isArray(field.children) && {
            children: normalizeForm({
              fields: field.children,
              layout: DEFAULT_LAYOUT
            }).fields
          }
        };
      }
    );
    return {
      layout: normalizedFormLayout,
      fields: normalizedFields
    };
  }
  var normalize_form_default = normalizeForm;

  // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
  var import_jsx_runtime210 = __toESM(require_jsx_runtime(), 1);
  function Header3({ title }) {
    return /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(
      Stack,
      {
        direction: "column",
        className: "dataforms-layouts-regular__header",
        gap: "lg",
        children: /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(import_components73.__experimentalHeading, { level: 2, size: 13, children: title }) })
      }
    );
  }
  function FormRegularField({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const { fields: fields3 } = (0, import_element104.useContext)(dataform_context_default);
    const layout = field.layout;
    const form = (0, import_element104.useMemo)(
      () => ({
        layout: DEFAULT_LAYOUT,
        fields: !!field.children ? field.children : []
      }),
      [field]
    );
    if (!!field.children) {
      return /* @__PURE__ */ (0, import_jsx_runtime210.jsxs)(import_jsx_runtime210.Fragment, { children: [
        !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(Header3, { title: field.label }),
        /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(
          DataFormLayout,
          {
            data,
            form,
            onChange,
            validity: validity?.children
          }
        )
      ] });
    }
    const labelPosition = layout.labelPosition;
    const fieldDefinition = fields3.find(
      (fieldDef) => fieldDef.id === field.id
    );
    if (!fieldDefinition || !fieldDefinition.Edit) {
      return null;
    }
    if (labelPosition === "side") {
      return /* @__PURE__ */ (0, import_jsx_runtime210.jsxs)(
        Stack,
        {
          direction: "row",
          className: "dataforms-layouts-regular__field",
          gap: "sm",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(
              "div",
              {
                className: clsx_default(
                  "dataforms-layouts-regular__field-label",
                  `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
                ),
                children: /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(import_components73.BaseControl.VisualLabel, { children: fieldDefinition.label })
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime210.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(
              fieldDefinition.render,
              {
                item: data,
                field: fieldDefinition
              }
            ) : /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(
              fieldDefinition.Edit,
              {
                data,
                field: fieldDefinition,
                onChange,
                hideLabelFromVision: true,
                markWhenOptional,
                validity
              },
              fieldDefinition.id
            ) })
          ]
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime210.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(import_jsx_runtime210.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime210.jsxs)(import_jsx_runtime210.Fragment, { children: [
      !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(import_components73.BaseControl.VisualLabel, { children: fieldDefinition.label }),
      /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(
        fieldDefinition.render,
        {
          item: data,
          field: fieldDefinition
        }
      )
    ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(
      fieldDefinition.Edit,
      {
        data,
        field: fieldDefinition,
        onChange,
        hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
        markWhenOptional,
        validity
      }
    ) });
  }

  // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
  var import_deepmerge2 = __toESM(require_cjs(), 1);
  var import_components76 = __toESM(require_components(), 1);
  var import_element109 = __toESM(require_element(), 1);
  var import_compose19 = __toESM(require_compose(), 1);

  // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
  var import_components75 = __toESM(require_components(), 1);
  var import_i18n111 = __toESM(require_i18n(), 1);
  var import_compose18 = __toESM(require_compose(), 1);
  var import_element105 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
  function getLabelClassName(labelPosition, showError) {
    return clsx_default(
      "dataforms-layouts-panel__field-label",
      `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
      { "has-error": showError }
    );
  }
  var get_label_classname_default = getLabelClassName;

  // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
  var import_components74 = __toESM(require_components(), 1);
  var import_jsx_runtime211 = __toESM(require_jsx_runtime(), 1);
  function getLabelContent(showError, errorMessage, fieldLabel) {
    return showError ? /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(import_components74.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
      /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(import_components74.Icon, { icon: error_default, size: 16 }),
      fieldLabel
    ] }) }) : fieldLabel;
  }
  var get_label_content_default = getLabelContent;

  // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
  function getFirstValidationError(validity) {
    if (!validity) {
      return void 0;
    }
    const validityRules = Object.keys(validity).filter(
      (key) => key !== "children"
    );
    for (const key of validityRules) {
      const rule = validity[key];
      if (rule === void 0) {
        continue;
      }
      if (rule.type === "invalid") {
        if (rule.message) {
          return rule.message;
        }
        if (key === "required") {
          return "A required field is empty";
        }
        return "Unidentified validation error";
      }
    }
    if (validity.children) {
      for (const childValidity of Object.values(validity.children)) {
        const childError = getFirstValidationError(childValidity);
        if (childError) {
          return childError;
        }
      }
    }
    return void 0;
  }
  var get_first_validation_error_default = getFirstValidationError;

  // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
  var import_jsx_runtime212 = __toESM(require_jsx_runtime(), 1);
  function SummaryButton({
    data,
    field,
    fieldLabel,
    summaryFields,
    validity,
    touched,
    disabled: disabled2,
    onClick,
    "aria-expanded": ariaExpanded
  }) {
    const { labelPosition, editVisibility } = field.layout;
    const errorMessage = get_first_validation_error_default(validity);
    const showError = touched && !!errorMessage;
    const labelClassName = get_label_classname_default(labelPosition, showError);
    const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
    const className = clsx_default(
      "dataforms-layouts-panel__field-trigger",
      `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
      {
        "is-disabled": disabled2,
        "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
      }
    );
    const controlId = (0, import_compose18.useInstanceId)(
      SummaryButton,
      "dataforms-layouts-panel__field-control"
    );
    const ariaLabel = showError ? (0, import_i18n111.sprintf)(
      // translators: %s: Field name.
      (0, import_i18n111._x)("Edit %s (has errors)", "field"),
      fieldLabel || ""
    ) : (0, import_i18n111.sprintf)(
      // translators: %s: Field name.
      (0, import_i18n111._x)("Edit %s", "field"),
      fieldLabel || ""
    );
    const rowRef = (0, import_element105.useRef)(null);
    const handleRowClick = () => {
      const selection = rowRef.current?.ownerDocument.defaultView?.getSelection();
      if (selection && selection.toString().length > 0) {
        return;
      }
      onClick();
    };
    const handleKeyDown = (event) => {
      if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
        event.preventDefault();
        onClick();
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)(
      "div",
      {
        ref: rowRef,
        className,
        onClick: !disabled2 ? handleRowClick : void 0,
        onKeyDown: !disabled2 ? handleKeyDown : void 0,
        children: [
          labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("span", { className: labelClassName, children: labelContent }),
          labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components75.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components75.Icon, { icon: error_default, size: 16 }) }) }),
          /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(
            "span",
            {
              id: `${controlId}`,
              className: "dataforms-layouts-panel__field-control",
              children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(
                "span",
                {
                  style: {
                    display: "flex",
                    flexDirection: "column",
                    alignItems: "flex-start",
                    width: "100%",
                    gap: "2px"
                  },
                  children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(
                    "span",
                    {
                      style: { width: "100%" },
                      children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(
                        summaryField.render,
                        {
                          item: data,
                          field: summaryField
                        }
                      )
                    },
                    summaryField.id
                  ))
                }
              ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(
                summaryField.render,
                {
                  item: data,
                  field: summaryField
                },
                summaryField.id
              ))
            }
          ),
          !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(
            import_components75.Button,
            {
              className: "dataforms-layouts-panel__field-trigger-icon",
              label: ariaLabel,
              icon: pencil_default,
              size: "small",
              "aria-expanded": ariaExpanded,
              "aria-haspopup": "dialog",
              "aria-describedby": `${controlId}`
            }
          )
        ]
      }
    );
  }

  // packages/dataviews/build-module/hooks/use-form-validity.mjs
  var import_deepmerge = __toESM(require_cjs(), 1);
  var import_es62 = __toESM(require_es6(), 1);
  var import_element106 = __toESM(require_element(), 1);
  var import_i18n112 = __toESM(require_i18n(), 1);
  function isFormValid(formValidity) {
    if (!formValidity) {
      return true;
    }
    return Object.values(formValidity).every((fieldValidation) => {
      return Object.entries(fieldValidation).every(
        ([key, validation]) => {
          if (key === "children" && validation && typeof validation === "object") {
            return isFormValid(validation);
          }
          return validation.type !== "invalid" && validation.type !== "validating";
        }
      );
    });
  }
  function getFormFieldsToValidate(form, fields3) {
    const normalizedForm = normalize_form_default(form);
    if (normalizedForm.fields.length === 0) {
      return [];
    }
    const fieldsMap = /* @__PURE__ */ new Map();
    fields3.forEach((field) => {
      fieldsMap.set(field.id, field);
    });
    function processFormField(formField) {
      if ("children" in formField && Array.isArray(formField.children)) {
        const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
        if (processedChildren.length === 0) {
          return null;
        }
        const fieldDef2 = fieldsMap.get(formField.id);
        if (fieldDef2) {
          const [normalizedField2] = normalizeFields([
            fieldDef2
          ]);
          return {
            id: formField.id,
            children: processedChildren,
            field: normalizedField2
          };
        }
        return {
          id: formField.id,
          children: processedChildren
        };
      }
      const fieldDef = fieldsMap.get(formField.id);
      if (!fieldDef) {
        return null;
      }
      const [normalizedField] = normalizeFields([fieldDef]);
      return {
        id: formField.id,
        children: [],
        field: normalizedField
      };
    }
    const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
    return toValidate;
  }
  function setValidityAtPath(formValidity, fieldValidity, path) {
    if (!formValidity) {
      formValidity = {};
    }
    if (path.length === 0) {
      return formValidity;
    }
    const result = { ...formValidity };
    let current = result;
    for (let i3 = 0; i3 < path.length - 1; i3++) {
      const segment = path[i3];
      if (!current[segment]) {
        current[segment] = {};
      }
      current[segment] = { ...current[segment] };
      current = current[segment];
    }
    const finalKey = path[path.length - 1];
    current[finalKey] = {
      ...current[finalKey] || {},
      ...fieldValidity
    };
    return result;
  }
  function removeValidationProperty(formValidity, path, property) {
    if (!formValidity || path.length === 0) {
      return formValidity;
    }
    const result = { ...formValidity };
    let current = result;
    for (let i3 = 0; i3 < path.length - 1; i3++) {
      const segment = path[i3];
      if (!current[segment]) {
        return formValidity;
      }
      current[segment] = { ...current[segment] };
      current = current[segment];
    }
    const finalKey = path[path.length - 1];
    if (!current[finalKey]) {
      return formValidity;
    }
    const fieldValidity = { ...current[finalKey] };
    delete fieldValidity[property];
    if (Object.keys(fieldValidity).length === 0) {
      delete current[finalKey];
    } else {
      current[finalKey] = fieldValidity;
    }
    if (Object.keys(result).length === 0) {
      return void 0;
    }
    return result;
  }
  function handleElementsValidationAsync(promise, formField, promiseHandler) {
    const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
    const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
    elementsCounterRef.current[formField.id] = currentToken;
    promise.then((result) => {
      if (currentToken !== elementsCounterRef.current[formField.id]) {
        return;
      }
      if (!Array.isArray(result)) {
        setFormValidity((prev) => {
          const newFormValidity = setValidityAtPath(
            prev,
            {
              elements: {
                type: "invalid",
                message: (0, import_i18n112.__)("Could not validate elements.")
              }
            },
            [...path, formField.id]
          );
          return newFormValidity;
        });
        return;
      }
      if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
        ...formField.field,
        elements: result
      })) {
        setFormValidity((prev) => {
          const newFormValidity = setValidityAtPath(
            prev,
            {
              elements: {
                type: "invalid",
                message: (0, import_i18n112.__)(
                  "Value must be one of the elements."
                )
              }
            },
            [...path, formField.id]
          );
          return newFormValidity;
        });
      } else {
        setFormValidity((prev) => {
          return removeValidationProperty(
            prev,
            [...path, formField.id],
            "elements"
          );
        });
      }
    }).catch((error2) => {
      if (currentToken !== elementsCounterRef.current[formField.id]) {
        return;
      }
      let errorMessage;
      if (error2 instanceof Error) {
        errorMessage = error2.message;
      } else {
        errorMessage = String(error2) || (0, import_i18n112.__)(
          "Unknown error when running elements validation asynchronously."
        );
      }
      setFormValidity((prev) => {
        const newFormValidity = setValidityAtPath(
          prev,
          {
            elements: {
              type: "invalid",
              message: errorMessage
            }
          },
          [...path, formField.id]
        );
        return newFormValidity;
      });
    });
  }
  function handleCustomValidationAsync(promise, formField, promiseHandler) {
    const { customCounterRef, setFormValidity, path } = promiseHandler;
    const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
    customCounterRef.current[formField.id] = currentToken;
    promise.then((result) => {
      if (currentToken !== customCounterRef.current[formField.id]) {
        return;
      }
      if (result === null) {
        setFormValidity((prev) => {
          return removeValidationProperty(
            prev,
            [...path, formField.id],
            "custom"
          );
        });
        return;
      }
      if (typeof result === "string") {
        setFormValidity((prev) => {
          const newFormValidity = setValidityAtPath(
            prev,
            {
              custom: {
                type: "invalid",
                message: result
              }
            },
            [...path, formField.id]
          );
          return newFormValidity;
        });
        return;
      }
      setFormValidity((prev) => {
        const newFormValidity = setValidityAtPath(
          prev,
          {
            custom: {
              type: "invalid",
              message: (0, import_i18n112.__)("Validation could not be processed.")
            }
          },
          [...path, formField.id]
        );
        return newFormValidity;
      });
    }).catch((error2) => {
      if (currentToken !== customCounterRef.current[formField.id]) {
        return;
      }
      let errorMessage;
      if (error2 instanceof Error) {
        errorMessage = error2.message;
      } else {
        errorMessage = String(error2) || (0, import_i18n112.__)(
          "Unknown error when running custom validation asynchronously."
        );
      }
      setFormValidity((prev) => {
        const newFormValidity = setValidityAtPath(
          prev,
          {
            custom: {
              type: "invalid",
              message: errorMessage
            }
          },
          [...path, formField.id]
        );
        return newFormValidity;
      });
    });
  }
  function validateFormField(item, formField, promiseHandler) {
    if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
      return {
        required: { type: "invalid" }
      };
    }
    if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
      return {
        pattern: {
          type: "invalid",
          message: (0, import_i18n112.__)("Value does not match the required pattern.")
        }
      };
    }
    if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
      return {
        min: {
          type: "invalid",
          message: (0, import_i18n112.__)("Value is below the minimum.")
        }
      };
    }
    if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
      return {
        max: {
          type: "invalid",
          message: (0, import_i18n112.__)("Value is above the maximum.")
        }
      };
    }
    if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
      return {
        minLength: {
          type: "invalid",
          message: (0, import_i18n112.__)("Value is too short.")
        }
      };
    }
    if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
      return {
        maxLength: {
          type: "invalid",
          message: (0, import_i18n112.__)("Value is too long.")
        }
      };
    }
    if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
      return {
        elements: {
          type: "invalid",
          message: (0, import_i18n112.__)("Value must be one of the elements.")
        }
      };
    }
    let customError;
    if (!!formField.field && formField.field.isValid.custom) {
      try {
        const value = formField.field.getValue({ item });
        customError = formField.field.isValid.custom(
          (0, import_deepmerge.default)(
            item,
            formField.field.setValue({
              item,
              value
            })
          ),
          formField.field
        );
      } catch (error2) {
        let errorMessage;
        if (error2 instanceof Error) {
          errorMessage = error2.message;
        } else {
          errorMessage = String(error2) || (0, import_i18n112.__)("Unknown error when running custom validation.");
        }
        return {
          custom: {
            type: "invalid",
            message: errorMessage
          }
        };
      }
    }
    if (typeof customError === "string") {
      return {
        custom: {
          type: "invalid",
          message: customError
        }
      };
    }
    const fieldValidity = {};
    if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
      handleElementsValidationAsync(
        formField.field.getElements(),
        formField,
        promiseHandler
      );
      fieldValidity.elements = {
        type: "validating",
        message: (0, import_i18n112.__)("Validating\u2026")
      };
    }
    if (customError instanceof Promise) {
      handleCustomValidationAsync(customError, formField, promiseHandler);
      fieldValidity.custom = {
        type: "validating",
        message: (0, import_i18n112.__)("Validating\u2026")
      };
    }
    if (Object.keys(fieldValidity).length > 0) {
      return fieldValidity;
    }
    if (formField.children.length > 0) {
      const result = {};
      formField.children.forEach((child) => {
        result[child.id] = validateFormField(item, child, {
          ...promiseHandler,
          path: [...promiseHandler.path, formField.id, "children"]
        });
      });
      const filteredResult = {};
      Object.entries(result).forEach(([key, value]) => {
        if (value !== void 0) {
          filteredResult[key] = value;
        }
      });
      if (Object.keys(filteredResult).length === 0) {
        return void 0;
      }
      return {
        children: filteredResult
      };
    }
    return void 0;
  }
  function getFormFieldValue(formField, item) {
    const fieldValue = formField?.field?.getValue({ item });
    if (formField.children.length === 0) {
      return fieldValue;
    }
    const childrenValues = formField.children.map(
      (child) => getFormFieldValue(child, item)
    );
    if (!childrenValues) {
      return fieldValue;
    }
    return {
      value: fieldValue,
      children: childrenValues
    };
  }
  function useFormValidity(item, fields3, form) {
    const [formValidity, setFormValidity] = (0, import_element106.useState)();
    const customCounterRef = (0, import_element106.useRef)({});
    const elementsCounterRef = (0, import_element106.useRef)({});
    const previousValuesRef = (0, import_element106.useRef)({});
    const validate = (0, import_element106.useCallback)(() => {
      const promiseHandler = {
        customCounterRef,
        elementsCounterRef,
        setFormValidity,
        path: [],
        item
      };
      const formFieldsToValidate = getFormFieldsToValidate(form, fields3);
      if (formFieldsToValidate.length === 0) {
        setFormValidity(void 0);
        return;
      }
      const newFormValidity = {};
      const untouchedFields = [];
      formFieldsToValidate.forEach((formField) => {
        const value = getFormFieldValue(formField, item);
        if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
          previousValuesRef.current[formField.id],
          value
        )) {
          untouchedFields.push(formField.id);
          return;
        }
        previousValuesRef.current[formField.id] = value;
        const fieldValidity = validateFormField(
          item,
          formField,
          promiseHandler
        );
        if (fieldValidity !== void 0) {
          newFormValidity[formField.id] = fieldValidity;
        }
      });
      setFormValidity((existingFormValidity) => {
        let validity = {
          ...existingFormValidity,
          ...newFormValidity
        };
        const fieldsToKeep = [
          ...untouchedFields,
          ...Object.keys(newFormValidity)
        ];
        Object.keys(validity).forEach((key) => {
          if (validity && !fieldsToKeep.includes(key)) {
            delete validity[key];
          }
        });
        if (Object.keys(validity).length === 0) {
          validity = void 0;
        }
        const areEqual = (0, import_es62.default)(existingFormValidity, validity);
        if (areEqual) {
          return existingFormValidity;
        }
        return validity;
      });
    }, [item, fields3, form]);
    (0, import_element106.useEffect)(() => {
      validate();
    }, [validate]);
    return {
      validity: formValidity,
      isValid: isFormValid(formValidity)
    };
  }
  var use_form_validity_default = useFormValidity;

  // packages/dataviews/build-module/hooks/use-report-validity.mjs
  var import_element107 = __toESM(require_element(), 1);
  function useReportValidity(ref, shouldReport) {
    (0, import_element107.useEffect)(() => {
      if (shouldReport && ref.current) {
        const inputs = ref.current.querySelectorAll(
          "input, textarea, select"
        );
        inputs.forEach((input) => {
          input.reportValidity();
        });
      }
    }, [shouldReport, ref]);
  }

  // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
  var import_element108 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
  function extractSummaryIds(summary) {
    if (Array.isArray(summary)) {
      return summary.map(
        (item) => typeof item === "string" ? item : item.id
      );
    }
    return [];
  }
  var getSummaryFields = (summaryField, fields3) => {
    if (Array.isArray(summaryField) && summaryField.length > 0) {
      const summaryIds = extractSummaryIds(summaryField);
      return summaryIds.map(
        (summaryId) => fields3.find((_field) => _field.id === summaryId)
      ).filter((_field) => _field !== void 0);
    }
    return [];
  };

  // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
  var getFieldDefinition = (field, fields3) => {
    const fieldDefinition = fields3.find((_field) => _field.id === field.id);
    if (!fieldDefinition) {
      return fields3.find((_field) => {
        if (!!field.children) {
          const simpleChildren = field.children.filter(
            (child) => !child.children
          );
          if (simpleChildren.length === 0) {
            return false;
          }
          return _field.id === simpleChildren[0].id;
        }
        return _field.id === field.id;
      });
    }
    return fieldDefinition;
  };
  function useFieldFromFormField(field) {
    const { fields: fields3 } = (0, import_element108.useContext)(dataform_context_default);
    const layout = field.layout;
    const summaryFields = getSummaryFields(layout.summary, fields3);
    const fieldDefinition = getFieldDefinition(field, fields3);
    const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
    if (summaryFields.length === 0) {
      return {
        summaryFields: fieldDefinition ? [fieldDefinition] : [],
        fieldDefinition,
        fieldLabel
      };
    }
    return {
      summaryFields,
      fieldDefinition,
      fieldLabel
    };
  }
  var use_field_from_form_field_default = useFieldFromFormField;

  // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
  var import_jsx_runtime213 = __toESM(require_jsx_runtime(), 1);
  function ModalContent({
    data,
    field,
    onChange,
    fieldLabel,
    onClose,
    touched
  }) {
    const { openAs } = field.layout;
    const { applyLabel, cancelLabel } = openAs;
    const { fields: fields3 } = (0, import_element109.useContext)(dataform_context_default);
    const [changes, setChanges] = (0, import_element109.useState)({});
    const modalData = (0, import_element109.useMemo)(() => {
      return (0, import_deepmerge2.default)(data, changes, {
        arrayMerge: (target, source) => source
      });
    }, [data, changes]);
    const form = (0, import_element109.useMemo)(
      () => ({
        layout: DEFAULT_LAYOUT,
        fields: !!field.children ? field.children : (
          // If not explicit children return the field id itself.
          [{ id: field.id, layout: DEFAULT_LAYOUT }]
        )
      }),
      [field]
    );
    const fieldsAsFieldType = fields3.map((f3) => ({
      ...f3,
      Edit: f3.Edit === null ? void 0 : f3.Edit,
      isValid: {
        required: f3.isValid.required?.constraint,
        elements: f3.isValid.elements?.constraint,
        min: f3.isValid.min?.constraint,
        max: f3.isValid.max?.constraint,
        pattern: f3.isValid.pattern?.constraint,
        minLength: f3.isValid.minLength?.constraint,
        maxLength: f3.isValid.maxLength?.constraint
      }
    }));
    const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
    const onApply = () => {
      onChange(changes);
      onClose();
    };
    const handleOnChange = (newValue) => {
      setChanges(
        (prev) => (0, import_deepmerge2.default)(prev, newValue, {
          arrayMerge: (target, source) => source
        })
      );
    };
    const focusOnMountRef = (0, import_compose19.useFocusOnMount)("firstInputElement");
    const contentRef = (0, import_element109.useRef)(null);
    const mergedRef = (0, import_compose19.useMergeRefs)([focusOnMountRef, contentRef]);
    useReportValidity(contentRef, touched);
    return /* @__PURE__ */ (0, import_jsx_runtime213.jsxs)(
      import_components76.Modal,
      {
        className: "dataforms-layouts-panel__modal",
        onRequestClose: onClose,
        isFullScreen: false,
        title: fieldLabel,
        size: "medium",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime213.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(
            DataFormLayout,
            {
              data: modalData,
              form,
              onChange: handleOnChange,
              validity,
              children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(
                FieldLayout,
                {
                  data: modalData,
                  field: childField,
                  onChange: handleOnChange,
                  hideLabelFromVision: form.fields.length < 2,
                  markWhenOptional,
                  validity: childFieldValidity
                },
                childField.id
              )
            }
          ) }),
          /* @__PURE__ */ (0, import_jsx_runtime213.jsxs)(
            Stack,
            {
              direction: "row",
              className: "dataforms-layouts-panel__modal-footer",
              gap: "md",
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(import_components76.__experimentalSpacer, { style: { flex: 1 } }),
                /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(
                  import_components76.Button,
                  {
                    variant: "tertiary",
                    onClick: onClose,
                    __next40pxDefaultSize: true,
                    children: cancelLabel
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(
                  import_components76.Button,
                  {
                    variant: "primary",
                    onClick: onApply,
                    __next40pxDefaultSize: true,
                    children: applyLabel
                  }
                )
              ]
            }
          )
        ]
      }
    );
  }
  function PanelModal({
    data,
    field,
    onChange,
    validity
  }) {
    const [touched, setTouched] = (0, import_element109.useState)(false);
    const [isOpen2, setIsOpen] = (0, import_element109.useState)(false);
    const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
    if (!fieldDefinition) {
      return null;
    }
    const handleClose = () => {
      setIsOpen(false);
      setTouched(true);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime213.jsxs)(import_jsx_runtime213.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(
        SummaryButton,
        {
          data,
          field,
          fieldLabel,
          summaryFields,
          validity,
          touched,
          disabled: fieldDefinition.readOnly === true,
          onClick: () => setIsOpen(true),
          "aria-expanded": isOpen2
        }
      ),
      isOpen2 && /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(
        ModalContent,
        {
          data,
          field,
          onChange,
          fieldLabel: fieldLabel ?? "",
          onClose: handleClose,
          touched
        }
      )
    ] });
  }
  var modal_default = PanelModal;

  // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
  var import_components77 = __toESM(require_components(), 1);
  var import_i18n113 = __toESM(require_i18n(), 1);
  var import_element110 = __toESM(require_element(), 1);
  var import_compose20 = __toESM(require_compose(), 1);
  var import_jsx_runtime214 = __toESM(require_jsx_runtime(), 1);
  function DropdownHeader({
    title,
    onClose
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
      Stack,
      {
        direction: "column",
        className: "dataforms-layouts-panel__dropdown-header",
        gap: "lg",
        children: /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
          title && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components77.__experimentalHeading, { level: 2, size: 13, children: title }),
          /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components77.__experimentalSpacer, { style: { flex: 1 } }),
          onClose && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
            import_components77.Button,
            {
              label: (0, import_i18n113.__)("Close"),
              icon: close_small_default,
              onClick: onClose,
              size: "small"
            }
          )
        ] })
      }
    );
  }
  function DropdownContentWithValidation({
    touched,
    children
  }) {
    const ref = (0, import_element110.useRef)(null);
    useReportValidity(ref, touched);
    return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("div", { ref, children });
  }
  function PanelDropdown({
    data,
    field,
    onChange,
    validity
  }) {
    const [touched, setTouched] = (0, import_element110.useState)(false);
    const [popoverAnchor, setPopoverAnchor] = (0, import_element110.useState)(
      null
    );
    const popoverProps = (0, import_element110.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    const [dialogRef, dialogProps] = (0, import_compose20.__experimentalUseDialog)({
      focusOnMount: "firstInputElement"
    });
    const form = (0, import_element110.useMemo)(
      () => ({
        layout: DEFAULT_LAYOUT,
        fields: !!field.children ? field.children : (
          // If not explicit children return the field id itself.
          [{ id: field.id, layout: DEFAULT_LAYOUT }]
        )
      }),
      [field]
    );
    const formValidity = (0, import_element110.useMemo)(() => {
      if (validity === void 0) {
        return void 0;
      }
      if (!!field.children) {
        return validity?.children;
      }
      return { [field.id]: validity };
    }, [validity, field]);
    const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
    if (!fieldDefinition) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
      "div",
      {
        ref: setPopoverAnchor,
        className: "dataforms-layouts-panel__field-dropdown-anchor",
        children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
          import_components77.Dropdown,
          {
            contentClassName: "dataforms-layouts-panel__field-dropdown",
            popoverProps,
            focusOnMount: false,
            onToggle: (willOpen) => {
              if (!willOpen) {
                setTouched(true);
              }
            },
            renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
              SummaryButton,
              {
                data,
                field,
                fieldLabel,
                summaryFields,
                validity,
                touched,
                disabled: fieldDefinition.readOnly === true,
                onClick: onToggle,
                "aria-expanded": isOpen2
              }
            ),
            renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
              /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
                DropdownHeader,
                {
                  title: fieldLabel,
                  onClose
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
                DataFormLayout,
                {
                  data,
                  form,
                  onChange,
                  validity: formValidity,
                  children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
                    FieldLayout,
                    {
                      data,
                      field: childField,
                      onChange,
                      hideLabelFromVision: (form?.fields ?? []).length < 2,
                      markWhenOptional,
                      validity: childFieldValidity
                    },
                    childField.id
                  )
                }
              )
            ] }) })
          }
        )
      }
    );
  }
  var dropdown_default = PanelDropdown;

  // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
  var import_jsx_runtime215 = __toESM(require_jsx_runtime(), 1);
  function FormPanelField({
    data,
    field,
    onChange,
    validity
  }) {
    const layout = field.layout;
    if (layout.openAs.type === "modal") {
      return /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(
        modal_default,
        {
          data,
          field,
          onChange,
          validity
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(
      dropdown_default,
      {
        data,
        field,
        onChange,
        validity
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
  var import_element111 = __toESM(require_element(), 1);

  // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
  var import_i18n114 = __toESM(require_i18n(), 1);
  var import_jsx_runtime216 = __toESM(require_jsx_runtime(), 1);
  function countInvalidFields(validity) {
    if (!validity) {
      return 0;
    }
    let count = 0;
    const validityRules = Object.keys(validity).filter(
      (key) => key !== "children"
    );
    for (const key of validityRules) {
      const rule = validity[key];
      if (rule?.type === "invalid") {
        count++;
      }
    }
    if (validity.children) {
      for (const childValidity of Object.values(validity.children)) {
        count += countInvalidFields(childValidity);
      }
    }
    return count;
  }
  function ValidationBadge({
    validity
  }) {
    const invalidCount = countInvalidFields(validity);
    if (invalidCount === 0) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime216.jsx)(Badge, { intent: "high", children: (0, import_i18n114.sprintf)(
      /* translators: %d: Number of fields that need attention */
      (0, import_i18n114._n)(
        "%d field needs attention",
        "%d fields need attention",
        invalidCount
      ),
      invalidCount
    ) });
  }

  // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
  var import_jsx_runtime217 = __toESM(require_jsx_runtime(), 1);
  function isSummaryFieldVisible(summaryField, summaryConfig, isOpen2) {
    if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
      return false;
    }
    const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
    const fieldConfig = summaryConfigArray.find((config2) => {
      if (typeof config2 === "string") {
        return config2 === summaryField.id;
      }
      if (typeof config2 === "object" && "id" in config2) {
        return config2.id === summaryField.id;
      }
      return false;
    });
    if (!fieldConfig) {
      return false;
    }
    if (typeof fieldConfig === "string") {
      return true;
    }
    if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
      return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen2;
    }
    return true;
  }
  function HeaderContent({
    data,
    fields: fields3,
    label,
    layout,
    isOpen: isOpen2,
    touched,
    validity
  }) {
    const summaryFields = getSummaryFields(layout.summary, fields3);
    const visibleSummaryFields = summaryFields.filter(
      (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen2)
    );
    const hasBadge = touched && layout.isCollapsible;
    const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
    return /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(
      Stack,
      {
        align: "center",
        justify: "space-between",
        className: "dataforms-layouts-card__field-header-content",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(card_exports.Title, { children: label }),
          (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
            hasBadge && /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(ValidationBadge, { validity }),
            hasSummary && /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
              summaryField.render,
              {
                item: data,
                field: summaryField
              },
              summaryField.id
            )) })
          ] })
        ]
      }
    );
  }
  function BodyContent({
    data,
    field,
    form,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity,
    withHeader
  }) {
    if (field.children) {
      return /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(import_jsx_runtime217.Fragment, { children: [
        field.description && /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
        /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
          DataFormLayout,
          {
            data,
            form,
            onChange,
            validity: validity?.children
          }
        )
      ] });
    }
    const SingleFieldLayout = getFormFieldLayout("regular")?.component;
    if (!SingleFieldLayout) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
      SingleFieldLayout,
      {
        data,
        field,
        onChange,
        hideLabelFromVision: hideLabelFromVision || withHeader,
        markWhenOptional,
        validity
      }
    );
  }
  function FormCardField({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const { fields: fields3 } = (0, import_element111.useContext)(dataform_context_default);
    const layout = field.layout;
    const contentRef = (0, import_element111.useRef)(null);
    const form = (0, import_element111.useMemo)(
      () => ({
        layout: DEFAULT_LAYOUT,
        fields: field.children ?? []
      }),
      [field]
    );
    const { isOpened, isCollapsible } = layout;
    const [isOpen2, setIsOpen] = (0, import_element111.useState)(isOpened);
    const [touched, setTouched] = (0, import_element111.useState)(false);
    (0, import_element111.useEffect)(() => {
      setIsOpen(isOpened);
    }, [isOpened]);
    const handleOpenChange = (0, import_element111.useCallback)((open) => {
      if (!open) {
        setTouched(true);
      }
      setIsOpen(open);
    }, []);
    const handleBlur = (0, import_element111.useCallback)(() => {
      setTouched(true);
    }, []);
    useReportValidity(
      contentRef,
      (isCollapsible ? isOpen2 : true) && touched
    );
    let label = field.label;
    let withHeader;
    if (field.children) {
      withHeader = !!label && layout.withHeader;
    } else {
      const fieldDefinition = fields3.find(
        (fieldDef) => fieldDef.id === field.id
      );
      if (!fieldDefinition || !fieldDefinition.Edit) {
        return null;
      }
      label = fieldDefinition.label;
      withHeader = !!label && layout.withHeader;
    }
    const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
      BodyContent,
      {
        data,
        field,
        form,
        onChange,
        hideLabelFromVision,
        markWhenOptional,
        validity,
        withHeader
      }
    );
    const headerContent = /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
      HeaderContent,
      {
        data,
        fields: fields3,
        label,
        layout,
        isOpen: isCollapsible ? !!isOpen2 : true,
        touched,
        validity
      }
    );
    if (withHeader && isCollapsible) {
      return /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(
        collapsible_card_exports.Root,
        {
          className: "dataforms-layouts-card__field",
          open: isOpen2,
          onOpenChange: handleOpenChange,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(collapsible_card_exports.Header, { children: headerContent }),
            /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
              collapsible_card_exports.Content,
              {
                ref: contentRef,
                onBlur: handleBlur,
                children: bodyContent
              }
            )
          ]
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [
      withHeader && /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(card_exports.Header, { children: headerContent }),
      /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent })
    ] });
  }

  // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
  var import_components78 = __toESM(require_components(), 1);
  var import_jsx_runtime218 = __toESM(require_jsx_runtime(), 1);
  function Header4({ title }) {
    return /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(
      Stack,
      {
        direction: "column",
        className: "dataforms-layouts-row__header",
        gap: "lg",
        children: /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(import_components78.__experimentalHeading, { level: 2, size: 13, children: title }) })
      }
    );
  }
  var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(import_jsx_runtime218.Fragment, { children });
  function FormRowField({
    data,
    field,
    onChange,
    hideLabelFromVision,
    markWhenOptional,
    validity
  }) {
    const layout = field.layout;
    if (!!field.children) {
      const form = {
        layout: DEFAULT_LAYOUT,
        fields: field.children
      };
      return /* @__PURE__ */ (0, import_jsx_runtime218.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
        !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(Header4, { title: field.label }),
        /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(
          DataFormLayout,
          {
            data,
            form,
            onChange,
            validity: validity?.children,
            as: EMPTY_WRAPPER,
            children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(
              "div",
              {
                className: "dataforms-layouts-row__field-control",
                style: layout.styles[childField.id],
                children: /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(
                  FieldLayout,
                  {
                    data,
                    field: childField,
                    onChange,
                    hideLabelFromVision,
                    markWhenOptional,
                    validity: childFieldValidity
                  }
                )
              },
              childField.id
            )
          }
        ) })
      ] });
    }
    const RegularLayout = getFormFieldLayout("regular")?.component;
    if (!RegularLayout) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(import_jsx_runtime218.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime218.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(
      RegularLayout,
      {
        data,
        field,
        onChange,
        markWhenOptional,
        validity
      }
    ) }) });
  }

  // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
  var import_element112 = __toESM(require_element(), 1);
  var import_i18n115 = __toESM(require_i18n(), 1);
  var import_jsx_runtime219 = __toESM(require_jsx_runtime(), 1);
  function FormDetailsField({
    data,
    field,
    onChange,
    validity
  }) {
    const { fields: fields3 } = (0, import_element112.useContext)(dataform_context_default);
    const detailsRef = (0, import_element112.useRef)(null);
    const contentRef = (0, import_element112.useRef)(null);
    const [touched, setTouched] = (0, import_element112.useState)(false);
    const [isOpen2, setIsOpen] = (0, import_element112.useState)(false);
    const form = (0, import_element112.useMemo)(
      () => ({
        layout: DEFAULT_LAYOUT,
        fields: field.children ?? []
      }),
      [field]
    );
    (0, import_element112.useEffect)(() => {
      const details = detailsRef.current;
      if (!details) {
        return;
      }
      const handleToggle = () => {
        const nowOpen = details.open;
        if (!nowOpen) {
          setTouched(true);
        }
        setIsOpen(nowOpen);
      };
      details.addEventListener("toggle", handleToggle);
      return () => {
        details.removeEventListener("toggle", handleToggle);
      };
    }, []);
    useReportValidity(contentRef, isOpen2 && touched);
    const handleBlur = (0, import_element112.useCallback)(() => {
      setTouched(true);
    }, []);
    if (!field.children) {
      return null;
    }
    const summaryFieldId = field.layout.summary ?? "";
    const summaryField = summaryFieldId ? fields3.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
    let summaryContent;
    if (summaryField && summaryField.render) {
      summaryContent = /* @__PURE__ */ (0, import_jsx_runtime219.jsx)(summaryField.render, { item: data, field: summaryField });
    } else {
      summaryContent = field.label || (0, import_i18n115.__)("More details");
    }
    return /* @__PURE__ */ (0, import_jsx_runtime219.jsxs)(
      "details",
      {
        ref: detailsRef,
        className: "dataforms-layouts-details__details",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime219.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime219.jsxs)(
            Stack,
            {
              direction: "row",
              align: "center",
              gap: "md",
              className: "dataforms-layouts-details__summary-content",
              children: [
                summaryContent,
                touched && /* @__PURE__ */ (0, import_jsx_runtime219.jsx)(ValidationBadge, { validity })
              ]
            }
          ) }),
          /* @__PURE__ */ (0, import_jsx_runtime219.jsx)(
            "div",
            {
              ref: contentRef,
              className: "dataforms-layouts-details__content",
              onBlur: handleBlur,
              children: /* @__PURE__ */ (0, import_jsx_runtime219.jsx)(
                DataFormLayout,
                {
                  data,
                  form,
                  onChange,
                  validity: validity?.children
                }
              )
            }
          )
        ]
      }
    );
  }

  // packages/dataviews/build-module/components/dataform-layouts/index.mjs
  var import_jsx_runtime220 = __toESM(require_jsx_runtime(), 1);
  var FORM_FIELD_LAYOUTS = [
    {
      type: "regular",
      component: FormRegularField,
      wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
        Stack,
        {
          direction: "column",
          className: "dataforms-layouts__wrapper",
          gap: "lg",
          children
        }
      )
    },
    {
      type: "panel",
      component: FormPanelField,
      wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
        Stack,
        {
          direction: "column",
          className: "dataforms-layouts__wrapper",
          gap: "md",
          children
        }
      )
    },
    {
      type: "card",
      component: FormCardField,
      wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
        Stack,
        {
          direction: "column",
          className: "dataforms-layouts__wrapper",
          gap: "xl",
          children
        }
      )
    },
    {
      type: "row",
      component: FormRowField,
      wrapper: ({
        children,
        layout
      }) => /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
        Stack,
        {
          direction: "column",
          className: "dataforms-layouts__wrapper",
          gap: "lg",
          children: /* @__PURE__ */ (0, import_jsx_runtime220.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
            Stack,
            {
              direction: "row",
              gap: "lg",
              align: layout.alignment,
              children
            }
          ) })
        }
      )
    },
    {
      type: "details",
      component: FormDetailsField
    }
  ];
  function getFormFieldLayout(type) {
    return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
  }

  // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
  var import_jsx_runtime221 = __toESM(require_jsx_runtime(), 1);
  var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
  function DataFormLayout({
    data,
    form,
    onChange,
    validity,
    children,
    as
  }) {
    const { fields: fieldDefinitions } = (0, import_element113.useContext)(dataform_context_default);
    const markWhenOptional = (0, import_element113.useMemo)(() => {
      const requiredCount = fieldDefinitions.filter(
        (f3) => !!f3.isValid?.required
      ).length;
      const optionalCount = fieldDefinitions.length - requiredCount;
      return requiredCount > optionalCount;
    }, [fieldDefinitions]);
    function getFieldDefinition2(field) {
      return fieldDefinitions.find(
        (fieldDefinition) => fieldDefinition.id === field.id
      );
    }
    const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
    return /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
      const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
      if (!FieldLayout) {
        return null;
      }
      const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
      if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
        return null;
      }
      if (children) {
        return children(
          FieldLayout,
          formField,
          validity?.[formField.id],
          markWhenOptional
        );
      }
      return /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(
        FieldLayout,
        {
          data,
          field: formField,
          onChange,
          markWhenOptional,
          validity: validity?.[formField.id]
        },
        formField.id
      );
    }) });
  }

  // packages/dataviews/build-module/dataform/index.mjs
  var import_jsx_runtime222 = __toESM(require_jsx_runtime(), 1);
  function DataForm({
    data,
    form,
    fields: fields3,
    onChange,
    validity
  }) {
    const normalizedForm = (0, import_element114.useMemo)(() => normalize_form_default(form), [form]);
    const normalizedFields = (0, import_element114.useMemo)(
      () => normalizeFields(fields3),
      [fields3]
    );
    if (!form.fields) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(
      DataFormLayout,
      {
        data,
        form: normalizedForm,
        onChange,
        validity
      }
    ) });
  }

  // packages/media-editor/build-module/components/media-form/index.mjs
  var import_components79 = __toESM(require_components(), 1);
  var import_jsx_runtime223 = __toESM(require_jsx_runtime(), 1);
  function MediaForm({
    form: formOverrides,
    header
  }) {
    const { media, fields: fields3, onChange } = useMediaEditorContext();
    if (!media || !onChange) {
      return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)("div", { className: "media-editor-form media-editor-form--loading", children: /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(import_components79.Spinner, {}) });
    }
    const defaultForm = {
      layout: {
        type: "panel"
      },
      fields: fields3.map((field) => {
        if (["title", "alt_text", "caption", "description"].includes(
          field.id
        )) {
          return {
            id: field.id,
            layout: {
              type: "regular",
              labelPosition: "top"
            }
          };
        }
        return field.id;
      })
    };
    const form = formOverrides || defaultForm;
    return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)("div", { className: "media-editor-form", children: /* @__PURE__ */ (0, import_jsx_runtime223.jsxs)(import_components79.__experimentalVStack, { spacing: 4, children: [
      header,
      /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(
        DataForm,
        {
          data: media,
          fields: fields3,
          form,
          onChange
        }
      )
    ] }) });
  }

  // packages/media-editor/build-module/lock-unlock.mjs
  var import_private_apis4 = __toESM(require_private_apis(), 1);
  var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
    "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
    "@wordpress/media-editor"
  );

  // packages/media-editor/build-module/store/index.mjs
  var import_data33 = __toESM(require_data(), 1);

  // packages/media-editor/build-module/store/reducer.mjs
  var DEFAULT_STATE = {
    isOpen: false,
    id: null,
    onUpdate: null
  };
  function reducer(state = DEFAULT_STATE, action) {
    switch (action.type) {
      case "OPEN_MEDIA_EDITOR_MODAL": {
        const { id, onUpdate } = action;
        return {
          isOpen: true,
          id,
          onUpdate
        };
      }
      case "CLOSE_MEDIA_EDITOR_MODAL":
        return DEFAULT_STATE;
    }
    return state;
  }

  // packages/media-editor/build-module/store/actions.mjs
  var actions_exports2 = {};
  __export(actions_exports2, {
    closeMediaEditorModal: () => closeMediaEditorModal,
    openMediaEditorModal: () => openMediaEditorModal
  });
  function openMediaEditorModal({
    id,
    onUpdate
  }) {
    return {
      type: "OPEN_MEDIA_EDITOR_MODAL",
      id,
      onUpdate: onUpdate ?? null
    };
  }
  function closeMediaEditorModal() {
    return { type: "CLOSE_MEDIA_EDITOR_MODAL" };
  }

  // packages/media-editor/build-module/store/selectors.mjs
  var selectors_exports2 = {};
  __export(selectors_exports2, {
    getId: () => getId,
    getOnUpdate: () => getOnUpdate,
    isOpen: () => isOpen
  });
  function isOpen(state) {
    return state.isOpen;
  }
  function getId(state) {
    return state.id;
  }
  function getOnUpdate(state) {
    return state.onUpdate;
  }

  // packages/media-editor/build-module/store/constants.mjs
  var STORE_NAME2 = "core/media-editor";

  // packages/media-editor/build-module/store/index.mjs
  var store = (0, import_data33.createReduxStore)(STORE_NAME2, {
    reducer,
    actions: actions_exports2,
    selectors: selectors_exports2
  });
  (0, import_data33.register)(store);

  // packages/media-editor/build-module/components/media-editor-modal/index.mjs
  var import_api_fetch3 = __toESM(require_api_fetch(), 1);
  var import_components89 = __toESM(require_components(), 1);
  var import_data39 = __toESM(require_data(), 1);
  var import_core_data25 = __toESM(require_core_data(), 1);
  var import_element127 = __toESM(require_element(), 1);
  var import_i18n123 = __toESM(require_i18n(), 1);
  var import_notices14 = __toESM(require_notices(), 1);

  // packages/interface/build-module/index.mjs
  var build_module_exports = {};
  __export(build_module_exports, {
    ActionItem: () => action_item_default,
    ComplementaryArea: () => complementary_area_default,
    ComplementaryAreaMoreMenuItem: () => ComplementaryAreaMoreMenuItem,
    FullscreenMode: () => fullscreen_mode_default,
    InterfaceSkeleton: () => interface_skeleton_default,
    PinnedItems: () => pinned_items_default,
    store: () => store2
  });

  // packages/interface/build-module/components/complementary-area/index.mjs
  var import_components84 = __toESM(require_components(), 1);
  var import_data38 = __toESM(require_data(), 1);
  var import_i18n116 = __toESM(require_i18n(), 1);
  var import_element116 = __toESM(require_element(), 1);
  var import_viewport = __toESM(require_viewport(), 1);
  var import_preferences5 = __toESM(require_preferences(), 1);
  var import_compose21 = __toESM(require_compose(), 1);
  var import_plugins2 = __toESM(require_plugins(), 1);

  // packages/interface/build-module/components/complementary-area-toggle/index.mjs
  var import_components80 = __toESM(require_components(), 1);
  var import_data37 = __toESM(require_data(), 1);
  var import_plugins = __toESM(require_plugins(), 1);

  // packages/interface/build-module/store/index.mjs
  var import_data36 = __toESM(require_data(), 1);

  // packages/interface/build-module/store/actions.mjs
  var actions_exports3 = {};
  __export(actions_exports3, {
    closeModal: () => closeModal,
    disableComplementaryArea: () => disableComplementaryArea,
    enableComplementaryArea: () => enableComplementaryArea,
    openModal: () => openModal,
    pinItem: () => pinItem,
    setDefaultComplementaryArea: () => setDefaultComplementaryArea,
    setFeatureDefaults: () => setFeatureDefaults,
    setFeatureValue: () => setFeatureValue,
    toggleFeature: () => toggleFeature,
    unpinItem: () => unpinItem
  });
  var import_deprecated4 = __toESM(require_deprecated(), 1);
  var import_preferences3 = __toESM(require_preferences(), 1);

  // packages/interface/build-module/store/deprecated.mjs
  var import_deprecated3 = __toESM(require_deprecated(), 1);
  function normalizeComplementaryAreaScope(scope) {
    if (["core/edit-post", "core/edit-site"].includes(scope)) {
      (0, import_deprecated3.default)(`${scope} interface scope`, {
        alternative: "core interface scope",
        hint: "core/edit-post and core/edit-site are merging.",
        version: "6.6"
      });
      return "core";
    }
    return scope;
  }
  function normalizeComplementaryAreaName(scope, name2) {
    if (scope === "core" && name2 === "edit-site/template") {
      (0, import_deprecated3.default)(`edit-site/template sidebar`, {
        alternative: "edit-post/document",
        version: "6.6"
      });
      return "edit-post/document";
    }
    if (scope === "core" && name2 === "edit-site/block-inspector") {
      (0, import_deprecated3.default)(`edit-site/block-inspector sidebar`, {
        alternative: "edit-post/block",
        version: "6.6"
      });
      return "edit-post/block";
    }
    return name2;
  }

  // packages/interface/build-module/store/actions.mjs
  var setDefaultComplementaryArea = (scope, area) => {
    scope = normalizeComplementaryAreaScope(scope);
    area = normalizeComplementaryAreaName(scope, area);
    return {
      type: "SET_DEFAULT_COMPLEMENTARY_AREA",
      scope,
      area
    };
  };
  var enableComplementaryArea = (scope, area) => ({ registry, dispatch: dispatch7 }) => {
    if (!area) {
      return;
    }
    scope = normalizeComplementaryAreaScope(scope);
    area = normalizeComplementaryAreaName(scope, area);
    const isComplementaryAreaVisible = registry.select(import_preferences3.store).get(scope, "isComplementaryAreaVisible");
    if (!isComplementaryAreaVisible) {
      registry.dispatch(import_preferences3.store).set(scope, "isComplementaryAreaVisible", true);
    }
    dispatch7({
      type: "ENABLE_COMPLEMENTARY_AREA",
      scope,
      area
    });
  };
  var disableComplementaryArea = (scope) => ({ registry }) => {
    scope = normalizeComplementaryAreaScope(scope);
    const isComplementaryAreaVisible = registry.select(import_preferences3.store).get(scope, "isComplementaryAreaVisible");
    if (isComplementaryAreaVisible) {
      registry.dispatch(import_preferences3.store).set(scope, "isComplementaryAreaVisible", false);
    }
  };
  var pinItem = (scope, item) => ({ registry }) => {
    if (!item) {
      return;
    }
    scope = normalizeComplementaryAreaScope(scope);
    item = normalizeComplementaryAreaName(scope, item);
    const pinnedItems = registry.select(import_preferences3.store).get(scope, "pinnedItems");
    if (pinnedItems?.[item] === true) {
      return;
    }
    registry.dispatch(import_preferences3.store).set(scope, "pinnedItems", {
      ...pinnedItems,
      [item]: true
    });
  };
  var unpinItem = (scope, item) => ({ registry }) => {
    if (!item) {
      return;
    }
    scope = normalizeComplementaryAreaScope(scope);
    item = normalizeComplementaryAreaName(scope, item);
    const pinnedItems = registry.select(import_preferences3.store).get(scope, "pinnedItems");
    registry.dispatch(import_preferences3.store).set(scope, "pinnedItems", {
      ...pinnedItems,
      [item]: false
    });
  };
  function toggleFeature(scope, featureName) {
    return function({ registry }) {
      (0, import_deprecated4.default)(`dispatch( 'core/interface' ).toggleFeature`, {
        since: "6.0",
        alternative: `dispatch( 'core/preferences' ).toggle`
      });
      registry.dispatch(import_preferences3.store).toggle(scope, featureName);
    };
  }
  function setFeatureValue(scope, featureName, value) {
    return function({ registry }) {
      (0, import_deprecated4.default)(`dispatch( 'core/interface' ).setFeatureValue`, {
        since: "6.0",
        alternative: `dispatch( 'core/preferences' ).set`
      });
      registry.dispatch(import_preferences3.store).set(scope, featureName, !!value);
    };
  }
  function setFeatureDefaults(scope, defaults2) {
    return function({ registry }) {
      (0, import_deprecated4.default)(`dispatch( 'core/interface' ).setFeatureDefaults`, {
        since: "6.0",
        alternative: `dispatch( 'core/preferences' ).setDefaults`
      });
      registry.dispatch(import_preferences3.store).setDefaults(scope, defaults2);
    };
  }
  function openModal(name2) {
    return {
      type: "OPEN_MODAL",
      name: name2
    };
  }
  function closeModal() {
    return {
      type: "CLOSE_MODAL"
    };
  }

  // packages/interface/build-module/store/selectors.mjs
  var selectors_exports3 = {};
  __export(selectors_exports3, {
    getActiveComplementaryArea: () => getActiveComplementaryArea,
    isComplementaryAreaLoading: () => isComplementaryAreaLoading,
    isFeatureActive: () => isFeatureActive,
    isItemPinned: () => isItemPinned,
    isModalActive: () => isModalActive
  });
  var import_data34 = __toESM(require_data(), 1);
  var import_deprecated6 = __toESM(require_deprecated(), 1);
  var import_preferences4 = __toESM(require_preferences(), 1);
  var getActiveComplementaryArea = (0, import_data34.createRegistrySelector)(
    (select7) => (state, scope) => {
      scope = normalizeComplementaryAreaScope(scope);
      const isComplementaryAreaVisible = select7(import_preferences4.store).get(
        scope,
        "isComplementaryAreaVisible"
      );
      if (isComplementaryAreaVisible === void 0) {
        return void 0;
      }
      if (isComplementaryAreaVisible === false) {
        return null;
      }
      return state?.complementaryAreas?.[scope];
    }
  );
  var isComplementaryAreaLoading = (0, import_data34.createRegistrySelector)(
    (select7) => (state, scope) => {
      scope = normalizeComplementaryAreaScope(scope);
      const isVisible2 = select7(import_preferences4.store).get(
        scope,
        "isComplementaryAreaVisible"
      );
      const identifier = state?.complementaryAreas?.[scope];
      return isVisible2 && identifier === void 0;
    }
  );
  var isItemPinned = (0, import_data34.createRegistrySelector)(
    (select7) => (state, scope, item) => {
      scope = normalizeComplementaryAreaScope(scope);
      item = normalizeComplementaryAreaName(scope, item);
      const pinnedItems = select7(import_preferences4.store).get(
        scope,
        "pinnedItems"
      );
      return pinnedItems?.[item] ?? true;
    }
  );
  var isFeatureActive = (0, import_data34.createRegistrySelector)(
    (select7) => (state, scope, featureName) => {
      (0, import_deprecated6.default)(
        `select( 'core/interface' ).isFeatureActive( scope, featureName )`,
        {
          since: "6.0",
          alternative: `select( 'core/preferences' ).get( scope, featureName )`
        }
      );
      return !!select7(import_preferences4.store).get(scope, featureName);
    }
  );
  function isModalActive(state, modalName3) {
    return state.activeModal === modalName3;
  }

  // packages/interface/build-module/store/reducer.mjs
  var import_data35 = __toESM(require_data(), 1);
  function complementaryAreas(state = {}, action) {
    switch (action.type) {
      case "SET_DEFAULT_COMPLEMENTARY_AREA": {
        const { scope, area } = action;
        if (state[scope]) {
          return state;
        }
        return {
          ...state,
          [scope]: area
        };
      }
      case "ENABLE_COMPLEMENTARY_AREA": {
        const { scope, area } = action;
        return {
          ...state,
          [scope]: area
        };
      }
    }
    return state;
  }
  function activeModal(state = null, action) {
    switch (action.type) {
      case "OPEN_MODAL":
        return action.name;
      case "CLOSE_MODAL":
        return null;
    }
    return state;
  }
  var reducer_default3 = (0, import_data35.combineReducers)({
    complementaryAreas,
    activeModal
  });

  // packages/interface/build-module/store/constants.mjs
  var STORE_NAME3 = "core/interface";

  // packages/interface/build-module/store/index.mjs
  var store2 = (0, import_data36.createReduxStore)(STORE_NAME3, {
    reducer: reducer_default3,
    actions: actions_exports3,
    selectors: selectors_exports3
  });
  (0, import_data36.register)(store2);

  // packages/interface/build-module/components/complementary-area-toggle/index.mjs
  var import_jsx_runtime224 = __toESM(require_jsx_runtime(), 1);
  function roleSupportsCheckedState(role) {
    return [
      "checkbox",
      "option",
      "radio",
      "switch",
      "menuitemcheckbox",
      "menuitemradio",
      "treeitem"
    ].includes(role);
  }
  function ComplementaryAreaToggle({
    as = import_components80.Button,
    scope,
    identifier: identifierProp,
    icon: iconProp,
    selectedIcon,
    name: name2,
    shortcut,
    ...props
  }) {
    const ComponentToUse = as;
    const context = (0, import_plugins.usePluginContext)();
    const icon = iconProp || context.icon;
    const identifier = identifierProp || `${context.name}/${name2}`;
    const isSelected2 = (0, import_data37.useSelect)(
      (select7) => select7(store2).getActiveComplementaryArea(scope) === identifier,
      [identifier, scope]
    );
    const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data37.useDispatch)(store2);
    return /* @__PURE__ */ (0, import_jsx_runtime224.jsx)(
      ComponentToUse,
      {
        icon: selectedIcon && isSelected2 ? selectedIcon : icon,
        "aria-controls": identifier.replace("/", ":"),
        "aria-checked": roleSupportsCheckedState(props.role) ? isSelected2 : void 0,
        onClick: () => {
          if (isSelected2) {
            disableComplementaryArea2(scope);
          } else {
            enableComplementaryArea2(scope, identifier);
          }
        },
        shortcut,
        ...props
      }
    );
  }

  // packages/interface/build-module/components/complementary-area-header/index.mjs
  var import_jsx_runtime225 = __toESM(require_jsx_runtime(), 1);
  var ComplementaryAreaHeader = ({
    children,
    className,
    toggleButtonProps
  }) => {
    const toggleButton = /* @__PURE__ */ (0, import_jsx_runtime225.jsx)(ComplementaryAreaToggle, { icon: close_small_default, ...toggleButtonProps });
    return /* @__PURE__ */ (0, import_jsx_runtime225.jsxs)(
      "div",
      {
        className: clsx_default(
          "components-panel__header",
          "interface-complementary-area-header",
          className
        ),
        tabIndex: -1,
        children: [
          children,
          toggleButton
        ]
      }
    );
  };
  var complementary_area_header_default = ComplementaryAreaHeader;

  // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs
  var import_components82 = __toESM(require_components(), 1);

  // packages/interface/build-module/components/action-item/index.mjs
  var import_components81 = __toESM(require_components(), 1);
  var import_element115 = __toESM(require_element(), 1);
  var import_jsx_runtime226 = __toESM(require_jsx_runtime(), 1);
  var noop4 = () => {
  };
  function ActionItemSlot({
    name: name2,
    as: Component6 = import_components81.MenuGroup,
    fillProps = {},
    bubblesVirtually,
    ...props
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(
      import_components81.Slot,
      {
        name: name2,
        bubblesVirtually,
        fillProps,
        children: (fills) => {
          if (!import_element115.Children.toArray(fills).length) {
            return null;
          }
          const initializedByPlugins = [];
          import_element115.Children.forEach(
            fills,
            ({
              props: { __unstableExplicitMenuItem, __unstableTarget }
            }) => {
              if (__unstableTarget && __unstableExplicitMenuItem) {
                initializedByPlugins.push(__unstableTarget);
              }
            }
          );
          const children = import_element115.Children.map(fills, (child) => {
            if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(
              child.props.__unstableTarget
            )) {
              return null;
            }
            return child;
          });
          return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(Component6, { ...props, children });
        }
      }
    );
  }
  function ActionItem({ name: name2, as: Component6 = import_components81.Button, onClick, ...props }) {
    return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(import_components81.Fill, { name: name2, children: ({ onClick: fpOnClick }) => {
      return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(
        Component6,
        {
          onClick: onClick || fpOnClick ? (...args) => {
            (onClick || noop4)(...args);
            (fpOnClick || noop4)(...args);
          } : void 0,
          ...props
        }
      );
    } });
  }
  ActionItem.Slot = ActionItemSlot;
  var action_item_default = ActionItem;

  // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs
  var import_jsx_runtime227 = __toESM(require_jsx_runtime(), 1);
  var PluginsMenuItem = ({
    // Menu item is marked with unstable prop for backward compatibility.
    // They are removed so they don't leak to DOM elements.
    // @see https://github.com/WordPress/gutenberg/issues/14457
    __unstableExplicitMenuItem,
    __unstableTarget,
    ...restProps
  }) => /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(import_components82.MenuItem, { ...restProps });
  function ComplementaryAreaMoreMenuItem({
    scope,
    target,
    __unstableExplicitMenuItem,
    ...props
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
      ComplementaryAreaToggle,
      {
        as: (toggleProps) => {
          return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
            action_item_default,
            {
              __unstableExplicitMenuItem,
              __unstableTarget: `${scope}/${target}`,
              as: PluginsMenuItem,
              name: `${scope}/plugin-more-menu`,
              ...toggleProps
            }
          );
        },
        role: "menuitemcheckbox",
        selectedIcon: check_default,
        name: target,
        scope,
        ...props
      }
    );
  }

  // packages/interface/build-module/components/pinned-items/index.mjs
  var import_components83 = __toESM(require_components(), 1);
  var import_jsx_runtime228 = __toESM(require_jsx_runtime(), 1);
  function PinnedItems({ scope, ...props }) {
    return /* @__PURE__ */ (0, import_jsx_runtime228.jsx)(import_components83.Fill, { name: `PinnedItems/${scope}`, ...props });
  }
  function PinnedItemsSlot({ scope, className, ...props }) {
    return /* @__PURE__ */ (0, import_jsx_runtime228.jsx)(import_components83.Slot, { name: `PinnedItems/${scope}`, ...props, children: (fills) => fills?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime228.jsx)(
      "div",
      {
        className: clsx_default(
          className,
          "interface-pinned-items"
        ),
        children: fills
      }
    ) });
  }
  PinnedItems.Slot = PinnedItemsSlot;
  var pinned_items_default = PinnedItems;

  // packages/interface/build-module/components/complementary-area/index.mjs
  var import_jsx_runtime229 = __toESM(require_jsx_runtime(), 1);
  var ANIMATION_DURATION = 0.3;
  function ComplementaryAreaSlot({ scope, ...props }) {
    return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(import_components84.Slot, { name: `ComplementaryArea/${scope}`, ...props });
  }
  var SIDEBAR_WIDTH = 280;
  var variants = {
    open: { width: SIDEBAR_WIDTH },
    closed: { width: 0 },
    mobileOpen: { width: "100vw" }
  };
  function ComplementaryAreaFill({
    activeArea,
    isActive,
    scope,
    children,
    className,
    id
  }) {
    const disableMotion = (0, import_compose21.useReducedMotion)();
    const isMobileViewport = (0, import_compose21.useViewportMatch)("medium", "<");
    const previousActiveArea = (0, import_compose21.usePrevious)(activeArea);
    const previousIsActive = (0, import_compose21.usePrevious)(isActive);
    const [, setState] = (0, import_element116.useState)({});
    (0, import_element116.useEffect)(() => {
      setState({});
    }, [isActive]);
    const transition = {
      type: "tween",
      duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION,
      ease: [0.6, 0, 0.4, 1]
    };
    return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(import_components84.Fill, { name: `ComplementaryArea/${scope}`, children: /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(import_components84.__unstableAnimatePresence, { initial: false, children: (previousIsActive || isActive) && /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
      import_components84.__unstableMotion.div,
      {
        variants,
        initial: "closed",
        animate: isMobileViewport ? "mobileOpen" : "open",
        exit: "closed",
        transition,
        className: "interface-complementary-area__fill",
        children: /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
          "div",
          {
            id,
            className,
            style: {
              width: isMobileViewport ? "100vw" : SIDEBAR_WIDTH
            },
            children
          }
        )
      }
    ) }) });
  }
  function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
    const previousIsSmallRef = (0, import_element116.useRef)(false);
    const shouldOpenWhenNotSmallRef = (0, import_element116.useRef)(false);
    const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data38.useDispatch)(store2);
    (0, import_element116.useEffect)(() => {
      if (isActive && isSmall && !previousIsSmallRef.current) {
        disableComplementaryArea2(scope);
        shouldOpenWhenNotSmallRef.current = true;
      } else if (
        // If there is a flag indicating the complementary area should be
        // enabled when we go from small to big window size and we are going
        // from a small to big window size.
        shouldOpenWhenNotSmallRef.current && !isSmall && previousIsSmallRef.current
      ) {
        shouldOpenWhenNotSmallRef.current = false;
        enableComplementaryArea2(scope, identifier);
      } else if (
        // If the flag is indicating the current complementary should be
        // reopened but another complementary area becomes active, remove
        // the flag.
        shouldOpenWhenNotSmallRef.current && activeArea && activeArea !== identifier
      ) {
        shouldOpenWhenNotSmallRef.current = false;
      }
      if (isSmall !== previousIsSmallRef.current) {
        previousIsSmallRef.current = isSmall;
      }
    }, [
      isActive,
      isSmall,
      scope,
      identifier,
      activeArea,
      disableComplementaryArea2,
      enableComplementaryArea2
    ]);
  }
  function ComplementaryArea({
    children,
    className,
    closeLabel = (0, import_i18n116.__)("Close plugin"),
    identifier: identifierProp,
    header,
    headerClassName,
    icon: iconProp,
    isPinnable = true,
    panelClassName,
    scope,
    name: name2,
    title,
    toggleShortcut,
    isActiveByDefault
  }) {
    const context = (0, import_plugins2.usePluginContext)();
    const icon = iconProp || context.icon;
    const identifier = identifierProp || `${context.name}/${name2}`;
    const [isReady2, setIsReady2] = (0, import_element116.useState)(false);
    const {
      isLoading,
      isActive,
      isPinned,
      activeArea,
      isSmall,
      isLarge,
      showIconLabels
    } = (0, import_data38.useSelect)(
      (select7) => {
        const {
          getActiveComplementaryArea: getActiveComplementaryArea2,
          isComplementaryAreaLoading: isComplementaryAreaLoading2,
          isItemPinned: isItemPinned2
        } = select7(store2);
        const { get } = select7(import_preferences5.store);
        const _activeArea = getActiveComplementaryArea2(scope);
        return {
          isLoading: isComplementaryAreaLoading2(scope),
          isActive: _activeArea === identifier,
          isPinned: isItemPinned2(scope, identifier),
          activeArea: _activeArea,
          isSmall: select7(import_viewport.store).isViewportMatch("< medium"),
          isLarge: select7(import_viewport.store).isViewportMatch("large"),
          showIconLabels: get("core", "showIconLabels")
        };
      },
      [identifier, scope]
    );
    const isMobileViewport = (0, import_compose21.useViewportMatch)("medium", "<");
    useAdjustComplementaryListener(
      scope,
      identifier,
      activeArea,
      isActive,
      isSmall
    );
    const {
      enableComplementaryArea: enableComplementaryArea2,
      disableComplementaryArea: disableComplementaryArea2,
      pinItem: pinItem2,
      unpinItem: unpinItem2
    } = (0, import_data38.useDispatch)(store2);
    (0, import_element116.useEffect)(() => {
      if (isActiveByDefault && activeArea === void 0 && !isSmall) {
        enableComplementaryArea2(scope, identifier);
      } else if (activeArea === void 0 && isSmall) {
        disableComplementaryArea2(scope, identifier);
      }
      setIsReady2(true);
    }, [
      activeArea,
      isActiveByDefault,
      scope,
      identifier,
      isSmall,
      enableComplementaryArea2,
      disableComplementaryArea2
    ]);
    if (!isReady2) {
      return;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime229.jsxs)(import_jsx_runtime229.Fragment, { children: [
      isPinnable && /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(pinned_items_default, { scope, children: isPinned && /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
        ComplementaryAreaToggle,
        {
          scope,
          identifier,
          isPressed: isActive && (!showIconLabels || isLarge),
          "aria-expanded": isActive,
          "aria-disabled": isLoading,
          label: title,
          icon: showIconLabels ? check_default : icon,
          showTooltip: !showIconLabels,
          variant: showIconLabels ? "tertiary" : void 0,
          size: "compact",
          shortcut: toggleShortcut
        }
      ) }),
      name2 && isPinnable && /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
        ComplementaryAreaMoreMenuItem,
        {
          target: name2,
          scope,
          icon,
          identifier,
          children: title
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime229.jsxs)(
        ComplementaryAreaFill,
        {
          activeArea,
          isActive,
          className: clsx_default("interface-complementary-area", className),
          scope,
          id: identifier.replace("/", ":"),
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
              complementary_area_header_default,
              {
                className: headerClassName,
                closeLabel,
                onClose: () => disableComplementaryArea2(scope),
                toggleButtonProps: {
                  label: closeLabel,
                  size: "compact",
                  shortcut: toggleShortcut,
                  scope,
                  identifier
                },
                children: header || /* @__PURE__ */ (0, import_jsx_runtime229.jsxs)(import_jsx_runtime229.Fragment, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime229.jsx)("h2", { className: "interface-complementary-area-header__title", children: title }),
                  isPinnable && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
                    import_components84.Button,
                    {
                      className: "interface-complementary-area__pin-unpin-item",
                      icon: isPinned ? star_filled_default : star_empty_default,
                      label: isPinned ? (0, import_i18n116.__)("Unpin from toolbar") : (0, import_i18n116.__)("Pin to toolbar"),
                      onClick: () => (isPinned ? unpinItem2 : pinItem2)(
                        scope,
                        identifier
                      ),
                      isPressed: isPinned,
                      "aria-expanded": isPinned,
                      size: "compact"
                    }
                  )
                ] })
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(import_components84.Panel, { className: panelClassName, children })
          ]
        }
      )
    ] });
  }
  ComplementaryArea.Slot = ComplementaryAreaSlot;
  var complementary_area_default = ComplementaryArea;

  // packages/interface/build-module/components/fullscreen-mode/index.mjs
  var import_element117 = __toESM(require_element(), 1);
  var FullscreenMode = ({ isActive }) => {
    (0, import_element117.useEffect)(() => {
      let isSticky = false;
      if (document.body.classList.contains("sticky-menu")) {
        isSticky = true;
        document.body.classList.remove("sticky-menu");
      }
      return () => {
        if (isSticky) {
          document.body.classList.add("sticky-menu");
        }
      };
    }, []);
    (0, import_element117.useEffect)(() => {
      if (isActive) {
        document.body.classList.add("is-fullscreen-mode");
      } else {
        document.body.classList.remove("is-fullscreen-mode");
      }
      return () => {
        if (isActive) {
          document.body.classList.remove("is-fullscreen-mode");
        }
      };
    }, [isActive]);
    return null;
  };
  var fullscreen_mode_default = FullscreenMode;

  // packages/admin-ui/build-module/navigable-region/index.mjs
  var import_element118 = __toESM(require_element(), 1);
  var import_jsx_runtime230 = __toESM(require_jsx_runtime(), 1);
  var NavigableRegion = (0, import_element118.forwardRef)(
    ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
      return /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(
        Tag,
        {
          ref,
          className: clsx_default("admin-ui-navigable-region", className),
          "aria-label": ariaLabel,
          role: "region",
          tabIndex: "-1",
          ...props,
          children
        }
      );
    }
  );
  NavigableRegion.displayName = "NavigableRegion";
  var navigable_region_default = NavigableRegion;

  // packages/interface/build-module/components/interface-skeleton/index.mjs
  var import_element119 = __toESM(require_element(), 1);
  var import_components85 = __toESM(require_components(), 1);
  var import_i18n117 = __toESM(require_i18n(), 1);
  var import_compose22 = __toESM(require_compose(), 1);
  var import_jsx_runtime231 = __toESM(require_jsx_runtime(), 1);
  var ANIMATION_DURATION2 = 0.25;
  var commonTransition = {
    type: "tween",
    duration: ANIMATION_DURATION2,
    ease: [0.6, 0, 0.4, 1]
  };
  function useHTMLClass(className) {
    (0, import_element119.useEffect)(() => {
      const element = document && document.querySelector(`html:not(.${className})`);
      if (!element) {
        return;
      }
      element.classList.toggle(className);
      return () => {
        element.classList.toggle(className);
      };
    }, [className]);
  }
  var headerVariants = {
    hidden: { opacity: 1, marginTop: -60 },
    visible: { opacity: 1, marginTop: 0 },
    distractionFreeHover: {
      opacity: 1,
      marginTop: 0,
      transition: {
        ...commonTransition,
        delay: 0.2,
        delayChildren: 0.2
      }
    },
    distractionFreeHidden: {
      opacity: 0,
      marginTop: -60
    },
    distractionFreeDisabled: {
      opacity: 0,
      marginTop: 0,
      transition: {
        ...commonTransition,
        delay: 0.8,
        delayChildren: 0.8
      }
    }
  };
  function InterfaceSkeleton({
    isDistractionFree,
    footer,
    header,
    editorNotices,
    sidebar,
    secondarySidebar,
    content,
    actions: actions2,
    labels,
    className
  }, ref) {
    const [secondarySidebarResizeListener, secondarySidebarSize] = (0, import_compose22.useResizeObserver)();
    const isMobileViewport = (0, import_compose22.useViewportMatch)("medium", "<");
    const disableMotion = (0, import_compose22.useReducedMotion)();
    const defaultTransition = {
      type: "tween",
      duration: disableMotion ? 0 : ANIMATION_DURATION2,
      ease: [0.6, 0, 0.4, 1]
    };
    useHTMLClass("interface-interface-skeleton__html-container");
    const defaultLabels = {
      /* translators: accessibility text for the top bar landmark region. */
      header: (0, import_i18n117._x)("Header", "header landmark area"),
      /* translators: accessibility text for the content landmark region. */
      body: (0, import_i18n117.__)("Content"),
      /* translators: accessibility text for the secondary sidebar landmark region. */
      secondarySidebar: (0, import_i18n117.__)("Block Library"),
      /* translators: accessibility text for the settings landmark region. */
      sidebar: (0, import_i18n117._x)("Settings", "settings landmark area"),
      /* translators: accessibility text for the publish landmark region. */
      actions: (0, import_i18n117.__)("Publish"),
      /* translators: accessibility text for the footer landmark region. */
      footer: (0, import_i18n117.__)("Footer")
    };
    const mergedLabels = { ...defaultLabels, ...labels };
    return /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)(
      "div",
      {
        ref,
        className: clsx_default(
          className,
          "interface-interface-skeleton",
          !!footer && "has-footer"
        ),
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)("div", { className: "interface-interface-skeleton__editor", children: [
            /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(import_components85.__unstableAnimatePresence, { initial: false, children: !!header && /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
              navigable_region_default,
              {
                as: import_components85.__unstableMotion.div,
                className: "interface-interface-skeleton__header",
                ariaLabel: mergedLabels.header,
                initial: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden",
                whileHover: isDistractionFree && !isMobileViewport ? "distractionFreeHover" : "visible",
                animate: isDistractionFree && !isMobileViewport ? "distractionFreeDisabled" : "visible",
                exit: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden",
                variants: headerVariants,
                transition: defaultTransition,
                children: header
              }
            ) }),
            isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime231.jsx)("div", { className: "interface-interface-skeleton__header", children: editorNotices }),
            /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)("div", { className: "interface-interface-skeleton__body", children: [
              /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(import_components85.__unstableAnimatePresence, { initial: false, children: !!secondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
                navigable_region_default,
                {
                  className: "interface-interface-skeleton__secondary-sidebar",
                  ariaLabel: mergedLabels.secondarySidebar,
                  as: import_components85.__unstableMotion.div,
                  initial: "closed",
                  animate: "open",
                  exit: "closed",
                  variants: {
                    open: { width: secondarySidebarSize.width },
                    closed: { width: 0 }
                  },
                  transition: defaultTransition,
                  children: /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)(
                    import_components85.__unstableMotion.div,
                    {
                      style: {
                        position: "absolute",
                        width: isMobileViewport ? "100vw" : "fit-content",
                        height: "100%",
                        left: 0
                      },
                      variants: {
                        open: { x: 0 },
                        closed: { x: "-100%" }
                      },
                      transition: defaultTransition,
                      children: [
                        secondarySidebarResizeListener,
                        secondarySidebar
                      ]
                    }
                  )
                }
              ) }),
              /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
                navigable_region_default,
                {
                  className: "interface-interface-skeleton__content",
                  ariaLabel: mergedLabels.body,
                  children: content
                }
              ),
              !!sidebar && /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
                navigable_region_default,
                {
                  className: "interface-interface-skeleton__sidebar",
                  ariaLabel: mergedLabels.sidebar,
                  children: sidebar
                }
              ),
              !!actions2 && /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
                navigable_region_default,
                {
                  className: "interface-interface-skeleton__actions",
                  ariaLabel: mergedLabels.actions,
                  children: actions2
                }
              )
            ] })
          ] }),
          !!footer && /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
            navigable_region_default,
            {
              className: "interface-interface-skeleton__footer",
              ariaLabel: mergedLabels.footer,
              children: footer
            }
          )
        ]
      }
    );
  }
  var interface_skeleton_default = (0, import_element119.forwardRef)(InterfaceSkeleton);

  // packages/media-editor/build-module/image-editor/react/hooks/use-cropper-state.mjs
  var import_element120 = __toESM(require_element(), 1);

  // packages/media-editor/build-module/image-editor/core/constants.mjs
  var import_i18n118 = __toESM(require_i18n(), 1);
  var MIN_ZOOM = 1;
  var MAX_ZOOM = 10;
  var MAX_ROTATION_OFFSET = 45;
  var DEFAULT_CROP_RECT = {
    x: 0,
    y: 0,
    width: 1,
    height: 1
  };
  var DEFAULT_FLIP = {
    horizontal: false,
    vertical: false
  };
  var DEFAULT_PAN = {
    x: 0,
    y: 0
  };
  var DEFAULT_STATE2 = {
    image: null,
    pan: { ...DEFAULT_PAN },
    zoom: MIN_ZOOM,
    rotation: 0,
    basePan: { ...DEFAULT_PAN },
    baseZoom: MIN_ZOOM,
    baseRotation: 0,
    flip: { ...DEFAULT_FLIP },
    cropRect: { ...DEFAULT_CROP_RECT }
  };
  var ORIGINAL_ASPECT_RATIO = -1;
  var DEFAULT_ASPECT_RATIOS = [
    { label: (0, import_i18n118.__)("Free"), value: 0 },
    { label: (0, import_i18n118.__)("Original"), value: ORIGINAL_ASPECT_RATIO },
    { label: (0, import_i18n118.__)("Square (1:1)"), value: 1 },
    { label: (0, import_i18n118.__)("Landscape (16:9)"), value: 16 / 9 },
    { label: (0, import_i18n118.__)("Portrait (9:16)"), value: 9 / 16 },
    { label: (0, import_i18n118.__)("Classic (4:3)"), value: 4 / 3 },
    { label: (0, import_i18n118.__)("Classic portrait (3:4)"), value: 3 / 4 },
    { label: (0, import_i18n118.__)("Photo (3:2)"), value: 3 / 2 },
    { label: (0, import_i18n118.__)("Photo portrait (2:3)"), value: 2 / 3 }
  ];

  // node_modules/gl-matrix/esm/common.js
  var EPSILON = 1e-6;
  var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
  var RANDOM = Math.random;
  function round(a3) {
    if (a3 >= 0) return Math.round(a3);
    return a3 % 0.5 === 0 ? Math.floor(a3) : Math.round(a3);
  }
  var degree = Math.PI / 180;
  var radian = 180 / Math.PI;

  // node_modules/gl-matrix/esm/mat2d.js
  var mat2d_exports = {};
  __export(mat2d_exports, {
    add: () => add,
    clone: () => clone,
    copy: () => copy,
    create: () => create,
    determinant: () => determinant,
    equals: () => equals,
    exactEquals: () => exactEquals,
    frob: () => frob,
    fromRotation: () => fromRotation,
    fromScaling: () => fromScaling,
    fromTranslation: () => fromTranslation,
    fromValues: () => fromValues,
    identity: () => identity2,
    invert: () => invert,
    mul: () => mul,
    multiply: () => multiply,
    multiplyScalar: () => multiplyScalar,
    multiplyScalarAndAdd: () => multiplyScalarAndAdd,
    rotate: () => rotate,
    scale: () => scale,
    set: () => set3,
    str: () => str,
    sub: () => sub,
    subtract: () => subtract,
    translate: () => translate
  });
  function create() {
    var out = new ARRAY_TYPE(6);
    if (ARRAY_TYPE != Float32Array) {
      out[1] = 0;
      out[2] = 0;
      out[4] = 0;
      out[5] = 0;
    }
    out[0] = 1;
    out[3] = 1;
    return out;
  }
  function clone(a3) {
    var out = new ARRAY_TYPE(6);
    out[0] = a3[0];
    out[1] = a3[1];
    out[2] = a3[2];
    out[3] = a3[3];
    out[4] = a3[4];
    out[5] = a3[5];
    return out;
  }
  function copy(out, a3) {
    out[0] = a3[0];
    out[1] = a3[1];
    out[2] = a3[2];
    out[3] = a3[3];
    out[4] = a3[4];
    out[5] = a3[5];
    return out;
  }
  function identity2(out) {
    out[0] = 1;
    out[1] = 0;
    out[2] = 0;
    out[3] = 1;
    out[4] = 0;
    out[5] = 0;
    return out;
  }
  function fromValues(a3, b3, c6, d3, tx, ty) {
    var out = new ARRAY_TYPE(6);
    out[0] = a3;
    out[1] = b3;
    out[2] = c6;
    out[3] = d3;
    out[4] = tx;
    out[5] = ty;
    return out;
  }
  function set3(out, a3, b3, c6, d3, tx, ty) {
    out[0] = a3;
    out[1] = b3;
    out[2] = c6;
    out[3] = d3;
    out[4] = tx;
    out[5] = ty;
    return out;
  }
  function invert(out, a3) {
    var aa = a3[0], ab = a3[1], ac = a3[2], ad = a3[3];
    var atx = a3[4], aty = a3[5];
    var det = aa * ad - ab * ac;
    if (!det) {
      return null;
    }
    det = 1 / det;
    out[0] = ad * det;
    out[1] = -ab * det;
    out[2] = -ac * det;
    out[3] = aa * det;
    out[4] = (ac * aty - ad * atx) * det;
    out[5] = (ab * atx - aa * aty) * det;
    return out;
  }
  function determinant(a3) {
    return a3[0] * a3[3] - a3[1] * a3[2];
  }
  function multiply(out, a3, b3) {
    var a0 = a3[0], a1 = a3[1], a22 = a3[2], a32 = a3[3], a4 = a3[4], a5 = a3[5];
    var b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5];
    out[0] = a0 * b0 + a22 * b1;
    out[1] = a1 * b0 + a32 * b1;
    out[2] = a0 * b22 + a22 * b32;
    out[3] = a1 * b22 + a32 * b32;
    out[4] = a0 * b4 + a22 * b5 + a4;
    out[5] = a1 * b4 + a32 * b5 + a5;
    return out;
  }
  function rotate(out, a3, rad) {
    var a0 = a3[0], a1 = a3[1], a22 = a3[2], a32 = a3[3], a4 = a3[4], a5 = a3[5];
    var s3 = Math.sin(rad);
    var c6 = Math.cos(rad);
    out[0] = a0 * c6 + a22 * s3;
    out[1] = a1 * c6 + a32 * s3;
    out[2] = a0 * -s3 + a22 * c6;
    out[3] = a1 * -s3 + a32 * c6;
    out[4] = a4;
    out[5] = a5;
    return out;
  }
  function scale(out, a3, v3) {
    var a0 = a3[0], a1 = a3[1], a22 = a3[2], a32 = a3[3], a4 = a3[4], a5 = a3[5];
    var v0 = v3[0], v1 = v3[1];
    out[0] = a0 * v0;
    out[1] = a1 * v0;
    out[2] = a22 * v1;
    out[3] = a32 * v1;
    out[4] = a4;
    out[5] = a5;
    return out;
  }
  function translate(out, a3, v3) {
    var a0 = a3[0], a1 = a3[1], a22 = a3[2], a32 = a3[3], a4 = a3[4], a5 = a3[5];
    var v0 = v3[0], v1 = v3[1];
    out[0] = a0;
    out[1] = a1;
    out[2] = a22;
    out[3] = a32;
    out[4] = a0 * v0 + a22 * v1 + a4;
    out[5] = a1 * v0 + a32 * v1 + a5;
    return out;
  }
  function fromRotation(out, rad) {
    var s3 = Math.sin(rad), c6 = Math.cos(rad);
    out[0] = c6;
    out[1] = s3;
    out[2] = -s3;
    out[3] = c6;
    out[4] = 0;
    out[5] = 0;
    return out;
  }
  function fromScaling(out, v3) {
    out[0] = v3[0];
    out[1] = 0;
    out[2] = 0;
    out[3] = v3[1];
    out[4] = 0;
    out[5] = 0;
    return out;
  }
  function fromTranslation(out, v3) {
    out[0] = 1;
    out[1] = 0;
    out[2] = 0;
    out[3] = 1;
    out[4] = v3[0];
    out[5] = v3[1];
    return out;
  }
  function str(a3) {
    return "mat2d(" + a3[0] + ", " + a3[1] + ", " + a3[2] + ", " + a3[3] + ", " + a3[4] + ", " + a3[5] + ")";
  }
  function frob(a3) {
    return Math.sqrt(a3[0] * a3[0] + a3[1] * a3[1] + a3[2] * a3[2] + a3[3] * a3[3] + a3[4] * a3[4] + a3[5] * a3[5] + 1);
  }
  function add(out, a3, b3) {
    out[0] = a3[0] + b3[0];
    out[1] = a3[1] + b3[1];
    out[2] = a3[2] + b3[2];
    out[3] = a3[3] + b3[3];
    out[4] = a3[4] + b3[4];
    out[5] = a3[5] + b3[5];
    return out;
  }
  function subtract(out, a3, b3) {
    out[0] = a3[0] - b3[0];
    out[1] = a3[1] - b3[1];
    out[2] = a3[2] - b3[2];
    out[3] = a3[3] - b3[3];
    out[4] = a3[4] - b3[4];
    out[5] = a3[5] - b3[5];
    return out;
  }
  function multiplyScalar(out, a3, b3) {
    out[0] = a3[0] * b3;
    out[1] = a3[1] * b3;
    out[2] = a3[2] * b3;
    out[3] = a3[3] * b3;
    out[4] = a3[4] * b3;
    out[5] = a3[5] * b3;
    return out;
  }
  function multiplyScalarAndAdd(out, a3, b3, scale3) {
    out[0] = a3[0] + b3[0] * scale3;
    out[1] = a3[1] + b3[1] * scale3;
    out[2] = a3[2] + b3[2] * scale3;
    out[3] = a3[3] + b3[3] * scale3;
    out[4] = a3[4] + b3[4] * scale3;
    out[5] = a3[5] + b3[5] * scale3;
    return out;
  }
  function exactEquals(a3, b3) {
    return a3[0] === b3[0] && a3[1] === b3[1] && a3[2] === b3[2] && a3[3] === b3[3] && a3[4] === b3[4] && a3[5] === b3[5];
  }
  function equals(a3, b3) {
    var a0 = a3[0], a1 = a3[1], a22 = a3[2], a32 = a3[3], a4 = a3[4], a5 = a3[5];
    var b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5];
    return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a22 - b22) <= EPSILON * Math.max(1, Math.abs(a22), Math.abs(b22)) && Math.abs(a32 - b32) <= EPSILON * Math.max(1, Math.abs(a32), Math.abs(b32)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1, Math.abs(a5), Math.abs(b5));
  }
  var mul = multiply;
  var sub = subtract;

  // node_modules/gl-matrix/esm/vec2.js
  var vec2_exports = {};
  __export(vec2_exports, {
    add: () => add2,
    angle: () => angle,
    ceil: () => ceil,
    clone: () => clone2,
    copy: () => copy2,
    create: () => create2,
    cross: () => cross,
    dist: () => dist,
    distance: () => distance,
    div: () => div,
    divide: () => divide,
    dot: () => dot,
    equals: () => equals2,
    exactEquals: () => exactEquals2,
    floor: () => floor,
    forEach: () => forEach,
    fromValues: () => fromValues2,
    inverse: () => inverse,
    len: () => len,
    length: () => length,
    lerp: () => lerp,
    max: () => max,
    min: () => min,
    mul: () => mul2,
    multiply: () => multiply2,
    negate: () => negate,
    normalize: () => normalize,
    random: () => random,
    rotate: () => rotate2,
    round: () => round2,
    scale: () => scale2,
    scaleAndAdd: () => scaleAndAdd,
    set: () => set4,
    signedAngle: () => signedAngle,
    sqrDist: () => sqrDist,
    sqrLen: () => sqrLen,
    squaredDistance: () => squaredDistance,
    squaredLength: () => squaredLength,
    str: () => str2,
    sub: () => sub2,
    subtract: () => subtract2,
    transformMat2: () => transformMat2,
    transformMat2d: () => transformMat2d,
    transformMat3: () => transformMat3,
    transformMat4: () => transformMat4,
    zero: () => zero
  });
  function create2() {
    var out = new ARRAY_TYPE(2);
    if (ARRAY_TYPE != Float32Array) {
      out[0] = 0;
      out[1] = 0;
    }
    return out;
  }
  function clone2(a3) {
    var out = new ARRAY_TYPE(2);
    out[0] = a3[0];
    out[1] = a3[1];
    return out;
  }
  function fromValues2(x2, y3) {
    var out = new ARRAY_TYPE(2);
    out[0] = x2;
    out[1] = y3;
    return out;
  }
  function copy2(out, a3) {
    out[0] = a3[0];
    out[1] = a3[1];
    return out;
  }
  function set4(out, x2, y3) {
    out[0] = x2;
    out[1] = y3;
    return out;
  }
  function add2(out, a3, b3) {
    out[0] = a3[0] + b3[0];
    out[1] = a3[1] + b3[1];
    return out;
  }
  function subtract2(out, a3, b3) {
    out[0] = a3[0] - b3[0];
    out[1] = a3[1] - b3[1];
    return out;
  }
  function multiply2(out, a3, b3) {
    out[0] = a3[0] * b3[0];
    out[1] = a3[1] * b3[1];
    return out;
  }
  function divide(out, a3, b3) {
    out[0] = a3[0] / b3[0];
    out[1] = a3[1] / b3[1];
    return out;
  }
  function ceil(out, a3) {
    out[0] = Math.ceil(a3[0]);
    out[1] = Math.ceil(a3[1]);
    return out;
  }
  function floor(out, a3) {
    out[0] = Math.floor(a3[0]);
    out[1] = Math.floor(a3[1]);
    return out;
  }
  function min(out, a3, b3) {
    out[0] = Math.min(a3[0], b3[0]);
    out[1] = Math.min(a3[1], b3[1]);
    return out;
  }
  function max(out, a3, b3) {
    out[0] = Math.max(a3[0], b3[0]);
    out[1] = Math.max(a3[1], b3[1]);
    return out;
  }
  function round2(out, a3) {
    out[0] = round(a3[0]);
    out[1] = round(a3[1]);
    return out;
  }
  function scale2(out, a3, b3) {
    out[0] = a3[0] * b3;
    out[1] = a3[1] * b3;
    return out;
  }
  function scaleAndAdd(out, a3, b3, scale3) {
    out[0] = a3[0] + b3[0] * scale3;
    out[1] = a3[1] + b3[1] * scale3;
    return out;
  }
  function distance(a3, b3) {
    var x2 = b3[0] - a3[0], y3 = b3[1] - a3[1];
    return Math.sqrt(x2 * x2 + y3 * y3);
  }
  function squaredDistance(a3, b3) {
    var x2 = b3[0] - a3[0], y3 = b3[1] - a3[1];
    return x2 * x2 + y3 * y3;
  }
  function length(a3) {
    var x2 = a3[0], y3 = a3[1];
    return Math.sqrt(x2 * x2 + y3 * y3);
  }
  function squaredLength(a3) {
    var x2 = a3[0], y3 = a3[1];
    return x2 * x2 + y3 * y3;
  }
  function negate(out, a3) {
    out[0] = -a3[0];
    out[1] = -a3[1];
    return out;
  }
  function inverse(out, a3) {
    out[0] = 1 / a3[0];
    out[1] = 1 / a3[1];
    return out;
  }
  function normalize(out, a3) {
    var x2 = a3[0], y3 = a3[1];
    var len2 = x2 * x2 + y3 * y3;
    if (len2 > 0) {
      len2 = 1 / Math.sqrt(len2);
    }
    out[0] = a3[0] * len2;
    out[1] = a3[1] * len2;
    return out;
  }
  function dot(a3, b3) {
    return a3[0] * b3[0] + a3[1] * b3[1];
  }
  function cross(out, a3, b3) {
    var z = a3[0] * b3[1] - a3[1] * b3[0];
    out[0] = out[1] = 0;
    out[2] = z;
    return out;
  }
  function lerp(out, a3, b3, t4) {
    var ax = a3[0], ay = a3[1];
    out[0] = ax + t4 * (b3[0] - ax);
    out[1] = ay + t4 * (b3[1] - ay);
    return out;
  }
  function random(out, scale3) {
    scale3 = scale3 === void 0 ? 1 : scale3;
    var r4 = RANDOM() * 2 * Math.PI;
    out[0] = Math.cos(r4) * scale3;
    out[1] = Math.sin(r4) * scale3;
    return out;
  }
  function transformMat2(out, a3, m2) {
    var x2 = a3[0], y3 = a3[1];
    out[0] = m2[0] * x2 + m2[2] * y3;
    out[1] = m2[1] * x2 + m2[3] * y3;
    return out;
  }
  function transformMat2d(out, a3, m2) {
    var x2 = a3[0], y3 = a3[1];
    out[0] = m2[0] * x2 + m2[2] * y3 + m2[4];
    out[1] = m2[1] * x2 + m2[3] * y3 + m2[5];
    return out;
  }
  function transformMat3(out, a3, m2) {
    var x2 = a3[0], y3 = a3[1];
    out[0] = m2[0] * x2 + m2[3] * y3 + m2[6];
    out[1] = m2[1] * x2 + m2[4] * y3 + m2[7];
    return out;
  }
  function transformMat4(out, a3, m2) {
    var x2 = a3[0];
    var y3 = a3[1];
    out[0] = m2[0] * x2 + m2[4] * y3 + m2[12];
    out[1] = m2[1] * x2 + m2[5] * y3 + m2[13];
    return out;
  }
  function rotate2(out, a3, b3, rad) {
    var p0 = a3[0] - b3[0], p1 = a3[1] - b3[1], sinC = Math.sin(rad), cosC = Math.cos(rad);
    out[0] = p0 * cosC - p1 * sinC + b3[0];
    out[1] = p0 * sinC + p1 * cosC + b3[1];
    return out;
  }
  function angle(a3, b3) {
    var ax = a3[0], ay = a3[1], bx = b3[0], by = b3[1];
    return Math.abs(Math.atan2(ay * bx - ax * by, ax * bx + ay * by));
  }
  function signedAngle(a3, b3) {
    var ax = a3[0], ay = a3[1], bx = b3[0], by = b3[1];
    return Math.atan2(ax * by - ay * bx, ax * bx + ay * by);
  }
  function zero(out) {
    out[0] = 0;
    out[1] = 0;
    return out;
  }
  function str2(a3) {
    return "vec2(" + a3[0] + ", " + a3[1] + ")";
  }
  function exactEquals2(a3, b3) {
    return a3[0] === b3[0] && a3[1] === b3[1];
  }
  function equals2(a3, b3) {
    var a0 = a3[0], a1 = a3[1];
    var b0 = b3[0], b1 = b3[1];
    return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1));
  }
  var len = length;
  var sub2 = subtract2;
  var mul2 = multiply2;
  var div = divide;
  var dist = distance;
  var sqrDist = squaredDistance;
  var sqrLen = squaredLength;
  var forEach = (function() {
    var vec = create2();
    return function(a3, stride, offset, count, fn, arg) {
      var i3, l3;
      if (!stride) {
        stride = 2;
      }
      if (!offset) {
        offset = 0;
      }
      if (count) {
        l3 = Math.min(count * stride + offset, a3.length);
      } else {
        l3 = a3.length;
      }
      for (i3 = offset; i3 < l3; i3 += stride) {
        vec[0] = a3[i3];
        vec[1] = a3[i3 + 1];
        fn(vec, vec, arg);
        a3[i3] = vec[0];
        a3[i3 + 1] = vec[1];
      }
      return a3;
    };
  })();

  // packages/media-editor/build-module/image-editor/core/math/rotation.mjs
  function normalizeRotation(degrees) {
    if (degrees >= 0) {
      return degrees % 360;
    }
    return (360 + degrees % 360) % 360;
  }
  function degreesToRadians(degrees) {
    return degrees * Math.PI / 180;
  }

  // packages/media-editor/build-module/image-editor/core/camera.mjs
  var _scratchMat = mat2d_exports.create();
  var _scratchVec = vec2_exports.create();
  function getRotatedBBox(width, height, rotation) {
    const rad = degreesToRadians(rotation);
    const cosR = Math.abs(Math.cos(rad));
    const sinR = Math.abs(Math.sin(rad));
    return {
      width: cosR * width + sinR * height,
      height: sinR * width + cosR * height
    };
  }
  function getImageFit(containerSize, imageSize, rotation) {
    if (containerSize.width === 0 || containerSize.height === 0 || imageSize.width === 0 || imageSize.height === 0) {
      return {
        elementSize: { width: 0, height: 0 },
        visualSize: { width: 0, height: 0 }
      };
    }
    const snapRotation = Math.round(rotation / 90) * 90;
    const naturalBBox = getRotatedBBox(
      imageSize.width,
      imageSize.height,
      snapRotation
    );
    const fitScale = Math.min(
      containerSize.width / naturalBBox.width,
      containerSize.height / naturalBBox.height
    );
    const renderedW = imageSize.width * fitScale;
    const renderedH = imageSize.height * fitScale;
    const visualSize = getRotatedBBox(renderedW, renderedH, snapRotation);
    return {
      elementSize: { width: renderedW, height: renderedH },
      visualSize
    };
  }
  function createCamera(state, containerSize, imageSize) {
    const m2 = mat2d_exports.create();
    if (containerSize.width === 0 || containerSize.height === 0 || imageSize.width === 0 || imageSize.height === 0) {
      return m2;
    }
    const snapRotation = Math.round(state.rotation / 90) * 90;
    const naturalBBox = getRotatedBBox(
      imageSize.width,
      imageSize.height,
      snapRotation
    );
    const fitScale = Math.min(
      containerSize.width / naturalBBox.width,
      containerSize.height / naturalBBox.height
    );
    const renderedW = imageSize.width * fitScale;
    const renderedH = imageSize.height * fitScale;
    const { width: visualW, height: visualH } = getRotatedBBox(
      renderedW,
      renderedH,
      snapRotation
    );
    mat2d_exports.translate(m2, m2, [
      containerSize.width / 2,
      containerSize.height / 2
    ]);
    mat2d_exports.translate(m2, m2, [state.pan.x * visualW, state.pan.y * visualH]);
    mat2d_exports.scale(m2, m2, [
      state.flip.horizontal ? -1 : 1,
      state.flip.vertical ? -1 : 1
    ]);
    mat2d_exports.rotate(m2, m2, degreesToRadians(state.rotation));
    mat2d_exports.scale(m2, m2, [state.zoom, state.zoom]);
    mat2d_exports.translate(m2, m2, [-renderedW / 2, -renderedH / 2]);
    mat2d_exports.scale(m2, m2, [renderedW, renderedH]);
    return m2;
  }
  function aabb(camera, corners) {
    const screenCorners = corners.map((c6) => {
      const out = vec2_exports.create();
      vec2_exports.transformMat2d(out, c6, camera);
      return out;
    });
    let minX = screenCorners[0][0];
    let maxX = screenCorners[0][0];
    let minY = screenCorners[0][1];
    let maxY = screenCorners[0][1];
    for (let i3 = 1; i3 < screenCorners.length; i3++) {
      const s3 = screenCorners[i3];
      if (s3[0] < minX) {
        minX = s3[0];
      }
      if (s3[0] > maxX) {
        maxX = s3[0];
      }
      if (s3[1] < minY) {
        minY = s3[1];
      }
      if (s3[1] > maxY) {
        maxY = s3[1];
      }
    }
    return { left: minX, top: minY, width: maxX - minX, height: maxY - minY };
  }
  function getVisibleBounds(camera) {
    return aabb(camera, [
      [0, 0],
      [1, 0],
      [1, 1],
      [0, 1]
    ]);
  }
  function createExportCamera(state, imageSize, outputSize) {
    const m2 = mat2d_exports.create();
    const { rotation, flip, cropRect, zoom, pan } = state;
    if (imageSize.width === 0 || imageSize.height === 0 || outputSize.width === 0 || outputSize.height === 0) {
      return m2;
    }
    const snapRotation = Math.round(rotation / 90) * 90;
    const { width: rotW, height: rotH } = getRotatedBBox(
      imageSize.width,
      imageSize.height,
      snapRotation
    );
    const naturalCropW = cropRect.width * rotW;
    const naturalCropH = cropRect.height * rotH;
    const outputScaleX = naturalCropW > 0 ? outputSize.width / naturalCropW : 1;
    const outputScaleY = naturalCropH > 0 ? outputSize.height / naturalCropH : 1;
    const cropOffsetX = cropRect.x * rotW + outputSize.width / 2 / outputScaleX;
    const cropOffsetY = cropRect.y * rotH + outputSize.height / 2 / outputScaleY;
    const visualCenterX = rotW / 2 + pan.x * rotW;
    const visualCenterY = rotH / 2 + pan.y * rotH;
    mat2d_exports.scale(m2, m2, [outputScaleX, outputScaleY]);
    mat2d_exports.translate(m2, m2, [
      visualCenterX - cropOffsetX + outputSize.width / 2 / outputScaleX,
      visualCenterY - cropOffsetY + outputSize.height / 2 / outputScaleY
    ]);
    mat2d_exports.scale(m2, m2, [flip.horizontal ? -1 : 1, flip.vertical ? -1 : 1]);
    mat2d_exports.rotate(m2, m2, degreesToRadians(rotation));
    mat2d_exports.scale(m2, m2, [zoom, zoom]);
    mat2d_exports.translate(m2, m2, [-imageSize.width / 2, -imageSize.height / 2]);
    return m2;
  }

  // packages/media-editor/build-module/image-editor/core/export/canvas-renderer.mjs
  var DEFAULT_QUALITY = 0.92;
  function loadImage(src) {
    return new Promise((resolve, reject) => {
      const image = new Image();
      image.addEventListener("load", () => resolve(image));
      image.addEventListener("error", (error2) => reject(error2));
      image.crossOrigin = "anonymous";
      image.src = src;
    });
  }
  function renderToCanvas(image, state) {
    const { naturalWidth, naturalHeight } = image;
    const { rotation, cropRect } = state;
    const imageSize = { width: naturalWidth, height: naturalHeight };
    const snapRotation = Math.round(rotation / 90) * 90;
    const rotBBox = getRotatedBBox(naturalWidth, naturalHeight, snapRotation);
    const outW = Math.round(cropRect.width * rotBBox.width);
    const outH = Math.round(cropRect.height * rotBBox.height);
    const canvas = document.createElement("canvas");
    canvas.width = outW;
    canvas.height = outH;
    const ctx9 = canvas.getContext("2d");
    if (!ctx9) {
      throw new Error(
        "Could not obtain a 2D context for the export canvas."
      );
    }
    const camera = createExportCamera(state, imageSize, {
      width: outW,
      height: outH
    });
    ctx9.setTransform(
      camera[0],
      camera[1],
      camera[2],
      camera[3],
      camera[4],
      camera[5]
    );
    ctx9.drawImage(image, 0, 0);
    return canvas;
  }
  function canvasToBlob(canvas, mimeType = "image/png", quality = DEFAULT_QUALITY) {
    return new Promise((resolve, reject) => {
      canvas.toBlob(
        (blob) => {
          if (blob) {
            resolve(blob);
          } else {
            reject(new Error("Canvas toBlob returned null."));
          }
        },
        mimeType,
        quality
      );
    });
  }
  async function exportCroppedImage(src, state, mimeType = "image/png", quality = DEFAULT_QUALITY) {
    const image = await loadImage(src);
    const canvas = renderToCanvas(image, state);
    return canvasToBlob(canvas, mimeType, quality);
  }

  // packages/media-editor/build-module/image-editor/core/containment.mjs
  var EPSILON2 = 1e-9;
  function getVisualDimensions(rotation, imageAspectRatio) {
    const rad = degreesToRadians(rotation);
    const absC = Math.abs(Math.cos(rad));
    const absS = Math.abs(Math.sin(rad));
    const bbox = getRotatedBBox(imageAspectRatio, 1, rotation);
    return {
      visualW: bbox.width,
      visualH: bbox.height,
      absC,
      absS
    };
  }
  function getMinZoomForCover(rotation, imageAspectRatio, cropRect) {
    const aspectRatio = Math.max(imageAspectRatio, Number.EPSILON);
    const snapRotation = Math.round(rotation / 90) * 90;
    const { visualW: snapVisualW, visualH: snapVisualH } = getVisualDimensions(
      snapRotation,
      aspectRatio
    );
    const { absC, absS } = getVisualDimensions(rotation, aspectRatio);
    const cropHalfW = cropRect.width * snapVisualW / 2;
    const cropHalfH = cropRect.height * snapVisualH / 2;
    const spanAlpha = cropHalfW * absC + cropHalfH * absS;
    const spanBeta = cropHalfW * absS + cropHalfH * absC;
    const zoomFromAlpha = 2 * spanAlpha / aspectRatio;
    const zoomFromBeta = 2 * spanBeta;
    return Math.max(1, zoomFromAlpha, zoomFromBeta);
  }
  function getCropBounds(state, elementSize, visualSize, containerSize) {
    if (elementSize.width === 0 || elementSize.height === 0 || visualSize.width === 0 || visualSize.height === 0) {
      return { minX: 0, minY: 0, maxX: 1, maxY: 1 };
    }
    const tx = state.pan.x * visualSize.width;
    const ty = state.pan.y * visualSize.height;
    const rad = degreesToRadians(state.rotation);
    const cos = Math.cos(rad);
    const sin = Math.sin(rad);
    const sx = state.flip.horizontal ? -1 : 1;
    const sy = state.flip.vertical ? -1 : 1;
    const z = state.zoom;
    const ma = sx * cos * z;
    const mb = sy * sin * z;
    const mc = -sx * sin * z;
    const md = sy * cos * z;
    const hw = elementSize.width / 2;
    const hh = elementSize.height / 2;
    const corners = [
      [-hw, -hh],
      [hw, -hh],
      [hw, hh],
      [-hw, hh]
    ];
    const offsetX = (containerSize.width - visualSize.width) / 2;
    const offsetY = (containerSize.height - visualSize.height) / 2;
    let imgMinX = Infinity;
    let imgMaxX = -Infinity;
    let imgMinY = Infinity;
    let imgMaxY = -Infinity;
    for (const [cx2, cy] of corners) {
      const screenX = ma * cx2 + mc * cy + tx;
      const screenY = mb * cx2 + md * cy + ty;
      const nx = screenX / visualSize.width + 0.5;
      const ny = screenY / visualSize.height + 0.5;
      imgMinX = Math.min(imgMinX, nx);
      imgMaxX = Math.max(imgMaxX, nx);
      imgMinY = Math.min(imgMinY, ny);
      imgMaxY = Math.max(imgMaxY, ny);
    }
    const containerMinX = -offsetX / visualSize.width;
    const containerMaxX = (containerSize.width - offsetX) / visualSize.width;
    const containerMinY = -offsetY / visualSize.height;
    const containerMaxY = (containerSize.height - offsetY) / visualSize.height;
    return {
      minX: Math.max(imgMinX, containerMinX),
      minY: Math.max(imgMinY, containerMinY),
      maxX: Math.min(imgMaxX, containerMaxX),
      maxY: Math.min(imgMaxY, containerMaxY)
    };
  }
  function restrictCropRect(cropRect, zoom, rotation, imageAspectRatio) {
    const aspectRatio = Math.max(imageAspectRatio, Number.EPSILON);
    const snapRotation = Math.round(rotation / 90) * 90;
    const { visualW, visualH } = getVisualDimensions(
      snapRotation,
      aspectRatio
    );
    const { absC, absS } = getVisualDimensions(rotation, aspectRatio);
    const W = cropRect.width;
    const H2 = cropRect.height;
    const cropWPx = W * visualW;
    const cropHPx = H2 * visualH;
    const spanAlpha = cropWPx * absC + cropHPx * absS;
    const spanBeta = cropWPx * absS + cropHPx * absC;
    const limitAlpha = aspectRatio * zoom;
    const limitBeta = zoom;
    let t4 = 1;
    if (spanAlpha > 0) {
      t4 = Math.min(t4, limitAlpha / spanAlpha);
    }
    if (spanBeta > 0) {
      t4 = Math.min(t4, limitBeta / spanBeta);
    }
    if (t4 >= 1 - EPSILON2) {
      return cropRect;
    }
    const newW = W * t4;
    const newH = H2 * t4;
    const centerX = cropRect.x + W / 2;
    const centerY = cropRect.y + H2 / 2;
    let newX = centerX - newW / 2;
    let newY = centerY - newH / 2;
    newX = Math.max(0, Math.min(newX, 1 - newW));
    newY = Math.max(0, Math.min(newY, 1 - newH));
    return { x: newX, y: newY, width: newW, height: newH };
  }
  var CANONICAL_CONTAINER = { width: 1e3, height: 1e3 };
  var _scratchMat2 = mat2d_exports.create();
  var _scratchVec2 = vec2_exports.create();
  function restrictPanZoom(state, imageSize, cropRect) {
    const aspectRatio = imageSize.width > 0 && imageSize.height > 0 ? imageSize.width / imageSize.height : 1;
    const minZoom = getMinZoomForCover(state.rotation, aspectRatio, cropRect);
    const zoom = Math.max(state.zoom, minZoom);
    const candidateState = { ...state, zoom };
    const camera = createCamera(
      candidateState,
      CANONICAL_CONTAINER,
      imageSize
    );
    const snapRotation = Math.round(state.rotation / 90) * 90;
    const baseCamera = createCamera(
      {
        ...candidateState,
        pan: { x: 0, y: 0 },
        zoom: 1,
        rotation: snapRotation
      },
      CANONICAL_CONTAINER,
      imageSize
    );
    const visibleBounds = getVisibleBounds(baseCamera);
    const stencilCorners = [
      [
        visibleBounds.left + cropRect.x * visibleBounds.width,
        visibleBounds.top + cropRect.y * visibleBounds.height
      ],
      [
        visibleBounds.left + (cropRect.x + cropRect.width) * visibleBounds.width,
        visibleBounds.top + cropRect.y * visibleBounds.height
      ],
      [
        visibleBounds.left + (cropRect.x + cropRect.width) * visibleBounds.width,
        visibleBounds.top + (cropRect.y + cropRect.height) * visibleBounds.height
      ],
      [
        visibleBounds.left + cropRect.x * visibleBounds.width,
        visibleBounds.top + (cropRect.y + cropRect.height) * visibleBounds.height
      ]
    ];
    mat2d_exports.invert(_scratchMat2, camera);
    let minWx = Infinity;
    let maxWx = -Infinity;
    let minWy = Infinity;
    let maxWy = -Infinity;
    for (const corner of stencilCorners) {
      vec2_exports.transformMat2d(_scratchVec2, corner, _scratchMat2);
      const w3 = _scratchVec2;
      if (w3[0] < minWx) {
        minWx = w3[0];
      }
      if (w3[0] > maxWx) {
        maxWx = w3[0];
      }
      if (w3[1] < minWy) {
        minWy = w3[1];
      }
      if (w3[1] > maxWy) {
        maxWy = w3[1];
      }
    }
    if (minWx >= -EPSILON2 && maxWx <= 1 + EPSILON2 && minWy >= -EPSILON2 && maxWy <= 1 + EPSILON2) {
      return { pan: state.pan, zoom };
    }
    let dwx = 0;
    let dwy = 0;
    if (minWx < 0 && maxWx <= 1 + EPSILON2) {
      dwx = -minWx;
    } else if (maxWx > 1 && minWx >= -EPSILON2) {
      dwx = 1 - maxWx;
    } else if (minWx < 0 && maxWx > 1) {
      dwx = (1 - maxWx - minWx) / 2;
    }
    if (minWy < 0 && maxWy <= 1 + EPSILON2) {
      dwy = -minWy;
    } else if (maxWy > 1 && minWy >= -EPSILON2) {
      dwy = 1 - maxWy;
    } else if (minWy < 0 && maxWy > 1) {
      dwy = (1 - maxWy - minWy) / 2;
    }
    const dsx = camera[0] * dwx + camera[2] * dwy;
    const dsy = camera[1] * dwx + camera[3] * dwy;
    const newPanX = state.pan.x - (visibleBounds.width > 0 ? dsx / visibleBounds.width : 0);
    const newPanY = state.pan.y - (visibleBounds.height > 0 ? dsy / visibleBounds.height : 0);
    return {
      pan: { x: newPanX, y: newPanY },
      zoom
    };
  }

  // packages/media-editor/build-module/image-editor/core/state.mjs
  function operationToAction(state, op) {
    switch (op.type) {
      case "crop":
        return { type: "SET_CROP_RECT", payload: { ...op.rect } };
      case "rotate": {
        const singleFlip = state.flip.horizontal !== state.flip.vertical;
        const fieldDelta = singleFlip ? -op.degrees : op.degrees;
        return {
          type: "SET_ROTATION",
          payload: normalizeRotation(state.rotation + fieldDelta)
        };
      }
      case "flip":
        return {
          type: "SET_FLIP",
          payload: {
            ...state.flip,
            [op.direction]: !state.flip[op.direction]
          }
        };
      case "zoom":
        return { type: "SET_ZOOM", payload: op.factor };
    }
  }
  function enforceContainment(state) {
    if (!state.image) {
      return state;
    }
    const imageSize = {
      width: state.image.naturalWidth,
      height: state.image.naturalHeight
    };
    const imageAspectRatio = imageSize.width / imageSize.height;
    const { pan: panAfterZoom, zoom } = restrictPanZoom(
      state,
      imageSize,
      state.cropRect
    );
    const cropRect = restrictCropRect(
      state.cropRect,
      zoom,
      state.rotation,
      imageAspectRatio
    );
    let pan = panAfterZoom;
    if (cropRect !== state.cropRect) {
      ({ pan } = restrictPanZoom(
        { ...state, zoom, cropRect },
        imageSize,
        cropRect
      ));
    }
    if (pan.x === state.pan.x && pan.y === state.pan.y && zoom === state.zoom && cropRect === state.cropRect) {
      return state;
    }
    return { ...state, pan, zoom, cropRect };
  }
  function commitBase(next) {
    if (next.basePan.x === next.pan.x && next.basePan.y === next.pan.y && next.baseZoom === next.zoom && next.baseRotation === next.rotation) {
      return next;
    }
    return {
      ...next,
      basePan: { x: next.pan.x, y: next.pan.y },
      baseZoom: next.zoom,
      baseRotation: next.rotation
    };
  }
  function cropperReducer(state, action) {
    switch (action.type) {
      case "SET_IMAGE":
        return commitBase(
          enforceContainment({
            ...state,
            image: action.payload
          })
        );
      case "SET_PAN":
        return commitBase(
          enforceContainment({
            ...state,
            pan: action.payload
          })
        );
      case "SET_ZOOM": {
        const z = Math.min(MAX_ZOOM, Math.max(1, action.payload));
        return commitBase(
          enforceContainment({
            ...state,
            zoom: z
          })
        );
      }
      case "SET_ZOOM_AT_POINT": {
        const z = Math.min(MAX_ZOOM, Math.max(1, action.payload.zoom));
        return commitBase(
          enforceContainment({
            ...state,
            zoom: z,
            pan: action.payload.pan
          })
        );
      }
      case "SET_ROTATION": {
        const newRotation = normalizeRotation(action.payload);
        const singleFlip = state.flip.horizontal !== state.flip.vertical;
        const deltaRad = degreesToRadians(
          newRotation - state.baseRotation
        );
        const cos = Math.cos(deltaRad);
        const sin = Math.sin(deltaRad) * (singleFlip ? -1 : 1);
        const cropCx = state.cropRect.x + state.cropRect.width / 2;
        const cropCy = state.cropRect.y + state.cropRect.height / 2;
        const ox = cropCx - 0.5;
        const oy = cropCy - 0.5;
        const dx = state.basePan.x - ox;
        const dy = state.basePan.y - oy;
        return enforceContainment({
          ...state,
          rotation: newRotation,
          zoom: state.baseZoom,
          pan: {
            x: ox + cos * dx - sin * dy,
            y: oy + sin * dx + cos * dy
          }
        });
      }
      case "SNAP_ROTATE_90": {
        const rawDir = action.payload.direction;
        const singleFlip = state.flip.horizontal !== state.flip.vertical;
        const fieldDir = singleFlip ? -rawDir : rawDir;
        const rot90 = normalizeRotation(state.rotation + fieldDir * 90);
        const rect = state.cropRect;
        const cx2 = rect.x + rect.width / 2;
        const cy = rect.y + rect.height / 2;
        const newPanX = rawDir === 1 ? -state.pan.y : state.pan.y;
        const newPanY = rawDir === 1 ? state.pan.x : -state.pan.x;
        return commitBase(
          enforceContainment({
            ...state,
            rotation: rot90,
            zoom: state.baseZoom,
            pan: { x: newPanX, y: newPanY },
            cropRect: {
              x: cx2 - rect.height / 2,
              y: cy - rect.width / 2,
              width: rect.height,
              height: rect.width
            }
          })
        );
      }
      case "SET_FLIP": {
        const oldFlip = state.flip;
        const newFlip = action.payload;
        const flippedH = oldFlip.horizontal !== newFlip.horizontal;
        const flippedV = oldFlip.vertical !== newFlip.vertical;
        const rect = state.cropRect;
        return commitBase(
          enforceContainment({
            ...state,
            flip: newFlip,
            pan: {
              x: flippedH ? -state.pan.x : state.pan.x,
              y: flippedV ? -state.pan.y : state.pan.y
            },
            cropRect: {
              x: flippedH ? 1 - rect.x - rect.width : rect.x,
              y: flippedV ? 1 - rect.y - rect.height : rect.y,
              width: rect.width,
              height: rect.height
            }
          })
        );
      }
      case "SET_CROP_RECT":
        return commitBase(
          enforceContainment({
            ...state,
            cropRect: action.payload
          })
        );
      case "SETTLE_CROP": {
        const rect = state.cropRect;
        if (rect.width === 0 || rect.height === 0 || !state.image) {
          return state;
        }
        const normalizedRatio = rect.width / rect.height;
        let newH = 1;
        let newW = normalizedRatio;
        if (newW > 1) {
          newW = 1;
          newH = 1 / normalizedRatio;
        }
        const s3 = newH / rect.height;
        const oldCx = rect.x + rect.width / 2;
        const oldCy = rect.y + rect.height / 2;
        return commitBase(
          enforceContainment({
            ...state,
            zoom: state.zoom * s3,
            pan: {
              x: (state.pan.x - oldCx + 0.5) * s3,
              y: (state.pan.y - oldCy + 0.5) * s3
            },
            cropRect: {
              x: (1 - newW) / 2,
              y: (1 - newH) / 2,
              width: newW,
              height: newH
            }
          })
        );
      }
      case "APPLY_OPERATION":
        return cropperReducer(
          state,
          operationToAction(state, action.payload)
        );
      case "RESET":
        return commitBase(
          enforceContainment({
            ...DEFAULT_STATE2,
            image: state.image,
            ...action.payload
          })
        );
    }
  }
  function isStateDirty(current, initial) {
    return current.pan.x !== initial.pan.x || current.pan.y !== initial.pan.y || current.zoom !== initial.zoom || current.rotation !== initial.rotation || current.flip.horizontal !== initial.flip.horizontal || current.flip.vertical !== initial.flip.vertical || current.cropRect.x !== initial.cropRect.x || current.cropRect.y !== initial.cropRect.y || current.cropRect.width !== initial.cropRect.width || current.cropRect.height !== initial.cropRect.height;
  }

  // packages/media-editor/build-module/image-editor/react/hooks/use-cropper-state.mjs
  function useCropperState(initialState) {
    const [state, dispatch7] = (0, import_element120.useReducer)(
      cropperReducer,
      initialState,
      (init2) => enforceContainment({ ...DEFAULT_STATE2, ...init2 })
    );
    const initialRef = (0, import_element120.useRef)(
      enforceContainment({ ...DEFAULT_STATE2, ...initialState })
    );
    const stateRef = (0, import_element120.useRef)(state);
    stateRef.current = state;
    const setImage = (0, import_element120.useCallback)(
      (image) => {
        dispatch7({ type: "SET_IMAGE", payload: image });
        initialRef.current = enforceContainment({
          ...initialRef.current,
          image
        });
      },
      [dispatch7]
    );
    const setPan = (0, import_element120.useCallback)(
      (pan) => {
        dispatch7({ type: "SET_PAN", payload: pan });
      },
      [dispatch7]
    );
    const setZoom = (0, import_element120.useCallback)(
      (zoom) => {
        dispatch7({ type: "SET_ZOOM", payload: zoom });
      },
      [dispatch7]
    );
    const setZoomAtPoint = (0, import_element120.useCallback)(
      (zoom, pan) => {
        dispatch7({
          type: "SET_ZOOM_AT_POINT",
          payload: { zoom, pan }
        });
      },
      [dispatch7]
    );
    const setRotation = (0, import_element120.useCallback)(
      (rotation) => {
        dispatch7({ type: "SET_ROTATION", payload: rotation });
      },
      [dispatch7]
    );
    const setFlip = (0, import_element120.useCallback)(
      (flip) => {
        dispatch7({ type: "SET_FLIP", payload: flip });
      },
      [dispatch7]
    );
    const snapRotate90 = (0, import_element120.useCallback)(
      (direction) => {
        dispatch7({
          type: "SNAP_ROTATE_90",
          payload: { direction }
        });
      },
      [dispatch7]
    );
    const setCropRect = (0, import_element120.useCallback)(
      (rect) => {
        dispatch7({ type: "SET_CROP_RECT", payload: rect });
      },
      [dispatch7]
    );
    const settleCrop = (0, import_element120.useCallback)(() => {
      dispatch7({ type: "SETTLE_CROP" });
    }, [dispatch7]);
    const applyOperation = (0, import_element120.useCallback)(
      (op) => {
        dispatch7({ type: "APPLY_OPERATION", payload: op });
      },
      [dispatch7]
    );
    const reset = (0, import_element120.useCallback)(
      (resetState) => {
        dispatch7({ type: "RESET", payload: resetState });
        initialRef.current = enforceContainment({
          ...DEFAULT_STATE2,
          image: stateRef.current.image,
          ...resetState
        });
      },
      [dispatch7]
    );
    const isDirty = isStateDirty(state, initialRef.current);
    const getCroppedImage = (0, import_element120.useCallback)(
      (mimeType, quality) => {
        if (!state.image) {
          return Promise.reject(
            new Error("No image loaded \u2014 call setImage first.")
          );
        }
        return exportCroppedImage(
          state.image.src,
          state,
          mimeType,
          quality
        );
      },
      [state]
    );
    const controller = {
      state,
      setImage,
      setPan,
      setZoom,
      setZoomAtPoint,
      setRotation,
      setFlip,
      snapRotate90,
      setCropRect,
      settleCrop,
      applyOperation,
      reset,
      isDirty,
      getCroppedImage
    };
    return controller;
  }

  // packages/media-editor/build-module/image-editor/react/components/cropper.mjs
  var import_element125 = __toESM(require_element(), 1);
  var import_i18n120 = __toESM(require_i18n(), 1);

  // packages/media-editor/build-module/image-editor/react/hooks/use-interaction.mjs
  var import_element121 = __toESM(require_element(), 1);

  // packages/media-editor/build-module/image-editor/core/interaction-controller.mjs
  var DOUBLE_TAP_TIME = 300;
  var DOUBLE_TAP_DISTANCE = 30;
  var ZOOM_ANIMATION_DURATION = 200;
  function getImageSizeFromState(state) {
    return state.image ? { width: state.image.naturalWidth, height: state.image.naturalHeight } : { width: 1, height: 1 };
  }
  function getTouchDistance(t1, t22) {
    const dx = t1.clientX - t22.clientX;
    const dy = t1.clientY - t22.clientY;
    return Math.sqrt(dx * dx + dy * dy);
  }
  var InteractionController = class {
    options;
    /** Current drag/zoom status. */
    isDragging = false;
    isZooming = false;
    /** Active drag state during pointer interactions. */
    drag = null;
    /** Active touch state during touch interactions. */
    touch = null;
    /** Cleanup function for active touch listeners on document. */
    touchCleanup = null;
    /**
     * Cleanup function for active pointer-drag listeners on the
     * captured element. Set while a pointer drag is in progress so
     * `destroy()` can tear the drag down cleanly if the consumer
     * unmounts mid-drag. Cleared on pointerup/lostpointercapture.
     */
    pointerCleanup = null;
    /** Last tap info for double-tap detection. */
    lastTap = null;
    /** Timer for the zoom animation state (double-tap). */
    zoomTimer;
    /** Timer for wheel gesture debounce. */
    wheelGestureTimer;
    /** Whether a wheel gesture is currently active. */
    wheelGestureActive = false;
    /** Current requestAnimationFrame ID. */
    rafId = 0;
    constructor(options) {
      this.options = options;
    }
    /** Read minZoom lazily so option changes take effect immediately. */
    get minZoom() {
      return this.options.minZoom ?? MIN_ZOOM;
    }
    /** Read maxZoom lazily so option changes take effect immediately. */
    get maxZoom() {
      return this.options.maxZoom ?? MAX_ZOOM;
    }
    /** Read zoomSpeed lazily so option changes take effect immediately. */
    get zoomSpeed() {
      return this.options.zoomSpeed ?? 0.01;
    }
    /** Read keyboardStep lazily so option changes take effect immediately. */
    get keyboardStep() {
      return this.options.keyboardStep ?? 0.05;
    }
    /** Read doubleTapZoom lazily so option changes take effect immediately. */
    get doubleTapZoom() {
      return this.options.doubleTapZoom ?? 2;
    }
    /**
     * Update the drag/zoom status and notify via callback if changed.
     *
     * @param update Partial status with isDragging and/or isZooming.
     */
    setStatus(update4) {
      let changed = false;
      if (update4.isDragging !== void 0 && update4.isDragging !== this.isDragging) {
        this.isDragging = update4.isDragging;
        changed = true;
      }
      if (update4.isZooming !== void 0 && update4.isZooming !== this.isZooming) {
        this.isZooming = update4.isZooming;
        changed = true;
      }
      if (changed) {
        this.options.onStatusChange?.({
          isDragging: this.isDragging,
          isZooming: this.isZooming
        });
      }
    }
    /**
     * Handle a pointer-down event on the container element.
     *
     * Initiates a drag (pan) interaction. Captures the pointer on the
     * provided element and registers pointermove/pointerup/lostpointercapture
     * listeners for the duration of the drag.
     *
     * @param e  The native PointerEvent.
     * @param el The DOM element to capture the pointer on.
     */
    handlePointerDown(e3, el) {
      if (e3.button !== 0) {
        return;
      }
      e3.preventDefault();
      const ownerDoc = el.ownerDocument;
      if (ownerDoc?.activeElement instanceof HTMLElement && ownerDoc.activeElement !== el) {
        ownerDoc.activeElement.blur();
      }
      el.focus();
      el.setPointerCapture(e3.pointerId);
      this.setStatus({ isDragging: true });
      this.options.onGestureStart?.();
      const currentState = this.options.getState();
      this.drag = {
        startX: e3.clientX,
        startY: e3.clientY,
        startPanX: currentState.pan.x,
        startPanY: currentState.pan.y
      };
      const onPointerMove = (moveEvent) => {
        const drag2 = this.drag;
        if (!drag2) {
          return;
        }
        const pe = moveEvent;
        cancelAnimationFrame(this.rafId);
        this.rafId = requestAnimationFrame(() => {
          const s3 = this.options.getState();
          const imgSize = this.options.getImageSize();
          const containerSize = this.options.getContainerSize();
          const panSize = imgSize ?? containerSize;
          const deltaX = panSize.width > 0 ? (pe.clientX - drag2.startX) / panSize.width : 0;
          const deltaY = panSize.height > 0 ? (pe.clientY - drag2.startY) / panSize.height : 0;
          const { pan: newCrop } = restrictPanZoom(
            {
              ...s3,
              pan: {
                x: drag2.startPanX + deltaX,
                y: drag2.startPanY + deltaY
              }
            },
            getImageSizeFromState(s3),
            s3.cropRect
          );
          this.options.actions.setPan(newCrop);
        });
      };
      const removeListeners = () => {
        el.removeEventListener("pointermove", onPointerMove);
        el.removeEventListener("pointerup", onPointerUp);
        el.removeEventListener("lostpointercapture", onPointerUp);
      };
      const onPointerUp = () => {
        this.setStatus({ isDragging: false });
        this.options.onGestureEnd?.();
        this.drag = null;
        cancelAnimationFrame(this.rafId);
        removeListeners();
        this.pointerCleanup = null;
      };
      el.addEventListener("pointermove", onPointerMove);
      el.addEventListener("pointerup", onPointerUp);
      el.addEventListener("lostpointercapture", onPointerUp);
      this.pointerCleanup = removeListeners;
    }
    /**
     * Handle a wheel event on the container element.
     *
     * Implements focal-point zoom: the point under the cursor stays
     * stationary on screen while the zoom level changes.
     *
     * Must be registered with `{ passive: false }` to allow preventDefault.
     *
     * @param e The native WheelEvent.
     */
    handleWheel(e3) {
      e3.preventDefault();
      if (!this.wheelGestureActive) {
        this.wheelGestureActive = true;
        this.options.onGestureStart?.();
      }
      clearTimeout(this.wheelGestureTimer);
      this.wheelGestureTimer = setTimeout(() => {
        this.wheelGestureActive = false;
        this.options.onGestureEnd?.();
      }, DOUBLE_TAP_TIME);
      const s3 = this.options.getState();
      const delta = -e3.deltaY * this.zoomSpeed;
      const newZoom = Math.min(
        this.maxZoom,
        Math.max(this.minZoom, s3.zoom + delta)
      );
      if (newZoom === s3.zoom) {
        return;
      }
      const containerSize = this.options.getContainerSize();
      const imgSize = this.options.getImageSize();
      const visSize = imgSize ?? containerSize;
      const target = e3.currentTarget;
      const rect = target instanceof Element ? target.getBoundingClientRect() : void 0;
      if (visSize.width > 0 && visSize.height > 0 && rect) {
        const fx = e3.clientX - rect.left - containerSize.width / 2;
        const fy = e3.clientY - rect.top - containerSize.height / 2;
        const zoomRatio = 1 - newZoom / s3.zoom;
        const focalNormX = fx / visSize.width;
        const focalNormY = fy / visSize.height;
        const newCropX = s3.pan.x + (focalNormX - s3.pan.x) * zoomRatio;
        const newCropY = s3.pan.y + (focalNormY - s3.pan.y) * zoomRatio;
        const { pan: clampedCrop } = restrictPanZoom(
          { ...s3, zoom: newZoom, pan: { x: newCropX, y: newCropY } },
          getImageSizeFromState(s3),
          s3.cropRect
        );
        this.options.actions.setZoomAtPoint(newZoom, clampedCrop);
      } else {
        this.options.actions.setZoom(newZoom);
      }
    }
    /**
     * Handle a touch-start event on the container element.
     *
     * Supports single-finger pan, two-finger pinch zoom, and
     * double-tap to toggle between fit and 2x zoom. Registers
     * touchmove/touchend/touchcancel on the provided document for the
     * duration of the gesture.
     *
     * @param e             The native TouchEvent.
     * @param containerRect The bounding rect of the container element.
     * @param doc           The document to register move/end listeners on.
     *                      Defaults to globalThis.document. Pass the iframe's
     *                      contentDocument when running inside an iframe.
     */
    handleTouchStart(e3, containerRect, doc = document) {
      if (this.touch && e3.touches.length === 2) {
        const s3 = this.options.getState();
        const distance2 = getTouchDistance(e3.touches[0], e3.touches[1]);
        const midX = (e3.touches[0].clientX + e3.touches[1].clientX) / 2;
        const midY = (e3.touches[0].clientY + e3.touches[1].clientY) / 2;
        this.touch.didPinch = true;
        this.touch.startDistance = distance2;
        this.touch.startZoom = s3.zoom;
        this.touch.startPanX = s3.pan.x;
        this.touch.startPanY = s3.pan.y;
        this.touch.startMidX = midX;
        this.touch.startMidY = midY;
        this.touch.containerRect = containerRect;
        this.setStatus({ isDragging: false });
        return;
      }
      if (e3.touches.length === 1) {
        const tapX = e3.touches[0].clientX;
        const tapY = e3.touches[0].clientY;
        if (this.tryDoubleTap(e3, tapX, tapY, containerRect)) {
          return;
        }
        const currentState = this.options.getState();
        this.touch = {
          startDistance: 0,
          startZoom: currentState.zoom,
          lastTouchX: e3.touches[0].clientX,
          lastTouchY: e3.touches[0].clientY,
          startPanX: currentState.pan.x,
          startPanY: currentState.pan.y,
          containerRect,
          startMidX: 0,
          startMidY: 0,
          didPinch: false,
          moved: false
        };
        this.options.onGestureStart?.();
      } else if (e3.touches.length === 2) {
        const currentState = this.options.getState();
        const distance2 = getTouchDistance(e3.touches[0], e3.touches[1]);
        const midX = (e3.touches[0].clientX + e3.touches[1].clientX) / 2;
        const midY = (e3.touches[0].clientY + e3.touches[1].clientY) / 2;
        this.touch = {
          startDistance: distance2,
          startZoom: currentState.zoom,
          lastTouchX: 0,
          lastTouchY: 0,
          startPanX: currentState.pan.x,
          startPanY: currentState.pan.y,
          containerRect,
          startMidX: midX,
          startMidY: midY,
          didPinch: true,
          moved: false
        };
        this.options.onGestureStart?.();
      }
      const onTouchEnd = () => {
        this.touch = null;
        this.touchCleanup = null;
        cancelAnimationFrame(this.rafId);
        doc.removeEventListener("touchmove", this.handleTouchMove);
        doc.removeEventListener("touchend", onTouchEnd);
        doc.removeEventListener("touchcancel", onTouchEnd);
        this.setStatus({ isDragging: false });
        this.options.onGestureEnd?.();
      };
      this.touchCleanup?.();
      doc.addEventListener("touchmove", this.handleTouchMove, {
        passive: false
      });
      doc.addEventListener("touchend", onTouchEnd);
      doc.addEventListener("touchcancel", onTouchEnd);
      this.touchCleanup = onTouchEnd;
    }
    // Handle a touchmove event during an active touch gesture. Decides pinch
    // vs. pan based on current `moveEvent.touches.length`, so the gesture
    // can transition between modes without timing sensitivity (e.g. fingers
    // landing 0ms vs 200ms apart). Arrow-property binding so `this` stays
    // attached when used as an event listener.
    handleTouchMove = (moveEvent) => {
      const touch = this.touch;
      if (!touch) {
        return;
      }
      cancelAnimationFrame(this.rafId);
      this.rafId = requestAnimationFrame(() => {
        const s3 = this.options.getState();
        if (moveEvent.touches.length === 2) {
          if (!touch.didPinch) {
            touch.didPinch = true;
            touch.startDistance = getTouchDistance(
              moveEvent.touches[0],
              moveEvent.touches[1]
            );
            touch.startZoom = s3.zoom;
            touch.startPanX = s3.pan.x;
            touch.startPanY = s3.pan.y;
            touch.startMidX = (moveEvent.touches[0].clientX + moveEvent.touches[1].clientX) / 2;
            touch.startMidY = (moveEvent.touches[0].clientY + moveEvent.touches[1].clientY) / 2;
            this.setStatus({ isDragging: false });
            return;
          }
          const latestContainerSize = this.options.getContainerSize();
          const latestImageSize = this.options.getImageSize();
          const t0 = moveEvent.touches[0];
          const t1 = moveEvent.touches[1];
          const currentDistance = getTouchDistance(t0, t1);
          const ratio = currentDistance / touch.startDistance;
          const newZoom = Math.min(
            this.maxZoom,
            Math.max(this.minZoom, touch.startZoom * ratio)
          );
          const visSize = latestImageSize ?? latestContainerSize;
          const rect = touch.containerRect;
          if (visSize.width > 0 && visSize.height > 0 && rect) {
            const mx = (t0.clientX + t1.clientX) / 2 - rect.left - latestContainerSize.width / 2;
            const my = (t0.clientY + t1.clientY) / 2 - rect.top - latestContainerSize.height / 2;
            const startMx = touch.startMidX - rect.left - latestContainerSize.width / 2;
            const startMy = touch.startMidY - rect.top - latestContainerSize.height / 2;
            const panDx = visSize.width > 0 ? (mx - startMx) / visSize.width : 0;
            const panDy = visSize.height > 0 ? (my - startMy) / visSize.height : 0;
            const zoomRatio = s3.zoom !== 0 ? 1 - newZoom / s3.zoom : 0;
            const focalNormX = mx / visSize.width;
            const focalNormY = my / visSize.height;
            const zoomCropX = s3.pan.x + (focalNormX - s3.pan.x) * zoomRatio;
            const zoomCropY = s3.pan.y + (focalNormY - s3.pan.y) * zoomRatio;
            const newCropX = touch.startPanX + panDx + (zoomCropX - s3.pan.x);
            const newCropY = touch.startPanY + panDy + (zoomCropY - s3.pan.y);
            const { pan: clampedCrop } = restrictPanZoom(
              {
                ...s3,
                zoom: newZoom,
                pan: { x: newCropX, y: newCropY }
              },
              getImageSizeFromState(s3),
              s3.cropRect
            );
            this.options.actions.setZoomAtPoint(newZoom, clampedCrop);
          } else if (newZoom !== s3.zoom) {
            this.options.actions.setZoom(newZoom);
          }
        } else if (moveEvent.touches.length === 1 && !touch.didPinch) {
          if (!touch.moved) {
            touch.moved = true;
            this.setStatus({ isDragging: true });
          }
          const panImageSize = this.options.getImageSize();
          const panContainerSize = this.options.getContainerSize();
          const panSize = panImageSize ?? panContainerSize;
          const deltaX = panSize.width > 0 ? (moveEvent.touches[0].clientX - touch.lastTouchX) / panSize.width : 0;
          const deltaY = panSize.height > 0 ? (moveEvent.touches[0].clientY - touch.lastTouchY) / panSize.height : 0;
          const { pan: newCrop } = restrictPanZoom(
            {
              ...s3,
              pan: {
                x: touch.startPanX + deltaX,
                y: touch.startPanY + deltaY
              }
            },
            getImageSizeFromState(s3),
            s3.cropRect
          );
          this.options.actions.setPan(newCrop);
        }
      });
    };
    // Handle double-tap-to-toggle-zoom. On a second tap within the configured
    // time/distance threshold, toggles zoom between `minZoom` and
    // `doubleTapZoom` around the tap point and dispatches. Returns `true` if
    // the tap was handled as a double-tap (caller should early-return),
    // `false` otherwise (caller proceeds with normal single-tap handling).
    // Either way, records the tap for next time.
    tryDoubleTap(e3, tapX, tapY, containerRect) {
      const now = Date.now();
      const lastTap = this.lastTap;
      if (!lastTap) {
        this.lastTap = { time: now, x: tapX, y: tapY };
        return false;
      }
      const timeDelta = now - lastTap.time;
      const distDelta = Math.sqrt(
        (tapX - lastTap.x) ** 2 + (tapY - lastTap.y) ** 2
      );
      const isDoubleTap = timeDelta < DOUBLE_TAP_TIME && distDelta < DOUBLE_TAP_DISTANCE;
      if (!isDoubleTap) {
        this.lastTap = { time: now, x: tapX, y: tapY };
        return false;
      }
      e3.preventDefault();
      this.lastTap = null;
      const currentState = this.options.getState();
      const containerSize = this.options.getContainerSize();
      const imgSize = this.options.getImageSize();
      const targetZoom = currentState.zoom > (this.minZoom + this.doubleTapZoom) / 2 ? this.minZoom : this.doubleTapZoom;
      const visSize = imgSize ?? containerSize;
      this.setStatus({ isZooming: true });
      clearTimeout(this.zoomTimer);
      this.zoomTimer = setTimeout(() => {
        this.setStatus({ isZooming: false });
      }, ZOOM_ANIMATION_DURATION);
      if (visSize.width > 0 && visSize.height > 0) {
        const fx = tapX - containerRect.left - containerSize.width / 2;
        const fy = tapY - containerRect.top - containerSize.height / 2;
        const zoomRatio = 1 - targetZoom / currentState.zoom;
        const focalNormX = fx / visSize.width;
        const focalNormY = fy / visSize.height;
        const newCropX = currentState.pan.x + (focalNormX - currentState.pan.x) * zoomRatio;
        const newCropY = currentState.pan.y + (focalNormY - currentState.pan.y) * zoomRatio;
        const { pan: clampedCrop } = restrictPanZoom(
          {
            ...currentState,
            zoom: targetZoom,
            pan: { x: newCropX, y: newCropY }
          },
          getImageSizeFromState(currentState),
          currentState.cropRect
        );
        this.options.actions.setZoomAtPoint(targetZoom, clampedCrop);
      } else {
        this.options.actions.setZoom(targetZoom);
      }
      return true;
    }
    /**
     * Handle a keydown event on the container element.
     *
     * Supports arrow keys for panning, +/- for zoom, and r/R for rotation.
     *
     * @param e The native KeyboardEvent.
     */
    handleKeyDown(e3) {
      const currentState = this.options.getState();
      switch (e3.key) {
        case "ArrowUp": {
          e3.preventDefault();
          const { pan: newCrop } = restrictPanZoom(
            {
              ...currentState,
              pan: {
                x: currentState.pan.x,
                y: currentState.pan.y + this.keyboardStep
              }
            },
            getImageSizeFromState(currentState),
            currentState.cropRect
          );
          this.options.actions.setPan(newCrop);
          break;
        }
        case "ArrowDown": {
          e3.preventDefault();
          const { pan: newCrop } = restrictPanZoom(
            {
              ...currentState,
              pan: {
                x: currentState.pan.x,
                y: currentState.pan.y - this.keyboardStep
              }
            },
            getImageSizeFromState(currentState),
            currentState.cropRect
          );
          this.options.actions.setPan(newCrop);
          break;
        }
        case "ArrowLeft": {
          e3.preventDefault();
          const { pan: newCrop } = restrictPanZoom(
            {
              ...currentState,
              pan: {
                x: currentState.pan.x + this.keyboardStep,
                y: currentState.pan.y
              }
            },
            getImageSizeFromState(currentState),
            currentState.cropRect
          );
          this.options.actions.setPan(newCrop);
          break;
        }
        case "ArrowRight": {
          e3.preventDefault();
          const { pan: newCrop } = restrictPanZoom(
            {
              ...currentState,
              pan: {
                x: currentState.pan.x - this.keyboardStep,
                y: currentState.pan.y
              }
            },
            getImageSizeFromState(currentState),
            currentState.cropRect
          );
          this.options.actions.setPan(newCrop);
          break;
        }
        case "+":
        case "=": {
          e3.preventDefault();
          const newZoom = Math.min(
            this.maxZoom,
            Math.max(this.minZoom, currentState.zoom + 0.5)
          );
          this.options.actions.setZoom(newZoom);
          break;
        }
        case "-":
        case "_": {
          e3.preventDefault();
          const newZoom = Math.min(
            this.maxZoom,
            Math.max(this.minZoom, currentState.zoom - 0.5)
          );
          this.options.actions.setZoom(newZoom);
          break;
        }
        case "r":
        case "R": {
          if (e3.metaKey || e3.ctrlKey || e3.altKey || e3.shiftKey) {
            break;
          }
          e3.preventDefault();
          this.options.actions.snapRotate90(1);
          break;
        }
      }
    }
    /**
     * Clean up all timers, animation frames, and active touch listeners.
     *
     * Must be called when the controller is no longer needed (e.g., on
     * component unmount or element removal).
     */
    destroy() {
      cancelAnimationFrame(this.rafId);
      clearTimeout(this.zoomTimer);
      clearTimeout(this.wheelGestureTimer);
      this.touchCleanup?.();
      this.touchCleanup = null;
      this.pointerCleanup?.();
      this.pointerCleanup = null;
      this.drag = null;
      this.touch = null;
      this.lastTap = null;
    }
  };

  // packages/media-editor/build-module/image-editor/react/hooks/use-interaction.mjs
  var KEYBOARD_INTERACTION_IDLE_MS = 300;
  function isHandledKeyboardPan(event) {
    switch (event.key) {
      case "ArrowUp":
      case "ArrowDown":
      case "ArrowLeft":
      case "ArrowRight":
        return true;
      default:
        return false;
    }
  }
  function useInteraction(state, actions2, containerSize, imageSize, options) {
    const [isDragging, setIsDragging] = (0, import_element121.useState)(false);
    const [isZooming, setIsZooming] = (0, import_element121.useState)(false);
    const [isGestureActive, setIsGestureActive] = (0, import_element121.useState)(false);
    const [isKeyboardPanning, setIsKeyboardPanning] = (0, import_element121.useState)(false);
    const keyboardInteractionTimerRef = (0, import_element121.useRef)();
    const stateRef = (0, import_element121.useRef)(state);
    stateRef.current = state;
    const containerSizeRef = (0, import_element121.useRef)(containerSize);
    containerSizeRef.current = containerSize;
    const imageSizeRef = (0, import_element121.useRef)(imageSize);
    imageSizeRef.current = imageSize;
    const optionsRef = (0, import_element121.useRef)(options);
    optionsRef.current = options;
    const actionsRef = (0, import_element121.useRef)(actions2);
    actionsRef.current = actions2;
    const controllerRef = (0, import_element121.useRef)(null);
    const startPlacementGesture = (0, import_element121.useCallback)(() => {
      setIsGestureActive(true);
    }, []);
    const stopPlacementGesture = (0, import_element121.useCallback)(() => {
      setIsGestureActive(false);
    }, []);
    const signalKeyboardPlacement = (0, import_element121.useCallback)(() => {
      setIsKeyboardPanning(true);
      clearTimeout(keyboardInteractionTimerRef.current);
      keyboardInteractionTimerRef.current = setTimeout(() => {
        setIsKeyboardPanning(false);
      }, KEYBOARD_INTERACTION_IDLE_MS);
    }, []);
    (0, import_element121.useEffect)(() => {
      return () => {
        clearTimeout(keyboardInteractionTimerRef.current);
      };
    }, []);
    (0, import_element121.useEffect)(() => {
      const controller = new InteractionController({
        getState: () => stateRef.current,
        actions: {
          setPan: (pan) => actionsRef.current.setPan(pan),
          setZoom: (zoom) => actionsRef.current.setZoom(zoom),
          setZoomAtPoint: (zoom, pan) => actionsRef.current.setZoomAtPoint(zoom, pan),
          snapRotate90: (direction) => actionsRef.current.snapRotate90(direction)
        },
        getContainerSize: () => containerSizeRef.current,
        getImageSize: () => imageSizeRef.current,
        get minZoom() {
          return optionsRef.current?.minZoom;
        },
        get maxZoom() {
          return optionsRef.current?.maxZoom;
        },
        get zoomSpeed() {
          return optionsRef.current?.zoomSpeed;
        },
        get keyboardStep() {
          return optionsRef.current?.keyboardStep;
        },
        get doubleTapZoom() {
          return optionsRef.current?.doubleTapZoom;
        },
        onGestureStart: () => {
          startPlacementGesture();
          optionsRef.current?.onGestureStart?.();
        },
        onGestureEnd: () => {
          stopPlacementGesture();
          optionsRef.current?.onGestureEnd?.();
        },
        onStatusChange: (status) => {
          setIsDragging(status.isDragging);
          setIsZooming(status.isZooming);
        }
      });
      controllerRef.current = controller;
      return () => {
        controller.destroy();
        controllerRef.current = null;
      };
    }, [startPlacementGesture, stopPlacementGesture]);
    const onPointerDown = (0, import_element121.useCallback)((e3) => {
      const el = e3.currentTarget;
      controllerRef.current?.handlePointerDown(e3.nativeEvent, el);
    }, []);
    const onTouchStart = (0, import_element121.useCallback)((e3) => {
      const el = e3.currentTarget;
      const rect = el.getBoundingClientRect();
      controllerRef.current?.handleTouchStart(
        e3.nativeEvent,
        rect,
        el.ownerDocument
      );
    }, []);
    const onKeyDown = (0, import_element121.useCallback)(
      (e3) => {
        if (isHandledKeyboardPan(e3.nativeEvent)) {
          signalKeyboardPlacement();
        }
        controllerRef.current?.handleKeyDown(e3.nativeEvent);
      },
      [signalKeyboardPlacement]
    );
    const onWheelNative = (0, import_element121.useCallback)((e3) => {
      controllerRef.current?.handleWheel(e3);
    }, []);
    return {
      handlers: {
        onPointerDown,
        onTouchStart,
        onKeyDown
      },
      onWheelNative,
      isDragging,
      isZooming,
      isPlacementActive: isGestureActive || isKeyboardPanning || isZooming
    };
  }

  // packages/media-editor/build-module/image-editor/react/hooks/use-transform-style.mjs
  var import_element122 = __toESM(require_element(), 1);

  // packages/media-editor/build-module/image-editor/core/transform-style.mjs
  function computeTransformStyle(state, imageSize) {
    const translateX = state.pan.x * imageSize.width;
    const translateY = state.pan.y * imageSize.height;
    const rad = degreesToRadians(state.rotation);
    const cos = Math.cos(rad);
    const sin = Math.sin(rad);
    const sx = state.flip.horizontal ? -1 : 1;
    const sy = state.flip.vertical ? -1 : 1;
    const z = state.zoom;
    const a3 = sx * cos * z;
    const b3 = sy * sin * z;
    const c6 = -sx * sin * z;
    const d3 = sy * cos * z;
    return `matrix(${a3}, ${b3}, ${c6}, ${d3}, ${translateX}, ${translateY})`;
  }

  // packages/media-editor/build-module/image-editor/react/hooks/use-transform-style.mjs
  function useTransformStyle(state, imageSize) {
    return (0, import_element122.useMemo)(
      () => computeTransformStyle(state, imageSize),
      [state, imageSize]
    );
  }

  // packages/media-editor/build-module/image-editor/react/hooks/use-aria-announcer.mjs
  var import_element123 = __toESM(require_element(), 1);
  var ARIA_DEBOUNCE_MS = 300;
  function buildAnnouncement(state) {
    const parts = [];
    parts.push(`Zoom ${Math.round(state.zoom * 100)}%`);
    if (state.rotation !== 0) {
      parts.push(`Rotation ${Math.round(state.rotation)} degrees`);
    }
    const cropW = Math.round(state.cropRect.width * 100);
    const cropH = Math.round(state.cropRect.height * 100);
    parts.push(`Crop ${cropW}% by ${cropH}%`);
    return parts.join(", ");
  }
  function useAriaAnnouncer(state) {
    const [ariaMessage, setAriaMessage] = (0, import_element123.useState)("");
    const timerRef = (0, import_element123.useRef)();
    const prevMessageRef = (0, import_element123.useRef)("");
    (0, import_element123.useEffect)(() => {
      clearTimeout(timerRef.current);
      timerRef.current = setTimeout(() => {
        const msg = buildAnnouncement(state);
        if (msg !== prevMessageRef.current) {
          prevMessageRef.current = msg;
          setAriaMessage(msg);
        }
      }, ARIA_DEBOUNCE_MS);
      return () => {
        clearTimeout(timerRef.current);
      };
    }, [
      state.zoom,
      state.rotation,
      state.cropRect.width,
      state.cropRect.height,
      state
    ]);
    return ariaMessage;
  }

  // packages/media-editor/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs
  var import_element124 = __toESM(require_element(), 1);
  var import_i18n119 = __toESM(require_i18n(), 1);

  // packages/media-editor/build-module/image-editor/core/stencil-math.mjs
  var MIN_CROP_SIZE = 0.05;
  function computeFreeResizeRect(drag2, clientX, clientY, imageSize, bounds) {
    const dx = imageSize.width > 0 ? (clientX - drag2.startX) / imageSize.width : 0;
    const dy = imageSize.height > 0 ? (clientY - drag2.startY) / imageSize.height : 0;
    const s3 = drag2.startRect;
    const handle = drag2.handle;
    let edgeTop = s3.y;
    let edgeBottom = s3.y + s3.height;
    let edgeLeft = s3.x;
    let edgeRight = s3.x + s3.width;
    if (handle === "n" || handle === "nw" || handle === "ne") {
      edgeTop = Math.max(
        bounds.minY,
        Math.min(s3.y + dy, edgeBottom - MIN_CROP_SIZE)
      );
    }
    if (handle === "s" || handle === "sw" || handle === "se") {
      edgeBottom = Math.max(
        edgeTop + MIN_CROP_SIZE,
        Math.min(s3.y + s3.height + dy, bounds.maxY)
      );
    }
    if (handle === "w" || handle === "nw" || handle === "sw") {
      edgeLeft = Math.max(
        bounds.minX,
        Math.min(s3.x + dx, edgeRight - MIN_CROP_SIZE)
      );
    }
    if (handle === "e" || handle === "ne" || handle === "se") {
      edgeRight = Math.max(
        edgeLeft + MIN_CROP_SIZE,
        Math.min(s3.x + s3.width + dx, bounds.maxX)
      );
    }
    return {
      x: edgeLeft,
      y: edgeTop,
      width: edgeRight - edgeLeft,
      height: edgeBottom - edgeTop
    };
  }
  function computeLockedResizeRect(drag2, clientX, clientY, imageSize, bounds, normalizedRatio) {
    if (normalizedRatio <= 0 || imageSize.width <= 0 || imageSize.height <= 0) {
      return { ...drag2.startRect };
    }
    const dx = (clientX - drag2.startX) / imageSize.width;
    const dy = (clientY - drag2.startY) / imageSize.height;
    const s3 = drag2.startRect;
    const handle = drag2.handle;
    const anchorX = handle === "nw" || handle === "sw" ? s3.x + s3.width : s3.x;
    const anchorY = handle === "nw" || handle === "ne" ? s3.y + s3.height : s3.y;
    const dirX = handle === "nw" || handle === "sw" ? -1 : 1;
    const dirY = handle === "nw" || handle === "ne" ? -1 : 1;
    const draggedX = (handle === "nw" || handle === "sw" ? s3.x : s3.x + s3.width) + dx;
    const draggedY = (handle === "nw" || handle === "ne" ? s3.y : s3.y + s3.height) + dy;
    let distW = (draggedX - anchorX) * dirX;
    let distH = (draggedY - anchorY) * dirY;
    distW = Math.max(distW, MIN_CROP_SIZE);
    distH = Math.max(distH, MIN_CROP_SIZE);
    const pixelDistW = distW * imageSize.width;
    const pixelDistH = distH * imageSize.height;
    const pixelRatio = normalizedRatio * imageSize.width / imageSize.height;
    if (pixelDistW / pixelDistH > pixelRatio) {
      distH = distW / normalizedRatio;
    } else {
      distW = distH * normalizedRatio;
    }
    const maxW = dirX > 0 ? bounds.maxX - anchorX : anchorX - bounds.minX;
    const maxH = dirY > 0 ? bounds.maxY - anchorY : anchorY - bounds.minY;
    if (distW > maxW) {
      distW = maxW;
      distH = distW / normalizedRatio;
    }
    if (distH > maxH) {
      distH = maxH;
      distW = distH * normalizedRatio;
    }
    distW = Math.max(distW, MIN_CROP_SIZE);
    distH = Math.max(distH, MIN_CROP_SIZE);
    const newX = dirX > 0 ? anchorX : anchorX - distW;
    const newY = dirY > 0 ? anchorY : anchorY - distH;
    return { x: newX, y: newY, width: distW, height: distH };
  }
  function computeShiftLockedResizeRect(drag2, clientX, clientY, imageSize, bounds) {
    const s3 = drag2.startRect;
    const pixelW = s3.width * imageSize.width;
    const pixelH = s3.height * imageSize.height;
    if (pixelH <= 0 || pixelW <= 0) {
      return computeFreeResizeRect(
        drag2,
        clientX,
        clientY,
        imageSize,
        bounds
      );
    }
    const normalizedRatio = s3.width / s3.height;
    const handle = drag2.handle;
    if (handle === "nw" || handle === "ne" || handle === "sw" || handle === "se") {
      return computeLockedResizeRect(
        drag2,
        clientX,
        clientY,
        imageSize,
        bounds,
        normalizedRatio
      );
    }
    const free = computeFreeResizeRect(
      drag2,
      clientX,
      clientY,
      imageSize,
      bounds
    );
    if (handle === "n" || handle === "s") {
      let newHeight2 = free.height;
      let newWidth2 = newHeight2 * normalizedRatio;
      const centerX = s3.x + s3.width / 2;
      const maxWidth = Math.min(centerX - bounds.minX, bounds.maxX - centerX) * 2;
      if (newWidth2 > maxWidth) {
        newWidth2 = maxWidth;
        newHeight2 = newWidth2 / normalizedRatio;
      }
      const minHeight = Math.max(
        MIN_CROP_SIZE,
        MIN_CROP_SIZE / normalizedRatio
      );
      if (newHeight2 < minHeight) {
        newHeight2 = minHeight;
        newWidth2 = newHeight2 * normalizedRatio;
      }
      const newY = handle === "n" ? s3.y + s3.height - newHeight2 : s3.y;
      return {
        x: centerX - newWidth2 / 2,
        y: newY,
        width: newWidth2,
        height: newHeight2
      };
    }
    let newWidth = free.width;
    let newHeight = newWidth / normalizedRatio;
    const centerY = s3.y + s3.height / 2;
    const maxHeight = Math.min(centerY - bounds.minY, bounds.maxY - centerY) * 2;
    if (newHeight > maxHeight) {
      newHeight = maxHeight;
      newWidth = newHeight * normalizedRatio;
    }
    const minWidth = Math.max(MIN_CROP_SIZE, MIN_CROP_SIZE * normalizedRatio);
    if (newWidth < minWidth) {
      newWidth = minWidth;
      newHeight = newWidth / normalizedRatio;
    }
    const newX = handle === "w" ? s3.x + s3.width - newWidth : s3.x;
    return {
      x: newX,
      y: centerY - newHeight / 2,
      width: newWidth,
      height: newHeight
    };
  }

  // packages/media-editor/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs
  var import_jsx_runtime232 = __toESM(require_jsx_runtime(), 1);
  var CORNER_POSITIONS = ["nw", "ne", "se", "sw"];
  var ALL_POSITIONS = [
    "nw",
    "n",
    "ne",
    "e",
    "se",
    "s",
    "sw",
    "w"
  ];
  function getHandleLabel(pos) {
    switch (pos) {
      case "n":
        return (0, import_i18n119.__)("Resize top edge");
      case "s":
        return (0, import_i18n119.__)("Resize bottom edge");
      case "e":
        return (0, import_i18n119.__)("Resize right edge");
      case "w":
        return (0, import_i18n119.__)("Resize left edge");
      case "nw":
        return (0, import_i18n119.__)("Resize top-left corner");
      case "ne":
        return (0, import_i18n119.__)("Resize top-right corner");
      case "sw":
        return (0, import_i18n119.__)("Resize bottom-left corner");
      case "se":
        return (0, import_i18n119.__)("Resize bottom-right corner");
    }
  }
  var KEYBOARD_STEP = 0.01;
  var KEYBOARD_STEP_SHIFT = 0.1;
  var KEYBOARD_SETTLE_DELAY = 500;
  function RectangleStencil({
    cropRect,
    containerSize,
    imageSize,
    onCropChange,
    onResizeStart,
    onResizeEnd,
    aspectRatio,
    freeformCrop = false,
    stencilTransition,
    cropBounds,
    onEscape
  }) {
    const boundsMinX = cropBounds?.minX ?? 0;
    const boundsMinY = cropBounds?.minY ?? 0;
    const boundsMaxX = cropBounds?.maxX ?? 1;
    const boundsMaxY = cropBounds?.maxY ?? 1;
    const bounds = (0, import_element124.useMemo)(
      () => ({
        minX: boundsMinX,
        minY: boundsMinY,
        maxX: boundsMaxX,
        maxY: boundsMaxY
      }),
      [boundsMinX, boundsMinY, boundsMaxX, boundsMaxY]
    );
    const keyboardSettleTimerRef = (0, import_element124.useRef)();
    const keyboardResizeActiveRef = (0, import_element124.useRef)(false);
    const hasLockedRatio = !!(aspectRatio && aspectRatio > 0);
    (0, import_element124.useEffect)(() => {
      return () => {
        clearTimeout(keyboardSettleTimerRef.current);
        keyboardResizeActiveRef.current = false;
      };
    }, []);
    const latestHandlersRef = (0, import_element124.useRef)(null);
    const normalizedRatio = (0, import_element124.useMemo)(() => {
      if (!hasLockedRatio || imageSize.width === 0) {
        return 0;
      }
      return aspectRatio * imageSize.height / imageSize.width;
    }, [aspectRatio, hasLockedRatio, imageSize.width, imageSize.height]);
    const offsetX = (containerSize.width - imageSize.width) / 2;
    const offsetY = (containerSize.height - imageSize.height) / 2;
    const left = offsetX + cropRect.x * imageSize.width;
    const top = offsetY + cropRect.y * imageSize.height;
    const width = cropRect.width * imageSize.width;
    const height = cropRect.height * imageSize.height;
    const handlePointerDown = (0, import_element124.useCallback)(
      (handle, event) => {
        if (event.button !== 0) {
          return;
        }
        event.preventDefault();
        event.stopPropagation();
        const ownerDoc = event.currentTarget.ownerDocument;
        if (ownerDoc.activeElement instanceof HTMLElement) {
          ownerDoc.activeElement.blur();
        }
        const el = event.currentTarget;
        el.setPointerCapture(event.pointerId);
        const drag2 = {
          handle,
          startX: event.clientX,
          startY: event.clientY,
          startRect: { ...cropRect }
        };
        let rafId = 0;
        let latestX = event.clientX;
        let latestY = event.clientY;
        let latestShift = event.shiftKey;
        const onMove = (e3) => {
          const pe = e3;
          latestX = pe.clientX;
          latestY = pe.clientY;
          latestShift = pe.shiftKey;
          if (rafId) {
            return;
          }
          rafId = requestAnimationFrame(() => {
            rafId = 0;
            const h3 = latestHandlersRef.current;
            if (!h3) {
              return;
            }
            let newRect;
            if (h3.hasLockedRatio) {
              newRect = h3.computeLockedRect(drag2, latestX, latestY);
            } else if (latestShift) {
              newRect = h3.computeShiftLockedRect(
                drag2,
                latestX,
                latestY
              );
            } else {
              newRect = h3.computeFreeRect(drag2, latestX, latestY);
            }
            h3.onCropChange(newRect);
          });
        };
        let ended = false;
        const onEnd = () => {
          if (ended) {
            return;
          }
          ended = true;
          if (rafId) {
            cancelAnimationFrame(rafId);
            rafId = 0;
          }
          el.removeEventListener("pointermove", onMove);
          el.removeEventListener("pointerup", onEnd);
          el.removeEventListener("lostpointercapture", onEnd);
          latestHandlersRef.current?.onResizeEnd?.();
          el.focus({ preventScroll: true });
        };
        el.addEventListener("pointermove", onMove);
        el.addEventListener("pointerup", onEnd);
        el.addEventListener("lostpointercapture", onEnd);
        onResizeStart?.();
        clearTimeout(keyboardSettleTimerRef.current);
        keyboardResizeActiveRef.current = false;
      },
      [cropRect, onResizeStart]
    );
    const computeFreeRect = (0, import_element124.useCallback)(
      (drag2, clientX, clientY) => computeFreeResizeRect(drag2, clientX, clientY, imageSize, bounds),
      [imageSize, bounds]
    );
    const computeLockedRect = (0, import_element124.useCallback)(
      (drag2, clientX, clientY) => computeLockedResizeRect(
        drag2,
        clientX,
        clientY,
        imageSize,
        bounds,
        normalizedRatio
      ),
      [imageSize, bounds, normalizedRatio]
    );
    const computeShiftLockedRect = (0, import_element124.useCallback)(
      (drag2, clientX, clientY) => computeShiftLockedResizeRect(
        drag2,
        clientX,
        clientY,
        imageSize,
        bounds
      ),
      [imageSize, bounds]
    );
    latestHandlersRef.current = {
      hasLockedRatio,
      computeLockedRect,
      computeFreeRect,
      computeShiftLockedRect,
      onCropChange,
      onResizeEnd
    };
    const handleKeyDown = (0, import_element124.useCallback)(
      (handle, event) => {
        const key = event.key;
        if (key === "Escape") {
          event.preventDefault();
          event.stopPropagation();
          onEscape?.();
          return;
        }
        if (key !== "ArrowUp" && key !== "ArrowDown" && key !== "ArrowLeft" && key !== "ArrowRight") {
          return;
        }
        event.preventDefault();
        event.stopPropagation();
        if (!keyboardResizeActiveRef.current) {
          keyboardResizeActiveRef.current = true;
          onResizeStart?.();
        }
        const scheduleKeyboardResizeEnd = () => {
          clearTimeout(keyboardSettleTimerRef.current);
          keyboardSettleTimerRef.current = setTimeout(() => {
            keyboardResizeActiveRef.current = false;
            onResizeEnd?.();
          }, KEYBOARD_SETTLE_DELAY);
        };
        const step = event.shiftKey ? KEYBOARD_STEP_SHIFT : KEYBOARD_STEP;
        let dx = 0;
        let dy = 0;
        if (key === "ArrowLeft") {
          dx = -step;
        }
        if (key === "ArrowRight") {
          dx = step;
        }
        if (key === "ArrowUp") {
          dy = -step;
        }
        if (key === "ArrowDown") {
          dy = step;
        }
        if (hasLockedRatio) {
          const syntheticDrag = {
            handle,
            startX: 0,
            startY: 0,
            startRect: { ...cropRect }
          };
          const clientX = dx * imageSize.width;
          const clientY = dy * imageSize.height;
          onCropChange(
            computeLockedRect(syntheticDrag, clientX, clientY)
          );
          scheduleKeyboardResizeEnd();
        } else {
          const syntheticDrag = {
            handle,
            startX: 0,
            startY: 0,
            startRect: { ...cropRect }
          };
          const clientX = dx * imageSize.width;
          const clientY = dy * imageSize.height;
          onCropChange(
            computeFreeRect(syntheticDrag, clientX, clientY)
          );
          scheduleKeyboardResizeEnd();
        }
      },
      [
        cropRect,
        hasLockedRatio,
        imageSize.width,
        imageSize.height,
        computeLockedRect,
        computeFreeRect,
        onCropChange,
        onResizeStart,
        onResizeEnd,
        onEscape
      ]
    );
    if (containerSize.width === 0 || containerSize.height === 0) {
      return null;
    }
    const handles = hasLockedRatio ? CORNER_POSITIONS : ALL_POSITIONS;
    return /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(
      "div",
      {
        className: "wp-media-editor-image-editor__stencil",
        style: {
          left,
          top,
          width,
          height,
          transition: stencilTransition
        },
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
            "div",
            {
              className: "wp-media-editor-image-editor__stencil-rect",
              style: {
                width: "100%",
                height: "100%",
                top: 0,
                left: 0
              }
            }
          ),
          freeformCrop && handles.map((pos) => /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
            "button",
            {
              type: "button",
              className: `wp-media-editor-image-editor__handle wp-media-editor-image-editor__handle--${pos}`,
              onPointerDown: (event) => handlePointerDown(pos, event),
              onTouchStart: (event) => event.stopPropagation(),
              onKeyDown: (event) => handleKeyDown(pos, event),
              "aria-label": getHandleLabel(pos)
            },
            pos
          ))
        ]
      }
    );
  }

  // packages/media-editor/build-module/image-editor/react/components/overlays/dimming-overlay.mjs
  var import_jsx_runtime233 = __toESM(require_jsx_runtime(), 1);
  function DimmingOverlay({
    cropRect,
    containerSize,
    imageSize
  }) {
    if (containerSize.width === 0 || containerSize.height === 0) {
      return null;
    }
    const offsetX = (containerSize.width - imageSize.width) / 2;
    const offsetY = (containerSize.height - imageSize.height) / 2;
    const left = offsetX + cropRect.x * imageSize.width;
    const top = offsetY + cropRect.y * imageSize.height;
    const width = cropRect.width * imageSize.width;
    const height = cropRect.height * imageSize.height;
    return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(
      "div",
      {
        className: "wp-media-editor-image-editor__dimming",
        style: {
          left,
          top,
          width,
          height
        }
      }
    );
  }

  // packages/media-editor/build-module/image-editor/react/components/overlays/grid-overlay.mjs
  var import_jsx_runtime234 = __toESM(require_jsx_runtime(), 1);
  function GridOverlay({
    cropRect,
    containerSize,
    imageSize
  }) {
    if (containerSize.width === 0 || containerSize.height === 0) {
      return null;
    }
    const offsetX = (containerSize.width - imageSize.width) / 2;
    const offsetY = (containerSize.height - imageSize.height) / 2;
    const left = offsetX + cropRect.x * imageSize.width;
    const top = offsetY + cropRect.y * imageSize.height;
    const width = cropRect.width * imageSize.width;
    const height = cropRect.height * imageSize.height;
    const thirdW = width / 3;
    const thirdH = height / 3;
    return /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(
      "div",
      {
        className: "wp-media-editor-image-editor__grid",
        "data-testid": "cropper-grid",
        style: {
          left,
          top,
          width,
          height
        },
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
            "div",
            {
              className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal",
              style: { top: thirdH }
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
            "div",
            {
              className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal",
              style: { top: thirdH * 2 }
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
            "div",
            {
              className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical",
              style: { left: thirdW }
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
            "div",
            {
              className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical",
              style: { left: thirdW * 2 }
            }
          )
        ]
      }
    );
  }

  // packages/media-editor/build-module/image-editor/react/components/cropper.mjs
  var import_jsx_runtime235 = __toESM(require_jsx_runtime(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='d3d6b4ac29']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "d3d6b4ac29");
    style.appendChild(document.createTextNode('.wp-media-editor-image-editor{cursor:grab;height:100%;overflow:hidden;position:relative;touch-action:none;user-select:none;width:100%}.wp-media-editor-image-editor__canvas{inset:22px;position:absolute}.wp-media-editor-image-editor--dragging{cursor:grabbing}.wp-media-editor-image-editor__image{left:0;position:absolute;top:0;transform-origin:center center;will-change:transform}.wp-media-editor-image-editor__stencil{pointer-events:none;position:absolute}.wp-media-editor-image-editor__dimming{box-shadow:0 0 0 9999px #000000b3;pointer-events:none;position:absolute;transition:box-shadow .15s ease}.wp-media-editor-image-editor--dragging .wp-media-editor-image-editor__dimming{box-shadow:0 0 0 9999px #00000080}.wp-media-editor-image-editor__grid{overflow:hidden;pointer-events:none;position:absolute;transition:opacity .15s ease}.wp-media-editor-image-editor__canvas--grid-interactive .wp-media-editor-image-editor__grid{opacity:0;transition-delay:.1s}.wp-media-editor-image-editor__canvas--show-grid .wp-media-editor-image-editor__grid{opacity:1;transition-delay:0s}.wp-media-editor-image-editor__grid-line{background:#fff6;position:absolute}.wp-media-editor-image-editor__grid-line--horizontal{height:1px;left:0;width:100%}.wp-media-editor-image-editor__grid-line--vertical{height:100%;top:0;width:1px}.wp-media-editor-image-editor__stencil-rect{border:1px solid #ffffffb3;box-sizing:border-box;pointer-events:none;position:absolute}.wp-media-editor-image-editor__handle{appearance:none;background:#fff9;border:1px solid #ffffffe6;border-radius:50%;box-sizing:border-box;cursor:default;font:inherit;height:12px;margin:0;padding:0;pointer-events:auto;position:absolute;transition:background-color .15s ease,box-shadow .15s ease;width:12px}.wp-media-editor-image-editor__handle:focus{outline:none}.wp-media-editor-image-editor__handle:focus-visible{background:var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba));border-color:#0000;box-shadow:0 0 0 2px #fff,0 0 0 4px var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba))}.wp-media-editor-image-editor__handle:before{content:"";height:44px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:44px}.wp-media-editor-image-editor__handle--n{cursor:ns-resize;left:50%;margin-left:-6px;top:-6px}.wp-media-editor-image-editor__handle--s{bottom:-6px;cursor:ns-resize;left:50%;margin-left:-6px}.wp-media-editor-image-editor__handle--e{cursor:ew-resize;margin-top:-6px;right:-6px;top:50%}.wp-media-editor-image-editor__handle--w{cursor:ew-resize;left:-6px;margin-top:-6px;top:50%}.wp-media-editor-image-editor__handle--nw{cursor:nwse-resize;left:-6px;top:-6px}.wp-media-editor-image-editor__handle--ne{cursor:nesw-resize;right:-6px;top:-6px}.wp-media-editor-image-editor__handle--sw{bottom:-6px;cursor:nesw-resize;left:-6px}.wp-media-editor-image-editor__handle--se{bottom:-6px;cursor:nwse-resize;right:-6px}'));
    document.head.appendChild(style);
  }
  var CROP_RECT_EPSILON = 1e-6;
  function computeInscribedRect(aspectRatio, visualSize) {
    let w3 = 1;
    let h3 = 1;
    if (aspectRatio && aspectRatio > 0 && visualSize.width > 0) {
      const normalizedRatio = aspectRatio * visualSize.height / visualSize.width;
      if (normalizedRatio <= 1) {
        w3 = normalizedRatio;
      } else {
        h3 = 1 / normalizedRatio;
      }
    }
    return {
      x: (1 - w3) / 2,
      y: (1 - h3) / 2,
      width: w3,
      height: h3
    };
  }
  function CropperInner({
    src,
    controller,
    stencil: StencilComponent = RectangleStencil,
    showGrid = false,
    isPlacementActive = false,
    showDimming = true,
    minZoom,
    maxZoom,
    aspectRatio,
    freeformCrop = false,
    onImageLoaded,
    onStateChange,
    onGestureStart,
    onGestureEnd,
    className
  }, ref) {
    const { state, setImage, setCropRect, settleCrop } = controller;
    const canvasRef = (0, import_element125.useRef)(null);
    const [canvasSize, setCanvasSize] = (0, import_element125.useState)({
      width: 0,
      height: 0
    });
    (0, import_element125.useEffect)(() => {
      const element = canvasRef.current;
      if (!element) {
        return;
      }
      const observer = new ResizeObserver((entries) => {
        for (const entry of entries) {
          const { width, height } = entry.contentRect;
          setCanvasSize((prev) => {
            if (prev.width === width && prev.height === height) {
              return prev;
            }
            return { width, height };
          });
        }
      });
      observer.observe(element);
      return () => {
        observer.disconnect();
      };
    }, []);
    (0, import_element125.useEffect)(() => {
      onStateChange?.(state);
    }, [state, onStateChange]);
    const ariaMessage = useAriaAnnouncer(state);
    const naturalWidth = state.image?.naturalWidth ?? 0;
    const naturalHeight = state.image?.naturalHeight ?? 0;
    const { elementSize, visualSize } = (0, import_element125.useMemo)(
      () => getImageFit(
        canvasSize,
        { width: naturalWidth, height: naturalHeight },
        state.rotation
      ),
      [canvasSize, naturalWidth, naturalHeight, state.rotation]
    );
    (0, import_element125.useEffect)(() => {
      if (freeformCrop || visualSize.width === 0 || visualSize.height === 0) {
        return;
      }
      const rect = computeInscribedRect(aspectRatio, visualSize);
      const current = state.cropRect;
      if (Math.abs(current.x - rect.x) < CROP_RECT_EPSILON && Math.abs(current.y - rect.y) < CROP_RECT_EPSILON && Math.abs(current.width - rect.width) < CROP_RECT_EPSILON && Math.abs(current.height - rect.height) < CROP_RECT_EPSILON) {
        return;
      }
      setCropRect(rect);
    }, [freeformCrop, aspectRatio, visualSize, setCropRect, state.cropRect]);
    const prevAspectRatioRef = (0, import_element125.useRef)(aspectRatio);
    (0, import_element125.useEffect)(() => {
      if (prevAspectRatioRef.current === aspectRatio) {
        return;
      }
      prevAspectRatioRef.current = aspectRatio;
      if (!freeformCrop || visualSize.width === 0 || visualSize.height === 0 || !aspectRatio || aspectRatio <= 0) {
        return;
      }
      setCropRect(computeInscribedRect(aspectRatio, visualSize));
    }, [aspectRatio, freeformCrop, visualSize, setCropRect]);
    const cropBounds = (0, import_element125.useMemo)(() => {
      if (!state.image || elementSize.width === 0) {
        return void 0;
      }
      return getCropBounds(state, elementSize, visualSize, canvasSize);
    }, [state, elementSize, visualSize, canvasSize]);
    const {
      handlers,
      onWheelNative,
      isDragging,
      isZooming,
      isPlacementActive: isInteractionPlacementActive
    } = useInteraction(state, controller, canvasSize, visualSize, {
      minZoom,
      maxZoom,
      onGestureStart,
      onGestureEnd
    });
    (0, import_element125.useEffect)(() => {
      const el = canvasRef.current;
      if (!el) {
        return;
      }
      el.addEventListener("wheel", onWheelNative, {
        passive: false
      });
      return () => {
        el.removeEventListener("wheel", onWheelNative);
      };
    }, [onWheelNative]);
    const transformString = useTransformStyle(state, visualSize);
    const handleImageLoad = (0, import_element125.useCallback)(
      (event) => {
        const img = event.currentTarget;
        const size = {
          width: img.naturalWidth,
          height: img.naturalHeight
        };
        setImage({
          src,
          naturalWidth: size.width,
          naturalHeight: size.height
        });
        onImageLoaded?.(size);
      },
      [src, setImage, onImageLoaded]
    );
    const handleCropChange = (0, import_element125.useCallback)(
      (rect) => {
        setCropRect(rect);
      },
      [setCropRect]
    );
    const [settling, setSettling] = (0, import_element125.useState)(false);
    const settleTimerRef = (0, import_element125.useRef)();
    (0, import_element125.useEffect)(() => {
      return () => {
        clearTimeout(settleTimerRef.current);
      };
    }, []);
    const [isResizing, setIsResizing] = (0, import_element125.useState)(false);
    const isInteractiveGrid = showGrid === "interactive";
    const showInteractiveGrid = isInteractiveGrid && (isInteractionPlacementActive || isResizing || isPlacementActive);
    const handleEscape = (0, import_element125.useCallback)(() => {
      canvasRef.current?.focus({ preventScroll: true });
    }, []);
    const handleResizeStart = (0, import_element125.useCallback)(() => {
      setIsResizing(true);
      onGestureStart?.();
    }, [onGestureStart]);
    const handleResizeEnd = (0, import_element125.useCallback)(() => {
      setIsResizing(false);
      setSettling(true);
      settleCrop();
      onGestureEnd?.();
      clearTimeout(settleTimerRef.current);
      settleTimerRef.current = setTimeout(() => {
        setSettling(false);
      }, 200);
    }, [settleCrop, onGestureEnd]);
    const imageTransition = settling || isZooming ? "transform 150ms linear" : void 0;
    const settleStencilTransition = settling ? "left 150ms linear, top 150ms linear, width 150ms linear, height 150ms linear" : void 0;
    const imageStyle = (0, import_element125.useMemo)(() => {
      if (elementSize.width === 0 || elementSize.height === 0) {
        return {};
      }
      const centerX = (canvasSize.width - elementSize.width) / 2;
      const centerY = (canvasSize.height - elementSize.height) / 2;
      return {
        width: elementSize.width,
        height: elementSize.height,
        maxWidth: elementSize.width,
        maxHeight: elementSize.height,
        left: centerX,
        top: centerY,
        transform: transformString,
        transition: imageTransition
      };
    }, [canvasSize, elementSize, transformString, imageTransition]);
    const setContainerRef = (0, import_element125.useCallback)(
      (element) => {
        if (typeof ref === "function") {
          ref(element);
        } else if (ref) {
          ref.current = element;
        }
      },
      [ref]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
      "div",
      {
        ref: setContainerRef,
        className: clsx_default(
          "wp-media-editor-image-editor",
          isDragging && "wp-media-editor-image-editor--dragging",
          className
        ),
        children: /* @__PURE__ */ (0, import_jsx_runtime235.jsxs)(
          "div",
          {
            ref: canvasRef,
            className: clsx_default(
              "wp-media-editor-image-editor__canvas",
              isInteractiveGrid && "wp-media-editor-image-editor__canvas--grid-interactive",
              showInteractiveGrid && "wp-media-editor-image-editor__canvas--show-grid"
            ),
            tabIndex: 0,
            role: "group",
            "aria-label": (0, import_i18n120.__)("Image editor"),
            ...handlers,
            children: [
              /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
                "img",
                {
                  className: "wp-media-editor-image-editor__image",
                  src,
                  alt: "",
                  onLoad: handleImageLoad,
                  style: imageStyle,
                  draggable: false
                }
              ),
              showDimming && /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
                DimmingOverlay,
                {
                  cropRect: state.cropRect,
                  containerSize: canvasSize,
                  imageSize: visualSize
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
                StencilComponent,
                {
                  cropRect: state.cropRect,
                  containerSize: canvasSize,
                  imageSize: visualSize,
                  onCropChange: handleCropChange,
                  onResizeStart: handleResizeStart,
                  onResizeEnd: handleResizeEnd,
                  onEscape: handleEscape,
                  aspectRatio,
                  freeformCrop,
                  stencilTransition: settleStencilTransition,
                  cropBounds
                }
              ),
              (showGrid === true || isInteractiveGrid) && /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
                GridOverlay,
                {
                  cropRect: state.cropRect,
                  containerSize: canvasSize,
                  imageSize: visualSize
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
                "div",
                {
                  "aria-live": "polite",
                  "aria-atomic": "true",
                  className: "wp-media-editor-image-editor__aria-live",
                  style: {
                    position: "absolute",
                    width: 1,
                    height: 1,
                    padding: 0,
                    margin: -1,
                    overflow: "hidden",
                    clip: "rect(0, 0, 0, 0)",
                    whiteSpace: "nowrap",
                    border: 0
                  },
                  children: ariaMessage
                }
              )
            ]
          }
        )
      }
    );
  }
  var Cropper = (0, import_element125.forwardRef)(
    CropperInner
  );

  // packages/media-editor/build-module/image-editor/react/components/cropper-provider.mjs
  var import_element126 = __toESM(require_element(), 1);
  var import_jsx_runtime236 = __toESM(require_jsx_runtime(), 1);
  var CropperContext = (0, import_element126.createContext)(null);
  function CropperProvider({
    initialState,
    children
  }) {
    const cropperReturn = useCropperState(initialState);
    return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(CropperContext.Provider, { value: cropperReturn, children });
  }
  function useCropper() {
    const context = (0, import_element126.useContext)(CropperContext);
    if (!context) {
      throw new Error("useCropper must be used within a CropperProvider.");
    }
    return context;
  }

  // packages/media-editor/build-module/components/media-editor-canvas/index.mjs
  var import_jsx_runtime237 = __toESM(require_jsx_runtime(), 1);
  function MediaEditorCanvas({
    aspectRatio,
    freeformCrop,
    isPlacementActive = false
  }) {
    const { media } = useMediaEditorContext();
    const controller = useCropper();
    const mediaUrl = media?.source_url;
    const mediaType = getMediaTypeFromMimeType(media?.mime_type);
    if (!mediaUrl || mediaType.type !== "image") {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime237.jsx)("div", { className: "media-editor-canvas", children: /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(
      Cropper,
      {
        src: mediaUrl,
        controller,
        aspectRatio,
        freeformCrop,
        showGrid: "interactive",
        isPlacementActive
      }
    ) });
  }

  // packages/media-editor/build-module/components/media-editor-toolbar/index.mjs
  var import_components87 = __toESM(require_components(), 1);
  var import_i18n121 = __toESM(require_i18n(), 1);
  var import_jsx_runtime238 = __toESM(require_jsx_runtime(), 1);
  function MediaEditorToolbar({
    onReset,
    onPlacementControlInteraction
  }) {
    const { state, setRotation, setFlip, snapRotate90, reset, isDirty } = useCropper();
    const handleReset = () => {
      reset();
      onReset?.();
    };
    const baseAngle = Math.round(state.rotation / 90) * 90;
    const singleFlip = state.flip.horizontal !== state.flip.vertical;
    const visualDir = singleFlip ? -1 : 1;
    const fineOffset = (state.rotation - baseAngle) * visualDir;
    const handleRotationSlider = (value) => {
      if (value === void 0) {
        return;
      }
      const EPS = 0.01;
      const clamped = Math.max(
        -MAX_ROTATION_OFFSET + EPS,
        Math.min(MAX_ROTATION_OFFSET - EPS, value)
      );
      onPlacementControlInteraction?.();
      setRotation(baseAngle + clamped * visualDir);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime238.jsxs)(
      Stack,
      {
        className: "media-editor-toolbar",
        direction: "row",
        align: "center",
        justify: "center",
        gap: "sm",
        wrap: "wrap",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(
            import_components87.Button,
            {
              size: "compact",
              icon: rotate_left_default,
              label: (0, import_i18n121.__)("Rotate 90\xB0 counter-clockwise"),
              showTooltip: true,
              onClick: () => snapRotate90(-1)
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(
            import_components87.Button,
            {
              size: "compact",
              icon: rotate_right_default,
              label: (0, import_i18n121.__)("Rotate 90\xB0 clockwise"),
              showTooltip: true,
              onClick: () => snapRotate90(1)
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(
            import_components87.Button,
            {
              size: "compact",
              icon: flip_horizontal_default,
              label: (0, import_i18n121.__)("Flip horizontal"),
              showTooltip: true,
              isPressed: state.flip.horizontal,
              onClick: () => setFlip({
                horizontal: !state.flip.horizontal,
                vertical: state.flip.vertical
              })
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(
            import_components87.Button,
            {
              size: "compact",
              icon: flip_vertical_default,
              label: (0, import_i18n121.__)("Flip vertical"),
              showTooltip: true,
              isPressed: state.flip.vertical,
              onClick: () => setFlip({
                horizontal: state.flip.horizontal,
                vertical: !state.flip.vertical
              })
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime238.jsx)("div", { className: "media-editor-toolbar__rotation-slider", children: /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(
            import_components87.RangeControl,
            {
              __next40pxDefaultSize: true,
              __nextHasNoMarginBottom: true,
              label: (0, import_i18n121.__)("Fine rotation"),
              hideLabelFromVision: true,
              min: -MAX_ROTATION_OFFSET,
              max: MAX_ROTATION_OFFSET,
              step: 0.5,
              value: fineOffset,
              onChange: handleRotationSlider,
              showTooltip: false
            }
          ) }),
          /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(
            import_components87.Button,
            {
              size: "compact",
              variant: "tertiary",
              disabled: !isDirty,
              accessibleWhenDisabled: true,
              onClick: handleReset,
              children: (0, import_i18n121.__)("Reset")
            }
          )
        ]
      }
    );
  }

  // packages/media-editor/build-module/components/media-editor-crop-panel/index.mjs
  var import_components88 = __toESM(require_components(), 1);
  var import_i18n122 = __toESM(require_i18n(), 1);
  var import_jsx_runtime239 = __toESM(require_jsx_runtime(), 1);
  function resolveAspectRatio(value, imageAspectRatio) {
    const num = parseFloat(value);
    if (num === 0) {
      return void 0;
    }
    if (num === ORIGINAL_ASPECT_RATIO && imageAspectRatio) {
      return imageAspectRatio;
    }
    if (num > 0) {
      return num;
    }
    return void 0;
  }
  function MediaEditorCropPanel({
    aspectRatioValue,
    onAspectRatioChange,
    freeformCrop,
    onFreeformChange,
    onPlacementControlInteraction,
    aspectRatioPresets
  }) {
    const { state, setZoom } = useCropper();
    const aspectRatioOptions = [
      ...DEFAULT_ASPECT_RATIOS.filter((preset) => preset.value <= 0),
      ...aspectRatioPresets ?? DEFAULT_ASPECT_RATIOS.filter((preset) => preset.value > 0)
    ];
    return /* @__PURE__ */ (0, import_jsx_runtime239.jsxs)(Stack, { direction: "column", gap: "md", children: [
      /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(
        import_components88.RangeControl,
        {
          __next40pxDefaultSize: true,
          __nextHasNoMarginBottom: true,
          label: (0, import_i18n122.__)("Zoom"),
          min: MIN_ZOOM,
          max: MAX_ZOOM,
          step: 0.1,
          value: state.zoom,
          onChange: (value) => {
            onPlacementControlInteraction?.();
            setZoom(typeof value === "number" ? value : MIN_ZOOM);
          },
          renderTooltipContent: (value) => {
            const zoom = typeof value === "number" ? value : MIN_ZOOM;
            return (0, import_i18n122.sprintf)(
              /* translators: %d: zoom level as a percentage. */
              (0, import_i18n122.__)("%d%%"),
              Math.round(zoom * 100)
            );
          }
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(
        import_components88.SelectControl,
        {
          __next40pxDefaultSize: true,
          __nextHasNoMarginBottom: true,
          label: (0, import_i18n122.__)("Aspect ratio"),
          value: aspectRatioValue,
          onChange: onAspectRatioChange,
          options: aspectRatioOptions.map((preset) => ({
            label: preset.label,
            value: preset.value.toString()
          }))
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(
        import_components88.ToggleControl,
        {
          __nextHasNoMarginBottom: true,
          label: (0, import_i18n122.__)("Freeform crop"),
          help: (0, import_i18n122.__)(
            "Drag the crop edges to resize freely. When off, the crop is fixed to the selected ratio."
          ),
          checked: freeformCrop,
          onChange: onFreeformChange
        }
      )
    ] });
  }

  // packages/media-editor/build-module/components/media-editor-modal/build-modifiers.mjs
  var CROP_TOLERANCE = 0.1;
  function buildModifiers(state, imageSize) {
    const modifiers = [];
    if (imageSize.width === 0 || imageSize.height === 0) {
      return modifiers;
    }
    const { cropRect, pan, zoom, flip } = state;
    const hasFlipH = flip.horizontal;
    const hasFlipV = flip.vertical;
    if (hasFlipH || hasFlipV) {
      modifiers.push({
        type: "flip",
        args: { flip: { horizontal: hasFlipH, vertical: hasFlipV } }
      });
    }
    const rawAngle = (state.rotation % 360 + 360) % 360;
    const singleAxisFlip = hasFlipH !== hasFlipV;
    const signedAngle2 = singleAxisFlip ? (360 - rawAngle) % 360 : rawAngle;
    if (signedAngle2 !== 0) {
      modifiers.push({ type: "rotate", args: { angle: signedAngle2 } });
    }
    const snapRotation = Math.round(state.rotation / 90) * 90;
    const { width: snapW, height: snapH } = getRotatedBBox(
      imageSize.width,
      imageSize.height,
      snapRotation
    );
    const { width: fullW, height: fullH } = getRotatedBBox(
      imageSize.width,
      imageSize.height,
      state.rotation
    );
    const imgLeft = 0.5 + pan.x - zoom / 2;
    const imgTop = 0.5 + pan.y - zoom / 2;
    const snapX = (cropRect.x - imgLeft) / zoom * snapW;
    const snapY = (cropRect.y - imgTop) / zoom * snapH;
    const widthPx = cropRect.width / zoom * snapW;
    const heightPx = cropRect.height / zoom * snapH;
    const offsetX = (fullW - snapW) / 2;
    const offsetY = (fullH - snapH) / 2;
    const fullX = snapX + offsetX;
    const fullY = snapY + offsetY;
    const leftPct = fullX / fullW * 100;
    const topPct = fullY / fullH * 100;
    const widthPct = widthPx / fullW * 100;
    const heightPct = heightPx / fullH * 100;
    const coversFullFrame = leftPct <= CROP_TOLERANCE && topPct <= CROP_TOLERANCE && widthPct >= 100 - CROP_TOLERANCE && heightPct >= 100 - CROP_TOLERANCE;
    if (!coversFullFrame) {
      modifiers.push({
        type: "crop",
        args: {
          left: leftPct,
          top: topPct,
          width: widthPct,
          height: heightPct
        }
      });
    }
    return modifiers;
  }

  // packages/media-editor/build-module/components/media-editor-modal/index.mjs
  var import_jsx_runtime240 = __toESM(require_jsx_runtime(), 1);
  var METADATA_EDIT_KEYS = [
    "title",
    "caption",
    "description",
    "alt_text",
    "post"
  ];
  var NOTICES_CONTEXT = "media-editor";
  var PLACEMENT_CONTROL_IDLE_MS = 300;
  var { Tabs } = unlock4(import_components89.privateApis);
  function MediaEditorModalSidebar({ tabs }) {
    const tabsContextValue = (0, import_element127.useContext)(Tabs.Context);
    return /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
      complementary_area_default,
      {
        scope: "media-editor",
        identifier: "media-editor/details",
        title: (0, import_i18n123.__)("Details"),
        icon: drawer_right_default,
        isActiveByDefault: true,
        className: "media-editor-modal__sidebar",
        panelClassName: "media-editor-modal__sidebar-panel",
        headerClassName: "media-editor-modal__sidebar-header",
        header: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(Tabs.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(Tabs.TabList, { children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(Tabs.Tab, { tabId: tab.id, children: tab.title }, tab.id)) }) }),
        children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(Tabs.Context.Provider, { value: tabsContextValue, children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
          Tabs.TabPanel,
          {
            tabId: tab.id,
            focusable: false,
            children: tab.panel
          },
          tab.id
        )) })
      }
    );
  }
  function HeaderActions({
    isSaving,
    hasMedia,
    hasChanges,
    onCancel,
    onSave
  }) {
    const saveDisabled = isSaving || !hasMedia || !hasChanges;
    return /* @__PURE__ */ (0, import_jsx_runtime240.jsxs)(
      import_components89.Flex,
      {
        className: "media-editor-modal__header-actions",
        justify: "flex-end",
        expanded: false,
        gap: 2,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(pinned_items_default.Slot, { scope: "media-editor" }),
          /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
            import_components89.Button,
            {
              size: "compact",
              variant: "tertiary",
              onClick: onCancel,
              disabled: isSaving,
              accessibleWhenDisabled: true,
              children: (0, import_i18n123.__)("Cancel")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
            import_components89.Button,
            {
              size: "compact",
              variant: "primary",
              onClick: onSave,
              isBusy: isSaving,
              disabled: saveDisabled,
              accessibleWhenDisabled: true,
              children: (0, import_i18n123.__)("Save")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
            import_components89.Button,
            {
              size: "compact",
              icon: close_default,
              label: (0, import_i18n123.__)("Close"),
              onClick: onCancel,
              disabled: isSaving,
              accessibleWhenDisabled: true
            }
          )
        ]
      }
    );
  }
  function MediaEditorModalContent({
    fields: fields3,
    id,
    media,
    hasEdits,
    aspectRatioPresets,
    onUpdate
  }) {
    const cropper = useCropper();
    const hasChanges = cropper.isDirty || hasEdits;
    const registry = (0, import_data39.useRegistry)();
    const {
      clearEntityRecordEdits,
      editEntityRecord,
      receiveEntityRecords,
      saveEditedEntityRecord
    } = (0, import_data39.useDispatch)(import_core_data25.store);
    const { closeMediaEditorModal: closeMediaEditorModal2 } = (0, import_data39.useDispatch)(store);
    const { createErrorNotice, removeAllNotices } = (0, import_data39.useDispatch)(import_notices14.store);
    const [isSaving, setIsSaving] = (0, import_element127.useState)(false);
    const [isDiscardDialogOpen, setIsDiscardDialogOpen] = (0, import_element127.useState)(false);
    const [isPlacementActive, setIsPlacementActive] = (0, import_element127.useState)(false);
    const placementControlTimerRef = (0, import_element127.useRef)();
    const [aspectRatioValue, setAspectRatioValue] = (0, import_element127.useState)("0");
    const [freeformCrop, setFreeformCrop] = (0, import_element127.useState)(true);
    const signalPlacementControlInteraction = (0, import_element127.useCallback)(() => {
      setIsPlacementActive(true);
      clearTimeout(placementControlTimerRef.current);
      placementControlTimerRef.current = setTimeout(() => {
        setIsPlacementActive(false);
      }, PLACEMENT_CONTROL_IDLE_MS);
    }, []);
    (0, import_element127.useEffect)(() => {
      return () => {
        clearTimeout(placementControlTimerRef.current);
      };
    }, []);
    (0, import_element127.useEffect)(() => {
      setAspectRatioValue("0");
      setFreeformCrop(true);
    }, [id]);
    const mediaType = getMediaTypeFromMimeType(media?.mime_type).type;
    const isImage = !!media && mediaType === "image";
    const imageAspectRatio = (0, import_element127.useMemo)(() => {
      if (!isImage) {
        return null;
      }
      const naturalWidth = Number(media?.media_details?.width);
      const naturalHeight = Number(media?.media_details?.height);
      if (Number.isFinite(naturalWidth) && Number.isFinite(naturalHeight) && naturalHeight > 0) {
        return naturalWidth / naturalHeight;
      }
      return null;
    }, [isImage, media]);
    const tabs = (0, import_element127.useMemo)(() => {
      const detailsTab = {
        id: "details",
        title: (0, import_i18n123.__)("Details"),
        panel: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
          Stack,
          {
            className: "media-editor-modal__panel",
            direction: "column",
            gap: "lg",
            children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(MediaForm, {})
          }
        )
      };
      if (!isImage) {
        return [detailsTab];
      }
      return [
        {
          id: "crop",
          title: (0, import_i18n123.__)("Crop"),
          panel: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
            Stack,
            {
              className: "media-editor-modal__panel",
              direction: "column",
              gap: "lg",
              children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
                MediaEditorCropPanel,
                {
                  aspectRatioValue,
                  onAspectRatioChange: setAspectRatioValue,
                  freeformCrop,
                  onFreeformChange: setFreeformCrop,
                  onPlacementControlInteraction: signalPlacementControlInteraction,
                  aspectRatioPresets
                }
              )
            }
          )
        },
        detailsTab
      ];
    }, [
      isImage,
      aspectRatioValue,
      freeformCrop,
      aspectRatioPresets,
      signalPlacementControlInteraction
    ]);
    const handleChange = (updates) => {
      editEntityRecord("postType", "attachment", id, updates);
    };
    const discardAndClose = () => {
      removeAllNotices("snackbar", NOTICES_CONTEXT);
      clearEntityRecordEdits("postType", "attachment", id);
      closeMediaEditorModal2();
    };
    const handleRequestClose = () => {
      if (isSaving) {
        return;
      }
      if (hasChanges) {
        setIsDiscardDialogOpen(true);
        return;
      }
      discardAndClose();
    };
    const handleSave = async () => {
      removeAllNotices("snackbar", NOTICES_CONTEXT);
      setIsSaving(true);
      try {
        let saved;
        const modifiers = cropper.isDirty && cropper.state.image ? buildModifiers(cropper.state, {
          width: cropper.state.image.naturalWidth,
          height: cropper.state.image.naturalHeight
        }) : [];
        if (modifiers.length > 0) {
          const pendingEdits = registry.select(import_core_data25.store).getEntityRecordNonTransientEdits(
            "postType",
            "attachment",
            id
          );
          const metadataEdits = {};
          for (const key of METADATA_EDIT_KEYS) {
            if (pendingEdits && key in pendingEdits) {
              metadataEdits[key] = pendingEdits[key];
            }
          }
          saved = await (0, import_api_fetch3.default)({
            path: `/wp/v2/media/${id}/edit`,
            method: "POST",
            data: {
              src: media?.source_url,
              modifiers,
              ...metadataEdits
            }
          });
          if (saved) {
            receiveEntityRecords(
              "postType",
              "attachment",
              saved,
              void 0,
              true
            );
          }
        } else {
          saved = await saveEditedEntityRecord(
            "postType",
            "attachment",
            id
          );
        }
        const next = saved ?? media;
        if (next && next.id !== id) {
          clearEntityRecordEdits("postType", "attachment", id);
        }
        if (next && next.id && onUpdate) {
          onUpdate({ id: next.id, url: next.source_url });
        }
        closeMediaEditorModal2();
      } catch (error2) {
        const message2 = error2 instanceof Error ? error2.message : error2?.message ?? (0, import_i18n123.__)("An unknown error occurred.");
        createErrorNotice(
          (0, import_i18n123.sprintf)(
            /* translators: %s: Error message. */
            (0, import_i18n123.__)("Could not save image. %s"),
            message2
          ),
          { type: "snackbar", context: NOTICES_CONTEXT }
        );
      } finally {
        setIsSaving(false);
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime240.jsxs)(
      import_components89.Modal,
      {
        className: "media-editor-modal",
        title: (0, import_i18n123.__)("Edit media"),
        size: "fill",
        isDismissible: false,
        shouldCloseOnClickOutside: !hasChanges && !isSaving,
        onKeyDown: (event) => {
          if (event.code !== "Escape" && event.key !== "Escape") {
            return;
          }
          if (isSaving) {
            event.preventDefault();
            return;
          }
          if (hasChanges) {
            event.preventDefault();
            setIsDiscardDialogOpen(true);
          }
        },
        onRequestClose: handleRequestClose,
        headerActions: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
          HeaderActions,
          {
            isSaving,
            hasMedia: !!media,
            hasChanges,
            onCancel: handleRequestClose,
            onSave: handleSave
          }
        ),
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime240.jsxs)(
            MediaEditorProvider,
            {
              value: media ?? void 0,
              onChange: handleChange,
              settings: { fields: fields3 },
              children: [
                !media ? /* @__PURE__ */ (0, import_jsx_runtime240.jsx)("div", { className: "media-editor-modal__loading", children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(import_components89.Spinner, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime240.jsxs)(import_jsx_runtime240.Fragment, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(Tabs, { children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(MediaEditorModalSidebar, { tabs }) }),
                  /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
                    interface_skeleton_default,
                    {
                      className: "media-editor-modal__skeleton",
                      content: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)("div", { className: "media-editor-modal__canvas", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
                        MediaEditorCanvas,
                        {
                          aspectRatio: resolveAspectRatio(
                            aspectRatioValue,
                            imageAspectRatio
                          ),
                          freeformCrop,
                          isPlacementActive
                        }
                      ) : /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(MediaPreview2, {}) }),
                      footer: isImage ? /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
                        MediaEditorToolbar,
                        {
                          onReset: () => {
                            setAspectRatioValue("0");
                            setFreeformCrop(true);
                          },
                          onPlacementControlInteraction: signalPlacementControlInteraction
                        }
                      ) : void 0,
                      sidebar: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(complementary_area_default.Slot, { scope: "media-editor" })
                    }
                  )
                ] }),
                /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
                  import_components89.__experimentalConfirmDialog,
                  {
                    isOpen: isDiscardDialogOpen,
                    confirmButtonText: (0, import_i18n123.__)("Discard"),
                    cancelButtonText: (0, import_i18n123.__)("Keep editing"),
                    onCancel: () => setIsDiscardDialogOpen(false),
                    onConfirm: () => {
                      setIsDiscardDialogOpen(false);
                      discardAndClose();
                    },
                    children: (0, import_i18n123.__)(
                      "Are you sure you want to discard your unsaved changes?"
                    )
                  }
                )
              ]
            }
          ),
          (0, import_element127.createPortal)(
            /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
              import_notices14.SnackbarNotices,
              {
                className: "media-editor-modal__snackbar",
                context: NOTICES_CONTEXT
              }
            ),
            document.body
          )
        ]
      }
    );
  }
  function MediaEditorModal({
    fields: fields3 = [],
    aspectRatioPresets
  }) {
    const { isModalOpen, id, onUpdate } = (0, import_data39.useSelect)((select7) => {
      const { isOpen: isOpen2, getId: getId2, getOnUpdate: getOnUpdate2 } = select7(store);
      return {
        isModalOpen: isOpen2(),
        id: getId2(),
        onUpdate: getOnUpdate2()
      };
    }, []);
    const { media, hasEdits } = (0, import_data39.useSelect)(
      (select7) => {
        if (!id) {
          return { media: null, hasEdits: false };
        }
        const { getEditedEntityRecord, hasEditsForEntityRecord } = select7(import_core_data25.store);
        return {
          media: getEditedEntityRecord(
            "postType",
            "attachment",
            id
          ),
          hasEdits: hasEditsForEntityRecord(
            "postType",
            "attachment",
            id
          )
        };
      },
      [id]
    );
    if (!isModalOpen || !id) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(CropperProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
      MediaEditorModalContent,
      {
        fields: fields3,
        id,
        media,
        hasEdits,
        aspectRatioPresets,
        onUpdate
      }
    ) }, id);
  }

  // packages/media-editor/build-module/private-apis.mjs
  var privateApis12 = {};
  lock4(privateApis12, {
    store,
    MediaEditorModal
  });

  // packages/editor/build-module/components/media-categories/index.mjs
  var import_i18n124 = __toESM(require_i18n(), 1);
  var import_data40 = __toESM(require_data(), 1);
  var import_html_entities7 = __toESM(require_html_entities(), 1);
  var import_core_data26 = __toESM(require_core_data(), 1);
  var getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`;
  var getExternalLinkAttributes = (url) => `href="${url}" target="_blank" rel="noopener"`;
  var getOpenverseLicense = (license, licenseVersion) => {
    let licenseName = license.trim();
    if (license !== "pdm") {
      licenseName = license.toUpperCase().replace("SAMPLING", "Sampling");
    }
    if (licenseVersion) {
      licenseName += ` ${licenseVersion}`;
    }
    if (!["pdm", "cc0"].includes(license)) {
      licenseName = `CC ${licenseName}`;
    }
    return licenseName;
  };
  var getOpenverseCaption = (item) => {
    const {
      title,
      foreign_landing_url: foreignLandingUrl,
      creator,
      creator_url: creatorUrl,
      license,
      license_version: licenseVersion,
      license_url: licenseUrl
    } = item;
    const fullLicense = getOpenverseLicense(license, licenseVersion);
    const _creator = (0, import_html_entities7.decodeEntities)(creator);
    let _caption;
    if (_creator) {
      _caption = title ? (0, import_i18n124.sprintf)(
        // translators: %1s: Title of a media work from Openverse; %2$s: Name of the work's creator; %3s: Work's licence e.g: "CC0 1.0".
        (0, import_i18n124._x)('"%1$s" by %2$s/ %3$s', "caption"),
        getExternalLink(
          foreignLandingUrl,
          (0, import_html_entities7.decodeEntities)(title)
        ),
        creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator,
        licenseUrl ? getExternalLink(
          `${licenseUrl}?ref=openverse`,
          fullLicense
        ) : fullLicense
      ) : (0, import_i18n124.sprintf)(
        // translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: "CC0 1.0".
        (0, import_i18n124._x)("<a %1$s>Work</a> by %2$s/ %3$s", "caption"),
        getExternalLinkAttributes(foreignLandingUrl),
        creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator,
        licenseUrl ? getExternalLink(
          `${licenseUrl}?ref=openverse`,
          fullLicense
        ) : fullLicense
      );
    } else {
      _caption = title ? (0, import_i18n124.sprintf)(
        // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
        (0, import_i18n124._x)('"%1$s"/ %2$s', "caption"),
        getExternalLink(
          foreignLandingUrl,
          (0, import_html_entities7.decodeEntities)(title)
        ),
        licenseUrl ? getExternalLink(
          `${licenseUrl}?ref=openverse`,
          fullLicense
        ) : fullLicense
      ) : (0, import_i18n124.sprintf)(
        // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
        (0, import_i18n124._x)("<a %1$s>Work</a>/ %2$s", "caption"),
        getExternalLinkAttributes(foreignLandingUrl),
        licenseUrl ? getExternalLink(
          `${licenseUrl}?ref=openverse`,
          fullLicense
        ) : fullLicense
      );
    }
    return _caption.replace(/\s{2}/g, " ");
  };
  var coreMediaFetch = async (query = {}) => {
    const mediaItems = await (0, import_data40.resolveSelect)(import_core_data26.store).getEntityRecords(
      "postType",
      "attachment",
      {
        ...query,
        orderBy: !!query?.search ? "relevance" : "date"
      }
    );
    return mediaItems.map((mediaItem) => ({
      ...mediaItem,
      alt: mediaItem.alt_text,
      url: mediaItem.source_url,
      previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
      caption: mediaItem.caption?.raw
    }));
  };
  var inserterMediaCategories = [
    {
      name: "images",
      labels: {
        name: (0, import_i18n124.__)("Images"),
        search_items: (0, import_i18n124.__)("Search images")
      },
      mediaType: "image",
      async fetch(query = {}) {
        return coreMediaFetch({ ...query, media_type: "image" });
      }
    },
    {
      name: "videos",
      labels: {
        name: (0, import_i18n124.__)("Videos"),
        search_items: (0, import_i18n124.__)("Search videos")
      },
      mediaType: "video",
      async fetch(query = {}) {
        return coreMediaFetch({ ...query, media_type: "video" });
      }
    },
    {
      name: "audio",
      labels: {
        name: (0, import_i18n124.__)("Audio"),
        search_items: (0, import_i18n124.__)("Search audio")
      },
      mediaType: "audio",
      async fetch(query = {}) {
        return coreMediaFetch({ ...query, media_type: "audio" });
      }
    },
    {
      name: "openverse",
      labels: {
        name: (0, import_i18n124.__)("Openverse"),
        search_items: (0, import_i18n124.__)("Search Openverse")
      },
      mediaType: "image",
      async fetch(query = {}) {
        const defaultArgs = {
          mature: false,
          excluded_source: "flickr,inaturalist,wikimedia",
          license: "pdm,cc0"
        };
        const finalQuery = { ...query, ...defaultArgs };
        const mapFromInserterMediaRequest = {
          per_page: "page_size",
          search: "q"
        };
        const url = new URL("https://api.openverse.org/v1/images/");
        Object.entries(finalQuery).forEach(([key, value]) => {
          const queryKey = mapFromInserterMediaRequest[key] || key;
          url.searchParams.set(queryKey, value);
        });
        const response = await window.fetch(url, {
          headers: {
            "User-Agent": "WordPress/inserter-media-fetch"
          }
        });
        const jsonResponse = await response.json();
        const results = jsonResponse.results;
        return results.map((result) => ({
          ...result,
          // This is a temp solution for better titles, until Openverse API
          // completes the cleaning up of some titles of their upstream data.
          title: result.title?.toLowerCase().startsWith("file:") ? result.title.slice(5) : result.title,
          sourceId: result.id,
          id: void 0,
          caption: getOpenverseCaption(result),
          previewUrl: result.thumbnail
        }));
      },
      getReportUrl: ({ sourceId }) => `https://wordpress.org/openverse/image/${sourceId}/report/`,
      isExternalResource: true
    }
  ];
  var media_categories_default = inserterMediaCategories;

  // node_modules/uuid/dist/esm-browser/rng.js
  var getRandomValues;
  var rnds8 = new Uint8Array(16);
  function rng() {
    if (!getRandomValues) {
      getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
      if (!getRandomValues) {
        throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
      }
    }
    return getRandomValues(rnds8);
  }

  // node_modules/uuid/dist/esm-browser/stringify.js
  var byteToHex = [];
  for (let i3 = 0; i3 < 256; ++i3) {
    byteToHex.push((i3 + 256).toString(16).slice(1));
  }
  function unsafeStringify(arr, offset = 0) {
    return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
  }

  // node_modules/uuid/dist/esm-browser/native.js
  var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
  var native_default = {
    randomUUID
  };

  // node_modules/uuid/dist/esm-browser/v4.js
  function v4(options, buf, offset) {
    if (native_default.randomUUID && !buf && !options) {
      return native_default.randomUUID();
    }
    options = options || {};
    const rnds = options.random || (options.rng || rng)();
    rnds[6] = rnds[6] & 15 | 64;
    rnds[8] = rnds[8] & 63 | 128;
    if (buf) {
      offset = offset || 0;
      for (let i3 = 0; i3 < 16; ++i3) {
        buf[offset + i3] = rnds[i3];
      }
      return buf;
    }
    return unsafeStringify(rnds);
  }
  var v4_default = v4;

  // packages/editor/build-module/utils/media-upload/index.mjs
  var import_data41 = __toESM(require_data(), 1);
  var import_core_data27 = __toESM(require_core_data(), 1);
  var import_media_utils2 = __toESM(require_media_utils(), 1);
  var import_upload_media = __toESM(require_upload_media(), 1);
  var noop5 = () => {
  };
  function mediaUpload({
    additionalData = {},
    allowedTypes,
    filesList,
    maxUploadFileSize,
    onError = noop5,
    onFileChange,
    onSuccess,
    multiple = true
  }) {
    const { receiveEntityRecords } = (0, import_data41.dispatch)(import_core_data27.store);
    const { getCurrentPost: getCurrentPost2, getEditorSettings: getEditorSettings2 } = (0, import_data41.select)(store3);
    const {
      lockPostAutosaving: lockPostAutosaving2,
      unlockPostAutosaving: unlockPostAutosaving2,
      lockPostSaving: lockPostSaving2,
      unlockPostSaving: unlockPostSaving2
    } = (0, import_data41.dispatch)(store3);
    const wpAllowedMimeTypes = getEditorSettings2().allowedMimeTypes;
    const isClientSideMediaActive = window.__clientSideMediaProcessing && (0, import_upload_media.isClientSideMediaSupported)();
    const lockKey = `image-upload-${v4_default()}`;
    maxUploadFileSize = maxUploadFileSize || getEditorSettings2().maxUploadFileSize;
    const currentPost = getCurrentPost2();
    const currentPostId = typeof currentPost?.id === "number" ? currentPost.id : currentPost?.wp_id;
    const clearSaveLock = () => {
      unlockPostSaving2(lockKey);
      unlockPostAutosaving2(lockKey);
    };
    if (!isClientSideMediaActive) {
      lockPostSaving2(lockKey);
      lockPostAutosaving2(lockKey);
    }
    const postData = currentPostId ? { post: currentPostId } : {};
    (0, import_media_utils2.uploadMedia)({
      allowedTypes,
      filesList,
      onFileChange: (files) => {
        onFileChange?.(files);
        const entityFiles = files.filter((_file) => _file?.id);
        if (entityFiles?.length) {
          const invalidateCache = true;
          receiveEntityRecords(
            "postType",
            "attachment",
            entityFiles,
            void 0,
            invalidateCache
          );
        }
        if (!isClientSideMediaActive && entityFiles.length === files.length) {
          clearSaveLock();
        }
      },
      onSuccess,
      additionalData: {
        ...postData,
        ...additionalData
      },
      maxUploadFileSize,
      onError: ({ message: message2 }) => {
        if (!isClientSideMediaActive) {
          clearSaveLock();
        }
        onError(message2);
      },
      wpAllowedMimeTypes,
      multiple
    });
  }

  // packages/editor/build-module/utils/url.mjs
  var import_url11 = __toESM(require_url(), 1);
  var import_deprecated8 = __toESM(require_deprecated(), 1);
  function cleanForSlug3(string) {
    (0, import_deprecated8.default)("wp.editor.cleanForSlug", {
      since: "12.7",
      plugin: "Gutenberg",
      alternative: "wp.url.cleanForSlug"
    });
    return (0, import_url11.cleanForSlug)(string);
  }

  // packages/editor/build-module/utils/media-upload/on-success.mjs
  var import_data42 = __toESM(require_data(), 1);
  var import_core_data28 = __toESM(require_core_data(), 1);
  function mediaUploadOnSuccess(attachments) {
    const { invalidateResolution } = (0, import_data42.dispatch)(import_core_data28.store);
    for (const attachment of attachments) {
      if (attachment.id) {
        invalidateResolution("getEntityRecord", [
          "postType",
          "attachment",
          attachment.id,
          { context: "view" }
        ]);
        invalidateResolution("getEntityRecord", [
          "postType",
          "attachment",
          attachment.id
        ]);
      }
    }
  }

  // packages/editor/build-module/utils/media-sideload/index.mjs
  var import_media_utils3 = __toESM(require_media_utils(), 1);
  var { sideloadMedia: mediaSideload } = unlock(import_media_utils3.privateApis);
  var media_sideload_default = mediaSideload;

  // packages/editor/build-module/utils/media-finalize/index.mjs
  var import_api_fetch4 = __toESM(require_api_fetch(), 1);
  async function mediaFinalize(id, subSizes = []) {
    await (0, import_api_fetch4.default)({
      path: `/wp/v2/media/${id}/finalize`,
      method: "POST",
      data: { sub_sizes: subSizes }
    });
  }

  // packages/editor/build-module/components/global-styles-provider/index.mjs
  var import_block_editor5 = __toESM(require_block_editor(), 1);
  var import_core_data29 = __toESM(require_core_data(), 1);
  var import_data44 = __toESM(require_data(), 1);
  var import_element128 = __toESM(require_element(), 1);

  // packages/global-styles-engine/build-module/utils/object.mjs
  function setImmutably(object, path, value) {
    path = Array.isArray(path) ? [...path] : [path];
    object = Array.isArray(object) ? [...object] : { ...object };
    const leaf = path.pop();
    let prev = object;
    for (const key of path) {
      const lvl = prev[key];
      prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl };
    }
    prev[leaf] = value;
    return object;
  }
  var getValueFromObjectPath = (object, path, defaultValue2) => {
    const arrayPath = Array.isArray(path) ? path : path.split(".");
    let value = object;
    arrayPath.forEach((fieldName) => {
      value = value?.[fieldName];
    });
    return value ?? defaultValue2;
  };

  // packages/global-styles-engine/build-module/settings/get-setting.mjs
  var VALID_SETTINGS = [
    "appearanceTools",
    "useRootPaddingAwareAlignments",
    "background.backgroundImage",
    "background.backgroundRepeat",
    "background.backgroundSize",
    "background.backgroundPosition",
    "background.gradient",
    "border.color",
    "border.radius",
    "border.radiusSizes",
    "border.style",
    "border.width",
    "shadow.presets",
    "shadow.defaultPresets",
    "color.background",
    "color.button",
    "color.caption",
    "color.custom",
    "color.customDuotone",
    "color.customGradient",
    "color.defaultDuotone",
    "color.defaultGradients",
    "color.defaultPalette",
    "color.duotone",
    "color.gradients",
    "color.heading",
    "color.link",
    "color.palette",
    "color.text",
    "custom",
    "dimensions.aspectRatio",
    "dimensions.height",
    "dimensions.minHeight",
    "dimensions.minWidth",
    "dimensions.width",
    "dimensions.dimensionSizes",
    "layout.contentSize",
    "layout.definitions",
    "layout.wideSize",
    "lightbox.enabled",
    "lightbox.allowEditing",
    "position.fixed",
    "position.sticky",
    "spacing.customSpacingSize",
    "spacing.defaultSpacingSizes",
    "spacing.spacingSizes",
    "spacing.spacingScale",
    "spacing.blockGap",
    "spacing.margin",
    "spacing.padding",
    "spacing.units",
    "typography.fluid",
    "typography.customFontSize",
    "typography.defaultFontSizes",
    "typography.dropCap",
    "typography.fontFamilies",
    "typography.fontSizes",
    "typography.fontStyle",
    "typography.fontWeight",
    "typography.letterSpacing",
    "typography.lineHeight",
    "typography.textAlign",
    "typography.textColumns",
    "typography.textDecoration",
    "typography.textIndent",
    "typography.textTransform",
    "typography.writingMode"
  ];
  function getSetting(globalStyles, path, blockName) {
    const appendedBlockPath = blockName ? ".blocks." + blockName : "";
    const appendedPropertyPath = path ? "." + path : "";
    const contextualPath = `settings${appendedBlockPath}${appendedPropertyPath}`;
    const globalPath = `settings${appendedPropertyPath}`;
    if (path) {
      return getValueFromObjectPath(globalStyles, contextualPath) ?? getValueFromObjectPath(globalStyles, globalPath);
    }
    let result = {};
    VALID_SETTINGS.forEach((setting) => {
      const value = getValueFromObjectPath(
        globalStyles,
        `settings${appendedBlockPath}.${setting}`
      ) ?? getValueFromObjectPath(globalStyles, `settings.${setting}`);
      if (value !== void 0) {
        result = setImmutably(result, setting.split("."), value);
      }
    });
    return result;
  }

  // packages/global-styles-engine/build-module/settings/set-setting.mjs
  function setSetting(globalStyles, path, newValue, blockName) {
    const appendedBlockPath = blockName ? ".blocks." + blockName : "";
    const appendedPropertyPath = path ? "." + path : "";
    const finalPath = `settings${appendedBlockPath}${appendedPropertyPath}`;
    return setImmutably(
      globalStyles,
      finalPath.split("."),
      newValue
    );
  }

  // packages/global-styles-engine/build-module/utils/common.mjs
  var import_style_engine = __toESM(require_style_engine(), 1);

  // packages/global-styles-engine/build-module/utils/fluid.mjs
  var DEFAULT_MAXIMUM_VIEWPORT_WIDTH = "1600px";
  var DEFAULT_MINIMUM_VIEWPORT_WIDTH = "320px";
  var DEFAULT_SCALE_FACTOR = 1;
  var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;
  var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;
  var DEFAULT_MINIMUM_FONT_SIZE_LIMIT = "14px";
  function getComputedFluidTypographyValue({
    minimumFontSize,
    maximumFontSize,
    fontSize,
    minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
    maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
    scaleFactor = DEFAULT_SCALE_FACTOR,
    minimumFontSizeLimit
  }) {
    minimumFontSizeLimit = !!getTypographyValueAndUnit(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT;
    if (fontSize) {
      const fontSizeParsed = getTypographyValueAndUnit(fontSize);
      if (!fontSizeParsed?.unit || !fontSizeParsed?.value) {
        return null;
      }
      const minimumFontSizeLimitParsed = getTypographyValueAndUnit(
        minimumFontSizeLimit,
        {
          coerceTo: fontSizeParsed.unit
        }
      );
      if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) {
        if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) {
          return null;
        }
      }
      if (!maximumFontSize) {
        maximumFontSize = `${fontSizeParsed.value}${fontSizeParsed.unit}`;
      }
      if (!minimumFontSize) {
        const fontSizeValueInPx = fontSizeParsed.unit === "px" ? fontSizeParsed.value : fontSizeParsed.value * 16;
        const minimumFontSizeFactor = Math.min(
          Math.max(
            1 - 0.075 * Math.log2(fontSizeValueInPx),
            DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN
          ),
          DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX
        );
        const calculatedMinimumFontSize = roundToPrecision(
          fontSizeParsed.value * minimumFontSizeFactor,
          3
        );
        if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) {
          minimumFontSize = `${minimumFontSizeLimitParsed.value}${minimumFontSizeLimitParsed.unit}`;
        } else {
          minimumFontSize = `${calculatedMinimumFontSize}${fontSizeParsed.unit}`;
        }
      }
    }
    const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize);
    const fontSizeUnit = minimumFontSizeParsed?.unit || "rem";
    const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, {
      coerceTo: fontSizeUnit
    });
    if (!minimumFontSizeParsed || !maximumFontSizeParsed) {
      return null;
    }
    const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, {
      coerceTo: "rem"
    });
    const maximumViewportWidthParsed = getTypographyValueAndUnit(
      maximumViewportWidth,
      { coerceTo: fontSizeUnit }
    );
    const minimumViewportWidthParsed = getTypographyValueAndUnit(
      minimumViewportWidth,
      { coerceTo: fontSizeUnit }
    );
    if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) {
      return null;
    }
    const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value;
    if (!linearDenominator) {
      return null;
    }
    const minViewportWidthOffsetValue = roundToPrecision(
      minimumViewportWidthParsed.value / 100,
      3
    );
    const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit;
    const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator);
    const linearFactorScaled = roundToPrecision(
      (linearFactor || 1) * scaleFactor,
      3
    );
    const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewportWidthOffset}) * ${linearFactorScaled})`;
    return `clamp(${minimumFontSize}, ${fluidTargetFontSize}, ${maximumFontSize})`;
  }
  function getTypographyValueAndUnit(rawValue, options = {}) {
    if (typeof rawValue !== "string" && typeof rawValue !== "number") {
      return null;
    }
    if (isFinite(rawValue)) {
      rawValue = `${rawValue}px`;
    }
    const { coerceTo, rootSizeValue, acceptableUnits } = {
      coerceTo: "",
      // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`.
      rootSizeValue: 16,
      acceptableUnits: ["rem", "px", "em"],
      ...options
    };
    const acceptableUnitsGroup = acceptableUnits?.join("|");
    const regexUnits = new RegExp(
      `^(\\d*\\.?\\d+)(${acceptableUnitsGroup}){1,1}$`
    );
    const matches = rawValue.toString().match(regexUnits);
    if (!matches || matches.length < 3) {
      return null;
    }
    let [, value, unit] = matches;
    let returnValue = parseFloat(value);
    if ("px" === coerceTo && ("em" === unit || "rem" === unit)) {
      returnValue = returnValue * rootSizeValue;
      unit = coerceTo;
    }
    if ("px" === unit && ("em" === coerceTo || "rem" === coerceTo)) {
      returnValue = returnValue / rootSizeValue;
      unit = coerceTo;
    }
    if (("em" === coerceTo || "rem" === coerceTo) && ("em" === unit || "rem" === unit)) {
      unit = coerceTo;
    }
    if (!unit) {
      return null;
    }
    return {
      value: roundToPrecision(returnValue, 3),
      unit
    };
  }
  function roundToPrecision(value, digits = 3) {
    const base = Math.pow(10, digits);
    return Math.round(value * base) / base;
  }

  // packages/global-styles-engine/build-module/utils/typography.mjs
  function isFluidTypographyEnabled(typographySettings) {
    const fluidSettings = typographySettings?.fluid;
    return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0;
  }
  function getFluidTypographyOptionsFromSettings(settings) {
    const typographySettings = settings?.typography ?? {};
    const layoutSettings = settings?.layout;
    const defaultMaxViewportWidth = getTypographyValueAndUnit(
      layoutSettings?.wideSize
    ) ? layoutSettings?.wideSize : null;
    return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? {
      fluid: {
        maxViewportWidth: defaultMaxViewportWidth,
        ...typeof typographySettings.fluid === "object" ? typographySettings.fluid : {}
      }
    } : {
      fluid: typographySettings?.fluid
    };
  }
  function getTypographyFontSizeValue(preset, settings) {
    const { size: defaultSize } = preset;
    if (!defaultSize || "0" === defaultSize || false === preset?.fluid) {
      return defaultSize;
    }
    if (!isFluidTypographyEnabled(settings?.typography) && !isFluidTypographyEnabled(preset)) {
      return defaultSize;
    }
    const fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings)?.fluid ?? {};
    const fluidFontSizeValue = getComputedFluidTypographyValue({
      minimumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.min,
      maximumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.max,
      fontSize: defaultSize,
      minimumFontSizeLimit: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minFontSize : void 0,
      maximumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.maxViewportWidth : void 0,
      minimumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minViewportWidth : void 0
    });
    if (!!fluidFontSizeValue) {
      return fluidFontSizeValue;
    }
    return defaultSize;
  }

  // packages/global-styles-engine/build-module/utils/common.mjs
  var ROOT_BLOCK_SELECTOR = "body";
  var ROOT_CSS_PROPERTIES_SELECTOR = ":root";
  var PRESET_METADATA = [
    {
      path: ["color", "palette"],
      valueKey: "color",
      cssVarInfix: "color",
      classes: [
        { classSuffix: "color", propertyName: "color" },
        {
          classSuffix: "background-color",
          propertyName: "background-color"
        },
        {
          classSuffix: "border-color",
          propertyName: "border-color"
        }
      ]
    },
    {
      path: ["color", "gradients"],
      valueKey: "gradient",
      cssVarInfix: "gradient",
      classes: [
        {
          classSuffix: "gradient-background",
          propertyName: "background"
        }
      ]
    },
    {
      path: ["color", "duotone"],
      valueKey: "colors",
      cssVarInfix: "duotone",
      valueFunc: ({ slug }) => `url( '#wp-duotone-${slug}' )`,
      classes: []
    },
    {
      path: ["shadow", "presets"],
      valueKey: "shadow",
      cssVarInfix: "shadow",
      classes: []
    },
    {
      path: ["typography", "fontSizes"],
      valueFunc: (preset, settings) => getTypographyFontSizeValue(preset, settings),
      valueKey: "size",
      cssVarInfix: "font-size",
      classes: [{ classSuffix: "font-size", propertyName: "font-size" }]
    },
    {
      path: ["typography", "fontFamilies"],
      valueKey: "fontFamily",
      cssVarInfix: "font-family",
      classes: [
        { classSuffix: "font-family", propertyName: "font-family" }
      ]
    },
    {
      path: ["spacing", "spacingSizes"],
      valueKey: "size",
      cssVarInfix: "spacing",
      valueFunc: ({ size }) => size,
      classes: []
    },
    {
      path: ["border", "radiusSizes"],
      valueKey: "size",
      cssVarInfix: "border-radius",
      classes: []
    },
    {
      path: ["dimensions", "dimensionSizes"],
      valueKey: "size",
      cssVarInfix: "dimension",
      classes: []
    }
  ];
  function scopeSelector(scope, selector2) {
    if (!scope || !selector2) {
      return selector2;
    }
    const scopes = scope.split(",");
    const selectors = selector2.split(",");
    const selectorsScoped = [];
    scopes.forEach((outer) => {
      selectors.forEach((inner) => {
        selectorsScoped.push(`${outer.trim()} ${inner.trim()}`);
      });
    });
    return selectorsScoped.join(", ");
  }
  function scopeFeatureSelectors(scope, selectors) {
    if (!scope || !selectors) {
      return;
    }
    const featureSelectors = {};
    Object.entries(selectors).forEach(([feature, selector2]) => {
      if (typeof selector2 === "string") {
        featureSelectors[feature] = scopeSelector(scope, selector2);
      }
      if (typeof selector2 === "object") {
        featureSelectors[feature] = {};
        Object.entries(selector2).forEach(
          ([subfeature, subfeatureSelector]) => {
            featureSelectors[feature][subfeature] = scopeSelector(
              scope,
              subfeatureSelector
            );
          }
        );
      }
    });
    return featureSelectors;
  }
  function appendToSelector(selector2, toAppend) {
    if (!selector2.includes(",")) {
      return selector2 + toAppend;
    }
    const selectors = selector2.split(",");
    const newSelectors = selectors.map((sel) => sel + toAppend);
    return newSelectors.join(",");
  }
  function getBlockStyleVariationSelector(variation, blockSelector) {
    const variationClass = `.is-style-${variation}`;
    if (!blockSelector) {
      return variationClass;
    }
    const ancestorRegex = /((?::\([^)]+\))?\s*)([^\s:]+)/;
    const addVariationClass = (_match, group1, group2) => {
      return group1 + group2 + variationClass;
    };
    const result = blockSelector.split(",").map((part) => part.replace(ancestorRegex, addVariationClass));
    return result.join(",");
  }
  function getResolvedRefValue(ruleValue, tree) {
    if (!ruleValue || !tree) {
      return ruleValue;
    }
    if (typeof ruleValue === "object" && "ref" in ruleValue && ruleValue?.ref) {
      const resolvedRuleValue = (0, import_style_engine.getCSSValueFromRawStyle)(
        getValueFromObjectPath(tree, ruleValue.ref)
      );
      if (typeof resolvedRuleValue === "object" && resolvedRuleValue !== null && "ref" in resolvedRuleValue && resolvedRuleValue?.ref) {
        return void 0;
      }
      if (resolvedRuleValue === void 0) {
        return ruleValue;
      }
      return resolvedRuleValue;
    }
    return ruleValue;
  }
  function getResolvedThemeFilePath(file, themeFileURIs) {
    if (!file || !themeFileURIs || !Array.isArray(themeFileURIs)) {
      return file;
    }
    const uri = themeFileURIs.find(
      (themeFileUri) => themeFileUri?.name === file
    );
    if (!uri?.href) {
      return file;
    }
    return uri?.href;
  }
  function getResolvedValue(ruleValue, tree) {
    if (!ruleValue || !tree) {
      return ruleValue;
    }
    const resolvedValue = getResolvedRefValue(ruleValue, tree);
    if (typeof resolvedValue === "object" && resolvedValue !== null && "url" in resolvedValue && resolvedValue?.url) {
      resolvedValue.url = getResolvedThemeFilePath(
        resolvedValue.url,
        tree?._links?.["wp:theme-file"]
      );
    }
    return resolvedValue;
  }
  function findInPresetsBy(settings, blockName, presetPath = [], presetProperty = "slug", presetValueValue) {
    const orderedPresetsByOrigin = [
      blockName ? getValueFromObjectPath(settings, [
        "blocks",
        blockName,
        ...presetPath
      ]) : void 0,
      getValueFromObjectPath(settings, presetPath)
    ].filter(Boolean);
    for (const presetByOrigin of orderedPresetsByOrigin) {
      if (presetByOrigin) {
        const origins = ["custom", "theme", "default"];
        for (const origin of origins) {
          const presets = presetByOrigin[origin];
          if (presets) {
            const presetObject = presets.find(
              (preset) => preset[presetProperty] === presetValueValue
            );
            if (presetObject) {
              if (presetProperty === "slug") {
                return presetObject;
              }
              const highestPresetObjectWithSameSlug = findInPresetsBy(
                settings,
                blockName,
                presetPath,
                "slug",
                presetObject.slug
              );
              if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) {
                return presetObject;
              }
              return void 0;
            }
          }
        }
      }
    }
  }
  function getValueFromPresetVariable(features, blockName, variable, [presetType, slug] = []) {
    const metadata = PRESET_METADATA.find(
      (data) => data.cssVarInfix === presetType
    );
    if (!metadata || !features.settings) {
      return variable;
    }
    const presetObject = findInPresetsBy(
      features.settings,
      blockName,
      metadata.path,
      "slug",
      slug
    );
    if (presetObject) {
      const { valueKey } = metadata;
      const result = presetObject[valueKey];
      return getValueFromVariable(features, blockName, result);
    }
    return variable;
  }
  function getValueFromCustomVariable(features, blockName, variable, path = []) {
    const result = (blockName ? getValueFromObjectPath(features?.settings ?? {}, [
      "blocks",
      blockName,
      "custom",
      ...path
    ]) : void 0) ?? getValueFromObjectPath(features?.settings ?? {}, [
      "custom",
      ...path
    ]);
    if (!result) {
      return variable;
    }
    return getValueFromVariable(features, blockName, result);
  }
  function getValueFromVariable(features, blockName, variable) {
    if (!variable || typeof variable !== "string") {
      if (typeof variable === "object" && variable !== null && "ref" in variable && typeof variable.ref === "string") {
        const resolvedVariable = getValueFromObjectPath(
          features,
          variable.ref
        );
        if (!resolvedVariable || typeof resolvedVariable === "object" && "ref" in resolvedVariable) {
          return resolvedVariable;
        }
        variable = resolvedVariable;
      } else {
        return variable;
      }
    }
    const USER_VALUE_PREFIX = "var:";
    const THEME_VALUE_PREFIX = "var(--wp--";
    const THEME_VALUE_SUFFIX = ")";
    let parsedVar;
    if (variable.startsWith(USER_VALUE_PREFIX)) {
      parsedVar = variable.slice(USER_VALUE_PREFIX.length).split("|");
    } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) {
      parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split("--");
    } else {
      return variable;
    }
    const [type, ...path] = parsedVar;
    if (type === "preset") {
      return getValueFromPresetVariable(
        features,
        blockName,
        variable,
        path
      );
    }
    if (type === "custom") {
      return getValueFromCustomVariable(
        features,
        blockName,
        variable,
        path
      );
    }
    return variable;
  }

  // packages/global-styles-engine/build-module/settings/get-style.mjs
  function getStyle(globalStyles, path, blockName, shouldDecodeEncode = true) {
    const appendedPath = path ? "." + path : "";
    const finalPath = !blockName ? `styles${appendedPath}` : `styles.blocks.${blockName}${appendedPath}`;
    if (!globalStyles) {
      return void 0;
    }
    const rawResult = getValueFromObjectPath(globalStyles, finalPath);
    const result = shouldDecodeEncode ? getValueFromVariable(globalStyles, blockName, rawResult) : rawResult;
    return result;
  }

  // packages/global-styles-engine/build-module/settings/set-style.mjs
  function setStyle(globalStyles, path, newValue, blockName) {
    const appendedPath = path ? "." + path : "";
    const finalPath = !blockName ? `styles${appendedPath}` : `styles.blocks.${blockName}${appendedPath}`;
    return setImmutably(
      globalStyles,
      finalPath.split("."),
      newValue
    );
  }

  // packages/global-styles-engine/build-module/core/equal.mjs
  var import_es63 = __toESM(require_es6(), 1);
  function areGlobalStylesEqual(original, variation) {
    if (typeof original !== "object" || typeof variation !== "object") {
      return original === variation;
    }
    return (0, import_es63.default)(original?.styles, variation?.styles) && (0, import_es63.default)(original?.settings, variation?.settings);
  }

  // packages/global-styles-engine/build-module/core/merge.mjs
  var import_deepmerge3 = __toESM(require_cjs(), 1);

  // node_modules/is-plain-object/dist/is-plain-object.mjs
  function isObject2(o4) {
    return Object.prototype.toString.call(o4) === "[object Object]";
  }
  function isPlainObject(o4) {
    var ctor, prot;
    if (isObject2(o4) === false) return false;
    ctor = o4.constructor;
    if (ctor === void 0) return true;
    prot = ctor.prototype;
    if (isObject2(prot) === false) return false;
    if (prot.hasOwnProperty("isPrototypeOf") === false) {
      return false;
    }
    return true;
  }

  // packages/global-styles-engine/build-module/core/merge.mjs
  function mergeGlobalStyles(base, user) {
    return (0, import_deepmerge3.default)(base, user, {
      /*
       * We only pass as arrays the presets,
       * in which case we want the new array of values
       * to override the old array (no merging).
       */
      isMergeableObject: isPlainObject,
      /*
       * Exceptions to the above rule.
       * Background images should be replaced, not merged,
       * as they themselves are specific object definitions for the style.
       */
      customMerge: (key) => {
        if (key === "backgroundImage") {
          return (baseConfig, userConfig) => userConfig ?? baseConfig;
        }
        return void 0;
      }
    });
  }

  // node_modules/memize/dist/index.js
  function memize(fn, options) {
    var size = 0;
    var head2;
    var tail;
    options = options || {};
    function memoized() {
      var node = head2, len2 = arguments.length, args, i3;
      searchCache: while (node) {
        if (node.args.length !== arguments.length) {
          node = node.next;
          continue;
        }
        for (i3 = 0; i3 < len2; i3++) {
          if (node.args[i3] !== arguments[i3]) {
            node = node.next;
            continue searchCache;
          }
        }
        if (node !== head2) {
          if (node === tail) {
            tail = node.prev;
          }
          node.prev.next = node.next;
          if (node.next) {
            node.next.prev = node.prev;
          }
          node.next = head2;
          node.prev = null;
          head2.prev = node;
          head2 = node;
        }
        return node.val;
      }
      args = new Array(len2);
      for (i3 = 0; i3 < len2; i3++) {
        args[i3] = arguments[i3];
      }
      node = {
        args,
        // Generate the result from original function
        val: fn.apply(null, args)
      };
      if (head2) {
        head2.prev = node;
        node.next = head2;
      } else {
        tail = node;
      }
      if (size === /** @type {MemizeOptions} */
      options.maxSize) {
        tail = /** @type {MemizeCacheNode} */
        tail.prev;
        tail.next = null;
      } else {
        size++;
      }
      head2 = node;
      return node.val;
    }
    memoized.clear = function() {
      head2 = null;
      tail = null;
      size = 0;
    };
    return memoized;
  }

  // packages/global-styles-engine/build-module/utils/get-global-styles-changes.mjs
  var import_i18n125 = __toESM(require_i18n(), 1);
  var import_blocks6 = __toESM(require_blocks(), 1);
  var globalStylesChangesCache = /* @__PURE__ */ new Map();
  var EMPTY_ARRAY8 = [];
  var translationMap = {
    caption: (0, import_i18n125.__)("Caption"),
    link: (0, import_i18n125.__)("Link"),
    button: (0, import_i18n125.__)("Button"),
    heading: (0, import_i18n125.__)("Heading"),
    h1: (0, import_i18n125.__)("H1"),
    h2: (0, import_i18n125.__)("H2"),
    h3: (0, import_i18n125.__)("H3"),
    h4: (0, import_i18n125.__)("H4"),
    h5: (0, import_i18n125.__)("H5"),
    h6: (0, import_i18n125.__)("H6"),
    "settings.color": (0, import_i18n125.__)("Color"),
    "settings.typography": (0, import_i18n125.__)("Typography"),
    "settings.shadow": (0, import_i18n125.__)("Shadow"),
    "settings.layout": (0, import_i18n125.__)("Layout"),
    "styles.color": (0, import_i18n125.__)("Colors"),
    "styles.spacing": (0, import_i18n125.__)("Spacing"),
    "styles.background": (0, import_i18n125.__)("Background"),
    "styles.typography": (0, import_i18n125.__)("Typography")
  };
  var getBlockNames = memize(
    () => (0, import_blocks6.getBlockTypes)().reduce(
      (accumulator, {
        name: name2,
        title
      }) => {
        accumulator[name2] = title;
        return accumulator;
      },
      {}
    )
  );
  var isObject3 = (obj) => obj !== null && typeof obj === "object";
  function getTranslation(key) {
    if (translationMap[key]) {
      return translationMap[key];
    }
    const keyArray = key.split(".");
    if (keyArray?.[0] === "blocks") {
      const blockName = getBlockNames()?.[keyArray[1]];
      return blockName || keyArray[1];
    }
    if (keyArray?.[0] === "elements") {
      return translationMap[keyArray[1]] || keyArray[1];
    }
    return void 0;
  }
  function deepCompare(changedObject, originalObject, parentPath = "") {
    if (!isObject3(changedObject) && !isObject3(originalObject)) {
      return changedObject !== originalObject ? parentPath.split(".").slice(0, 2).join(".") : void 0;
    }
    changedObject = isObject3(changedObject) ? changedObject : {};
    originalObject = isObject3(originalObject) ? originalObject : {};
    const allKeys = /* @__PURE__ */ new Set([
      ...Object.keys(changedObject),
      ...Object.keys(originalObject)
    ]);
    let diffs = [];
    for (const key of allKeys) {
      const path = parentPath ? parentPath + "." + key : key;
      const changedPath = deepCompare(
        changedObject[key],
        originalObject[key],
        path
      );
      if (changedPath) {
        diffs = diffs.concat(changedPath);
      }
    }
    return diffs;
  }
  function getGlobalStylesChangelist(next, previous) {
    const cacheKey2 = JSON.stringify({ next, previous });
    if (globalStylesChangesCache.has(cacheKey2)) {
      return globalStylesChangesCache.get(cacheKey2);
    }
    const changedValueTree = deepCompare(
      {
        styles: {
          background: next?.styles?.background,
          color: next?.styles?.color,
          typography: next?.styles?.typography,
          spacing: next?.styles?.spacing
        },
        blocks: next?.styles?.blocks,
        elements: next?.styles?.elements,
        settings: next?.settings
      },
      {
        styles: {
          background: previous?.styles?.background,
          color: previous?.styles?.color,
          typography: previous?.styles?.typography,
          spacing: previous?.styles?.spacing
        },
        blocks: previous?.styles?.blocks,
        elements: previous?.styles?.elements,
        settings: previous?.settings
      }
    );
    if (!changedValueTree || Array.isArray(changedValueTree) && !changedValueTree.length) {
      globalStylesChangesCache.set(cacheKey2, []);
      return [];
    }
    const changedValueArray = Array.isArray(changedValueTree) ? changedValueTree : [changedValueTree];
    const result = [...new Set(changedValueArray)].reduce((acc, curr) => {
      const translation = getTranslation(curr);
      if (translation) {
        acc.push([curr.split(".")[0], translation]);
      }
      return acc;
    }, []);
    globalStylesChangesCache.set(cacheKey2, result);
    return result;
  }
  function getGlobalStylesChanges(next, previous, options = {}) {
    let changeList = getGlobalStylesChangelist(next, previous);
    const changesLength = changeList.length;
    const { maxResults } = options;
    if (changesLength) {
      if (!!maxResults && changesLength > maxResults) {
        changeList = changeList.slice(0, maxResults);
      }
      return Object.entries(
        changeList.reduce((acc, curr) => {
          const group = acc[curr[0]] || [];
          if (!group.includes(curr[1])) {
            acc[curr[0]] = [...group, curr[1]];
          }
          return acc;
        }, {})
      ).map(([key, changeValues]) => {
        const changeValuesLength = changeValues.length;
        const joinedChangesValue = changeValues.join(
          /* translators: Used between list items, there is a space after the comma. */
          (0, import_i18n125.__)(", ")
          // eslint-disable-line @wordpress/i18n-no-flanking-whitespace
        );
        switch (key) {
          case "blocks": {
            return (0, import_i18n125.sprintf)(
              // translators: %s: a list of block names separated by a comma.
              (0, import_i18n125._n)("%s block.", "%s blocks.", changeValuesLength),
              joinedChangesValue
            );
          }
          case "elements": {
            return (0, import_i18n125.sprintf)(
              // translators: %s: a list of element names separated by a comma.
              (0, import_i18n125._n)("%s element.", "%s elements.", changeValuesLength),
              joinedChangesValue
            );
          }
          case "settings": {
            return (0, import_i18n125.sprintf)(
              // translators: %s: a list of theme.json setting labels separated by a comma.
              (0, import_i18n125.__)("%s settings."),
              joinedChangesValue
            );
          }
          case "styles": {
            return (0, import_i18n125.sprintf)(
              // translators: %s: a list of theme.json top-level styles labels separated by a comma.
              (0, import_i18n125.__)("%s styles."),
              joinedChangesValue
            );
          }
          default: {
            return (0, import_i18n125.sprintf)(
              // translators: %s: a list of global styles changes separated by a comma.
              (0, import_i18n125.__)("%s."),
              joinedChangesValue
            );
          }
        }
      });
    }
    return EMPTY_ARRAY8;
  }

  // packages/global-styles-engine/build-module/core/render.mjs
  var import_blocks7 = __toESM(require_blocks(), 1);
  var import_style_engine2 = __toESM(require_style_engine(), 1);
  var import_data43 = __toESM(require_data(), 1);

  // packages/global-styles-engine/build-module/core/selectors.mjs
  function getBlockSelector(blockType, target = "root", options = {}) {
    if (!target) {
      return null;
    }
    const { fallback = false } = options;
    const { name: name2, selectors, supports } = blockType;
    const hasSelectors = selectors && Object.keys(selectors).length > 0;
    const path = Array.isArray(target) ? target.join(".") : target;
    let rootSelector = null;
    if (hasSelectors && selectors.root) {
      rootSelector = selectors?.root;
    } else if (supports?.__experimentalSelector) {
      rootSelector = supports.__experimentalSelector;
    } else {
      rootSelector = ".wp-block-" + name2.replace("core/", "").replace("/", "-");
    }
    if (path === "root") {
      return rootSelector;
    }
    const pathArray = Array.isArray(target) ? target : target.split(".");
    if (pathArray.length === 1) {
      const fallbackSelector = fallback ? rootSelector : null;
      if (hasSelectors) {
        const featureSelector2 = getValueFromObjectPath(
          selectors,
          `${path}.root`,
          null
        ) || getValueFromObjectPath(selectors, path, null);
        return featureSelector2 || fallbackSelector;
      }
      const featureSelector = supports ? getValueFromObjectPath(
        supports,
        `${path}.__experimentalSelector`,
        null
      ) : void 0;
      if (!featureSelector) {
        return fallbackSelector;
      }
      return scopeSelector(rootSelector, featureSelector);
    }
    let subfeatureSelector;
    if (hasSelectors) {
      subfeatureSelector = getValueFromObjectPath(selectors, path, null);
    }
    if (subfeatureSelector) {
      return subfeatureSelector;
    }
    if (fallback) {
      return getBlockSelector(blockType, pathArray[0], options);
    }
    return null;
  }

  // packages/global-styles-engine/build-module/utils/duotone.mjs
  function getValuesFromColors(colors2 = []) {
    const values = {
      r: [],
      g: [],
      b: [],
      a: []
    };
    colors2.forEach((color) => {
      const rgbColor = w2(color).toRgb();
      values.r.push(rgbColor.r / 255);
      values.g.push(rgbColor.g / 255);
      values.b.push(rgbColor.b / 255);
      values.a.push(rgbColor.a);
    });
    return values;
  }
  function getDuotoneFilter(id, colors2) {
    const values = getValuesFromColors(colors2);
    return `
<svg
	xmlns:xlink="http://www.w3.org/1999/xlink"
	viewBox="0 0 0 0"
	width="0"
	height="0"
	focusable="false"
	role="none"
	aria-hidden="true"
	style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
>
	<defs>
		<filter id="${id}">
			<!--
				Use sRGB instead of linearRGB so transparency looks correct.
				Use perceptual brightness to convert to grayscale.
			-->
			<feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
			<!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
			<feComponentTransfer color-interpolation-filters="sRGB">
				<feFuncR type="table" tableValues="${values.r.join(" ")}"></feFuncR>
				<feFuncG type="table" tableValues="${values.g.join(" ")}"></feFuncG>
				<feFuncB type="table" tableValues="${values.b.join(" ")}"></feFuncB>
				<feFuncA type="table" tableValues="${values.a.join(" ")}"></feFuncA>
			</feComponentTransfer>
			<!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
			<feComposite in2="SourceGraphic" operator="in"></feComposite>
		</filter>
	</defs>
</svg>`;
  }

  // packages/global-styles-engine/build-module/utils/string.mjs
  function kebabCase2(str3) {
    return str3.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([0-9])([a-zA-Z])/g, "$1-$2").replace(/([a-zA-Z])([0-9])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
  }

  // packages/global-styles-engine/build-module/utils/spacing.mjs
  function getSpacingPresetCssVar(value) {
    if (!value) {
      return;
    }
    const slug = value.match(/var:preset\|spacing\|(.+)/);
    if (!slug) {
      return value;
    }
    return `var(--wp--preset--spacing--${slug[1]})`;
  }

  // packages/global-styles-engine/build-module/utils/gap.mjs
  function getGapBoxControlValueFromStyle(blockGapValue) {
    if (!blockGapValue) {
      return null;
    }
    const isValueString = typeof blockGapValue === "string";
    return {
      top: isValueString ? blockGapValue : blockGapValue?.top,
      left: isValueString ? blockGapValue : blockGapValue?.left
    };
  }
  function getGapCSSValue(blockGapValue, defaultValue2 = "0") {
    const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue);
    if (!blockGapBoxControlValue) {
      return null;
    }
    const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue2;
    const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue2;
    return row === column ? row : `${row} ${column}`;
  }

  // packages/global-styles-engine/build-module/utils/background.mjs
  var BACKGROUND_BLOCK_DEFAULT_VALUES = {
    backgroundSize: "cover",
    backgroundPosition: "50% 50%"
    // used only when backgroundSize is 'contain'.
  };
  function setBackgroundStyleDefaults(backgroundStyle) {
    if (!backgroundStyle || // @ts-expect-error
    !backgroundStyle?.backgroundImage?.url) {
      return;
    }
    let backgroundStylesWithDefaults;
    if (!backgroundStyle?.backgroundSize) {
      backgroundStylesWithDefaults = {
        backgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize
      };
    }
    if ("contain" === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) {
      backgroundStylesWithDefaults = {
        backgroundPosition: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition
      };
    }
    return backgroundStylesWithDefaults;
  }

  // packages/global-styles-engine/build-module/utils/layout.mjs
  var LAYOUT_DEFINITIONS = {
    default: {
      name: "default",
      slug: "flow",
      className: "is-layout-flow",
      baseStyles: [
        {
          selector: " > .alignleft",
          rules: {
            float: "left",
            "margin-inline-start": "0",
            "margin-inline-end": "2em"
          }
        },
        {
          selector: " > .alignright",
          rules: {
            float: "right",
            "margin-inline-start": "2em",
            "margin-inline-end": "0"
          }
        },
        {
          selector: " > .aligncenter",
          rules: {
            "margin-left": "auto !important",
            "margin-right": "auto !important"
          }
        }
      ],
      spacingStyles: [
        {
          selector: " > :first-child",
          rules: {
            "margin-block-start": "0"
          }
        },
        {
          selector: " > :last-child",
          rules: {
            "margin-block-end": "0"
          }
        },
        {
          selector: " > *",
          rules: {
            "margin-block-start": null,
            "margin-block-end": "0"
          }
        }
      ]
    },
    constrained: {
      name: "constrained",
      slug: "constrained",
      className: "is-layout-constrained",
      baseStyles: [
        {
          selector: " > .alignleft",
          rules: {
            float: "left",
            "margin-inline-start": "0",
            "margin-inline-end": "2em"
          }
        },
        {
          selector: " > .alignright",
          rules: {
            float: "right",
            "margin-inline-start": "2em",
            "margin-inline-end": "0"
          }
        },
        {
          selector: " > .aligncenter",
          rules: {
            "margin-left": "auto !important",
            "margin-right": "auto !important"
          }
        },
        {
          selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))",
          rules: {
            "max-width": "var(--wp--style--global--content-size)",
            "margin-left": "auto !important",
            "margin-right": "auto !important"
          }
        },
        {
          selector: " > .alignwide",
          rules: {
            "max-width": "var(--wp--style--global--wide-size)"
          }
        }
      ],
      spacingStyles: [
        {
          selector: " > :first-child",
          rules: {
            "margin-block-start": "0"
          }
        },
        {
          selector: " > :last-child",
          rules: {
            "margin-block-end": "0"
          }
        },
        {
          selector: " > *",
          rules: {
            "margin-block-start": null,
            "margin-block-end": "0"
          }
        }
      ]
    },
    flex: {
      name: "flex",
      slug: "flex",
      className: "is-layout-flex",
      displayMode: "flex",
      baseStyles: [
        {
          selector: "",
          rules: {
            "flex-wrap": "wrap",
            "align-items": "center"
          }
        },
        {
          selector: " > :is(*, div)",
          // :is(*, div) instead of just * increases the specificity by 001.
          rules: {
            margin: "0"
          }
        }
      ],
      spacingStyles: [
        {
          selector: "",
          rules: {
            gap: null
          }
        }
      ]
    },
    grid: {
      name: "grid",
      slug: "grid",
      className: "is-layout-grid",
      displayMode: "grid",
      baseStyles: [
        {
          selector: " > :is(*, div)",
          // :is(*, div) instead of just * increases the specificity by 001.
          rules: {
            margin: "0"
          }
        }
      ],
      spacingStyles: [
        {
          selector: "",
          rules: {
            gap: null
          }
        }
      ]
    }
  };

  // packages/global-styles-engine/build-module/core/render.mjs
  var ELEMENT_CLASS_NAMES = {
    button: "wp-element-button",
    caption: "wp-element-caption"
  };
  var BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
    __experimentalBorder: "border",
    color: "color",
    dimensions: "dimensions",
    spacing: "spacing",
    typography: "typography"
  };
  var VALID_BLOCK_PSEUDO_SELECTORS = {
    "core/button": [":hover", ":focus", ":focus-visible", ":active"],
    "core/navigation-link": [":hover", ":focus", ":focus-visible", ":active"]
  };
  function getPresetsClasses(blockSelector = "*", blockPresets = {}) {
    return PRESET_METADATA.reduce(
      (declarations, { path, cssVarInfix, classes }) => {
        if (!classes) {
          return declarations;
        }
        const presetByOrigin = getValueFromObjectPath(
          blockPresets,
          path,
          []
        );
        ["default", "theme", "custom"].forEach((origin) => {
          if (presetByOrigin[origin]) {
            presetByOrigin[origin].forEach(
              ({ slug }) => {
                classes.forEach(
                  ({
                    classSuffix,
                    propertyName
                  }) => {
                    const classSelectorToUse = `.has-${kebabCase2(
                      slug
                    )}-${classSuffix}`;
                    const selectorToUse = blockSelector.split(",").map(
                      (selector2) => `${selector2}${classSelectorToUse}`
                    ).join(",");
                    const value = `var(--wp--preset--${cssVarInfix}--${kebabCase2(
                      slug
                    )})`;
                    declarations += `${selectorToUse}{${propertyName}: ${value} !important;}`;
                  }
                );
              }
            );
          }
        });
        return declarations;
      },
      ""
    );
  }
  function getPresetsSvgFilters(blockPresets = {}) {
    return PRESET_METADATA.filter(
      // Duotone are the only type of filters for now.
      (metadata) => metadata.path.at(-1) === "duotone"
    ).flatMap((metadata) => {
      const presetByOrigin = getValueFromObjectPath(
        blockPresets,
        metadata.path,
        {}
      );
      return ["default", "theme"].filter((origin) => presetByOrigin[origin]).flatMap(
        (origin) => presetByOrigin[origin].map(
          (preset) => getDuotoneFilter(
            `wp-duotone-${preset.slug}`,
            preset.colors
          )
        )
      ).join("");
    });
  }
  function flattenTree(input = {}, prefix2, token) {
    let result = [];
    Object.keys(input).forEach((key) => {
      const newKey = prefix2 + kebabCase2(key.replace("/", "-"));
      const newLeaf = input[key];
      if (newLeaf instanceof Object) {
        const newPrefix = newKey + token;
        result = [...result, ...flattenTree(newLeaf, newPrefix, token)];
      } else {
        result.push(`${newKey}: ${newLeaf}`);
      }
    });
    return result;
  }
  function concatFeatureVariationSelectorString(featureSelector, styleVariationSelector) {
    const featureSelectors = featureSelector.split(",");
    const combinedSelectors = [];
    featureSelectors.forEach((selector2) => {
      combinedSelectors.push(
        `${styleVariationSelector.trim()}${selector2.trim()}`
      );
    });
    return combinedSelectors.join(", ");
  }
  var updateParagraphTextIndentSelector = (featureDeclarations, settings, blockName) => {
    if (blockName !== "core/paragraph") {
      return featureDeclarations;
    }
    const blockSettings = settings?.blocks?.["core/paragraph"];
    const textIndentSetting = blockSettings?.typography?.textIndent ?? settings?.typography?.textIndent ?? "subsequent";
    if (textIndentSetting !== "all") {
      return featureDeclarations;
    }
    const oldSelector = ".wp-block-paragraph + .wp-block-paragraph";
    const newSelector = ".wp-block-paragraph";
    if (oldSelector in featureDeclarations) {
      const declarations = featureDeclarations[oldSelector];
      const updated = { ...featureDeclarations };
      delete updated[oldSelector];
      updated[newSelector] = declarations;
      return updated;
    }
    return featureDeclarations;
  };
  var updateButtonWidthDeclarations = (featureDeclarations, settings) => {
    const buttonSelector = ".wp-block-button";
    if (!(buttonSelector in featureDeclarations)) {
      return featureDeclarations;
    }
    const updated = { ...featureDeclarations };
    updated[buttonSelector] = updated[buttonSelector].map(
      (declaration) => {
        const match3 = declaration.match(/^width:\s*(.+)$/);
        if (!match3) {
          return declaration;
        }
        const value = match3[1];
        let percentage = null;
        if (value.endsWith("%")) {
          percentage = parseFloat(value);
        }
        const presetPrefix = "var(--wp--preset--dimension--";
        if (percentage === null && value.startsWith(presetPrefix) && value.endsWith(")")) {
          const slug = value.slice(presetPrefix.length, -1);
          const dimensionSizes = {
            ...settings?.dimensions?.dimensionSizes ?? {},
            ...settings?.blocks?.["core/button"]?.dimensions?.dimensionSizes ?? {}
          };
          for (const origin of Object.values(dimensionSizes)) {
            if (!Array.isArray(origin)) {
              continue;
            }
            for (const preset of origin) {
              if (preset.slug === slug && typeof preset.size === "string" && preset.size.endsWith("%")) {
                percentage = parseFloat(preset.size);
                break;
              }
            }
            if (percentage !== null) {
              break;
            }
          }
        }
        if (percentage === null || isNaN(percentage)) {
          return declaration;
        }
        return `width: calc(${percentage} * 1% - (var(--wp--style--block-gap, 0.5em) * (1 - ${percentage} / 100)))`;
      }
    );
    return updated;
  };
  var getFeatureDeclarations = (selectors, styles) => {
    const declarations = {};
    Object.entries(selectors).forEach(([feature, selector2]) => {
      if (feature === "root" || !styles?.[feature]) {
        return;
      }
      const isShorthand = typeof selector2 === "string";
      if (!isShorthand && typeof selector2 === "object" && selector2 !== null) {
        Object.entries(selector2).forEach(
          ([subfeature, subfeatureSelector]) => {
            if (subfeature === "root" || !styles?.[feature][subfeature]) {
              return;
            }
            const subfeatureStyles = {
              [feature]: {
                [subfeature]: styles[feature][subfeature]
              }
            };
            const newDeclarations = getStylesDeclarations(subfeatureStyles);
            declarations[subfeatureSelector] = [
              ...declarations[subfeatureSelector] || [],
              ...newDeclarations
            ];
            delete styles[feature][subfeature];
          }
        );
      }
      if (isShorthand || typeof selector2 === "object" && selector2 !== null && "root" in selector2) {
        const featureSelector = isShorthand ? selector2 : selector2.root;
        const featureStyles = { [feature]: styles[feature] };
        const newDeclarations = getStylesDeclarations(featureStyles);
        declarations[featureSelector] = [
          ...declarations[featureSelector] || [],
          ...newDeclarations
        ];
        delete styles[feature];
      }
    });
    return declarations;
  };
  function getStylesDeclarations(blockStyles = {}, selector2 = "", useRootPaddingAlign, tree = {}, disableRootPadding = false) {
    const isRoot = ROOT_BLOCK_SELECTOR === selector2;
    const output = Object.entries(
      import_blocks7.__EXPERIMENTAL_STYLE_PROPERTY
    ).reduce(
      (declarations, [key, { value, properties, useEngine, rootOnly }]) => {
        if (rootOnly && !isRoot) {
          return declarations;
        }
        const pathToValue = value;
        if (pathToValue[0] === "elements" || useEngine) {
          return declarations;
        }
        const styleValue = getValueFromObjectPath(
          blockStyles,
          pathToValue
        );
        if (key === "--wp--style--root--padding" && (typeof styleValue === "string" || !useRootPaddingAlign)) {
          return declarations;
        }
        if (properties && typeof styleValue !== "string") {
          Object.entries(properties).forEach((entry) => {
            const [name2, prop] = entry;
            if (!getValueFromObjectPath(styleValue, [prop], false)) {
              return;
            }
            const cssProperty = name2.startsWith("--") ? name2 : kebabCase2(name2);
            declarations.push(
              `${cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)(
                getValueFromObjectPath(styleValue, [prop])
              )}`
            );
          });
        } else if (getValueFromObjectPath(blockStyles, pathToValue, false)) {
          const cssProperty = key.startsWith("--") ? key : kebabCase2(key);
          declarations.push(
            `${cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)(
              getValueFromObjectPath(blockStyles, pathToValue)
            )}`
          );
        }
        return declarations;
      },
      []
    );
    if (!!blockStyles.background) {
      if (blockStyles.background?.backgroundImage) {
        blockStyles.background.backgroundImage = getResolvedValue(
          blockStyles.background.backgroundImage,
          tree
        );
      }
      if (!isRoot && !!blockStyles.background?.backgroundImage?.id) {
        blockStyles = {
          ...blockStyles,
          background: {
            ...blockStyles.background,
            ...setBackgroundStyleDefaults(blockStyles.background)
          }
        };
      }
    }
    const extraRules = (0, import_style_engine2.getCSSRules)(blockStyles);
    extraRules.forEach((rule) => {
      if (isRoot && (useRootPaddingAlign || disableRootPadding) && rule.key.startsWith("padding")) {
        return;
      }
      const cssProperty = rule.key.startsWith("--") ? rule.key : kebabCase2(rule.key);
      let ruleValue = getResolvedValue(rule.value, tree);
      if (cssProperty === "font-size") {
        ruleValue = getTypographyFontSizeValue(
          { name: "", slug: "", size: ruleValue },
          tree?.settings
        );
      }
      if (cssProperty === "aspect-ratio") {
        output.push("min-height: unset");
      }
      output.push(`${cssProperty}: ${ruleValue}`);
    });
    return output;
  }
  function getLayoutStyles({
    layoutDefinitions = LAYOUT_DEFINITIONS,
    style,
    selector: selector2,
    hasBlockGapSupport,
    hasFallbackGapSupport,
    fallbackGapValue
  }) {
    let ruleset = "";
    let gapValue = hasBlockGapSupport ? getGapCSSValue(style?.spacing?.blockGap) : "";
    if (hasFallbackGapSupport) {
      if (selector2 === ROOT_BLOCK_SELECTOR) {
        gapValue = !gapValue ? "0.5em" : gapValue;
      } else if (!hasBlockGapSupport && fallbackGapValue) {
        gapValue = fallbackGapValue;
      }
    }
    if (gapValue && layoutDefinitions) {
      Object.values(layoutDefinitions).forEach(
        ({ className, name: name2, spacingStyles }) => {
          if (!hasBlockGapSupport && "flex" !== name2 && "grid" !== name2) {
            return;
          }
          if (spacingStyles?.length) {
            spacingStyles.forEach((spacingStyle) => {
              const declarations = [];
              if (spacingStyle.rules) {
                Object.entries(spacingStyle.rules).forEach(
                  ([cssProperty, cssValue]) => {
                    declarations.push(
                      `${cssProperty}: ${cssValue ? cssValue : gapValue}`
                    );
                  }
                );
              }
              if (declarations.length) {
                let combinedSelector = "";
                if (!hasBlockGapSupport) {
                  combinedSelector = selector2 === ROOT_BLOCK_SELECTOR ? `:where(.${className}${spacingStyle?.selector || ""})` : `:where(${selector2}.${className}${spacingStyle?.selector || ""})`;
                } else {
                  combinedSelector = selector2 === ROOT_BLOCK_SELECTOR ? `:root :where(.${className})${spacingStyle?.selector || ""}` : `:root :where(${selector2}-${className})${spacingStyle?.selector || ""}`;
                }
                ruleset += `${combinedSelector} { ${declarations.join(
                  "; "
                )}; }`;
              }
            });
          }
        }
      );
      if (selector2 === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) {
        ruleset += `${ROOT_CSS_PROPERTIES_SELECTOR} { --wp--style--block-gap: ${gapValue}; }`;
      }
    }
    if (selector2 === ROOT_BLOCK_SELECTOR && layoutDefinitions) {
      const validDisplayModes = ["block", "flex", "grid"];
      Object.values(layoutDefinitions).forEach(
        ({ className, displayMode, baseStyles }) => {
          if (displayMode && validDisplayModes.includes(displayMode)) {
            ruleset += `${selector2} .${className} { display:${displayMode}; }`;
          }
          if (baseStyles?.length) {
            baseStyles.forEach((baseStyle) => {
              const declarations = [];
              if (baseStyle.rules) {
                Object.entries(baseStyle.rules).forEach(
                  ([cssProperty, cssValue]) => {
                    declarations.push(
                      `${cssProperty}: ${cssValue}`
                    );
                  }
                );
              }
              if (declarations.length) {
                const combinedSelector = `.${className}${baseStyle?.selector || ""}`;
                ruleset += `${combinedSelector} { ${declarations.join(
                  "; "
                )}; }`;
              }
            });
          }
        }
      );
    }
    return ruleset;
  }
  var STYLE_KEYS = [
    "border",
    "color",
    "dimensions",
    "spacing",
    "typography",
    "filter",
    "outline",
    "shadow",
    "background"
  ];
  function pickStyleKeys(treeToPickFrom) {
    return pickStyleAndPseudoKeys(treeToPickFrom);
  }
  function pickStyleAndPseudoKeys(treeToPickFrom, blockName) {
    if (!treeToPickFrom) {
      return {};
    }
    const entries = Object.entries(treeToPickFrom);
    const allowedPseudoSelectors = blockName ? VALID_BLOCK_PSEUDO_SELECTORS[blockName] ?? [] : [];
    const pickedEntries = entries.filter(
      ([key]) => STYLE_KEYS.includes(key) || allowedPseudoSelectors.includes(key)
    );
    const clonedEntries = pickedEntries.map(([key, style]) => [
      key,
      JSON.parse(JSON.stringify(style))
    ]);
    return Object.fromEntries(clonedEntries);
  }
  function appendPseudoSelectorStyles(styles, selector2, ruleset, featureSelectors, treeSettings, blockName, styleVariationSelector) {
    const pseudoSelectorStyles = Object.entries(styles).filter(
      ([key]) => key.startsWith(":")
    );
    if (!pseudoSelectorStyles.length) {
      return ruleset;
    }
    pseudoSelectorStyles.forEach(([pseudoKey, pseudoStyle]) => {
      if (!pseudoStyle || typeof pseudoStyle !== "object") {
        return;
      }
      const remainingPseudoStyles = JSON.parse(
        JSON.stringify(pseudoStyle)
      );
      if (featureSelectors && typeof featureSelectors !== "string") {
        let pseudoFeatureDeclarations = getFeatureDeclarations(
          featureSelectors,
          remainingPseudoStyles
        );
        pseudoFeatureDeclarations = updateParagraphTextIndentSelector(
          pseudoFeatureDeclarations,
          treeSettings,
          blockName
        );
        pseudoFeatureDeclarations = updateButtonWidthDeclarations(
          pseudoFeatureDeclarations,
          treeSettings
        );
        Object.entries(pseudoFeatureDeclarations).forEach(
          ([baseSelector, declarations]) => {
            if (!declarations.length) {
              return;
            }
            const pseudoFeatureSelector = appendToSelector(
              baseSelector,
              pseudoKey
            );
            const cssSelector = styleVariationSelector ? concatFeatureVariationSelectorString(
              pseudoFeatureSelector,
              styleVariationSelector
            ) : pseudoFeatureSelector;
            const rules = declarations.join(";");
            ruleset += `:root :where(${cssSelector}){${rules};}`;
          }
        );
      }
      const pseudoDeclarations = getStylesDeclarations(
        remainingPseudoStyles
      );
      if (!pseudoDeclarations.length) {
        return;
      }
      const pseudoSelector = appendToSelector(selector2, pseudoKey);
      const pseudoRule = `:root :where(${pseudoSelector}){${pseudoDeclarations.join(
        ";"
      )};}`;
      ruleset += pseudoRule;
    });
    return ruleset;
  }
  var getNodesWithStyles = (tree, blockSelectors) => {
    const nodes = [];
    if (!tree?.styles) {
      return nodes;
    }
    const styles = pickStyleKeys(tree.styles);
    if (styles) {
      nodes.push({
        styles,
        selector: ROOT_BLOCK_SELECTOR,
        // Root selector (body) styles should not be wrapped in `:root where()` to keep
        // specificity at (0,0,1) and maintain backwards compatibility.
        skipSelectorWrapper: true
      });
    }
    Object.entries(import_blocks7.__EXPERIMENTAL_ELEMENTS).forEach(([name2, selector2]) => {
      if (tree.styles?.elements?.[name2]) {
        nodes.push({
          styles: tree.styles?.elements?.[name2] ?? {},
          selector: selector2,
          // Top level elements that don't use a class name should not receive the
          // `:root :where()` wrapper to maintain backwards compatibility.
          skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name2]
        });
      }
    });
    Object.entries(tree.styles?.blocks ?? {}).forEach(
      ([blockName, node]) => {
        const blockStyles = pickStyleAndPseudoKeys(node, blockName);
        const typedNode = node;
        const variationNodesToAdd = [];
        if (typedNode?.variations) {
          const variations = {};
          Object.entries(typedNode.variations).forEach(
            ([variationName, variation]) => {
              const typedVariation = variation;
              variations[variationName] = pickStyleAndPseudoKeys(
                typedVariation,
                blockName
              );
              if (typedVariation?.css) {
                variations[variationName].css = typedVariation.css;
              }
              const variationSelector = typeof blockSelectors !== "string" ? blockSelectors[blockName]?.styleVariationSelectors?.[variationName] : void 0;
              Object.entries(
                typedVariation?.elements ?? {}
              ).forEach(([element, elementStyles]) => {
                if (elementStyles && import_blocks7.__EXPERIMENTAL_ELEMENTS[element]) {
                  variationNodesToAdd.push({
                    styles: elementStyles,
                    selector: scopeSelector(
                      variationSelector,
                      import_blocks7.__EXPERIMENTAL_ELEMENTS[element]
                    )
                  });
                }
              });
              Object.entries(typedVariation?.blocks ?? {}).forEach(
                ([
                  variationBlockName,
                  variationBlockStyles
                ]) => {
                  const variationBlockSelector = typeof blockSelectors !== "string" ? scopeSelector(
                    variationSelector,
                    blockSelectors[variationBlockName]?.selector
                  ) : void 0;
                  const variationDuotoneSelector = typeof blockSelectors !== "string" ? scopeSelector(
                    variationSelector,
                    blockSelectors[variationBlockName]?.duotoneSelector
                  ) : void 0;
                  const variationFeatureSelectors = typeof blockSelectors !== "string" ? scopeFeatureSelectors(
                    variationSelector,
                    blockSelectors[variationBlockName]?.featureSelectors ?? {}
                  ) : void 0;
                  const variationBlockStyleNodes = pickStyleAndPseudoKeys(
                    variationBlockStyles,
                    variationBlockName
                  );
                  if (variationBlockStyles?.css) {
                    variationBlockStyleNodes.css = variationBlockStyles.css;
                  }
                  if (!variationBlockSelector || typeof blockSelectors === "string") {
                    return;
                  }
                  variationNodesToAdd.push({
                    selector: variationBlockSelector,
                    duotoneSelector: variationDuotoneSelector,
                    featureSelectors: variationFeatureSelectors,
                    fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue,
                    hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport,
                    styles: variationBlockStyleNodes
                  });
                  Object.entries(
                    variationBlockStyles.elements ?? {}
                  ).forEach(
                    ([
                      variationBlockElement,
                      variationBlockElementStyles
                    ]) => {
                      if (variationBlockElementStyles && import_blocks7.__EXPERIMENTAL_ELEMENTS[variationBlockElement]) {
                        variationNodesToAdd.push({
                          styles: variationBlockElementStyles,
                          selector: scopeSelector(
                            variationBlockSelector,
                            import_blocks7.__EXPERIMENTAL_ELEMENTS[variationBlockElement]
                          )
                        });
                      }
                    }
                  );
                }
              );
            }
          );
          blockStyles.variations = variations;
        }
        if (typeof blockSelectors !== "string" && blockSelectors?.[blockName]?.selector) {
          nodes.push({
            duotoneSelector: blockSelectors[blockName].duotoneSelector,
            fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
            hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
            selector: blockSelectors[blockName].selector,
            styles: blockStyles,
            featureSelectors: blockSelectors[blockName].featureSelectors,
            styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors,
            name: blockName
          });
        }
        Object.entries(typedNode?.elements ?? {}).forEach(
          ([elementName, value]) => {
            if (typeof blockSelectors !== "string" && value && blockSelectors?.[blockName] && import_blocks7.__EXPERIMENTAL_ELEMENTS[elementName]) {
              nodes.push({
                styles: value,
                selector: blockSelectors[blockName]?.selector.split(",").map((sel) => {
                  const elementSelectors = import_blocks7.__EXPERIMENTAL_ELEMENTS[elementName].split(",");
                  return elementSelectors.map(
                    (elementSelector) => sel + " " + elementSelector
                  );
                }).join(",")
              });
            }
          }
        );
        nodes.push(...variationNodesToAdd);
      }
    );
    return nodes;
  };
  var getNodesWithSettings = (tree, blockSelectors) => {
    const nodes = [];
    if (!tree?.settings) {
      return nodes;
    }
    const pickPresets = (treeToPickFrom) => {
      let presets2 = {};
      PRESET_METADATA.forEach(({ path }) => {
        const value = getValueFromObjectPath(treeToPickFrom, path, false);
        if (value !== false) {
          presets2 = setImmutably(presets2, path, value);
        }
      });
      return presets2;
    };
    const presets = pickPresets(tree.settings);
    const custom = tree.settings?.custom;
    if (Object.keys(presets).length > 0 || custom) {
      nodes.push({
        presets,
        custom,
        selector: ROOT_CSS_PROPERTIES_SELECTOR
      });
    }
    Object.entries(tree.settings?.blocks ?? {}).forEach(
      ([blockName, node]) => {
        const blockCustom = node.custom;
        if (typeof blockSelectors === "string" || !blockSelectors[blockName]) {
          return;
        }
        const blockPresets = pickPresets(node);
        if (Object.keys(blockPresets).length > 0 || blockCustom) {
          nodes.push({
            presets: blockPresets,
            custom: blockCustom,
            selector: blockSelectors[blockName]?.selector,
            featureSelectors: blockSelectors[blockName]?.featureSelectors
          });
        }
      }
    );
    return nodes;
  };
  function resolveFeatureSelector(featureSelectors, featureKey, fallback) {
    if (!featureSelectors || typeof featureSelectors === "string") {
      return fallback;
    }
    const feature = featureSelectors[featureKey];
    if (typeof feature === "string") {
      return feature;
    }
    if (typeof feature === "object" && feature.root) {
      return feature.root;
    }
    return fallback;
  }
  function getPresetVarDeclarations(presets, mergedSettings, { path, valueKey, valueFunc, cssVarInfix }) {
    const presetByOrigin = getValueFromObjectPath(
      presets,
      path,
      []
    );
    const declarations = [];
    for (const origin of ["default", "theme", "custom"]) {
      if (!presetByOrigin[origin]) {
        continue;
      }
      for (const value of presetByOrigin[origin]) {
        const slug = kebabCase2(value.slug);
        if (valueKey && !valueFunc) {
          declarations.push(
            `--wp--preset--${cssVarInfix}--${slug}: ${value[valueKey]}`
          );
        } else if (valueFunc && typeof valueFunc === "function") {
          declarations.push(
            `--wp--preset--${cssVarInfix}--${slug}: ${valueFunc(
              value,
              mergedSettings
            )}`
          );
        }
      }
    }
    return declarations;
  }
  var generateCustomProperties = (tree, blockSelectors) => {
    const nodes = getNodesWithSettings(tree, blockSelectors);
    let ruleset = "";
    for (const { presets, custom, selector: selector2, featureSelectors } of nodes) {
      const defaultSelector = selector2;
      const varsBySelector = {
        [defaultSelector]: []
      };
      if (tree?.settings) {
        for (const metadata of PRESET_METADATA) {
          const declarations = getPresetVarDeclarations(
            presets,
            tree.settings,
            metadata
          );
          if (declarations.length === 0) {
            continue;
          }
          const target = resolveFeatureSelector(
            featureSelectors,
            metadata.path[0],
            defaultSelector
          );
          if (!varsBySelector[target]) {
            varsBySelector[target] = [];
          }
          varsBySelector[target].push(...declarations);
        }
      }
      const customProps = flattenTree(custom, "--wp--custom--", "--");
      if (customProps.length > 0) {
        varsBySelector[defaultSelector].push(...customProps);
      }
      for (const [ruleSelector, declarations] of Object.entries(
        varsBySelector
      )) {
        if (declarations.length > 0) {
          ruleset += `${ruleSelector}{${declarations.join(";")};}`;
        }
      }
    }
    return ruleset;
  };
  var transformToStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles = false, disableRootPadding = false, styleOptions = {}) => {
    const options = {
      blockGap: true,
      blockStyles: true,
      layoutStyles: true,
      marginReset: true,
      presets: true,
      rootPadding: true,
      variationStyles: false,
      ...styleOptions
    };
    const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
    const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
    const useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments;
    const { contentSize, wideSize } = tree?.settings?.layout || {};
    const hasBodyStyles = options.marginReset || options.rootPadding || options.layoutStyles;
    let ruleset = "";
    if (options.presets && (contentSize || wideSize)) {
      ruleset += `${ROOT_CSS_PROPERTIES_SELECTOR} {`;
      ruleset = contentSize ? ruleset + ` --wp--style--global--content-size: ${contentSize};` : ruleset;
      ruleset = wideSize ? ruleset + ` --wp--style--global--wide-size: ${wideSize};` : ruleset;
      ruleset += "}";
    }
    if (hasBodyStyles) {
      ruleset += ":where(body) {margin: 0;";
      if (options.rootPadding && useRootPaddingAlign) {
        ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
				.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
				.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
				.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; }
				.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0;
				`;
      }
      ruleset += "}";
    }
    if (options.blockStyles) {
      nodesWithStyles.forEach(
        ({
          selector: selector2,
          duotoneSelector,
          styles,
          fallbackGapValue,
          hasLayoutSupport,
          featureSelectors,
          styleVariationSelectors,
          skipSelectorWrapper,
          name: name2
        }) => {
          if (featureSelectors) {
            let featureDeclarations = getFeatureDeclarations(
              featureSelectors,
              styles
            );
            featureDeclarations = updateParagraphTextIndentSelector(
              featureDeclarations,
              tree.settings,
              name2
            );
            featureDeclarations = updateButtonWidthDeclarations(
              featureDeclarations,
              tree.settings
            );
            Object.entries(featureDeclarations).forEach(
              ([cssSelector, declarations]) => {
                if (declarations.length) {
                  const rules = declarations.join(";");
                  ruleset += `:root :where(${cssSelector}){${rules};}`;
                }
              }
            );
          }
          if (duotoneSelector) {
            const duotoneStyles = {};
            if (styles?.filter) {
              duotoneStyles.filter = styles.filter;
              delete styles.filter;
            }
            const duotoneDeclarations = getStylesDeclarations(duotoneStyles);
            if (duotoneDeclarations.length) {
              ruleset += `${duotoneSelector}{${duotoneDeclarations.join(
                ";"
              )};}`;
            }
          }
          if (!disableLayoutStyles && (ROOT_BLOCK_SELECTOR === selector2 || hasLayoutSupport)) {
            ruleset += getLayoutStyles({
              style: styles,
              selector: selector2,
              hasBlockGapSupport,
              hasFallbackGapSupport,
              fallbackGapValue
            });
          }
          const styleDeclarations = getStylesDeclarations(
            styles,
            selector2,
            useRootPaddingAlign,
            tree,
            disableRootPadding
          );
          if (styleDeclarations?.length) {
            const generalSelector = skipSelectorWrapper ? selector2 : `:root :where(${selector2})`;
            ruleset += `${generalSelector}{${styleDeclarations.join(
              ";"
            )};}`;
          }
          if (styles?.css) {
            ruleset += processCSSNesting(
              styles.css,
              `:root :where(${selector2})`
            );
          }
          if (options.variationStyles && styleVariationSelectors) {
            Object.entries(styleVariationSelectors).forEach(
              ([styleVariationName, styleVariationSelector]) => {
                const styleVariations = styles?.variations?.[styleVariationName];
                if (styleVariations) {
                  if (featureSelectors) {
                    let featureDeclarations = getFeatureDeclarations(
                      featureSelectors,
                      styleVariations
                    );
                    featureDeclarations = updateParagraphTextIndentSelector(
                      featureDeclarations,
                      tree.settings,
                      name2
                    );
                    featureDeclarations = updateButtonWidthDeclarations(
                      featureDeclarations,
                      tree.settings
                    );
                    Object.entries(
                      featureDeclarations
                    ).forEach(
                      ([baseSelector, declarations]) => {
                        if (declarations.length) {
                          const cssSelector = concatFeatureVariationSelectorString(
                            baseSelector,
                            styleVariationSelector
                          );
                          const rules = declarations.join(";");
                          ruleset += `:root :where(${cssSelector}){${rules};}`;
                        }
                      }
                    );
                  }
                  const styleVariationDeclarations = getStylesDeclarations(
                    styleVariations,
                    styleVariationSelector,
                    useRootPaddingAlign,
                    tree
                  );
                  if (styleVariationDeclarations.length) {
                    ruleset += `:root :where(${styleVariationSelector}){${styleVariationDeclarations.join(
                      ";"
                    )};}`;
                  }
                  if (styleVariations?.css) {
                    ruleset += processCSSNesting(
                      styleVariations.css,
                      `:root :where(${styleVariationSelector})`
                    );
                  }
                  ruleset = appendPseudoSelectorStyles(
                    styleVariations,
                    styleVariationSelector,
                    ruleset,
                    featureSelectors,
                    tree.settings,
                    name2,
                    styleVariationSelector
                  );
                  if (hasLayoutSupport && styleVariations?.spacing?.blockGap) {
                    const variationSelectorWithBlock = styleVariationSelector + selector2;
                    ruleset += getLayoutStyles({
                      style: styleVariations,
                      selector: variationSelectorWithBlock,
                      hasBlockGapSupport: true,
                      hasFallbackGapSupport,
                      fallbackGapValue
                    });
                  }
                }
              }
            );
          }
          ruleset = appendPseudoSelectorStyles(
            styles,
            selector2,
            ruleset,
            featureSelectors,
            tree.settings,
            name2
          );
        }
      );
    }
    if (options.layoutStyles) {
      ruleset = ruleset + ".wp-site-blocks > .alignleft { float: left; margin-right: 2em; }";
      ruleset = ruleset + ".wp-site-blocks > .alignright { float: right; margin-left: 2em; }";
      ruleset = ruleset + ".wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }";
    }
    if (options.blockGap && hasBlockGapSupport) {
      const gapValue = getGapCSSValue(tree?.styles?.spacing?.blockGap) || "0.5em";
      ruleset = ruleset + `:root :where(.wp-site-blocks) > * { margin-block-start: ${gapValue}; margin-block-end: 0; }`;
      ruleset = ruleset + ":root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }";
      ruleset = ruleset + ":root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }";
    }
    if (options.presets) {
      nodesWithSettings.forEach(({ selector: selector2, presets }) => {
        if (ROOT_BLOCK_SELECTOR === selector2 || ROOT_CSS_PROPERTIES_SELECTOR === selector2) {
          selector2 = "";
        }
        const classes = getPresetsClasses(selector2, presets);
        if (classes.length > 0) {
          ruleset += classes;
        }
      });
    }
    return ruleset;
  };
  function generateSvgFilters(tree, blockSelectors) {
    const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
    return nodesWithSettings.flatMap(({ presets }) => {
      return getPresetsSvgFilters(presets);
    });
  }
  var getSelectorsConfig = (blockType, rootSelector) => {
    if (blockType?.selectors && Object.keys(blockType.selectors).length > 0) {
      return blockType.selectors;
    }
    const config2 = {
      root: rootSelector
    };
    Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(
      ([featureKey, featureName]) => {
        const featureSelector = getBlockSelector(blockType, featureKey);
        if (featureSelector) {
          config2[featureName] = featureSelector;
        }
      }
    );
    return config2;
  };
  var getBlockSelectors = (blockTypes, variationInstanceId) => {
    const { getBlockStyles } = (0, import_data43.select)(import_blocks7.store);
    const result = {};
    blockTypes.forEach((blockType) => {
      const name2 = blockType.name;
      const selector2 = getBlockSelector(blockType);
      if (!selector2) {
        return;
      }
      let duotoneSelector = getBlockSelector(blockType, "filter.duotone");
      if (!duotoneSelector) {
        const rootSelector = getBlockSelector(blockType);
        const duotoneSupport = (0, import_blocks7.getBlockSupport)(
          blockType,
          "color.__experimentalDuotone",
          false
        );
        if (typeof duotoneSupport === "string" && rootSelector) {
          duotoneSelector = scopeSelector(rootSelector, duotoneSupport);
        }
      }
      const hasLayoutSupport = !!blockType?.supports?.layout || !!blockType?.supports?.__experimentalLayout;
      const fallbackGapValue = (
        // @ts-expect-error
        blockType?.supports?.spacing?.blockGap?.__experimentalDefault
      );
      const blockStyleVariations = getBlockStyles(name2);
      const styleVariationSelectors = {};
      blockStyleVariations?.forEach((variation) => {
        const variationSuffix = variationInstanceId ? `-${variationInstanceId}` : "";
        const variationName = `${variation.name}${variationSuffix}`;
        const styleVariationSelector = getBlockStyleVariationSelector(
          variationName,
          selector2
        );
        styleVariationSelectors[variationName] = styleVariationSelector;
      });
      const featureSelectors = getSelectorsConfig(blockType, selector2);
      result[name2] = {
        duotoneSelector: duotoneSelector ?? void 0,
        fallbackGapValue,
        featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : void 0,
        hasLayoutSupport,
        name: name2,
        selector: selector2,
        styleVariationSelectors: blockStyleVariations?.length ? styleVariationSelectors : void 0
      };
    });
    return result;
  };
  function updateConfigWithSeparator(config2) {
    const blocks = config2.styles?.blocks;
    const separatorBlock = blocks?.["core/separator"];
    const needsSeparatorStyleUpdate = separatorBlock && separatorBlock.color?.background && !separatorBlock.color?.text && !separatorBlock.border?.color;
    if (needsSeparatorStyleUpdate) {
      return {
        ...config2,
        styles: {
          ...config2.styles,
          blocks: {
            ...blocks,
            "core/separator": {
              ...separatorBlock,
              color: {
                ...separatorBlock.color,
                text: separatorBlock.color?.background
              }
            }
          }
        }
      };
    }
    return config2;
  }
  function processCSSNesting(css, blockSelector) {
    let processedCSS = "";
    if (!css || css.trim() === "") {
      return processedCSS;
    }
    const parts = css.split("&");
    parts.forEach((part) => {
      if (!part || part.trim() === "") {
        return;
      }
      const isRootCss = !part.includes("{");
      if (isRootCss) {
        processedCSS += `:root :where(${blockSelector}){${part.trim()}}`;
      } else {
        const splitPart = part.replace("}", "").split("{");
        if (splitPart.length !== 2) {
          return;
        }
        const [nestedSelector, cssValue] = splitPart;
        const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/);
        const pseudoPart = matches ? matches[1] : "";
        const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, "").trim() : nestedSelector.trim();
        let combinedSelector;
        if (withoutPseudoElement === "") {
          combinedSelector = blockSelector;
        } else {
          combinedSelector = nestedSelector.startsWith(" ") ? scopeSelector(blockSelector, withoutPseudoElement) : appendToSelector(blockSelector, withoutPseudoElement);
        }
        processedCSS += `:root :where(${combinedSelector})${pseudoPart}{${cssValue.trim()}}`;
      }
    });
    return processedCSS;
  }
  function generateGlobalStyles(config2 = {}, blockTypes = [], options = {}) {
    const {
      hasBlockGapSupport: hasBlockGapSupportOption,
      hasFallbackGapSupport: hasFallbackGapSupportOption,
      disableLayoutStyles = false,
      disableRootPadding = false,
      styleOptions = {}
    } = options;
    const blocks = blockTypes.length > 0 ? blockTypes : (0, import_blocks7.getBlockTypes)();
    const blockGap = getSetting(config2, "spacing.blockGap");
    const hasBlockGapSupport = hasBlockGapSupportOption ?? blockGap !== null;
    const hasFallbackGapSupport = hasFallbackGapSupportOption ?? !hasBlockGapSupport;
    if (!config2?.styles || !config2?.settings) {
      return [[], {}];
    }
    const updatedConfig = updateConfigWithSeparator(config2);
    const blockSelectors = getBlockSelectors(blocks);
    const customProperties = generateCustomProperties(
      updatedConfig,
      blockSelectors
    );
    const globalStyles = transformToStyles(
      updatedConfig,
      blockSelectors,
      hasBlockGapSupport,
      hasFallbackGapSupport,
      disableLayoutStyles,
      disableRootPadding,
      styleOptions
    );
    const svgs = generateSvgFilters(updatedConfig, blockSelectors);
    const styles = [
      {
        css: customProperties,
        isGlobalStyles: true
      },
      {
        css: globalStyles,
        isGlobalStyles: true
      },
      // Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.
      {
        css: updatedConfig?.styles?.css ?? "",
        isGlobalStyles: true
      },
      {
        assets: svgs,
        __unstableType: "svgs",
        isGlobalStyles: true
      }
    ];
    blocks.forEach((blockType) => {
      const blockStyles = updatedConfig?.styles?.blocks?.[blockType.name];
      if (blockStyles?.css) {
        const { featureSelectors } = blockSelectors[blockType.name];
        const cssFeatureSelector = typeof featureSelectors === "object" ? featureSelectors?.css : void 0;
        let resolvedCssSelector;
        if (typeof cssFeatureSelector === "string") {
          resolvedCssSelector = cssFeatureSelector;
        } else if (typeof cssFeatureSelector === "object") {
          resolvedCssSelector = cssFeatureSelector?.root;
        }
        const selector2 = resolvedCssSelector ?? blockSelectors[blockType.name].selector;
        styles.push({
          css: processCSSNesting(blockStyles.css, selector2),
          isGlobalStyles: true
        });
      }
    });
    return [styles, updatedConfig.settings];
  }

  // packages/global-styles-engine/build-module/preview-state-styles.mjs
  function generatePreviewStateStyles(stateStyles, blockName) {
    if (!stateStyles || !blockName) {
      return "";
    }
    const previewConfig = {
      settings: {},
      // Empty settings to satisfy the config structure
      styles: {
        blocks: {
          [blockName]: stateStyles
        }
      }
    };
    try {
      const [generatedStyles] = generateGlobalStyles(previewConfig, []);
      return generatedStyles.map((style) => style.css).join("\n");
    } catch {
      return "";
    }
  }

  // packages/editor/build-module/components/global-styles-provider/index.mjs
  var { cleanEmptyObject } = unlock(import_block_editor5.privateApis);
  function useGlobalStylesUserConfig() {
    const { globalStylesId, isReady: isReady2, settings, styles, _links } = (0, import_data44.useSelect)(
      (select7) => {
        const {
          getEntityRecord,
          getEditedEntityRecord: getEditedEntityRecord2,
          hasFinishedResolution,
          canUser
        } = select7(import_core_data29.store);
        const _globalStylesId = select7(import_core_data29.store).__experimentalGetCurrentGlobalStylesId();
        let record;
        const userCanEditGlobalStyles = _globalStylesId ? canUser("update", {
          kind: "root",
          name: "globalStyles",
          id: _globalStylesId
        }) : null;
        if (_globalStylesId && /*
        * Test that the OPTIONS request for user capabilities is complete
        * before fetching the global styles entity record.
        * This is to avoid fetching the global styles entity unnecessarily.
        */
        typeof userCanEditGlobalStyles === "boolean") {
          if (userCanEditGlobalStyles) {
            record = getEditedEntityRecord2(
              "root",
              "globalStyles",
              _globalStylesId
            );
          } else {
            record = getEntityRecord(
              "root",
              "globalStyles",
              _globalStylesId,
              { context: "view" }
            );
          }
        }
        let hasResolved = false;
        if (hasFinishedResolution(
          "__experimentalGetCurrentGlobalStylesId"
        )) {
          if (_globalStylesId) {
            hasResolved = userCanEditGlobalStyles ? hasFinishedResolution("getEditedEntityRecord", [
              "root",
              "globalStyles",
              _globalStylesId
            ]) : hasFinishedResolution("getEntityRecord", [
              "root",
              "globalStyles",
              _globalStylesId,
              { context: "view" }
            ]);
          } else {
            hasResolved = true;
          }
        }
        return {
          globalStylesId: _globalStylesId,
          isReady: hasResolved,
          settings: record?.settings,
          styles: record?.styles,
          _links: record?._links
        };
      },
      []
    );
    const { getEditedEntityRecord } = (0, import_data44.useSelect)(import_core_data29.store);
    const { editEntityRecord } = (0, import_data44.useDispatch)(import_core_data29.store);
    const config2 = (0, import_element128.useMemo)(() => {
      return {
        settings: settings ?? {},
        styles: styles ?? {},
        _links: _links ?? {}
      };
    }, [settings, styles, _links]);
    const setConfig = (0, import_element128.useCallback)(
      /**
       * Set the global styles config.
       * @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values.
       *                                           Otherwise, overwrite the current config with the incoming object.
       * @param {Object}          options          Options for editEntityRecord Core selector.
       */
      (callbackOrObject, options = {}) => {
        const record = getEditedEntityRecord(
          "root",
          "globalStyles",
          globalStylesId
        );
        const currentConfig = {
          styles: record?.styles ?? {},
          settings: record?.settings ?? {},
          _links: record?._links ?? {}
        };
        const updatedConfig = typeof callbackOrObject === "function" ? callbackOrObject(currentConfig) : callbackOrObject;
        editEntityRecord(
          "root",
          "globalStyles",
          globalStylesId,
          {
            styles: cleanEmptyObject(updatedConfig.styles) || {},
            settings: cleanEmptyObject(updatedConfig.settings) || {},
            _links: cleanEmptyObject(updatedConfig._links) || {}
          },
          options
        );
      },
      [globalStylesId, editEntityRecord, getEditedEntityRecord]
    );
    return [isReady2, config2, setConfig];
  }
  function useGlobalStylesBaseConfig() {
    const baseConfig = (0, import_data44.useSelect)(
      (select7) => select7(import_core_data29.store).__experimentalGetCurrentThemeBaseGlobalStyles(),
      []
    );
    return [!!baseConfig, baseConfig];
  }
  function useGlobalStylesContext() {
    const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig();
    const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig();
    const mergedConfig = (0, import_element128.useMemo)(() => {
      if (!baseConfig || !userConfig) {
        return {};
      }
      return mergeGlobalStyles(baseConfig, userConfig);
    }, [userConfig, baseConfig]);
    const context = (0, import_element128.useMemo)(() => {
      return {
        isReady: isUserConfigReady && isBaseConfigReady,
        user: userConfig,
        base: baseConfig,
        merged: mergedConfig,
        setUserConfig
      };
    }, [
      mergedConfig,
      userConfig,
      baseConfig,
      setUserConfig,
      isUserConfigReady,
      isBaseConfigReady
    ]);
    return context;
  }

  // packages/editor/build-module/components/provider/use-block-editor-settings.mjs
  var { store: mediaEditorStore } = unlock(privateApis12);
  var EMPTY_OBJECT4 = {};
  function __experimentalReusableBlocksSelect(select7) {
    const { RECEIVE_INTERMEDIATE_RESULTS: RECEIVE_INTERMEDIATE_RESULTS2 } = unlock(import_core_data30.privateApis);
    const { getEntityRecords } = select7(import_core_data30.store);
    return getEntityRecords("postType", "wp_block", {
      per_page: -1,
      [RECEIVE_INTERMEDIATE_RESULTS2]: true
    });
  }
  var BLOCK_EDITOR_SETTINGS = [
    "__experimentalBlockBindingsSupportedAttributes",
    "__experimentalBlockDirectory",
    "__experimentalDiscussionSettings",
    "__experimentalFeatures",
    "__experimentalGlobalStylesBaseStyles",
    "allImageSizes",
    "alignWide",
    "blockInspectorTabs",
    "maxUploadFileSize",
    "allowedMimeTypes",
    "bodyPlaceholder",
    "canEditCSS",
    "canLockBlocks",
    "canUpdateBlockBindings",
    "capabilities",
    "clearBlockSelection",
    "codeEditingEnabled",
    "colors",
    "disableContentOnlyForUnsyncedPatterns",
    "disableCustomColors",
    "disableCustomFontSizes",
    "disableCustomSpacingSizes",
    "disableCustomGradients",
    "disableLayoutStyles",
    "enableCustomLineHeight",
    "enableCustomSpacing",
    "enableCustomUnits",
    "enableOpenverseMediaCategory",
    "fontSizes",
    "gradients",
    "generateAnchors",
    "onNavigateToEntityRecord",
    "imageDefaultSize",
    "imageDimensions",
    "imageEditing",
    "imageSizes",
    "isPreviewMode",
    "isRTL",
    "locale",
    "maxWidth",
    "postContentAttributes",
    "postsPerPage",
    "readOnly",
    "styles",
    "titlePlaceholder",
    "supportsLayout",
    "widgetTypesToHideFromLegacyWidgetBlock",
    "__unstableHasCustomAppender",
    "__unstableResolvedAssets",
    "__unstableIsBlockBasedTheme"
  ];
  var {
    globalStylesDataKey,
    globalStylesLinksDataKey,
    selectBlockPatternsKey,
    reusableBlocksSelectKey,
    sectionRootClientIdKey,
    mediaEditKey,
    getMediaSelectKey,
    isIsolatedEditorKey,
    deviceTypeKey,
    isNavigationOverlayContextKey,
    isNavigationPostEditorKey,
    mediaUploadOnSuccessKey,
    openMediaEditorModalKey
  } = unlock(import_block_editor6.privateApis);
  function useBlockEditorSettings(settings, postType2, postId2, renderingMode2) {
    const isLargeViewport = (0, import_compose23.useViewportMatch)("medium");
    const {
      allImageSizes,
      bigImageSizeThreshold,
      allowRightClickOverrides,
      blockTypes,
      focusMode,
      hasFixedToolbar,
      isDistractionFree,
      keepCaretInsideBlock,
      hasUploadPermissions,
      hiddenBlockTypes,
      canUseUnfilteredHTML,
      userCanCreatePages,
      pageOnFront,
      pageForPosts,
      userPatternCategories,
      restBlockPatternCategories,
      sectionRootClientId,
      deviceType: deviceType2,
      isNavigationOverlayContext,
      isRevisionsMode: isRevisionsMode2
    } = (0, import_data45.useSelect)(
      (select7) => {
        const {
          canUser,
          getRawEntityRecord,
          getEntityRecord,
          getUserPatternCategories,
          getBlockPatternCategories
        } = select7(import_core_data30.store);
        const { get } = select7(import_preferences6.store);
        const { getBlockTypes: getBlockTypes6 } = select7(import_blocks8.store);
        const { getDeviceType: getDeviceType2, isRevisionsMode: _isRevisionsMode } = unlock(
          select7(store3)
        );
        const { getBlocksByName, getBlockAttributes: getBlockAttributes2 } = select7(import_block_editor6.store);
        const siteSettings = canUser("read", {
          kind: "root",
          name: "site"
        }) ? getEntityRecord("root", "site") : void 0;
        const baseData = getEntityRecord("root", "__unstableBase");
        function getSectionRootBlock() {
          if (renderingMode2 === "template-locked") {
            return getBlocksByName("core/post-content")?.[0] ?? "";
          }
          return getBlocksByName("core/group").find(
            (clientId) => getBlockAttributes2(clientId)?.tagName === "main"
          ) ?? "";
        }
        return {
          allImageSizes: baseData?.image_sizes,
          bigImageSizeThreshold: baseData?.image_size_threshold,
          allowRightClickOverrides: get(
            "core",
            "allowRightClickOverrides"
          ),
          blockTypes: getBlockTypes6(),
          canUseUnfilteredHTML: getRawEntityRecord(
            "postType",
            postType2,
            postId2
          )?._links?.hasOwnProperty("wp:action-unfiltered-html"),
          focusMode: get("core", "focusMode"),
          hasFixedToolbar: get("core", "fixedToolbar") || !isLargeViewport,
          hiddenBlockTypes: get("core", "hiddenBlockTypes"),
          isDistractionFree: get("core", "distractionFree"),
          keepCaretInsideBlock: get("core", "keepCaretInsideBlock"),
          hasUploadPermissions: canUser("create", {
            kind: "postType",
            name: "attachment"
          }) ?? true,
          userCanCreatePages: canUser("create", {
            kind: "postType",
            name: "page"
          }),
          pageOnFront: siteSettings?.page_on_front,
          pageForPosts: siteSettings?.page_for_posts,
          userPatternCategories: getUserPatternCategories(),
          restBlockPatternCategories: getBlockPatternCategories(),
          sectionRootClientId: getSectionRootBlock(),
          deviceType: getDeviceType2(),
          isNavigationOverlayContext: postType2 === "wp_template_part" && postId2 ? getEntityRecord(
            "postType",
            "wp_template_part",
            postId2
          )?.area === "navigation-overlay" : false,
          isRevisionsMode: _isRevisionsMode()
        };
      },
      [postType2, postId2, isLargeViewport, renderingMode2]
    );
    const { merged: mergedGlobalStyles } = useGlobalStylesContext();
    const globalStylesData = mergedGlobalStyles.styles ?? EMPTY_OBJECT4;
    const globalStylesLinksData = mergedGlobalStyles._links ?? EMPTY_OBJECT4;
    const settingsBlockPatterns = settings.__experimentalAdditionalBlockPatterns ?? // WP 6.0
    settings.__experimentalBlockPatterns;
    const settingsBlockPatternCategories = settings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0
    settings.__experimentalBlockPatternCategories;
    const blockPatterns = (0, import_element129.useMemo)(
      () => [...settingsBlockPatterns || []].filter(
        ({ postTypes }) => {
          return !postTypes || Array.isArray(postTypes) && postTypes.includes(postType2);
        }
      ),
      [settingsBlockPatterns, postType2]
    );
    const blockPatternCategories = (0, import_element129.useMemo)(
      () => [
        ...settingsBlockPatternCategories || [],
        ...restBlockPatternCategories || []
      ].filter(
        (x2, index, arr) => index === arr.findIndex((y3) => x2.name === y3.name)
      ),
      [settingsBlockPatternCategories, restBlockPatternCategories]
    );
    const { undo: undo2, setIsInserterOpened: setIsInserterOpened2 } = (0, import_data45.useDispatch)(store3);
    const { editMediaEntity } = unlock((0, import_data45.useDispatch)(import_core_data30.store));
    const { saveEntityRecord } = (0, import_data45.useDispatch)(import_core_data30.store);
    const { openMediaEditorModal: openMediaEditorModal2 } = (0, import_data45.useDispatch)(mediaEditorStore);
    const createPageEntity = (0, import_element129.useCallback)(
      (options) => {
        if (!userCanCreatePages) {
          return Promise.reject({
            message: (0, import_i18n126.__)(
              "You do not have permission to create Pages."
            )
          });
        }
        return saveEntityRecord("postType", "page", options);
      },
      [saveEntityRecord, userCanCreatePages]
    );
    const allowedBlockTypes = (0, import_element129.useMemo)(() => {
      if (hiddenBlockTypes && hiddenBlockTypes.length > 0) {
        const defaultAllowedBlockTypes = true === settings.allowedBlockTypes ? blockTypes.map(({ name: name2 }) => name2) : settings.allowedBlockTypes || [];
        return defaultAllowedBlockTypes.filter(
          (type) => !hiddenBlockTypes.includes(type)
        );
      }
      return settings.allowedBlockTypes;
    }, [settings.allowedBlockTypes, hiddenBlockTypes, blockTypes]);
    const forceDisableFocusMode = settings.focusMode === false;
    return (0, import_element129.useMemo)(() => {
      const blockEditorSettings = {
        ...Object.fromEntries(
          Object.entries(settings).filter(
            ([key]) => BLOCK_EDITOR_SETTINGS.includes(key)
          )
        ),
        [globalStylesDataKey]: globalStylesData,
        [globalStylesLinksDataKey]: globalStylesLinksData,
        allImageSizes,
        bigImageSizeThreshold,
        allowedBlockTypes,
        allowRightClickOverrides,
        focusMode: focusMode && !forceDisableFocusMode,
        hasFixedToolbar,
        isDistractionFree,
        keepCaretInsideBlock,
        [getMediaSelectKey]: (select7, attachmentId) => {
          return select7(import_core_data30.store).getEntityRecord(
            "postType",
            "attachment",
            attachmentId
          );
        },
        [mediaEditKey]: hasUploadPermissions ? editMediaEntity : void 0,
        [openMediaEditorModalKey]: window?.__experimentalMediaEditorModal ? ({ id, onUpdate }) => openMediaEditorModal2({ id, onUpdate }) : void 0,
        mediaUpload: hasUploadPermissions ? mediaUpload : void 0,
        [mediaUploadOnSuccessKey]: hasUploadPermissions ? mediaUploadOnSuccess : void 0,
        mediaSideload: hasUploadPermissions ? media_sideload_default : void 0,
        mediaFinalize: hasUploadPermissions ? mediaFinalize : void 0,
        __experimentalBlockPatterns: blockPatterns,
        [selectBlockPatternsKey]: (select7) => {
          const { hasFinishedResolution, getBlockPatternsForPostType } = unlock(select7(import_core_data30.store));
          const patterns2 = getBlockPatternsForPostType(postType2);
          return hasFinishedResolution("getBlockPatterns") ? patterns2 : void 0;
        },
        [reusableBlocksSelectKey]: __experimentalReusableBlocksSelect,
        __experimentalBlockPatternCategories: blockPatternCategories,
        __experimentalUserPatternCategories: userPatternCategories,
        __experimentalFetchLinkSuggestions: (search, searchOptions) => (0, import_core_data30.__experimentalFetchLinkSuggestions)(search, searchOptions, settings),
        inserterMediaCategories: media_categories_default,
        __experimentalFetchRichUrlData: import_core_data30.__experimentalFetchUrlData,
        // Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.
        // This might be better as a generic "canUser" selector.
        __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
        //Todo: this is only needed for native and should probably be removed.
        __experimentalUndo: undo2,
        // Check whether we want all site editor frames to have outlines
        // including the navigation / pattern / parts editors.
        outlineMode: !isDistractionFree && postType2 === "wp_template",
        // Check these two properties: they were not present in the site editor.
        __experimentalCreatePageEntity: createPageEntity,
        __experimentalUserCanCreatePages: userCanCreatePages,
        pageOnFront,
        pageForPosts,
        __experimentalPreferPatternsOnRoot: postType2 === "wp_template",
        templateLock: postType2 === "wp_navigation" ? "insert" : settings.templateLock,
        template: postType2 === "wp_navigation" ? [["core/navigation", {}, []]] : settings.template,
        __experimentalSetIsInserterOpened: setIsInserterOpened2,
        [sectionRootClientIdKey]: sectionRootClientId,
        editorTool: renderingMode2 === "post-only" && postType2 !== "wp_template" ? "edit" : void 0,
        // When editing template parts, patterns, or navigation directly,
        // we're in an isolated editing context (focused on that entity alone).
        [isIsolatedEditorKey]: [
          "wp_template_part",
          "wp_block",
          "wp_navigation"
        ].includes(postType2),
        [isNavigationPostEditorKey]: postType2 === "wp_navigation",
        // When in template-locked mode (e.g., "Show Template" in the post editor),
        // don't treat template parts as contentOnly sections.
        disableContentOnlyForTemplateParts: renderingMode2 === "template-locked",
        ...deviceType2 ? { [deviceTypeKey]: deviceType2 } : {},
        [isNavigationOverlayContextKey]: isNavigationOverlayContext
      };
      if (isRevisionsMode2) {
        blockEditorSettings.isPreviewMode = true;
      }
      return blockEditorSettings;
    }, [
      isRevisionsMode2,
      allowedBlockTypes,
      allowRightClickOverrides,
      focusMode,
      forceDisableFocusMode,
      hasFixedToolbar,
      isDistractionFree,
      keepCaretInsideBlock,
      settings,
      hasUploadPermissions,
      userPatternCategories,
      blockPatterns,
      blockPatternCategories,
      canUseUnfilteredHTML,
      undo2,
      createPageEntity,
      userCanCreatePages,
      pageOnFront,
      pageForPosts,
      postType2,
      setIsInserterOpened2,
      sectionRootClientId,
      globalStylesData,
      globalStylesLinksData,
      renderingMode2,
      editMediaEntity,
      openMediaEditorModal2,
      settings.onNavigateToEntityRecord,
      deviceType2,
      allImageSizes,
      bigImageSizeThreshold,
      isNavigationOverlayContext
    ]);
  }
  var use_block_editor_settings_default = useBlockEditorSettings;

  // packages/editor/build-module/components/provider/disable-non-page-content-blocks.mjs
  var import_data46 = __toESM(require_data(), 1);
  var import_block_editor7 = __toESM(require_block_editor(), 1);
  var import_element131 = __toESM(require_element(), 1);

  // packages/editor/build-module/components/provider/use-post-content-block-types.mjs
  var import_element130 = __toESM(require_element(), 1);
  var import_hooks4 = __toESM(require_hooks(), 1);
  var POST_CONTENT_BLOCK_TYPES = [
    "core/post-title",
    "core/post-featured-image",
    "core/post-content"
  ];
  function usePostContentBlockTypes() {
    return (0, import_element130.useMemo)(
      () => [
        ...(0, import_hooks4.applyFilters)(
          "editor.postContentBlockTypes",
          POST_CONTENT_BLOCK_TYPES
        )
      ],
      []
    );
  }

  // packages/editor/build-module/components/provider/disable-non-page-content-blocks.mjs
  function DisableNonPageContentBlocks() {
    const postContentBlockTypes = usePostContentBlockTypes();
    const { contentOnlyIds, templateParts } = (0, import_data46.useSelect)(
      (select7) => {
        const { getPostBlocksByName: getPostBlocksByName2 } = unlock(select7(store3));
        const { getBlocksByName } = select7(import_block_editor7.store);
        return {
          contentOnlyIds: getPostBlocksByName2(postContentBlockTypes),
          templateParts: getBlocksByName("core/template-part")
        };
      },
      [postContentBlockTypes]
    );
    const templatePartChildren = (0, import_data46.useSelect)(
      (select7) => {
        const { getBlockOrder: getBlockOrder2 } = select7(import_block_editor7.store);
        return templateParts.flatMap(
          (clientId) => getBlockOrder2(clientId)
        );
      },
      [templateParts]
    );
    const registry = (0, import_data46.useRegistry)();
    (0, import_element131.useEffect)(() => {
      const { setBlockEditingMode, unsetBlockEditingMode } = registry.dispatch(import_block_editor7.store);
      setBlockEditingMode("", "disabled");
      return () => {
        unsetBlockEditingMode("");
      };
    }, [registry]);
    (0, import_element131.useEffect)(() => {
      const { setBlockEditingMode, unsetBlockEditingMode } = registry.dispatch(import_block_editor7.store);
      registry.batch(() => {
        for (const clientId of templateParts) {
          setBlockEditingMode(clientId, "contentOnly");
        }
      });
      return () => {
        registry.batch(() => {
          for (const clientId of templateParts) {
            unsetBlockEditingMode(clientId);
          }
        });
      };
    }, [templateParts, registry]);
    (0, import_element131.useEffect)(() => {
      const { setBlockEditingMode, unsetBlockEditingMode } = registry.dispatch(import_block_editor7.store);
      const contentOnlySet = new Set(contentOnlyIds);
      registry.batch(() => {
        for (const clientId of contentOnlyIds) {
          setBlockEditingMode(clientId, "contentOnly");
        }
        for (const clientId of templatePartChildren) {
          if (!contentOnlySet.has(clientId)) {
            setBlockEditingMode(clientId, "disabled");
          }
        }
      });
      return () => {
        registry.batch(() => {
          for (const clientId of contentOnlyIds) {
            unsetBlockEditingMode(clientId);
          }
          for (const clientId of templatePartChildren) {
            if (!contentOnlySet.has(clientId)) {
              unsetBlockEditingMode(clientId);
            }
          }
        });
      };
    }, [contentOnlyIds, templatePartChildren, registry]);
    return null;
  }

  // packages/editor/build-module/components/provider/navigation-block-editing-mode.mjs
  var import_element132 = __toESM(require_element(), 1);
  var import_data47 = __toESM(require_data(), 1);
  var import_block_editor8 = __toESM(require_block_editor(), 1);
  function NavigationBlockEditingMode() {
    const blockClientId = (0, import_data47.useSelect)(
      (select7) => select7(import_block_editor8.store).getBlockOrder()?.[0],
      []
    );
    const { setBlockEditingMode, unsetBlockEditingMode } = (0, import_data47.useDispatch)(import_block_editor8.store);
    (0, import_element132.useEffect)(() => {
      if (!blockClientId) {
        return;
      }
      setBlockEditingMode(blockClientId, "contentOnly");
      return () => {
        unsetBlockEditingMode(blockClientId);
      };
    }, [blockClientId, unsetBlockEditingMode, setBlockEditingMode]);
  }

  // packages/editor/build-module/components/provider/use-hide-blocks-from-inserter.mjs
  var import_element133 = __toESM(require_element(), 1);
  var import_hooks5 = __toESM(require_hooks(), 1);
  var POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = [
    "wp_block",
    "wp_template",
    "wp_template_part"
  ];
  function useHideBlocksFromInserter(postType2, mode) {
    (0, import_element133.useEffect)(() => {
      (0, import_hooks5.addFilter)(
        "blockEditor.__unstableCanInsertBlockType",
        "removeTemplatePartsFromInserter",
        (canInsert, blockType) => {
          if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(
            postType2
          ) && blockType.name === "core/template-part" && mode === "post-only") {
            return false;
          }
          return canInsert;
        }
      );
      (0, import_hooks5.addFilter)(
        "blockEditor.__unstableCanInsertBlockType",
        "removePostContentFromInserter",
        (canInsert, blockType, rootClientId, { getBlockParentsByBlockName }) => {
          if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(
            postType2
          ) && blockType.name === "core/post-content") {
            return getBlockParentsByBlockName(rootClientId, "core/query").length > 0;
          }
          return canInsert;
        }
      );
      return () => {
        (0, import_hooks5.removeFilter)(
          "blockEditor.__unstableCanInsertBlockType",
          "removeTemplatePartsFromInserter"
        );
        (0, import_hooks5.removeFilter)(
          "blockEditor.__unstableCanInsertBlockType",
          "removePostContentFromInserter"
        );
      };
    }, [postType2, mode]);
  }

  // packages/editor/build-module/components/provider/use-revision-blocks.mjs
  var import_data48 = __toESM(require_data(), 1);
  var import_element134 = __toESM(require_element(), 1);
  var import_blocks10 = __toESM(require_blocks(), 1);

  // packages/editor/build-module/components/post-revisions-preview/block-diff.mjs
  var import_array5 = __toESM(require_array(), 1);
  var import_word = __toESM(require_word(), 1);
  var import_block_serialization_default_parser = __toESM(require_block_serialization_default_parser(), 1);
  var import_blocks9 = __toESM(require_blocks(), 1);
  var import_rich_text = __toESM(require_rich_text(), 1);
  var import_i18n127 = __toESM(require_i18n(), 1);
  var { parseRawBlock } = unlock(import_blocks9.privateApis);
  function stringifyValue(value) {
    if (value === null || value === void 0) {
      return "";
    }
    if (typeof value === "object") {
      return JSON.stringify(value, null, 2);
    }
    return String(value);
  }
  function textSimilarity(text1, text2) {
    if (!text1 && !text2) {
      return 1;
    }
    if (!text1 || !text2) {
      return 0;
    }
    const changes = (0, import_word.diffWords)(text1, text2);
    const unchanged = changes.filter((c6) => !c6.added && !c6.removed).reduce((sum, c6) => sum + c6.value.length, 0);
    const total = Math.max(text1.length, text2.length);
    return total > 0 ? unchanged / total : 0;
  }
  function pairSimilarBlocks(blocks) {
    const removed = [];
    const added = [];
    blocks.forEach((block, index) => {
      const status = block.__revisionDiffStatus?.status;
      if (status === "removed") {
        removed.push({ block, index });
      } else if (status === "added") {
        added.push({ block, index });
      }
    });
    if (removed.length === 0 || added.length === 0) {
      return blocks;
    }
    const pairedRemoved = /* @__PURE__ */ new Set();
    const modifications = /* @__PURE__ */ new Map();
    const SIMILARITY_THRESHOLD = 0.3;
    for (const rem of removed) {
      let bestMatch = null;
      let bestScore = 0;
      for (const add3 of added) {
        if (modifications.has(add3.index)) {
          continue;
        }
        if (add3.block.blockName !== rem.block.blockName) {
          continue;
        }
        const score = textSimilarity(
          rem.block.innerHTML || "",
          add3.block.innerHTML || ""
        );
        const attrsMatch = JSON.stringify(rem.block.attrs) === JSON.stringify(add3.block.attrs);
        if (score > bestScore && score > SIMILARITY_THRESHOLD && (score < 1 || !attrsMatch)) {
          bestScore = score;
          bestMatch = add3;
        }
      }
      if (bestMatch) {
        pairedRemoved.add(rem.index);
        modifications.set(bestMatch.index, {
          ...bestMatch.block,
          __revisionDiffStatus: { status: "modified" },
          __previousRawBlock: rem.block
        });
      }
    }
    return blocks.map((block, index) => {
      if (pairedRemoved.has(index)) {
        return null;
      }
      if (modifications.has(index)) {
        return modifications.get(index);
      }
      return block;
    }).filter(Boolean);
  }
  function diffRawBlocks(currentRaw, previousRaw) {
    const createBlockSignature = (rawBlock) => JSON.stringify({
      name: rawBlock.blockName,
      attrs: rawBlock.attrs,
      // Use innerContent filtered to non-null and non-whitespace-only strings.
      // This excludes whitespace between inner blocks which changes based on count.
      html: (rawBlock.innerContent || []).filter(
        (c6) => c6 !== null && c6.trim() !== ""
      )
    });
    const currentSigs = currentRaw.map(createBlockSignature);
    const previousSigs = previousRaw.map(createBlockSignature);
    const diff = (0, import_array5.diffArrays)(previousSigs, currentSigs);
    const result = [];
    let currIdx = 0;
    let prevIdx = 0;
    for (const part of diff) {
      if (part.added) {
        for (let i3 = 0; i3 < part.count; i3++) {
          result.push({
            ...currentRaw[currIdx++],
            __revisionDiffStatus: { status: "added" }
          });
        }
      } else if (part.removed) {
        for (let i3 = 0; i3 < part.count; i3++) {
          result.push({
            ...previousRaw[prevIdx++],
            __revisionDiffStatus: { status: "removed" }
          });
        }
      } else {
        for (let i3 = 0; i3 < part.count; i3++) {
          const currBlock = currentRaw[currIdx++];
          const prevBlock = previousRaw[prevIdx++];
          const diffedInnerBlocks = diffRawBlocks(
            currBlock.innerBlocks || [],
            prevBlock.innerBlocks || []
          );
          result.push({
            ...currBlock,
            innerBlocks: diffedInnerBlocks
          });
        }
      }
    }
    return pairSimilarBlocks(result);
  }
  function hasFormatChangedAtIndex(currentFormats, previousFormats, currentIndex, previousIndex) {
    const currFmts = currentFormats[currentIndex] || [];
    const prevFmts = previousFormats[previousIndex] || [];
    if (currFmts.length !== prevFmts.length) {
      return true;
    }
    for (const fmt of currFmts) {
      const match3 = prevFmts.find(
        (pf) => pf.type === fmt.type && JSON.stringify(pf.attributes) === JSON.stringify(fmt.attributes)
      );
      if (!match3) {
        return true;
      }
    }
    return false;
  }
  function describeFormatChange(currentFormats, previousFormats, currIdx, prevIdx) {
    const currFmts = currentFormats[currIdx] || [];
    const prevFmts = previousFormats[prevIdx] || [];
    let addedCount = 0;
    let removedCount = 0;
    let changedCount = 0;
    for (const fmt of currFmts) {
      const match3 = prevFmts.find((pf) => pf.type === fmt.type);
      if (!match3) {
        addedCount++;
      } else if (JSON.stringify(fmt.attributes) !== JSON.stringify(match3.attributes)) {
        changedCount++;
      }
    }
    for (const fmt of prevFmts) {
      const match3 = currFmts.find((cf) => cf.type === fmt.type);
      if (!match3) {
        removedCount++;
      }
    }
    if (addedCount > 0 && removedCount === 0 && changedCount === 0) {
      return {
        type: "added",
        description: (0, import_i18n127.sprintf)(
          /* translators: %d: number of formats added */
          (0, import_i18n127._n)("%d format added", "%d formats added", addedCount),
          addedCount
        )
      };
    }
    if (removedCount > 0 && addedCount === 0 && changedCount === 0) {
      return {
        type: "removed",
        description: (0, import_i18n127.sprintf)(
          /* translators: %d: number of formats removed */
          (0, import_i18n127._n)("%d format removed", "%d formats removed", removedCount),
          removedCount
        )
      };
    }
    const parts = [];
    if (addedCount > 0) {
      parts.push(
        (0, import_i18n127.sprintf)(
          /* translators: %d: number of formats added */
          (0, import_i18n127._n)("%d format added", "%d formats added", addedCount),
          addedCount
        )
      );
    }
    if (removedCount > 0) {
      parts.push(
        (0, import_i18n127.sprintf)(
          /* translators: %d: number of formats removed */
          (0, import_i18n127._n)("%d format removed", "%d formats removed", removedCount),
          removedCount
        )
      );
    }
    if (changedCount > 0) {
      parts.push(
        (0, import_i18n127.sprintf)(
          /* translators: %d: number of formats changed */
          (0, import_i18n127._n)("%d format changed", "%d formats changed", changedCount),
          changedCount
        )
      );
    }
    return {
      type: "changed",
      description: parts.join(", ") || (0, import_i18n127.__)("Formatting changed")
    };
  }
  function applyRichTextDiff(currentRichText, previousRichText) {
    const currentText = currentRichText.toPlainText();
    const previousText = previousRichText.toPlainText();
    const textDiff = (0, import_word.diffWords)(previousText, currentText);
    let result = (0, import_rich_text.create)({ text: "" });
    let currentIdx = 0;
    let previousIdx = 0;
    for (const part of textDiff) {
      if (part.removed) {
        const removedSlice = (0, import_rich_text.slice)(
          previousRichText,
          previousIdx,
          previousIdx + part.value.length
        );
        const formatted = (0, import_rich_text.applyFormat)(
          removedSlice,
          {
            type: "revision/diff-removed",
            attributes: { title: (0, import_i18n127.__)("Removed") }
          },
          0,
          part.value.length
        );
        result = (0, import_rich_text.concat)(result, formatted);
        previousIdx += part.value.length;
      } else if (part.added) {
        const addedSlice = (0, import_rich_text.slice)(
          currentRichText,
          currentIdx,
          currentIdx + part.value.length
        );
        const formatted = (0, import_rich_text.applyFormat)(
          addedSlice,
          {
            type: "revision/diff-added",
            attributes: { title: (0, import_i18n127.__)("Added") }
          },
          0,
          part.value.length
        );
        result = (0, import_rich_text.concat)(result, formatted);
        currentIdx += part.value.length;
      } else {
        const currentFormats = currentRichText.formats || [];
        const previousFormats = previousRichText.formats || [];
        const len2 = part.value.length;
        const checkFormatChanged = (offset) => hasFormatChangedAtIndex(
          currentFormats,
          previousFormats,
          currentIdx + offset,
          previousIdx + offset
        );
        let rangeStart = 0;
        let rangeFormatChanged = checkFormatChanged(0);
        for (let i3 = 1; i3 <= len2; i3++) {
          const formatChanged = i3 < len2 && checkFormatChanged(i3);
          if (i3 === len2 || formatChanged !== rangeFormatChanged) {
            const rangeSlice = (0, import_rich_text.slice)(
              currentRichText,
              currentIdx + rangeStart,
              currentIdx + i3
            );
            if (rangeFormatChanged) {
              const { type, description } = describeFormatChange(
                currentFormats,
                previousFormats,
                currentIdx + rangeStart,
                previousIdx + rangeStart
              );
              const formatType = {
                added: "revision/diff-format-added",
                removed: "revision/diff-format-removed",
                changed: "revision/diff-format-changed"
              }[type];
              const marked = (0, import_rich_text.applyFormat)(
                rangeSlice,
                {
                  type: formatType,
                  attributes: { title: description }
                },
                0,
                i3 - rangeStart
              );
              result = (0, import_rich_text.concat)(result, marked);
            } else {
              result = (0, import_rich_text.concat)(result, rangeSlice);
            }
            rangeStart = i3;
            rangeFormatChanged = formatChanged;
          }
        }
        currentIdx += part.value.length;
        previousIdx += part.value.length;
      }
    }
    return new import_rich_text.RichTextData(result);
  }
  function applyDiffToBlock(currentBlock, previousBlock, diffStatus) {
    const blockType = (0, import_blocks9.getBlockType)(currentBlock.name);
    if (!blockType) {
      return;
    }
    const changedAttributes = {};
    for (const [attrName, attrDef] of Object.entries(
      blockType.attributes
    )) {
      if (attrDef.source === "rich-text") {
        const currentRichText = currentBlock.attributes[attrName];
        const previousRichText = previousBlock.attributes[attrName];
        if (currentRichText instanceof import_rich_text.RichTextData && previousRichText instanceof import_rich_text.RichTextData) {
          currentBlock.attributes[attrName] = applyRichTextDiff(
            currentRichText,
            previousRichText
          );
        }
      } else {
        const currStr = stringifyValue(
          currentBlock.attributes[attrName]
        );
        const prevStr = stringifyValue(
          previousBlock.attributes[attrName]
        );
        if (currStr !== prevStr) {
          changedAttributes[attrName] = (0, import_word.diffWords)(prevStr, currStr);
        }
      }
    }
    if (Object.keys(changedAttributes).length > 0) {
      diffStatus.changedAttributes = changedAttributes;
    }
  }
  function applyDiffRecursively(parsedBlock, rawBlock) {
    if (rawBlock.__revisionDiffStatus) {
      if (rawBlock.__revisionDiffStatus.status === "modified" && rawBlock.__previousRawBlock) {
        const previousParsed = parseRawBlock(rawBlock.__previousRawBlock);
        if (previousParsed) {
          applyDiffToBlock(
            parsedBlock,
            previousParsed,
            rawBlock.__revisionDiffStatus
          );
        }
      }
      parsedBlock.__revisionDiffStatus = rawBlock.__revisionDiffStatus;
      parsedBlock.attributes.__revisionDiffStatus = rawBlock.__revisionDiffStatus;
    }
    if (parsedBlock.innerBlocks && rawBlock.innerBlocks) {
      for (let i3 = 0; i3 < parsedBlock.innerBlocks.length; i3++) {
        const parsedInner = parsedBlock.innerBlocks[i3];
        const rawInner = rawBlock.innerBlocks[i3];
        if (parsedInner && rawInner) {
          applyDiffRecursively(parsedInner, rawInner);
        }
      }
    }
  }
  function diffRevisionContent(currentContent, previousContent) {
    const currentRaw = (0, import_block_serialization_default_parser.parse)(currentContent || "");
    const previousRaw = (0, import_block_serialization_default_parser.parse)(previousContent || "");
    const mergedRaw = diffRawBlocks(currentRaw, previousRaw);
    return mergedRaw.map((rawBlock) => {
      const parsed = parseRawBlock(rawBlock);
      if (parsed) {
        applyDiffRecursively(parsed, rawBlock);
      }
      return parsed;
    }).filter(Boolean);
  }

  // packages/editor/build-module/components/post-revisions-preview/preserve-client-ids.mjs
  var import_array6 = __toESM(require_array(), 1);
  function preserveClientIds(newBlocks, prevBlocks) {
    if (!prevBlocks?.length || !newBlocks?.length) {
      return newBlocks;
    }
    const newSigs = newBlocks.map((block) => block.name);
    const prevSigs = prevBlocks.map((block) => block.name);
    const diffResult = (0, import_array6.diffArrays)(prevSigs, newSigs);
    let newIndex = 0;
    let prevIndex = 0;
    const result = [];
    for (const chunk2 of diffResult) {
      if (chunk2.removed) {
        prevIndex += chunk2.count;
      } else if (chunk2.added) {
        for (let i3 = 0; i3 < chunk2.count; i3++) {
          result.push(newBlocks[newIndex++]);
        }
      } else {
        for (let i3 = 0; i3 < chunk2.count; i3++) {
          const newBlock = newBlocks[newIndex++];
          const prevBlock = prevBlocks[prevIndex++];
          result.push({
            ...newBlock,
            clientId: prevBlock.clientId,
            innerBlocks: preserveClientIds(
              newBlock.innerBlocks,
              prevBlock.innerBlocks
            )
          });
        }
      }
    }
    return result;
  }

  // packages/editor/build-module/components/provider/use-revision-blocks.mjs
  function useRevisionBlocks() {
    const {
      isInRevisionsMode,
      showDiff,
      revision,
      previousRevision,
      postType: postType2
    } = (0, import_data48.useSelect)((select7) => {
      const {
        isRevisionsMode: isRevisionsMode2,
        isShowingRevisionDiff: isShowingRevisionDiff2,
        getCurrentRevision: getCurrentRevision2,
        getPreviousRevision: getPreviousRevision2
      } = unlock(select7(store3));
      const { getCurrentPostType: getCurrentPostType2 } = select7(store3);
      const inRevisions = isRevisionsMode2();
      return {
        isInRevisionsMode: inRevisions,
        showDiff: isShowingRevisionDiff2(),
        revision: inRevisions ? getCurrentRevision2() : void 0,
        previousRevision: inRevisions ? getPreviousRevision2() : void 0,
        postType: getCurrentPostType2()
      };
    }, []);
    const previousBlocksRef = (0, import_element134.useRef)([]);
    const blocks = (0, import_element134.useMemo)(() => {
      if (!isInRevisionsMode) {
        previousBlocksRef.current = [];
        return null;
      }
      if (!revision) {
        return [];
      }
      const currentContent = revision?.content?.raw ?? "";
      let parsedBlocks;
      if (showDiff) {
        const previousContent = previousRevision?.content?.raw || "";
        parsedBlocks = diffRevisionContent(
          currentContent,
          previousContent
        );
      } else {
        parsedBlocks = (0, import_blocks10.parse)(currentContent);
      }
      if (postType2 === "wp_navigation") {
        parsedBlocks = [
          (0, import_blocks10.createBlock)(
            "core/navigation",
            { templateLock: false },
            parsedBlocks
          )
        ];
      }
      const blocksWithStableIds = preserveClientIds(
        parsedBlocks,
        previousBlocksRef.current
      );
      previousBlocksRef.current = blocksWithStableIds;
      return blocksWithStableIds;
    }, [
      isInRevisionsMode,
      revision,
      revision?.content?.raw,
      previousRevision?.content?.raw,
      postType2,
      showDiff
    ]);
    return blocks;
  }

  // packages/editor/build-module/components/commands/index.mjs
  var import_data51 = __toESM(require_data(), 1);
  var import_i18n128 = __toESM(require_i18n(), 1);
  var import_commands = __toESM(require_commands(), 1);
  var import_preferences7 = __toESM(require_preferences(), 1);
  var import_notices15 = __toESM(require_notices(), 1);
  var import_block_editor9 = __toESM(require_block_editor(), 1);
  var import_core_data33 = __toESM(require_core_data(), 1);
  var import_html_entities8 = __toESM(require_html_entities(), 1);

  // packages/editor/build-module/components/pattern-rename-modal/index.mjs
  var import_data49 = __toESM(require_data(), 1);
  var import_patterns5 = __toESM(require_patterns(), 1);
  var import_core_data31 = __toESM(require_core_data(), 1);
  var import_jsx_runtime241 = __toESM(require_jsx_runtime(), 1);
  var { RenamePatternModal } = unlock(import_patterns5.privateApis);
  var modalName = "editor/pattern-rename";
  function PatternRenameModal() {
    const isActive = (0, import_data49.useSelect)(
      (select7) => select7(store2).isModalActive(modalName)
    );
    const { record, postType: postType2 } = (0, import_data49.useSelect)(
      (select7) => {
        if (!isActive) {
          return {};
        }
        const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select7(store3);
        const { getEditedEntityRecord } = select7(import_core_data31.store);
        const _postType = getCurrentPostType2();
        return {
          record: getEditedEntityRecord(
            "postType",
            _postType,
            getCurrentPostId2()
          ),
          postType: _postType
        };
      },
      [isActive]
    );
    const { closeModal: closeModal2 } = (0, import_data49.useDispatch)(store2);
    if (!isActive || postType2 !== PATTERN_POST_TYPE) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime241.jsx)(RenamePatternModal, { onClose: closeModal2, pattern: record });
  }

  // packages/editor/build-module/components/pattern-duplicate-modal/index.mjs
  var import_data50 = __toESM(require_data(), 1);
  var import_patterns6 = __toESM(require_patterns(), 1);
  var import_core_data32 = __toESM(require_core_data(), 1);
  var import_jsx_runtime242 = __toESM(require_jsx_runtime(), 1);
  var { DuplicatePatternModal } = unlock(import_patterns6.privateApis);
  var modalName2 = "editor/pattern-duplicate";
  function PatternDuplicateModal() {
    const isActive = (0, import_data50.useSelect)(
      (select7) => select7(store2).isModalActive(modalName2)
    );
    const { record, postType: postType2 } = (0, import_data50.useSelect)(
      (select7) => {
        if (!isActive) {
          return {};
        }
        const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select7(store3);
        const { getEditedEntityRecord } = select7(import_core_data32.store);
        const _postType = getCurrentPostType2();
        return {
          record: getEditedEntityRecord(
            "postType",
            _postType,
            getCurrentPostId2()
          ),
          postType: _postType
        };
      },
      [isActive]
    );
    const { closeModal: closeModal2 } = (0, import_data50.useDispatch)(store2);
    if (!isActive || postType2 !== PATTERN_POST_TYPE) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(
      DuplicatePatternModal,
      {
        onClose: closeModal2,
        onSuccess: () => closeModal2(),
        pattern: record
      }
    );
  }

  // packages/editor/build-module/components/commands/index.mjs
  var getEditorCommandLoader = () => function useEditorCommandLoader() {
    const {
      editorMode,
      isListViewOpen,
      showBlockBreadcrumbs,
      isDistractionFree,
      isFocusMode,
      isPreviewMode,
      isViewable,
      isCodeEditingEnabled,
      isRichEditingEnabled,
      isPublishSidebarEnabled: isPublishSidebarEnabled2
    } = (0, import_data51.useSelect)((select7) => {
      const { get } = select7(import_preferences7.store);
      const { isListViewOpened: isListViewOpened2, getCurrentPostType: getCurrentPostType2, getEditorSettings: getEditorSettings2 } = select7(store3);
      const { getSettings: getSettings11 } = select7(import_block_editor9.store);
      const { getPostType } = select7(import_core_data33.store);
      return {
        editorMode: get("core", "editorMode") ?? "visual",
        isListViewOpen: isListViewOpened2(),
        showBlockBreadcrumbs: get("core", "showBlockBreadcrumbs"),
        isDistractionFree: get("core", "distractionFree"),
        isFocusMode: get("core", "focusMode"),
        isPreviewMode: getSettings11().isPreviewMode,
        isViewable: getPostType(getCurrentPostType2())?.viewable ?? false,
        isCodeEditingEnabled: getEditorSettings2().codeEditingEnabled,
        isRichEditingEnabled: getEditorSettings2().richEditingEnabled,
        isPublishSidebarEnabled: select7(store3).isPublishSidebarEnabled()
      };
    }, []);
    const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data51.useSelect)(store2);
    const { toggle } = (0, import_data51.useDispatch)(import_preferences7.store);
    const { createInfoNotice } = (0, import_data51.useDispatch)(import_notices15.store);
    const {
      __unstableSaveForPreview: __unstableSaveForPreview2,
      setIsListViewOpened: setIsListViewOpened2,
      switchEditorMode: switchEditorMode2,
      toggleDistractionFree: toggleDistractionFree2,
      toggleSpotlightMode: toggleSpotlightMode2,
      toggleTopToolbar: toggleTopToolbar2
    } = (0, import_data51.useDispatch)(store3);
    const { openModal: openModal2, enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data51.useDispatch)(store2);
    const { getCurrentPostId: getCurrentPostId2 } = (0, import_data51.useSelect)(store3);
    const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
    if (isPreviewMode) {
      return { commands: [], isLoading: false };
    }
    const commands = [];
    commands.push({
      name: "core/open-shortcut-help",
      label: (0, import_i18n128.__)("Keyboard shortcuts"),
      icon: keyboard_default,
      category: "view",
      callback: ({ close }) => {
        close();
        openModal2("editor/keyboard-shortcut-help");
      }
    });
    commands.push({
      name: "core/toggle-distraction-free",
      label: isDistractionFree ? (0, import_i18n128.__)("Exit Distraction free") : (0, import_i18n128.__)("Enter Distraction free"),
      category: "command",
      callback: ({ close }) => {
        toggleDistractionFree2();
        close();
      }
    });
    commands.push({
      name: "core/open-preferences",
      label: (0, import_i18n128.__)("Editor preferences"),
      category: "view",
      callback: ({ close }) => {
        close();
        openModal2("editor/preferences");
      }
    });
    commands.push({
      name: "core/toggle-spotlight-mode",
      label: isFocusMode ? (0, import_i18n128.__)("Exit Spotlight mode") : (0, import_i18n128.__)("Enter Spotlight mode"),
      category: "command",
      callback: ({ close }) => {
        toggleSpotlightMode2();
        close();
      }
    });
    commands.push({
      name: "core/toggle-list-view",
      label: isListViewOpen ? (0, import_i18n128.__)("Close List View") : (0, import_i18n128.__)("Open List View"),
      icon: list_view_default,
      category: "command",
      callback: ({ close }) => {
        setIsListViewOpened2(!isListViewOpen);
        close();
        createInfoNotice(
          isListViewOpen ? (0, import_i18n128.__)("List View off.") : (0, import_i18n128.__)("List View on."),
          {
            id: "core/editor/toggle-list-view/notice",
            type: "snackbar"
          }
        );
      }
    });
    commands.push({
      name: "core/toggle-top-toolbar",
      label: (0, import_i18n128.__)("Top toolbar"),
      category: "command",
      callback: ({ close }) => {
        toggleTopToolbar2();
        close();
      }
    });
    if (allowSwitchEditorMode) {
      commands.push({
        name: "core/toggle-code-editor",
        label: editorMode === "visual" ? (0, import_i18n128.__)("Open code editor") : (0, import_i18n128.__)("Exit code editor"),
        icon: code_default,
        category: "command",
        callback: ({ close }) => {
          switchEditorMode2(
            editorMode === "visual" ? "text" : "visual"
          );
          close();
        }
      });
    }
    commands.push({
      name: "core/toggle-breadcrumbs",
      label: showBlockBreadcrumbs ? (0, import_i18n128.__)("Hide block breadcrumbs") : (0, import_i18n128.__)("Show block breadcrumbs"),
      category: "command",
      callback: ({ close }) => {
        toggle("core", "showBlockBreadcrumbs");
        close();
        createInfoNotice(
          showBlockBreadcrumbs ? (0, import_i18n128.__)("Breadcrumbs hidden.") : (0, import_i18n128.__)("Breadcrumbs visible."),
          {
            id: "core/editor/toggle-breadcrumbs/notice",
            type: "snackbar"
          }
        );
      }
    });
    commands.push({
      name: "core/open-settings-sidebar",
      label: (0, import_i18n128.__)("Show or hide the Settings panel"),
      icon: (0, import_i18n128.isRTL)() ? drawer_left_default : drawer_right_default,
      category: "command",
      callback: ({ close }) => {
        const activeSidebar = getActiveComplementaryArea2("core");
        close();
        if (activeSidebar === "edit-post/document") {
          disableComplementaryArea2("core");
        } else {
          enableComplementaryArea2("core", "edit-post/document");
        }
      }
    });
    commands.push({
      name: "core/open-block-inspector",
      label: (0, import_i18n128.__)("Show or hide the Block settings panel"),
      icon: block_default_default,
      category: "command",
      callback: ({ close }) => {
        const activeSidebar = getActiveComplementaryArea2("core");
        close();
        if (activeSidebar === "edit-post/block") {
          disableComplementaryArea2("core");
        } else {
          enableComplementaryArea2("core", "edit-post/block");
        }
      }
    });
    commands.push({
      name: "core/toggle-publish-sidebar",
      label: isPublishSidebarEnabled2 ? (0, import_i18n128.__)("Disable pre-publish checks") : (0, import_i18n128.__)("Enable pre-publish checks"),
      icon: format_list_bullets_default,
      category: "command",
      callback: ({ close }) => {
        close();
        toggle("core", "isPublishSidebarEnabled");
        createInfoNotice(
          isPublishSidebarEnabled2 ? (0, import_i18n128.__)("Pre-publish checks disabled.") : (0, import_i18n128.__)("Pre-publish checks enabled."),
          {
            id: "core/editor/publish-sidebar/notice",
            type: "snackbar"
          }
        );
      }
    });
    if (isViewable) {
      commands.push({
        name: "core/preview-link",
        label: (0, import_i18n128.__)("Preview in a new tab"),
        icon: external_default,
        category: "view",
        callback: async ({ close }) => {
          close();
          const postId2 = getCurrentPostId2();
          const link = await __unstableSaveForPreview2();
          window.open(link, `wp-preview-${postId2}`);
        }
      });
    }
    return {
      commands,
      isLoading: false
    };
  };
  var getEditedEntityContextualCommands = () => function useEditedEntityContextualCommands() {
    const { postType: postType2 } = (0, import_data51.useSelect)((select7) => {
      const { getCurrentPostType: getCurrentPostType2 } = select7(store3);
      return {
        postType: getCurrentPostType2()
      };
    }, []);
    const { openModal: openModal2 } = (0, import_data51.useDispatch)(store2);
    const commands = [];
    if (postType2 === PATTERN_POST_TYPE) {
      commands.push({
        name: "core/rename-pattern",
        label: (0, import_i18n128.__)("Rename pattern"),
        icon: pencil_default,
        category: "edit",
        callback: ({ close }) => {
          openModal2(modalName);
          close();
        }
      });
      commands.push({
        name: "core/duplicate-pattern",
        label: (0, import_i18n128.__)("Duplicate pattern"),
        icon: symbol_default,
        category: "command",
        callback: ({ close }) => {
          openModal2(modalName2);
          close();
        }
      });
    }
    return { isLoading: false, commands };
  };
  var getPageContentFocusCommands = () => function usePageContentFocusCommands() {
    const {
      onNavigateToEntityRecord,
      goBack,
      templateId: templateId2,
      isPreviewMode,
      canEditTemplate
    } = (0, import_data51.useSelect)((select7) => {
      const {
        getRenderingMode: getRenderingMode2,
        getEditorSettings: _getEditorSettings,
        getCurrentTemplateId: getCurrentTemplateId2
      } = unlock(select7(store3));
      const editorSettings2 = _getEditorSettings();
      const _templateId = getCurrentTemplateId2();
      return {
        isTemplateHidden: getRenderingMode2() === "post-only",
        onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord,
        getEditorSettings: _getEditorSettings,
        goBack: editorSettings2.onNavigateToPreviousEntityRecord,
        templateId: _templateId,
        isPreviewMode: editorSettings2.isPreviewMode,
        canEditTemplate: !!_templateId && select7(import_core_data33.store).canUser("update", {
          kind: "postType",
          name: "wp_template",
          id: _templateId
        })
      };
    }, []);
    const { editedRecord: template2, hasResolved } = (0, import_core_data33.useEntityRecord)(
      "postType",
      "wp_template",
      templateId2
    );
    if (isPreviewMode) {
      return { isLoading: false, commands: [] };
    }
    const commands = [];
    if (templateId2 && hasResolved && canEditTemplate) {
      commands.push({
        name: "core/switch-to-template-focus",
        label: (0, import_i18n128.sprintf)(
          /* translators: %s: template title */
          (0, import_i18n128.__)("Edit template: %s"),
          (0, import_html_entities8.decodeEntities)(template2.title)
        ),
        icon: layout_default,
        category: "edit",
        callback: ({ close }) => {
          onNavigateToEntityRecord({
            postId: templateId2,
            postType: "wp_template"
          });
          close();
        }
      });
    }
    if (!!goBack) {
      commands.push({
        name: "core/switch-to-previous-entity",
        label: (0, import_i18n128.__)("Go back"),
        icon: page_default,
        category: "view",
        callback: ({ close }) => {
          goBack();
          close();
        }
      });
    }
    return { isLoading: false, commands };
  };
  var getManipulateDocumentCommands = () => function useManipulateDocumentCommands() {
    const { postType: postType2, postId: postId2 } = (0, import_data51.useSelect)((select7) => {
      const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
      return {
        postType: getCurrentPostType2(),
        postId: getCurrentPostId2()
      };
    }, []);
    const { editedRecord: template2, hasResolved } = (0, import_core_data33.useEntityRecord)(
      "postType",
      postType2,
      postId2
    );
    const { revertTemplate: revertTemplate3 } = unlock((0, import_data51.useDispatch)(store3));
    if (!hasResolved || ![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(
      postType2
    )) {
      return { isLoading: true, commands: [] };
    }
    const commands = [];
    if (isTemplateRevertable(template2)) {
      const label = template2.type === TEMPLATE_POST_TYPE ? (0, import_i18n128.sprintf)(
        /* translators: %s: template title */
        (0, import_i18n128.__)("Reset template: %s"),
        (0, import_html_entities8.decodeEntities)(template2.title)
      ) : (0, import_i18n128.sprintf)(
        /* translators: %s: template part title */
        (0, import_i18n128.__)("Reset template part: %s"),
        (0, import_html_entities8.decodeEntities)(template2.title)
      );
      commands.push({
        name: "core/reset-template",
        label,
        icon: (0, import_i18n128.isRTL)() ? rotate_right_default : rotate_left_default,
        category: "command",
        callback: ({ close }) => {
          revertTemplate3(template2);
          close();
        }
      });
    }
    return {
      isLoading: !hasResolved,
      commands
    };
  };
  function useCommands() {
    (0, import_commands.useCommandLoader)({
      name: "core/editor/edit-ui",
      hook: getEditorCommandLoader()
    });
    (0, import_commands.useCommandLoader)({
      name: "core/editor/contextual-commands",
      hook: getEditedEntityContextualCommands(),
      context: "entity-edit"
    });
    (0, import_commands.useCommandLoader)({
      name: "core/editor/page-content-focus",
      hook: getPageContentFocusCommands(),
      context: "entity-edit"
    });
    (0, import_commands.useCommandLoader)({
      name: "core/edit-site/manipulate-document",
      hook: getManipulateDocumentCommands()
    });
  }

  // packages/editor/build-module/components/provider/use-upload-save-lock.mjs
  var import_data52 = __toESM(require_data(), 1);
  var import_element135 = __toESM(require_element(), 1);
  var import_upload_media2 = __toESM(require_upload_media(), 1);
  var LOCK_NAME = "upload-in-progress";
  function useUploadSaveLock() {
    const isUploading = (0, import_data52.useSelect)(
      (select7) => select7(import_upload_media2.store).isUploading(),
      []
    );
    const {
      lockPostSaving: lockPostSaving2,
      unlockPostSaving: unlockPostSaving2,
      lockPostAutosaving: lockPostAutosaving2,
      unlockPostAutosaving: unlockPostAutosaving2
    } = (0, import_data52.useDispatch)(store3);
    (0, import_element135.useEffect)(() => {
      if (isUploading) {
        lockPostSaving2(LOCK_NAME);
        lockPostAutosaving2(LOCK_NAME);
      } else {
        unlockPostSaving2(LOCK_NAME);
        unlockPostAutosaving2(LOCK_NAME);
      }
      return () => {
        unlockPostSaving2(LOCK_NAME);
        unlockPostAutosaving2(LOCK_NAME);
      };
    }, [
      isUploading,
      lockPostSaving2,
      unlockPostSaving2,
      lockPostAutosaving2,
      unlockPostAutosaving2
    ]);
  }

  // packages/editor/build-module/components/block-removal-warnings/index.mjs
  var import_i18n129 = __toESM(require_i18n(), 1);
  var import_block_editor10 = __toESM(require_block_editor(), 1);
  var import_data53 = __toESM(require_data(), 1);
  var import_element136 = __toESM(require_element(), 1);
  var import_jsx_runtime243 = __toESM(require_jsx_runtime(), 1);
  var { BlockRemovalWarningModal } = unlock(import_block_editor10.privateApis);
  var TEMPLATE_BLOCKS = [
    "core/post-content",
    "core/post-template",
    "core/query"
  ];
  var BLOCK_REMOVAL_RULES = [
    {
      // Template blocks.
      // The warning is only shown when a user manipulates templates or template parts.
      postTypes: ["wp_template", "wp_template_part"],
      callback(removedBlocks) {
        const removedPostContentBlocks = removedBlocks.filter(
          ({ name: name2 }) => name2 === "core/post-content"
        );
        if (removedPostContentBlocks.length) {
          return {
            description: (0, import_i18n129.__)(
              "This block displays the content of posts and pages using this template."
            ),
            warning: (0, import_i18n129.__)(
              "If you delete it, posts or pages using this template will not display any content."
            ),
            subtext: (0, import_i18n129.__)("Visitors will see blank pages."),
            requireConfirmation: true
          };
        }
        const removedTemplateBlocks = removedBlocks.filter(
          ({ name: name2 }) => TEMPLATE_BLOCKS.includes(name2)
        );
        if (removedTemplateBlocks.length) {
          return (0, import_i18n129._n)(
            "Deleting this block will stop your post or page content from displaying on this template. It is not recommended.",
            "Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.",
            removedBlocks.length
          );
        }
      }
    },
    {
      // Pattern overrides.
      // The warning is only shown when the user edits a pattern.
      postTypes: ["wp_block"],
      callback(removedBlocks) {
        const removedBlocksWithOverrides = removedBlocks.filter(
          ({ attributes }) => attributes?.metadata?.bindings && Object.values(attributes.metadata.bindings).some(
            (binding) => binding.source === "core/pattern-overrides"
          )
        );
        if (removedBlocksWithOverrides.length) {
          return (0, import_i18n129._n)(
            "The deleted block allows instance overrides. Removing it may result in content not displaying where this pattern is used. Are you sure you want to proceed?",
            "Some of the deleted blocks allow instance overrides. Removing them may result in content not displaying where this pattern is used. Are you sure you want to proceed?",
            removedBlocks.length
          );
        }
      }
    }
  ];
  function BlockRemovalWarnings() {
    const currentPostType = (0, import_data53.useSelect)(
      (select7) => select7(store3).getCurrentPostType(),
      []
    );
    const removalRulesForPostType = (0, import_element136.useMemo)(
      () => BLOCK_REMOVAL_RULES.filter(
        (rule) => rule.postTypes.includes(currentPostType)
      ),
      [currentPostType]
    );
    if (!BlockRemovalWarningModal) {
      return null;
    }
    if (!removalRulesForPostType) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(BlockRemovalWarningModal, { rules: removalRulesForPostType });
  }

  // packages/editor/build-module/components/start-page-options/index.mjs
  var import_components90 = __toESM(require_components(), 1);
  var import_i18n130 = __toESM(require_i18n(), 1);
  var import_element137 = __toESM(require_element(), 1);
  var import_block_editor11 = __toESM(require_block_editor(), 1);
  var import_data54 = __toESM(require_data(), 1);
  var import_core_data34 = __toESM(require_core_data(), 1);
  var import_blocks11 = __toESM(require_blocks(), 1);
  var import_preferences8 = __toESM(require_preferences(), 1);
  var import_jsx_runtime244 = __toESM(require_jsx_runtime(), 1);
  function useStartPatterns() {
    const { blockPatternsWithPostContentBlockType, postType: postType2 } = (0, import_data54.useSelect)(
      (select7) => {
        const { getPatternsByBlockTypes, getBlocksByName } = select7(import_block_editor11.store);
        const { getCurrentPostType: getCurrentPostType2, getRenderingMode: getRenderingMode2 } = select7(store3);
        const rootClientId = getRenderingMode2() === "post-only" ? "" : getBlocksByName("core/post-content")?.[0];
        return {
          blockPatternsWithPostContentBlockType: getPatternsByBlockTypes(
            "core/post-content",
            rootClientId
          ),
          postType: getCurrentPostType2()
        };
      },
      []
    );
    return (0, import_element137.useMemo)(() => {
      if (!blockPatternsWithPostContentBlockType?.length) {
        return [];
      }
      return blockPatternsWithPostContentBlockType.filter((pattern) => {
        return postType2 === "page" && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType2);
      });
    }, [postType2, blockPatternsWithPostContentBlockType]);
  }
  function PatternSelection({ blockPatterns, onChoosePattern }) {
    const { editEntityRecord } = (0, import_data54.useDispatch)(import_core_data34.store);
    const { postType: postType2, postId: postId2 } = (0, import_data54.useSelect)((select7) => {
      const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select7(store3);
      return {
        postType: getCurrentPostType2(),
        postId: getCurrentPostId2()
      };
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(
      import_block_editor11.__experimentalBlockPatternsList,
      {
        blockPatterns,
        onClickPattern: (_pattern, blocks) => {
          editEntityRecord("postType", postType2, postId2, {
            blocks,
            content: ({ blocks: blocksForSerialization = [] }) => (0, import_blocks11.__unstableSerializeAndClean)(blocksForSerialization)
          });
          onChoosePattern();
        }
      }
    );
  }
  function StartPageOptionsModal({ onClose }) {
    const [showStartPatterns, setShowStartPatterns] = (0, import_element137.useState)(true);
    const { set: setPreference } = (0, import_data54.useDispatch)(import_preferences8.store);
    const startPatterns = useStartPatterns();
    const hasStartPattern = startPatterns.length > 0;
    if (!hasStartPattern) {
      return null;
    }
    function handleClose() {
      onClose();
      setPreference("core", "enableChoosePatternModal", showStartPatterns);
    }
    return /* @__PURE__ */ (0, import_jsx_runtime244.jsxs)(
      import_components90.Modal,
      {
        className: "editor-start-page-options__modal",
        title: (0, import_i18n130.__)("Choose a pattern"),
        isFullScreen: true,
        onRequestClose: handleClose,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime244.jsx)("div", { className: "editor-start-page-options__modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(
            PatternSelection,
            {
              blockPatterns: startPatterns,
              onChoosePattern: handleClose
            }
          ) }),
          /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(
            import_components90.Flex,
            {
              className: "editor-start-page-options__modal__actions",
              justify: "flex-start",
              expanded: false,
              children: /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(import_components90.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(
                import_components90.CheckboxControl,
                {
                  checked: showStartPatterns,
                  label: (0, import_i18n130.__)(
                    "Always show starter patterns for new pages"
                  ),
                  onChange: (newValue) => {
                    setShowStartPatterns(newValue);
                  }
                }
              ) })
            }
          )
        ]
      }
    );
  }
  function StartPageOptions() {
    const [isOpen2, setIsOpen] = (0, import_element137.useState)(false);
    const { isEditedPostDirty: isEditedPostDirty2, isEditedPostEmpty: isEditedPostEmpty2 } = (0, import_data54.useSelect)(store3);
    const { isModalActive: isModalActive2 } = (0, import_data54.useSelect)(store2);
    const { enabled, postId: postId2 } = (0, import_data54.useSelect)((select7) => {
      const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
      const choosePatternModalEnabled = select7(import_preferences8.store).get(
        "core",
        "enableChoosePatternModal"
      );
      const currentPostType = getCurrentPostType2();
      return {
        postId: getCurrentPostId2(),
        enabled: choosePatternModalEnabled && ATTACHMENT_POST_TYPE !== currentPostType && TEMPLATE_POST_TYPE !== currentPostType && TEMPLATE_PART_POST_TYPE !== currentPostType
      };
    }, []);
    (0, import_element137.useEffect)(() => {
      const isFreshPage = !isEditedPostDirty2() && isEditedPostEmpty2();
      const isPreferencesModalActive = isModalActive2("editor/preferences");
      if (!enabled || !isFreshPage || isPreferencesModalActive) {
        return;
      }
      setIsOpen(true);
    }, [
      enabled,
      postId2,
      isEditedPostDirty2,
      isEditedPostEmpty2,
      isModalActive2
    ]);
    if (!isOpen2) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(StartPageOptionsModal, { onClose: () => setIsOpen(false) });
  }

  // packages/editor/build-module/components/keyboard-shortcut-help-modal/index.mjs
  var import_components91 = __toESM(require_components(), 1);
  var import_i18n132 = __toESM(require_i18n(), 1);
  var import_keyboard_shortcuts2 = __toESM(require_keyboard_shortcuts(), 1);
  var import_data56 = __toESM(require_data(), 1);

  // packages/editor/build-module/components/keyboard-shortcut-help-modal/config.mjs
  var import_i18n131 = __toESM(require_i18n(), 1);
  var textFormattingShortcuts = [
    {
      keyCombination: { modifier: "primary", character: "b" },
      description: (0, import_i18n131.__)("Make the selected text bold.")
    },
    {
      keyCombination: { modifier: "primary", character: "i" },
      description: (0, import_i18n131.__)("Make the selected text italic.")
    },
    {
      keyCombination: { modifier: "primary", character: "k" },
      description: (0, import_i18n131.__)("Convert the selected text into a link.")
    },
    {
      keyCombination: { modifier: "primaryShift", character: "k" },
      description: (0, import_i18n131.__)("Remove a link.")
    },
    {
      keyCombination: { character: "[[" },
      description: (0, import_i18n131.__)("Insert a link to a post or page.")
    },
    {
      keyCombination: { modifier: "primary", character: "u" },
      description: (0, import_i18n131.__)("Underline the selected text.")
    },
    {
      keyCombination: { modifier: "access", character: "d" },
      description: (0, import_i18n131.__)("Strikethrough the selected text.")
    },
    {
      keyCombination: { modifier: "access", character: "x" },
      description: (0, import_i18n131.__)("Make the selected text inline code.")
    },
    {
      keyCombination: {
        modifier: "access",
        character: "0"
      },
      aliases: [
        {
          modifier: "access",
          character: "7"
        }
      ],
      description: (0, import_i18n131.__)("Convert the current heading to a paragraph.")
    },
    {
      keyCombination: { modifier: "access", character: "1-6" },
      description: (0, import_i18n131.__)(
        "Convert the current paragraph or heading to a heading of level 1 to 6."
      )
    },
    {
      keyCombination: { modifier: "primaryShift", character: "SPACE" },
      description: (0, import_i18n131.__)("Add non breaking space.")
    }
  ];

  // packages/editor/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs
  var import_element138 = __toESM(require_element(), 1);
  var import_keycodes3 = __toESM(require_keycodes(), 1);
  var import_jsx_runtime245 = __toESM(require_jsx_runtime(), 1);
  function KeyCombination({ keyCombination, forceAriaLabel }) {
    const shortcut = keyCombination.modifier ? import_keycodes3.displayShortcutList[keyCombination.modifier](
      keyCombination.character
    ) : keyCombination.character;
    const ariaLabel = keyCombination.modifier ? import_keycodes3.shortcutAriaLabel[keyCombination.modifier](
      keyCombination.character
    ) : keyCombination.character;
    return /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(
      "kbd",
      {
        className: "editor-keyboard-shortcut-help-modal__shortcut-key-combination",
        "aria-label": forceAriaLabel || ariaLabel,
        children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map(
          (character, index) => {
            if (character === "+") {
              return /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(import_element138.Fragment, { children: character }, index);
            }
            return /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(
              "kbd",
              {
                className: "editor-keyboard-shortcut-help-modal__shortcut-key",
                children: character
              },
              index
            );
          }
        )
      }
    );
  }
  function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) {
    return /* @__PURE__ */ (0, import_jsx_runtime245.jsxs)(import_jsx_runtime245.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime245.jsx)("div", { className: "editor-keyboard-shortcut-help-modal__shortcut-description", children: description }),
      /* @__PURE__ */ (0, import_jsx_runtime245.jsxs)("div", { className: "editor-keyboard-shortcut-help-modal__shortcut-term", children: [
        /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(
          KeyCombination,
          {
            keyCombination,
            forceAriaLabel: ariaLabel
          }
        ),
        aliases.map((alias, index) => /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(
          KeyCombination,
          {
            keyCombination: alias,
            forceAriaLabel: ariaLabel
          },
          index
        ))
      ] })
    ] });
  }
  var shortcut_default = Shortcut;

  // packages/editor/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs
  var import_data55 = __toESM(require_data(), 1);
  var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1);
  var import_jsx_runtime246 = __toESM(require_jsx_runtime(), 1);
  function DynamicShortcut({ name: name2 }) {
    const { keyCombination, description, aliases } = (0, import_data55.useSelect)(
      (select7) => {
        const {
          getShortcutKeyCombination,
          getShortcutDescription,
          getShortcutAliases
        } = select7(import_keyboard_shortcuts.store);
        return {
          keyCombination: getShortcutKeyCombination(name2),
          aliases: getShortcutAliases(name2),
          description: getShortcutDescription(name2)
        };
      },
      [name2]
    );
    if (!keyCombination) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
      shortcut_default,
      {
        keyCombination,
        description,
        aliases
      }
    );
  }
  var dynamic_shortcut_default = DynamicShortcut;

  // packages/editor/build-module/components/keyboard-shortcut-help-modal/index.mjs
  var import_jsx_runtime247 = __toESM(require_jsx_runtime(), 1);
  var KEYBOARD_SHORTCUT_HELP_MODAL_NAME = "editor/keyboard-shortcut-help";
  var ShortcutList = ({ shortcuts }) => (
    /*
     * Disable reason: The `list` ARIA role is redundant but
     * Safari+VoiceOver won't announce the list otherwise.
     */
    /* eslint-disable jsx-a11y/no-redundant-roles */
    /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
      "ul",
      {
        className: "editor-keyboard-shortcut-help-modal__shortcut-list",
        role: "list",
        children: shortcuts.map((shortcut, index) => /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
          "li",
          {
            className: "editor-keyboard-shortcut-help-modal__shortcut",
            children: typeof shortcut === "string" ? /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(dynamic_shortcut_default, { name: shortcut }) : /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(shortcut_default, { ...shortcut })
          },
          index
        ))
      }
    )
  );
  var ShortcutSection = ({ title, shortcuts, className }) => /* @__PURE__ */ (0, import_jsx_runtime247.jsxs)(
    "section",
    {
      className: clsx_default(
        "editor-keyboard-shortcut-help-modal__section",
        className
      ),
      children: [
        !!title && /* @__PURE__ */ (0, import_jsx_runtime247.jsx)("h2", { className: "editor-keyboard-shortcut-help-modal__section-title", children: title }),
        /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(ShortcutList, { shortcuts })
      ]
    }
  );
  var ShortcutCategorySection = ({
    title,
    categoryName,
    additionalShortcuts = []
  }) => {
    const categoryShortcuts = (0, import_data56.useSelect)(
      (select7) => {
        return select7(import_keyboard_shortcuts2.store).getCategoryShortcuts(
          categoryName
        );
      },
      [categoryName]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
      ShortcutSection,
      {
        title,
        shortcuts: categoryShortcuts.concat(additionalShortcuts)
      }
    );
  };
  function KeyboardShortcutHelpModal() {
    const isModalActive2 = (0, import_data56.useSelect)(
      (select7) => select7(store2).isModalActive(
        KEYBOARD_SHORTCUT_HELP_MODAL_NAME
      ),
      []
    );
    const { openModal: openModal2, closeModal: closeModal2 } = (0, import_data56.useDispatch)(store2);
    const toggleModal = () => {
      if (isModalActive2) {
        closeModal2();
      } else {
        openModal2(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
      }
    };
    (0, import_keyboard_shortcuts2.useShortcut)("core/editor/keyboard-shortcuts", toggleModal);
    if (!isModalActive2) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime247.jsxs)(
      import_components91.Modal,
      {
        className: "editor-keyboard-shortcut-help-modal",
        title: (0, import_i18n132.__)("Keyboard shortcuts"),
        closeButtonLabel: (0, import_i18n132.__)("Close"),
        onRequestClose: toggleModal,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
            ShortcutSection,
            {
              className: "editor-keyboard-shortcut-help-modal__main-shortcuts",
              shortcuts: ["core/editor/keyboard-shortcuts"]
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
            ShortcutCategorySection,
            {
              title: (0, import_i18n132.__)("Global shortcuts"),
              categoryName: "global"
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
            ShortcutCategorySection,
            {
              title: (0, import_i18n132.__)("Selection shortcuts"),
              categoryName: "selection"
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
            ShortcutCategorySection,
            {
              title: (0, import_i18n132.__)("Block shortcuts"),
              categoryName: "block",
              additionalShortcuts: [
                {
                  keyCombination: { character: "/" },
                  description: (0, import_i18n132.__)(
                    "Change the block type after adding a new paragraph."
                  ),
                  /* translators: The forward-slash character. e.g. '/'. */
                  ariaLabel: (0, import_i18n132.__)("Forward-slash")
                }
              ]
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
            ShortcutSection,
            {
              title: (0, import_i18n132.__)("Text formatting"),
              shortcuts: textFormattingShortcuts
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
            ShortcutCategorySection,
            {
              title: (0, import_i18n132.__)("List View shortcuts"),
              categoryName: "list-view"
            }
          )
        ]
      }
    );
  }
  var keyboard_shortcut_help_modal_default = KeyboardShortcutHelpModal;

  // packages/editor/build-module/components/start-template-options/index.mjs
  var import_components92 = __toESM(require_components(), 1);
  var import_i18n133 = __toESM(require_i18n(), 1);
  var import_element139 = __toESM(require_element(), 1);
  var import_block_editor12 = __toESM(require_block_editor(), 1);
  var import_data57 = __toESM(require_data(), 1);
  var import_blocks12 = __toESM(require_blocks(), 1);
  var import_core_data35 = __toESM(require_core_data(), 1);
  var import_jsx_runtime248 = __toESM(require_jsx_runtime(), 1);
  function useFallbackTemplateContent(slug, isCustom = false) {
    return (0, import_data57.useSelect)(
      (select7) => {
        const { getEntityRecord, getDefaultTemplateId } = select7(import_core_data35.store);
        const templateId2 = getDefaultTemplateId({
          slug,
          is_custom: isCustom,
          ignore_empty: true
        });
        return templateId2 ? getEntityRecord("postType", TEMPLATE_POST_TYPE, templateId2)?.content?.raw : void 0;
      },
      [slug, isCustom]
    );
  }
  function useStartPatterns2(fallbackContent) {
    const { slug, patterns: patterns2 } = (0, import_data57.useSelect)((select7) => {
      const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select7(store3);
      const { getEntityRecord, getBlockPatterns } = select7(import_core_data35.store);
      const postId2 = getCurrentPostId2();
      const postType2 = getCurrentPostType2();
      const record = getEntityRecord("postType", postType2, postId2);
      return {
        slug: record.slug,
        patterns: getBlockPatterns()
      };
    }, []);
    const currentThemeStylesheet = (0, import_data57.useSelect)(
      (select7) => select7(import_core_data35.store).getCurrentTheme().stylesheet
    );
    function injectThemeAttributeInBlockTemplateContent2(block) {
      if (block.innerBlocks.find(
        (innerBlock) => innerBlock.name === "core/template-part"
      )) {
        block.innerBlocks = block.innerBlocks.map((innerBlock) => {
          if (innerBlock.name === "core/template-part" && innerBlock.attributes.theme === void 0) {
            innerBlock.attributes.theme = currentThemeStylesheet;
          }
          return innerBlock;
        });
      }
      if (block.name === "core/template-part" && block.attributes.theme === void 0) {
        block.attributes.theme = currentThemeStylesheet;
      }
      return block;
    }
    return (0, import_element139.useMemo)(() => {
      return [
        {
          name: "fallback",
          blocks: (0, import_blocks12.parse)(fallbackContent),
          title: (0, import_i18n133.__)("Fallback content")
        },
        ...patterns2.filter((pattern) => {
          return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some(
            (templateType) => slug.startsWith(templateType)
          );
        }).map((pattern) => {
          return {
            ...pattern,
            blocks: (0, import_blocks12.parse)(pattern.content).map(
              (block) => injectThemeAttributeInBlockTemplateContent2(block)
            )
          };
        })
      ];
    }, [fallbackContent, slug, patterns2]);
  }
  function PatternSelection2({ fallbackContent, onChoosePattern, postType: postType2 }) {
    const [, , onChange] = (0, import_core_data35.useEntityBlockEditor)("postType", postType2);
    const blockPatterns = useStartPatterns2(fallbackContent);
    return /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
      import_block_editor12.__experimentalBlockPatternsList,
      {
        blockPatterns,
        onClickPattern: (pattern, blocks) => {
          onChange(blocks, { selection: void 0 });
          onChoosePattern();
        }
      }
    );
  }
  function StartModal({ slug, isCustom, onClose, postType: postType2 }) {
    const fallbackContent = useFallbackTemplateContent(slug, isCustom);
    if (!fallbackContent) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime248.jsxs)(
      import_components92.Modal,
      {
        className: "editor-start-template-options__modal",
        title: (0, import_i18n133.__)("Choose a pattern"),
        closeLabel: (0, import_i18n133.__)("Cancel"),
        focusOnMount: "firstElement",
        onRequestClose: onClose,
        isFullScreen: true,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime248.jsx)("div", { className: "editor-start-template-options__modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
            PatternSelection2,
            {
              fallbackContent,
              slug,
              isCustom,
              postType: postType2,
              onChoosePattern: () => {
                onClose();
              }
            }
          ) }),
          /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
            import_components92.Flex,
            {
              className: "editor-start-template-options__modal__actions",
              justify: "flex-end",
              expanded: false,
              children: /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(import_components92.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
                import_components92.Button,
                {
                  __next40pxDefaultSize: true,
                  variant: "tertiary",
                  onClick: onClose,
                  children: (0, import_i18n133.__)("Skip")
                }
              ) })
            }
          )
        ]
      }
    );
  }
  function StartTemplateOptions() {
    const [isClosed, setIsClosed] = (0, import_element139.useState)(false);
    const { shouldOpenModal, slug, isCustom, postType: postType2, postId: postId2 } = (0, import_data57.useSelect)(
      (select7) => {
        const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select7(store3);
        const _postType = getCurrentPostType2();
        const _postId = getCurrentPostId2();
        const { getEditedEntityRecord, hasEditsForEntityRecord } = select7(import_core_data35.store);
        const templateRecord = getEditedEntityRecord(
          "postType",
          _postType,
          _postId
        );
        const hasEdits = hasEditsForEntityRecord(
          "postType",
          _postType,
          _postId
        );
        return {
          shouldOpenModal: !hasEdits && "" === templateRecord.content && TEMPLATE_POST_TYPE === _postType,
          slug: templateRecord.slug,
          isCustom: templateRecord.is_custom,
          postType: _postType,
          postId: _postId
        };
      },
      []
    );
    (0, import_element139.useEffect)(() => {
      setIsClosed(false);
    }, [postType2, postId2]);
    if (!shouldOpenModal || isClosed) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
      StartModal,
      {
        slug,
        isCustom,
        postType: postType2,
        onClose: () => setIsClosed(true)
      }
    );
  }

  // packages/editor/build-module/components/global-keyboard-shortcuts/index.mjs
  var import_keyboard_shortcuts3 = __toESM(require_keyboard_shortcuts(), 1);
  var import_data58 = __toESM(require_data(), 1);
  var import_block_editor13 = __toESM(require_block_editor(), 1);
  function EditorKeyboardShortcuts() {
    const isModeToggleDisabled = (0, import_data58.useSelect)((select7) => {
      const { richEditingEnabled, codeEditingEnabled } = select7(store3).getEditorSettings();
      return !richEditingEnabled || !codeEditingEnabled;
    }, []);
    const { getBlockSelectionStart: getBlockSelectionStart2 } = (0, import_data58.useSelect)(import_block_editor13.store);
    const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data58.useSelect)(store2);
    const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data58.useDispatch)(store2);
    const {
      redo: redo2,
      undo: undo2,
      savePost: savePost2,
      setIsListViewOpened: setIsListViewOpened2,
      switchEditorMode: switchEditorMode2,
      toggleDistractionFree: toggleDistractionFree2
    } = (0, import_data58.useDispatch)(store3);
    const {
      isEditedPostDirty: isEditedPostDirty2,
      isPostSavingLocked: isPostSavingLocked2,
      isListViewOpened: isListViewOpened2,
      getEditorMode: getEditorMode2
    } = (0, import_data58.useSelect)(store3);
    (0, import_keyboard_shortcuts3.useShortcut)(
      "core/editor/toggle-mode",
      () => {
        switchEditorMode2(
          getEditorMode2() === "visual" ? "text" : "visual"
        );
      },
      {
        isDisabled: isModeToggleDisabled
      }
    );
    (0, import_keyboard_shortcuts3.useShortcut)("core/editor/toggle-distraction-free", () => {
      toggleDistractionFree2();
    });
    (0, import_keyboard_shortcuts3.useShortcut)("core/editor/undo", (event) => {
      undo2();
      event.preventDefault();
    });
    (0, import_keyboard_shortcuts3.useShortcut)("core/editor/redo", (event) => {
      redo2();
      event.preventDefault();
    });
    (0, import_keyboard_shortcuts3.useShortcut)("core/editor/save", (event) => {
      event.preventDefault();
      if (isPostSavingLocked2()) {
        return;
      }
      if (!isEditedPostDirty2()) {
        return;
      }
      savePost2();
    });
    (0, import_keyboard_shortcuts3.useShortcut)("core/editor/toggle-list-view", (event) => {
      if (!isListViewOpened2()) {
        event.preventDefault();
        setIsListViewOpened2(true);
      }
    });
    (0, import_keyboard_shortcuts3.useShortcut)("core/editor/toggle-sidebar", (event) => {
      event.preventDefault();
      const isEditorSidebarOpened = [
        "edit-post/document",
        "edit-post/block"
      ].includes(getActiveComplementaryArea2("core"));
      if (isEditorSidebarOpened) {
        disableComplementaryArea2("core");
      } else {
        const sidebarToOpen = getBlockSelectionStart2() ? "edit-post/block" : "edit-post/document";
        enableComplementaryArea2("core", sidebarToOpen);
      }
    });
    return null;
  }

  // packages/editor/build-module/components/template-part-menu-items/index.mjs
  var import_data61 = __toESM(require_data(), 1);
  var import_block_editor16 = __toESM(require_block_editor(), 1);

  // packages/editor/build-module/components/template-part-menu-items/convert-to-regular.mjs
  var import_data59 = __toESM(require_data(), 1);
  var import_block_editor14 = __toESM(require_block_editor(), 1);
  var import_core_data36 = __toESM(require_core_data(), 1);
  var import_components93 = __toESM(require_components(), 1);
  var import_i18n134 = __toESM(require_i18n(), 1);
  var import_html_entities9 = __toESM(require_html_entities(), 1);
  var import_element140 = __toESM(require_element(), 1);
  var import_jsx_runtime249 = __toESM(require_jsx_runtime(), 1);
  function ConvertToRegularBlocks({ clientId, onClose }) {
    const [showConfirmDialog, setShowConfirmDialog] = (0, import_element140.useState)(false);
    const { getBlocks: getBlocks2 } = (0, import_data59.useSelect)(import_block_editor14.store);
    const { replaceBlocks: replaceBlocks2 } = (0, import_data59.useDispatch)(import_block_editor14.store);
    const { canRemove, templatePartTitle } = (0, import_data59.useSelect)(
      (select7) => {
        const { canRemoveBlock, getBlock: getBlock2 } = select7(import_block_editor14.store);
        const { getEntityRecord, getCurrentTheme } = select7(import_core_data36.store);
        const block = getBlock2(clientId);
        const { slug, theme } = block?.attributes ?? {};
        const themeSlug = theme || getCurrentTheme()?.stylesheet;
        const templatePartId = themeSlug && slug ? `${themeSlug}//${slug}` : null;
        const entity = templatePartId ? getEntityRecord(
          "postType",
          "wp_template_part",
          templatePartId
        ) : null;
        return {
          canRemove: canRemoveBlock(clientId),
          templatePartTitle: entity?.title?.rendered ? (0, import_html_entities9.decodeEntities)(entity.title.rendered) : null
        };
      },
      [clientId]
    );
    if (!canRemove) {
      return null;
    }
    const title = templatePartTitle ? (0, import_i18n134.sprintf)(
      /* translators: %s: template part title, e.g. "Header" */
      (0, import_i18n134.__)("Detach %s?"),
      templatePartTitle
    ) : (0, import_i18n134.__)("Detach template part?");
    const message2 = templatePartTitle ? (0, import_i18n134.sprintf)(
      /* translators: %s: template part title, e.g. "Header" */
      (0, import_i18n134.__)(
        "The blocks will be separated from the original template part and will be fully editable. Future changes to the %s template part will not apply here."
      ),
      templatePartTitle
    ) : (0, import_i18n134.__)(
      "The blocks will be separated from the original template part and will be fully editable. Future changes to the template part will not apply here."
    );
    return /* @__PURE__ */ (0, import_jsx_runtime249.jsxs)(import_jsx_runtime249.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(import_components93.MenuItem, { onClick: () => setShowConfirmDialog(true), children: (0, import_i18n134.__)("Detach") }),
      /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(
        import_components93.__experimentalConfirmDialog,
        {
          isOpen: showConfirmDialog,
          onConfirm: () => {
            replaceBlocks2(clientId, getBlocks2(clientId));
            onClose();
          },
          onCancel: () => setShowConfirmDialog(false),
          confirmButtonText: (0, import_i18n134.__)("Detach"),
          size: "medium",
          title,
          __experimentalHideHeader: false,
          children: message2
        }
      )
    ] });
  }

  // packages/editor/build-module/components/template-part-menu-items/convert-to-template-part.mjs
  var import_data60 = __toESM(require_data(), 1);
  var import_block_editor15 = __toESM(require_block_editor(), 1);
  var import_components94 = __toESM(require_components(), 1);
  var import_blocks13 = __toESM(require_blocks(), 1);
  var import_i18n135 = __toESM(require_i18n(), 1);
  var import_element141 = __toESM(require_element(), 1);
  var import_notices16 = __toESM(require_notices(), 1);
  var import_core_data37 = __toESM(require_core_data(), 1);
  var import_jsx_runtime250 = __toESM(require_jsx_runtime(), 1);
  function ConvertToTemplatePart({ clientIds, blocks }) {
    const [isModalOpen, setIsModalOpen] = (0, import_element141.useState)(false);
    const { replaceBlocks: replaceBlocks2 } = (0, import_data60.useDispatch)(import_block_editor15.store);
    const { createSuccessNotice } = (0, import_data60.useDispatch)(import_notices16.store);
    const { isBlockBasedTheme, canCreate } = (0, import_data60.useSelect)((select7) => {
      return {
        isBlockBasedTheme: select7(import_core_data37.store).getCurrentTheme()?.is_block_theme,
        canCreate: select7(import_block_editor15.store).canInsertBlockType(
          "core/template-part"
        )
      };
    }, []);
    if (!isBlockBasedTheme || !canCreate) {
      return null;
    }
    const onConvert = async (templatePart) => {
      replaceBlocks2(
        clientIds,
        (0, import_blocks13.createBlock)("core/template-part", {
          slug: templatePart.slug,
          theme: templatePart.theme
        })
      );
      createSuccessNotice((0, import_i18n135.__)("Template part created."), {
        type: "snackbar"
      });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime250.jsxs)(import_jsx_runtime250.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(
        import_components94.MenuItem,
        {
          icon: symbol_filled_default,
          onClick: () => {
            setIsModalOpen(true);
          },
          "aria-expanded": isModalOpen,
          "aria-haspopup": "dialog",
          children: (0, import_i18n135.__)("Create template part")
        }
      ),
      isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(
        CreateTemplatePartModal,
        {
          closeModal: () => {
            setIsModalOpen(false);
          },
          blocks,
          onCreate: onConvert
        }
      )
    ] });
  }

  // packages/editor/build-module/components/template-part-menu-items/index.mjs
  var import_jsx_runtime251 = __toESM(require_jsx_runtime(), 1);
  function TemplatePartMenuItems() {
    return /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(import_block_editor16.BlockSettingsMenuControls, { children: ({ selectedClientIds, onClose }) => /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(
      TemplatePartConverterMenuItem,
      {
        clientIds: selectedClientIds,
        onClose
      }
    ) });
  }
  function TemplatePartConverterMenuItem({ clientIds, onClose }) {
    const { blocks } = (0, import_data61.useSelect)(
      (select7) => {
        const { getBlocksByClientId: getBlocksByClientId2 } = select7(import_block_editor16.store);
        return {
          blocks: getBlocksByClientId2(clientIds)
        };
      },
      [clientIds]
    );
    if (blocks.length === 1 && blocks[0]?.name === "core/template-part") {
      return /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(
        ConvertToRegularBlocks,
        {
          clientId: clientIds[0],
          onClose
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(ConvertToTemplatePart, { clientIds, blocks });
  }

  // packages/editor/build-module/components/media/media-editor-modal.mjs
  var import_block_editor17 = __toESM(require_block_editor(), 1);
  var import_element143 = __toESM(require_element(), 1);

  // packages/editor/build-module/components/post-fields/index.mjs
  var import_element142 = __toESM(require_element(), 1);
  var import_data62 = __toESM(require_data(), 1);
  function usePostFields({
    postType: postType2
  }) {
    const { registerPostTypeSchema: registerPostTypeSchema2 } = unlock((0, import_data62.useDispatch)(store3));
    (0, import_element142.useEffect)(() => {
      registerPostTypeSchema2(postType2);
    }, [registerPostTypeSchema2, postType2]);
    const { fields: fields3 } = (0, import_data62.useSelect)(
      (select7) => {
        const { getEntityFields: getEntityFields3 } = unlock(select7(store3));
        return {
          fields: getEntityFields3("postType", postType2)
        };
      },
      [postType2]
    );
    return fields3;
  }
  var post_fields_default = usePostFields;

  // packages/editor/build-module/components/media/media-editor-modal.mjs
  var import_jsx_runtime252 = __toESM(require_jsx_runtime(), 1);
  var { MediaEditorModal: MediaEditorModal2 } = unlock(privateApis12);
  function ratioToNumber(ratio) {
    if (ratio === void 0 || ratio === null) {
      return NaN;
    }
    const [a3, b3, ...rest] = String(ratio).split("/").map(Number);
    if (a3 <= 0 || b3 <= 0 || Number.isNaN(a3) || Number.isNaN(b3) || rest.length) {
      return NaN;
    }
    return b3 ? a3 / b3 : a3;
  }
  function aspectRatioPresetFromSettings({ name: name2, ratio } = {}) {
    const value = ratioToNumber(ratio);
    if (!name2 || !Number.isFinite(value) || value <= 0) {
      return null;
    }
    return {
      label: name2,
      value
    };
  }
  function MediaEditorModalMount() {
    const fields3 = post_fields_default({ postType: "attachment" });
    const [defaultRatios, themeRatios, showDefaultRatios] = (0, import_block_editor17.useSettings)(
      "dimensions.aspectRatios.default",
      "dimensions.aspectRatios.theme",
      "dimensions.defaultAspectRatios"
    );
    const aspectRatioPresets = (0, import_element143.useMemo)(() => {
      const hasAspectRatioSettings = Array.isArray(defaultRatios) || Array.isArray(themeRatios) || typeof showDefaultRatios === "boolean";
      if (!hasAspectRatioSettings) {
        return void 0;
      }
      const candidateRatios = [
        ...showDefaultRatios && Array.isArray(defaultRatios) ? defaultRatios : [],
        ...Array.isArray(themeRatios) ? themeRatios : []
      ];
      const presets = candidateRatios.map(aspectRatioPresetFromSettings).filter(Boolean);
      if (presets.length || showDefaultRatios === false) {
        return presets;
      }
      return void 0;
    }, [defaultRatios, themeRatios, showDefaultRatios]);
    return /* @__PURE__ */ (0, import_jsx_runtime252.jsx)(
      MediaEditorModal2,
      {
        fields: fields3,
        aspectRatioPresets
      }
    );
  }

  // packages/editor/build-module/components/provider/index.mjs
  var import_jsx_runtime253 = __toESM(require_jsx_runtime(), 1);
  var { ExperimentalBlockEditorProvider } = unlock(import_block_editor18.privateApis);
  var { PatternsMenuItems } = unlock(import_patterns7.privateApis);
  var noop6 = () => {
  };
  var NON_CONTEXTUAL_POST_TYPES = [
    "wp_block",
    "wp_navigation",
    "wp_template_part"
  ];
  function useBlockEditorProps(post2, template2, mode) {
    const revisionBlocks = useRevisionBlocks();
    const rootLevelPost = mode === "template-locked" ? "template" : "post";
    const [postBlocks, onInput, onChange] = (0, import_core_data38.useEntityBlockEditor)(
      "postType",
      post2.type,
      { id: post2.id }
    );
    const [templateBlocks, onInputTemplate, onChangeTemplate] = (0, import_core_data38.useEntityBlockEditor)("postType", template2?.type, {
      id: template2?.id
    });
    const maybeNavigationBlocks = (0, import_element144.useMemo)(() => {
      if (post2.type === "wp_navigation") {
        return [
          (0, import_blocks14.createBlock)("core/navigation", {
            ref: post2.id,
            // As the parent editor is locked with `templateLock`, the template locking
            // must be explicitly "unset" on the block itself to allow the user to modify
            // the block's content.
            templateLock: false
          })
        ];
      }
    }, [post2.type, post2.id]);
    const blocks = (0, import_element144.useMemo)(() => {
      if (maybeNavigationBlocks) {
        return maybeNavigationBlocks;
      }
      if (rootLevelPost === "template") {
        return templateBlocks;
      }
      return postBlocks;
    }, [maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks]);
    if (revisionBlocks !== null) {
      return [revisionBlocks, noop6, noop6];
    }
    const disableRootLevelChanges = !!template2 && mode === "template-locked" || post2.type === "wp_navigation";
    if (disableRootLevelChanges) {
      return [blocks, noop6, noop6];
    }
    return [
      blocks,
      rootLevelPost === "post" ? onInput : onInputTemplate,
      rootLevelPost === "post" ? onChange : onChangeTemplate
    ];
  }
  var ExperimentalEditorProvider = with_registry_provider_default(
    ({
      post: post2,
      settings,
      recovery,
      initialEdits,
      children,
      BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
      __unstableTemplate: template2
    }) => {
      const hasTemplate = !!template2;
      const {
        editorSettings: editorSettings2,
        selection,
        isReady: isReady2,
        mode,
        defaultMode,
        postTypeEntities,
        isInRevisionsMode,
        currentRevisionId
      } = (0, import_data63.useSelect)(
        (select7) => {
          const {
            getEditorSettings: getEditorSettings2,
            getRenderingMode: getRenderingMode2,
            __unstableIsEditorReady: __unstableIsEditorReady2,
            getDefaultRenderingMode: getDefaultRenderingMode2,
            isRevisionsMode: _isRevisionsMode,
            getCurrentRevisionId: _getCurrentRevisionId
          } = unlock(select7(store3));
          const { getEntitiesConfig, getEntityRecordEdits } = select7(import_core_data38.store);
          const _mode = getRenderingMode2();
          const _defaultMode = getDefaultRenderingMode2(post2.type);
          const hasResolvedDefaultMode = _defaultMode === "template-locked" ? hasTemplate : _defaultMode !== void 0;
          const isRenderingModeReady = _defaultMode !== void 0;
          const entityEdits = getEntityRecordEdits(
            "postType",
            post2.type,
            post2.id
          );
          return {
            editorSettings: getEditorSettings2(),
            isReady: __unstableIsEditorReady2(),
            mode: isRenderingModeReady ? _mode : void 0,
            defaultMode: hasResolvedDefaultMode ? _defaultMode : void 0,
            selection: entityEdits?.selection,
            postTypeEntities: post2.type === "wp_template" ? getEntitiesConfig("postType") : null,
            isInRevisionsMode: _isRevisionsMode(),
            currentRevisionId: _getCurrentRevisionId()
          };
        },
        [post2.type, post2.id, hasTemplate]
      );
      const shouldRenderTemplate = hasTemplate && mode !== "post-only";
      const rootLevelPost = shouldRenderTemplate ? template2 : post2;
      const defaultBlockContext = (0, import_element144.useMemo)(() => {
        const postContext = {};
        if (post2.type === "wp_template") {
          if (post2.slug === "page") {
            postContext.postType = "page";
          } else if (post2.slug === "single") {
            postContext.postType = "post";
          } else if (post2.slug.split("-")[0] === "single") {
            const postTypeNames = postTypeEntities?.map((entity) => entity.name) || [];
            const match3 = post2.slug.match(
              `^single-(${postTypeNames.join("|")})(?:-.+)?$`
            );
            if (match3) {
              postContext.postType = match3[1];
            }
          }
        } else if (!NON_CONTEXTUAL_POST_TYPES.includes(rootLevelPost.type) || shouldRenderTemplate) {
          postContext.postId = post2.id;
          postContext.postType = post2.type;
        }
        return {
          ...postContext,
          templateSlug: rootLevelPost.type === "wp_template" ? rootLevelPost.slug : void 0
        };
      }, [
        shouldRenderTemplate,
        post2.id,
        post2.type,
        post2.slug,
        rootLevelPost.type,
        rootLevelPost.slug,
        postTypeEntities
      ]);
      const { id, type } = rootLevelPost;
      const blockEditorSettings = use_block_editor_settings_default(
        editorSettings2,
        type,
        id,
        mode
      );
      const [blocks, onInput, onChange] = useBlockEditorProps(
        post2,
        template2,
        mode
      );
      const {
        updatePostLock: updatePostLock2,
        setupEditor: setupEditor2,
        updateEditorSettings: updateEditorSettings2,
        setCurrentTemplateId: setCurrentTemplateId2,
        setEditedPost: setEditedPost2,
        setRenderingMode: setRenderingMode2
      } = unlock((0, import_data63.useDispatch)(store3));
      const { editEntityRecord } = (0, import_data63.useDispatch)(import_core_data38.store);
      const onChangeSelection = (0, import_element144.useCallback)(
        (newSelection) => {
          editEntityRecord(
            "postType",
            post2.type,
            post2.id,
            { selection: newSelection },
            { undoIgnore: true }
          );
        },
        [editEntityRecord, post2.type, post2.id]
      );
      const { createWarningNotice, removeNotice } = (0, import_data63.useDispatch)(import_notices17.store);
      (0, import_element144.useLayoutEffect)(() => {
        if (recovery) {
          return;
        }
        updatePostLock2(settings.postLock);
        setupEditor2(post2, initialEdits, settings.template);
        if (settings.autosave) {
          createWarningNotice(
            (0, import_i18n136.__)(
              "There is an autosave of this post that is more recent than the version below."
            ),
            {
              id: "autosave-exists",
              actions: [
                {
                  label: (0, import_i18n136.__)("View the autosave"),
                  url: settings.autosave.editLink
                }
              ]
            }
          );
        }
      }, []);
      (0, import_element144.useEffect)(() => {
        setEditedPost2(post2.type, post2.id);
        if (typeof window !== "undefined" && window.__experimentalTemplateActivate) {
          removeNotice("template-activate-notice");
        }
        return () => setEditedPost2(null, null);
      }, [post2.type, post2.id, setEditedPost2, removeNotice]);
      (0, import_element144.useEffect)(() => {
        updateEditorSettings2(settings);
      }, [settings, updateEditorSettings2]);
      (0, import_element144.useEffect)(() => {
        setCurrentTemplateId2(template2?.id);
      }, [template2?.id, setCurrentTemplateId2]);
      (0, import_element144.useEffect)(() => {
        if (defaultMode) {
          setRenderingMode2(defaultMode);
        }
      }, [defaultMode, setRenderingMode2]);
      useHideBlocksFromInserter(post2.type, mode);
      useCommands();
      useUploadSaveLock();
      if (!isReady2 || !mode) {
        return null;
      }
      const isAttachment = post2.type === ATTACHMENT_POST_TYPE && window?.__experimentalMediaEditor;
      if (isAttachment) {
        return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(import_core_data38.EntityProvider, { kind: "root", type: "site", children: /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(
          import_core_data38.EntityProvider,
          {
            kind: "postType",
            type: post2.type,
            id: post2.id,
            children: [
              children,
              !settings.isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(import_jsx_runtime253.Fragment, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(EditorKeyboardShortcuts, {}),
                /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(keyboard_shortcut_help_modal_default, {})
              ] })
            ]
          }
        ) });
      }
      return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(import_core_data38.EntityProvider, { kind: "root", type: "site", children: /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(
        import_core_data38.EntityProvider,
        {
          kind: "postType",
          type: post2.type,
          id: post2.id,
          revisionId: currentRevisionId ?? void 0,
          children: /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(import_block_editor18.BlockContextProvider, { value: defaultBlockContext, children: /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(
            BlockEditorProviderComponent,
            {
              value: blocks,
              onChange,
              onInput,
              selection: isInRevisionsMode ? void 0 : selection,
              onChangeSelection: isInRevisionsMode ? noop6 : onChangeSelection,
              settings: blockEditorSettings,
              useSubRegistry: false,
              children: [
                children,
                !settings.isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(import_jsx_runtime253.Fragment, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(PatternsMenuItems, {}),
                  /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(TemplatePartMenuItems, {}),
                  mode === "template-locked" && /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(DisableNonPageContentBlocks, {}),
                  type === "wp_navigation" && /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(NavigationBlockEditingMode, {}),
                  /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(EditorKeyboardShortcuts, {}),
                  /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(keyboard_shortcut_help_modal_default, {}),
                  /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(BlockRemovalWarnings, {}),
                  /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(StartPageOptions, {}),
                  /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(StartTemplateOptions, {}),
                  /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(PatternRenameModal, {}),
                  /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(PatternDuplicateModal, {}),
                  window?.__experimentalMediaEditorModal && /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(MediaEditorModalMount, {})
                ] })
              ]
            }
          ) })
        }
      ) });
    }
  );
  function EditorProvider(props) {
    return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(
      ExperimentalEditorProvider,
      {
        ...props,
        BlockEditorProviderComponent: import_block_editor18.BlockEditorProvider,
        children: props.children
      }
    );
  }
  var provider_default = EditorProvider;

  // packages/editor/build-module/components/global-styles/index.mjs
  var import_core_data51 = __toESM(require_core_data(), 1);
  var import_data78 = __toESM(require_data(), 1);
  var import_element178 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/global-styles-ui.mjs
  var import_components154 = __toESM(require_components(), 1);
  var import_blocks19 = __toESM(require_blocks(), 1);
  var import_data75 = __toESM(require_data(), 1);
  var import_block_editor32 = __toESM(require_block_editor(), 1);
  var import_element175 = __toESM(require_element(), 1);
  var import_compose29 = __toESM(require_compose(), 1);

  // packages/global-styles-ui/build-module/provider.mjs
  var import_element146 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/context.mjs
  var import_element145 = __toESM(require_element(), 1);
  var GlobalStylesContext = (0, import_element145.createContext)({
    user: { styles: {}, settings: {} },
    base: { styles: {}, settings: {} },
    merged: { styles: {}, settings: {} },
    onChange: () => {
    },
    fontLibraryEnabled: false
  });

  // packages/global-styles-ui/build-module/provider.mjs
  var import_jsx_runtime254 = __toESM(require_jsx_runtime(), 1);
  function GlobalStylesProvider({
    children,
    value,
    baseValue,
    onChange,
    fontLibraryEnabled
  }) {
    const merged = (0, import_element146.useMemo)(() => {
      return mergeGlobalStyles(baseValue, value);
    }, [baseValue, value]);
    const contextValue = (0, import_element146.useMemo)(
      () => ({
        user: value,
        base: baseValue,
        merged,
        onChange,
        fontLibraryEnabled
      }),
      [value, baseValue, merged, onChange, fontLibraryEnabled]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(GlobalStylesContext.Provider, { value: contextValue, children });
  }

  // packages/global-styles-ui/build-module/screen-root.mjs
  var import_components101 = __toESM(require_components(), 1);
  var import_i18n141 = __toESM(require_i18n(), 1);
  var import_data65 = __toESM(require_data(), 1);
  var import_core_data40 = __toESM(require_core_data(), 1);

  // packages/global-styles-ui/build-module/icon-with-current-color.mjs
  var import_jsx_runtime255 = __toESM(require_jsx_runtime(), 1);
  function IconWithCurrentColor({
    className,
    ...props
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
      icon_default,
      {
        className: clsx_default(
          className,
          "global-styles-ui-icon-with-current-color"
        ),
        ...props
      }
    );
  }

  // packages/global-styles-ui/build-module/navigation-button.mjs
  var import_components95 = __toESM(require_components(), 1);
  var import_jsx_runtime256 = __toESM(require_jsx_runtime(), 1);
  function GenericNavigationButton({
    icon,
    children,
    ...props
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime256.jsxs)(import_components95.__experimentalItem, { ...props, children: [
      icon && /* @__PURE__ */ (0, import_jsx_runtime256.jsxs)(import_components95.__experimentalHStack, { justify: "flex-start", children: [
        /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(IconWithCurrentColor, { icon, size: 24 }),
        /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(import_components95.FlexItem, { children })
      ] }),
      !icon && children
    ] });
  }
  function NavigationButtonAsItem(props) {
    return /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(import_components95.Navigator.Button, { as: GenericNavigationButton, ...props });
  }

  // packages/global-styles-ui/build-module/root-menu.mjs
  var import_components96 = __toESM(require_components(), 1);
  var import_i18n139 = __toESM(require_i18n(), 1);
  var import_block_editor19 = __toESM(require_block_editor(), 1);

  // node_modules/colord/plugins/a11y.mjs
  var o3 = function(o4) {
    var t4 = o4 / 255;
    return t4 < 0.04045 ? t4 / 12.92 : Math.pow((t4 + 0.055) / 1.055, 2.4);
  };
  var t3 = function(t4) {
    return 0.2126 * o3(t4.r) + 0.7152 * o3(t4.g) + 0.0722 * o3(t4.b);
  };
  function a11y_default(o4) {
    o4.prototype.luminance = function() {
      return o5 = t3(this.rgba), void 0 === (r4 = 2) && (r4 = 0), void 0 === n3 && (n3 = Math.pow(10, r4)), Math.round(n3 * o5) / n3 + 0;
      var o5, r4, n3;
    }, o4.prototype.contrast = function(r4) {
      void 0 === r4 && (r4 = "#FFF");
      var n3, a3, i3, e3, v3, u3, d3, c6 = r4 instanceof o4 ? r4 : new o4(r4);
      return e3 = this.rgba, v3 = c6.toRgb(), u3 = t3(e3), d3 = t3(v3), n3 = u3 > d3 ? (u3 + 0.05) / (d3 + 0.05) : (d3 + 0.05) / (u3 + 0.05), void 0 === (a3 = 2) && (a3 = 0), void 0 === i3 && (i3 = Math.pow(10, a3)), Math.floor(i3 * n3) / i3 + 0;
    }, o4.prototype.isReadable = function(o5, t4) {
      return void 0 === o5 && (o5 = "#FFF"), void 0 === t4 && (t4 = {}), this.contrast(o5) >= (e3 = void 0 === (i3 = (r4 = t4).size) ? "normal" : i3, "AAA" === (a3 = void 0 === (n3 = r4.level) ? "AA" : n3) && "normal" === e3 ? 7 : "AA" === a3 && "large" === e3 ? 3 : 4.5);
      var r4, n3, a3, i3, e3;
    };
  }

  // packages/global-styles-ui/build-module/hooks.mjs
  var import_element147 = __toESM(require_element(), 1);
  var import_data64 = __toESM(require_data(), 1);
  var import_core_data39 = __toESM(require_core_data(), 1);
  var import_i18n138 = __toESM(require_i18n(), 1);

  // packages/global-styles-ui/build-module/utils.mjs
  var import_i18n137 = __toESM(require_i18n(), 1);
  var VALID_ELEMENT_STATES = {
    link: [
      { value: ":link", label: (0, import_i18n137.__)("Link") },
      { value: ":any-link", label: (0, import_i18n137.__)("Any Link") },
      { value: ":visited", label: (0, import_i18n137.__)("Visited") },
      { value: ":hover", label: (0, import_i18n137.__)("Hover") },
      { value: ":focus", label: (0, import_i18n137.__)("Focus") },
      { value: ":focus-visible", label: (0, import_i18n137.__)("Focus-visible") },
      { value: ":active", label: (0, import_i18n137.__)("Active") }
    ],
    button: [
      { value: ":link", label: (0, import_i18n137.__)("Link") },
      { value: ":any-link", label: (0, import_i18n137.__)("Any Link") },
      { value: ":visited", label: (0, import_i18n137.__)("Visited") },
      { value: ":hover", label: (0, import_i18n137.__)("Hover") },
      { value: ":focus", label: (0, import_i18n137.__)("Focus") },
      { value: ":focus-visible", label: (0, import_i18n137.__)("Focus-visible") },
      { value: ":active", label: (0, import_i18n137.__)("Active") }
    ]
  };
  var VALID_BLOCK_STATES = {
    "core/button": [
      { value: ":hover", label: (0, import_i18n137.__)("Hover") },
      { value: ":focus", label: (0, import_i18n137.__)("Focus") },
      { value: ":focus-visible", label: (0, import_i18n137.__)("Focus-visible") },
      { value: ":active", label: (0, import_i18n137.__)("Active") }
    ]
  };
  function getValidStates(name2) {
    if (VALID_BLOCK_STATES[name2]) {
      return VALID_BLOCK_STATES[name2];
    }
    if (VALID_ELEMENT_STATES[name2]) {
      return VALID_ELEMENT_STATES[name2];
    }
    return [];
  }
  function removePropertiesFromObject(object, properties) {
    if (!properties?.length) {
      return object;
    }
    if (typeof object !== "object" || !object || !Object.keys(object).length) {
      return object;
    }
    for (const key in object) {
      if (properties.includes(key)) {
        delete object[key];
      } else if (typeof object[key] === "object") {
        removePropertiesFromObject(object[key], properties);
      }
    }
    return object;
  }
  var filterObjectByProperties = (object, properties) => {
    if (!object || !properties?.length) {
      return {};
    }
    const newObject = {};
    Object.keys(object).forEach((key) => {
      if (properties.includes(key)) {
        newObject[key] = object[key];
      } else if (typeof object[key] === "object") {
        const newFilter = filterObjectByProperties(
          object[key],
          properties
        );
        if (Object.keys(newFilter).length) {
          newObject[key] = newFilter;
        }
      }
    });
    return newObject;
  };
  function isVariationWithProperties(variation, properties) {
    const variationWithProperties = filterObjectByProperties(
      structuredClone(variation),
      properties
    );
    return areGlobalStylesEqual(variationWithProperties, variation);
  }
  function getFontFamilyFromSetting(fontFamilies, setting) {
    if (!Array.isArray(fontFamilies) || !setting) {
      return null;
    }
    const fontFamilyVariable = setting.replace("var(", "").replace(")", "");
    const fontFamilySlug = fontFamilyVariable?.split("--").slice(-1)[0];
    return fontFamilies.find(
      (fontFamily) => fontFamily.slug === fontFamilySlug
    );
  }
  function getFontFamilies(themeJson) {
    const themeFontFamilies = themeJson?.settings?.typography?.fontFamilies?.theme;
    const customFontFamilies = themeJson?.settings?.typography?.fontFamilies?.custom;
    let fontFamilies = [];
    if (themeFontFamilies && customFontFamilies) {
      fontFamilies = [...themeFontFamilies, ...customFontFamilies];
    } else if (themeFontFamilies) {
      fontFamilies = themeFontFamilies;
    } else if (customFontFamilies) {
      fontFamilies = customFontFamilies;
    }
    const bodyFontFamilySetting = themeJson?.styles?.typography?.fontFamily;
    const bodyFontFamily = getFontFamilyFromSetting(
      fontFamilies,
      bodyFontFamilySetting
    );
    const headingFontFamilySetting = themeJson?.styles?.elements?.heading?.typography?.fontFamily;
    let headingFontFamily;
    if (!headingFontFamilySetting) {
      headingFontFamily = bodyFontFamily;
    } else {
      headingFontFamily = getFontFamilyFromSetting(
        fontFamilies,
        themeJson?.styles?.elements?.heading?.typography?.fontFamily
      );
    }
    return [bodyFontFamily, headingFontFamily];
  }
  function getVariationClassName(variation) {
    if (!variation) {
      return "";
    }
    return `is-style-${variation}`;
  }
  function getNewIndexFromPresets(presets, slugPrefix) {
    const nameRegex = new RegExp(`^${slugPrefix}([\\d]+)$`);
    const highestPresetValue = presets.reduce((currentHighest, preset) => {
      if (typeof preset?.slug === "string") {
        const matches = preset?.slug.match(nameRegex);
        if (matches) {
          const id = parseInt(matches[1], 10);
          if (id > currentHighest) {
            return id;
          }
        }
      }
      return currentHighest;
    }, 0);
    return highestPresetValue + 1;
  }

  // packages/global-styles-ui/build-module/hooks.mjs
  k([a11y_default]);
  function useStyle(path, blockName, readFrom = "merged", shouldDecodeEncode = true, state) {
    const { user, base, merged, onChange } = (0, import_element147.useContext)(GlobalStylesContext);
    let sourceValue = merged;
    if (readFrom === "base") {
      sourceValue = base;
    } else if (readFrom === "user") {
      sourceValue = user;
    }
    const styleValue = (0, import_element147.useMemo)(() => {
      const rawValue = getStyle(
        sourceValue,
        path,
        blockName,
        shouldDecodeEncode
      );
      if (state) {
        return rawValue?.[state] ?? {};
      }
      return rawValue;
    }, [sourceValue, path, blockName, shouldDecodeEncode, state]);
    const setStyleValue = (0, import_element147.useCallback)(
      (newValue) => {
        let valueToSet = newValue;
        if (state) {
          const fullCurrentValue = getStyle(
            user,
            path,
            blockName,
            false
          );
          valueToSet = {
            ...fullCurrentValue,
            [state]: newValue
          };
        }
        const newGlobalStyles = setStyle(
          user,
          path,
          valueToSet,
          blockName
        );
        onChange(newGlobalStyles);
      },
      [user, onChange, path, blockName, state]
    );
    return [styleValue, setStyleValue];
  }
  function useSetting(path, blockName, readFrom = "merged") {
    const { user, base, merged, onChange } = (0, import_element147.useContext)(GlobalStylesContext);
    let sourceValue = merged;
    if (readFrom === "base") {
      sourceValue = base;
    } else if (readFrom === "user") {
      sourceValue = user;
    }
    const settingValue = (0, import_element147.useMemo)(
      () => getSetting(sourceValue, path, blockName),
      [sourceValue, path, blockName]
    );
    const setSettingValue = (0, import_element147.useCallback)(
      (newValue) => {
        const newGlobalStyles = setSetting(
          user,
          path,
          newValue,
          blockName
        );
        onChange(newGlobalStyles);
      },
      [user, onChange, path, blockName]
    );
    return [settingValue, setSettingValue];
  }
  var EMPTY_ARRAY9 = [];
  function hasThemeVariation({
    title,
    settings,
    styles
  }) {
    return title === (0, import_i18n138.__)("Default") || Object.keys(settings || {}).length > 0 || Object.keys(styles || {}).length > 0;
  }
  function useCurrentMergeThemeStyleVariationsWithUserConfig(properties = []) {
    const { variationsFromTheme } = (0, import_data64.useSelect)((select7) => {
      const _variationsFromTheme = select7(
        import_core_data39.store
      ).__experimentalGetCurrentThemeGlobalStylesVariations?.();
      return {
        variationsFromTheme: _variationsFromTheme || EMPTY_ARRAY9
      };
    }, []);
    const { user: userVariation } = (0, import_element147.useContext)(GlobalStylesContext);
    return (0, import_element147.useMemo)(() => {
      const clonedUserVariation = structuredClone(userVariation);
      const userVariationWithoutProperties = removePropertiesFromObject(
        clonedUserVariation,
        properties
      );
      userVariationWithoutProperties.title = (0, import_i18n138.__)("Default");
      const variationsWithPropertiesAndBase = variationsFromTheme.filter((variation) => {
        return isVariationWithProperties(variation, properties);
      }).map((variation) => {
        return mergeGlobalStyles(
          userVariationWithoutProperties,
          variation
        );
      });
      const variationsByProperties = [
        userVariationWithoutProperties,
        ...variationsWithPropertiesAndBase
      ];
      return variationsByProperties?.length ? variationsByProperties.filter(hasThemeVariation) : [];
    }, [properties, userVariation, variationsFromTheme]);
  }
  function useColorRandomizer(blockName) {
    const [themeColors, setThemeColors] = useSetting(
      "color.palette.theme",
      blockName
    );
    const randomizeColors = (0, import_element147.useCallback)(() => {
      if (!themeColors || !themeColors.length) {
        return;
      }
      const randomRotationValue = Math.floor(Math.random() * 225);
      const newColors = themeColors.map((colorObject) => {
        const { color } = colorObject;
        const newColor = w2(color).rotate(randomRotationValue).toHex();
        return {
          ...colorObject,
          color: newColor
        };
      });
      setThemeColors(newColors);
    }, [themeColors, setThemeColors]);
    return window.__experimentalEnableColorRandomizer ? [randomizeColors] : [];
  }

  // packages/global-styles-ui/build-module/lock-unlock.mjs
  var import_private_apis6 = __toESM(require_private_apis(), 1);
  var { lock: lock5, unlock: unlock5 } = (0, import_private_apis6.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
    "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
    "@wordpress/global-styles-ui"
  );

  // packages/global-styles-ui/build-module/root-menu.mjs
  var import_jsx_runtime257 = __toESM(require_jsx_runtime(), 1);
  var {
    useHasDimensionsPanel,
    useHasTypographyPanel,
    useHasColorPanel,
    useSettingsForBlockElement,
    useHasBackgroundPanel
  } = unlock5(import_block_editor19.privateApis);
  function RootMenu() {
    const [rawSettings] = useSetting("");
    const settings = useSettingsForBlockElement(rawSettings);
    const hasBackgroundPanel = useHasBackgroundPanel(rawSettings);
    const hasTypographyPanel = useHasTypographyPanel(settings);
    const hasColorPanel = useHasColorPanel(settings);
    const hasShadowPanel = true;
    const hasDimensionsPanel = useHasDimensionsPanel(settings);
    const hasLayoutPanel = hasDimensionsPanel;
    return /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_jsx_runtime257.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime257.jsxs)(import_components96.__experimentalItemGroup, { children: [
      hasTypographyPanel && /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(
        NavigationButtonAsItem,
        {
          icon: typography_default,
          path: "/typography",
          children: (0, import_i18n139.__)("Typography")
        }
      ),
      hasColorPanel && /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(NavigationButtonAsItem, { icon: color_default, path: "/colors", children: (0, import_i18n139.__)("Colors") }),
      hasBackgroundPanel && /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(
        NavigationButtonAsItem,
        {
          icon: background_default,
          path: "/background",
          "aria-label": (0, import_i18n139.__)("Background styles"),
          children: (0, import_i18n139.__)("Background")
        }
      ),
      hasShadowPanel && /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(NavigationButtonAsItem, { icon: shadow_default, path: "/shadows", children: (0, import_i18n139.__)("Shadows") }),
      hasLayoutPanel && /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(NavigationButtonAsItem, { icon: layout_default, path: "/layout", children: (0, import_i18n139.__)("Layout") })
    ] }) });
  }
  var root_menu_default = RootMenu;

  // packages/global-styles-ui/build-module/preview-styles.mjs
  var import_components100 = __toESM(require_components(), 1);

  // packages/global-styles-ui/build-module/preview-hooks.mjs
  function useStylesPreviewColors() {
    const [textColor = "black"] = useStyle("color.text");
    const [backgroundColor = "white"] = useStyle("color.background");
    const [headingColor = textColor] = useStyle(
      "elements.h1.color.text"
    );
    const [linkColor = headingColor] = useStyle(
      "elements.link.color.text"
    );
    const [buttonBackgroundColor = linkColor] = useStyle(
      "elements.button.color.background"
    );
    const [coreColors] = useSetting("color.palette.core") || [];
    const [themeColors] = useSetting("color.palette.theme") || [];
    const [customColors] = useSetting("color.palette.custom") || [];
    const paletteColors = (themeColors ?? []).concat(customColors ?? []).concat(coreColors ?? []);
    const textColorObject = paletteColors.filter(
      ({ color }) => color === textColor
    );
    const buttonBackgroundColorObject = paletteColors.filter(
      ({ color }) => color === buttonBackgroundColor
    );
    const highlightedColors = textColorObject.concat(buttonBackgroundColorObject).concat(paletteColors).filter(
      // we exclude these background color because it is already visible in the preview.
      ({ color }) => color !== backgroundColor
    ).slice(0, 2);
    return {
      paletteColors,
      highlightedColors
    };
  }

  // packages/global-styles-ui/build-module/typography-example.mjs
  var import_element148 = __toESM(require_element(), 1);
  var import_components97 = __toESM(require_components(), 1);
  var import_i18n140 = __toESM(require_i18n(), 1);

  // packages/global-styles-ui/build-module/font-library/utils/preview-styles.mjs
  function findNearest(input, numbers) {
    if (numbers.length === 0) {
      return null;
    }
    numbers.sort((a3, b3) => Math.abs(input - a3) - Math.abs(input - b3));
    return numbers[0];
  }
  function extractFontWeights(fontFaces) {
    const result = [];
    fontFaces.forEach((face) => {
      const weights = String(face.fontWeight).split(" ");
      if (weights.length === 2) {
        const start2 = parseInt(weights[0]);
        const end = parseInt(weights[1]);
        for (let i3 = start2; i3 <= end; i3 += 100) {
          result.push(i3);
        }
      } else if (weights.length === 1) {
        result.push(parseInt(weights[0]));
      }
    });
    return result;
  }
  function formatFontFamily(input) {
    const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/;
    const output = input.trim();
    const formatItem = (item) => {
      item = item.trim();
      if (item.match(regex)) {
        item = item.replace(/^["']|["']$/g, "");
        return `"${item}"`;
      }
      return item;
    };
    if (output.includes(",")) {
      return output.split(",").map(formatItem).filter((item) => item !== "").join(", ");
    }
    return formatItem(output);
  }
  function formatFontFaceName(input) {
    if (!input) {
      return "";
    }
    let output = input.trim();
    if (output.includes(",")) {
      output = (output.split(",").find((item) => item.trim() !== "") ?? "").trim();
    }
    output = output.replace(/^["']|["']$/g, "");
    if (window.navigator.userAgent.toLowerCase().includes("firefox")) {
      output = `"${output}"`;
    }
    return output;
  }
  function getFamilyPreviewStyle(family) {
    const style = {
      fontFamily: formatFontFamily(family.fontFamily)
    };
    if (!("fontFace" in family) || !Array.isArray(family.fontFace)) {
      style.fontWeight = "400";
      style.fontStyle = "normal";
      return style;
    }
    if (family.fontFace) {
      const normalFaces = family.fontFace.filter(
        (face) => face?.fontStyle && face.fontStyle.toLowerCase() === "normal"
      );
      if (normalFaces.length > 0) {
        style.fontStyle = "normal";
        const normalWeights = extractFontWeights(normalFaces);
        const nearestWeight = findNearest(400, normalWeights);
        style.fontWeight = String(nearestWeight) || "400";
      } else {
        style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || "normal";
        style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || "400";
      }
    }
    return style;
  }
  function getFacePreviewStyle(face) {
    return {
      fontFamily: formatFontFamily(face.fontFamily),
      fontStyle: face.fontStyle || "normal",
      fontWeight: face.fontWeight || "400"
    };
  }

  // packages/global-styles-ui/build-module/typography-example.mjs
  var import_jsx_runtime258 = __toESM(require_jsx_runtime(), 1);
  function PreviewTypography({
    fontSize,
    variation
  }) {
    const { base } = (0, import_element148.useContext)(GlobalStylesContext);
    let config2 = base;
    if (variation) {
      config2 = { ...base, ...variation };
    }
    const [textColor] = useStyle("color.text");
    const [bodyFontFamilies, headingFontFamilies] = getFontFamilies(config2);
    const bodyPreviewStyle = bodyFontFamilies ? getFamilyPreviewStyle(bodyFontFamilies) : {};
    const headingPreviewStyle = headingFontFamilies ? getFamilyPreviewStyle(headingFontFamilies) : {};
    if (textColor) {
      bodyPreviewStyle.color = textColor;
      headingPreviewStyle.color = textColor;
    }
    if (fontSize) {
      bodyPreviewStyle.fontSize = fontSize;
      headingPreviewStyle.fontSize = fontSize;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)(
      import_components97.__unstableMotion.div,
      {
        animate: {
          scale: 1,
          opacity: 1
        },
        initial: {
          scale: 0.1,
          opacity: 0
        },
        transition: {
          delay: 0.3,
          type: "tween"
        },
        style: {
          textAlign: "center",
          lineHeight: 1
        },
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime258.jsx)("span", { style: headingPreviewStyle, children: (0, import_i18n140._x)("A", "Uppercase letter A") }),
          /* @__PURE__ */ (0, import_jsx_runtime258.jsx)("span", { style: bodyPreviewStyle, children: (0, import_i18n140._x)("a", "Lowercase letter A") })
        ]
      }
    );
  }

  // packages/global-styles-ui/build-module/highlighted-colors.mjs
  var import_components98 = __toESM(require_components(), 1);
  var import_jsx_runtime259 = __toESM(require_jsx_runtime(), 1);
  function HighlightedColors({
    normalizedColorSwatchSize,
    ratio
  }) {
    const { highlightedColors } = useStylesPreviewColors();
    const scaledSwatchSize = normalizedColorSwatchSize * ratio;
    return highlightedColors.map(({ slug, color }, index) => /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
      import_components98.__unstableMotion.div,
      {
        style: {
          height: scaledSwatchSize,
          width: scaledSwatchSize,
          background: color,
          borderRadius: scaledSwatchSize / 2
        },
        animate: {
          scale: 1,
          opacity: 1
        },
        initial: {
          scale: 0.1,
          opacity: 0
        },
        transition: {
          delay: index === 1 ? 0.2 : 0.1
        }
      },
      `${slug}-${index}`
    ));
  }

  // packages/global-styles-ui/build-module/preview-wrapper.mjs
  var import_components99 = __toESM(require_components(), 1);
  var import_compose24 = __toESM(require_compose(), 1);
  var import_element149 = __toESM(require_element(), 1);
  var import_jsx_runtime260 = __toESM(require_jsx_runtime(), 1);
  var normalizedWidth = 248;
  var normalizedHeight = 152;
  var THROTTLE_OPTIONS = {
    leading: true,
    trailing: true
  };
  function PreviewWrapper({
    children,
    label,
    isFocused,
    withHoverView
  }) {
    const [backgroundColor = "white"] = useStyle("color.background");
    const [gradientValue] = useStyle("color.gradient");
    const disableMotion = (0, import_compose24.useReducedMotion)();
    const [isHovered, setIsHovered] = (0, import_element149.useState)(false);
    const [containerResizeListener, { width }] = (0, import_compose24.useResizeObserver)();
    const [throttledWidth, setThrottledWidthState] = (0, import_element149.useState)(width);
    const [ratioState, setRatioState] = (0, import_element149.useState)();
    const setThrottledWidth = (0, import_compose24.useThrottle)(
      setThrottledWidthState,
      250,
      THROTTLE_OPTIONS
    );
    (0, import_element149.useLayoutEffect)(() => {
      if (width) {
        setThrottledWidth(width);
      }
    }, [width, setThrottledWidth]);
    (0, import_element149.useLayoutEffect)(() => {
      const newRatio = throttledWidth ? throttledWidth / normalizedWidth : 1;
      const ratioDiff = newRatio - (ratioState || 0);
      const isRatioDiffBigEnough = Math.abs(ratioDiff) > 0.1;
      if (isRatioDiffBigEnough || !ratioState) {
        setRatioState(newRatio);
      }
    }, [throttledWidth, ratioState]);
    const fallbackRatio = width ? width / normalizedWidth : 1;
    const ratio = ratioState ? ratioState : fallbackRatio;
    const isReady2 = !!width;
    return /* @__PURE__ */ (0, import_jsx_runtime260.jsxs)(import_jsx_runtime260.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime260.jsx)("div", { style: { position: "relative" }, children: containerResizeListener }),
      isReady2 && /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(
        "div",
        {
          className: clsx_default("global-styles-ui-preview__wrapper", {
            "is-hoverable": withHoverView
          }),
          style: {
            height: normalizedHeight * ratio
          },
          onMouseEnter: () => setIsHovered(true),
          onMouseLeave: () => setIsHovered(false),
          tabIndex: -1,
          children: /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(
            import_components99.__unstableMotion.div,
            {
              style: {
                height: normalizedHeight * ratio,
                width: "100%",
                background: gradientValue ?? backgroundColor
              },
              initial: "start",
              animate: (isHovered || isFocused) && !disableMotion && label ? "hover" : "start",
              children: [].concat(children).map(
                (child, key) => child({ ratio, key })
              )
            }
          )
        }
      )
    ] });
  }
  var preview_wrapper_default = PreviewWrapper;

  // packages/global-styles-ui/build-module/preview-styles.mjs
  var import_jsx_runtime261 = __toESM(require_jsx_runtime(), 1);
  var firstFrameVariants = {
    start: {
      scale: 1,
      opacity: 1
    },
    hover: {
      scale: 0,
      opacity: 0
    }
  };
  var midFrameVariants = {
    hover: {
      opacity: 1
    },
    start: {
      opacity: 0.5
    }
  };
  var secondFrameVariants = {
    hover: {
      scale: 1,
      opacity: 1
    },
    start: {
      scale: 0,
      opacity: 0
    }
  };
  function PreviewStyles({
    label,
    isFocused,
    withHoverView,
    variation
  }) {
    const [fontWeight] = useStyle("typography.fontWeight");
    const [fontFamily = "serif"] = useStyle(
      "typography.fontFamily"
    );
    const [headingFontFamily = fontFamily] = useStyle(
      "elements.h1.typography.fontFamily"
    );
    const [headingFontWeight = fontWeight] = useStyle(
      "elements.h1.typography.fontWeight"
    );
    const [textColor = "black"] = useStyle("color.text");
    const [headingColor = textColor] = useStyle(
      "elements.h1.color.text"
    );
    const { paletteColors } = useStylesPreviewColors();
    return /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(
      preview_wrapper_default,
      {
        label,
        isFocused,
        withHoverView,
        children: [
          ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(
            import_components100.__unstableMotion.div,
            {
              variants: firstFrameVariants,
              style: {
                height: "100%",
                overflow: "hidden"
              },
              children: /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(
                import_components100.__experimentalHStack,
                {
                  spacing: 10 * ratio,
                  justify: "center",
                  style: {
                    height: "100%",
                    overflow: "hidden"
                  },
                  children: [
                    /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(
                      PreviewTypography,
                      {
                        fontSize: 65 * ratio,
                        variation
                      }
                    ),
                    /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(import_components100.__experimentalVStack, { spacing: 4 * ratio, children: /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(
                      HighlightedColors,
                      {
                        normalizedColorSwatchSize: 32,
                        ratio
                      }
                    ) })
                  ]
                }
              )
            },
            key
          ),
          ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(
            import_components100.__unstableMotion.div,
            {
              variants: withHoverView ? midFrameVariants : void 0,
              style: {
                height: "100%",
                width: "100%",
                position: "absolute",
                top: 0,
                overflow: "hidden",
                filter: "blur(60px)",
                opacity: 0.1
              },
              children: /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(
                import_components100.__experimentalHStack,
                {
                  spacing: 0,
                  justify: "flex-start",
                  style: {
                    height: "100%",
                    overflow: "hidden"
                  },
                  children: paletteColors.slice(0, 4).map(({ color }, index) => /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(
                    "div",
                    {
                      style: {
                        height: "100%",
                        background: color,
                        flexGrow: 1
                      }
                    },
                    index
                  ))
                }
              )
            },
            key
          ),
          ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(
            import_components100.__unstableMotion.div,
            {
              variants: secondFrameVariants,
              style: {
                height: "100%",
                width: "100%",
                overflow: "hidden",
                position: "absolute",
                top: 0
              },
              children: /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(
                import_components100.__experimentalVStack,
                {
                  spacing: 3 * ratio,
                  justify: "center",
                  style: {
                    height: "100%",
                    overflow: "hidden",
                    padding: 10 * ratio,
                    boxSizing: "border-box"
                  },
                  children: label && /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(
                    "div",
                    {
                      style: {
                        fontSize: 40 * ratio,
                        fontFamily: headingFontFamily,
                        color: headingColor,
                        fontWeight: headingFontWeight,
                        lineHeight: "1em",
                        textAlign: "center"
                      },
                      children: label
                    }
                  )
                }
              )
            },
            key
          )
        ]
      }
    );
  }
  var preview_styles_default = PreviewStyles;

  // packages/global-styles-ui/build-module/screen-root.mjs
  var import_jsx_runtime262 = __toESM(require_jsx_runtime(), 1);
  function ScreenRoot() {
    const hasVariations = (0, import_data65.useSelect)((select7) => {
      const { __experimentalGetCurrentThemeGlobalStylesVariations } = select7(import_core_data40.store);
      return !!__experimentalGetCurrentThemeGlobalStylesVariations()?.length;
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(
      import_components101.Card,
      {
        size: "small",
        isBorderless: true,
        className: "global-styles-ui-screen-root",
        isRounded: false,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components101.CardBody, { children: /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_components101.__experimentalVStack, { spacing: 4, children: [
            /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components101.Card, { className: "global-styles-ui-screen-root__active-style-tile", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components101.CardMedia, { className: "global-styles-ui-screen-root__active-style-tile-preview", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(preview_styles_default, {}) }) }),
            hasVariations && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components101.__experimentalItemGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(NavigationButtonAsItem, { path: "/variations", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_components101.__experimentalHStack, { justify: "space-between", children: [
              /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components101.FlexItem, { children: (0, import_i18n141.__)("Browse styles") }),
              /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
                IconWithCurrentColor,
                {
                  icon: (0, import_i18n141.isRTL)() ? chevron_left_default : chevron_right_default
                }
              )
            ] }) }) }),
            /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(root_menu_default, {})
          ] }) }),
          /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components101.CardDivider, {}),
          /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_components101.CardBody, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
              import_components101.__experimentalSpacer,
              {
                as: "p",
                paddingTop: 2,
                paddingX: "13px",
                marginBottom: 4,
                children: (0, import_i18n141.__)(
                  "Customize the appearance of specific blocks for the whole site."
                )
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components101.__experimentalItemGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(NavigationButtonAsItem, { path: "/blocks", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_components101.__experimentalHStack, { justify: "space-between", children: [
              /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components101.FlexItem, { children: (0, import_i18n141.__)("Blocks") }),
              /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
                IconWithCurrentColor,
                {
                  icon: (0, import_i18n141.isRTL)() ? chevron_left_default : chevron_right_default
                }
              )
            ] }) }) })
          ] })
        ]
      }
    );
  }
  var screen_root_default = ScreenRoot;

  // packages/global-styles-ui/build-module/screen-block-list.mjs
  var import_blocks16 = __toESM(require_blocks(), 1);
  var import_i18n143 = __toESM(require_i18n(), 1);
  var import_components104 = __toESM(require_components(), 1);
  var import_data67 = __toESM(require_data(), 1);
  var import_element150 = __toESM(require_element(), 1);
  var import_block_editor21 = __toESM(require_block_editor(), 1);
  var import_compose25 = __toESM(require_compose(), 1);
  var import_a11y3 = __toESM(require_a11y(), 1);

  // packages/global-styles-ui/build-module/variations/variations-panel.mjs
  var import_blocks15 = __toESM(require_blocks(), 1);
  var import_data66 = __toESM(require_data(), 1);
  var import_components102 = __toESM(require_components(), 1);
  var import_jsx_runtime263 = __toESM(require_jsx_runtime(), 1);
  function getFilteredBlockStyles(blockStyles, variations) {
    return blockStyles?.filter(
      (style) => style.source === "block" || variations.includes(style.name)
    ) || [];
  }
  function useBlockVariations(name2) {
    const blockStyles = (0, import_data66.useSelect)(
      (select7) => {
        const { getBlockStyles } = select7(import_blocks15.store);
        return getBlockStyles(name2);
      },
      [name2]
    );
    const [variations] = useStyle("variations", name2);
    const variationNames = Object.keys(variations ?? {});
    return getFilteredBlockStyles(blockStyles, variationNames);
  }
  function VariationsPanel({ name: name2 }) {
    const coreBlockStyles = useBlockVariations(name2);
    return /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(import_components102.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: coreBlockStyles.map((style, index) => {
      if (style?.isDefault) {
        return null;
      }
      return /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(
        NavigationButtonAsItem,
        {
          path: "/blocks/" + encodeURIComponent(name2) + "/variations/" + encodeURIComponent(style.name),
          children: style.label
        },
        index
      );
    }) });
  }

  // packages/global-styles-ui/build-module/screen-header.mjs
  var import_components103 = __toESM(require_components(), 1);
  var import_i18n142 = __toESM(require_i18n(), 1);
  var import_block_editor20 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime264 = __toESM(require_jsx_runtime(), 1);
  var { StateControl } = unlock5(import_block_editor20.privateApis);
  function ScreenHeader({
    title,
    description,
    onBack,
    states,
    selectedState = "default",
    onChangeState
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_components103.__experimentalVStack, { spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_components103.__experimentalView, { children: /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_components103.__experimentalSpacer, { marginBottom: 0, paddingX: 4, paddingY: 3, children: /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)(import_components103.__experimentalVStack, { spacing: 2, children: [
      /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)(import_components103.__experimentalHStack, { spacing: 2, children: [
        /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
          import_components103.Navigator.BackButton,
          {
            icon: (0, import_i18n142.isRTL)() ? chevron_right_default : chevron_left_default,
            size: "small",
            label: (0, import_i18n142.__)("Back"),
            onClick: onBack
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_components103.__experimentalSpacer, { children: /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)(
          import_components103.__experimentalHStack,
          {
            justify: "space-between",
            alignment: "center",
            children: [
              /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
                import_components103.__experimentalHeading,
                {
                  className: "global-styles-ui-header",
                  level: 2,
                  size: 13,
                  children: title
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
                StateControl,
                {
                  states,
                  value: selectedState,
                  onChange: onChangeState
                }
              )
            ]
          }
        ) })
      ] }),
      description && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_components103.__experimentalText, { className: "global-styles-ui-header__description", children: description })
    ] }) }) }) });
  }

  // packages/global-styles-ui/build-module/screen-block-list.mjs
  var import_jsx_runtime265 = __toESM(require_jsx_runtime(), 1);
  var {
    useHasDimensionsPanel: useHasDimensionsPanel2,
    useHasTypographyPanel: useHasTypographyPanel2,
    useHasBorderPanel,
    useSettingsForBlockElement: useSettingsForBlockElement2,
    useHasColorPanel: useHasColorPanel2
  } = unlock5(import_block_editor21.privateApis);
  function useSortedBlockTypes() {
    const blockItems = (0, import_data67.useSelect)(
      (select7) => select7(import_blocks16.store).getBlockTypes(),
      []
    );
    const groupByType = (blocks, block) => {
      const { core, noncore } = blocks;
      const type = block.name.startsWith("core/") ? core : noncore;
      type.push(block);
      return blocks;
    };
    const { core: coreItems, noncore: nonCoreItems } = blockItems.reduce(
      groupByType,
      { core: [], noncore: [] }
    );
    return [...coreItems, ...nonCoreItems];
  }
  function useBlockHasGlobalStyles(blockName) {
    const [rawSettings] = useSetting("", blockName);
    const settings = useSettingsForBlockElement2(rawSettings, blockName);
    const hasTypographyPanel = useHasTypographyPanel2(settings);
    const hasColorPanel = useHasColorPanel2(settings);
    const hasBorderPanel = useHasBorderPanel(settings);
    const hasDimensionsPanel = useHasDimensionsPanel2(settings);
    const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
    const hasVariationsPanel = !!useBlockVariations(blockName)?.length;
    const hasGlobalStyles = hasTypographyPanel || hasColorPanel || hasLayoutPanel || hasVariationsPanel;
    return hasGlobalStyles;
  }
  function BlockMenuItem({ block }) {
    const hasBlockMenuItem = useBlockHasGlobalStyles(block.name);
    if (!hasBlockMenuItem) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
      NavigationButtonAsItem,
      {
        path: "/blocks/" + encodeURIComponent(block.name),
        children: /* @__PURE__ */ (0, import_jsx_runtime265.jsxs)(import_components104.__experimentalHStack, { justify: "flex-start", children: [
          /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(import_block_editor21.BlockIcon, { icon: block.icon }),
          /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(import_components104.FlexItem, { children: block.title })
        ] })
      }
    );
  }
  function BlockList({ filterValue }) {
    const sortedBlockTypes = useSortedBlockTypes();
    const debouncedSpeak = (0, import_compose25.useDebounce)(import_a11y3.speak, 500);
    const { isMatchingSearchTerm } = (0, import_data67.useSelect)(import_blocks16.store);
    const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter(
      (blockType) => isMatchingSearchTerm(blockType, filterValue)
    );
    const blockTypesListRef = (0, import_element150.useRef)(null);
    (0, import_element150.useEffect)(() => {
      if (!filterValue) {
        return;
      }
      const count = blockTypesListRef.current?.childElementCount || 0;
      const resultsFoundMessage = (0, import_i18n143.sprintf)(
        /* translators: %d: number of results. */
        (0, import_i18n143._n)("%d result found.", "%d results found.", count),
        count
      );
      debouncedSpeak(resultsFoundMessage, "polite");
    }, [filterValue, debouncedSpeak]);
    return /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
      "div",
      {
        ref: blockTypesListRef,
        className: "global-styles-ui-block-types-item-list",
        role: "list",
        children: filteredBlockTypes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(import_components104.__experimentalText, { align: "center", as: "p", children: (0, import_i18n143.__)("No blocks found.") }) : filteredBlockTypes.map((block) => /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
          BlockMenuItem,
          {
            block
          },
          "menu-itemblock-" + block.name
        ))
      }
    );
  }
  var MemoizedBlockList = (0, import_element150.memo)(BlockList);
  function ScreenBlockList() {
    const [filterValue, setFilterValue] = (0, import_element150.useState)("");
    const deferredFilterValue = (0, import_element150.useDeferredValue)(filterValue);
    return /* @__PURE__ */ (0, import_jsx_runtime265.jsxs)(import_jsx_runtime265.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
        ScreenHeader,
        {
          title: (0, import_i18n143.__)("Blocks"),
          description: (0, import_i18n143.__)(
            "Customize the appearance of specific blocks and for the whole site."
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
        import_components104.SearchControl,
        {
          className: "global-styles-ui-block-types-search",
          onChange: setFilterValue,
          value: filterValue,
          label: (0, import_i18n143.__)("Search"),
          placeholder: (0, import_i18n143.__)("Search")
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(MemoizedBlockList, { filterValue: deferredFilterValue })
    ] });
  }
  var screen_block_list_default = ScreenBlockList;

  // packages/global-styles-ui/build-module/screen-block.mjs
  var import_blocks18 = __toESM(require_blocks(), 1);
  var import_block_editor23 = __toESM(require_block_editor(), 1);
  var import_element152 = __toESM(require_element(), 1);
  var import_data68 = __toESM(require_data(), 1);
  var import_core_data41 = __toESM(require_core_data(), 1);
  var import_components107 = __toESM(require_components(), 1);
  var import_i18n144 = __toESM(require_i18n(), 1);

  // packages/global-styles-ui/build-module/block-preview-panel.mjs
  var import_block_editor22 = __toESM(require_block_editor(), 1);
  var import_blocks17 = __toESM(require_blocks(), 1);
  var import_components105 = __toESM(require_components(), 1);
  var import_element151 = __toESM(require_element(), 1);
  var import_jsx_runtime266 = __toESM(require_jsx_runtime(), 1);
  var BlockPreviewPanel = ({
    name: name2,
    variation = "",
    selectedState = "default",
    stateStyles
  }) => {
    const blockExample = (0, import_blocks17.getBlockType)(name2)?.example;
    const blocks = (0, import_element151.useMemo)(() => {
      if (!blockExample) {
        return null;
      }
      const example = {
        ...blockExample,
        attributes: {
          ...blockExample.attributes,
          style: void 0,
          className: variation ? getVariationClassName(variation) : blockExample.attributes?.className
        }
      };
      return (0, import_blocks17.getBlockFromExample)(name2, example);
    }, [name2, blockExample, variation]);
    const stateCSS = (0, import_element151.useMemo)(() => {
      if (selectedState === "default" || !stateStyles) {
        return "";
      }
      return generatePreviewStateStyles(stateStyles, name2);
    }, [selectedState, stateStyles, name2]);
    const viewportWidth = blockExample?.viewportWidth ?? 500;
    const previewHeight = 144;
    const sidebarWidth = 235;
    const scale3 = sidebarWidth / viewportWidth;
    const minHeight = scale3 !== 0 && scale3 < 1 && previewHeight ? previewHeight / scale3 : previewHeight;
    if (!blockExample) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(import_components105.__experimentalSpacer, { marginX: 4, marginBottom: 4, children: /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(
      "div",
      {
        className: "global-styles-ui__block-preview-panel",
        style: { maxHeight: previewHeight, boxSizing: "initial" },
        children: /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(
          import_block_editor22.BlockPreview,
          {
            blocks,
            viewportWidth,
            minHeight: previewHeight,
            additionalStyles: (
              //We want this CSS to be in sync with the one in InserterPreviewPanel.
              [
                {
                  css: `
								body{
									padding: 24px;
									min-height:${Math.round(minHeight)}px;
									display:flex;
									align-items:center;
								}
								.is-root-container { width: 100%; }
								${stateCSS}
							`
                }
              ]
            )
          }
        )
      }
    ) });
  };
  var block_preview_panel_default = BlockPreviewPanel;

  // packages/global-styles-ui/build-module/subtitle.mjs
  var import_components106 = __toESM(require_components(), 1);
  var import_jsx_runtime267 = __toESM(require_jsx_runtime(), 1);
  function Subtitle({ children, level = 2 }) {
    return /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(import_components106.__experimentalHeading, { className: "global-styles-ui-subtitle", level, children });
  }

  // packages/global-styles-ui/build-module/screen-block.mjs
  var import_jsx_runtime268 = __toESM(require_jsx_runtime(), 1);
  var BACKGROUND_BLOCK_DEFAULT_VALUES2 = {
    backgroundSize: "cover",
    backgroundPosition: "50% 50%"
    // used only when backgroundSize is 'contain'.
  };
  function applyFallbackStyle(border) {
    if (!border) {
      return border;
    }
    const hasColorOrWidth = border.color || border.width;
    if (!border.style && hasColorOrWidth) {
      return { ...border, style: "solid" };
    }
    if (border.style && !hasColorOrWidth) {
      return void 0;
    }
    return border;
  }
  function applyAllFallbackStyles(border) {
    if (!border) {
      return border;
    }
    if ((0, import_components107.__experimentalHasSplitBorders)(border)) {
      return {
        top: applyFallbackStyle(border.top),
        right: applyFallbackStyle(border.right),
        bottom: applyFallbackStyle(border.bottom),
        left: applyFallbackStyle(border.left)
      };
    }
    return applyFallbackStyle(border);
  }
  var {
    useHasDimensionsPanel: useHasDimensionsPanel3,
    useHasTypographyPanel: useHasTypographyPanel3,
    useHasBorderPanel: useHasBorderPanel2,
    useSettingsForBlockElement: useSettingsForBlockElement3,
    useHasColorPanel: useHasColorPanel3,
    useHasFiltersPanel,
    useHasImageSettingsPanel,
    useHasBackgroundPanel: useHasBackgroundPanel2,
    BackgroundPanel: StylesBackgroundPanel,
    BorderPanel: StylesBorderPanel,
    ColorPanel: StylesColorPanel,
    TypographyPanel: StylesTypographyPanel,
    DimensionsPanel: StylesDimensionsPanel,
    FiltersPanel: StylesFiltersPanel,
    ImageSettingsPanel,
    AdvancedPanel: StylesAdvancedPanel
  } = unlock5(import_block_editor23.privateApis);
  function ScreenBlock({ name: name2, variation }) {
    const { user: userConfig, onChange: onChangeGlobalStyles } = (0, import_element152.useContext)(GlobalStylesContext);
    let prefixParts = [];
    if (variation) {
      prefixParts = ["variations", variation].concat(prefixParts);
    }
    const prefix2 = prefixParts.join(".");
    const [selectedState, setSelectedState] = (0, import_element152.useState)("default");
    const validStates = (0, import_element152.useMemo)(() => getValidStates(name2), [name2]);
    const stateParam = selectedState !== "default" ? selectedState : void 0;
    const [style, setStyle2] = useStyle(
      prefix2,
      name2,
      "user",
      false,
      stateParam
    );
    const [inheritedStyle] = useStyle(
      prefix2,
      name2,
      "merged",
      false,
      stateParam
    );
    const [userSettings] = useSetting("", name2, "user");
    const [rawSettings, setSettings] = useSetting("", name2);
    const settingsForBlockElement = useSettingsForBlockElement3(
      rawSettings,
      name2
    );
    const blockType = (0, import_blocks18.getBlockType)(name2);
    let disableBlockGap = false;
    if (settingsForBlockElement?.spacing?.blockGap && blockType?.supports?.spacing?.blockGap && (blockType?.supports?.spacing?.__experimentalSkipSerialization === true || blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(
      (spacingType) => spacingType === "blockGap"
    ))) {
      disableBlockGap = true;
    }
    let disableAspectRatio = false;
    if (settingsForBlockElement?.dimensions?.aspectRatio && name2 === "core/group") {
      disableAspectRatio = true;
    }
    const settings = (0, import_element152.useMemo)(() => {
      const updatedSettings = structuredClone(settingsForBlockElement);
      if (disableBlockGap) {
        updatedSettings.spacing.blockGap = false;
      }
      if (disableAspectRatio) {
        updatedSettings.dimensions.aspectRatio = false;
      }
      return updatedSettings;
    }, [settingsForBlockElement, disableBlockGap, disableAspectRatio]);
    const blockVariations = useBlockVariations(name2);
    const hasBackgroundPanel = useHasBackgroundPanel2(settings);
    const hasTypographyPanel = useHasTypographyPanel3(settings);
    const hasColorPanel = useHasColorPanel3(settings);
    const hasBorderPanel = useHasBorderPanel2(settings);
    const hasDimensionsPanel = useHasDimensionsPanel3(settings);
    const hasFiltersPanel = useHasFiltersPanel(settings);
    const hasImageSettingsPanel = useHasImageSettingsPanel(
      name2,
      userSettings,
      settings
    );
    const hasVariationsPanel = !!blockVariations?.length && !variation;
    const { canEditCSS } = (0, import_data68.useSelect)((select7) => {
      const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select7(import_core_data41.store);
      const globalStylesId = __experimentalGetCurrentGlobalStylesId();
      const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0;
      return {
        canEditCSS: !!globalStyles?._links?.["wp:action-edit-css"]
      };
    }, []);
    const currentBlockStyle = variation ? blockVariations.find((s3) => s3.name === variation) : null;
    const inheritedStyleWithLayout = (0, import_element152.useMemo)(() => {
      return {
        ...inheritedStyle,
        layout: settings.layout
      };
    }, [inheritedStyle, settings.layout]);
    const styleWithLayout = (0, import_element152.useMemo)(() => {
      return {
        ...style,
        layout: userSettings.layout
      };
    }, [style, userSettings.layout]);
    const onChangeDimensions = (newStyle) => {
      const updatedStyle = { ...newStyle };
      delete updatedStyle.layout;
      setStyle2(updatedStyle);
      if (newStyle.layout !== userSettings.layout) {
        setSettings({
          ...userSettings,
          layout: newStyle.layout
        });
      }
    };
    const onChangeLightbox = (newSetting) => {
      if (newSetting === void 0) {
        setSettings({
          ...rawSettings,
          lightbox: void 0
        });
      } else {
        setSettings({
          ...rawSettings,
          lightbox: {
            ...rawSettings.lightbox,
            ...newSetting
          }
        });
      }
    };
    const onChangeTypography = (newStyle) => {
      const { settings: newSettings, ...styleWithoutSettings } = newStyle;
      if (newSettings?.typography) {
        let updatedConfig = setStyle(
          userConfig,
          prefix2,
          styleWithoutSettings,
          name2
        );
        updatedConfig = setSetting(
          updatedConfig,
          "typography",
          {
            ...userSettings.typography,
            ...newSettings.typography
          },
          name2
        );
        onChangeGlobalStyles(updatedConfig);
      } else {
        setStyle2(styleWithoutSettings);
      }
    };
    const onChangeBorders = (newStyle) => {
      if (!newStyle?.border) {
        setStyle2(newStyle);
        return;
      }
      const { radius, ...newBorder } = newStyle.border;
      const border = applyAllFallbackStyles(newBorder);
      const updatedBorder = !(0, import_components107.__experimentalHasSplitBorders)(border) ? {
        top: border,
        right: border,
        bottom: border,
        left: border
      } : {
        color: null,
        style: null,
        width: null,
        ...border
      };
      setStyle2({ ...newStyle, border: { ...updatedBorder, radius } });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime268.jsxs)(import_jsx_runtime268.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
        ScreenHeader,
        {
          title: variation ? currentBlockStyle?.label : blockType?.title,
          states: validStates,
          selectedState,
          onChangeState: setSelectedState
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
        block_preview_panel_default,
        {
          name: name2,
          variation,
          selectedState,
          stateStyles: selectedState !== "default" ? style : void 0
        }
      ),
      hasVariationsPanel && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)("div", { className: "global-styles-ui-screen-variations", children: /* @__PURE__ */ (0, import_jsx_runtime268.jsxs)(import_components107.__experimentalVStack, { spacing: 3, children: [
        /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(Subtitle, { children: (0, import_i18n144.__)("Style Variations") }),
        /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(VariationsPanel, { name: name2 })
      ] }) }),
      hasColorPanel && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
        StylesColorPanel,
        {
          inheritedValue: inheritedStyle,
          value: style,
          onChange: setStyle2,
          settings
        }
      ),
      hasBackgroundPanel && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
        StylesBackgroundPanel,
        {
          inheritedValue: inheritedStyle,
          value: style,
          onChange: setStyle2,
          settings,
          defaultValues: BACKGROUND_BLOCK_DEFAULT_VALUES2
        }
      ),
      hasTypographyPanel && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
        StylesTypographyPanel,
        {
          inheritedValue: inheritedStyle,
          value: style,
          onChange: onChangeTypography,
          settings,
          isGlobalStyles: true
        }
      ),
      hasDimensionsPanel && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
        StylesDimensionsPanel,
        {
          inheritedValue: inheritedStyleWithLayout,
          value: styleWithLayout,
          onChange: onChangeDimensions,
          settings,
          includeLayoutControls: true
        }
      ),
      hasBorderPanel && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
        StylesBorderPanel,
        {
          inheritedValue: inheritedStyle,
          value: style,
          onChange: onChangeBorders,
          settings
        }
      ),
      hasFiltersPanel && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
        StylesFiltersPanel,
        {
          inheritedValue: inheritedStyleWithLayout,
          value: styleWithLayout,
          onChange: setStyle2,
          settings,
          includeLayoutControls: true
        }
      ),
      hasImageSettingsPanel && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
        ImageSettingsPanel,
        {
          onChange: onChangeLightbox,
          value: userSettings,
          inheritedValue: settings
        }
      ),
      canEditCSS && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(import_components107.PanelBody, { title: (0, import_i18n144.__)("Advanced"), initialOpen: false, children: /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
        StylesAdvancedPanel,
        {
          value: style,
          onChange: setStyle2,
          inheritedValue: inheritedStyle,
          help: (0, import_i18n144.sprintf)(
            // translators: %s: is the name of a block e.g., 'Image' or 'Table'.
            (0, import_i18n144.__)(
              "Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value."
            ),
            blockType?.title
          )
        }
      ) })
    ] });
  }
  var screen_block_default = ScreenBlock;

  // packages/global-styles-ui/build-module/screen-typography.mjs
  var import_i18n158 = __toESM(require_i18n(), 1);
  var import_components127 = __toESM(require_components(), 1);
  var import_element163 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/screen-body.mjs
  var import_components108 = __toESM(require_components(), 1);
  var import_jsx_runtime269 = __toESM(require_jsx_runtime(), 1);
  function ScreenBody({ children, className }) {
    return /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(
      import_components108.__experimentalSpacer,
      {
        className: clsx_default("global-styles-ui-screen-body", className),
        padding: 4,
        children
      }
    );
  }

  // packages/global-styles-ui/build-module/typography-elements.mjs
  var import_i18n145 = __toESM(require_i18n(), 1);
  var import_components109 = __toESM(require_components(), 1);
  var import_jsx_runtime270 = __toESM(require_jsx_runtime(), 1);
  function ElementItem({ parentMenu, element, label }) {
    const prefix2 = element === "text" || !element ? "" : `elements.${element}.`;
    const extraStyles = element === "link" ? {
      textDecoration: "underline"
    } : {};
    const [fontFamily] = useStyle(
      prefix2 + "typography.fontFamily"
    );
    const [fontStyle] = useStyle(prefix2 + "typography.fontStyle");
    const [fontWeight] = useStyle(
      prefix2 + "typography.fontWeight"
    );
    const [backgroundColor] = useStyle(
      prefix2 + "color.background"
    );
    const [fallbackBackgroundColor] = useStyle("color.background");
    const [gradientValue] = useStyle(prefix2 + "color.gradient");
    const [color] = useStyle(prefix2 + "color.text");
    return /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(NavigationButtonAsItem, { path: parentMenu + "/typography/" + element, children: /* @__PURE__ */ (0, import_jsx_runtime270.jsxs)(import_components109.__experimentalHStack, { justify: "flex-start", children: [
      /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(
        import_components109.FlexItem,
        {
          className: "global-styles-ui-screen-typography__indicator",
          "aria-hidden": "true",
          style: {
            fontFamily: fontFamily ?? "serif",
            background: gradientValue ?? backgroundColor ?? fallbackBackgroundColor,
            color,
            fontStyle,
            fontWeight,
            ...extraStyles
          },
          children: (0, import_i18n145.__)("Aa")
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(import_components109.FlexItem, { children: label })
    ] }) });
  }
  function TypographyElements() {
    const parentMenu = "";
    return /* @__PURE__ */ (0, import_jsx_runtime270.jsxs)(import_components109.__experimentalVStack, { spacing: 3, children: [
      /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(Subtitle, { level: 3, children: (0, import_i18n145.__)("Elements") }),
      /* @__PURE__ */ (0, import_jsx_runtime270.jsxs)(import_components109.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: [
        /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(
          ElementItem,
          {
            parentMenu,
            element: "text",
            label: (0, import_i18n145.__)("Text")
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(
          ElementItem,
          {
            parentMenu,
            element: "link",
            label: (0, import_i18n145.__)("Links")
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(
          ElementItem,
          {
            parentMenu,
            element: "heading",
            label: (0, import_i18n145.__)("Headings")
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(
          ElementItem,
          {
            parentMenu,
            element: "caption",
            label: (0, import_i18n145.__)("Captions")
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(
          ElementItem,
          {
            parentMenu,
            element: "button",
            label: (0, import_i18n145.__)("Buttons")
          }
        )
      ] })
    ] });
  }
  var typography_elements_default = TypographyElements;

  // packages/global-styles-ui/build-module/variations/variations-typography.mjs
  var import_components112 = __toESM(require_components(), 1);

  // packages/global-styles-ui/build-module/preview-typography.mjs
  var import_components110 = __toESM(require_components(), 1);
  var import_jsx_runtime271 = __toESM(require_jsx_runtime(), 1);
  var StylesPreviewTypography = ({
    variation,
    isFocused,
    withHoverView
  }) => {
    return /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
      preview_wrapper_default,
      {
        label: variation.title,
        isFocused,
        withHoverView,
        children: ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
          import_components110.__experimentalHStack,
          {
            spacing: 10 * ratio,
            justify: "center",
            style: {
              height: "100%",
              overflow: "hidden"
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
              PreviewTypography,
              {
                variation,
                fontSize: 85 * ratio
              }
            )
          },
          key
        )
      }
    );
  };
  var preview_typography_default = StylesPreviewTypography;

  // packages/global-styles-ui/build-module/variations/variation.mjs
  var import_components111 = __toESM(require_components(), 1);
  var import_element153 = __toESM(require_element(), 1);
  var import_keycodes4 = __toESM(require_keycodes(), 1);
  var import_i18n146 = __toESM(require_i18n(), 1);
  var import_jsx_runtime272 = __toESM(require_jsx_runtime(), 1);
  function Variation({
    variation,
    children,
    isPill = false,
    properties,
    showTooltip = false
  }) {
    const [isFocused, setIsFocused] = (0, import_element153.useState)(false);
    const {
      base,
      user,
      onChange: setUserConfig
    } = (0, import_element153.useContext)(GlobalStylesContext);
    const context = (0, import_element153.useMemo)(() => {
      let merged = mergeGlobalStyles(base, variation);
      if (properties) {
        merged = filterObjectByProperties(merged, properties);
      }
      return {
        user: variation,
        base,
        merged,
        onChange: () => {
        }
      };
    }, [variation, base, properties]);
    const selectVariation = () => setUserConfig(variation);
    const selectOnEnter = (event) => {
      if (event.keyCode === import_keycodes4.ENTER) {
        event.preventDefault();
        selectVariation();
      }
    };
    const isActive = (0, import_element153.useMemo)(
      () => areGlobalStylesEqual(user, variation),
      [user, variation]
    );
    let label = variation?.title;
    if (variation?.description) {
      label = (0, import_i18n146.sprintf)(
        /* translators: 1: variation title. 2: variation description. */
        (0, import_i18n146._x)("%1$s (%2$s)", "variation label"),
        variation?.title,
        variation?.description
      );
    }
    const content = /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(
      "div",
      {
        className: clsx_default("global-styles-ui-variations_item", {
          "is-active": isActive
        }),
        role: "button",
        onClick: selectVariation,
        onKeyDown: selectOnEnter,
        tabIndex: 0,
        "aria-label": label,
        "aria-current": isActive,
        onFocus: () => setIsFocused(true),
        onBlur: () => setIsFocused(false),
        children: /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(
          "div",
          {
            className: clsx_default("global-styles-ui-variations_item-preview", {
              "is-pill": isPill
            }),
            children: children(isFocused)
          }
        )
      }
    );
    return /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(GlobalStylesContext.Provider, { value: context, children: showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(import_components111.Tooltip, { text: variation?.title, children: content }) : content });
  }

  // packages/global-styles-ui/build-module/variations/variations-typography.mjs
  var import_jsx_runtime273 = __toESM(require_jsx_runtime(), 1);
  var propertiesToFilter = ["typography"];
  function TypographyVariations({
    title,
    gap = 2
  }) {
    const typographyVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter);
    if (typographyVariations?.length <= 1) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime273.jsxs)(import_components112.__experimentalVStack, { spacing: 3, children: [
      title && /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(Subtitle, { level: 3, children: title }),
      /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
        import_components112.__experimentalGrid,
        {
          columns: 3,
          gap,
          className: "global-styles-ui-style-variations-container",
          children: typographyVariations.map(
            (variation, index) => {
              return /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
                Variation,
                {
                  variation,
                  properties: propertiesToFilter,
                  showTooltip: true,
                  children: () => /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
                    preview_typography_default,
                    {
                      variation
                    }
                  )
                },
                index
              );
            }
          )
        }
      )
    ] });
  }

  // packages/global-styles-ui/build-module/font-families.mjs
  var import_i18n156 = __toESM(require_i18n(), 1);
  var import_components125 = __toESM(require_components(), 1);
  var import_element162 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/font-library/context.mjs
  var import_element154 = __toESM(require_element(), 1);
  var import_data69 = __toESM(require_data(), 1);
  var import_core_data43 = __toESM(require_core_data(), 1);
  var import_i18n148 = __toESM(require_i18n(), 1);

  // packages/global-styles-ui/build-module/font-library/api.mjs
  var import_api_fetch5 = __toESM(require_api_fetch(), 1);
  var import_core_data42 = __toESM(require_core_data(), 1);
  var FONT_FAMILIES_URL = "/wp/v2/font-families";
  function invalidateFontFamilyCache(registry) {
    const { receiveEntityRecords } = registry.dispatch(import_core_data42.store);
    receiveEntityRecords(
      "postType",
      "wp_font_family",
      [],
      void 0,
      true
      // invalidateCache
    );
  }
  async function fetchInstallFontFamily(data, registry) {
    const config2 = {
      path: FONT_FAMILIES_URL,
      method: "POST",
      body: data
    };
    const response = await (0, import_api_fetch5.default)(config2);
    invalidateFontFamilyCache(registry);
    return {
      id: response.id,
      ...response.font_family_settings,
      fontFace: []
    };
  }
  async function fetchInstallFontFace(fontFamilyId, data, registry) {
    const config2 = {
      path: `${FONT_FAMILIES_URL}/${fontFamilyId}/font-faces`,
      method: "POST",
      body: data
    };
    const response = await (0, import_api_fetch5.default)(config2);
    invalidateFontFamilyCache(registry);
    return {
      id: response.id,
      ...response.font_face_settings
    };
  }

  // packages/global-styles-ui/build-module/font-library/utils/index.mjs
  var import_components113 = __toESM(require_components(), 1);

  // packages/global-styles-ui/build-module/font-library/utils/constants.mjs
  var import_i18n147 = __toESM(require_i18n(), 1);
  var ALLOWED_FILE_EXTENSIONS = ["otf", "ttf", "woff", "woff2"];
  var FONT_WEIGHTS = {
    100: (0, import_i18n147._x)("Thin", "font weight"),
    200: (0, import_i18n147._x)("Extra-light", "font weight"),
    300: (0, import_i18n147._x)("Light", "font weight"),
    400: (0, import_i18n147._x)("Normal", "font weight"),
    500: (0, import_i18n147._x)("Medium", "font weight"),
    600: (0, import_i18n147._x)("Semi-bold", "font weight"),
    700: (0, import_i18n147._x)("Bold", "font weight"),
    800: (0, import_i18n147._x)("Extra-bold", "font weight"),
    900: (0, import_i18n147._x)("Black", "font weight")
  };
  var FONT_STYLES = {
    normal: (0, import_i18n147._x)("Normal", "font style"),
    italic: (0, import_i18n147._x)("Italic", "font style")
  };

  // packages/global-styles-ui/build-module/font-library/utils/index.mjs
  var { File: File2 } = window;
  var { kebabCase: kebabCase3 } = unlock5(import_components113.privateApis);
  function setUIValuesNeeded(font2, extraValues = {}) {
    if (!font2.name && (font2.fontFamily || font2.slug)) {
      font2.name = font2.fontFamily || font2.slug;
    }
    return {
      ...font2,
      ...extraValues
    };
  }
  function isUrlEncoded(url) {
    if (typeof url !== "string") {
      return false;
    }
    return url !== decodeURIComponent(url);
  }
  function getFontFaceVariantName(face) {
    const weightName = FONT_WEIGHTS[face.fontWeight ?? ""] || face.fontWeight;
    const styleName = face.fontStyle === "normal" ? "" : FONT_STYLES[face.fontStyle ?? ""] || face.fontStyle;
    return `${weightName} ${styleName}`;
  }
  function mergeFontFaces(existing = [], incoming = []) {
    const map = /* @__PURE__ */ new Map();
    for (const face of existing) {
      map.set(`${face.fontWeight}${face.fontStyle}`, face);
    }
    for (const face of incoming) {
      map.set(`${face.fontWeight}${face.fontStyle}`, face);
    }
    return Array.from(map.values());
  }
  function mergeFontFamilies(existing = [], incoming = []) {
    const map = /* @__PURE__ */ new Map();
    for (const font2 of existing) {
      map.set(font2.slug, { ...font2 });
    }
    for (const font2 of incoming) {
      if (map.has(font2.slug)) {
        const { fontFace: incomingFontFaces, ...restIncoming } = font2;
        const existingFont = map.get(font2.slug);
        const mergedFontFaces = mergeFontFaces(
          existingFont.fontFace,
          incomingFontFaces
        );
        map.set(font2.slug, {
          ...restIncoming,
          fontFace: mergedFontFaces
        });
      } else {
        map.set(font2.slug, { ...font2 });
      }
    }
    return Array.from(map.values());
  }
  async function loadFontFaceInBrowser(fontFace, source, addTo = "all") {
    let dataSource;
    if (typeof source === "string") {
      dataSource = `url(${source})`;
    } else if (source instanceof File2) {
      dataSource = await source.arrayBuffer();
    } else {
      return;
    }
    const newFont = new window.FontFace(
      formatFontFaceName(fontFace.fontFamily),
      dataSource,
      {
        style: fontFace.fontStyle,
        weight: String(fontFace.fontWeight)
      }
    );
    const loadedFace = await newFont.load();
    if (addTo === "document" || addTo === "all") {
      document.fonts.add(loadedFace);
    }
    if (addTo === "iframe" || addTo === "all") {
      const iframe = document.querySelector(
        'iframe[name="editor-canvas"]'
      );
      if (iframe?.contentDocument) {
        iframe.contentDocument.fonts.add(loadedFace);
      }
    }
  }
  function unloadFontFaceInBrowser(fontFace, removeFrom = "all") {
    const unloadFontFace = (fonts) => {
      fonts.forEach((f3) => {
        if (f3.family === formatFontFaceName(fontFace?.fontFamily) && f3.weight === fontFace?.fontWeight && f3.style === fontFace?.fontStyle) {
          fonts.delete(f3);
        }
      });
    };
    if (removeFrom === "document" || removeFrom === "all") {
      unloadFontFace(document.fonts);
    }
    if (removeFrom === "iframe" || removeFrom === "all") {
      const iframe = document.querySelector(
        'iframe[name="editor-canvas"]'
      );
      if (iframe?.contentDocument) {
        unloadFontFace(iframe.contentDocument.fonts);
      }
    }
  }
  function getDisplaySrcFromFontFace(input) {
    if (!input) {
      return;
    }
    let src;
    if (Array.isArray(input)) {
      src = input[0];
    } else {
      src = input;
    }
    if (src.startsWith("file:.")) {
      return;
    }
    if (!isUrlEncoded(src)) {
      src = encodeURI(src);
    }
    return src;
  }
  function makeFontFamilyFormData(fontFamily) {
    const formData = new FormData();
    const { fontFace, category, ...familyWithValidParameters } = fontFamily;
    const fontFamilySettings = {
      ...familyWithValidParameters,
      slug: kebabCase3(fontFamily.slug)
    };
    formData.append(
      "font_family_settings",
      JSON.stringify(fontFamilySettings)
    );
    return formData;
  }
  function makeFontFacesFormData(font2) {
    const fontFacesFormData = (font2?.fontFace ?? []).map(
      (item, faceIndex) => {
        const face = { ...item };
        const formData = new FormData();
        if (face.file) {
          const files = Array.isArray(face.file) ? face.file : [face.file];
          const src = [];
          files.forEach((file, key) => {
            const fileId = `file-${faceIndex}-${key}`;
            formData.append(fileId, file, file.name);
            src.push(fileId);
          });
          face.src = src.length === 1 ? src[0] : src;
          delete face.file;
          formData.append("font_face_settings", JSON.stringify(face));
        } else {
          formData.append("font_face_settings", JSON.stringify(face));
        }
        return formData;
      }
    );
    return fontFacesFormData;
  }
  async function batchInstallFontFaces(fontFamilyId, fontFacesData, registry) {
    const responses = [];
    for (const faceData of fontFacesData) {
      try {
        const response = await fetchInstallFontFace(
          fontFamilyId,
          faceData,
          registry
        );
        responses.push({ status: "fulfilled", value: response });
      } catch (error2) {
        responses.push({ status: "rejected", reason: error2 });
      }
    }
    const results = {
      errors: [],
      successes: []
    };
    responses.forEach((result, index) => {
      if (result.status === "fulfilled" && result.value) {
        const response = result.value;
        results.successes.push(response);
      } else if (result.reason) {
        results.errors.push({
          data: fontFacesData[index],
          message: result.reason.message
        });
      }
    });
    return results;
  }
  async function downloadFontFaceAssets(src) {
    src = Array.isArray(src) ? src : [src];
    const files = await Promise.all(
      src.map(async (url) => {
        return fetch(new Request(url)).then((response) => {
          if (!response.ok) {
            throw new Error(
              `Error downloading font face asset from ${url}. Server responded with status: ${response.status}`
            );
          }
          return response.blob();
        }).then((blob) => {
          const filename = url.split("/").pop();
          const file = new File2([blob], filename, {
            type: blob.type
          });
          return file;
        });
      })
    );
    return files.length === 1 ? files[0] : files;
  }
  function checkFontFaceInstalled(fontFace, collection) {
    return -1 !== collection.findIndex((collectionFontFace) => {
      return collectionFontFace.fontWeight === fontFace.fontWeight && collectionFontFace.fontStyle === fontFace.fontStyle;
    });
  }

  // packages/global-styles-ui/build-module/font-library/utils/set-immutably.mjs
  function setImmutably2(object, path, value) {
    path = Array.isArray(path) ? [...path] : [path];
    object = Array.isArray(object) ? [...object] : { ...object };
    const leaf = path.pop();
    let prev = object;
    for (const key of path) {
      const lvl = prev[key];
      prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl };
    }
    prev[leaf] = value;
    return object;
  }

  // packages/global-styles-ui/build-module/font-library/utils/toggleFont.mjs
  function toggleFont(font2, face, initialfonts = []) {
    const isFontActivated = (f3) => f3.slug === font2.slug;
    const getActivatedFont = (fonts) => fonts.find(isFontActivated);
    const toggleEntireFontFamily = (activatedFont2) => {
      if (!activatedFont2) {
        return [...initialfonts, font2];
      }
      return initialfonts.filter(
        (f3) => !isFontActivated(f3)
      );
    };
    const toggleFontVariant = (activatedFont2) => {
      const isFaceActivated = (f3) => f3.fontWeight === face.fontWeight && f3.fontStyle === face.fontStyle;
      if (!activatedFont2) {
        return [...initialfonts, { ...font2, fontFace: [face] }];
      }
      let newFontFaces = activatedFont2.fontFace || [];
      if (newFontFaces.find(isFaceActivated)) {
        newFontFaces = newFontFaces.filter(
          (f3) => !isFaceActivated(f3)
        );
      } else {
        newFontFaces = [...newFontFaces, face];
      }
      if (newFontFaces.length === 0) {
        return initialfonts.filter(
          (f3) => !isFontActivated(f3)
        );
      }
      return initialfonts.map(
        (f3) => isFontActivated(f3) ? { ...f3, fontFace: newFontFaces } : f3
      );
    };
    const activatedFont = getActivatedFont(initialfonts);
    if (!face) {
      return toggleEntireFontFamily(activatedFont);
    }
    return toggleFontVariant(activatedFont);
  }

  // packages/global-styles-ui/build-module/font-library/context.mjs
  var import_jsx_runtime274 = __toESM(require_jsx_runtime(), 1);
  var FontLibraryContext = (0, import_element154.createContext)(
    {}
  );
  FontLibraryContext.displayName = "FontLibraryContext";
  function FontLibraryProvider({ children }) {
    const registry = (0, import_data69.useRegistry)();
    const { saveEntityRecord, deleteEntityRecord } = (0, import_data69.useDispatch)(import_core_data43.store);
    const { globalStylesId } = (0, import_data69.useSelect)((select7) => {
      const { __experimentalGetCurrentGlobalStylesId } = select7(import_core_data43.store);
      return { globalStylesId: __experimentalGetCurrentGlobalStylesId() };
    }, []);
    const globalStyles = (0, import_core_data43.useEntityRecord)(
      "root",
      "globalStyles",
      globalStylesId
    );
    const [isInstalling, setIsInstalling] = (0, import_element154.useState)(false);
    const { records: libraryPosts = [], isResolving: isResolvingLibrary } = (0, import_core_data43.useEntityRecords)(
      "postType",
      "wp_font_family",
      {
        _embed: true
      }
    );
    const libraryFonts = (libraryPosts || []).map((fontFamilyPost) => {
      return {
        id: fontFamilyPost.id,
        ...fontFamilyPost.font_family_settings || {},
        fontFace: fontFamilyPost?._embedded?.font_faces?.map(
          (face) => face.font_face_settings
        ) || []
      };
    }) || [];
    const [fontFamilies, setFontFamilies] = useSetting("typography.fontFamilies");
    const saveFontFamilies = async (fonts) => {
      if (!globalStyles.record) {
        return;
      }
      const updatedGlobalStyles = globalStyles.record;
      const finalGlobalStyles = setImmutably2(
        updatedGlobalStyles ?? {},
        ["settings", "typography", "fontFamilies"],
        fonts
      );
      await saveEntityRecord("root", "globalStyles", finalGlobalStyles);
    };
    const [modalTabOpen, setModalTabOpen] = (0, import_element154.useState)("");
    const [libraryFontSelected, setLibraryFontSelected] = (0, import_element154.useState)(void 0);
    const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map((f3) => setUIValuesNeeded(f3, { source: "theme" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : [];
    const customFonts = fontFamilies?.custom ? fontFamilies.custom.map((f3) => setUIValuesNeeded(f3, { source: "custom" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : [];
    const baseCustomFonts = libraryFonts ? libraryFonts.map((f3) => setUIValuesNeeded(f3, { source: "custom" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : [];
    (0, import_element154.useEffect)(() => {
      if (!modalTabOpen) {
        setLibraryFontSelected(void 0);
      }
    }, [modalTabOpen]);
    const handleSetLibraryFontSelected = (font2) => {
      if (!font2) {
        setLibraryFontSelected(void 0);
        return;
      }
      const fonts = font2.source === "theme" ? themeFonts : baseCustomFonts;
      const fontSelected = fonts.find((f3) => f3.slug === font2.slug);
      setLibraryFontSelected({
        ...fontSelected || font2,
        source: font2.source
      });
    };
    const [loadedFontUrls] = (0, import_element154.useState)(/* @__PURE__ */ new Set());
    const getAvailableFontsOutline = (availableFontFamilies) => {
      const outline = availableFontFamilies.reduce(
        (acc, font2) => {
          const availableFontFaces = font2?.fontFace && font2.fontFace?.length > 0 ? font2?.fontFace.map(
            (face) => `${face.fontStyle ?? ""}${face.fontWeight ?? ""}`
          ) : ["normal400"];
          acc[font2.slug] = availableFontFaces;
          return acc;
        },
        {}
      );
      return outline;
    };
    const getActivatedFontsOutline = (source) => {
      switch (source) {
        case "theme":
          return getAvailableFontsOutline(themeFonts);
        case "custom":
        default:
          return getAvailableFontsOutline(customFonts);
      }
    };
    const isFontActivated = (slug, style, weight, source) => {
      if (!style && !weight) {
        return !!getActivatedFontsOutline(source)[slug];
      }
      return !!getActivatedFontsOutline(source)[slug]?.includes(
        (style ?? "") + (weight ?? "")
      );
    };
    const getFontFacesActivated = (slug, source) => {
      return getActivatedFontsOutline(source)[slug] || [];
    };
    async function installFonts(fontFamiliesToInstall) {
      setIsInstalling(true);
      try {
        const fontFamiliesToActivate = [];
        let installationErrors = [];
        for (const fontFamilyToInstall of fontFamiliesToInstall) {
          let isANewFontFamily = false;
          const fontFamilyRecords = await (0, import_data69.resolveSelect)(
            import_core_data43.store
          ).getEntityRecords(
            "postType",
            "wp_font_family",
            {
              slug: fontFamilyToInstall.slug,
              per_page: 1,
              _embed: true
            }
          );
          const fontFamilyPost = fontFamilyRecords && fontFamilyRecords.length > 0 ? fontFamilyRecords[0] : null;
          let installedFontFamily = fontFamilyPost ? {
            id: fontFamilyPost.id,
            ...fontFamilyPost.font_family_settings,
            fontFace: (fontFamilyPost?._embedded?.font_faces ?? []).map(
              (face) => face.font_face_settings
            ) || []
          } : null;
          if (!installedFontFamily) {
            isANewFontFamily = true;
            installedFontFamily = await fetchInstallFontFamily(
              makeFontFamilyFormData(fontFamilyToInstall),
              registry
            );
          }
          const alreadyInstalledFontFaces = installedFontFamily.fontFace && fontFamilyToInstall.fontFace ? installedFontFamily.fontFace.filter(
            (fontFaceToInstall) => fontFaceToInstall && fontFamilyToInstall.fontFace && checkFontFaceInstalled(
              fontFaceToInstall,
              fontFamilyToInstall.fontFace
            )
          ) : [];
          if (installedFontFamily.fontFace && fontFamilyToInstall.fontFace) {
            fontFamilyToInstall.fontFace = fontFamilyToInstall.fontFace.filter(
              (fontFaceToInstall) => !checkFontFaceInstalled(
                fontFaceToInstall,
                installedFontFamily.fontFace
              )
            );
          }
          let successfullyInstalledFontFaces = [];
          let unsuccessfullyInstalledFontFaces = [];
          if (fontFamilyToInstall?.fontFace?.length ?? 0 > 0) {
            const response = await batchInstallFontFaces(
              // @ts-expect-error - Type mismatch: WpFontFamily.id can be number | string, but batchInstallFontFaces expects only string.
              installedFontFamily.id,
              makeFontFacesFormData(
                fontFamilyToInstall
              ),
              registry
            );
            successfullyInstalledFontFaces = response?.successes;
            unsuccessfullyInstalledFontFaces = response?.errors;
          }
          if (successfullyInstalledFontFaces?.length > 0 || alreadyInstalledFontFaces?.length > 0) {
            installedFontFamily.fontFace = [
              ...successfullyInstalledFontFaces
            ];
            fontFamiliesToActivate.push(installedFontFamily);
          }
          if (installedFontFamily && !fontFamilyToInstall?.fontFace?.length) {
            fontFamiliesToActivate.push(installedFontFamily);
          }
          if (isANewFontFamily && (fontFamilyToInstall?.fontFace?.length ?? 0) > 0 && successfullyInstalledFontFaces?.length === 0) {
            await deleteEntityRecord(
              "postType",
              "wp_font_family",
              installedFontFamily.id,
              { force: true }
            );
          }
          installationErrors = installationErrors.concat(
            unsuccessfullyInstalledFontFaces
          );
        }
        const installationErrorMessages = installationErrors.reduce(
          (unique, item) => unique.includes(item.message) ? unique : [...unique, item.message],
          []
        );
        if (fontFamiliesToActivate.length > 0) {
          const activeFonts = activateCustomFontFamilies(
            // @ts-expect-error - Type mismatch: items may have id as number | string, but FontFamily.id should be string | undefined.
            fontFamiliesToActivate
          );
          await saveFontFamilies(activeFonts);
        }
        if (installationErrorMessages.length > 0) {
          const installError = new Error((0, import_i18n148.__)("There was an error installing fonts."));
          installError.installationErrors = installationErrorMessages;
          throw installError;
        }
      } finally {
        setIsInstalling(false);
      }
    }
    async function uninstallFontFamily(fontFamilyToUninstall) {
      if (!fontFamilyToUninstall?.id) {
        throw new Error((0, import_i18n148.__)("Font family to uninstall is not defined."));
      }
      try {
        await deleteEntityRecord(
          "postType",
          "wp_font_family",
          fontFamilyToUninstall.id,
          { force: true }
        );
        const activeFonts = deactivateFontFamily(fontFamilyToUninstall);
        await saveFontFamilies(activeFonts);
        return { deleted: true };
      } catch (error2) {
        console.error(
          `There was an error uninstalling the font family:`,
          error2
        );
        throw error2;
      }
    }
    const deactivateFontFamily = (font2) => {
      const initialCustomFonts = fontFamilies?.[font2.source ?? ""] ?? [];
      const newCustomFonts = initialCustomFonts.filter(
        (f3) => f3.slug !== font2.slug
      );
      const activeFonts = {
        ...fontFamilies,
        [font2.source ?? ""]: newCustomFonts
      };
      setFontFamilies(activeFonts);
      if (font2.fontFace) {
        font2.fontFace.forEach((face) => {
          unloadFontFaceInBrowser(face, "all");
        });
      }
      return activeFonts;
    };
    const activateCustomFontFamilies = (fontsToAdd) => {
      const fontsToActivate = cleanFontsForSave(fontsToAdd);
      const activeFonts = {
        ...fontFamilies,
        // Merge the existing custom fonts with the new fonts.
        custom: mergeFontFamilies(fontFamilies?.custom, fontsToActivate)
      };
      setFontFamilies(activeFonts);
      loadFontsInBrowser(fontsToActivate);
      return activeFonts;
    };
    const cleanFontsForSave = (fonts) => {
      return fonts.map(({ id: _familyDbId, fontFace, ...font2 }) => ({
        ...font2,
        ...fontFace && fontFace.length > 0 ? {
          fontFace: fontFace.map(
            ({ id: _faceDbId, ...face }) => face
          )
        } : {}
      }));
    };
    const loadFontsInBrowser = (fonts) => {
      fonts.forEach((font2) => {
        if (font2.fontFace) {
          font2.fontFace.forEach((face) => {
            const displaySrc = getDisplaySrcFromFontFace(
              face?.src ?? ""
            );
            if (displaySrc) {
              loadFontFaceInBrowser(face, displaySrc, "all");
            }
          });
        }
      });
    };
    const toggleActivateFont = (font2, face) => {
      const initialFonts = fontFamilies?.[font2.source ?? ""] ?? [];
      const newFonts = toggleFont(font2, face, initialFonts);
      setFontFamilies({
        ...fontFamilies,
        [font2.source ?? ""]: newFonts
      });
      const isFaceActivated = isFontActivated(
        font2.slug,
        face?.fontStyle ?? "",
        face?.fontWeight ?? "",
        font2.source ?? "custom"
      );
      if (face && isFaceActivated) {
        unloadFontFaceInBrowser(face, "all");
      } else {
        const displaySrc = getDisplaySrcFromFontFace(face?.src ?? "");
        if (face && displaySrc) {
          loadFontFaceInBrowser(face, displaySrc, "all");
        }
      }
    };
    const loadFontFaceAsset = async (fontFace) => {
      if (!fontFace.src) {
        return;
      }
      const src = getDisplaySrcFromFontFace(fontFace.src);
      if (!src || loadedFontUrls.has(src)) {
        return;
      }
      loadFontFaceInBrowser(fontFace, src, "document");
      loadedFontUrls.add(src);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(
      FontLibraryContext.Provider,
      {
        value: {
          libraryFontSelected,
          handleSetLibraryFontSelected,
          fontFamilies: fontFamilies ?? {},
          baseCustomFonts,
          isFontActivated,
          getFontFacesActivated,
          loadFontFaceAsset,
          installFonts,
          uninstallFontFamily,
          toggleActivateFont,
          getAvailableFontsOutline,
          modalTabOpen,
          setModalTabOpen,
          saveFontFamilies,
          isResolvingLibrary,
          isInstalling
        },
        children
      }
    );
  }
  var context_default = FontLibraryProvider;

  // packages/global-styles-ui/build-module/font-library/modal.mjs
  var import_i18n154 = __toESM(require_i18n(), 1);
  var import_components123 = __toESM(require_components(), 1);
  var import_core_data46 = __toESM(require_core_data(), 1);
  var import_data71 = __toESM(require_data(), 1);

  // packages/global-styles-ui/build-module/font-library/installed-fonts.mjs
  var import_components117 = __toESM(require_components(), 1);
  var import_core_data44 = __toESM(require_core_data(), 1);
  var import_data70 = __toESM(require_data(), 1);
  var import_element157 = __toESM(require_element(), 1);
  var import_i18n150 = __toESM(require_i18n(), 1);

  // packages/global-styles-ui/build-module/font-library/font-card.mjs
  var import_i18n149 = __toESM(require_i18n(), 1);
  var import_components115 = __toESM(require_components(), 1);

  // packages/global-styles-ui/build-module/font-library/font-demo.mjs
  var import_components114 = __toESM(require_components(), 1);
  var import_element155 = __toESM(require_element(), 1);
  var import_jsx_runtime275 = __toESM(require_jsx_runtime(), 1);
  function getPreviewUrl(fontFace) {
    if (fontFace.preview) {
      return fontFace.preview;
    }
    if (fontFace.src) {
      return Array.isArray(fontFace.src) ? fontFace.src[0] : fontFace.src;
    }
    return void 0;
  }
  function getDisplayFontFace(font2) {
    if ("fontStyle" in font2 && font2.fontStyle || "fontWeight" in font2 && font2.fontWeight) {
      return font2;
    }
    if ("fontFace" in font2 && font2.fontFace && font2.fontFace.length) {
      return font2.fontFace.find(
        (face) => face.fontStyle === "normal" && face.fontWeight === "400"
      ) || font2.fontFace[0];
    }
    return {
      fontStyle: "normal",
      fontWeight: "400",
      fontFamily: font2.fontFamily
    };
  }
  function FontDemo({ font: font2, text }) {
    const ref = (0, import_element155.useRef)(null);
    const fontFace = getDisplayFontFace(font2);
    const style = getFamilyPreviewStyle(font2);
    text = text || ("name" in font2 ? font2.name : "");
    const customPreviewUrl = font2.preview;
    const [isIntersecting, setIsIntersecting] = (0, import_element155.useState)(false);
    const [isAssetLoaded, setIsAssetLoaded] = (0, import_element155.useState)(false);
    const { loadFontFaceAsset } = (0, import_element155.useContext)(FontLibraryContext);
    const previewUrl = customPreviewUrl ?? getPreviewUrl(fontFace);
    const isPreviewImage = previewUrl && previewUrl.match(/\.(png|jpg|jpeg|gif|svg)$/i);
    const faceStyles = getFacePreviewStyle(fontFace);
    const textDemoStyle = {
      fontSize: "18px",
      lineHeight: 1,
      opacity: isAssetLoaded ? "1" : "0",
      ...style,
      ...faceStyles
    };
    (0, import_element155.useEffect)(() => {
      const observer = new window.IntersectionObserver(([entry]) => {
        setIsIntersecting(entry.isIntersecting);
      }, {});
      if (ref.current) {
        observer.observe(ref.current);
      }
      return () => observer.disconnect();
    }, [ref]);
    (0, import_element155.useEffect)(() => {
      const loadAsset = async () => {
        if (isIntersecting) {
          if (!isPreviewImage && fontFace.src) {
            await loadFontFaceAsset(fontFace);
          }
          setIsAssetLoaded(true);
        }
      };
      loadAsset();
    }, [fontFace, isIntersecting, loadFontFaceAsset, isPreviewImage]);
    return /* @__PURE__ */ (0, import_jsx_runtime275.jsx)("div", { ref, children: isPreviewImage ? /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(
      "img",
      {
        src: previewUrl,
        loading: "lazy",
        alt: text,
        className: "font-library__font-variant_demo-image"
      }
    ) : /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(
      import_components114.__experimentalText,
      {
        style: textDemoStyle,
        className: "font-library__font-variant_demo-text",
        children: text
      }
    ) });
  }
  var font_demo_default = FontDemo;

  // packages/global-styles-ui/build-module/font-library/font-card.mjs
  var import_jsx_runtime276 = __toESM(require_jsx_runtime(), 1);
  function FontCard({
    font: font2,
    onClick,
    variantsText,
    navigatorPath
  }) {
    const variantsCount = font2.fontFace?.length || 1;
    const style = {
      cursor: !!onClick ? "pointer" : "default"
    };
    const navigator2 = (0, import_components115.useNavigator)();
    return /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(
      import_components115.Button,
      {
        __next40pxDefaultSize: true,
        onClick: () => {
          onClick();
          if (navigatorPath) {
            navigator2.goTo(navigatorPath);
          }
        },
        style,
        className: "font-library__font-card",
        children: /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)(import_components115.Flex, { justify: "space-between", wrap: false, children: [
          /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(font_demo_default, { font: font2 }),
          /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)(import_components115.Flex, { justify: "flex-end", children: [
            /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(import_components115.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(import_components115.__experimentalText, { className: "font-library__font-card__count", children: variantsText || (0, import_i18n149.sprintf)(
              /* translators: %d: Number of font variants. */
              (0, import_i18n149._n)(
                "%d variant",
                "%d variants",
                variantsCount
              ),
              variantsCount
            ) }) }),
            /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(import_components115.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(icon_default, { icon: (0, import_i18n149.isRTL)() ? chevron_left_default : chevron_right_default }) })
          ] })
        ] })
      }
    );
  }
  var font_card_default = FontCard;

  // packages/global-styles-ui/build-module/font-library/library-font-variant.mjs
  var import_element156 = __toESM(require_element(), 1);
  var import_components116 = __toESM(require_components(), 1);
  var import_jsx_runtime277 = __toESM(require_jsx_runtime(), 1);
  function LibraryFontVariant({
    face,
    font: font2
  }) {
    const { isFontActivated, toggleActivateFont } = (0, import_element156.useContext)(FontLibraryContext);
    const isInstalled = (font2?.fontFace?.length ?? 0) > 0 ? isFontActivated(
      font2.slug,
      face.fontStyle,
      face.fontWeight,
      font2.source
    ) : isFontActivated(font2.slug, void 0, void 0, font2.source);
    const handleToggleActivation = () => {
      if ((font2?.fontFace?.length ?? 0) > 0) {
        toggleActivateFont(font2, face);
        return;
      }
      toggleActivateFont(font2);
    };
    const displayName = font2.name + " " + getFontFaceVariantName(face);
    const checkboxId = (0, import_element156.useId)();
    return /* @__PURE__ */ (0, import_jsx_runtime277.jsx)("div", { className: "font-library__font-card", children: /* @__PURE__ */ (0, import_jsx_runtime277.jsxs)(import_components116.Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [
      /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(
        import_components116.CheckboxControl,
        {
          checked: isInstalled,
          onChange: handleToggleActivation,
          id: checkboxId
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime277.jsx)("label", { htmlFor: checkboxId, children: /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(
        font_demo_default,
        {
          font: face,
          text: displayName,
          onClick: handleToggleActivation
        }
      ) })
    ] }) });
  }
  var library_font_variant_default = LibraryFontVariant;

  // packages/global-styles-ui/build-module/font-library/utils/sort-font-faces.mjs
  function getNumericFontWeight(value) {
    switch (value) {
      case "normal":
        return 400;
      case "bold":
        return 700;
      case "bolder":
        return 500;
      case "lighter":
        return 300;
      default:
        return parseInt(value, 10);
    }
  }
  function sortFontFaces(faces) {
    return faces.sort((a3, b3) => {
      if (a3.fontStyle === "normal" && b3.fontStyle !== "normal") {
        return -1;
      }
      if (b3.fontStyle === "normal" && a3.fontStyle !== "normal") {
        return 1;
      }
      if (a3.fontStyle === b3.fontStyle) {
        return getNumericFontWeight(a3.fontWeight?.toString() ?? "normal") - getNumericFontWeight(b3.fontWeight?.toString() ?? "normal");
      }
      if (!a3.fontStyle || !b3.fontStyle) {
        return !a3.fontStyle ? 1 : -1;
      }
      return a3.fontStyle.localeCompare(b3.fontStyle);
    });
  }

  // packages/global-styles-ui/build-module/font-library/installed-fonts.mjs
  var import_jsx_runtime278 = __toESM(require_jsx_runtime(), 1);
  function InstalledFonts() {
    const {
      baseCustomFonts,
      libraryFontSelected,
      handleSetLibraryFontSelected,
      uninstallFontFamily,
      isResolvingLibrary,
      isInstalling,
      saveFontFamilies,
      getFontFacesActivated
    } = (0, import_element157.useContext)(FontLibraryContext);
    const [fontFamilies, setFontFamilies] = useSetting("typography.fontFamilies");
    const [isConfirmDeleteOpen, setIsConfirmDeleteOpen] = (0, import_element157.useState)(false);
    const [notice, setNotice] = (0, import_element157.useState)(null);
    const [baseFontFamilies] = useSetting("typography.fontFamilies", void 0, "base");
    const globalStylesId = (0, import_data70.useSelect)((select7) => {
      const { __experimentalGetCurrentGlobalStylesId } = select7(import_core_data44.store);
      return __experimentalGetCurrentGlobalStylesId();
    }, []);
    const globalStyles = (0, import_core_data44.useEntityRecord)(
      "root",
      "globalStyles",
      globalStylesId
    );
    const fontFamiliesHasChanges = !!globalStyles?.edits?.settings?.typography?.fontFamilies;
    const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map((f3) => setUIValuesNeeded(f3, { source: "theme" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : [];
    const themeFontsSlugs = new Set(themeFonts.map((f3) => f3.slug));
    const baseThemeFonts = baseFontFamilies?.theme ? themeFonts.concat(
      baseFontFamilies.theme.filter((f3) => !themeFontsSlugs.has(f3.slug)).map((f3) => setUIValuesNeeded(f3, { source: "theme" })).sort((a3, b3) => a3.name.localeCompare(b3.name))
    ) : [];
    const customFontFamilyId = libraryFontSelected?.source === "custom" && libraryFontSelected?.id;
    const canUserDelete = (0, import_data70.useSelect)(
      (select7) => {
        const { canUser } = select7(import_core_data44.store);
        return customFontFamilyId && canUser("delete", {
          kind: "postType",
          name: "wp_font_family",
          id: customFontFamilyId
        });
      },
      [customFontFamilyId]
    );
    const shouldDisplayDeleteButton = !!libraryFontSelected && libraryFontSelected?.source !== "theme" && canUserDelete;
    const handleUninstallClick = () => {
      setIsConfirmDeleteOpen(true);
    };
    const handleUpdate = async () => {
      setNotice(null);
      try {
        await saveFontFamilies(fontFamilies);
        setNotice({
          type: "success",
          message: (0, import_i18n150.__)("Font family updated successfully.")
        });
      } catch (error2) {
        setNotice({
          type: "error",
          message: (0, import_i18n150.sprintf)(
            /* translators: %s: error message */
            (0, import_i18n150.__)("There was an error updating the font family. %s"),
            error2.message
          )
        });
      }
    };
    const getFontFacesToDisplay = (font2) => {
      if (!font2) {
        return [];
      }
      if (!font2.fontFace || !font2.fontFace.length) {
        return [
          {
            fontFamily: font2.fontFamily,
            fontStyle: "normal",
            fontWeight: "400"
          }
        ];
      }
      return sortFontFaces(font2.fontFace);
    };
    const getFontCardVariantsText = (font2) => {
      const variantsInstalled = font2?.fontFace && (font2?.fontFace?.length ?? 0) > 0 ? font2.fontFace.length : 1;
      const variantsActive = getFontFacesActivated(
        font2.slug,
        font2.source
      ).length;
      return (0, import_i18n150.sprintf)(
        /* translators: 1: Active font variants, 2: Total font variants. */
        (0, import_i18n150.__)("%1$d/%2$d variants active"),
        variantsActive,
        variantsInstalled
      );
    };
    (0, import_element157.useEffect)(() => {
      handleSetLibraryFontSelected(libraryFontSelected);
    }, []);
    const activeFontsCount = libraryFontSelected ? getFontFacesActivated(
      libraryFontSelected.slug,
      libraryFontSelected.source
    ).length : 0;
    const selectedFontsCount = libraryFontSelected?.fontFace?.length ?? (libraryFontSelected?.fontFamily ? 1 : 0);
    const isIndeterminate = activeFontsCount > 0 && activeFontsCount !== selectedFontsCount;
    const isSelectAllChecked = activeFontsCount === selectedFontsCount;
    const toggleSelectAll = () => {
      if (!libraryFontSelected || !libraryFontSelected?.source) {
        return;
      }
      const initialFonts = fontFamilies?.[libraryFontSelected.source]?.filter(
        (f3) => f3.slug !== libraryFontSelected.slug
      ) ?? [];
      const newFonts = isSelectAllChecked ? initialFonts : [...initialFonts, libraryFontSelected];
      setFontFamilies({
        ...fontFamilies,
        [libraryFontSelected.source]: newFonts
      });
      if (libraryFontSelected.fontFace) {
        libraryFontSelected.fontFace.forEach((face) => {
          if (isSelectAllChecked) {
            unloadFontFaceInBrowser(face, "all");
          } else {
            const displaySrc = getDisplaySrcFromFontFace(
              face?.src ?? ""
            );
            if (displaySrc) {
              loadFontFaceInBrowser(face, displaySrc, "all");
            }
          }
        });
      }
    };
    const hasFonts = baseThemeFonts.length > 0 || baseCustomFonts.length > 0;
    return /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
      isResolvingLibrary && /* @__PURE__ */ (0, import_jsx_runtime278.jsx)("div", { className: "font-library__loading", children: /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components117.ProgressBar, {}) }),
      !isResolvingLibrary && /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_jsx_runtime278.Fragment, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(
          import_components117.Navigator,
          {
            initialPath: libraryFontSelected ? "/fontFamily" : "/",
            children: [
              /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components117.Navigator.Screen, { path: "/", children: /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_components117.__experimentalVStack, { spacing: "8", children: [
                notice && /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                  import_components117.Notice,
                  {
                    status: notice.type,
                    onRemove: () => setNotice(null),
                    children: notice.message
                  }
                ),
                !hasFonts && /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components117.__experimentalText, { as: "p", children: (0, import_i18n150.__)("No fonts installed.") }),
                baseThemeFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_components117.__experimentalVStack, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)("h2", {
                    className: "font-library__fonts-title",
                    /* translators: Heading for a list of fonts provided by the theme. */
                    children: (0, import_i18n150._x)("Theme", "font source")
                  }),
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                    "ul",
                    {
                      role: "list",
                      className: "font-library__fonts-list",
                      children: baseThemeFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                        "li",
                        {
                          className: "font-library__fonts-list-item",
                          children: /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                            font_card_default,
                            {
                              font: font2,
                              navigatorPath: "/fontFamily",
                              variantsText: getFontCardVariantsText(
                                font2
                              ),
                              onClick: () => {
                                setNotice(null);
                                handleSetLibraryFontSelected(
                                  font2
                                );
                              }
                            }
                          )
                        },
                        font2.slug
                      ))
                    }
                  )
                ] }),
                baseCustomFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_components117.__experimentalVStack, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)("h2", {
                    className: "font-library__fonts-title",
                    /* translators: Heading for a list of fonts installed by the user. */
                    children: (0, import_i18n150._x)("Custom", "font source")
                  }),
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                    "ul",
                    {
                      role: "list",
                      className: "font-library__fonts-list",
                      children: baseCustomFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                        "li",
                        {
                          className: "font-library__fonts-list-item",
                          children: /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                            font_card_default,
                            {
                              font: font2,
                              navigatorPath: "/fontFamily",
                              variantsText: getFontCardVariantsText(
                                font2
                              ),
                              onClick: () => {
                                setNotice(null);
                                handleSetLibraryFontSelected(
                                  font2
                                );
                              }
                            }
                          )
                        },
                        font2.slug
                      ))
                    }
                  )
                ] })
              ] }) }),
              /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_components117.Navigator.Screen, { path: "/fontFamily", children: [
                libraryFontSelected && /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                  ConfirmDeleteDialog,
                  {
                    font: libraryFontSelected,
                    isOpen: isConfirmDeleteOpen,
                    setIsOpen: setIsConfirmDeleteOpen,
                    setNotice,
                    uninstallFontFamily,
                    handleSetLibraryFontSelected
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_components117.Flex, { justify: "flex-start", children: [
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                    import_components117.Navigator.BackButton,
                    {
                      icon: (0, import_i18n150.isRTL)() ? chevron_right_default : chevron_left_default,
                      size: "small",
                      onClick: () => {
                        handleSetLibraryFontSelected(
                          void 0
                        );
                        setNotice(null);
                      },
                      label: (0, import_i18n150.__)("Back")
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                    import_components117.__experimentalHeading,
                    {
                      level: 2,
                      size: 13,
                      className: "global-styles-ui-header",
                      children: libraryFontSelected?.name
                    }
                  )
                ] }),
                notice && /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_jsx_runtime278.Fragment, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components117.__experimentalSpacer, { margin: 1 }),
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                    import_components117.Notice,
                    {
                      status: notice.type,
                      onRemove: () => setNotice(null),
                      children: notice.message
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components117.__experimentalSpacer, { margin: 1 })
                ] }),
                /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components117.__experimentalSpacer, { margin: 4 }),
                /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components117.__experimentalText, { children: (0, import_i18n150.__)(
                  "Choose font variants. Keep in mind that too many variants could make your site slower."
                ) }),
                /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components117.__experimentalSpacer, { margin: 4 }),
                /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_components117.__experimentalVStack, { spacing: 0, children: [
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                    import_components117.CheckboxControl,
                    {
                      className: "font-library__select-all",
                      label: (0, import_i18n150.__)("Select all"),
                      checked: isSelectAllChecked,
                      onChange: toggleSelectAll,
                      indeterminate: isIndeterminate
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components117.__experimentalSpacer, { margin: 8 }),
                  /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                    "ul",
                    {
                      role: "list",
                      className: "font-library__fonts-list",
                      children: libraryFontSelected && getFontFacesToDisplay(
                        libraryFontSelected
                      ).map((face, i3) => /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                        "li",
                        {
                          className: "font-library__fonts-list-item",
                          children: /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
                            library_font_variant_default,
                            {
                              font: libraryFontSelected,
                              face
                            },
                            `face${i3}`
                          )
                        },
                        `face${i3}`
                      ))
                    }
                  )
                ] })
              ] })
            ]
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_components117.__experimentalHStack, { justify: "flex-end", className: "font-library__footer", children: [
          isInstalling && /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components117.ProgressBar, {}),
          shouldDisplayDeleteButton && /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
            import_components117.Button,
            {
              __next40pxDefaultSize: true,
              isDestructive: true,
              variant: "tertiary",
              onClick: handleUninstallClick,
              children: (0, import_i18n150.__)("Delete")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
            import_components117.Button,
            {
              __next40pxDefaultSize: true,
              variant: "primary",
              onClick: handleUpdate,
              disabled: !fontFamiliesHasChanges,
              accessibleWhenDisabled: true,
              children: (0, import_i18n150.__)("Update")
            }
          )
        ] })
      ] })
    ] });
  }
  function ConfirmDeleteDialog({
    font: font2,
    isOpen: isOpen2,
    setIsOpen,
    setNotice,
    uninstallFontFamily,
    handleSetLibraryFontSelected
  }) {
    const navigator2 = (0, import_components117.useNavigator)();
    const handleConfirmUninstall = async () => {
      setNotice(null);
      setIsOpen(false);
      try {
        await uninstallFontFamily(font2);
        navigator2.goBack();
        handleSetLibraryFontSelected(void 0);
        setNotice({
          type: "success",
          message: (0, import_i18n150.__)("Font family uninstalled successfully.")
        });
      } catch (error2) {
        setNotice({
          type: "error",
          message: (0, import_i18n150.__)("There was an error uninstalling the font family.") + error2.message
        });
      }
    };
    const handleCancelUninstall = () => {
      setIsOpen(false);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
      import_components117.__experimentalConfirmDialog,
      {
        isOpen: isOpen2,
        cancelButtonText: (0, import_i18n150.__)("Cancel"),
        confirmButtonText: (0, import_i18n150.__)("Delete"),
        onCancel: handleCancelUninstall,
        onConfirm: handleConfirmUninstall,
        size: "medium",
        children: font2 && (0, import_i18n150.sprintf)(
          /* translators: %s: Name of the font. */
          (0, import_i18n150.__)(
            'Are you sure you want to delete "%s" font and all its variants and assets?'
          ),
          font2.name
        )
      }
    );
  }
  var installed_fonts_default = InstalledFonts;

  // packages/global-styles-ui/build-module/font-library/font-collection.mjs
  var import_element159 = __toESM(require_element(), 1);
  var import_components120 = __toESM(require_components(), 1);
  var import_compose26 = __toESM(require_compose(), 1);
  var import_i18n152 = __toESM(require_i18n(), 1);
  var import_core_data45 = __toESM(require_core_data(), 1);

  // packages/global-styles-ui/build-module/font-library/utils/filter-fonts.mjs
  function filterFonts(fonts, filters) {
    const { category, search } = filters;
    let filteredFonts = fonts || [];
    if (category && category !== "all") {
      filteredFonts = filteredFonts.filter(
        (font2) => font2.categories && font2.categories.indexOf(category) !== -1
      );
    }
    if (search) {
      filteredFonts = filteredFonts.filter(
        (font2) => font2.font_family_settings && font2.font_family_settings.name.toLowerCase().includes(search.toLowerCase())
      );
    }
    return filteredFonts;
  }

  // packages/global-styles-ui/build-module/font-library/utils/fonts-outline.mjs
  function getFontsOutline(fonts) {
    return fonts.reduce(
      (acc, font2) => ({
        ...acc,
        [font2.slug]: (font2?.fontFace || []).reduce(
          (faces, face) => ({
            ...faces,
            [`${face.fontStyle}-${face.fontWeight}`]: true
          }),
          {}
        )
      }),
      {}
    );
  }
  function isFontFontFaceInOutline(slug, face, outline) {
    if (!face) {
      return !!outline[slug];
    }
    return !!outline[slug]?.[`${face.fontStyle}-${face.fontWeight}`];
  }

  // packages/global-styles-ui/build-module/font-library/google-fonts-confirm-dialog.mjs
  var import_i18n151 = __toESM(require_i18n(), 1);
  var import_components118 = __toESM(require_components(), 1);
  var import_jsx_runtime279 = __toESM(require_jsx_runtime(), 1);
  function GoogleFontsConfirmDialog() {
    const handleConfirm = () => {
      window.localStorage.setItem(
        "wp-font-library-google-fonts-permission",
        "true"
      );
      window.dispatchEvent(new Event("storage"));
    };
    return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)("div", { className: "font-library__google-fonts-confirm", children: /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_components118.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(import_components118.CardBody, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_components118.__experimentalHeading, { level: 2, children: (0, import_i18n151.__)("Connect to Google Fonts") }),
      /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_components118.__experimentalSpacer, { margin: 6 }),
      /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_components118.__experimentalText, { as: "p", children: (0, import_i18n151.__)(
        "To install fonts from Google you must give permission to connect directly to Google servers. The fonts you install will be downloaded from Google and stored on your site. Your site will then use these locally-hosted fonts."
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_components118.__experimentalSpacer, { margin: 3 }),
      /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_components118.__experimentalText, { as: "p", children: (0, import_i18n151.__)(
        "You can alternatively upload files directly on the Upload tab."
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_components118.__experimentalSpacer, { margin: 6 }),
      /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
        import_components118.Button,
        {
          __next40pxDefaultSize: true,
          variant: "primary",
          onClick: handleConfirm,
          children: (0, import_i18n151.__)("Allow access to Google Fonts")
        }
      )
    ] }) }) });
  }
  var google_fonts_confirm_dialog_default = GoogleFontsConfirmDialog;

  // packages/global-styles-ui/build-module/font-library/collection-font-variant.mjs
  var import_element158 = __toESM(require_element(), 1);
  var import_components119 = __toESM(require_components(), 1);
  var import_jsx_runtime280 = __toESM(require_jsx_runtime(), 1);
  function CollectionFontVariant({
    face,
    font: font2,
    handleToggleVariant,
    selected
  }) {
    const handleToggleActivation = () => {
      if (font2?.fontFace) {
        handleToggleVariant(font2, face);
        return;
      }
      handleToggleVariant(font2);
    };
    const displayName = font2.name + " " + getFontFaceVariantName(face);
    const checkboxId = (0, import_element158.useId)();
    return /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("div", { className: "font-library__font-card", children: /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(import_components119.Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [
      /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
        import_components119.CheckboxControl,
        {
          checked: selected,
          onChange: handleToggleActivation,
          id: checkboxId
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("label", { htmlFor: checkboxId, children: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
        font_demo_default,
        {
          font: face,
          text: displayName,
          onClick: handleToggleActivation
        }
      ) })
    ] }) });
  }
  var collection_font_variant_default = CollectionFontVariant;

  // packages/global-styles-ui/build-module/font-library/font-collection.mjs
  var import_jsx_runtime281 = __toESM(require_jsx_runtime(), 1);
  var DEFAULT_CATEGORY = {
    slug: "all",
    name: (0, import_i18n152._x)("All", "font categories")
  };
  var LOCAL_STORAGE_ITEM = "wp-font-library-google-fonts-permission";
  var MIN_WINDOW_HEIGHT = 500;
  function FontCollection({ slug }) {
    const requiresPermission = slug === "google-fonts";
    const getGoogleFontsPermissionFromStorage = () => {
      return window.localStorage.getItem(LOCAL_STORAGE_ITEM) === "true";
    };
    const [selectedFont, setSelectedFont] = (0, import_element159.useState)(
      null
    );
    const [notice, setNotice] = (0, import_element159.useState)(null);
    const [fontsToInstall, setFontsToInstall] = (0, import_element159.useState)(
      []
    );
    const [page, setPage] = (0, import_element159.useState)(1);
    const [filters, setFilters] = (0, import_element159.useState)({});
    const [renderConfirmDialog, setRenderConfirmDialog] = (0, import_element159.useState)(
      requiresPermission && !getGoogleFontsPermissionFromStorage()
    );
    const { installFonts, isInstalling } = (0, import_element159.useContext)(FontLibraryContext);
    const { record: selectedCollection, isResolving: isLoading } = (0, import_core_data45.useEntityRecord)("root", "fontCollection", slug);
    (0, import_element159.useEffect)(() => {
      const handleStorage = () => {
        setRenderConfirmDialog(
          requiresPermission && !getGoogleFontsPermissionFromStorage()
        );
      };
      handleStorage();
      window.addEventListener("storage", handleStorage);
      return () => window.removeEventListener("storage", handleStorage);
    }, [slug, requiresPermission]);
    const revokeAccess = () => {
      window.localStorage.setItem(LOCAL_STORAGE_ITEM, "false");
      window.dispatchEvent(new Event("storage"));
    };
    (0, import_element159.useEffect)(() => {
      setSelectedFont(null);
    }, [slug]);
    (0, import_element159.useEffect)(() => {
      setFontsToInstall([]);
    }, [selectedFont]);
    const collectionFonts = (0, import_element159.useMemo)(
      () => selectedCollection?.font_families ?? [],
      [selectedCollection]
    );
    const collectionCategories = selectedCollection?.categories ?? [];
    const categories = [DEFAULT_CATEGORY, ...collectionCategories];
    const fonts = (0, import_element159.useMemo)(
      () => filterFonts(collectionFonts, filters),
      [collectionFonts, filters]
    );
    const windowHeight = Math.max(window.innerHeight, MIN_WINDOW_HEIGHT);
    const pageSize = Math.floor((windowHeight - 417) / 61);
    const totalPages = Math.ceil(fonts.length / pageSize);
    const itemsStart = (page - 1) * pageSize;
    const itemsLimit = page * pageSize;
    const items = fonts.slice(itemsStart, itemsLimit);
    const handleCategoryFilter = (category) => {
      setFilters({ ...filters, category });
      setPage(1);
    };
    const handleUpdateSearchInput = (value) => {
      setFilters({ ...filters, search: value });
      setPage(1);
    };
    const debouncedUpdateSearchInput = (0, import_compose26.debounce)(handleUpdateSearchInput, 300);
    const handleToggleVariant = (font2, face) => {
      const newFontsToInstall = toggleFont(font2, face, fontsToInstall);
      setFontsToInstall(newFontsToInstall);
    };
    const fontToInstallOutline = getFontsOutline(fontsToInstall);
    const resetFontsToInstall = () => {
      setFontsToInstall([]);
    };
    const selectFontCount = fontsToInstall.length > 0 ? fontsToInstall[0]?.fontFace?.length ?? 0 : 0;
    const isIndeterminate = selectFontCount > 0 && selectFontCount !== selectedFont?.fontFace?.length;
    const isSelectAllChecked = selectFontCount === selectedFont?.fontFace?.length;
    const toggleSelectAll = () => {
      const newFonts = [];
      if (!isSelectAllChecked && selectedFont) {
        newFonts.push(selectedFont);
      }
      setFontsToInstall(newFonts);
    };
    const handleInstall = async () => {
      setNotice(null);
      const fontFamily = fontsToInstall[0];
      try {
        if (fontFamily?.fontFace) {
          await Promise.all(
            fontFamily.fontFace.map(async (fontFace) => {
              if (fontFace.src) {
                fontFace.file = await downloadFontFaceAssets(
                  fontFace.src
                );
              }
            })
          );
        }
      } catch {
        setNotice({
          type: "error",
          message: (0, import_i18n152.__)(
            "Error installing the fonts, could not be downloaded."
          )
        });
        return;
      }
      try {
        await installFonts([fontFamily]);
        setNotice({
          type: "success",
          message: (0, import_i18n152.__)("Fonts were installed successfully.")
        });
      } catch (error2) {
        setNotice({
          type: "error",
          message: error2.message
        });
      }
      resetFontsToInstall();
    };
    const getSortedFontFaces = (fontFamily) => {
      if (!fontFamily) {
        return [];
      }
      if (!fontFamily.fontFace || !fontFamily.fontFace.length) {
        return [
          {
            fontFamily: fontFamily.fontFamily,
            fontStyle: "normal",
            fontWeight: "400"
          }
        ];
      }
      return sortFontFaces(fontFamily.fontFace);
    };
    if (renderConfirmDialog) {
      return /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(google_fonts_confirm_dialog_default, {});
    }
    const ActionsComponent = () => {
      if (slug !== "google-fonts" || renderConfirmDialog || selectedFont) {
        return null;
      }
      return /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
        import_components120.DropdownMenu,
        {
          icon: more_vertical_default,
          label: (0, import_i18n152.__)("Actions"),
          popoverProps: {
            position: "bottom left"
          },
          controls: [
            {
              title: (0, import_i18n152.__)("Revoke access to Google Fonts"),
              onClick: revokeAccess
            }
          ]
        }
      );
    };
    return /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
      isLoading && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)("div", { className: "font-library__loading", children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.ProgressBar, {}) }),
      !isLoading && selectedCollection && /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_jsx_runtime281.Fragment, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(
          import_components120.Navigator,
          {
            initialPath: "/",
            className: "font-library__tabpanel-layout",
            children: [
              /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_components120.Navigator.Screen, { path: "/", children: [
                /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_components120.__experimentalHStack, { justify: "space-between", children: [
                  /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_components120.__experimentalVStack, { children: [
                    /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalHeading, { level: 2, size: 13, children: selectedCollection.name }),
                    /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalText, { children: selectedCollection.description })
                  ] }),
                  /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(ActionsComponent, {})
                ] }),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalSpacer, { margin: 4 }),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_components120.__experimentalHStack, { spacing: 4, justify: "space-between", children: [
                  /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                    import_components120.SearchControl,
                    {
                      value: filters.search,
                      placeholder: (0, import_i18n152.__)("Font name\u2026"),
                      label: (0, import_i18n152.__)("Search"),
                      onChange: debouncedUpdateSearchInput,
                      hideLabelFromVision: false
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                    import_components120.SelectControl,
                    {
                      __next40pxDefaultSize: true,
                      label: (0, import_i18n152.__)("Category"),
                      value: filters.category,
                      onChange: handleCategoryFilter,
                      children: categories && categories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                        "option",
                        {
                          value: category.slug,
                          children: category.name
                        },
                        category.slug
                      ))
                    }
                  )
                ] }),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalSpacer, { margin: 4 }),
                !!selectedCollection?.font_families?.length && !fonts.length && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalText, { children: (0, import_i18n152.__)(
                  "No fonts found. Try with a different search term."
                ) }),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)("div", { className: "font-library__fonts-grid__main", children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                  "ul",
                  {
                    role: "list",
                    className: "font-library__fonts-list",
                    children: items.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                      "li",
                      {
                        className: "font-library__fonts-list-item",
                        children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                          font_card_default,
                          {
                            font: font2.font_family_settings,
                            navigatorPath: "/fontFamily",
                            onClick: () => {
                              setSelectedFont(
                                font2.font_family_settings
                              );
                            }
                          }
                        )
                      },
                      font2.font_family_settings.slug
                    ))
                  }
                ) })
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_components120.Navigator.Screen, { path: "/fontFamily", children: [
                /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_components120.Flex, { justify: "flex-start", children: [
                  /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                    import_components120.Navigator.BackButton,
                    {
                      icon: (0, import_i18n152.isRTL)() ? chevron_right_default : chevron_left_default,
                      size: "small",
                      onClick: () => {
                        setSelectedFont(null);
                        setNotice(null);
                      },
                      label: (0, import_i18n152.__)("Back")
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                    import_components120.__experimentalHeading,
                    {
                      level: 2,
                      size: 13,
                      className: "global-styles-ui-header",
                      children: selectedFont?.name
                    }
                  )
                ] }),
                notice && /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_jsx_runtime281.Fragment, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalSpacer, { margin: 1 }),
                  /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                    import_components120.Notice,
                    {
                      status: notice.type,
                      onRemove: () => setNotice(null),
                      children: notice.message
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalSpacer, { margin: 1 })
                ] }),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalSpacer, { margin: 4 }),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalText, { children: (0, import_i18n152.__)("Select font variants to install.") }),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalSpacer, { margin: 4 }),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                  import_components120.CheckboxControl,
                  {
                    className: "font-library__select-all",
                    label: (0, import_i18n152.__)("Select all"),
                    checked: isSelectAllChecked,
                    onChange: toggleSelectAll,
                    indeterminate: isIndeterminate
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalVStack, { spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                  "ul",
                  {
                    role: "list",
                    className: "font-library__fonts-list",
                    children: selectedFont && getSortedFontFaces(selectedFont).map(
                      (face, i3) => /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                        "li",
                        {
                          className: "font-library__fonts-list-item",
                          children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                            collection_font_variant_default,
                            {
                              font: selectedFont,
                              face,
                              handleToggleVariant,
                              selected: isFontFontFaceInOutline(
                                selectedFont.slug,
                                selectedFont.fontFace ? face : null,
                                // If the font has no fontFace, we want to check if the font is in the outline
                                fontToInstallOutline
                              )
                            }
                          )
                        },
                        `face${i3}`
                      )
                    )
                  }
                ) }),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components120.__experimentalSpacer, { margin: 16 })
              ] })
            ]
          }
        ),
        selectedFont && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
          import_components120.Flex,
          {
            justify: "flex-end",
            className: "font-library__footer",
            children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
              import_components120.Button,
              {
                __next40pxDefaultSize: true,
                variant: "primary",
                onClick: handleInstall,
                isBusy: isInstalling,
                disabled: fontsToInstall.length === 0 || isInstalling,
                accessibleWhenDisabled: true,
                children: (0, import_i18n152.__)("Install")
              }
            )
          }
        ),
        !selectedFont && /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(
          import_components120.__experimentalHStack,
          {
            expanded: false,
            className: "font-library__footer",
            justify: "end",
            spacing: 6,
            children: [
              /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                import_components120.__experimentalHStack,
                {
                  justify: "flex-start",
                  expanded: false,
                  spacing: 1,
                  className: "font-library__page-selection",
                  children: (0, import_element159.createInterpolateElement)(
                    (0, import_i18n152.sprintf)(
                      // translators: 1: Current page number, 2: Total number of pages.
                      (0, import_i18n152._x)(
                        "<div>Page</div>%1$s<div>of %2$d</div>",
                        "paging"
                      ),
                      "<CurrentPage />",
                      totalPages
                    ),
                    {
                      div: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)("div", { "aria-hidden": true }),
                      // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
                      CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                        import_components120.SelectControl,
                        {
                          "aria-label": (0, import_i18n152.__)(
                            "Current page"
                          ),
                          value: page.toString(),
                          options: [
                            ...Array(totalPages)
                          ].map((e3, i3) => {
                            return {
                              label: (i3 + 1).toString(),
                              value: (i3 + 1).toString()
                            };
                          }),
                          onChange: (newPage) => setPage(
                            parseInt(newPage)
                          ),
                          size: "small",
                          variant: "minimal"
                        }
                      )
                    }
                  )
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_components120.__experimentalHStack, { expanded: false, spacing: 1, children: [
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                  import_components120.Button,
                  {
                    onClick: () => setPage(page - 1),
                    disabled: page === 1,
                    accessibleWhenDisabled: true,
                    label: (0, import_i18n152.__)("Previous page"),
                    icon: (0, import_i18n152.isRTL)() ? next_default : previous_default,
                    showTooltip: true,
                    size: "compact",
                    tooltipPosition: "top"
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
                  import_components120.Button,
                  {
                    onClick: () => setPage(page + 1),
                    disabled: page === totalPages,
                    accessibleWhenDisabled: true,
                    label: (0, import_i18n152.__)("Next page"),
                    icon: (0, import_i18n152.isRTL)() ? previous_default : next_default,
                    showTooltip: true,
                    size: "compact",
                    tooltipPosition: "top"
                  }
                )
              ] })
            ]
          }
        )
      ] })
    ] });
  }
  var font_collection_default = FontCollection;

  // packages/global-styles-ui/build-module/font-library/upload-fonts.mjs
  var import_i18n153 = __toESM(require_i18n(), 1);
  var import_components122 = __toESM(require_components(), 1);
  var import_element160 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/font-library/lib/unbrotli.mjs
  var __require2 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, {
    get: (a3, b3) => (typeof __require !== "undefined" ? __require : a3)[b3]
  }) : x2)(function(x2) {
    if (typeof __require !== "undefined") return __require.apply(this, arguments);
    throw Error('Dynamic require of "' + x2 + '" is not supported');
  });
  var unbrotli_default = (function() {
    var define2, module, exports;
    return (/* @__PURE__ */ (function() {
      function r4(e3, n3, t4) {
        function o4(i22, f3) {
          if (!n3[i22]) {
            if (!e3[i22]) {
              var c6 = "function" == typeof __require2 && __require2;
              if (!f3 && c6) return c6(i22, true);
              if (u3) return u3(i22, true);
              var a3 = new Error("Cannot find module '" + i22 + "'");
              throw a3.code = "MODULE_NOT_FOUND", a3;
            }
            var p4 = n3[i22] = { exports: {} };
            e3[i22][0].call(
              p4.exports,
              function(r22) {
                var n22 = e3[i22][1][r22];
                return o4(n22 || r22);
              },
              p4,
              p4.exports,
              r4,
              e3,
              n3,
              t4
            );
          }
          return n3[i22].exports;
        }
        for (var u3 = "function" == typeof __require2 && __require2, i3 = 0; i3 < t4.length; i3++)
          o4(t4[i3]);
        return o4;
      }
      return r4;
    })())(
      {
        1: [
          function(require2, module2, exports2) {
            var BROTLI_READ_SIZE = 4096;
            var BROTLI_IBUF_SIZE = 2 * BROTLI_READ_SIZE + 32;
            var BROTLI_IBUF_MASK = 2 * BROTLI_READ_SIZE - 1;
            var kBitMask = new Uint32Array([
              0,
              1,
              3,
              7,
              15,
              31,
              63,
              127,
              255,
              511,
              1023,
              2047,
              4095,
              8191,
              16383,
              32767,
              65535,
              131071,
              262143,
              524287,
              1048575,
              2097151,
              4194303,
              8388607,
              16777215
            ]);
            function BrotliBitReader(input) {
              this.buf_ = new Uint8Array(BROTLI_IBUF_SIZE);
              this.input_ = input;
              this.reset();
            }
            BrotliBitReader.READ_SIZE = BROTLI_READ_SIZE;
            BrotliBitReader.IBUF_MASK = BROTLI_IBUF_MASK;
            BrotliBitReader.prototype.reset = function() {
              this.buf_ptr_ = 0;
              this.val_ = 0;
              this.pos_ = 0;
              this.bit_pos_ = 0;
              this.bit_end_pos_ = 0;
              this.eos_ = 0;
              this.readMoreInput();
              for (var i3 = 0; i3 < 4; i3++) {
                this.val_ |= this.buf_[this.pos_] << 8 * i3;
                ++this.pos_;
              }
              return this.bit_end_pos_ > 0;
            };
            BrotliBitReader.prototype.readMoreInput = function() {
              if (this.bit_end_pos_ > 256) {
                return;
              } else if (this.eos_) {
                if (this.bit_pos_ > this.bit_end_pos_)
                  throw new Error(
                    "Unexpected end of input " + this.bit_pos_ + " " + this.bit_end_pos_
                  );
              } else {
                var dst = this.buf_ptr_;
                var bytes_read = this.input_.read(
                  this.buf_,
                  dst,
                  BROTLI_READ_SIZE
                );
                if (bytes_read < 0) {
                  throw new Error("Unexpected end of input");
                }
                if (bytes_read < BROTLI_READ_SIZE) {
                  this.eos_ = 1;
                  for (var p4 = 0; p4 < 32; p4++)
                    this.buf_[dst + bytes_read + p4] = 0;
                }
                if (dst === 0) {
                  for (var p4 = 0; p4 < 32; p4++)
                    this.buf_[(BROTLI_READ_SIZE << 1) + p4] = this.buf_[p4];
                  this.buf_ptr_ = BROTLI_READ_SIZE;
                } else {
                  this.buf_ptr_ = 0;
                }
                this.bit_end_pos_ += bytes_read << 3;
              }
            };
            BrotliBitReader.prototype.fillBitWindow = function() {
              while (this.bit_pos_ >= 8) {
                this.val_ >>>= 8;
                this.val_ |= this.buf_[this.pos_ & BROTLI_IBUF_MASK] << 24;
                ++this.pos_;
                this.bit_pos_ = this.bit_pos_ - 8 >>> 0;
                this.bit_end_pos_ = this.bit_end_pos_ - 8 >>> 0;
              }
            };
            BrotliBitReader.prototype.readBits = function(n_bits) {
              if (32 - this.bit_pos_ < n_bits) {
                this.fillBitWindow();
              }
              var val = this.val_ >>> this.bit_pos_ & kBitMask[n_bits];
              this.bit_pos_ += n_bits;
              return val;
            };
            module2.exports = BrotliBitReader;
          },
          {}
        ],
        2: [
          function(require2, module2, exports2) {
            var CONTEXT_LSB6 = 0;
            var CONTEXT_MSB6 = 1;
            var CONTEXT_UTF8 = 2;
            var CONTEXT_SIGNED = 3;
            exports2.lookup = new Uint8Array([
              /* CONTEXT_UTF8, last byte. */
              /* ASCII range. */
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              4,
              4,
              0,
              0,
              4,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              8,
              12,
              16,
              12,
              12,
              20,
              12,
              16,
              24,
              28,
              12,
              12,
              32,
              12,
              36,
              12,
              44,
              44,
              44,
              44,
              44,
              44,
              44,
              44,
              44,
              44,
              32,
              32,
              24,
              40,
              28,
              12,
              12,
              48,
              52,
              52,
              52,
              48,
              52,
              52,
              52,
              48,
              52,
              52,
              52,
              52,
              52,
              48,
              52,
              52,
              52,
              52,
              52,
              48,
              52,
              52,
              52,
              52,
              52,
              24,
              12,
              28,
              12,
              12,
              12,
              56,
              60,
              60,
              60,
              56,
              60,
              60,
              60,
              56,
              60,
              60,
              60,
              60,
              60,
              56,
              60,
              60,
              60,
              60,
              60,
              56,
              60,
              60,
              60,
              60,
              60,
              24,
              12,
              28,
              12,
              0,
              /* UTF8 continuation byte range. */
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              0,
              1,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              2,
              3,
              /* ASCII range. */
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              1,
              1,
              1,
              1,
              1,
              1,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              1,
              1,
              1,
              1,
              0,
              /* UTF8 continuation byte range. */
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              0,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              2,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              3,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              4,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              5,
              6,
              6,
              6,
              6,
              6,
              6,
              6,
              6,
              6,
              6,
              6,
              6,
              6,
              6,
              6,
              7,
              /* CONTEXT_SIGNED, last byte, same as the above values shifted by 3 bits. */
              0,
              8,
              8,
              8,
              8,
              8,
              8,
              8,
              8,
              8,
              8,
              8,
              8,
              8,
              8,
              8,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              24,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              32,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              40,
              48,
              48,
              48,
              48,
              48,
              48,
              48,
              48,
              48,
              48,
              48,
              48,
              48,
              48,
              48,
              56,
              /* CONTEXT_LSB6, last byte. */
              0,
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25,
              26,
              27,
              28,
              29,
              30,
              31,
              32,
              33,
              34,
              35,
              36,
              37,
              38,
              39,
              40,
              41,
              42,
              43,
              44,
              45,
              46,
              47,
              48,
              49,
              50,
              51,
              52,
              53,
              54,
              55,
              56,
              57,
              58,
              59,
              60,
              61,
              62,
              63,
              0,
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25,
              26,
              27,
              28,
              29,
              30,
              31,
              32,
              33,
              34,
              35,
              36,
              37,
              38,
              39,
              40,
              41,
              42,
              43,
              44,
              45,
              46,
              47,
              48,
              49,
              50,
              51,
              52,
              53,
              54,
              55,
              56,
              57,
              58,
              59,
              60,
              61,
              62,
              63,
              0,
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25,
              26,
              27,
              28,
              29,
              30,
              31,
              32,
              33,
              34,
              35,
              36,
              37,
              38,
              39,
              40,
              41,
              42,
              43,
              44,
              45,
              46,
              47,
              48,
              49,
              50,
              51,
              52,
              53,
              54,
              55,
              56,
              57,
              58,
              59,
              60,
              61,
              62,
              63,
              0,
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25,
              26,
              27,
              28,
              29,
              30,
              31,
              32,
              33,
              34,
              35,
              36,
              37,
              38,
              39,
              40,
              41,
              42,
              43,
              44,
              45,
              46,
              47,
              48,
              49,
              50,
              51,
              52,
              53,
              54,
              55,
              56,
              57,
              58,
              59,
              60,
              61,
              62,
              63,
              /* CONTEXT_MSB6, last byte. */
              0,
              0,
              0,
              0,
              1,
              1,
              1,
              1,
              2,
              2,
              2,
              2,
              3,
              3,
              3,
              3,
              4,
              4,
              4,
              4,
              5,
              5,
              5,
              5,
              6,
              6,
              6,
              6,
              7,
              7,
              7,
              7,
              8,
              8,
              8,
              8,
              9,
              9,
              9,
              9,
              10,
              10,
              10,
              10,
              11,
              11,
              11,
              11,
              12,
              12,
              12,
              12,
              13,
              13,
              13,
              13,
              14,
              14,
              14,
              14,
              15,
              15,
              15,
              15,
              16,
              16,
              16,
              16,
              17,
              17,
              17,
              17,
              18,
              18,
              18,
              18,
              19,
              19,
              19,
              19,
              20,
              20,
              20,
              20,
              21,
              21,
              21,
              21,
              22,
              22,
              22,
              22,
              23,
              23,
              23,
              23,
              24,
              24,
              24,
              24,
              25,
              25,
              25,
              25,
              26,
              26,
              26,
              26,
              27,
              27,
              27,
              27,
              28,
              28,
              28,
              28,
              29,
              29,
              29,
              29,
              30,
              30,
              30,
              30,
              31,
              31,
              31,
              31,
              32,
              32,
              32,
              32,
              33,
              33,
              33,
              33,
              34,
              34,
              34,
              34,
              35,
              35,
              35,
              35,
              36,
              36,
              36,
              36,
              37,
              37,
              37,
              37,
              38,
              38,
              38,
              38,
              39,
              39,
              39,
              39,
              40,
              40,
              40,
              40,
              41,
              41,
              41,
              41,
              42,
              42,
              42,
              42,
              43,
              43,
              43,
              43,
              44,
              44,
              44,
              44,
              45,
              45,
              45,
              45,
              46,
              46,
              46,
              46,
              47,
              47,
              47,
              47,
              48,
              48,
              48,
              48,
              49,
              49,
              49,
              49,
              50,
              50,
              50,
              50,
              51,
              51,
              51,
              51,
              52,
              52,
              52,
              52,
              53,
              53,
              53,
              53,
              54,
              54,
              54,
              54,
              55,
              55,
              55,
              55,
              56,
              56,
              56,
              56,
              57,
              57,
              57,
              57,
              58,
              58,
              58,
              58,
              59,
              59,
              59,
              59,
              60,
              60,
              60,
              60,
              61,
              61,
              61,
              61,
              62,
              62,
              62,
              62,
              63,
              63,
              63,
              63,
              /* CONTEXT_{M,L}SB6, second last byte, */
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0
            ]);
            exports2.lookupOffsets = new Uint16Array([
              /* CONTEXT_LSB6 */
              1024,
              1536,
              1280,
              1536,
              0,
              256,
              768,
              512
            ]);
          },
          {}
        ],
        3: [
          function(require2, module2, exports2) {
            var BrotliInput = require2("./streams").BrotliInput;
            var BrotliOutput = require2("./streams").BrotliOutput;
            var BrotliBitReader = require2("./bit_reader");
            var BrotliDictionary = require2("./dictionary");
            var HuffmanCode = require2("./huffman").HuffmanCode;
            var BrotliBuildHuffmanTable = require2("./huffman").BrotliBuildHuffmanTable;
            var Context = require2("./context");
            var Prefix = require2("./prefix");
            var Transform = require2("./transform");
            var kDefaultCodeLength = 8;
            var kCodeLengthRepeatCode = 16;
            var kNumLiteralCodes = 256;
            var kNumInsertAndCopyCodes = 704;
            var kNumBlockLengthCodes = 26;
            var kLiteralContextBits = 6;
            var kDistanceContextBits = 2;
            var HUFFMAN_TABLE_BITS = 8;
            var HUFFMAN_TABLE_MASK = 255;
            var HUFFMAN_MAX_TABLE_SIZE = 1080;
            var CODE_LENGTH_CODES = 18;
            var kCodeLengthCodeOrder = new Uint8Array([
              1,
              2,
              3,
              4,
              0,
              5,
              17,
              6,
              16,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15
            ]);
            var NUM_DISTANCE_SHORT_CODES = 16;
            var kDistanceShortCodeIndexOffset = new Uint8Array([
              3,
              2,
              1,
              0,
              3,
              3,
              3,
              3,
              3,
              3,
              2,
              2,
              2,
              2,
              2,
              2
            ]);
            var kDistanceShortCodeValueOffset = new Int8Array([
              0,
              0,
              0,
              0,
              -1,
              1,
              -2,
              2,
              -3,
              3,
              -1,
              1,
              -2,
              2,
              -3,
              3
            ]);
            var kMaxHuffmanTableSize = new Uint16Array([
              256,
              402,
              436,
              468,
              500,
              534,
              566,
              598,
              630,
              662,
              694,
              726,
              758,
              790,
              822,
              854,
              886,
              920,
              952,
              984,
              1016,
              1048,
              1080
            ]);
            function DecodeWindowBits(br) {
              var n3;
              if (br.readBits(1) === 0) {
                return 16;
              }
              n3 = br.readBits(3);
              if (n3 > 0) {
                return 17 + n3;
              }
              n3 = br.readBits(3);
              if (n3 > 0) {
                return 8 + n3;
              }
              return 17;
            }
            function DecodeVarLenUint8(br) {
              if (br.readBits(1)) {
                var nbits = br.readBits(3);
                if (nbits === 0) {
                  return 1;
                } else {
                  return br.readBits(nbits) + (1 << nbits);
                }
              }
              return 0;
            }
            function MetaBlockLength() {
              this.meta_block_length = 0;
              this.input_end = 0;
              this.is_uncompressed = 0;
              this.is_metadata = false;
            }
            function DecodeMetaBlockLength(br) {
              var out = new MetaBlockLength();
              var size_nibbles;
              var size_bytes;
              var i3;
              out.input_end = br.readBits(1);
              if (out.input_end && br.readBits(1)) {
                return out;
              }
              size_nibbles = br.readBits(2) + 4;
              if (size_nibbles === 7) {
                out.is_metadata = true;
                if (br.readBits(1) !== 0)
                  throw new Error("Invalid reserved bit");
                size_bytes = br.readBits(2);
                if (size_bytes === 0) return out;
                for (i3 = 0; i3 < size_bytes; i3++) {
                  var next_byte = br.readBits(8);
                  if (i3 + 1 === size_bytes && size_bytes > 1 && next_byte === 0)
                    throw new Error("Invalid size byte");
                  out.meta_block_length |= next_byte << i3 * 8;
                }
              } else {
                for (i3 = 0; i3 < size_nibbles; ++i3) {
                  var next_nibble = br.readBits(4);
                  if (i3 + 1 === size_nibbles && size_nibbles > 4 && next_nibble === 0)
                    throw new Error("Invalid size nibble");
                  out.meta_block_length |= next_nibble << i3 * 4;
                }
              }
              ++out.meta_block_length;
              if (!out.input_end && !out.is_metadata) {
                out.is_uncompressed = br.readBits(1);
              }
              return out;
            }
            function ReadSymbol(table, index, br) {
              var start_index = index;
              var nbits;
              br.fillBitWindow();
              index += br.val_ >>> br.bit_pos_ & HUFFMAN_TABLE_MASK;
              nbits = table[index].bits - HUFFMAN_TABLE_BITS;
              if (nbits > 0) {
                br.bit_pos_ += HUFFMAN_TABLE_BITS;
                index += table[index].value;
                index += br.val_ >>> br.bit_pos_ & (1 << nbits) - 1;
              }
              br.bit_pos_ += table[index].bits;
              return table[index].value;
            }
            function ReadHuffmanCodeLengths(code_length_code_lengths, num_symbols, code_lengths, br) {
              var symbol3 = 0;
              var prev_code_len = kDefaultCodeLength;
              var repeat = 0;
              var repeat_code_len = 0;
              var space = 32768;
              var table = [];
              for (var i3 = 0; i3 < 32; i3++)
                table.push(new HuffmanCode(0, 0));
              BrotliBuildHuffmanTable(
                table,
                0,
                5,
                code_length_code_lengths,
                CODE_LENGTH_CODES
              );
              while (symbol3 < num_symbols && space > 0) {
                var p4 = 0;
                var code_len;
                br.readMoreInput();
                br.fillBitWindow();
                p4 += br.val_ >>> br.bit_pos_ & 31;
                br.bit_pos_ += table[p4].bits;
                code_len = table[p4].value & 255;
                if (code_len < kCodeLengthRepeatCode) {
                  repeat = 0;
                  code_lengths[symbol3++] = code_len;
                  if (code_len !== 0) {
                    prev_code_len = code_len;
                    space -= 32768 >> code_len;
                  }
                } else {
                  var extra_bits = code_len - 14;
                  var old_repeat;
                  var repeat_delta;
                  var new_len = 0;
                  if (code_len === kCodeLengthRepeatCode) {
                    new_len = prev_code_len;
                  }
                  if (repeat_code_len !== new_len) {
                    repeat = 0;
                    repeat_code_len = new_len;
                  }
                  old_repeat = repeat;
                  if (repeat > 0) {
                    repeat -= 2;
                    repeat <<= extra_bits;
                  }
                  repeat += br.readBits(extra_bits) + 3;
                  repeat_delta = repeat - old_repeat;
                  if (symbol3 + repeat_delta > num_symbols) {
                    throw new Error(
                      "[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols"
                    );
                  }
                  for (var x2 = 0; x2 < repeat_delta; x2++)
                    code_lengths[symbol3 + x2] = repeat_code_len;
                  symbol3 += repeat_delta;
                  if (repeat_code_len !== 0) {
                    space -= repeat_delta << 15 - repeat_code_len;
                  }
                }
              }
              if (space !== 0) {
                throw new Error(
                  "[ReadHuffmanCodeLengths] space = " + space
                );
              }
              for (; symbol3 < num_symbols; symbol3++)
                code_lengths[symbol3] = 0;
            }
            function ReadHuffmanCode(alphabet_size, tables, table, br) {
              var table_size = 0;
              var simple_code_or_skip;
              var code_lengths = new Uint8Array(alphabet_size);
              br.readMoreInput();
              simple_code_or_skip = br.readBits(2);
              if (simple_code_or_skip === 1) {
                var i3;
                var max_bits_counter = alphabet_size - 1;
                var max_bits = 0;
                var symbols = new Int32Array(4);
                var num_symbols = br.readBits(2) + 1;
                while (max_bits_counter) {
                  max_bits_counter >>= 1;
                  ++max_bits;
                }
                for (i3 = 0; i3 < num_symbols; ++i3) {
                  symbols[i3] = br.readBits(max_bits) % alphabet_size;
                  code_lengths[symbols[i3]] = 2;
                }
                code_lengths[symbols[0]] = 1;
                switch (num_symbols) {
                  case 1:
                    break;
                  case 3:
                    if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[1] === symbols[2]) {
                      throw new Error(
                        "[ReadHuffmanCode] invalid symbols"
                      );
                    }
                    break;
                  case 2:
                    if (symbols[0] === symbols[1]) {
                      throw new Error(
                        "[ReadHuffmanCode] invalid symbols"
                      );
                    }
                    code_lengths[symbols[1]] = 1;
                    break;
                  case 4:
                    if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[0] === symbols[3] || symbols[1] === symbols[2] || symbols[1] === symbols[3] || symbols[2] === symbols[3]) {
                      throw new Error(
                        "[ReadHuffmanCode] invalid symbols"
                      );
                    }
                    if (br.readBits(1)) {
                      code_lengths[symbols[2]] = 3;
                      code_lengths[symbols[3]] = 3;
                    } else {
                      code_lengths[symbols[0]] = 2;
                    }
                    break;
                }
              } else {
                var i3;
                var code_length_code_lengths = new Uint8Array(
                  CODE_LENGTH_CODES
                );
                var space = 32;
                var num_codes = 0;
                var huff = [
                  new HuffmanCode(2, 0),
                  new HuffmanCode(2, 4),
                  new HuffmanCode(2, 3),
                  new HuffmanCode(3, 2),
                  new HuffmanCode(2, 0),
                  new HuffmanCode(2, 4),
                  new HuffmanCode(2, 3),
                  new HuffmanCode(4, 1),
                  new HuffmanCode(2, 0),
                  new HuffmanCode(2, 4),
                  new HuffmanCode(2, 3),
                  new HuffmanCode(3, 2),
                  new HuffmanCode(2, 0),
                  new HuffmanCode(2, 4),
                  new HuffmanCode(2, 3),
                  new HuffmanCode(4, 5)
                ];
                for (i3 = simple_code_or_skip; i3 < CODE_LENGTH_CODES && space > 0; ++i3) {
                  var code_len_idx = kCodeLengthCodeOrder[i3];
                  var p4 = 0;
                  var v3;
                  br.fillBitWindow();
                  p4 += br.val_ >>> br.bit_pos_ & 15;
                  br.bit_pos_ += huff[p4].bits;
                  v3 = huff[p4].value;
                  code_length_code_lengths[code_len_idx] = v3;
                  if (v3 !== 0) {
                    space -= 32 >> v3;
                    ++num_codes;
                  }
                }
                if (!(num_codes === 1 || space === 0))
                  throw new Error(
                    "[ReadHuffmanCode] invalid num_codes or space"
                  );
                ReadHuffmanCodeLengths(
                  code_length_code_lengths,
                  alphabet_size,
                  code_lengths,
                  br
                );
              }
              table_size = BrotliBuildHuffmanTable(
                tables,
                table,
                HUFFMAN_TABLE_BITS,
                code_lengths,
                alphabet_size
              );
              if (table_size === 0) {
                throw new Error(
                  "[ReadHuffmanCode] BuildHuffmanTable failed: "
                );
              }
              return table_size;
            }
            function ReadBlockLength(table, index, br) {
              var code;
              var nbits;
              code = ReadSymbol(table, index, br);
              nbits = Prefix.kBlockLengthPrefixCode[code].nbits;
              return Prefix.kBlockLengthPrefixCode[code].offset + br.readBits(nbits);
            }
            function TranslateShortCodes(code, ringbuffer, index) {
              var val;
              if (code < NUM_DISTANCE_SHORT_CODES) {
                index += kDistanceShortCodeIndexOffset[code];
                index &= 3;
                val = ringbuffer[index] + kDistanceShortCodeValueOffset[code];
              } else {
                val = code - NUM_DISTANCE_SHORT_CODES + 1;
              }
              return val;
            }
            function MoveToFront(v3, index) {
              var value = v3[index];
              var i3 = index;
              for (; i3; --i3) v3[i3] = v3[i3 - 1];
              v3[0] = value;
            }
            function InverseMoveToFrontTransform(v3, v_len) {
              var mtf = new Uint8Array(256);
              var i3;
              for (i3 = 0; i3 < 256; ++i3) {
                mtf[i3] = i3;
              }
              for (i3 = 0; i3 < v_len; ++i3) {
                var index = v3[i3];
                v3[i3] = mtf[index];
                if (index) MoveToFront(mtf, index);
              }
            }
            function HuffmanTreeGroup(alphabet_size, num_htrees) {
              this.alphabet_size = alphabet_size;
              this.num_htrees = num_htrees;
              this.codes = new Array(
                num_htrees + num_htrees * kMaxHuffmanTableSize[alphabet_size + 31 >>> 5]
              );
              this.htrees = new Uint32Array(num_htrees);
            }
            HuffmanTreeGroup.prototype.decode = function(br) {
              var i3;
              var table_size;
              var next = 0;
              for (i3 = 0; i3 < this.num_htrees; ++i3) {
                this.htrees[i3] = next;
                table_size = ReadHuffmanCode(
                  this.alphabet_size,
                  this.codes,
                  next,
                  br
                );
                next += table_size;
              }
            };
            function DecodeContextMap(context_map_size, br) {
              var out = { num_htrees: null, context_map: null };
              var use_rle_for_zeros;
              var max_run_length_prefix = 0;
              var table;
              var i3;
              br.readMoreInput();
              var num_htrees = out.num_htrees = DecodeVarLenUint8(br) + 1;
              var context_map = out.context_map = new Uint8Array(
                context_map_size
              );
              if (num_htrees <= 1) {
                return out;
              }
              use_rle_for_zeros = br.readBits(1);
              if (use_rle_for_zeros) {
                max_run_length_prefix = br.readBits(4) + 1;
              }
              table = [];
              for (i3 = 0; i3 < HUFFMAN_MAX_TABLE_SIZE; i3++) {
                table[i3] = new HuffmanCode(0, 0);
              }
              ReadHuffmanCode(
                num_htrees + max_run_length_prefix,
                table,
                0,
                br
              );
              for (i3 = 0; i3 < context_map_size; ) {
                var code;
                br.readMoreInput();
                code = ReadSymbol(table, 0, br);
                if (code === 0) {
                  context_map[i3] = 0;
                  ++i3;
                } else if (code <= max_run_length_prefix) {
                  var reps = 1 + (1 << code) + br.readBits(code);
                  while (--reps) {
                    if (i3 >= context_map_size) {
                      throw new Error(
                        "[DecodeContextMap] i >= context_map_size"
                      );
                    }
                    context_map[i3] = 0;
                    ++i3;
                  }
                } else {
                  context_map[i3] = code - max_run_length_prefix;
                  ++i3;
                }
              }
              if (br.readBits(1)) {
                InverseMoveToFrontTransform(
                  context_map,
                  context_map_size
                );
              }
              return out;
            }
            function DecodeBlockType(max_block_type, trees, tree_type, block_types, ringbuffers, indexes, br) {
              var ringbuffer = tree_type * 2;
              var index = tree_type;
              var type_code = ReadSymbol(
                trees,
                tree_type * HUFFMAN_MAX_TABLE_SIZE,
                br
              );
              var block_type;
              if (type_code === 0) {
                block_type = ringbuffers[ringbuffer + (indexes[index] & 1)];
              } else if (type_code === 1) {
                block_type = ringbuffers[ringbuffer + (indexes[index] - 1 & 1)] + 1;
              } else {
                block_type = type_code - 2;
              }
              if (block_type >= max_block_type) {
                block_type -= max_block_type;
              }
              block_types[tree_type] = block_type;
              ringbuffers[ringbuffer + (indexes[index] & 1)] = block_type;
              ++indexes[index];
            }
            function CopyUncompressedBlockToOutput(output, len2, pos, ringbuffer, ringbuffer_mask, br) {
              var rb_size = ringbuffer_mask + 1;
              var rb_pos = pos & ringbuffer_mask;
              var br_pos = br.pos_ & BrotliBitReader.IBUF_MASK;
              var nbytes;
              if (len2 < 8 || br.bit_pos_ + (len2 << 3) < br.bit_end_pos_) {
                while (len2-- > 0) {
                  br.readMoreInput();
                  ringbuffer[rb_pos++] = br.readBits(8);
                  if (rb_pos === rb_size) {
                    output.write(ringbuffer, rb_size);
                    rb_pos = 0;
                  }
                }
                return;
              }
              if (br.bit_end_pos_ < 32) {
                throw new Error(
                  "[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32"
                );
              }
              while (br.bit_pos_ < 32) {
                ringbuffer[rb_pos] = br.val_ >>> br.bit_pos_;
                br.bit_pos_ += 8;
                ++rb_pos;
                --len2;
              }
              nbytes = br.bit_end_pos_ - br.bit_pos_ >> 3;
              if (br_pos + nbytes > BrotliBitReader.IBUF_MASK) {
                var tail = BrotliBitReader.IBUF_MASK + 1 - br_pos;
                for (var x2 = 0; x2 < tail; x2++)
                  ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2];
                nbytes -= tail;
                rb_pos += tail;
                len2 -= tail;
                br_pos = 0;
              }
              for (var x2 = 0; x2 < nbytes; x2++)
                ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2];
              rb_pos += nbytes;
              len2 -= nbytes;
              if (rb_pos >= rb_size) {
                output.write(ringbuffer, rb_size);
                rb_pos -= rb_size;
                for (var x2 = 0; x2 < rb_pos; x2++)
                  ringbuffer[x2] = ringbuffer[rb_size + x2];
              }
              while (rb_pos + len2 >= rb_size) {
                nbytes = rb_size - rb_pos;
                if (br.input_.read(ringbuffer, rb_pos, nbytes) < nbytes) {
                  throw new Error(
                    "[CopyUncompressedBlockToOutput] not enough bytes"
                  );
                }
                output.write(ringbuffer, rb_size);
                len2 -= nbytes;
                rb_pos = 0;
              }
              if (br.input_.read(ringbuffer, rb_pos, len2) < len2) {
                throw new Error(
                  "[CopyUncompressedBlockToOutput] not enough bytes"
                );
              }
              br.reset();
            }
            function JumpToByteBoundary(br) {
              var new_bit_pos = br.bit_pos_ + 7 & ~7;
              var pad_bits = br.readBits(new_bit_pos - br.bit_pos_);
              return pad_bits == 0;
            }
            function BrotliDecompressedSize(buffer) {
              var input = new BrotliInput(buffer);
              var br = new BrotliBitReader(input);
              DecodeWindowBits(br);
              var out = DecodeMetaBlockLength(br);
              return out.meta_block_length;
            }
            exports2.BrotliDecompressedSize = BrotliDecompressedSize;
            function BrotliDecompressBuffer(buffer, output_size) {
              var input = new BrotliInput(buffer);
              if (output_size == null) {
                output_size = BrotliDecompressedSize(buffer);
              }
              var output_buffer = new Uint8Array(output_size);
              var output = new BrotliOutput(output_buffer);
              BrotliDecompress(input, output);
              if (output.pos < output.buffer.length) {
                output.buffer = output.buffer.subarray(
                  0,
                  output.pos
                );
              }
              return output.buffer;
            }
            exports2.BrotliDecompressBuffer = BrotliDecompressBuffer;
            function BrotliDecompress(input, output) {
              var i3;
              var pos = 0;
              var input_end = 0;
              var window_bits = 0;
              var max_backward_distance;
              var max_distance = 0;
              var ringbuffer_size;
              var ringbuffer_mask;
              var ringbuffer;
              var ringbuffer_end;
              var dist_rb = [16, 15, 11, 4];
              var dist_rb_idx = 0;
              var prev_byte1 = 0;
              var prev_byte2 = 0;
              var hgroup = [
                new HuffmanTreeGroup(0, 0),
                new HuffmanTreeGroup(0, 0),
                new HuffmanTreeGroup(0, 0)
              ];
              var block_type_trees;
              var block_len_trees;
              var br;
              var kRingBufferWriteAheadSlack = 128 + BrotliBitReader.READ_SIZE;
              br = new BrotliBitReader(input);
              window_bits = DecodeWindowBits(br);
              max_backward_distance = (1 << window_bits) - 16;
              ringbuffer_size = 1 << window_bits;
              ringbuffer_mask = ringbuffer_size - 1;
              ringbuffer = new Uint8Array(
                ringbuffer_size + kRingBufferWriteAheadSlack + BrotliDictionary.maxDictionaryWordLength
              );
              ringbuffer_end = ringbuffer_size;
              block_type_trees = [];
              block_len_trees = [];
              for (var x2 = 0; x2 < 3 * HUFFMAN_MAX_TABLE_SIZE; x2++) {
                block_type_trees[x2] = new HuffmanCode(0, 0);
                block_len_trees[x2] = new HuffmanCode(0, 0);
              }
              while (!input_end) {
                var meta_block_remaining_len = 0;
                var is_uncompressed;
                var block_length = [1 << 28, 1 << 28, 1 << 28];
                var block_type = [0];
                var num_block_types = [1, 1, 1];
                var block_type_rb = [0, 1, 0, 1, 0, 1];
                var block_type_rb_index = [0];
                var distance_postfix_bits;
                var num_direct_distance_codes;
                var distance_postfix_mask;
                var num_distance_codes;
                var context_map = null;
                var context_modes = null;
                var num_literal_htrees;
                var dist_context_map = null;
                var num_dist_htrees;
                var context_offset = 0;
                var context_map_slice = null;
                var literal_htree_index = 0;
                var dist_context_offset = 0;
                var dist_context_map_slice = null;
                var dist_htree_index = 0;
                var context_lookup_offset1 = 0;
                var context_lookup_offset2 = 0;
                var context_mode;
                var htree_command;
                for (i3 = 0; i3 < 3; ++i3) {
                  hgroup[i3].codes = null;
                  hgroup[i3].htrees = null;
                }
                br.readMoreInput();
                var _out = DecodeMetaBlockLength(br);
                meta_block_remaining_len = _out.meta_block_length;
                if (pos + meta_block_remaining_len > output.buffer.length) {
                  var tmp = new Uint8Array(
                    pos + meta_block_remaining_len
                  );
                  tmp.set(output.buffer);
                  output.buffer = tmp;
                }
                input_end = _out.input_end;
                is_uncompressed = _out.is_uncompressed;
                if (_out.is_metadata) {
                  JumpToByteBoundary(br);
                  for (; meta_block_remaining_len > 0; --meta_block_remaining_len) {
                    br.readMoreInput();
                    br.readBits(8);
                  }
                  continue;
                }
                if (meta_block_remaining_len === 0) {
                  continue;
                }
                if (is_uncompressed) {
                  br.bit_pos_ = br.bit_pos_ + 7 & ~7;
                  CopyUncompressedBlockToOutput(
                    output,
                    meta_block_remaining_len,
                    pos,
                    ringbuffer,
                    ringbuffer_mask,
                    br
                  );
                  pos += meta_block_remaining_len;
                  continue;
                }
                for (i3 = 0; i3 < 3; ++i3) {
                  num_block_types[i3] = DecodeVarLenUint8(br) + 1;
                  if (num_block_types[i3] >= 2) {
                    ReadHuffmanCode(
                      num_block_types[i3] + 2,
                      block_type_trees,
                      i3 * HUFFMAN_MAX_TABLE_SIZE,
                      br
                    );
                    ReadHuffmanCode(
                      kNumBlockLengthCodes,
                      block_len_trees,
                      i3 * HUFFMAN_MAX_TABLE_SIZE,
                      br
                    );
                    block_length[i3] = ReadBlockLength(
                      block_len_trees,
                      i3 * HUFFMAN_MAX_TABLE_SIZE,
                      br
                    );
                    block_type_rb_index[i3] = 1;
                  }
                }
                br.readMoreInput();
                distance_postfix_bits = br.readBits(2);
                num_direct_distance_codes = NUM_DISTANCE_SHORT_CODES + (br.readBits(4) << distance_postfix_bits);
                distance_postfix_mask = (1 << distance_postfix_bits) - 1;
                num_distance_codes = num_direct_distance_codes + (48 << distance_postfix_bits);
                context_modes = new Uint8Array(
                  num_block_types[0]
                );
                for (i3 = 0; i3 < num_block_types[0]; ++i3) {
                  br.readMoreInput();
                  context_modes[i3] = br.readBits(2) << 1;
                }
                var _o1 = DecodeContextMap(
                  num_block_types[0] << kLiteralContextBits,
                  br
                );
                num_literal_htrees = _o1.num_htrees;
                context_map = _o1.context_map;
                var _o2 = DecodeContextMap(
                  num_block_types[2] << kDistanceContextBits,
                  br
                );
                num_dist_htrees = _o2.num_htrees;
                dist_context_map = _o2.context_map;
                hgroup[0] = new HuffmanTreeGroup(
                  kNumLiteralCodes,
                  num_literal_htrees
                );
                hgroup[1] = new HuffmanTreeGroup(
                  kNumInsertAndCopyCodes,
                  num_block_types[1]
                );
                hgroup[2] = new HuffmanTreeGroup(
                  num_distance_codes,
                  num_dist_htrees
                );
                for (i3 = 0; i3 < 3; ++i3) {
                  hgroup[i3].decode(br);
                }
                context_map_slice = 0;
                dist_context_map_slice = 0;
                context_mode = context_modes[block_type[0]];
                context_lookup_offset1 = Context.lookupOffsets[context_mode];
                context_lookup_offset2 = Context.lookupOffsets[context_mode + 1];
                htree_command = hgroup[1].htrees[0];
                while (meta_block_remaining_len > 0) {
                  var cmd_code;
                  var range_idx;
                  var insert_code;
                  var copy_code;
                  var insert_length;
                  var copy_length;
                  var distance_code;
                  var distance2;
                  var context;
                  var j2;
                  var copy_dst;
                  br.readMoreInput();
                  if (block_length[1] === 0) {
                    DecodeBlockType(
                      num_block_types[1],
                      block_type_trees,
                      1,
                      block_type,
                      block_type_rb,
                      block_type_rb_index,
                      br
                    );
                    block_length[1] = ReadBlockLength(
                      block_len_trees,
                      HUFFMAN_MAX_TABLE_SIZE,
                      br
                    );
                    htree_command = hgroup[1].htrees[block_type[1]];
                  }
                  --block_length[1];
                  cmd_code = ReadSymbol(
                    hgroup[1].codes,
                    htree_command,
                    br
                  );
                  range_idx = cmd_code >> 6;
                  if (range_idx >= 2) {
                    range_idx -= 2;
                    distance_code = -1;
                  } else {
                    distance_code = 0;
                  }
                  insert_code = Prefix.kInsertRangeLut[range_idx] + (cmd_code >> 3 & 7);
                  copy_code = Prefix.kCopyRangeLut[range_idx] + (cmd_code & 7);
                  insert_length = Prefix.kInsertLengthPrefixCode[insert_code].offset + br.readBits(
                    Prefix.kInsertLengthPrefixCode[insert_code].nbits
                  );
                  copy_length = Prefix.kCopyLengthPrefixCode[copy_code].offset + br.readBits(
                    Prefix.kCopyLengthPrefixCode[copy_code].nbits
                  );
                  prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask];
                  prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask];
                  for (j2 = 0; j2 < insert_length; ++j2) {
                    br.readMoreInput();
                    if (block_length[0] === 0) {
                      DecodeBlockType(
                        num_block_types[0],
                        block_type_trees,
                        0,
                        block_type,
                        block_type_rb,
                        block_type_rb_index,
                        br
                      );
                      block_length[0] = ReadBlockLength(
                        block_len_trees,
                        0,
                        br
                      );
                      context_offset = block_type[0] << kLiteralContextBits;
                      context_map_slice = context_offset;
                      context_mode = context_modes[block_type[0]];
                      context_lookup_offset1 = Context.lookupOffsets[context_mode];
                      context_lookup_offset2 = Context.lookupOffsets[context_mode + 1];
                    }
                    context = Context.lookup[context_lookup_offset1 + prev_byte1] | Context.lookup[context_lookup_offset2 + prev_byte2];
                    literal_htree_index = context_map[context_map_slice + context];
                    --block_length[0];
                    prev_byte2 = prev_byte1;
                    prev_byte1 = ReadSymbol(
                      hgroup[0].codes,
                      hgroup[0].htrees[literal_htree_index],
                      br
                    );
                    ringbuffer[pos & ringbuffer_mask] = prev_byte1;
                    if ((pos & ringbuffer_mask) === ringbuffer_mask) {
                      output.write(
                        ringbuffer,
                        ringbuffer_size
                      );
                    }
                    ++pos;
                  }
                  meta_block_remaining_len -= insert_length;
                  if (meta_block_remaining_len <= 0) break;
                  if (distance_code < 0) {
                    var context;
                    br.readMoreInput();
                    if (block_length[2] === 0) {
                      DecodeBlockType(
                        num_block_types[2],
                        block_type_trees,
                        2,
                        block_type,
                        block_type_rb,
                        block_type_rb_index,
                        br
                      );
                      block_length[2] = ReadBlockLength(
                        block_len_trees,
                        2 * HUFFMAN_MAX_TABLE_SIZE,
                        br
                      );
                      dist_context_offset = block_type[2] << kDistanceContextBits;
                      dist_context_map_slice = dist_context_offset;
                    }
                    --block_length[2];
                    context = (copy_length > 4 ? 3 : copy_length - 2) & 255;
                    dist_htree_index = dist_context_map[dist_context_map_slice + context];
                    distance_code = ReadSymbol(
                      hgroup[2].codes,
                      hgroup[2].htrees[dist_htree_index],
                      br
                    );
                    if (distance_code >= num_direct_distance_codes) {
                      var nbits;
                      var postfix;
                      var offset;
                      distance_code -= num_direct_distance_codes;
                      postfix = distance_code & distance_postfix_mask;
                      distance_code >>= distance_postfix_bits;
                      nbits = (distance_code >> 1) + 1;
                      offset = (2 + (distance_code & 1) << nbits) - 4;
                      distance_code = num_direct_distance_codes + (offset + br.readBits(nbits) << distance_postfix_bits) + postfix;
                    }
                  }
                  distance2 = TranslateShortCodes(
                    distance_code,
                    dist_rb,
                    dist_rb_idx
                  );
                  if (distance2 < 0) {
                    throw new Error(
                      "[BrotliDecompress] invalid distance"
                    );
                  }
                  if (pos < max_backward_distance && max_distance !== max_backward_distance) {
                    max_distance = pos;
                  } else {
                    max_distance = max_backward_distance;
                  }
                  copy_dst = pos & ringbuffer_mask;
                  if (distance2 > max_distance) {
                    if (copy_length >= BrotliDictionary.minDictionaryWordLength && copy_length <= BrotliDictionary.maxDictionaryWordLength) {
                      var offset = BrotliDictionary.offsetsByLength[copy_length];
                      var word_id = distance2 - max_distance - 1;
                      var shift = BrotliDictionary.sizeBitsByLength[copy_length];
                      var mask = (1 << shift) - 1;
                      var word_idx = word_id & mask;
                      var transform_idx = word_id >> shift;
                      offset += word_idx * copy_length;
                      if (transform_idx < Transform.kNumTransforms) {
                        var len2 = Transform.transformDictionaryWord(
                          ringbuffer,
                          copy_dst,
                          offset,
                          copy_length,
                          transform_idx
                        );
                        copy_dst += len2;
                        pos += len2;
                        meta_block_remaining_len -= len2;
                        if (copy_dst >= ringbuffer_end) {
                          output.write(
                            ringbuffer,
                            ringbuffer_size
                          );
                          for (var _x49 = 0; _x49 < copy_dst - ringbuffer_end; _x49++)
                            ringbuffer[_x49] = ringbuffer[ringbuffer_end + _x49];
                        }
                      } else {
                        throw new Error(
                          "Invalid backward reference. pos: " + pos + " distance: " + distance2 + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
                        );
                      }
                    } else {
                      throw new Error(
                        "Invalid backward reference. pos: " + pos + " distance: " + distance2 + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
                      );
                    }
                  } else {
                    if (distance_code > 0) {
                      dist_rb[dist_rb_idx & 3] = distance2;
                      ++dist_rb_idx;
                    }
                    if (copy_length > meta_block_remaining_len) {
                      throw new Error(
                        "Invalid backward reference. pos: " + pos + " distance: " + distance2 + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
                      );
                    }
                    for (j2 = 0; j2 < copy_length; ++j2) {
                      ringbuffer[pos & ringbuffer_mask] = ringbuffer[pos - distance2 & ringbuffer_mask];
                      if ((pos & ringbuffer_mask) === ringbuffer_mask) {
                        output.write(
                          ringbuffer,
                          ringbuffer_size
                        );
                      }
                      ++pos;
                      --meta_block_remaining_len;
                    }
                  }
                  prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask];
                  prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask];
                }
                pos &= 1073741823;
              }
              output.write(ringbuffer, pos & ringbuffer_mask);
            }
            exports2.BrotliDecompress = BrotliDecompress;
            BrotliDictionary.init();
          },
          {
            "./bit_reader": 1,
            "./context": 2,
            "./dictionary": 6,
            "./huffman": 7,
            "./prefix": 9,
            "./streams": 10,
            "./transform": 11
          }
        ],
        4: [
          function(require2, module2, exports2) {
            var base64 = require2("base64-js");
            exports2.init = function() {
              var BrotliDecompressBuffer = require2("./decode").BrotliDecompressBuffer;
              var compressed = base64.toByteArray(
                require2("./dictionary.bin.js")
              );
              return BrotliDecompressBuffer(compressed);
            };
          },
          { "./decode": 3, "./dictionary.bin.js": 5, "base64-js": 8 }
        ],
        5: [
          function(require2, module2, exports2) {
            module2.exports = " ";
          },
          {}
        ],
        6: [
          function(require2, module2, exports2) {
            var data = require2("./dictionary-browser");
            exports2.init = function() {
              exports2.dictionary = data.init();
            };
            exports2.offsetsByLength = new Uint32Array([
              0,
              0,
              0,
              0,
              0,
              4096,
              9216,
              21504,
              35840,
              44032,
              53248,
              63488,
              74752,
              87040,
              93696,
              100864,
              104704,
              106752,
              108928,
              113536,
              115968,
              118528,
              119872,
              121280,
              122016
            ]);
            exports2.sizeBitsByLength = new Uint8Array([
              0,
              0,
              0,
              0,
              10,
              10,
              11,
              11,
              10,
              10,
              10,
              10,
              10,
              9,
              9,
              8,
              7,
              7,
              8,
              7,
              7,
              6,
              6,
              5,
              5
            ]);
            exports2.minDictionaryWordLength = 4;
            exports2.maxDictionaryWordLength = 24;
          },
          { "./dictionary-browser": 4 }
        ],
        7: [
          function(require2, module2, exports2) {
            function HuffmanCode(bits, value) {
              this.bits = bits;
              this.value = value;
            }
            exports2.HuffmanCode = HuffmanCode;
            var MAX_LENGTH = 15;
            function GetNextKey(key, len2) {
              var step = 1 << len2 - 1;
              while (key & step) {
                step >>= 1;
              }
              return (key & step - 1) + step;
            }
            function ReplicateValue(table, i3, step, end, code) {
              do {
                end -= step;
                table[i3 + end] = new HuffmanCode(
                  code.bits,
                  code.value
                );
              } while (end > 0);
            }
            function NextTableBitSize(count, len2, root_bits) {
              var left = 1 << len2 - root_bits;
              while (len2 < MAX_LENGTH) {
                left -= count[len2];
                if (left <= 0) break;
                ++len2;
                left <<= 1;
              }
              return len2 - root_bits;
            }
            exports2.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_lengths, code_lengths_size) {
              var start_table = table;
              var code;
              var len2;
              var symbol3;
              var key;
              var step;
              var low;
              var mask;
              var table_bits;
              var table_size;
              var total_size;
              var sorted;
              var count = new Int32Array(
                MAX_LENGTH + 1
              );
              var offset = new Int32Array(
                MAX_LENGTH + 1
              );
              sorted = new Int32Array(code_lengths_size);
              for (symbol3 = 0; symbol3 < code_lengths_size; symbol3++) {
                count[code_lengths[symbol3]]++;
              }
              offset[1] = 0;
              for (len2 = 1; len2 < MAX_LENGTH; len2++) {
                offset[len2 + 1] = offset[len2] + count[len2];
              }
              for (symbol3 = 0; symbol3 < code_lengths_size; symbol3++) {
                if (code_lengths[symbol3] !== 0) {
                  sorted[offset[code_lengths[symbol3]]++] = symbol3;
                }
              }
              table_bits = root_bits;
              table_size = 1 << table_bits;
              total_size = table_size;
              if (offset[MAX_LENGTH] === 1) {
                for (key = 0; key < total_size; ++key) {
                  root_table[table + key] = new HuffmanCode(
                    0,
                    sorted[0] & 65535
                  );
                }
                return total_size;
              }
              key = 0;
              symbol3 = 0;
              for (len2 = 1, step = 2; len2 <= root_bits; ++len2, step <<= 1) {
                for (; count[len2] > 0; --count[len2]) {
                  code = new HuffmanCode(
                    len2 & 255,
                    sorted[symbol3++] & 65535
                  );
                  ReplicateValue(
                    root_table,
                    table + key,
                    step,
                    table_size,
                    code
                  );
                  key = GetNextKey(key, len2);
                }
              }
              mask = total_size - 1;
              low = -1;
              for (len2 = root_bits + 1, step = 2; len2 <= MAX_LENGTH; ++len2, step <<= 1) {
                for (; count[len2] > 0; --count[len2]) {
                  if ((key & mask) !== low) {
                    table += table_size;
                    table_bits = NextTableBitSize(
                      count,
                      len2,
                      root_bits
                    );
                    table_size = 1 << table_bits;
                    total_size += table_size;
                    low = key & mask;
                    root_table[start_table + low] = new HuffmanCode(
                      table_bits + root_bits & 255,
                      table - start_table - low & 65535
                    );
                  }
                  code = new HuffmanCode(
                    len2 - root_bits & 255,
                    sorted[symbol3++] & 65535
                  );
                  ReplicateValue(
                    root_table,
                    table + (key >> root_bits),
                    step,
                    table_size,
                    code
                  );
                  key = GetNextKey(key, len2);
                }
              }
              return total_size;
            };
          },
          {}
        ],
        8: [
          function(require2, module2, exports2) {
            "use strict";
            exports2.byteLength = byteLength;
            exports2.toByteArray = toByteArray;
            exports2.fromByteArray = fromByteArray;
            var lookup = [];
            var revLookup = [];
            var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
            var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
            for (var i3 = 0, len2 = code.length; i3 < len2; ++i3) {
              lookup[i3] = code[i3];
              revLookup[code.charCodeAt(i3)] = i3;
            }
            revLookup["-".charCodeAt(0)] = 62;
            revLookup["_".charCodeAt(0)] = 63;
            function getLens(b64) {
              var len22 = b64.length;
              if (len22 % 4 > 0) {
                throw new Error(
                  "Invalid string. Length must be a multiple of 4"
                );
              }
              var validLen = b64.indexOf("=");
              if (validLen === -1) validLen = len22;
              var placeHoldersLen = validLen === len22 ? 0 : 4 - validLen % 4;
              return [validLen, placeHoldersLen];
            }
            function byteLength(b64) {
              var lens = getLens(b64);
              var validLen = lens[0];
              var placeHoldersLen = lens[1];
              return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
            }
            function _byteLength(b64, validLen, placeHoldersLen) {
              return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
            }
            function toByteArray(b64) {
              var tmp;
              var lens = getLens(b64);
              var validLen = lens[0];
              var placeHoldersLen = lens[1];
              var arr = new Arr(
                _byteLength(b64, validLen, placeHoldersLen)
              );
              var curByte = 0;
              var len22 = placeHoldersLen > 0 ? validLen - 4 : validLen;
              for (var i22 = 0; i22 < len22; i22 += 4) {
                tmp = revLookup[b64.charCodeAt(i22)] << 18 | revLookup[b64.charCodeAt(i22 + 1)] << 12 | revLookup[b64.charCodeAt(i22 + 2)] << 6 | revLookup[b64.charCodeAt(i22 + 3)];
                arr[curByte++] = tmp >> 16 & 255;
                arr[curByte++] = tmp >> 8 & 255;
                arr[curByte++] = tmp & 255;
              }
              if (placeHoldersLen === 2) {
                tmp = revLookup[b64.charCodeAt(i22)] << 2 | revLookup[b64.charCodeAt(i22 + 1)] >> 4;
                arr[curByte++] = tmp & 255;
              }
              if (placeHoldersLen === 1) {
                tmp = revLookup[b64.charCodeAt(i22)] << 10 | revLookup[b64.charCodeAt(i22 + 1)] << 4 | revLookup[b64.charCodeAt(i22 + 2)] >> 2;
                arr[curByte++] = tmp >> 8 & 255;
                arr[curByte++] = tmp & 255;
              }
              return arr;
            }
            function tripletToBase64(num) {
              return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
            }
            function encodeChunk(uint8, start2, end) {
              var tmp;
              var output = [];
              for (var i22 = start2; i22 < end; i22 += 3) {
                tmp = (uint8[i22] << 16 & 16711680) + (uint8[i22 + 1] << 8 & 65280) + (uint8[i22 + 2] & 255);
                output.push(tripletToBase64(tmp));
              }
              return output.join("");
            }
            function fromByteArray(uint8) {
              var tmp;
              var len22 = uint8.length;
              var extraBytes = len22 % 3;
              var parts = [];
              var maxChunkLength = 16383;
              for (var i22 = 0, len222 = len22 - extraBytes; i22 < len222; i22 += maxChunkLength) {
                parts.push(
                  encodeChunk(
                    uint8,
                    i22,
                    i22 + maxChunkLength > len222 ? len222 : i22 + maxChunkLength
                  )
                );
              }
              if (extraBytes === 1) {
                tmp = uint8[len22 - 1];
                parts.push(
                  lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
                );
              } else if (extraBytes === 2) {
                tmp = (uint8[len22 - 2] << 8) + uint8[len22 - 1];
                parts.push(
                  lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
                );
              }
              return parts.join("");
            }
          },
          {}
        ],
        9: [
          function(require2, module2, exports2) {
            function PrefixCodeRange(offset, nbits) {
              this.offset = offset;
              this.nbits = nbits;
            }
            exports2.kBlockLengthPrefixCode = [
              new PrefixCodeRange(1, 2),
              new PrefixCodeRange(5, 2),
              new PrefixCodeRange(9, 2),
              new PrefixCodeRange(13, 2),
              new PrefixCodeRange(17, 3),
              new PrefixCodeRange(25, 3),
              new PrefixCodeRange(33, 3),
              new PrefixCodeRange(41, 3),
              new PrefixCodeRange(49, 4),
              new PrefixCodeRange(65, 4),
              new PrefixCodeRange(81, 4),
              new PrefixCodeRange(97, 4),
              new PrefixCodeRange(113, 5),
              new PrefixCodeRange(145, 5),
              new PrefixCodeRange(177, 5),
              new PrefixCodeRange(209, 5),
              new PrefixCodeRange(241, 6),
              new PrefixCodeRange(305, 6),
              new PrefixCodeRange(369, 7),
              new PrefixCodeRange(497, 8),
              new PrefixCodeRange(753, 9),
              new PrefixCodeRange(1265, 10),
              new PrefixCodeRange(2289, 11),
              new PrefixCodeRange(4337, 12),
              new PrefixCodeRange(8433, 13),
              new PrefixCodeRange(16625, 24)
            ];
            exports2.kInsertLengthPrefixCode = [
              new PrefixCodeRange(0, 0),
              new PrefixCodeRange(1, 0),
              new PrefixCodeRange(2, 0),
              new PrefixCodeRange(3, 0),
              new PrefixCodeRange(4, 0),
              new PrefixCodeRange(5, 0),
              new PrefixCodeRange(6, 1),
              new PrefixCodeRange(8, 1),
              new PrefixCodeRange(10, 2),
              new PrefixCodeRange(14, 2),
              new PrefixCodeRange(18, 3),
              new PrefixCodeRange(26, 3),
              new PrefixCodeRange(34, 4),
              new PrefixCodeRange(50, 4),
              new PrefixCodeRange(66, 5),
              new PrefixCodeRange(98, 5),
              new PrefixCodeRange(130, 6),
              new PrefixCodeRange(194, 7),
              new PrefixCodeRange(322, 8),
              new PrefixCodeRange(578, 9),
              new PrefixCodeRange(1090, 10),
              new PrefixCodeRange(2114, 12),
              new PrefixCodeRange(6210, 14),
              new PrefixCodeRange(22594, 24)
            ];
            exports2.kCopyLengthPrefixCode = [
              new PrefixCodeRange(2, 0),
              new PrefixCodeRange(3, 0),
              new PrefixCodeRange(4, 0),
              new PrefixCodeRange(5, 0),
              new PrefixCodeRange(6, 0),
              new PrefixCodeRange(7, 0),
              new PrefixCodeRange(8, 0),
              new PrefixCodeRange(9, 0),
              new PrefixCodeRange(10, 1),
              new PrefixCodeRange(12, 1),
              new PrefixCodeRange(14, 2),
              new PrefixCodeRange(18, 2),
              new PrefixCodeRange(22, 3),
              new PrefixCodeRange(30, 3),
              new PrefixCodeRange(38, 4),
              new PrefixCodeRange(54, 4),
              new PrefixCodeRange(70, 5),
              new PrefixCodeRange(102, 5),
              new PrefixCodeRange(134, 6),
              new PrefixCodeRange(198, 7),
              new PrefixCodeRange(326, 8),
              new PrefixCodeRange(582, 9),
              new PrefixCodeRange(1094, 10),
              new PrefixCodeRange(2118, 24)
            ];
            exports2.kInsertRangeLut = [0, 0, 8, 8, 0, 16, 8, 16, 16];
            exports2.kCopyRangeLut = [0, 8, 0, 8, 16, 0, 16, 8, 16];
          },
          {}
        ],
        10: [
          function(require2, module2, exports2) {
            function BrotliInput(buffer) {
              this.buffer = buffer;
              this.pos = 0;
            }
            BrotliInput.prototype.read = function(buf, i3, count) {
              if (this.pos + count > this.buffer.length) {
                count = this.buffer.length - this.pos;
              }
              for (var p4 = 0; p4 < count; p4++)
                buf[i3 + p4] = this.buffer[this.pos + p4];
              this.pos += count;
              return count;
            };
            exports2.BrotliInput = BrotliInput;
            function BrotliOutput(buf) {
              this.buffer = buf;
              this.pos = 0;
            }
            BrotliOutput.prototype.write = function(buf, count) {
              if (this.pos + count > this.buffer.length)
                throw new Error(
                  "Output buffer is not large enough"
                );
              this.buffer.set(buf.subarray(0, count), this.pos);
              this.pos += count;
              return count;
            };
            exports2.BrotliOutput = BrotliOutput;
          },
          {}
        ],
        11: [
          function(require2, module2, exports2) {
            var BrotliDictionary = require2("./dictionary");
            var kIdentity = 0;
            var kOmitLast1 = 1;
            var kOmitLast2 = 2;
            var kOmitLast3 = 3;
            var kOmitLast4 = 4;
            var kOmitLast5 = 5;
            var kOmitLast6 = 6;
            var kOmitLast7 = 7;
            var kOmitLast8 = 8;
            var kOmitLast9 = 9;
            var kUppercaseFirst = 10;
            var kUppercaseAll = 11;
            var kOmitFirst1 = 12;
            var kOmitFirst2 = 13;
            var kOmitFirst3 = 14;
            var kOmitFirst4 = 15;
            var kOmitFirst5 = 16;
            var kOmitFirst6 = 17;
            var kOmitFirst7 = 18;
            var kOmitFirst8 = 19;
            var kOmitFirst9 = 20;
            function Transform(prefix2, transform, suffix) {
              this.prefix = new Uint8Array(prefix2.length);
              this.transform = transform;
              this.suffix = new Uint8Array(suffix.length);
              for (var i3 = 0; i3 < prefix2.length; i3++)
                this.prefix[i3] = prefix2.charCodeAt(i3);
              for (var i3 = 0; i3 < suffix.length; i3++)
                this.suffix[i3] = suffix.charCodeAt(i3);
            }
            var kTransforms = [
              new Transform("", kIdentity, ""),
              new Transform("", kIdentity, " "),
              new Transform(" ", kIdentity, " "),
              new Transform("", kOmitFirst1, ""),
              new Transform("", kUppercaseFirst, " "),
              new Transform("", kIdentity, " the "),
              new Transform(" ", kIdentity, ""),
              new Transform("s ", kIdentity, " "),
              new Transform("", kIdentity, " of "),
              new Transform("", kUppercaseFirst, ""),
              new Transform("", kIdentity, " and "),
              new Transform("", kOmitFirst2, ""),
              new Transform("", kOmitLast1, ""),
              new Transform(", ", kIdentity, " "),
              new Transform("", kIdentity, ", "),
              new Transform(" ", kUppercaseFirst, " "),
              new Transform("", kIdentity, " in "),
              new Transform("", kIdentity, " to "),
              new Transform("e ", kIdentity, " "),
              new Transform("", kIdentity, '"'),
              new Transform("", kIdentity, "."),
              new Transform("", kIdentity, '">'),
              new Transform("", kIdentity, "\n"),
              new Transform("", kOmitLast3, ""),
              new Transform("", kIdentity, "]"),
              new Transform("", kIdentity, " for "),
              new Transform("", kOmitFirst3, ""),
              new Transform("", kOmitLast2, ""),
              new Transform("", kIdentity, " a "),
              new Transform("", kIdentity, " that "),
              new Transform(" ", kUppercaseFirst, ""),
              new Transform("", kIdentity, ". "),
              new Transform(".", kIdentity, ""),
              new Transform(" ", kIdentity, ", "),
              new Transform("", kOmitFirst4, ""),
              new Transform("", kIdentity, " with "),
              new Transform("", kIdentity, "'"),
              new Transform("", kIdentity, " from "),
              new Transform("", kIdentity, " by "),
              new Transform("", kOmitFirst5, ""),
              new Transform("", kOmitFirst6, ""),
              new Transform(" the ", kIdentity, ""),
              new Transform("", kOmitLast4, ""),
              new Transform("", kIdentity, ". The "),
              new Transform("", kUppercaseAll, ""),
              new Transform("", kIdentity, " on "),
              new Transform("", kIdentity, " as "),
              new Transform("", kIdentity, " is "),
              new Transform("", kOmitLast7, ""),
              new Transform("", kOmitLast1, "ing "),
              new Transform("", kIdentity, "\n	"),
              new Transform("", kIdentity, ":"),
              new Transform(" ", kIdentity, ". "),
              new Transform("", kIdentity, "ed "),
              new Transform("", kOmitFirst9, ""),
              new Transform("", kOmitFirst7, ""),
              new Transform("", kOmitLast6, ""),
              new Transform("", kIdentity, "("),
              new Transform("", kUppercaseFirst, ", "),
              new Transform("", kOmitLast8, ""),
              new Transform("", kIdentity, " at "),
              new Transform("", kIdentity, "ly "),
              new Transform(" the ", kIdentity, " of "),
              new Transform("", kOmitLast5, ""),
              new Transform("", kOmitLast9, ""),
              new Transform(" ", kUppercaseFirst, ", "),
              new Transform("", kUppercaseFirst, '"'),
              new Transform(".", kIdentity, "("),
              new Transform("", kUppercaseAll, " "),
              new Transform("", kUppercaseFirst, '">'),
              new Transform("", kIdentity, '="'),
              new Transform(" ", kIdentity, "."),
              new Transform(".com/", kIdentity, ""),
              new Transform(" the ", kIdentity, " of the "),
              new Transform("", kUppercaseFirst, "'"),
              new Transform("", kIdentity, ". This "),
              new Transform("", kIdentity, ","),
              new Transform(".", kIdentity, " "),
              new Transform("", kUppercaseFirst, "("),
              new Transform("", kUppercaseFirst, "."),
              new Transform("", kIdentity, " not "),
              new Transform(" ", kIdentity, '="'),
              new Transform("", kIdentity, "er "),
              new Transform(" ", kUppercaseAll, " "),
              new Transform("", kIdentity, "al "),
              new Transform(" ", kUppercaseAll, ""),
              new Transform("", kIdentity, "='"),
              new Transform("", kUppercaseAll, '"'),
              new Transform("", kUppercaseFirst, ". "),
              new Transform(" ", kIdentity, "("),
              new Transform("", kIdentity, "ful "),
              new Transform(" ", kUppercaseFirst, ". "),
              new Transform("", kIdentity, "ive "),
              new Transform("", kIdentity, "less "),
              new Transform("", kUppercaseAll, "'"),
              new Transform("", kIdentity, "est "),
              new Transform(" ", kUppercaseFirst, "."),
              new Transform("", kUppercaseAll, '">'),
              new Transform(" ", kIdentity, "='"),
              new Transform("", kUppercaseFirst, ","),
              new Transform("", kIdentity, "ize "),
              new Transform("", kUppercaseAll, "."),
              new Transform("\xC2\xA0", kIdentity, ""),
              new Transform(" ", kIdentity, ","),
              new Transform("", kUppercaseFirst, '="'),
              new Transform("", kUppercaseAll, '="'),
              new Transform("", kIdentity, "ous "),
              new Transform("", kUppercaseAll, ", "),
              new Transform("", kUppercaseFirst, "='"),
              new Transform(" ", kUppercaseFirst, ","),
              new Transform(" ", kUppercaseAll, '="'),
              new Transform(" ", kUppercaseAll, ", "),
              new Transform("", kUppercaseAll, ","),
              new Transform("", kUppercaseAll, "("),
              new Transform("", kUppercaseAll, ". "),
              new Transform(" ", kUppercaseAll, "."),
              new Transform("", kUppercaseAll, "='"),
              new Transform(" ", kUppercaseAll, ". "),
              new Transform(" ", kUppercaseFirst, '="'),
              new Transform(" ", kUppercaseAll, "='"),
              new Transform(" ", kUppercaseFirst, "='")
            ];
            exports2.kTransforms = kTransforms;
            exports2.kNumTransforms = kTransforms.length;
            function ToUpperCase(p4, i3) {
              if (p4[i3] < 192) {
                if (p4[i3] >= 97 && p4[i3] <= 122) {
                  p4[i3] ^= 32;
                }
                return 1;
              }
              if (p4[i3] < 224) {
                p4[i3 + 1] ^= 32;
                return 2;
              }
              p4[i3 + 2] ^= 5;
              return 3;
            }
            exports2.transformDictionaryWord = function(dst, idx, word, len2, transform) {
              var prefix2 = kTransforms[transform].prefix;
              var suffix = kTransforms[transform].suffix;
              var t4 = kTransforms[transform].transform;
              var skip = t4 < kOmitFirst1 ? 0 : t4 - (kOmitFirst1 - 1);
              var i3 = 0;
              var start_idx = idx;
              var uppercase;
              if (skip > len2) {
                skip = len2;
              }
              var prefix_pos = 0;
              while (prefix_pos < prefix2.length) {
                dst[idx++] = prefix2[prefix_pos++];
              }
              word += skip;
              len2 -= skip;
              if (t4 <= kOmitLast9) {
                len2 -= t4;
              }
              for (i3 = 0; i3 < len2; i3++) {
                dst[idx++] = BrotliDictionary.dictionary[word + i3];
              }
              uppercase = idx - len2;
              if (t4 === kUppercaseFirst) {
                ToUpperCase(dst, uppercase);
              } else if (t4 === kUppercaseAll) {
                while (len2 > 0) {
                  var step = ToUpperCase(dst, uppercase);
                  uppercase += step;
                  len2 -= step;
                }
              }
              var suffix_pos = 0;
              while (suffix_pos < suffix.length) {
                dst[idx++] = suffix[suffix_pos++];
              }
              return idx - start_idx;
            };
          },
          { "./dictionary": 6 }
        ],
        12: [
          function(require2, module2, exports2) {
            module2.exports = require2("./dec/decode").BrotliDecompressBuffer;
          },
          { "./dec/decode": 3 }
        ]
      },
      {},
      [12]
    )(12);
  })();

  // packages/global-styles-ui/build-module/font-library/lib/inflate.mjs
  var __require3 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, {
    get: (a3, b3) => (typeof __require !== "undefined" ? __require : a3)[b3]
  }) : x2)(function(x2) {
    if (typeof __require !== "undefined") return __require.apply(this, arguments);
    throw Error('Dynamic require of "' + x2 + '" is not supported');
  });
  var inflate_default = (function() {
    var define2, module, exports;
    return (/* @__PURE__ */ (function() {
      function r4(e3, n3, t4) {
        function o4(i22, f3) {
          if (!n3[i22]) {
            if (!e3[i22]) {
              var c6 = "function" == typeof __require3 && __require3;
              if (!f3 && c6) return c6(i22, true);
              if (u3) return u3(i22, true);
              var a3 = new Error("Cannot find module '" + i22 + "'");
              throw a3.code = "MODULE_NOT_FOUND", a3;
            }
            var p4 = n3[i22] = { exports: {} };
            e3[i22][0].call(
              p4.exports,
              function(r22) {
                var n22 = e3[i22][1][r22];
                return o4(n22 || r22);
              },
              p4,
              p4.exports,
              r4,
              e3,
              n3,
              t4
            );
          }
          return n3[i22].exports;
        }
        for (var u3 = "function" == typeof __require3 && __require3, i3 = 0; i3 < t4.length; i3++)
          o4(t4[i3]);
        return o4;
      }
      return r4;
    })())(
      {
        1: [
          function(require2, module2, exports2) {
            "use strict";
            var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined";
            function _has(obj, key) {
              return Object.prototype.hasOwnProperty.call(obj, key);
            }
            exports2.assign = function(obj) {
              var sources = Array.prototype.slice.call(
                arguments,
                1
              );
              while (sources.length) {
                var source = sources.shift();
                if (!source) {
                  continue;
                }
                if (typeof source !== "object") {
                  throw new TypeError(
                    source + "must be non-object"
                  );
                }
                for (var p4 in source) {
                  if (_has(source, p4)) {
                    obj[p4] = source[p4];
                  }
                }
              }
              return obj;
            };
            exports2.shrinkBuf = function(buf, size) {
              if (buf.length === size) {
                return buf;
              }
              if (buf.subarray) {
                return buf.subarray(0, size);
              }
              buf.length = size;
              return buf;
            };
            var fnTyped = {
              arraySet: function(dest, src, src_offs, len2, dest_offs) {
                if (src.subarray && dest.subarray) {
                  dest.set(
                    src.subarray(src_offs, src_offs + len2),
                    dest_offs
                  );
                  return;
                }
                for (var i3 = 0; i3 < len2; i3++) {
                  dest[dest_offs + i3] = src[src_offs + i3];
                }
              },
              // Join array of chunks to single array.
              flattenChunks: function(chunks) {
                var i3, l3, len2, pos, chunk2, result;
                len2 = 0;
                for (i3 = 0, l3 = chunks.length; i3 < l3; i3++) {
                  len2 += chunks[i3].length;
                }
                result = new Uint8Array(len2);
                pos = 0;
                for (i3 = 0, l3 = chunks.length; i3 < l3; i3++) {
                  chunk2 = chunks[i3];
                  result.set(chunk2, pos);
                  pos += chunk2.length;
                }
                return result;
              }
            };
            var fnUntyped = {
              arraySet: function(dest, src, src_offs, len2, dest_offs) {
                for (var i3 = 0; i3 < len2; i3++) {
                  dest[dest_offs + i3] = src[src_offs + i3];
                }
              },
              // Join array of chunks to single array.
              flattenChunks: function(chunks) {
                return [].concat.apply([], chunks);
              }
            };
            exports2.setTyped = function(on) {
              if (on) {
                exports2.Buf8 = Uint8Array;
                exports2.Buf16 = Uint16Array;
                exports2.Buf32 = Int32Array;
                exports2.assign(exports2, fnTyped);
              } else {
                exports2.Buf8 = Array;
                exports2.Buf16 = Array;
                exports2.Buf32 = Array;
                exports2.assign(exports2, fnUntyped);
              }
            };
            exports2.setTyped(TYPED_OK);
          },
          {}
        ],
        2: [
          function(require2, module2, exports2) {
            "use strict";
            var utils = require2("./common");
            var STR_APPLY_OK = true;
            var STR_APPLY_UIA_OK = true;
            try {
              String.fromCharCode.apply(null, [0]);
            } catch (__314) {
              STR_APPLY_OK = false;
            }
            try {
              String.fromCharCode.apply(null, new Uint8Array(1));
            } catch (__314) {
              STR_APPLY_UIA_OK = false;
            }
            var _utf8len = new utils.Buf8(256);
            for (var q = 0; q < 256; q++) {
              _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;
            }
            _utf8len[254] = _utf8len[254] = 1;
            exports2.string2buf = function(str3) {
              var buf, c6, c22, m_pos, i3, str_len = str3.length, buf_len = 0;
              for (m_pos = 0; m_pos < str_len; m_pos++) {
                c6 = str3.charCodeAt(m_pos);
                if ((c6 & 64512) === 55296 && m_pos + 1 < str_len) {
                  c22 = str3.charCodeAt(m_pos + 1);
                  if ((c22 & 64512) === 56320) {
                    c6 = 65536 + (c6 - 55296 << 10) + (c22 - 56320);
                    m_pos++;
                  }
                }
                buf_len += c6 < 128 ? 1 : c6 < 2048 ? 2 : c6 < 65536 ? 3 : 4;
              }
              buf = new utils.Buf8(buf_len);
              for (i3 = 0, m_pos = 0; i3 < buf_len; m_pos++) {
                c6 = str3.charCodeAt(m_pos);
                if ((c6 & 64512) === 55296 && m_pos + 1 < str_len) {
                  c22 = str3.charCodeAt(m_pos + 1);
                  if ((c22 & 64512) === 56320) {
                    c6 = 65536 + (c6 - 55296 << 10) + (c22 - 56320);
                    m_pos++;
                  }
                }
                if (c6 < 128) {
                  buf[i3++] = c6;
                } else if (c6 < 2048) {
                  buf[i3++] = 192 | c6 >>> 6;
                  buf[i3++] = 128 | c6 & 63;
                } else if (c6 < 65536) {
                  buf[i3++] = 224 | c6 >>> 12;
                  buf[i3++] = 128 | c6 >>> 6 & 63;
                  buf[i3++] = 128 | c6 & 63;
                } else {
                  buf[i3++] = 240 | c6 >>> 18;
                  buf[i3++] = 128 | c6 >>> 12 & 63;
                  buf[i3++] = 128 | c6 >>> 6 & 63;
                  buf[i3++] = 128 | c6 & 63;
                }
              }
              return buf;
            };
            function buf2binstring(buf, len2) {
              if (len2 < 65534) {
                if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) {
                  return String.fromCharCode.apply(
                    null,
                    utils.shrinkBuf(buf, len2)
                  );
                }
              }
              var result = "";
              for (var i3 = 0; i3 < len2; i3++) {
                result += String.fromCharCode(buf[i3]);
              }
              return result;
            }
            exports2.buf2binstring = function(buf) {
              return buf2binstring(buf, buf.length);
            };
            exports2.binstring2buf = function(str3) {
              var buf = new utils.Buf8(str3.length);
              for (var i3 = 0, len2 = buf.length; i3 < len2; i3++) {
                buf[i3] = str3.charCodeAt(i3);
              }
              return buf;
            };
            exports2.buf2string = function(buf, max2) {
              var i3, out, c6, c_len;
              var len2 = max2 || buf.length;
              var utf16buf = new Array(len2 * 2);
              for (out = 0, i3 = 0; i3 < len2; ) {
                c6 = buf[i3++];
                if (c6 < 128) {
                  utf16buf[out++] = c6;
                  continue;
                }
                c_len = _utf8len[c6];
                if (c_len > 4) {
                  utf16buf[out++] = 65533;
                  i3 += c_len - 1;
                  continue;
                }
                c6 &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;
                while (c_len > 1 && i3 < len2) {
                  c6 = c6 << 6 | buf[i3++] & 63;
                  c_len--;
                }
                if (c_len > 1) {
                  utf16buf[out++] = 65533;
                  continue;
                }
                if (c6 < 65536) {
                  utf16buf[out++] = c6;
                } else {
                  c6 -= 65536;
                  utf16buf[out++] = 55296 | c6 >> 10 & 1023;
                  utf16buf[out++] = 56320 | c6 & 1023;
                }
              }
              return buf2binstring(utf16buf, out);
            };
            exports2.utf8border = function(buf, max2) {
              var pos;
              max2 = max2 || buf.length;
              if (max2 > buf.length) {
                max2 = buf.length;
              }
              pos = max2 - 1;
              while (pos >= 0 && (buf[pos] & 192) === 128) {
                pos--;
              }
              if (pos < 0) {
                return max2;
              }
              if (pos === 0) {
                return max2;
              }
              return pos + _utf8len[buf[pos]] > max2 ? pos : max2;
            };
          },
          { "./common": 1 }
        ],
        3: [
          function(require2, module2, exports2) {
            "use strict";
            function adler32(adler, buf, len2, pos) {
              var s1 = adler & 65535 | 0, s22 = adler >>> 16 & 65535 | 0, n3 = 0;
              while (len2 !== 0) {
                n3 = len2 > 2e3 ? 2e3 : len2;
                len2 -= n3;
                do {
                  s1 = s1 + buf[pos++] | 0;
                  s22 = s22 + s1 | 0;
                } while (--n3);
                s1 %= 65521;
                s22 %= 65521;
              }
              return s1 | s22 << 16 | 0;
            }
            module2.exports = adler32;
          },
          {}
        ],
        4: [
          function(require2, module2, exports2) {
            "use strict";
            module2.exports = {
              /* Allowed flush values; see deflate() and inflate() below for details */
              Z_NO_FLUSH: 0,
              Z_PARTIAL_FLUSH: 1,
              Z_SYNC_FLUSH: 2,
              Z_FULL_FLUSH: 3,
              Z_FINISH: 4,
              Z_BLOCK: 5,
              Z_TREES: 6,
              /* Return codes for the compression/decompression functions. Negative values
               * are errors, positive values are used for special but normal events.
               */
              Z_OK: 0,
              Z_STREAM_END: 1,
              Z_NEED_DICT: 2,
              Z_ERRNO: -1,
              Z_STREAM_ERROR: -2,
              Z_DATA_ERROR: -3,
              //Z_MEM_ERROR:     -4,
              Z_BUF_ERROR: -5,
              //Z_VERSION_ERROR: -6,
              /* compression levels */
              Z_NO_COMPRESSION: 0,
              Z_BEST_SPEED: 1,
              Z_BEST_COMPRESSION: 9,
              Z_DEFAULT_COMPRESSION: -1,
              Z_FILTERED: 1,
              Z_HUFFMAN_ONLY: 2,
              Z_RLE: 3,
              Z_FIXED: 4,
              Z_DEFAULT_STRATEGY: 0,
              /* Possible values of the data_type field (though see inflate()) */
              Z_BINARY: 0,
              Z_TEXT: 1,
              //Z_ASCII:                1, // = Z_TEXT (deprecated)
              Z_UNKNOWN: 2,
              /* The deflate compression method */
              Z_DEFLATED: 8
              //Z_NULL:                 null // Use -1 or null inline, depending on var type
            };
          },
          {}
        ],
        5: [
          function(require2, module2, exports2) {
            "use strict";
            function makeTable() {
              var c6, table = [];
              for (var n3 = 0; n3 < 256; n3++) {
                c6 = n3;
                for (var k2 = 0; k2 < 8; k2++) {
                  c6 = c6 & 1 ? 3988292384 ^ c6 >>> 1 : c6 >>> 1;
                }
                table[n3] = c6;
              }
              return table;
            }
            var crcTable = makeTable();
            function crc32(crc, buf, len2, pos) {
              var t4 = crcTable, end = pos + len2;
              crc ^= -1;
              for (var i3 = pos; i3 < end; i3++) {
                crc = crc >>> 8 ^ t4[(crc ^ buf[i3]) & 255];
              }
              return crc ^ -1;
            }
            module2.exports = crc32;
          },
          {}
        ],
        6: [
          function(require2, module2, exports2) {
            "use strict";
            function GZheader() {
              this.text = 0;
              this.time = 0;
              this.xflags = 0;
              this.os = 0;
              this.extra = null;
              this.extra_len = 0;
              this.name = "";
              this.comment = "";
              this.hcrc = 0;
              this.done = false;
            }
            module2.exports = GZheader;
          },
          {}
        ],
        7: [
          function(require2, module2, exports2) {
            "use strict";
            var BAD = 30;
            var TYPE = 12;
            module2.exports = function inflate_fast(strm, start2) {
              var state;
              var _in;
              var last;
              var _out;
              var beg;
              var end;
              var dmax;
              var wsize;
              var whave;
              var wnext;
              var s_window;
              var hold;
              var bits;
              var lcode;
              var dcode;
              var lmask;
              var dmask;
              var here;
              var op;
              var len2;
              var dist2;
              var from;
              var from_source;
              var input, output;
              state = strm.state;
              _in = strm.next_in;
              input = strm.input;
              last = _in + (strm.avail_in - 5);
              _out = strm.next_out;
              output = strm.output;
              beg = _out - (start2 - strm.avail_out);
              end = _out + (strm.avail_out - 257);
              dmax = state.dmax;
              wsize = state.wsize;
              whave = state.whave;
              wnext = state.wnext;
              s_window = state.window;
              hold = state.hold;
              bits = state.bits;
              lcode = state.lencode;
              dcode = state.distcode;
              lmask = (1 << state.lenbits) - 1;
              dmask = (1 << state.distbits) - 1;
              top: do {
                if (bits < 15) {
                  hold += input[_in++] << bits;
                  bits += 8;
                  hold += input[_in++] << bits;
                  bits += 8;
                }
                here = lcode[hold & lmask];
                dolen: for (; ; ) {
                  op = here >>> 24;
                  hold >>>= op;
                  bits -= op;
                  op = here >>> 16 & 255;
                  if (op === 0) {
                    output[_out++] = here & 65535;
                  } else if (op & 16) {
                    len2 = here & 65535;
                    op &= 15;
                    if (op) {
                      if (bits < op) {
                        hold += input[_in++] << bits;
                        bits += 8;
                      }
                      len2 += hold & (1 << op) - 1;
                      hold >>>= op;
                      bits -= op;
                    }
                    if (bits < 15) {
                      hold += input[_in++] << bits;
                      bits += 8;
                      hold += input[_in++] << bits;
                      bits += 8;
                    }
                    here = dcode[hold & dmask];
                    dodist: for (; ; ) {
                      op = here >>> 24;
                      hold >>>= op;
                      bits -= op;
                      op = here >>> 16 & 255;
                      if (op & 16) {
                        dist2 = here & 65535;
                        op &= 15;
                        if (bits < op) {
                          hold += input[_in++] << bits;
                          bits += 8;
                          if (bits < op) {
                            hold += input[_in++] << bits;
                            bits += 8;
                          }
                        }
                        dist2 += hold & (1 << op) - 1;
                        if (dist2 > dmax) {
                          strm.msg = "invalid distance too far back";
                          state.mode = BAD;
                          break top;
                        }
                        hold >>>= op;
                        bits -= op;
                        op = _out - beg;
                        if (dist2 > op) {
                          op = dist2 - op;
                          if (op > whave) {
                            if (state.sane) {
                              strm.msg = "invalid distance too far back";
                              state.mode = BAD;
                              break top;
                            }
                          }
                          from = 0;
                          from_source = s_window;
                          if (wnext === 0) {
                            from += wsize - op;
                            if (op < len2) {
                              len2 -= op;
                              do {
                                output[_out++] = s_window[from++];
                              } while (--op);
                              from = _out - dist2;
                              from_source = output;
                            }
                          } else if (wnext < op) {
                            from += wsize + wnext - op;
                            op -= wnext;
                            if (op < len2) {
                              len2 -= op;
                              do {
                                output[_out++] = s_window[from++];
                              } while (--op);
                              from = 0;
                              if (wnext < len2) {
                                op = wnext;
                                len2 -= op;
                                do {
                                  output[_out++] = s_window[from++];
                                } while (--op);
                                from = _out - dist2;
                                from_source = output;
                              }
                            }
                          } else {
                            from += wnext - op;
                            if (op < len2) {
                              len2 -= op;
                              do {
                                output[_out++] = s_window[from++];
                              } while (--op);
                              from = _out - dist2;
                              from_source = output;
                            }
                          }
                          while (len2 > 2) {
                            output[_out++] = from_source[from++];
                            output[_out++] = from_source[from++];
                            output[_out++] = from_source[from++];
                            len2 -= 3;
                          }
                          if (len2) {
                            output[_out++] = from_source[from++];
                            if (len2 > 1) {
                              output[_out++] = from_source[from++];
                            }
                          }
                        } else {
                          from = _out - dist2;
                          do {
                            output[_out++] = output[from++];
                            output[_out++] = output[from++];
                            output[_out++] = output[from++];
                            len2 -= 3;
                          } while (len2 > 2);
                          if (len2) {
                            output[_out++] = output[from++];
                            if (len2 > 1) {
                              output[_out++] = output[from++];
                            }
                          }
                        }
                      } else if ((op & 64) === 0) {
                        here = dcode[(here & 65535) + (hold & (1 << op) - 1)];
                        continue dodist;
                      } else {
                        strm.msg = "invalid distance code";
                        state.mode = BAD;
                        break top;
                      }
                      break;
                    }
                  } else if ((op & 64) === 0) {
                    here = lcode[(here & 65535) + (hold & (1 << op) - 1)];
                    continue dolen;
                  } else if (op & 32) {
                    state.mode = TYPE;
                    break top;
                  } else {
                    strm.msg = "invalid literal/length code";
                    state.mode = BAD;
                    break top;
                  }
                  break;
                }
              } while (_in < last && _out < end);
              len2 = bits >> 3;
              _in -= len2;
              bits -= len2 << 3;
              hold &= (1 << bits) - 1;
              strm.next_in = _in;
              strm.next_out = _out;
              strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);
              strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);
              state.hold = hold;
              state.bits = bits;
              return;
            };
          },
          {}
        ],
        8: [
          function(require2, module2, exports2) {
            "use strict";
            var utils = require2("../utils/common");
            var adler32 = require2("./adler32");
            var crc32 = require2("./crc32");
            var inflate_fast = require2("./inffast");
            var inflate_table = require2("./inftrees");
            var CODES = 0;
            var LENS = 1;
            var DISTS = 2;
            var Z_FINISH = 4;
            var Z_BLOCK = 5;
            var Z_TREES = 6;
            var Z_OK = 0;
            var Z_STREAM_END = 1;
            var Z_NEED_DICT = 2;
            var Z_STREAM_ERROR = -2;
            var Z_DATA_ERROR = -3;
            var Z_MEM_ERROR = -4;
            var Z_BUF_ERROR = -5;
            var Z_DEFLATED = 8;
            var HEAD = 1;
            var FLAGS = 2;
            var TIME = 3;
            var OS = 4;
            var EXLEN = 5;
            var EXTRA = 6;
            var NAME = 7;
            var COMMENT = 8;
            var HCRC = 9;
            var DICTID = 10;
            var DICT = 11;
            var TYPE = 12;
            var TYPEDO = 13;
            var STORED = 14;
            var COPY_ = 15;
            var COPY = 16;
            var TABLE = 17;
            var LENLENS = 18;
            var CODELENS = 19;
            var LEN_ = 20;
            var LEN = 21;
            var LENEXT = 22;
            var DIST = 23;
            var DISTEXT = 24;
            var MATCH = 25;
            var LIT = 26;
            var CHECK = 27;
            var LENGTH = 28;
            var DONE = 29;
            var BAD = 30;
            var MEM = 31;
            var SYNC = 32;
            var ENOUGH_LENS = 852;
            var ENOUGH_DISTS = 592;
            var MAX_WBITS = 15;
            var DEF_WBITS = MAX_WBITS;
            function zswap32(q) {
              return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);
            }
            function InflateState() {
              this.mode = 0;
              this.last = false;
              this.wrap = 0;
              this.havedict = false;
              this.flags = 0;
              this.dmax = 0;
              this.check = 0;
              this.total = 0;
              this.head = null;
              this.wbits = 0;
              this.wsize = 0;
              this.whave = 0;
              this.wnext = 0;
              this.window = null;
              this.hold = 0;
              this.bits = 0;
              this.length = 0;
              this.offset = 0;
              this.extra = 0;
              this.lencode = null;
              this.distcode = null;
              this.lenbits = 0;
              this.distbits = 0;
              this.ncode = 0;
              this.nlen = 0;
              this.ndist = 0;
              this.have = 0;
              this.next = null;
              this.lens = new utils.Buf16(
                320
              );
              this.work = new utils.Buf16(
                288
              );
              this.lendyn = null;
              this.distdyn = null;
              this.sane = 0;
              this.back = 0;
              this.was = 0;
            }
            function inflateResetKeep(strm) {
              var state;
              if (!strm || !strm.state) {
                return Z_STREAM_ERROR;
              }
              state = strm.state;
              strm.total_in = strm.total_out = state.total = 0;
              strm.msg = "";
              if (state.wrap) {
                strm.adler = state.wrap & 1;
              }
              state.mode = HEAD;
              state.last = 0;
              state.havedict = 0;
              state.dmax = 32768;
              state.head = null;
              state.hold = 0;
              state.bits = 0;
              state.lencode = state.lendyn = new utils.Buf32(
                ENOUGH_LENS
              );
              state.distcode = state.distdyn = new utils.Buf32(
                ENOUGH_DISTS
              );
              state.sane = 1;
              state.back = -1;
              return Z_OK;
            }
            function inflateReset(strm) {
              var state;
              if (!strm || !strm.state) {
                return Z_STREAM_ERROR;
              }
              state = strm.state;
              state.wsize = 0;
              state.whave = 0;
              state.wnext = 0;
              return inflateResetKeep(strm);
            }
            function inflateReset2(strm, windowBits) {
              var wrap;
              var state;
              if (!strm || !strm.state) {
                return Z_STREAM_ERROR;
              }
              state = strm.state;
              if (windowBits < 0) {
                wrap = 0;
                windowBits = -windowBits;
              } else {
                wrap = (windowBits >> 4) + 1;
                if (windowBits < 48) {
                  windowBits &= 15;
                }
              }
              if (windowBits && (windowBits < 8 || windowBits > 15)) {
                return Z_STREAM_ERROR;
              }
              if (state.window !== null && state.wbits !== windowBits) {
                state.window = null;
              }
              state.wrap = wrap;
              state.wbits = windowBits;
              return inflateReset(strm);
            }
            function inflateInit2(strm, windowBits) {
              var ret;
              var state;
              if (!strm) {
                return Z_STREAM_ERROR;
              }
              state = new InflateState();
              strm.state = state;
              state.window = null;
              ret = inflateReset2(strm, windowBits);
              if (ret !== Z_OK) {
                strm.state = null;
              }
              return ret;
            }
            function inflateInit(strm) {
              return inflateInit2(strm, DEF_WBITS);
            }
            var virgin = true;
            var lenfix, distfix;
            function fixedtables(state) {
              if (virgin) {
                var sym;
                lenfix = new utils.Buf32(512);
                distfix = new utils.Buf32(32);
                sym = 0;
                while (sym < 144) {
                  state.lens[sym++] = 8;
                }
                while (sym < 256) {
                  state.lens[sym++] = 9;
                }
                while (sym < 280) {
                  state.lens[sym++] = 7;
                }
                while (sym < 288) {
                  state.lens[sym++] = 8;
                }
                inflate_table(
                  LENS,
                  state.lens,
                  0,
                  288,
                  lenfix,
                  0,
                  state.work,
                  { bits: 9 }
                );
                sym = 0;
                while (sym < 32) {
                  state.lens[sym++] = 5;
                }
                inflate_table(
                  DISTS,
                  state.lens,
                  0,
                  32,
                  distfix,
                  0,
                  state.work,
                  { bits: 5 }
                );
                virgin = false;
              }
              state.lencode = lenfix;
              state.lenbits = 9;
              state.distcode = distfix;
              state.distbits = 5;
            }
            function updatewindow(strm, src, end, copy3) {
              var dist2;
              var state = strm.state;
              if (state.window === null) {
                state.wsize = 1 << state.wbits;
                state.wnext = 0;
                state.whave = 0;
                state.window = new utils.Buf8(state.wsize);
              }
              if (copy3 >= state.wsize) {
                utils.arraySet(
                  state.window,
                  src,
                  end - state.wsize,
                  state.wsize,
                  0
                );
                state.wnext = 0;
                state.whave = state.wsize;
              } else {
                dist2 = state.wsize - state.wnext;
                if (dist2 > copy3) {
                  dist2 = copy3;
                }
                utils.arraySet(
                  state.window,
                  src,
                  end - copy3,
                  dist2,
                  state.wnext
                );
                copy3 -= dist2;
                if (copy3) {
                  utils.arraySet(
                    state.window,
                    src,
                    end - copy3,
                    copy3,
                    0
                  );
                  state.wnext = copy3;
                  state.whave = state.wsize;
                } else {
                  state.wnext += dist2;
                  if (state.wnext === state.wsize) {
                    state.wnext = 0;
                  }
                  if (state.whave < state.wsize) {
                    state.whave += dist2;
                  }
                }
              }
              return 0;
            }
            function inflate(strm, flush2) {
              var state;
              var input, output;
              var next;
              var put;
              var have, left;
              var hold;
              var bits;
              var _in, _out;
              var copy3;
              var from;
              var from_source;
              var here = 0;
              var here_bits, here_op, here_val;
              var last_bits, last_op, last_val;
              var len2;
              var ret;
              var hbuf = new utils.Buf8(
                4
              );
              var opts;
              var n3;
              var order = (
                /* permutation of code lengths */
                [
                  16,
                  17,
                  18,
                  0,
                  8,
                  7,
                  9,
                  6,
                  10,
                  5,
                  11,
                  4,
                  12,
                  3,
                  13,
                  2,
                  14,
                  1,
                  15
                ]
              );
              if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
                return Z_STREAM_ERROR;
              }
              state = strm.state;
              if (state.mode === TYPE) {
                state.mode = TYPEDO;
              }
              put = strm.next_out;
              output = strm.output;
              left = strm.avail_out;
              next = strm.next_in;
              input = strm.input;
              have = strm.avail_in;
              hold = state.hold;
              bits = state.bits;
              _in = have;
              _out = left;
              ret = Z_OK;
              inf_leave: for (; ; ) {
                switch (state.mode) {
                  case HEAD:
                    if (state.wrap === 0) {
                      state.mode = TYPEDO;
                      break;
                    }
                    while (bits < 16) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    if (state.wrap & 2 && hold === 35615) {
                      state.check = 0;
                      hbuf[0] = hold & 255;
                      hbuf[1] = hold >>> 8 & 255;
                      state.check = crc32(
                        state.check,
                        hbuf,
                        2,
                        0
                      );
                      hold = 0;
                      bits = 0;
                      state.mode = FLAGS;
                      break;
                    }
                    state.flags = 0;
                    if (state.head) {
                      state.head.done = false;
                    }
                    if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) {
                      strm.msg = "incorrect header check";
                      state.mode = BAD;
                      break;
                    }
                    if ((hold & 15) !== Z_DEFLATED) {
                      strm.msg = "unknown compression method";
                      state.mode = BAD;
                      break;
                    }
                    hold >>>= 4;
                    bits -= 4;
                    len2 = (hold & 15) + 8;
                    if (state.wbits === 0) {
                      state.wbits = len2;
                    } else if (len2 > state.wbits) {
                      strm.msg = "invalid window size";
                      state.mode = BAD;
                      break;
                    }
                    state.dmax = 1 << len2;
                    strm.adler = state.check = 1;
                    state.mode = hold & 512 ? DICTID : TYPE;
                    hold = 0;
                    bits = 0;
                    break;
                  case FLAGS:
                    while (bits < 16) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    state.flags = hold;
                    if ((state.flags & 255) !== Z_DEFLATED) {
                      strm.msg = "unknown compression method";
                      state.mode = BAD;
                      break;
                    }
                    if (state.flags & 57344) {
                      strm.msg = "unknown header flags set";
                      state.mode = BAD;
                      break;
                    }
                    if (state.head) {
                      state.head.text = hold >> 8 & 1;
                    }
                    if (state.flags & 512) {
                      hbuf[0] = hold & 255;
                      hbuf[1] = hold >>> 8 & 255;
                      state.check = crc32(
                        state.check,
                        hbuf,
                        2,
                        0
                      );
                    }
                    hold = 0;
                    bits = 0;
                    state.mode = TIME;
                  /* falls through */
                  case TIME:
                    while (bits < 32) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    if (state.head) {
                      state.head.time = hold;
                    }
                    if (state.flags & 512) {
                      hbuf[0] = hold & 255;
                      hbuf[1] = hold >>> 8 & 255;
                      hbuf[2] = hold >>> 16 & 255;
                      hbuf[3] = hold >>> 24 & 255;
                      state.check = crc32(
                        state.check,
                        hbuf,
                        4,
                        0
                      );
                    }
                    hold = 0;
                    bits = 0;
                    state.mode = OS;
                  /* falls through */
                  case OS:
                    while (bits < 16) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    if (state.head) {
                      state.head.xflags = hold & 255;
                      state.head.os = hold >> 8;
                    }
                    if (state.flags & 512) {
                      hbuf[0] = hold & 255;
                      hbuf[1] = hold >>> 8 & 255;
                      state.check = crc32(
                        state.check,
                        hbuf,
                        2,
                        0
                      );
                    }
                    hold = 0;
                    bits = 0;
                    state.mode = EXLEN;
                  /* falls through */
                  case EXLEN:
                    if (state.flags & 1024) {
                      while (bits < 16) {
                        if (have === 0) {
                          break inf_leave;
                        }
                        have--;
                        hold += input[next++] << bits;
                        bits += 8;
                      }
                      state.length = hold;
                      if (state.head) {
                        state.head.extra_len = hold;
                      }
                      if (state.flags & 512) {
                        hbuf[0] = hold & 255;
                        hbuf[1] = hold >>> 8 & 255;
                        state.check = crc32(
                          state.check,
                          hbuf,
                          2,
                          0
                        );
                      }
                      hold = 0;
                      bits = 0;
                    } else if (state.head) {
                      state.head.extra = null;
                    }
                    state.mode = EXTRA;
                  /* falls through */
                  case EXTRA:
                    if (state.flags & 1024) {
                      copy3 = state.length;
                      if (copy3 > have) {
                        copy3 = have;
                      }
                      if (copy3) {
                        if (state.head) {
                          len2 = state.head.extra_len - state.length;
                          if (!state.head.extra) {
                            state.head.extra = new Array(
                              state.head.extra_len
                            );
                          }
                          utils.arraySet(
                            state.head.extra,
                            input,
                            next,
                            // extra field is limited to 65536 bytes
                            // - no need for additional size check
                            copy3,
                            /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
                            len2
                          );
                        }
                        if (state.flags & 512) {
                          state.check = crc32(
                            state.check,
                            input,
                            copy3,
                            next
                          );
                        }
                        have -= copy3;
                        next += copy3;
                        state.length -= copy3;
                      }
                      if (state.length) {
                        break inf_leave;
                      }
                    }
                    state.length = 0;
                    state.mode = NAME;
                  /* falls through */
                  case NAME:
                    if (state.flags & 2048) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      copy3 = 0;
                      do {
                        len2 = input[next + copy3++];
                        if (state.head && len2 && state.length < 65536) {
                          state.head.name += String.fromCharCode(len2);
                        }
                      } while (len2 && copy3 < have);
                      if (state.flags & 512) {
                        state.check = crc32(
                          state.check,
                          input,
                          copy3,
                          next
                        );
                      }
                      have -= copy3;
                      next += copy3;
                      if (len2) {
                        break inf_leave;
                      }
                    } else if (state.head) {
                      state.head.name = null;
                    }
                    state.length = 0;
                    state.mode = COMMENT;
                  /* falls through */
                  case COMMENT:
                    if (state.flags & 4096) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      copy3 = 0;
                      do {
                        len2 = input[next + copy3++];
                        if (state.head && len2 && state.length < 65536) {
                          state.head.comment += String.fromCharCode(len2);
                        }
                      } while (len2 && copy3 < have);
                      if (state.flags & 512) {
                        state.check = crc32(
                          state.check,
                          input,
                          copy3,
                          next
                        );
                      }
                      have -= copy3;
                      next += copy3;
                      if (len2) {
                        break inf_leave;
                      }
                    } else if (state.head) {
                      state.head.comment = null;
                    }
                    state.mode = HCRC;
                  /* falls through */
                  case HCRC:
                    if (state.flags & 512) {
                      while (bits < 16) {
                        if (have === 0) {
                          break inf_leave;
                        }
                        have--;
                        hold += input[next++] << bits;
                        bits += 8;
                      }
                      if (hold !== (state.check & 65535)) {
                        strm.msg = "header crc mismatch";
                        state.mode = BAD;
                        break;
                      }
                      hold = 0;
                      bits = 0;
                    }
                    if (state.head) {
                      state.head.hcrc = state.flags >> 9 & 1;
                      state.head.done = true;
                    }
                    strm.adler = state.check = 0;
                    state.mode = TYPE;
                    break;
                  case DICTID:
                    while (bits < 32) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    strm.adler = state.check = zswap32(hold);
                    hold = 0;
                    bits = 0;
                    state.mode = DICT;
                  /* falls through */
                  case DICT:
                    if (state.havedict === 0) {
                      strm.next_out = put;
                      strm.avail_out = left;
                      strm.next_in = next;
                      strm.avail_in = have;
                      state.hold = hold;
                      state.bits = bits;
                      return Z_NEED_DICT;
                    }
                    strm.adler = state.check = 1;
                    state.mode = TYPE;
                  /* falls through */
                  case TYPE:
                    if (flush2 === Z_BLOCK || flush2 === Z_TREES) {
                      break inf_leave;
                    }
                  /* falls through */
                  case TYPEDO:
                    if (state.last) {
                      hold >>>= bits & 7;
                      bits -= bits & 7;
                      state.mode = CHECK;
                      break;
                    }
                    while (bits < 3) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    state.last = hold & 1;
                    hold >>>= 1;
                    bits -= 1;
                    switch (hold & 3) {
                      case 0:
                        state.mode = STORED;
                        break;
                      case 1:
                        fixedtables(state);
                        state.mode = LEN_;
                        if (flush2 === Z_TREES) {
                          hold >>>= 2;
                          bits -= 2;
                          break inf_leave;
                        }
                        break;
                      case 2:
                        state.mode = TABLE;
                        break;
                      case 3:
                        strm.msg = "invalid block type";
                        state.mode = BAD;
                    }
                    hold >>>= 2;
                    bits -= 2;
                    break;
                  case STORED:
                    hold >>>= bits & 7;
                    bits -= bits & 7;
                    while (bits < 32) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {
                      strm.msg = "invalid stored block lengths";
                      state.mode = BAD;
                      break;
                    }
                    state.length = hold & 65535;
                    hold = 0;
                    bits = 0;
                    state.mode = COPY_;
                    if (flush2 === Z_TREES) {
                      break inf_leave;
                    }
                  /* falls through */
                  case COPY_:
                    state.mode = COPY;
                  /* falls through */
                  case COPY:
                    copy3 = state.length;
                    if (copy3) {
                      if (copy3 > have) {
                        copy3 = have;
                      }
                      if (copy3 > left) {
                        copy3 = left;
                      }
                      if (copy3 === 0) {
                        break inf_leave;
                      }
                      utils.arraySet(
                        output,
                        input,
                        next,
                        copy3,
                        put
                      );
                      have -= copy3;
                      next += copy3;
                      left -= copy3;
                      put += copy3;
                      state.length -= copy3;
                      break;
                    }
                    state.mode = TYPE;
                    break;
                  case TABLE:
                    while (bits < 14) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    state.nlen = (hold & 31) + 257;
                    hold >>>= 5;
                    bits -= 5;
                    state.ndist = (hold & 31) + 1;
                    hold >>>= 5;
                    bits -= 5;
                    state.ncode = (hold & 15) + 4;
                    hold >>>= 4;
                    bits -= 4;
                    if (state.nlen > 286 || state.ndist > 30) {
                      strm.msg = "too many length or distance symbols";
                      state.mode = BAD;
                      break;
                    }
                    state.have = 0;
                    state.mode = LENLENS;
                  /* falls through */
                  case LENLENS:
                    while (state.have < state.ncode) {
                      while (bits < 3) {
                        if (have === 0) {
                          break inf_leave;
                        }
                        have--;
                        hold += input[next++] << bits;
                        bits += 8;
                      }
                      state.lens[order[state.have++]] = hold & 7;
                      hold >>>= 3;
                      bits -= 3;
                    }
                    while (state.have < 19) {
                      state.lens[order[state.have++]] = 0;
                    }
                    state.lencode = state.lendyn;
                    state.lenbits = 7;
                    opts = { bits: state.lenbits };
                    ret = inflate_table(
                      CODES,
                      state.lens,
                      0,
                      19,
                      state.lencode,
                      0,
                      state.work,
                      opts
                    );
                    state.lenbits = opts.bits;
                    if (ret) {
                      strm.msg = "invalid code lengths set";
                      state.mode = BAD;
                      break;
                    }
                    state.have = 0;
                    state.mode = CODELENS;
                  /* falls through */
                  case CODELENS:
                    while (state.have < state.nlen + state.ndist) {
                      for (; ; ) {
                        here = state.lencode[hold & (1 << state.lenbits) - 1];
                        here_bits = here >>> 24;
                        here_op = here >>> 16 & 255;
                        here_val = here & 65535;
                        if (here_bits <= bits) {
                          break;
                        }
                        if (have === 0) {
                          break inf_leave;
                        }
                        have--;
                        hold += input[next++] << bits;
                        bits += 8;
                      }
                      if (here_val < 16) {
                        hold >>>= here_bits;
                        bits -= here_bits;
                        state.lens[state.have++] = here_val;
                      } else {
                        if (here_val === 16) {
                          n3 = here_bits + 2;
                          while (bits < n3) {
                            if (have === 0) {
                              break inf_leave;
                            }
                            have--;
                            hold += input[next++] << bits;
                            bits += 8;
                          }
                          hold >>>= here_bits;
                          bits -= here_bits;
                          if (state.have === 0) {
                            strm.msg = "invalid bit length repeat";
                            state.mode = BAD;
                            break;
                          }
                          len2 = state.lens[state.have - 1];
                          copy3 = 3 + (hold & 3);
                          hold >>>= 2;
                          bits -= 2;
                        } else if (here_val === 17) {
                          n3 = here_bits + 3;
                          while (bits < n3) {
                            if (have === 0) {
                              break inf_leave;
                            }
                            have--;
                            hold += input[next++] << bits;
                            bits += 8;
                          }
                          hold >>>= here_bits;
                          bits -= here_bits;
                          len2 = 0;
                          copy3 = 3 + (hold & 7);
                          hold >>>= 3;
                          bits -= 3;
                        } else {
                          n3 = here_bits + 7;
                          while (bits < n3) {
                            if (have === 0) {
                              break inf_leave;
                            }
                            have--;
                            hold += input[next++] << bits;
                            bits += 8;
                          }
                          hold >>>= here_bits;
                          bits -= here_bits;
                          len2 = 0;
                          copy3 = 11 + (hold & 127);
                          hold >>>= 7;
                          bits -= 7;
                        }
                        if (state.have + copy3 > state.nlen + state.ndist) {
                          strm.msg = "invalid bit length repeat";
                          state.mode = BAD;
                          break;
                        }
                        while (copy3--) {
                          state.lens[state.have++] = len2;
                        }
                      }
                    }
                    if (state.mode === BAD) {
                      break;
                    }
                    if (state.lens[256] === 0) {
                      strm.msg = "invalid code -- missing end-of-block";
                      state.mode = BAD;
                      break;
                    }
                    state.lenbits = 9;
                    opts = { bits: state.lenbits };
                    ret = inflate_table(
                      LENS,
                      state.lens,
                      0,
                      state.nlen,
                      state.lencode,
                      0,
                      state.work,
                      opts
                    );
                    state.lenbits = opts.bits;
                    if (ret) {
                      strm.msg = "invalid literal/lengths set";
                      state.mode = BAD;
                      break;
                    }
                    state.distbits = 6;
                    state.distcode = state.distdyn;
                    opts = { bits: state.distbits };
                    ret = inflate_table(
                      DISTS,
                      state.lens,
                      state.nlen,
                      state.ndist,
                      state.distcode,
                      0,
                      state.work,
                      opts
                    );
                    state.distbits = opts.bits;
                    if (ret) {
                      strm.msg = "invalid distances set";
                      state.mode = BAD;
                      break;
                    }
                    state.mode = LEN_;
                    if (flush2 === Z_TREES) {
                      break inf_leave;
                    }
                  /* falls through */
                  case LEN_:
                    state.mode = LEN;
                  /* falls through */
                  case LEN:
                    if (have >= 6 && left >= 258) {
                      strm.next_out = put;
                      strm.avail_out = left;
                      strm.next_in = next;
                      strm.avail_in = have;
                      state.hold = hold;
                      state.bits = bits;
                      inflate_fast(strm, _out);
                      put = strm.next_out;
                      output = strm.output;
                      left = strm.avail_out;
                      next = strm.next_in;
                      input = strm.input;
                      have = strm.avail_in;
                      hold = state.hold;
                      bits = state.bits;
                      if (state.mode === TYPE) {
                        state.back = -1;
                      }
                      break;
                    }
                    state.back = 0;
                    for (; ; ) {
                      here = state.lencode[hold & (1 << state.lenbits) - 1];
                      here_bits = here >>> 24;
                      here_op = here >>> 16 & 255;
                      here_val = here & 65535;
                      if (here_bits <= bits) {
                        break;
                      }
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    if (here_op && (here_op & 240) === 0) {
                      last_bits = here_bits;
                      last_op = here_op;
                      last_val = here_val;
                      for (; ; ) {
                        here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
                        here_bits = here >>> 24;
                        here_op = here >>> 16 & 255;
                        here_val = here & 65535;
                        if (last_bits + here_bits <= bits) {
                          break;
                        }
                        if (have === 0) {
                          break inf_leave;
                        }
                        have--;
                        hold += input[next++] << bits;
                        bits += 8;
                      }
                      hold >>>= last_bits;
                      bits -= last_bits;
                      state.back += last_bits;
                    }
                    hold >>>= here_bits;
                    bits -= here_bits;
                    state.back += here_bits;
                    state.length = here_val;
                    if (here_op === 0) {
                      state.mode = LIT;
                      break;
                    }
                    if (here_op & 32) {
                      state.back = -1;
                      state.mode = TYPE;
                      break;
                    }
                    if (here_op & 64) {
                      strm.msg = "invalid literal/length code";
                      state.mode = BAD;
                      break;
                    }
                    state.extra = here_op & 15;
                    state.mode = LENEXT;
                  /* falls through */
                  case LENEXT:
                    if (state.extra) {
                      n3 = state.extra;
                      while (bits < n3) {
                        if (have === 0) {
                          break inf_leave;
                        }
                        have--;
                        hold += input[next++] << bits;
                        bits += 8;
                      }
                      state.length += hold & (1 << state.extra) - 1;
                      hold >>>= state.extra;
                      bits -= state.extra;
                      state.back += state.extra;
                    }
                    state.was = state.length;
                    state.mode = DIST;
                  /* falls through */
                  case DIST:
                    for (; ; ) {
                      here = state.distcode[hold & (1 << state.distbits) - 1];
                      here_bits = here >>> 24;
                      here_op = here >>> 16 & 255;
                      here_val = here & 65535;
                      if (here_bits <= bits) {
                        break;
                      }
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    if ((here_op & 240) === 0) {
                      last_bits = here_bits;
                      last_op = here_op;
                      last_val = here_val;
                      for (; ; ) {
                        here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
                        here_bits = here >>> 24;
                        here_op = here >>> 16 & 255;
                        here_val = here & 65535;
                        if (last_bits + here_bits <= bits) {
                          break;
                        }
                        if (have === 0) {
                          break inf_leave;
                        }
                        have--;
                        hold += input[next++] << bits;
                        bits += 8;
                      }
                      hold >>>= last_bits;
                      bits -= last_bits;
                      state.back += last_bits;
                    }
                    hold >>>= here_bits;
                    bits -= here_bits;
                    state.back += here_bits;
                    if (here_op & 64) {
                      strm.msg = "invalid distance code";
                      state.mode = BAD;
                      break;
                    }
                    state.offset = here_val;
                    state.extra = here_op & 15;
                    state.mode = DISTEXT;
                  /* falls through */
                  case DISTEXT:
                    if (state.extra) {
                      n3 = state.extra;
                      while (bits < n3) {
                        if (have === 0) {
                          break inf_leave;
                        }
                        have--;
                        hold += input[next++] << bits;
                        bits += 8;
                      }
                      state.offset += hold & (1 << state.extra) - 1;
                      hold >>>= state.extra;
                      bits -= state.extra;
                      state.back += state.extra;
                    }
                    if (state.offset > state.dmax) {
                      strm.msg = "invalid distance too far back";
                      state.mode = BAD;
                      break;
                    }
                    state.mode = MATCH;
                  /* falls through */
                  case MATCH:
                    if (left === 0) {
                      break inf_leave;
                    }
                    copy3 = _out - left;
                    if (state.offset > copy3) {
                      copy3 = state.offset - copy3;
                      if (copy3 > state.whave) {
                        if (state.sane) {
                          strm.msg = "invalid distance too far back";
                          state.mode = BAD;
                          break;
                        }
                      }
                      if (copy3 > state.wnext) {
                        copy3 -= state.wnext;
                        from = state.wsize - copy3;
                      } else {
                        from = state.wnext - copy3;
                      }
                      if (copy3 > state.length) {
                        copy3 = state.length;
                      }
                      from_source = state.window;
                    } else {
                      from_source = output;
                      from = put - state.offset;
                      copy3 = state.length;
                    }
                    if (copy3 > left) {
                      copy3 = left;
                    }
                    left -= copy3;
                    state.length -= copy3;
                    do {
                      output[put++] = from_source[from++];
                    } while (--copy3);
                    if (state.length === 0) {
                      state.mode = LEN;
                    }
                    break;
                  case LIT:
                    if (left === 0) {
                      break inf_leave;
                    }
                    output[put++] = state.length;
                    left--;
                    state.mode = LEN;
                    break;
                  case CHECK:
                    if (state.wrap) {
                      while (bits < 32) {
                        if (have === 0) {
                          break inf_leave;
                        }
                        have--;
                        hold |= input[next++] << bits;
                        bits += 8;
                      }
                      _out -= left;
                      strm.total_out += _out;
                      state.total += _out;
                      if (_out) {
                        strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/
                        state.flags ? crc32(
                          state.check,
                          output,
                          _out,
                          put - _out
                        ) : adler32(
                          state.check,
                          output,
                          _out,
                          put - _out
                        );
                      }
                      _out = left;
                      if ((state.flags ? hold : zswap32(hold)) !== state.check) {
                        strm.msg = "incorrect data check";
                        state.mode = BAD;
                        break;
                      }
                      hold = 0;
                      bits = 0;
                    }
                    state.mode = LENGTH;
                  /* falls through */
                  case LENGTH:
                    if (state.wrap && state.flags) {
                      while (bits < 32) {
                        if (have === 0) {
                          break inf_leave;
                        }
                        have--;
                        hold += input[next++] << bits;
                        bits += 8;
                      }
                      if (hold !== (state.total & 4294967295)) {
                        strm.msg = "incorrect length check";
                        state.mode = BAD;
                        break;
                      }
                      hold = 0;
                      bits = 0;
                    }
                    state.mode = DONE;
                  /* falls through */
                  case DONE:
                    ret = Z_STREAM_END;
                    break inf_leave;
                  case BAD:
                    ret = Z_DATA_ERROR;
                    break inf_leave;
                  case MEM:
                    return Z_MEM_ERROR;
                  case SYNC:
                  /* falls through */
                  default:
                    return Z_STREAM_ERROR;
                }
              }
              strm.next_out = put;
              strm.avail_out = left;
              strm.next_in = next;
              strm.avail_in = have;
              state.hold = hold;
              state.bits = bits;
              if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush2 !== Z_FINISH)) {
                if (updatewindow(
                  strm,
                  strm.output,
                  strm.next_out,
                  _out - strm.avail_out
                )) {
                  state.mode = MEM;
                  return Z_MEM_ERROR;
                }
              }
              _in -= strm.avail_in;
              _out -= strm.avail_out;
              strm.total_in += _in;
              strm.total_out += _out;
              state.total += _out;
              if (state.wrap && _out) {
                strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
                state.flags ? crc32(
                  state.check,
                  output,
                  _out,
                  strm.next_out - _out
                ) : adler32(
                  state.check,
                  output,
                  _out,
                  strm.next_out - _out
                );
              }
              strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
              if ((_in === 0 && _out === 0 || flush2 === Z_FINISH) && ret === Z_OK) {
                ret = Z_BUF_ERROR;
              }
              return ret;
            }
            function inflateEnd(strm) {
              if (!strm || !strm.state) {
                return Z_STREAM_ERROR;
              }
              var state = strm.state;
              if (state.window) {
                state.window = null;
              }
              strm.state = null;
              return Z_OK;
            }
            function inflateGetHeader(strm, head2) {
              var state;
              if (!strm || !strm.state) {
                return Z_STREAM_ERROR;
              }
              state = strm.state;
              if ((state.wrap & 2) === 0) {
                return Z_STREAM_ERROR;
              }
              state.head = head2;
              head2.done = false;
              return Z_OK;
            }
            function inflateSetDictionary(strm, dictionary) {
              var dictLength = dictionary.length;
              var state;
              var dictid;
              var ret;
              if (!strm || !strm.state) {
                return Z_STREAM_ERROR;
              }
              state = strm.state;
              if (state.wrap !== 0 && state.mode !== DICT) {
                return Z_STREAM_ERROR;
              }
              if (state.mode === DICT) {
                dictid = 1;
                dictid = adler32(
                  dictid,
                  dictionary,
                  dictLength,
                  0
                );
                if (dictid !== state.check) {
                  return Z_DATA_ERROR;
                }
              }
              ret = updatewindow(
                strm,
                dictionary,
                dictLength,
                dictLength
              );
              if (ret) {
                state.mode = MEM;
                return Z_MEM_ERROR;
              }
              state.havedict = 1;
              return Z_OK;
            }
            exports2.inflateReset = inflateReset;
            exports2.inflateReset2 = inflateReset2;
            exports2.inflateResetKeep = inflateResetKeep;
            exports2.inflateInit = inflateInit;
            exports2.inflateInit2 = inflateInit2;
            exports2.inflate = inflate;
            exports2.inflateEnd = inflateEnd;
            exports2.inflateGetHeader = inflateGetHeader;
            exports2.inflateSetDictionary = inflateSetDictionary;
            exports2.inflateInfo = "pako inflate (from Nodeca project)";
          },
          {
            "../utils/common": 1,
            "./adler32": 3,
            "./crc32": 5,
            "./inffast": 7,
            "./inftrees": 9
          }
        ],
        9: [
          function(require2, module2, exports2) {
            "use strict";
            var utils = require2("../utils/common");
            var MAXBITS = 15;
            var ENOUGH_LENS = 852;
            var ENOUGH_DISTS = 592;
            var CODES = 0;
            var LENS = 1;
            var DISTS = 2;
            var lbase = [
              /* Length codes 257..285 base */
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              13,
              15,
              17,
              19,
              23,
              27,
              31,
              35,
              43,
              51,
              59,
              67,
              83,
              99,
              115,
              131,
              163,
              195,
              227,
              258,
              0,
              0
            ];
            var lext = [
              /* Length codes 257..285 extra */
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              16,
              17,
              17,
              17,
              17,
              18,
              18,
              18,
              18,
              19,
              19,
              19,
              19,
              20,
              20,
              20,
              20,
              21,
              21,
              21,
              21,
              16,
              72,
              78
            ];
            var dbase = [
              /* Distance codes 0..29 base */
              1,
              2,
              3,
              4,
              5,
              7,
              9,
              13,
              17,
              25,
              33,
              49,
              65,
              97,
              129,
              193,
              257,
              385,
              513,
              769,
              1025,
              1537,
              2049,
              3073,
              4097,
              6145,
              8193,
              12289,
              16385,
              24577,
              0,
              0
            ];
            var dext = [
              /* Distance codes 0..29 extra */
              16,
              16,
              16,
              16,
              17,
              17,
              18,
              18,
              19,
              19,
              20,
              20,
              21,
              21,
              22,
              22,
              23,
              23,
              24,
              24,
              25,
              25,
              26,
              26,
              27,
              27,
              28,
              28,
              29,
              29,
              64,
              64
            ];
            module2.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) {
              var bits = opts.bits;
              var len2 = 0;
              var sym = 0;
              var min2 = 0, max2 = 0;
              var root = 0;
              var curr = 0;
              var drop = 0;
              var left = 0;
              var used = 0;
              var huff = 0;
              var incr;
              var fill;
              var low;
              var mask;
              var next;
              var base = null;
              var base_index = 0;
              var end;
              var count = new utils.Buf16(MAXBITS + 1);
              var offs = new utils.Buf16(MAXBITS + 1);
              var extra = null;
              var extra_index = 0;
              var here_bits, here_op, here_val;
              for (len2 = 0; len2 <= MAXBITS; len2++) {
                count[len2] = 0;
              }
              for (sym = 0; sym < codes; sym++) {
                count[lens[lens_index + sym]]++;
              }
              root = bits;
              for (max2 = MAXBITS; max2 >= 1; max2--) {
                if (count[max2] !== 0) {
                  break;
                }
              }
              if (root > max2) {
                root = max2;
              }
              if (max2 === 0) {
                table[table_index++] = 1 << 24 | 64 << 16 | 0;
                table[table_index++] = 1 << 24 | 64 << 16 | 0;
                opts.bits = 1;
                return 0;
              }
              for (min2 = 1; min2 < max2; min2++) {
                if (count[min2] !== 0) {
                  break;
                }
              }
              if (root < min2) {
                root = min2;
              }
              left = 1;
              for (len2 = 1; len2 <= MAXBITS; len2++) {
                left <<= 1;
                left -= count[len2];
                if (left < 0) {
                  return -1;
                }
              }
              if (left > 0 && (type === CODES || max2 !== 1)) {
                return -1;
              }
              offs[1] = 0;
              for (len2 = 1; len2 < MAXBITS; len2++) {
                offs[len2 + 1] = offs[len2] + count[len2];
              }
              for (sym = 0; sym < codes; sym++) {
                if (lens[lens_index + sym] !== 0) {
                  work[offs[lens[lens_index + sym]]++] = sym;
                }
              }
              if (type === CODES) {
                base = extra = work;
                end = 19;
              } else if (type === LENS) {
                base = lbase;
                base_index -= 257;
                extra = lext;
                extra_index -= 257;
                end = 256;
              } else {
                base = dbase;
                extra = dext;
                end = -1;
              }
              huff = 0;
              sym = 0;
              len2 = min2;
              next = table_index;
              curr = root;
              drop = 0;
              low = -1;
              used = 1 << root;
              mask = used - 1;
              if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
                return 1;
              }
              for (; ; ) {
                here_bits = len2 - drop;
                if (work[sym] < end) {
                  here_op = 0;
                  here_val = work[sym];
                } else if (work[sym] > end) {
                  here_op = extra[extra_index + work[sym]];
                  here_val = base[base_index + work[sym]];
                } else {
                  here_op = 32 + 64;
                  here_val = 0;
                }
                incr = 1 << len2 - drop;
                fill = 1 << curr;
                min2 = fill;
                do {
                  fill -= incr;
                  table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
                } while (fill !== 0);
                incr = 1 << len2 - 1;
                while (huff & incr) {
                  incr >>= 1;
                }
                if (incr !== 0) {
                  huff &= incr - 1;
                  huff += incr;
                } else {
                  huff = 0;
                }
                sym++;
                if (--count[len2] === 0) {
                  if (len2 === max2) {
                    break;
                  }
                  len2 = lens[lens_index + work[sym]];
                }
                if (len2 > root && (huff & mask) !== low) {
                  if (drop === 0) {
                    drop = root;
                  }
                  next += min2;
                  curr = len2 - drop;
                  left = 1 << curr;
                  while (curr + drop < max2) {
                    left -= count[curr + drop];
                    if (left <= 0) {
                      break;
                    }
                    curr++;
                    left <<= 1;
                  }
                  used += 1 << curr;
                  if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
                    return 1;
                  }
                  low = huff & mask;
                  table[low] = root << 24 | curr << 16 | next - table_index | 0;
                }
              }
              if (huff !== 0) {
                table[next + huff] = len2 - drop << 24 | 64 << 16 | 0;
              }
              opts.bits = root;
              return 0;
            };
          },
          { "../utils/common": 1 }
        ],
        10: [
          function(require2, module2, exports2) {
            "use strict";
            module2.exports = {
              2: "need dictionary",
              1: "stream end",
              0: "",
              "-1": "file error",
              "-2": "stream error",
              "-3": "data error",
              "-4": "insufficient memory",
              "-5": "buffer error",
              "-6": "incompatible version"
            };
          },
          {}
        ],
        11: [
          function(require2, module2, exports2) {
            "use strict";
            function ZStream() {
              this.input = null;
              this.next_in = 0;
              this.avail_in = 0;
              this.total_in = 0;
              this.output = null;
              this.next_out = 0;
              this.avail_out = 0;
              this.total_out = 0;
              this.msg = "";
              this.state = null;
              this.data_type = 2;
              this.adler = 0;
            }
            module2.exports = ZStream;
          },
          {}
        ],
        "/lib/inflate.js": [
          function(require2, module2, exports2) {
            "use strict";
            var zlib_inflate = require2("./zlib/inflate");
            var utils = require2("./utils/common");
            var strings = require2("./utils/strings");
            var c6 = require2("./zlib/constants");
            var msg = require2("./zlib/messages");
            var ZStream = require2("./zlib/zstream");
            var GZheader = require2("./zlib/gzheader");
            var toString = Object.prototype.toString;
            function Inflate(options) {
              if (!(this instanceof Inflate))
                return new Inflate(options);
              this.options = utils.assign(
                {
                  chunkSize: 16384,
                  windowBits: 0,
                  to: ""
                },
                options || {}
              );
              var opt = this.options;
              if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
                opt.windowBits = -opt.windowBits;
                if (opt.windowBits === 0) {
                  opt.windowBits = -15;
                }
              }
              if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
                opt.windowBits += 32;
              }
              if (opt.windowBits > 15 && opt.windowBits < 48) {
                if ((opt.windowBits & 15) === 0) {
                  opt.windowBits |= 15;
                }
              }
              this.err = 0;
              this.msg = "";
              this.ended = false;
              this.chunks = [];
              this.strm = new ZStream();
              this.strm.avail_out = 0;
              var status = zlib_inflate.inflateInit2(
                this.strm,
                opt.windowBits
              );
              if (status !== c6.Z_OK) {
                throw new Error(msg[status]);
              }
              this.header = new GZheader();
              zlib_inflate.inflateGetHeader(this.strm, this.header);
              if (opt.dictionary) {
                if (typeof opt.dictionary === "string") {
                  opt.dictionary = strings.string2buf(
                    opt.dictionary
                  );
                } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {
                  opt.dictionary = new Uint8Array(
                    opt.dictionary
                  );
                }
                if (opt.raw) {
                  status = zlib_inflate.inflateSetDictionary(
                    this.strm,
                    opt.dictionary
                  );
                  if (status !== c6.Z_OK) {
                    throw new Error(msg[status]);
                  }
                }
              }
            }
            Inflate.prototype.push = function(data, mode) {
              var strm = this.strm;
              var chunkSize = this.options.chunkSize;
              var dictionary = this.options.dictionary;
              var status, _mode;
              var next_out_utf8, tail, utf8str;
              var allowBufError = false;
              if (this.ended) {
                return false;
              }
              _mode = mode === ~~mode ? mode : mode === true ? c6.Z_FINISH : c6.Z_NO_FLUSH;
              if (typeof data === "string") {
                strm.input = strings.binstring2buf(data);
              } else if (toString.call(data) === "[object ArrayBuffer]") {
                strm.input = new Uint8Array(data);
              } else {
                strm.input = data;
              }
              strm.next_in = 0;
              strm.avail_in = strm.input.length;
              do {
                if (strm.avail_out === 0) {
                  strm.output = new utils.Buf8(chunkSize);
                  strm.next_out = 0;
                  strm.avail_out = chunkSize;
                }
                status = zlib_inflate.inflate(
                  strm,
                  c6.Z_NO_FLUSH
                );
                if (status === c6.Z_NEED_DICT && dictionary) {
                  status = zlib_inflate.inflateSetDictionary(
                    this.strm,
                    dictionary
                  );
                }
                if (status === c6.Z_BUF_ERROR && allowBufError === true) {
                  status = c6.Z_OK;
                  allowBufError = false;
                }
                if (status !== c6.Z_STREAM_END && status !== c6.Z_OK) {
                  this.onEnd(status);
                  this.ended = true;
                  return false;
                }
                if (strm.next_out) {
                  if (strm.avail_out === 0 || status === c6.Z_STREAM_END || strm.avail_in === 0 && (_mode === c6.Z_FINISH || _mode === c6.Z_SYNC_FLUSH)) {
                    if (this.options.to === "string") {
                      next_out_utf8 = strings.utf8border(
                        strm.output,
                        strm.next_out
                      );
                      tail = strm.next_out - next_out_utf8;
                      utf8str = strings.buf2string(
                        strm.output,
                        next_out_utf8
                      );
                      strm.next_out = tail;
                      strm.avail_out = chunkSize - tail;
                      if (tail) {
                        utils.arraySet(
                          strm.output,
                          strm.output,
                          next_out_utf8,
                          tail,
                          0
                        );
                      }
                      this.onData(utf8str);
                    } else {
                      this.onData(
                        utils.shrinkBuf(
                          strm.output,
                          strm.next_out
                        )
                      );
                    }
                  }
                }
                if (strm.avail_in === 0 && strm.avail_out === 0) {
                  allowBufError = true;
                }
              } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c6.Z_STREAM_END);
              if (status === c6.Z_STREAM_END) {
                _mode = c6.Z_FINISH;
              }
              if (_mode === c6.Z_FINISH) {
                status = zlib_inflate.inflateEnd(this.strm);
                this.onEnd(status);
                this.ended = true;
                return status === c6.Z_OK;
              }
              if (_mode === c6.Z_SYNC_FLUSH) {
                this.onEnd(c6.Z_OK);
                strm.avail_out = 0;
                return true;
              }
              return true;
            };
            Inflate.prototype.onData = function(chunk2) {
              this.chunks.push(chunk2);
            };
            Inflate.prototype.onEnd = function(status) {
              if (status === c6.Z_OK) {
                if (this.options.to === "string") {
                  this.result = this.chunks.join("");
                } else {
                  this.result = utils.flattenChunks(
                    this.chunks
                  );
                }
              }
              this.chunks = [];
              this.err = status;
              this.msg = this.strm.msg;
            };
            function inflate(input, options) {
              var inflator = new Inflate(options);
              inflator.push(input, true);
              if (inflator.err) {
                throw inflator.msg || msg[inflator.err];
              }
              return inflator.result;
            }
            function inflateRaw(input, options) {
              options = options || {};
              options.raw = true;
              return inflate(input, options);
            }
            exports2.Inflate = Inflate;
            exports2.inflate = inflate;
            exports2.inflateRaw = inflateRaw;
            exports2.ungzip = inflate;
          },
          {
            "./utils/common": 1,
            "./utils/strings": 2,
            "./zlib/constants": 4,
            "./zlib/gzheader": 6,
            "./zlib/inflate": 8,
            "./zlib/messages": 10,
            "./zlib/zstream": 11
          }
        ]
      },
      {},
      []
    )("/lib/inflate.js");
  })();

  // packages/global-styles-ui/build-module/font-library/lib/lib-font.browser.mjs
  var fetchFunction = globalThis.fetch;
  var Event2 = class {
    constructor(type, detail = {}, msg) {
      this.type = type;
      this.detail = detail;
      this.msg = msg;
      Object.defineProperty(this, `__mayPropagate`, {
        enumerable: false,
        writable: true
      });
      this.__mayPropagate = true;
    }
    preventDefault() {
    }
    stopPropagation() {
      this.__mayPropagate = false;
    }
    valueOf() {
      return this;
    }
    toString() {
      return this.msg ? `[${this.type} event]: ${this.msg}` : `[${this.type} event]`;
    }
  };
  var EventManager = class {
    constructor() {
      this.listeners = {};
    }
    addEventListener(type, listener, useCapture) {
      let bin = this.listeners[type] || [];
      if (useCapture) bin.unshift(listener);
      else bin.push(listener);
      this.listeners[type] = bin;
    }
    removeEventListener(type, listener) {
      let bin = this.listeners[type] || [];
      let pos = bin.findIndex((e3) => e3 === listener);
      if (pos > -1) {
        bin.splice(pos, 1);
        this.listeners[type] = bin;
      }
    }
    dispatch(event) {
      let bin = this.listeners[event.type];
      if (bin) {
        for (let l3 = 0, e3 = bin.length; l3 < e3; l3++) {
          if (!event.__mayPropagate) break;
          bin[l3](event);
        }
      }
    }
  };
  var startDate = (/* @__PURE__ */ new Date(`1904-01-01T00:00:00+0000`)).getTime();
  function asText(data) {
    return Array.from(data).map((v3) => String.fromCharCode(v3)).join(``);
  }
  var Parser = class {
    constructor(dict, dataview, name2) {
      this.name = (name2 || dict.tag || ``).trim();
      this.length = dict.length;
      this.start = dict.offset;
      this.offset = 0;
      this.data = dataview;
      [
        `getInt8`,
        `getUint8`,
        `getInt16`,
        `getUint16`,
        `getInt32`,
        `getUint32`,
        `getBigInt64`,
        `getBigUint64`
      ].forEach((name3) => {
        let fn = name3.replace(/get(Big)?/, "").toLowerCase();
        let increment = parseInt(name3.replace(/[^\d]/g, "")) / 8;
        Object.defineProperty(this, fn, {
          get: () => this.getValue(name3, increment)
        });
      });
    }
    get currentPosition() {
      return this.start + this.offset;
    }
    set currentPosition(position) {
      this.start = position;
      this.offset = 0;
    }
    skip(n3 = 0, bits = 8) {
      this.offset += n3 * bits / 8;
    }
    getValue(type, increment) {
      let pos = this.start + this.offset;
      this.offset += increment;
      try {
        return this.data[type](pos);
      } catch (e3) {
        console.error(`parser`, type, increment, this);
        console.error(`parser`, this.start, this.offset);
        throw e3;
      }
    }
    flags(n3) {
      if (n3 === 8 || n3 === 16 || n3 === 32 || n3 === 64) {
        return this[`uint${n3}`].toString(2).padStart(n3, 0).split(``).map((v3) => v3 === "1");
      }
      console.error(
        `Error parsing flags: flag types can only be 1, 2, 4, or 8 bytes long`
      );
      console.trace();
    }
    get tag() {
      const t4 = this.uint32;
      return asText([
        t4 >> 24 & 255,
        t4 >> 16 & 255,
        t4 >> 8 & 255,
        t4 & 255
      ]);
    }
    get fixed() {
      let major = this.int16;
      let minor = Math.round(1e3 * this.uint16 / 65356);
      return major + minor / 1e3;
    }
    get legacyFixed() {
      let major = this.uint16;
      let minor = this.uint16.toString(16).padStart(4, 0);
      return parseFloat(`${major}.${minor}`);
    }
    get uint24() {
      return (this.uint8 << 16) + (this.uint8 << 8) + this.uint8;
    }
    get uint128() {
      let value = 0;
      for (let i3 = 0; i3 < 5; i3++) {
        let byte = this.uint8;
        value = value * 128 + (byte & 127);
        if (byte < 128) break;
      }
      return value;
    }
    get longdatetime() {
      return new Date(startDate + 1e3 * parseInt(this.int64.toString()));
    }
    get fword() {
      return this.int16;
    }
    get ufword() {
      return this.uint16;
    }
    get Offset16() {
      return this.uint16;
    }
    get Offset32() {
      return this.uint32;
    }
    get F2DOT14() {
      const bits = p.uint16;
      const integer = [0, 1, -2, -1][bits >> 14];
      const fraction = bits & 16383;
      return integer + fraction / 16384;
    }
    verifyLength() {
      if (this.offset != this.length) {
        console.error(
          `unexpected parsed table size (${this.offset}) for "${this.name}" (expected ${this.length})`
        );
      }
    }
    readBytes(n3 = 0, position = 0, bits = 8, signed = false) {
      n3 = n3 || this.length;
      if (n3 === 0) return [];
      if (position) this.currentPosition = position;
      const fn = `${signed ? `` : `u`}int${bits}`, slice2 = [];
      while (n3--) slice2.push(this[fn]);
      return slice2;
    }
  };
  var ParsedData = class {
    constructor(parser) {
      const pGetter = { enumerable: false, get: () => parser };
      Object.defineProperty(this, `parser`, pGetter);
      const start2 = parser.currentPosition;
      const startGetter = { enumerable: false, get: () => start2 };
      Object.defineProperty(this, `start`, startGetter);
    }
    load(struct) {
      Object.keys(struct).forEach((p22) => {
        let props = Object.getOwnPropertyDescriptor(struct, p22);
        if (props.get) {
          this[p22] = props.get.bind(this);
        } else if (props.value !== void 0) {
          this[p22] = props.value;
        }
      });
      if (this.parser.length) {
        this.parser.verifyLength();
      }
    }
  };
  var SimpleTable = class extends ParsedData {
    constructor(dict, dataview, name2) {
      const { parser, start: start2 } = super(
        new Parser(dict, dataview, name2)
      );
      const pGetter = { enumerable: false, get: () => parser };
      Object.defineProperty(this, `p`, pGetter);
      const startGetter = { enumerable: false, get: () => start2 };
      Object.defineProperty(this, `tableStart`, startGetter);
    }
  };
  function lazy$1(object, property, getter) {
    let val;
    Object.defineProperty(object, property, {
      get: () => {
        if (val) return val;
        val = getter();
        return val;
      },
      enumerable: true
    });
  }
  var SFNT = class extends SimpleTable {
    constructor(font2, dataview, createTable2) {
      const { p: p22 } = super({ offset: 0, length: 12 }, dataview, `sfnt`);
      this.version = p22.uint32;
      this.numTables = p22.uint16;
      this.searchRange = p22.uint16;
      this.entrySelector = p22.uint16;
      this.rangeShift = p22.uint16;
      p22.verifyLength();
      this.directory = [...new Array(this.numTables)].map(
        (_) => new TableRecord(p22)
      );
      this.tables = {};
      this.directory.forEach((entry) => {
        const getter = () => createTable2(
          this.tables,
          {
            tag: entry.tag,
            offset: entry.offset,
            length: entry.length
          },
          dataview
        );
        lazy$1(this.tables, entry.tag.trim(), getter);
      });
    }
  };
  var TableRecord = class {
    constructor(p22) {
      this.tag = p22.tag;
      this.checksum = p22.uint32;
      this.offset = p22.uint32;
      this.length = p22.uint32;
    }
  };
  var gzipDecode = inflate_default.inflate || void 0;
  var nativeGzipDecode = void 0;
  var WOFF$1 = class extends SimpleTable {
    constructor(font2, dataview, createTable2) {
      const { p: p22 } = super({ offset: 0, length: 44 }, dataview, `woff`);
      this.signature = p22.tag;
      this.flavor = p22.uint32;
      this.length = p22.uint32;
      this.numTables = p22.uint16;
      p22.uint16;
      this.totalSfntSize = p22.uint32;
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
      this.metaOffset = p22.uint32;
      this.metaLength = p22.uint32;
      this.metaOrigLength = p22.uint32;
      this.privOffset = p22.uint32;
      this.privLength = p22.uint32;
      p22.verifyLength();
      this.directory = [...new Array(this.numTables)].map(
        (_) => new WoffTableDirectoryEntry(p22)
      );
      buildWoffLazyLookups(this, dataview, createTable2);
    }
  };
  var WoffTableDirectoryEntry = class {
    constructor(p22) {
      this.tag = p22.tag;
      this.offset = p22.uint32;
      this.compLength = p22.uint32;
      this.origLength = p22.uint32;
      this.origChecksum = p22.uint32;
    }
  };
  function buildWoffLazyLookups(woff, dataview, createTable2) {
    woff.tables = {};
    woff.directory.forEach((entry) => {
      lazy$1(woff.tables, entry.tag.trim(), () => {
        let offset = 0;
        let view2 = dataview;
        if (entry.compLength !== entry.origLength) {
          const data = dataview.buffer.slice(
            entry.offset,
            entry.offset + entry.compLength
          );
          let unpacked;
          if (gzipDecode) {
            unpacked = gzipDecode(new Uint8Array(data));
          } else if (nativeGzipDecode) {
            unpacked = nativeGzipDecode(new Uint8Array(data));
          } else {
            const msg = `no brotli decoder available to decode WOFF2 font`;
            if (font.onerror) font.onerror(msg);
            throw new Error(msg);
          }
          view2 = new DataView(unpacked.buffer);
        } else {
          offset = entry.offset;
        }
        return createTable2(
          woff.tables,
          { tag: entry.tag, offset, length: entry.origLength },
          view2
        );
      });
    });
  }
  var brotliDecode = unbrotli_default;
  var nativeBrotliDecode = void 0;
  var WOFF2$1 = class extends SimpleTable {
    constructor(font2, dataview, createTable2) {
      const { p: p22 } = super({ offset: 0, length: 48 }, dataview, `woff2`);
      this.signature = p22.tag;
      this.flavor = p22.uint32;
      this.length = p22.uint32;
      this.numTables = p22.uint16;
      p22.uint16;
      this.totalSfntSize = p22.uint32;
      this.totalCompressedSize = p22.uint32;
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
      this.metaOffset = p22.uint32;
      this.metaLength = p22.uint32;
      this.metaOrigLength = p22.uint32;
      this.privOffset = p22.uint32;
      this.privLength = p22.uint32;
      p22.verifyLength();
      this.directory = [...new Array(this.numTables)].map(
        (_) => new Woff2TableDirectoryEntry(p22)
      );
      let dictOffset = p22.currentPosition;
      this.directory[0].offset = 0;
      this.directory.forEach((e3, i3) => {
        let next = this.directory[i3 + 1];
        if (next) {
          next.offset = e3.offset + (e3.transformLength !== void 0 ? e3.transformLength : e3.origLength);
        }
      });
      let decoded;
      let buffer = dataview.buffer.slice(dictOffset);
      if (brotliDecode) {
        decoded = brotliDecode(new Uint8Array(buffer));
      } else if (nativeBrotliDecode) {
        decoded = new Uint8Array(nativeBrotliDecode(buffer));
      } else {
        const msg = `no brotli decoder available to decode WOFF2 font`;
        if (font2.onerror) font2.onerror(msg);
        throw new Error(msg);
      }
      buildWoff2LazyLookups(this, decoded, createTable2);
    }
  };
  var Woff2TableDirectoryEntry = class {
    constructor(p22) {
      this.flags = p22.uint8;
      const tagNumber = this.tagNumber = this.flags & 63;
      if (tagNumber === 63) {
        this.tag = p22.tag;
      } else {
        this.tag = getWOFF2Tag(tagNumber);
      }
      const transformVersion = this.transformVersion = (this.flags & 192) >> 6;
      let hasTransforms = transformVersion !== 0;
      if (this.tag === `glyf` || this.tag === `loca`) {
        hasTransforms = this.transformVersion !== 3;
      }
      this.origLength = p22.uint128;
      if (hasTransforms) {
        this.transformLength = p22.uint128;
      }
    }
  };
  function buildWoff2LazyLookups(woff2, decoded, createTable2) {
    woff2.tables = {};
    woff2.directory.forEach((entry) => {
      lazy$1(woff2.tables, entry.tag.trim(), () => {
        const start2 = entry.offset;
        const end = start2 + (entry.transformLength ? entry.transformLength : entry.origLength);
        const data = new DataView(decoded.slice(start2, end).buffer);
        try {
          return createTable2(
            woff2.tables,
            { tag: entry.tag, offset: 0, length: entry.origLength },
            data
          );
        } catch (e3) {
          console.error(e3);
        }
      });
    });
  }
  function getWOFF2Tag(flag) {
    return [
      `cmap`,
      `head`,
      `hhea`,
      `hmtx`,
      `maxp`,
      `name`,
      `OS/2`,
      `post`,
      `cvt `,
      `fpgm`,
      `glyf`,
      `loca`,
      `prep`,
      `CFF `,
      `VORG`,
      `EBDT`,
      `EBLC`,
      `gasp`,
      `hdmx`,
      `kern`,
      `LTSH`,
      `PCLT`,
      `VDMX`,
      `vhea`,
      `vmtx`,
      `BASE`,
      `GDEF`,
      `GPOS`,
      `GSUB`,
      `EBSC`,
      `JSTF`,
      `MATH`,
      `CBDT`,
      `CBLC`,
      `COLR`,
      `CPAL`,
      `SVG `,
      `sbix`,
      `acnt`,
      `avar`,
      `bdat`,
      `bloc`,
      `bsln`,
      `cvar`,
      `fdsc`,
      `feat`,
      `fmtx`,
      `fvar`,
      `gvar`,
      `hsty`,
      `just`,
      `lcar`,
      `mort`,
      `morx`,
      `opbd`,
      `prop`,
      `trak`,
      `Zapf`,
      `Silf`,
      `Glat`,
      `Gloc`,
      `Feat`,
      `Sill`
    ][flag & 63];
  }
  var tableClasses = {};
  var tableClassesLoaded = false;
  Promise.all([
    Promise.resolve().then(function() {
      return cmap$1;
    }),
    Promise.resolve().then(function() {
      return head$1;
    }),
    Promise.resolve().then(function() {
      return hhea$1;
    }),
    Promise.resolve().then(function() {
      return hmtx$1;
    }),
    Promise.resolve().then(function() {
      return maxp$1;
    }),
    Promise.resolve().then(function() {
      return name$1;
    }),
    Promise.resolve().then(function() {
      return OS2$1;
    }),
    Promise.resolve().then(function() {
      return post$1;
    }),
    Promise.resolve().then(function() {
      return BASE$1;
    }),
    Promise.resolve().then(function() {
      return GDEF$1;
    }),
    Promise.resolve().then(function() {
      return GSUB$1;
    }),
    Promise.resolve().then(function() {
      return GPOS$1;
    }),
    Promise.resolve().then(function() {
      return SVG$1;
    }),
    Promise.resolve().then(function() {
      return fvar$1;
    }),
    Promise.resolve().then(function() {
      return cvt$1;
    }),
    Promise.resolve().then(function() {
      return fpgm$1;
    }),
    Promise.resolve().then(function() {
      return gasp$1;
    }),
    Promise.resolve().then(function() {
      return glyf$1;
    }),
    Promise.resolve().then(function() {
      return loca$1;
    }),
    Promise.resolve().then(function() {
      return prep$1;
    }),
    Promise.resolve().then(function() {
      return CFF$1;
    }),
    Promise.resolve().then(function() {
      return CFF2$1;
    }),
    Promise.resolve().then(function() {
      return VORG$1;
    }),
    Promise.resolve().then(function() {
      return EBLC$1;
    }),
    Promise.resolve().then(function() {
      return EBDT$1;
    }),
    Promise.resolve().then(function() {
      return EBSC$1;
    }),
    Promise.resolve().then(function() {
      return CBLC$1;
    }),
    Promise.resolve().then(function() {
      return CBDT$1;
    }),
    Promise.resolve().then(function() {
      return sbix$1;
    }),
    Promise.resolve().then(function() {
      return COLR$1;
    }),
    Promise.resolve().then(function() {
      return CPAL$1;
    }),
    Promise.resolve().then(function() {
      return DSIG$1;
    }),
    Promise.resolve().then(function() {
      return hdmx$1;
    }),
    Promise.resolve().then(function() {
      return kern$1;
    }),
    Promise.resolve().then(function() {
      return LTSH$1;
    }),
    Promise.resolve().then(function() {
      return MERG$1;
    }),
    Promise.resolve().then(function() {
      return meta$1;
    }),
    Promise.resolve().then(function() {
      return PCLT$1;
    }),
    Promise.resolve().then(function() {
      return VDMX$1;
    }),
    Promise.resolve().then(function() {
      return vhea$1;
    }),
    Promise.resolve().then(function() {
      return vmtx$1;
    })
  ]).then((data) => {
    data.forEach((e3) => {
      let name2 = Object.keys(e3)[0];
      tableClasses[name2] = e3[name2];
    });
    tableClassesLoaded = true;
  });
  function createTable(tables, dict, dataview) {
    let name2 = dict.tag.replace(/[^\w\d]/g, ``);
    let Type = tableClasses[name2];
    if (Type) return new Type(dict, dataview, tables);
    console.warn(
      `lib-font has no definition for ${name2}. The table was skipped.`
    );
    return {};
  }
  function loadTableClasses() {
    let count = 0;
    function checkLoaded(resolve, reject) {
      if (!tableClassesLoaded) {
        if (count > 10) {
          return reject(new Error(`loading took too long`));
        }
        count++;
        return setTimeout(() => checkLoaded(resolve), 250);
      }
      resolve(createTable);
    }
    return new Promise((resolve, reject) => checkLoaded(resolve));
  }
  function getFontCSSFormat(path, errorOnStyle) {
    let pos = path.lastIndexOf(`.`);
    let ext = (path.substring(pos + 1) || ``).toLowerCase();
    let format6 = {
      ttf: `truetype`,
      otf: `opentype`,
      woff: `woff`,
      woff2: `woff2`
    }[ext];
    if (format6) return format6;
    let msg = {
      eot: `The .eot format is not supported: it died in January 12, 2016, when Microsoft retired all versions of IE that didn't already support WOFF.`,
      svg: `The .svg format is not supported: SVG fonts (not to be confused with OpenType with embedded SVG) were so bad we took the entire fonts chapter out of the SVG specification again.`,
      fon: `The .fon format is not supported: this is an ancient Windows bitmap font format.`,
      ttc: `Based on the current CSS specification, font collections are not (yet?) supported.`
    }[ext];
    if (!msg) msg = `${path} is not a known webfont format.`;
    if (errorOnStyle) {
      throw new Error(msg);
    } else {
      console.warn(`Could not load font: ${msg}`);
    }
  }
  async function setupFontFace(name2, url, options = {}) {
    if (!globalThis.document) return;
    let format6 = getFontCSSFormat(url, options.errorOnStyle);
    if (!format6) return;
    let style = document.createElement(`style`);
    style.className = `injected-by-Font-js`;
    let rules = [];
    if (options.styleRules) {
      rules = Object.entries(options.styleRules).map(
        ([key, value]) => `${key}: ${value};`
      );
    }
    style.textContent = `
@font-face {
    font-family: "${name2}";
    ${rules.join(
      `
	`
    )}
    src: url("${url}") format("${format6}");
}`;
    globalThis.document.head.appendChild(style);
    return style;
  }
  var TTF = [0, 1, 0, 0];
  var OTF = [79, 84, 84, 79];
  var WOFF = [119, 79, 70, 70];
  var WOFF2 = [119, 79, 70, 50];
  function match2(ar1, ar2) {
    if (ar1.length !== ar2.length) return;
    for (let i3 = 0; i3 < ar1.length; i3++) {
      if (ar1[i3] !== ar2[i3]) return;
    }
    return true;
  }
  function validFontFormat(dataview) {
    const LEAD_BYTES = [
      dataview.getUint8(0),
      dataview.getUint8(1),
      dataview.getUint8(2),
      dataview.getUint8(3)
    ];
    if (match2(LEAD_BYTES, TTF) || match2(LEAD_BYTES, OTF)) return `SFNT`;
    if (match2(LEAD_BYTES, WOFF)) return `WOFF`;
    if (match2(LEAD_BYTES, WOFF2)) return `WOFF2`;
  }
  function checkFetchResponseStatus(response) {
    if (!response.ok) {
      throw new Error(
        `HTTP ${response.status} - ${response.statusText}`
      );
    }
    return response;
  }
  var Font = class extends EventManager {
    constructor(name2, options = {}) {
      super();
      this.name = name2;
      this.options = options;
      this.metrics = false;
    }
    get src() {
      return this.__src;
    }
    set src(src) {
      this.__src = src;
      (async () => {
        if (globalThis.document && !this.options.skipStyleSheet) {
          await setupFontFace(this.name, src, this.options);
        }
        this.loadFont(src);
      })();
    }
    async loadFont(url, filename) {
      fetch(url).then(
        (response) => checkFetchResponseStatus(response) && response.arrayBuffer()
      ).then(
        (buffer) => this.fromDataBuffer(buffer, filename || url)
      ).catch((err) => {
        const evt = new Event2(
          `error`,
          err,
          `Failed to load font at ${filename || url}`
        );
        this.dispatch(evt);
        if (this.onerror) this.onerror(evt);
      });
    }
    async fromDataBuffer(buffer, filenameOrUrL) {
      this.fontData = new DataView(buffer);
      let type = validFontFormat(this.fontData);
      if (!type) {
        throw new Error(
          `${filenameOrUrL} is either an unsupported font format, or not a font at all.`
        );
      }
      await this.parseBasicData(type);
      const evt = new Event2("load", { font: this });
      this.dispatch(evt);
      if (this.onload) this.onload(evt);
    }
    async parseBasicData(type) {
      return loadTableClasses().then((createTable2) => {
        if (type === `SFNT`) {
          this.opentype = new SFNT(this, this.fontData, createTable2);
        }
        if (type === `WOFF`) {
          this.opentype = new WOFF$1(this, this.fontData, createTable2);
        }
        if (type === `WOFF2`) {
          this.opentype = new WOFF2$1(this, this.fontData, createTable2);
        }
        return this.opentype;
      });
    }
    getGlyphId(char) {
      return this.opentype.tables.cmap.getGlyphId(char);
    }
    reverse(glyphid) {
      return this.opentype.tables.cmap.reverse(glyphid);
    }
    supports(char) {
      return this.getGlyphId(char) !== 0;
    }
    supportsVariation(variation) {
      return this.opentype.tables.cmap.supportsVariation(variation) !== false;
    }
    measureText(text, size = 16) {
      if (this.__unloaded)
        throw new Error(
          "Cannot measure text: font was unloaded. Please reload before calling measureText()"
        );
      let d3 = document.createElement("div");
      d3.textContent = text;
      d3.style.fontFamily = this.name;
      d3.style.fontSize = `${size}px`;
      d3.style.color = `transparent`;
      d3.style.background = `transparent`;
      d3.style.top = `0`;
      d3.style.left = `0`;
      d3.style.position = `absolute`;
      document.body.appendChild(d3);
      let bbox = d3.getBoundingClientRect();
      document.body.removeChild(d3);
      const OS22 = this.opentype.tables["OS/2"];
      bbox.fontSize = size;
      bbox.ascender = OS22.sTypoAscender;
      bbox.descender = OS22.sTypoDescender;
      return bbox;
    }
    unload() {
      if (this.styleElement.parentNode) {
        this.styleElement.parentNode.removeElement(this.styleElement);
        const evt = new Event2("unload", { font: this });
        this.dispatch(evt);
        if (this.onunload) this.onunload(evt);
      }
      this._unloaded = true;
    }
    load() {
      if (this.__unloaded) {
        delete this.__unloaded;
        document.head.appendChild(this.styleElement);
        const evt = new Event2("load", { font: this });
        this.dispatch(evt);
        if (this.onload) this.onload(evt);
      }
    }
  };
  globalThis.Font = Font;
  var Subtable = class extends ParsedData {
    constructor(p22, plaformID, encodingID) {
      super(p22);
      this.plaformID = plaformID;
      this.encodingID = encodingID;
    }
  };
  var Format0 = class extends Subtable {
    constructor(p22, platformID, encodingID) {
      super(p22, platformID, encodingID);
      this.format = 0;
      this.length = p22.uint16;
      this.language = p22.uint16;
      this.glyphIdArray = [...new Array(256)].map((_) => p22.uint8);
    }
    supports(charCode) {
      if (charCode.charCodeAt) {
        charCode = -1;
        console.warn(
          `supports(character) not implemented for cmap subtable format 0. only supports(id) is implemented.`
        );
      }
      return 0 <= charCode && charCode <= 255;
    }
    reverse(glyphID) {
      console.warn(`reverse not implemented for cmap subtable format 0`);
      return {};
    }
    getSupportedCharCodes() {
      return [{ start: 1, end: 256 }];
    }
  };
  var Format2 = class extends Subtable {
    constructor(p22, platformID, encodingID) {
      super(p22, platformID, encodingID);
      this.format = 2;
      this.length = p22.uint16;
      this.language = p22.uint16;
      this.subHeaderKeys = [...new Array(256)].map((_) => p22.uint16);
      const subHeaderCount = Math.max(...this.subHeaderKeys);
      const subHeaderOffset = p22.currentPosition;
      lazy$1(this, `subHeaders`, () => {
        p22.currentPosition = subHeaderOffset;
        return [...new Array(subHeaderCount)].map(
          (_) => new SubHeader(p22)
        );
      });
      const glyphIndexOffset = subHeaderOffset + subHeaderCount * 8;
      lazy$1(this, `glyphIndexArray`, () => {
        p22.currentPosition = glyphIndexOffset;
        return [...new Array(subHeaderCount)].map((_) => p22.uint16);
      });
    }
    supports(charCode) {
      if (charCode.charCodeAt) {
        charCode = -1;
        console.warn(
          `supports(character) not implemented for cmap subtable format 2. only supports(id) is implemented.`
        );
      }
      const low = charCode && 255;
      const high = charCode && 65280;
      const subHeaderKey = this.subHeaders[high];
      const subheader = this.subHeaders[subHeaderKey];
      const first = subheader.firstCode;
      const last = first + subheader.entryCount;
      return first <= low && low <= last;
    }
    reverse(glyphID) {
      console.warn(`reverse not implemented for cmap subtable format 2`);
      return {};
    }
    getSupportedCharCodes(preservePropNames = false) {
      if (preservePropNames) {
        return this.subHeaders.map((h3) => ({
          firstCode: h3.firstCode,
          lastCode: h3.lastCode
        }));
      }
      return this.subHeaders.map((h3) => ({
        start: h3.firstCode,
        end: h3.lastCode
      }));
    }
  };
  var SubHeader = class {
    constructor(p22) {
      this.firstCode = p22.uint16;
      this.entryCount = p22.uint16;
      this.lastCode = this.first + this.entryCount;
      this.idDelta = p22.int16;
      this.idRangeOffset = p22.uint16;
    }
  };
  var Format4 = class extends Subtable {
    constructor(p22, platformID, encodingID) {
      super(p22, platformID, encodingID);
      this.format = 4;
      this.length = p22.uint16;
      this.language = p22.uint16;
      this.segCountX2 = p22.uint16;
      this.segCount = this.segCountX2 / 2;
      this.searchRange = p22.uint16;
      this.entrySelector = p22.uint16;
      this.rangeShift = p22.uint16;
      const endCodePosition = p22.currentPosition;
      lazy$1(
        this,
        `endCode`,
        () => p22.readBytes(this.segCount, endCodePosition, 16)
      );
      const startCodePosition = endCodePosition + 2 + this.segCountX2;
      lazy$1(
        this,
        `startCode`,
        () => p22.readBytes(this.segCount, startCodePosition, 16)
      );
      const idDeltaPosition = startCodePosition + this.segCountX2;
      lazy$1(
        this,
        `idDelta`,
        () => p22.readBytes(this.segCount, idDeltaPosition, 16, true)
      );
      const idRangePosition = idDeltaPosition + this.segCountX2;
      lazy$1(
        this,
        `idRangeOffset`,
        () => p22.readBytes(this.segCount, idRangePosition, 16)
      );
      const glyphIdArrayPosition = idRangePosition + this.segCountX2;
      const glyphIdArrayLength = this.length - (glyphIdArrayPosition - this.tableStart);
      lazy$1(
        this,
        `glyphIdArray`,
        () => p22.readBytes(glyphIdArrayLength, glyphIdArrayPosition, 16)
      );
      lazy$1(
        this,
        `segments`,
        () => this.buildSegments(idRangePosition, glyphIdArrayPosition, p22)
      );
    }
    buildSegments(idRangePosition, glyphIdArrayPosition, p22) {
      const build = (_, i3) => {
        let startCode = this.startCode[i3], endCode = this.endCode[i3], idDelta = this.idDelta[i3], idRangeOffset = this.idRangeOffset[i3], idRangeOffsetPointer = idRangePosition + 2 * i3, glyphIDs = [];
        if (idRangeOffset === 0) {
          for (let i22 = startCode + idDelta, e3 = endCode + idDelta; i22 <= e3; i22++) {
            glyphIDs.push(i22);
          }
        } else {
          for (let i22 = 0, e3 = endCode - startCode; i22 <= e3; i22++) {
            p22.currentPosition = idRangeOffsetPointer + idRangeOffset + i22 * 2;
            glyphIDs.push(p22.uint16);
          }
        }
        return {
          startCode,
          endCode,
          idDelta,
          idRangeOffset,
          glyphIDs
        };
      };
      return [...new Array(this.segCount)].map(build);
    }
    reverse(glyphID) {
      let s3 = this.segments.find((v3) => v3.glyphIDs.includes(glyphID));
      if (!s3) return {};
      const code = s3.startCode + s3.glyphIDs.indexOf(glyphID);
      return { code, unicode: String.fromCodePoint(code) };
    }
    getGlyphId(charCode) {
      if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
      if (55296 <= charCode && charCode <= 57343) return 0;
      if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535)
        return 0;
      let segment = this.segments.find(
        (s3) => s3.startCode <= charCode && charCode <= s3.endCode
      );
      if (!segment) return 0;
      return segment.glyphIDs[charCode - segment.startCode];
    }
    supports(charCode) {
      return this.getGlyphId(charCode) !== 0;
    }
    getSupportedCharCodes(preservePropNames = false) {
      if (preservePropNames) return this.segments;
      return this.segments.map((v3) => ({
        start: v3.startCode,
        end: v3.endCode
      }));
    }
  };
  var Format6 = class extends Subtable {
    constructor(p22, platformID, encodingID) {
      super(p22, platformID, encodingID);
      this.format = 6;
      this.length = p22.uint16;
      this.language = p22.uint16;
      this.firstCode = p22.uint16;
      this.entryCount = p22.uint16;
      this.lastCode = this.firstCode + this.entryCount - 1;
      const getter = () => [...new Array(this.entryCount)].map((_) => p22.uint16);
      lazy$1(this, `glyphIdArray`, getter);
    }
    supports(charCode) {
      if (charCode.charCodeAt) {
        charCode = -1;
        console.warn(
          `supports(character) not implemented for cmap subtable format 6. only supports(id) is implemented.`
        );
      }
      if (charCode < this.firstCode) return {};
      if (charCode > this.firstCode + this.entryCount) return {};
      const code = charCode - this.firstCode;
      return { code, unicode: String.fromCodePoint(code) };
    }
    reverse(glyphID) {
      let pos = this.glyphIdArray.indexOf(glyphID);
      if (pos > -1) return this.firstCode + pos;
    }
    getSupportedCharCodes(preservePropNames = false) {
      if (preservePropNames) {
        return [{ firstCode: this.firstCode, lastCode: this.lastCode }];
      }
      return [{ start: this.firstCode, end: this.lastCode }];
    }
  };
  var Format8 = class extends Subtable {
    constructor(p22, platformID, encodingID) {
      super(p22, platformID, encodingID);
      this.format = 8;
      p22.uint16;
      this.length = p22.uint32;
      this.language = p22.uint32;
      this.is32 = [...new Array(8192)].map((_) => p22.uint8);
      this.numGroups = p22.uint32;
      const getter = () => [...new Array(this.numGroups)].map(
        (_) => new SequentialMapGroup$1(p22)
      );
      lazy$1(this, `groups`, getter);
    }
    supports(charCode) {
      if (charCode.charCodeAt) {
        charCode = -1;
        console.warn(
          `supports(character) not implemented for cmap subtable format 8. only supports(id) is implemented.`
        );
      }
      return this.groups.findIndex(
        (s3) => s3.startcharCode <= charCode && charCode <= s3.endcharCode
      ) !== -1;
    }
    reverse(glyphID) {
      console.warn(`reverse not implemented for cmap subtable format 8`);
      return {};
    }
    getSupportedCharCodes(preservePropNames = false) {
      if (preservePropNames) return this.groups;
      return this.groups.map((v3) => ({
        start: v3.startcharCode,
        end: v3.endcharCode
      }));
    }
  };
  var SequentialMapGroup$1 = class {
    constructor(p22) {
      this.startcharCode = p22.uint32;
      this.endcharCode = p22.uint32;
      this.startGlyphID = p22.uint32;
    }
  };
  var Format10 = class extends Subtable {
    constructor(p22, platformID, encodingID) {
      super(p22, platformID, encodingID);
      this.format = 10;
      p22.uint16;
      this.length = p22.uint32;
      this.language = p22.uint32;
      this.startCharCode = p22.uint32;
      this.numChars = p22.uint32;
      this.endCharCode = this.startCharCode + this.numChars;
      const getter = () => [...new Array(this.numChars)].map((_) => p22.uint16);
      lazy$1(this, `glyphs`, getter);
    }
    supports(charCode) {
      if (charCode.charCodeAt) {
        charCode = -1;
        console.warn(
          `supports(character) not implemented for cmap subtable format 10. only supports(id) is implemented.`
        );
      }
      if (charCode < this.startCharCode) return false;
      if (charCode > this.startCharCode + this.numChars) return false;
      return charCode - this.startCharCode;
    }
    reverse(glyphID) {
      console.warn(`reverse not implemented for cmap subtable format 10`);
      return {};
    }
    getSupportedCharCodes(preservePropNames = false) {
      if (preservePropNames) {
        return [
          {
            startCharCode: this.startCharCode,
            endCharCode: this.endCharCode
          }
        ];
      }
      return [{ start: this.startCharCode, end: this.endCharCode }];
    }
  };
  var Format12 = class extends Subtable {
    constructor(p22, platformID, encodingID) {
      super(p22, platformID, encodingID);
      this.format = 12;
      p22.uint16;
      this.length = p22.uint32;
      this.language = p22.uint32;
      this.numGroups = p22.uint32;
      const getter = () => [...new Array(this.numGroups)].map(
        (_) => new SequentialMapGroup(p22)
      );
      lazy$1(this, `groups`, getter);
    }
    supports(charCode) {
      if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
      if (55296 <= charCode && charCode <= 57343) return 0;
      if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535)
        return 0;
      return this.groups.findIndex(
        (s3) => s3.startCharCode <= charCode && charCode <= s3.endCharCode
      ) !== -1;
    }
    reverse(glyphID) {
      for (let group of this.groups) {
        let start2 = group.startGlyphID;
        if (start2 > glyphID) continue;
        if (start2 === glyphID) return group.startCharCode;
        let end = start2 + (group.endCharCode - group.startCharCode);
        if (end < glyphID) continue;
        const code = group.startCharCode + (glyphID - start2);
        return { code, unicode: String.fromCodePoint(code) };
      }
      return {};
    }
    getSupportedCharCodes(preservePropNames = false) {
      if (preservePropNames) return this.groups;
      return this.groups.map((v3) => ({
        start: v3.startCharCode,
        end: v3.endCharCode
      }));
    }
  };
  var SequentialMapGroup = class {
    constructor(p22) {
      this.startCharCode = p22.uint32;
      this.endCharCode = p22.uint32;
      this.startGlyphID = p22.uint32;
    }
  };
  var Format13 = class extends Subtable {
    constructor(p22, platformID, encodingID) {
      super(p22, platformID, encodingID);
      this.format = 13;
      p22.uint16;
      this.length = p22.uint32;
      this.language = p22.uint32;
      this.numGroups = p22.uint32;
      const getter = [...new Array(this.numGroups)].map(
        (_) => new ConstantMapGroup(p22)
      );
      lazy$1(this, `groups`, getter);
    }
    supports(charCode) {
      if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
      return this.groups.findIndex(
        (s3) => s3.startCharCode <= charCode && charCode <= s3.endCharCode
      ) !== -1;
    }
    reverse(glyphID) {
      console.warn(`reverse not implemented for cmap subtable format 13`);
      return {};
    }
    getSupportedCharCodes(preservePropNames = false) {
      if (preservePropNames) return this.groups;
      return this.groups.map((v3) => ({
        start: v3.startCharCode,
        end: v3.endCharCode
      }));
    }
  };
  var ConstantMapGroup = class {
    constructor(p22) {
      this.startCharCode = p22.uint32;
      this.endCharCode = p22.uint32;
      this.glyphID = p22.uint32;
    }
  };
  var Format14 = class extends Subtable {
    constructor(p22, platformID, encodingID) {
      super(p22, platformID, encodingID);
      this.subTableStart = p22.currentPosition;
      this.format = 14;
      this.length = p22.uint32;
      this.numVarSelectorRecords = p22.uint32;
      lazy$1(
        this,
        `varSelectors`,
        () => [...new Array(this.numVarSelectorRecords)].map(
          (_) => new VariationSelector(p22)
        )
      );
    }
    supports() {
      console.warn(`supports not implemented for cmap subtable format 14`);
      return 0;
    }
    getSupportedCharCodes() {
      console.warn(
        `getSupportedCharCodes not implemented for cmap subtable format 14`
      );
      return [];
    }
    reverse(glyphID) {
      console.warn(`reverse not implemented for cmap subtable format 14`);
      return {};
    }
    supportsVariation(variation) {
      let v3 = this.varSelector.find(
        (uvs) => uvs.varSelector === variation
      );
      return v3 ? v3 : false;
    }
    getSupportedVariations() {
      return this.varSelectors.map((v3) => v3.varSelector);
    }
  };
  var VariationSelector = class {
    constructor(p22) {
      this.varSelector = p22.uint24;
      this.defaultUVSOffset = p22.Offset32;
      this.nonDefaultUVSOffset = p22.Offset32;
    }
  };
  function createSubTable(parser, platformID, encodingID) {
    const format6 = parser.uint16;
    if (format6 === 0) return new Format0(parser, platformID, encodingID);
    if (format6 === 2) return new Format2(parser, platformID, encodingID);
    if (format6 === 4) return new Format4(parser, platformID, encodingID);
    if (format6 === 6) return new Format6(parser, platformID, encodingID);
    if (format6 === 8) return new Format8(parser, platformID, encodingID);
    if (format6 === 10) return new Format10(parser, platformID, encodingID);
    if (format6 === 12) return new Format12(parser, platformID, encodingID);
    if (format6 === 13) return new Format13(parser, platformID, encodingID);
    if (format6 === 14) return new Format14(parser, platformID, encodingID);
    return {};
  }
  var cmap = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.numTables = p22.uint16;
      this.encodingRecords = [...new Array(this.numTables)].map(
        (_) => new EncodingRecord(p22, this.tableStart)
      );
    }
    getSubTable(tableID) {
      return this.encodingRecords[tableID].table;
    }
    getSupportedEncodings() {
      return this.encodingRecords.map((r4) => ({
        platformID: r4.platformID,
        encodingId: r4.encodingID
      }));
    }
    getSupportedCharCodes(platformID, encodingID) {
      const recordID = this.encodingRecords.findIndex(
        (r4) => r4.platformID === platformID && r4.encodingID === encodingID
      );
      if (recordID === -1) return false;
      const subtable = this.getSubTable(recordID);
      return subtable.getSupportedCharCodes();
    }
    reverse(glyphid) {
      for (let i3 = 0; i3 < this.numTables; i3++) {
        let code = this.getSubTable(i3).reverse(glyphid);
        if (code) return code;
      }
    }
    getGlyphId(char) {
      let last = 0;
      this.encodingRecords.some((_, tableID) => {
        let t4 = this.getSubTable(tableID);
        if (!t4.getGlyphId) return false;
        last = t4.getGlyphId(char);
        return last !== 0;
      });
      return last;
    }
    supports(char) {
      return this.encodingRecords.some((_, tableID) => {
        const t4 = this.getSubTable(tableID);
        return t4.supports && t4.supports(char) !== false;
      });
    }
    supportsVariation(variation) {
      return this.encodingRecords.some((_, tableID) => {
        const t4 = this.getSubTable(tableID);
        return t4.supportsVariation && t4.supportsVariation(variation) !== false;
      });
    }
  };
  var EncodingRecord = class {
    constructor(p22, tableStart) {
      const platformID = this.platformID = p22.uint16;
      const encodingID = this.encodingID = p22.uint16;
      const offset = this.offset = p22.Offset32;
      lazy$1(this, `table`, () => {
        p22.currentPosition = tableStart + offset;
        return createSubTable(p22, platformID, encodingID);
      });
    }
  };
  var cmap$1 = Object.freeze({ __proto__: null, cmap });
  var head = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.load({
        majorVersion: p22.uint16,
        minorVersion: p22.uint16,
        fontRevision: p22.fixed,
        checkSumAdjustment: p22.uint32,
        magicNumber: p22.uint32,
        flags: p22.flags(16),
        unitsPerEm: p22.uint16,
        created: p22.longdatetime,
        modified: p22.longdatetime,
        xMin: p22.int16,
        yMin: p22.int16,
        xMax: p22.int16,
        yMax: p22.int16,
        macStyle: p22.flags(16),
        lowestRecPPEM: p22.uint16,
        fontDirectionHint: p22.uint16,
        indexToLocFormat: p22.uint16,
        glyphDataFormat: p22.uint16
      });
    }
  };
  var head$1 = Object.freeze({ __proto__: null, head });
  var hhea = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
      this.ascender = p22.fword;
      this.descender = p22.fword;
      this.lineGap = p22.fword;
      this.advanceWidthMax = p22.ufword;
      this.minLeftSideBearing = p22.fword;
      this.minRightSideBearing = p22.fword;
      this.xMaxExtent = p22.fword;
      this.caretSlopeRise = p22.int16;
      this.caretSlopeRun = p22.int16;
      this.caretOffset = p22.int16;
      p22.int16;
      p22.int16;
      p22.int16;
      p22.int16;
      this.metricDataFormat = p22.int16;
      this.numberOfHMetrics = p22.uint16;
      p22.verifyLength();
    }
  };
  var hhea$1 = Object.freeze({ __proto__: null, hhea });
  var hmtx = class extends SimpleTable {
    constructor(dict, dataview, tables) {
      const { p: p22 } = super(dict, dataview);
      const numberOfHMetrics = tables.hhea.numberOfHMetrics;
      const numGlyphs = tables.maxp.numGlyphs;
      const metricsStart = p22.currentPosition;
      lazy$1(this, `hMetrics`, () => {
        p22.currentPosition = metricsStart;
        return [...new Array(numberOfHMetrics)].map(
          (_) => new LongHorMetric(p22.uint16, p22.int16)
        );
      });
      if (numberOfHMetrics < numGlyphs) {
        const lsbStart = metricsStart + numberOfHMetrics * 4;
        lazy$1(this, `leftSideBearings`, () => {
          p22.currentPosition = lsbStart;
          return [...new Array(numGlyphs - numberOfHMetrics)].map(
            (_) => p22.int16
          );
        });
      }
    }
  };
  var LongHorMetric = class {
    constructor(w3, b3) {
      this.advanceWidth = w3;
      this.lsb = b3;
    }
  };
  var hmtx$1 = Object.freeze({ __proto__: null, hmtx });
  var maxp = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.legacyFixed;
      this.numGlyphs = p22.uint16;
      if (this.version === 1) {
        this.maxPoints = p22.uint16;
        this.maxContours = p22.uint16;
        this.maxCompositePoints = p22.uint16;
        this.maxCompositeContours = p22.uint16;
        this.maxZones = p22.uint16;
        this.maxTwilightPoints = p22.uint16;
        this.maxStorage = p22.uint16;
        this.maxFunctionDefs = p22.uint16;
        this.maxInstructionDefs = p22.uint16;
        this.maxStackElements = p22.uint16;
        this.maxSizeOfInstructions = p22.uint16;
        this.maxComponentElements = p22.uint16;
        this.maxComponentDepth = p22.uint16;
      }
      p22.verifyLength();
    }
  };
  var maxp$1 = Object.freeze({ __proto__: null, maxp });
  var name = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.format = p22.uint16;
      this.count = p22.uint16;
      this.stringOffset = p22.Offset16;
      this.nameRecords = [...new Array(this.count)].map(
        (_) => new NameRecord(p22, this)
      );
      if (this.format === 1) {
        this.langTagCount = p22.uint16;
        this.langTagRecords = [...new Array(this.langTagCount)].map(
          (_) => new LangTagRecord(p22.uint16, p22.Offset16)
        );
      }
      this.stringStart = this.tableStart + this.stringOffset;
    }
    get(nameID) {
      let record = this.nameRecords.find(
        (record2) => record2.nameID === nameID
      );
      if (record) return record.string;
    }
  };
  var LangTagRecord = class {
    constructor(length2, offset) {
      this.length = length2;
      this.offset = offset;
    }
  };
  var NameRecord = class {
    constructor(p22, nameTable) {
      this.platformID = p22.uint16;
      this.encodingID = p22.uint16;
      this.languageID = p22.uint16;
      this.nameID = p22.uint16;
      this.length = p22.uint16;
      this.offset = p22.Offset16;
      lazy$1(this, `string`, () => {
        p22.currentPosition = nameTable.stringStart + this.offset;
        return decodeString(p22, this);
      });
    }
  };
  function decodeString(p22, record) {
    const { platformID, length: length2 } = record;
    if (length2 === 0) return ``;
    if (platformID === 0 || platformID === 3) {
      const str22 = [];
      for (let i3 = 0, e3 = length2 / 2; i3 < e3; i3++)
        str22[i3] = String.fromCharCode(p22.uint16);
      return str22.join(``);
    }
    const bytes = p22.readBytes(length2);
    const str3 = [];
    bytes.forEach(function(b3, i3) {
      str3[i3] = String.fromCharCode(b3);
    });
    return str3.join(``);
  }
  var name$1 = Object.freeze({ __proto__: null, name });
  var OS2 = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.xAvgCharWidth = p22.int16;
      this.usWeightClass = p22.uint16;
      this.usWidthClass = p22.uint16;
      this.fsType = p22.uint16;
      this.ySubscriptXSize = p22.int16;
      this.ySubscriptYSize = p22.int16;
      this.ySubscriptXOffset = p22.int16;
      this.ySubscriptYOffset = p22.int16;
      this.ySuperscriptXSize = p22.int16;
      this.ySuperscriptYSize = p22.int16;
      this.ySuperscriptXOffset = p22.int16;
      this.ySuperscriptYOffset = p22.int16;
      this.yStrikeoutSize = p22.int16;
      this.yStrikeoutPosition = p22.int16;
      this.sFamilyClass = p22.int16;
      this.panose = [...new Array(10)].map((_) => p22.uint8);
      this.ulUnicodeRange1 = p22.flags(32);
      this.ulUnicodeRange2 = p22.flags(32);
      this.ulUnicodeRange3 = p22.flags(32);
      this.ulUnicodeRange4 = p22.flags(32);
      this.achVendID = p22.tag;
      this.fsSelection = p22.uint16;
      this.usFirstCharIndex = p22.uint16;
      this.usLastCharIndex = p22.uint16;
      this.sTypoAscender = p22.int16;
      this.sTypoDescender = p22.int16;
      this.sTypoLineGap = p22.int16;
      this.usWinAscent = p22.uint16;
      this.usWinDescent = p22.uint16;
      if (this.version === 0) return p22.verifyLength();
      this.ulCodePageRange1 = p22.flags(32);
      this.ulCodePageRange2 = p22.flags(32);
      if (this.version === 1) return p22.verifyLength();
      this.sxHeight = p22.int16;
      this.sCapHeight = p22.int16;
      this.usDefaultChar = p22.uint16;
      this.usBreakChar = p22.uint16;
      this.usMaxContext = p22.uint16;
      if (this.version <= 4) return p22.verifyLength();
      this.usLowerOpticalPointSize = p22.uint16;
      this.usUpperOpticalPointSize = p22.uint16;
      if (this.version === 5) return p22.verifyLength();
    }
  };
  var OS2$1 = Object.freeze({ __proto__: null, OS2 });
  var post = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.legacyFixed;
      this.italicAngle = p22.fixed;
      this.underlinePosition = p22.fword;
      this.underlineThickness = p22.fword;
      this.isFixedPitch = p22.uint32;
      this.minMemType42 = p22.uint32;
      this.maxMemType42 = p22.uint32;
      this.minMemType1 = p22.uint32;
      this.maxMemType1 = p22.uint32;
      if (this.version === 1 || this.version === 3) return p22.verifyLength();
      this.numGlyphs = p22.uint16;
      if (this.version === 2) {
        this.glyphNameIndex = [...new Array(this.numGlyphs)].map(
          (_) => p22.uint16
        );
        this.namesOffset = p22.currentPosition;
        this.glyphNameOffsets = [1];
        for (let i3 = 0; i3 < this.numGlyphs; i3++) {
          let index = this.glyphNameIndex[i3];
          if (index < macStrings.length) {
            this.glyphNameOffsets.push(this.glyphNameOffsets[i3]);
            continue;
          }
          let bytelength = p22.int8;
          p22.skip(bytelength);
          this.glyphNameOffsets.push(
            this.glyphNameOffsets[i3] + bytelength + 1
          );
        }
      }
      if (this.version === 2.5) {
        this.offset = [...new Array(this.numGlyphs)].map(
          (_) => p22.int8
        );
      }
    }
    getGlyphName(glyphid) {
      if (this.version !== 2) {
        console.warn(
          `post table version ${this.version} does not support glyph name lookups`
        );
        return ``;
      }
      let index = this.glyphNameIndex[glyphid];
      if (index < 258) return macStrings[index];
      let offset = this.glyphNameOffsets[glyphid];
      let next = this.glyphNameOffsets[glyphid + 1];
      let len2 = next - offset - 1;
      if (len2 === 0) return `.notdef.`;
      this.parser.currentPosition = this.namesOffset + offset;
      const data = this.parser.readBytes(
        len2,
        this.namesOffset + offset,
        8,
        true
      );
      return data.map((b3) => String.fromCharCode(b3)).join(``);
    }
  };
  var macStrings = [
    `.notdef`,
    `.null`,
    `nonmarkingreturn`,
    `space`,
    `exclam`,
    `quotedbl`,
    `numbersign`,
    `dollar`,
    `percent`,
    `ampersand`,
    `quotesingle`,
    `parenleft`,
    `parenright`,
    `asterisk`,
    `plus`,
    `comma`,
    `hyphen`,
    `period`,
    `slash`,
    `zero`,
    `one`,
    `two`,
    `three`,
    `four`,
    `five`,
    `six`,
    `seven`,
    `eight`,
    `nine`,
    `colon`,
    `semicolon`,
    `less`,
    `equal`,
    `greater`,
    `question`,
    `at`,
    `A`,
    `B`,
    `C`,
    `D`,
    `E`,
    `F`,
    `G`,
    `H`,
    `I`,
    `J`,
    `K`,
    `L`,
    `M`,
    `N`,
    `O`,
    `P`,
    `Q`,
    `R`,
    `S`,
    `T`,
    `U`,
    `V`,
    `W`,
    `X`,
    `Y`,
    `Z`,
    `bracketleft`,
    `backslash`,
    `bracketright`,
    `asciicircum`,
    `underscore`,
    `grave`,
    `a`,
    `b`,
    `c`,
    `d`,
    `e`,
    `f`,
    `g`,
    `h`,
    `i`,
    `j`,
    `k`,
    `l`,
    `m`,
    `n`,
    `o`,
    `p`,
    `q`,
    `r`,
    `s`,
    `t`,
    `u`,
    `v`,
    `w`,
    `x`,
    `y`,
    `z`,
    `braceleft`,
    `bar`,
    `braceright`,
    `asciitilde`,
    `Adieresis`,
    `Aring`,
    `Ccedilla`,
    `Eacute`,
    `Ntilde`,
    `Odieresis`,
    `Udieresis`,
    `aacute`,
    `agrave`,
    `acircumflex`,
    `adieresis`,
    `atilde`,
    `aring`,
    `ccedilla`,
    `eacute`,
    `egrave`,
    `ecircumflex`,
    `edieresis`,
    `iacute`,
    `igrave`,
    `icircumflex`,
    `idieresis`,
    `ntilde`,
    `oacute`,
    `ograve`,
    `ocircumflex`,
    `odieresis`,
    `otilde`,
    `uacute`,
    `ugrave`,
    `ucircumflex`,
    `udieresis`,
    `dagger`,
    `degree`,
    `cent`,
    `sterling`,
    `section`,
    `bullet`,
    `paragraph`,
    `germandbls`,
    `registered`,
    `copyright`,
    `trademark`,
    `acute`,
    `dieresis`,
    `notequal`,
    `AE`,
    `Oslash`,
    `infinity`,
    `plusminus`,
    `lessequal`,
    `greaterequal`,
    `yen`,
    `mu`,
    `partialdiff`,
    `summation`,
    `product`,
    `pi`,
    `integral`,
    `ordfeminine`,
    `ordmasculine`,
    `Omega`,
    `ae`,
    `oslash`,
    `questiondown`,
    `exclamdown`,
    `logicalnot`,
    `radical`,
    `florin`,
    `approxequal`,
    `Delta`,
    `guillemotleft`,
    `guillemotright`,
    `ellipsis`,
    `nonbreakingspace`,
    `Agrave`,
    `Atilde`,
    `Otilde`,
    `OE`,
    `oe`,
    `endash`,
    `emdash`,
    `quotedblleft`,
    `quotedblright`,
    `quoteleft`,
    `quoteright`,
    `divide`,
    `lozenge`,
    `ydieresis`,
    `Ydieresis`,
    `fraction`,
    `currency`,
    `guilsinglleft`,
    `guilsinglright`,
    `fi`,
    `fl`,
    `daggerdbl`,
    `periodcentered`,
    `quotesinglbase`,
    `quotedblbase`,
    `perthousand`,
    `Acircumflex`,
    `Ecircumflex`,
    `Aacute`,
    `Edieresis`,
    `Egrave`,
    `Iacute`,
    `Icircumflex`,
    `Idieresis`,
    `Igrave`,
    `Oacute`,
    `Ocircumflex`,
    `apple`,
    `Ograve`,
    `Uacute`,
    `Ucircumflex`,
    `Ugrave`,
    `dotlessi`,
    `circumflex`,
    `tilde`,
    `macron`,
    `breve`,
    `dotaccent`,
    `ring`,
    `cedilla`,
    `hungarumlaut`,
    `ogonek`,
    `caron`,
    `Lslash`,
    `lslash`,
    `Scaron`,
    `scaron`,
    `Zcaron`,
    `zcaron`,
    `brokenbar`,
    `Eth`,
    `eth`,
    `Yacute`,
    `yacute`,
    `Thorn`,
    `thorn`,
    `minus`,
    `multiply`,
    `onesuperior`,
    `twosuperior`,
    `threesuperior`,
    `onehalf`,
    `onequarter`,
    `threequarters`,
    `franc`,
    `Gbreve`,
    `gbreve`,
    `Idotaccent`,
    `Scedilla`,
    `scedilla`,
    `Cacute`,
    `cacute`,
    `Ccaron`,
    `ccaron`,
    `dcroat`
  ];
  var post$1 = Object.freeze({ __proto__: null, post });
  var BASE = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
      this.horizAxisOffset = p22.Offset16;
      this.vertAxisOffset = p22.Offset16;
      lazy$1(
        this,
        `horizAxis`,
        () => new AxisTable(
          { offset: dict.offset + this.horizAxisOffset },
          dataview
        )
      );
      lazy$1(
        this,
        `vertAxis`,
        () => new AxisTable(
          { offset: dict.offset + this.vertAxisOffset },
          dataview
        )
      );
      if (this.majorVersion === 1 && this.minorVersion === 1) {
        this.itemVarStoreOffset = p22.Offset32;
        lazy$1(
          this,
          `itemVarStore`,
          () => new AxisTable(
            { offset: dict.offset + this.itemVarStoreOffset },
            dataview
          )
        );
      }
    }
  };
  var AxisTable = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview, `AxisTable`);
      this.baseTagListOffset = p22.Offset16;
      this.baseScriptListOffset = p22.Offset16;
      lazy$1(
        this,
        `baseTagList`,
        () => new BaseTagListTable(
          { offset: dict.offset + this.baseTagListOffset },
          dataview
        )
      );
      lazy$1(
        this,
        `baseScriptList`,
        () => new BaseScriptListTable(
          { offset: dict.offset + this.baseScriptListOffset },
          dataview
        )
      );
    }
  };
  var BaseTagListTable = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview, `BaseTagListTable`);
      this.baseTagCount = p22.uint16;
      this.baselineTags = [...new Array(this.baseTagCount)].map(
        (_) => p22.tag
      );
    }
  };
  var BaseScriptListTable = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview, `BaseScriptListTable`);
      this.baseScriptCount = p22.uint16;
      const recordStart = p22.currentPosition;
      lazy$1(this, `baseScriptRecords`, () => {
        p22.currentPosition = recordStart;
        return [...new Array(this.baseScriptCount)].map(
          (_) => new BaseScriptRecord(this.start, p22)
        );
      });
    }
  };
  var BaseScriptRecord = class {
    constructor(baseScriptListTableStart, p22) {
      this.baseScriptTag = p22.tag;
      this.baseScriptOffset = p22.Offset16;
      lazy$1(this, `baseScriptTable`, () => {
        p22.currentPosition = baseScriptListTableStart + this.baseScriptOffset;
        return new BaseScriptTable(p22);
      });
    }
  };
  var BaseScriptTable = class {
    constructor(p22) {
      this.start = p22.currentPosition;
      this.baseValuesOffset = p22.Offset16;
      this.defaultMinMaxOffset = p22.Offset16;
      this.baseLangSysCount = p22.uint16;
      this.baseLangSysRecords = [...new Array(this.baseLangSysCount)].map(
        (_) => new BaseLangSysRecord(this.start, p22)
      );
      lazy$1(this, `baseValues`, () => {
        p22.currentPosition = this.start + this.baseValuesOffset;
        return new BaseValuesTable(p22);
      });
      lazy$1(this, `defaultMinMax`, () => {
        p22.currentPosition = this.start + this.defaultMinMaxOffset;
        return new MinMaxTable(p22);
      });
    }
  };
  var BaseLangSysRecord = class {
    constructor(baseScriptTableStart, p22) {
      this.baseLangSysTag = p22.tag;
      this.minMaxOffset = p22.Offset16;
      lazy$1(this, `minMax`, () => {
        p22.currentPosition = baseScriptTableStart + this.minMaxOffset;
        return new MinMaxTable(p22);
      });
    }
  };
  var BaseValuesTable = class {
    constructor(p22) {
      this.parser = p22;
      this.start = p22.currentPosition;
      this.defaultBaselineIndex = p22.uint16;
      this.baseCoordCount = p22.uint16;
      this.baseCoords = [...new Array(this.baseCoordCount)].map(
        (_) => p22.Offset16
      );
    }
    getTable(id) {
      this.parser.currentPosition = this.start + this.baseCoords[id];
      return new BaseCoordTable(this.parser);
    }
  };
  var MinMaxTable = class {
    constructor(p22) {
      this.minCoord = p22.Offset16;
      this.maxCoord = p22.Offset16;
      this.featMinMaxCount = p22.uint16;
      const recordStart = p22.currentPosition;
      lazy$1(this, `featMinMaxRecords`, () => {
        p22.currentPosition = recordStart;
        return [...new Array(this.featMinMaxCount)].map(
          (_) => new FeatMinMaxRecord(p22)
        );
      });
    }
  };
  var FeatMinMaxRecord = class {
    constructor(p22) {
      this.featureTableTag = p22.tag;
      this.minCoord = p22.Offset16;
      this.maxCoord = p22.Offset16;
    }
  };
  var BaseCoordTable = class {
    constructor(p22) {
      this.baseCoordFormat = p22.uint16;
      this.coordinate = p22.int16;
      if (this.baseCoordFormat === 2) {
        this.referenceGlyph = p22.uint16;
        this.baseCoordPoint = p22.uint16;
      }
      if (this.baseCoordFormat === 3) {
        this.deviceTable = p22.Offset16;
      }
    }
  };
  var BASE$1 = Object.freeze({ __proto__: null, BASE });
  var ClassDefinition = class {
    constructor(p22) {
      this.classFormat = p22.uint16;
      if (this.classFormat === 1) {
        this.startGlyphID = p22.uint16;
        this.glyphCount = p22.uint16;
        this.classValueArray = [...new Array(this.glyphCount)].map(
          (_) => p22.uint16
        );
      }
      if (this.classFormat === 2) {
        this.classRangeCount = p22.uint16;
        this.classRangeRecords = [
          ...new Array(this.classRangeCount)
        ].map((_) => new ClassRangeRecord(p22));
      }
    }
  };
  var ClassRangeRecord = class {
    constructor(p22) {
      this.startGlyphID = p22.uint16;
      this.endGlyphID = p22.uint16;
      this.class = p22.uint16;
    }
  };
  var CoverageTable = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.coverageFormat = p22.uint16;
      if (this.coverageFormat === 1) {
        this.glyphCount = p22.uint16;
        this.glyphArray = [...new Array(this.glyphCount)].map(
          (_) => p22.uint16
        );
      }
      if (this.coverageFormat === 2) {
        this.rangeCount = p22.uint16;
        this.rangeRecords = [...new Array(this.rangeCount)].map(
          (_) => new CoverageRangeRecord(p22)
        );
      }
    }
  };
  var CoverageRangeRecord = class {
    constructor(p22) {
      this.startGlyphID = p22.uint16;
      this.endGlyphID = p22.uint16;
      this.startCoverageIndex = p22.uint16;
    }
  };
  var ItemVariationStoreTable = class {
    constructor(table, p22) {
      this.table = table;
      this.parser = p22;
      this.start = p22.currentPosition;
      this.format = p22.uint16;
      this.variationRegionListOffset = p22.Offset32;
      this.itemVariationDataCount = p22.uint16;
      this.itemVariationDataOffsets = [
        ...new Array(this.itemVariationDataCount)
      ].map((_) => p22.Offset32);
    }
  };
  var GDEF = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
      this.glyphClassDefOffset = p22.Offset16;
      lazy$1(this, `glyphClassDefs`, () => {
        if (this.glyphClassDefOffset === 0) return void 0;
        p22.currentPosition = this.tableStart + this.glyphClassDefOffset;
        return new ClassDefinition(p22);
      });
      this.attachListOffset = p22.Offset16;
      lazy$1(this, `attachList`, () => {
        if (this.attachListOffset === 0) return void 0;
        p22.currentPosition = this.tableStart + this.attachListOffset;
        return new AttachList(p22);
      });
      this.ligCaretListOffset = p22.Offset16;
      lazy$1(this, `ligCaretList`, () => {
        if (this.ligCaretListOffset === 0) return void 0;
        p22.currentPosition = this.tableStart + this.ligCaretListOffset;
        return new LigCaretList(p22);
      });
      this.markAttachClassDefOffset = p22.Offset16;
      lazy$1(this, `markAttachClassDef`, () => {
        if (this.markAttachClassDefOffset === 0) return void 0;
        p22.currentPosition = this.tableStart + this.markAttachClassDefOffset;
        return new ClassDefinition(p22);
      });
      if (this.minorVersion >= 2) {
        this.markGlyphSetsDefOffset = p22.Offset16;
        lazy$1(this, `markGlyphSetsDef`, () => {
          if (this.markGlyphSetsDefOffset === 0) return void 0;
          p22.currentPosition = this.tableStart + this.markGlyphSetsDefOffset;
          return new MarkGlyphSetsTable(p22);
        });
      }
      if (this.minorVersion === 3) {
        this.itemVarStoreOffset = p22.Offset32;
        lazy$1(this, `itemVarStore`, () => {
          if (this.itemVarStoreOffset === 0) return void 0;
          p22.currentPosition = this.tableStart + this.itemVarStoreOffset;
          return new ItemVariationStoreTable(p22);
        });
      }
    }
  };
  var AttachList = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.coverageOffset = p22.Offset16;
      this.glyphCount = p22.uint16;
      this.attachPointOffsets = [...new Array(this.glyphCount)].map(
        (_) => p22.Offset16
      );
    }
    getPoint(pointID) {
      this.parser.currentPosition = this.start + this.attachPointOffsets[pointID];
      return new AttachPoint(this.parser);
    }
  };
  var AttachPoint = class {
    constructor(p22) {
      this.pointCount = p22.uint16;
      this.pointIndices = [...new Array(this.pointCount)].map(
        (_) => p22.uint16
      );
    }
  };
  var LigCaretList = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.coverageOffset = p22.Offset16;
      lazy$1(this, `coverage`, () => {
        p22.currentPosition = this.start + this.coverageOffset;
        return new CoverageTable(p22);
      });
      this.ligGlyphCount = p22.uint16;
      this.ligGlyphOffsets = [...new Array(this.ligGlyphCount)].map(
        (_) => p22.Offset16
      );
    }
    getLigGlyph(ligGlyphID) {
      this.parser.currentPosition = this.start + this.ligGlyphOffsets[ligGlyphID];
      return new LigGlyph(this.parser);
    }
  };
  var LigGlyph = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.caretCount = p22.uint16;
      this.caretValueOffsets = [...new Array(this.caretCount)].map(
        (_) => p22.Offset16
      );
    }
    getCaretValue(caretID) {
      this.parser.currentPosition = this.start + this.caretValueOffsets[caretID];
      return new CaretValue(this.parser);
    }
  };
  var CaretValue = class {
    constructor(p22) {
      this.caretValueFormat = p22.uint16;
      if (this.caretValueFormat === 1) {
        this.coordinate = p22.int16;
      }
      if (this.caretValueFormat === 2) {
        this.caretValuePointIndex = p22.uint16;
      }
      if (this.caretValueFormat === 3) {
        this.coordinate = p22.int16;
        this.deviceOffset = p22.Offset16;
      }
    }
  };
  var MarkGlyphSetsTable = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.markGlyphSetTableFormat = p22.uint16;
      this.markGlyphSetCount = p22.uint16;
      this.coverageOffsets = [...new Array(this.markGlyphSetCount)].map(
        (_) => p22.Offset32
      );
    }
    getMarkGlyphSet(markGlyphSetID) {
      this.parser.currentPosition = this.start + this.coverageOffsets[markGlyphSetID];
      return new CoverageTable(this.parser);
    }
  };
  var GDEF$1 = Object.freeze({ __proto__: null, GDEF });
  var ScriptList = class extends ParsedData {
    static EMPTY = { scriptCount: 0, scriptRecords: [] };
    constructor(p22) {
      super(p22);
      this.scriptCount = p22.uint16;
      this.scriptRecords = [...new Array(this.scriptCount)].map(
        (_) => new ScriptRecord(p22)
      );
    }
  };
  var ScriptRecord = class {
    constructor(p22) {
      this.scriptTag = p22.tag;
      this.scriptOffset = p22.Offset16;
    }
  };
  var ScriptTable = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.defaultLangSys = p22.Offset16;
      this.langSysCount = p22.uint16;
      this.langSysRecords = [...new Array(this.langSysCount)].map(
        (_) => new LangSysRecord(p22)
      );
    }
  };
  var LangSysRecord = class {
    constructor(p22) {
      this.langSysTag = p22.tag;
      this.langSysOffset = p22.Offset16;
    }
  };
  var LangSysTable = class {
    constructor(p22) {
      this.lookupOrder = p22.Offset16;
      this.requiredFeatureIndex = p22.uint16;
      this.featureIndexCount = p22.uint16;
      this.featureIndices = [...new Array(this.featureIndexCount)].map(
        (_) => p22.uint16
      );
    }
  };
  var FeatureList = class extends ParsedData {
    static EMPTY = { featureCount: 0, featureRecords: [] };
    constructor(p22) {
      super(p22);
      this.featureCount = p22.uint16;
      this.featureRecords = [...new Array(this.featureCount)].map(
        (_) => new FeatureRecord(p22)
      );
    }
  };
  var FeatureRecord = class {
    constructor(p22) {
      this.featureTag = p22.tag;
      this.featureOffset = p22.Offset16;
    }
  };
  var FeatureTable = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.featureParams = p22.Offset16;
      this.lookupIndexCount = p22.uint16;
      this.lookupListIndices = [...new Array(this.lookupIndexCount)].map(
        (_) => p22.uint16
      );
    }
    getFeatureParams() {
      if (this.featureParams > 0) {
        const p22 = this.parser;
        p22.currentPosition = this.start + this.featureParams;
        const tag = this.featureTag;
        if (tag === `size`) return new Size(p22);
        if (tag.startsWith(`cc`)) return new CharacterVariant(p22);
        if (tag.startsWith(`ss`)) return new StylisticSet(p22);
      }
    }
  };
  var CharacterVariant = class {
    constructor(p22) {
      this.format = p22.uint16;
      this.featUiLabelNameId = p22.uint16;
      this.featUiTooltipTextNameId = p22.uint16;
      this.sampleTextNameId = p22.uint16;
      this.numNamedParameters = p22.uint16;
      this.firstParamUiLabelNameId = p22.uint16;
      this.charCount = p22.uint16;
      this.character = [...new Array(this.charCount)].map(
        (_) => p22.uint24
      );
    }
  };
  var Size = class {
    constructor(p22) {
      this.designSize = p22.uint16;
      this.subfamilyIdentifier = p22.uint16;
      this.subfamilyNameID = p22.uint16;
      this.smallEnd = p22.uint16;
      this.largeEnd = p22.uint16;
    }
  };
  var StylisticSet = class {
    constructor(p22) {
      this.version = p22.uint16;
      this.UINameID = p22.uint16;
    }
  };
  function undoCoverageOffsetParsing(instance) {
    instance.parser.currentPosition -= 2;
    delete instance.coverageOffset;
    delete instance.getCoverageTable;
  }
  var LookupType$1 = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.substFormat = p22.uint16;
      this.coverageOffset = p22.Offset16;
    }
    getCoverageTable() {
      let p22 = this.parser;
      p22.currentPosition = this.start + this.coverageOffset;
      return new CoverageTable(p22);
    }
  };
  var SubstLookupRecord = class {
    constructor(p22) {
      this.glyphSequenceIndex = p22.uint16;
      this.lookupListIndex = p22.uint16;
    }
  };
  var LookupType1$1 = class extends LookupType$1 {
    constructor(p22) {
      super(p22);
      this.deltaGlyphID = p22.int16;
    }
  };
  var LookupType2$1 = class extends LookupType$1 {
    constructor(p22) {
      super(p22);
      this.sequenceCount = p22.uint16;
      this.sequenceOffsets = [...new Array(this.sequenceCount)].map(
        (_) => p22.Offset16
      );
    }
    getSequence(index) {
      let p22 = this.parser;
      p22.currentPosition = this.start + this.sequenceOffsets[index];
      return new SequenceTable(p22);
    }
  };
  var SequenceTable = class {
    constructor(p22) {
      this.glyphCount = p22.uint16;
      this.substituteGlyphIDs = [...new Array(this.glyphCount)].map(
        (_) => p22.uint16
      );
    }
  };
  var LookupType3$1 = class extends LookupType$1 {
    constructor(p22) {
      super(p22);
      this.alternateSetCount = p22.uint16;
      this.alternateSetOffsets = [
        ...new Array(this.alternateSetCount)
      ].map((_) => p22.Offset16);
    }
    getAlternateSet(index) {
      let p22 = this.parser;
      p22.currentPosition = this.start + this.alternateSetOffsets[index];
      return new AlternateSetTable(p22);
    }
  };
  var AlternateSetTable = class {
    constructor(p22) {
      this.glyphCount = p22.uint16;
      this.alternateGlyphIDs = [...new Array(this.glyphCount)].map(
        (_) => p22.uint16
      );
    }
  };
  var LookupType4$1 = class extends LookupType$1 {
    constructor(p22) {
      super(p22);
      this.ligatureSetCount = p22.uint16;
      this.ligatureSetOffsets = [...new Array(this.ligatureSetCount)].map(
        (_) => p22.Offset16
      );
    }
    getLigatureSet(index) {
      let p22 = this.parser;
      p22.currentPosition = this.start + this.ligatureSetOffsets[index];
      return new LigatureSetTable(p22);
    }
  };
  var LigatureSetTable = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.ligatureCount = p22.uint16;
      this.ligatureOffsets = [...new Array(this.ligatureCount)].map(
        (_) => p22.Offset16
      );
    }
    getLigature(index) {
      let p22 = this.parser;
      p22.currentPosition = this.start + this.ligatureOffsets[index];
      return new LigatureTable(p22);
    }
  };
  var LigatureTable = class {
    constructor(p22) {
      this.ligatureGlyph = p22.uint16;
      this.componentCount = p22.uint16;
      this.componentGlyphIDs = [
        ...new Array(this.componentCount - 1)
      ].map((_) => p22.uint16);
    }
  };
  var LookupType5$1 = class extends LookupType$1 {
    constructor(p22) {
      super(p22);
      if (this.substFormat === 1) {
        this.subRuleSetCount = p22.uint16;
        this.subRuleSetOffsets = [
          ...new Array(this.subRuleSetCount)
        ].map((_) => p22.Offset16);
      }
      if (this.substFormat === 2) {
        this.classDefOffset = p22.Offset16;
        this.subClassSetCount = p22.uint16;
        this.subClassSetOffsets = [
          ...new Array(this.subClassSetCount)
        ].map((_) => p22.Offset16);
      }
      if (this.substFormat === 3) {
        undoCoverageOffsetParsing(this);
        this.glyphCount = p22.uint16;
        this.substitutionCount = p22.uint16;
        this.coverageOffsets = [...new Array(this.glyphCount)].map(
          (_) => p22.Offset16
        );
        this.substLookupRecords = [
          ...new Array(this.substitutionCount)
        ].map((_) => new SubstLookupRecord(p22));
      }
    }
    getSubRuleSet(index) {
      if (this.substFormat !== 1)
        throw new Error(
          `lookup type 5.${this.substFormat} has no subrule sets.`
        );
      let p22 = this.parser;
      p22.currentPosition = this.start + this.subRuleSetOffsets[index];
      return new SubRuleSetTable(p22);
    }
    getSubClassSet(index) {
      if (this.substFormat !== 2)
        throw new Error(
          `lookup type 5.${this.substFormat} has no subclass sets.`
        );
      let p22 = this.parser;
      p22.currentPosition = this.start + this.subClassSetOffsets[index];
      return new SubClassSetTable(p22);
    }
    getCoverageTable(index) {
      if (this.substFormat !== 3 && !index)
        return super.getCoverageTable();
      if (!index)
        throw new Error(
          `lookup type 5.${this.substFormat} requires an coverage table index.`
        );
      let p22 = this.parser;
      p22.currentPosition = this.start + this.coverageOffsets[index];
      return new CoverageTable(p22);
    }
  };
  var SubRuleSetTable = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.subRuleCount = p22.uint16;
      this.subRuleOffsets = [...new Array(this.subRuleCount)].map(
        (_) => p22.Offset16
      );
    }
    getSubRule(index) {
      let p22 = this.parser;
      p22.currentPosition = this.start + this.subRuleOffsets[index];
      return new SubRuleTable(p22);
    }
  };
  var SubRuleTable = class {
    constructor(p22) {
      this.glyphCount = p22.uint16;
      this.substitutionCount = p22.uint16;
      this.inputSequence = [...new Array(this.glyphCount - 1)].map(
        (_) => p22.uint16
      );
      this.substLookupRecords = [
        ...new Array(this.substitutionCount)
      ].map((_) => new SubstLookupRecord(p22));
    }
  };
  var SubClassSetTable = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.subClassRuleCount = p22.uint16;
      this.subClassRuleOffsets = [
        ...new Array(this.subClassRuleCount)
      ].map((_) => p22.Offset16);
    }
    getSubClass(index) {
      let p22 = this.parser;
      p22.currentPosition = this.start + this.subClassRuleOffsets[index];
      return new SubClassRuleTable(p22);
    }
  };
  var SubClassRuleTable = class extends SubRuleTable {
    constructor(p22) {
      super(p22);
    }
  };
  var LookupType6$1 = class extends LookupType$1 {
    constructor(p22) {
      super(p22);
      if (this.substFormat === 1) {
        this.chainSubRuleSetCount = p22.uint16;
        this.chainSubRuleSetOffsets = [
          ...new Array(this.chainSubRuleSetCount)
        ].map((_) => p22.Offset16);
      }
      if (this.substFormat === 2) {
        this.backtrackClassDefOffset = p22.Offset16;
        this.inputClassDefOffset = p22.Offset16;
        this.lookaheadClassDefOffset = p22.Offset16;
        this.chainSubClassSetCount = p22.uint16;
        this.chainSubClassSetOffsets = [
          ...new Array(this.chainSubClassSetCount)
        ].map((_) => p22.Offset16);
      }
      if (this.substFormat === 3) {
        undoCoverageOffsetParsing(this);
        this.backtrackGlyphCount = p22.uint16;
        this.backtrackCoverageOffsets = [
          ...new Array(this.backtrackGlyphCount)
        ].map((_) => p22.Offset16);
        this.inputGlyphCount = p22.uint16;
        this.inputCoverageOffsets = [
          ...new Array(this.inputGlyphCount)
        ].map((_) => p22.Offset16);
        this.lookaheadGlyphCount = p22.uint16;
        this.lookaheadCoverageOffsets = [
          ...new Array(this.lookaheadGlyphCount)
        ].map((_) => p22.Offset16);
        this.seqLookupCount = p22.uint16;
        this.seqLookupRecords = [
          ...new Array(this.substitutionCount)
        ].map((_) => new SequenceLookupRecord(p22));
      }
    }
    getChainSubRuleSet(index) {
      if (this.substFormat !== 1)
        throw new Error(
          `lookup type 6.${this.substFormat} has no chainsubrule sets.`
        );
      let p22 = this.parser;
      p22.currentPosition = this.start + this.chainSubRuleSetOffsets[index];
      return new ChainSubRuleSetTable(p22);
    }
    getChainSubClassSet(index) {
      if (this.substFormat !== 2)
        throw new Error(
          `lookup type 6.${this.substFormat} has no chainsubclass sets.`
        );
      let p22 = this.parser;
      p22.currentPosition = this.start + this.chainSubClassSetOffsets[index];
      return new ChainSubClassSetTable(p22);
    }
    getCoverageFromOffset(offset) {
      if (this.substFormat !== 3)
        throw new Error(
          `lookup type 6.${this.substFormat} does not use contextual coverage offsets.`
        );
      let p22 = this.parser;
      p22.currentPosition = this.start + offset;
      return new CoverageTable(p22);
    }
  };
  var ChainSubRuleSetTable = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.chainSubRuleCount = p22.uint16;
      this.chainSubRuleOffsets = [
        ...new Array(this.chainSubRuleCount)
      ].map((_) => p22.Offset16);
    }
    getSubRule(index) {
      let p22 = this.parser;
      p22.currentPosition = this.start + this.chainSubRuleOffsets[index];
      return new ChainSubRuleTable(p22);
    }
  };
  var ChainSubRuleTable = class {
    constructor(p22) {
      this.backtrackGlyphCount = p22.uint16;
      this.backtrackSequence = [
        ...new Array(this.backtrackGlyphCount)
      ].map((_) => p22.uint16);
      this.inputGlyphCount = p22.uint16;
      this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map(
        (_) => p22.uint16
      );
      this.lookaheadGlyphCount = p22.uint16;
      this.lookAheadSequence = [
        ...new Array(this.lookAheadGlyphCount)
      ].map((_) => p22.uint16);
      this.substitutionCount = p22.uint16;
      this.substLookupRecords = [...new Array(this.SubstCount)].map(
        (_) => new SubstLookupRecord(p22)
      );
    }
  };
  var ChainSubClassSetTable = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.chainSubClassRuleCount = p22.uint16;
      this.chainSubClassRuleOffsets = [
        ...new Array(this.chainSubClassRuleCount)
      ].map((_) => p22.Offset16);
    }
    getSubClass(index) {
      let p22 = this.parser;
      p22.currentPosition = this.start + this.chainSubRuleOffsets[index];
      return new ChainSubClassRuleTable(p22);
    }
  };
  var ChainSubClassRuleTable = class {
    constructor(p22) {
      this.backtrackGlyphCount = p22.uint16;
      this.backtrackSequence = [
        ...new Array(this.backtrackGlyphCount)
      ].map((_) => p22.uint16);
      this.inputGlyphCount = p22.uint16;
      this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map(
        (_) => p22.uint16
      );
      this.lookaheadGlyphCount = p22.uint16;
      this.lookAheadSequence = [
        ...new Array(this.lookAheadGlyphCount)
      ].map((_) => p22.uint16);
      this.substitutionCount = p22.uint16;
      this.substLookupRecords = [
        ...new Array(this.substitutionCount)
      ].map((_) => new SequenceLookupRecord(p22));
    }
  };
  var SequenceLookupRecord = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.sequenceIndex = p22.uint16;
      this.lookupListIndex = p22.uint16;
    }
  };
  var LookupType7$1 = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.substFormat = p22.uint16;
      this.extensionLookupType = p22.uint16;
      this.extensionOffset = p22.Offset32;
    }
  };
  var LookupType8$1 = class extends LookupType$1 {
    constructor(p22) {
      super(p22);
      this.backtrackGlyphCount = p22.uint16;
      this.backtrackCoverageOffsets = [
        ...new Array(this.backtrackGlyphCount)
      ].map((_) => p22.Offset16);
      this.lookaheadGlyphCount = p22.uint16;
      this.lookaheadCoverageOffsets = [
        new Array(this.lookaheadGlyphCount)
      ].map((_) => p22.Offset16);
      this.glyphCount = p22.uint16;
      this.substituteGlyphIDs = [...new Array(this.glyphCount)].map(
        (_) => p22.uint16
      );
    }
  };
  var GSUBtables = {
    buildSubtable: function(type, p22) {
      const subtable = new [
        void 0,
        LookupType1$1,
        LookupType2$1,
        LookupType3$1,
        LookupType4$1,
        LookupType5$1,
        LookupType6$1,
        LookupType7$1,
        LookupType8$1
      ][type](p22);
      subtable.type = type;
      return subtable;
    }
  };
  var LookupType = class extends ParsedData {
    constructor(p22) {
      super(p22);
    }
  };
  var LookupType1 = class extends LookupType {
    constructor(p22) {
      super(p22);
      console.log(`lookup type 1`);
    }
  };
  var LookupType2 = class extends LookupType {
    constructor(p22) {
      super(p22);
      console.log(`lookup type 2`);
    }
  };
  var LookupType3 = class extends LookupType {
    constructor(p22) {
      super(p22);
      console.log(`lookup type 3`);
    }
  };
  var LookupType4 = class extends LookupType {
    constructor(p22) {
      super(p22);
      console.log(`lookup type 4`);
    }
  };
  var LookupType5 = class extends LookupType {
    constructor(p22) {
      super(p22);
      console.log(`lookup type 5`);
    }
  };
  var LookupType6 = class extends LookupType {
    constructor(p22) {
      super(p22);
      console.log(`lookup type 6`);
    }
  };
  var LookupType7 = class extends LookupType {
    constructor(p22) {
      super(p22);
      console.log(`lookup type 7`);
    }
  };
  var LookupType8 = class extends LookupType {
    constructor(p22) {
      super(p22);
      console.log(`lookup type 8`);
    }
  };
  var LookupType9 = class extends LookupType {
    constructor(p22) {
      super(p22);
      console.log(`lookup type 9`);
    }
  };
  var GPOStables = {
    buildSubtable: function(type, p22) {
      const subtable = new [
        void 0,
        LookupType1,
        LookupType2,
        LookupType3,
        LookupType4,
        LookupType5,
        LookupType6,
        LookupType7,
        LookupType8,
        LookupType9
      ][type](p22);
      subtable.type = type;
      return subtable;
    }
  };
  var LookupList = class extends ParsedData {
    static EMPTY = { lookupCount: 0, lookups: [] };
    constructor(p22) {
      super(p22);
      this.lookupCount = p22.uint16;
      this.lookups = [...new Array(this.lookupCount)].map(
        (_) => p22.Offset16
      );
    }
  };
  var LookupTable = class extends ParsedData {
    constructor(p22, type) {
      super(p22);
      this.ctType = type;
      this.lookupType = p22.uint16;
      this.lookupFlag = p22.uint16;
      this.subTableCount = p22.uint16;
      this.subtableOffsets = [...new Array(this.subTableCount)].map(
        (_) => p22.Offset16
      );
      this.markFilteringSet = p22.uint16;
    }
    get rightToLeft() {
      return this.lookupFlag & true;
    }
    get ignoreBaseGlyphs() {
      return this.lookupFlag & true;
    }
    get ignoreLigatures() {
      return this.lookupFlag & true;
    }
    get ignoreMarks() {
      return this.lookupFlag & true;
    }
    get useMarkFilteringSet() {
      return this.lookupFlag & true;
    }
    get markAttachmentType() {
      return this.lookupFlag & true;
    }
    getSubTable(index) {
      const builder = this.ctType === `GSUB` ? GSUBtables : GPOStables;
      this.parser.currentPosition = this.start + this.subtableOffsets[index];
      return builder.buildSubtable(this.lookupType, this.parser);
    }
  };
  var CommonLayoutTable = class extends SimpleTable {
    constructor(dict, dataview, name2) {
      const { p: p22, tableStart } = super(dict, dataview, name2);
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
      this.scriptListOffset = p22.Offset16;
      this.featureListOffset = p22.Offset16;
      this.lookupListOffset = p22.Offset16;
      if (this.majorVersion === 1 && this.minorVersion === 1) {
        this.featureVariationsOffset = p22.Offset32;
      }
      const no_content = !(this.scriptListOffset || this.featureListOffset || this.lookupListOffset);
      lazy$1(this, `scriptList`, () => {
        if (no_content) return ScriptList.EMPTY;
        p22.currentPosition = tableStart + this.scriptListOffset;
        return new ScriptList(p22);
      });
      lazy$1(this, `featureList`, () => {
        if (no_content) return FeatureList.EMPTY;
        p22.currentPosition = tableStart + this.featureListOffset;
        return new FeatureList(p22);
      });
      lazy$1(this, `lookupList`, () => {
        if (no_content) return LookupList.EMPTY;
        p22.currentPosition = tableStart + this.lookupListOffset;
        return new LookupList(p22);
      });
      if (this.featureVariationsOffset) {
        lazy$1(this, `featureVariations`, () => {
          if (no_content) return FeatureVariations.EMPTY;
          p22.currentPosition = tableStart + this.featureVariationsOffset;
          return new FeatureVariations(p22);
        });
      }
    }
    getSupportedScripts() {
      return this.scriptList.scriptRecords.map((r4) => r4.scriptTag);
    }
    getScriptTable(scriptTag) {
      let record = this.scriptList.scriptRecords.find(
        (r4) => r4.scriptTag === scriptTag
      );
      this.parser.currentPosition = this.scriptList.start + record.scriptOffset;
      let table = new ScriptTable(this.parser);
      table.scriptTag = scriptTag;
      return table;
    }
    ensureScriptTable(arg) {
      if (typeof arg === "string") {
        return this.getScriptTable(arg);
      }
      return arg;
    }
    getSupportedLangSys(scriptTable) {
      scriptTable = this.ensureScriptTable(scriptTable);
      const hasDefault = scriptTable.defaultLangSys !== 0;
      const supported = scriptTable.langSysRecords.map(
        (l3) => l3.langSysTag
      );
      if (hasDefault) supported.unshift(`dflt`);
      return supported;
    }
    getDefaultLangSysTable(scriptTable) {
      scriptTable = this.ensureScriptTable(scriptTable);
      let offset = scriptTable.defaultLangSys;
      if (offset !== 0) {
        this.parser.currentPosition = scriptTable.start + offset;
        let table = new LangSysTable(this.parser);
        table.langSysTag = ``;
        table.defaultForScript = scriptTable.scriptTag;
        return table;
      }
    }
    getLangSysTable(scriptTable, langSysTag = `dflt`) {
      if (langSysTag === `dflt`)
        return this.getDefaultLangSysTable(scriptTable);
      scriptTable = this.ensureScriptTable(scriptTable);
      let record = scriptTable.langSysRecords.find(
        (l3) => l3.langSysTag === langSysTag
      );
      this.parser.currentPosition = scriptTable.start + record.langSysOffset;
      let table = new LangSysTable(this.parser);
      table.langSysTag = langSysTag;
      return table;
    }
    getFeatures(langSysTable) {
      return langSysTable.featureIndices.map(
        (index) => this.getFeature(index)
      );
    }
    getFeature(indexOrTag) {
      let record;
      if (parseInt(indexOrTag) == indexOrTag) {
        record = this.featureList.featureRecords[indexOrTag];
      } else {
        record = this.featureList.featureRecords.find(
          (f3) => f3.featureTag === indexOrTag
        );
      }
      if (!record) return;
      this.parser.currentPosition = this.featureList.start + record.featureOffset;
      let table = new FeatureTable(this.parser);
      table.featureTag = record.featureTag;
      return table;
    }
    getLookups(featureTable) {
      return featureTable.lookupListIndices.map(
        (index) => this.getLookup(index)
      );
    }
    getLookup(lookupIndex, type) {
      let lookupOffset = this.lookupList.lookups[lookupIndex];
      this.parser.currentPosition = this.lookupList.start + lookupOffset;
      return new LookupTable(this.parser, type);
    }
  };
  var GSUB = class extends CommonLayoutTable {
    constructor(dict, dataview) {
      super(dict, dataview, `GSUB`);
    }
    getLookup(lookupIndex) {
      return super.getLookup(lookupIndex, `GSUB`);
    }
  };
  var GSUB$1 = Object.freeze({ __proto__: null, GSUB });
  var GPOS = class extends CommonLayoutTable {
    constructor(dict, dataview) {
      super(dict, dataview, `GPOS`);
    }
    getLookup(lookupIndex) {
      return super.getLookup(lookupIndex, `GPOS`);
    }
  };
  var GPOS$1 = Object.freeze({ __proto__: null, GPOS });
  var SVG91 = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.offsetToSVGDocumentList = p22.Offset32;
      p22.currentPosition = this.tableStart + this.offsetToSVGDocumentList;
      this.documentList = new SVGDocumentList(p22);
    }
  };
  var SVGDocumentList = class extends ParsedData {
    constructor(p22) {
      super(p22);
      this.numEntries = p22.uint16;
      this.documentRecords = [...new Array(this.numEntries)].map(
        (_) => new SVGDocumentRecord(p22)
      );
    }
    getDocument(documentID) {
      let record = this.documentRecords[documentID];
      if (!record) return "";
      let offset = this.start + record.svgDocOffset;
      this.parser.currentPosition = offset;
      return this.parser.readBytes(record.svgDocLength);
    }
    getDocumentForGlyph(glyphID) {
      let id = this.documentRecords.findIndex(
        (d3) => d3.startGlyphID <= glyphID && glyphID <= d3.endGlyphID
      );
      if (id === -1) return "";
      return this.getDocument(id);
    }
  };
  var SVGDocumentRecord = class {
    constructor(p22) {
      this.startGlyphID = p22.uint16;
      this.endGlyphID = p22.uint16;
      this.svgDocOffset = p22.Offset32;
      this.svgDocLength = p22.uint32;
    }
  };
  var SVG$1 = Object.freeze({ __proto__: null, SVG: SVG91 });
  var fvar = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
      this.axesArrayOffset = p22.Offset16;
      p22.uint16;
      this.axisCount = p22.uint16;
      this.axisSize = p22.uint16;
      this.instanceCount = p22.uint16;
      this.instanceSize = p22.uint16;
      const axisStart = this.tableStart + this.axesArrayOffset;
      lazy$1(this, `axes`, () => {
        p22.currentPosition = axisStart;
        return [...new Array(this.axisCount)].map(
          (_) => new VariationAxisRecord(p22)
        );
      });
      const instanceStart = axisStart + this.axisCount * this.axisSize;
      lazy$1(this, `instances`, () => {
        let instances = [];
        for (let i3 = 0; i3 < this.instanceCount; i3++) {
          p22.currentPosition = instanceStart + i3 * this.instanceSize;
          instances.push(
            new InstanceRecord(p22, this.axisCount, this.instanceSize)
          );
        }
        return instances;
      });
    }
    getSupportedAxes() {
      return this.axes.map((a3) => a3.tag);
    }
    getAxis(name2) {
      return this.axes.find((a3) => a3.tag === name2);
    }
  };
  var VariationAxisRecord = class {
    constructor(p22) {
      this.tag = p22.tag;
      this.minValue = p22.fixed;
      this.defaultValue = p22.fixed;
      this.maxValue = p22.fixed;
      this.flags = p22.flags(16);
      this.axisNameID = p22.uint16;
    }
  };
  var InstanceRecord = class {
    constructor(p22, axisCount, size) {
      let start2 = p22.currentPosition;
      this.subfamilyNameID = p22.uint16;
      p22.uint16;
      this.coordinates = [...new Array(axisCount)].map(
        (_) => p22.fixed
      );
      if (p22.currentPosition - start2 < size) {
        this.postScriptNameID = p22.uint16;
      }
    }
  };
  var fvar$1 = Object.freeze({ __proto__: null, fvar });
  var cvt = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      const n3 = dict.length / 2;
      lazy$1(
        this,
        `items`,
        () => [...new Array(n3)].map((_) => p22.fword)
      );
    }
  };
  var cvt$1 = Object.freeze({ __proto__: null, cvt });
  var fpgm = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      lazy$1(
        this,
        `instructions`,
        () => [...new Array(dict.length)].map((_) => p22.uint8)
      );
    }
  };
  var fpgm$1 = Object.freeze({ __proto__: null, fpgm });
  var gasp = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.numRanges = p22.uint16;
      const getter = () => [...new Array(this.numRanges)].map(
        (_) => new GASPRange(p22)
      );
      lazy$1(this, `gaspRanges`, getter);
    }
  };
  var GASPRange = class {
    constructor(p22) {
      this.rangeMaxPPEM = p22.uint16;
      this.rangeGaspBehavior = p22.uint16;
    }
  };
  var gasp$1 = Object.freeze({ __proto__: null, gasp });
  var glyf = class extends SimpleTable {
    constructor(dict, dataview) {
      super(dict, dataview);
    }
    getGlyphData(offset, length2) {
      this.parser.currentPosition = this.tableStart + offset;
      return this.parser.readBytes(length2);
    }
  };
  var glyf$1 = Object.freeze({ __proto__: null, glyf });
  var loca = class extends SimpleTable {
    constructor(dict, dataview, tables) {
      const { p: p22 } = super(dict, dataview);
      const n3 = tables.maxp.numGlyphs + 1;
      if (tables.head.indexToLocFormat === 0) {
        this.x2 = true;
        lazy$1(
          this,
          `offsets`,
          () => [...new Array(n3)].map((_) => p22.Offset16)
        );
      } else {
        lazy$1(
          this,
          `offsets`,
          () => [...new Array(n3)].map((_) => p22.Offset32)
        );
      }
    }
    getGlyphDataOffsetAndLength(glyphID) {
      let offset = this.offsets[glyphID] * this.x2 ? 2 : 1;
      let nextOffset = this.offsets[glyphID + 1] * this.x2 ? 2 : 1;
      return { offset, length: nextOffset - offset };
    }
  };
  var loca$1 = Object.freeze({ __proto__: null, loca });
  var prep = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      lazy$1(
        this,
        `instructions`,
        () => [...new Array(dict.length)].map((_) => p22.uint8)
      );
    }
  };
  var prep$1 = Object.freeze({ __proto__: null, prep });
  var CFF = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      lazy$1(this, `data`, () => p22.readBytes());
    }
  };
  var CFF$1 = Object.freeze({ __proto__: null, CFF });
  var CFF2 = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      lazy$1(this, `data`, () => p22.readBytes());
    }
  };
  var CFF2$1 = Object.freeze({ __proto__: null, CFF2 });
  var VORG = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
      this.defaultVertOriginY = p22.int16;
      this.numVertOriginYMetrics = p22.uint16;
      lazy$1(
        this,
        `vertORiginYMetrics`,
        () => [...new Array(this.numVertOriginYMetrics)].map(
          (_) => new VertOriginYMetric(p22)
        )
      );
    }
  };
  var VertOriginYMetric = class {
    constructor(p22) {
      this.glyphIndex = p22.uint16;
      this.vertOriginY = p22.int16;
    }
  };
  var VORG$1 = Object.freeze({ __proto__: null, VORG });
  var BitmapSize = class {
    constructor(p22) {
      this.indexSubTableArrayOffset = p22.Offset32;
      this.indexTablesSize = p22.uint32;
      this.numberofIndexSubTables = p22.uint32;
      this.colorRef = p22.uint32;
      this.hori = new SbitLineMetrics(p22);
      this.vert = new SbitLineMetrics(p22);
      this.startGlyphIndex = p22.uint16;
      this.endGlyphIndex = p22.uint16;
      this.ppemX = p22.uint8;
      this.ppemY = p22.uint8;
      this.bitDepth = p22.uint8;
      this.flags = p22.int8;
    }
  };
  var BitmapScale = class {
    constructor(p22) {
      this.hori = new SbitLineMetrics(p22);
      this.vert = new SbitLineMetrics(p22);
      this.ppemX = p22.uint8;
      this.ppemY = p22.uint8;
      this.substitutePpemX = p22.uint8;
      this.substitutePpemY = p22.uint8;
    }
  };
  var SbitLineMetrics = class {
    constructor(p22) {
      this.ascender = p22.int8;
      this.descender = p22.int8;
      this.widthMax = p22.uint8;
      this.caretSlopeNumerator = p22.int8;
      this.caretSlopeDenominator = p22.int8;
      this.caretOffset = p22.int8;
      this.minOriginSB = p22.int8;
      this.minAdvanceSB = p22.int8;
      this.maxBeforeBL = p22.int8;
      this.minAfterBL = p22.int8;
      this.pad1 = p22.int8;
      this.pad2 = p22.int8;
    }
  };
  var EBLC = class extends SimpleTable {
    constructor(dict, dataview, name2) {
      const { p: p22 } = super(dict, dataview, name2);
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
      this.numSizes = p22.uint32;
      lazy$1(
        this,
        `bitMapSizes`,
        () => [...new Array(this.numSizes)].map(
          (_) => new BitmapSize(p22)
        )
      );
    }
  };
  var EBLC$1 = Object.freeze({ __proto__: null, EBLC });
  var EBDT = class extends SimpleTable {
    constructor(dict, dataview, name2) {
      const { p: p22 } = super(dict, dataview, name2);
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
    }
  };
  var EBDT$1 = Object.freeze({ __proto__: null, EBDT });
  var EBSC = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.majorVersion = p22.uint16;
      this.minorVersion = p22.uint16;
      this.numSizes = p22.uint32;
      lazy$1(
        this,
        `bitmapScales`,
        () => [...new Array(this.numSizes)].map(
          (_) => new BitmapScale(p22)
        )
      );
    }
  };
  var EBSC$1 = Object.freeze({ __proto__: null, EBSC });
  var CBLC = class extends EBLC {
    constructor(dict, dataview) {
      super(dict, dataview, `CBLC`);
    }
  };
  var CBLC$1 = Object.freeze({ __proto__: null, CBLC });
  var CBDT = class extends EBDT {
    constructor(dict, dataview) {
      super(dict, dataview, `CBDT`);
    }
  };
  var CBDT$1 = Object.freeze({ __proto__: null, CBDT });
  var sbix = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.flags = p22.flags(16);
      this.numStrikes = p22.uint32;
      lazy$1(
        this,
        `strikeOffsets`,
        () => [...new Array(this.numStrikes)].map((_) => p22.Offset32)
      );
    }
  };
  var sbix$1 = Object.freeze({ __proto__: null, sbix });
  var COLR = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.numBaseGlyphRecords = p22.uint16;
      this.baseGlyphRecordsOffset = p22.Offset32;
      this.layerRecordsOffset = p22.Offset32;
      this.numLayerRecords = p22.uint16;
    }
    getBaseGlyphRecord(glyphID) {
      let start2 = this.tableStart + this.baseGlyphRecordsOffset;
      this.parser.currentPosition = start2;
      let first = new BaseGlyphRecord(this.parser);
      let firstID = first.gID;
      let end = this.tableStart + this.layerRecordsOffset - 6;
      this.parser.currentPosition = end;
      let last = new BaseGlyphRecord(this.parser);
      let lastID = last.gID;
      if (firstID === glyphID) return first;
      if (lastID === glyphID) return last;
      while (true) {
        if (start2 === end) break;
        let mid = start2 + (end - start2) / 12;
        this.parser.currentPosition = mid;
        let middle = new BaseGlyphRecord(this.parser);
        let midID = middle.gID;
        if (midID === glyphID) return middle;
        else if (midID > glyphID) {
          end = mid;
        } else if (midID < glyphID) {
          start2 = mid;
        }
      }
      return false;
    }
    getLayers(glyphID) {
      let record = this.getBaseGlyphRecord(glyphID);
      this.parser.currentPosition = this.tableStart + this.layerRecordsOffset + 4 * record.firstLayerIndex;
      return [...new Array(record.numLayers)].map(
        (_) => new LayerRecord(p)
      );
    }
  };
  var BaseGlyphRecord = class {
    constructor(p22) {
      this.gID = p22.uint16;
      this.firstLayerIndex = p22.uint16;
      this.numLayers = p22.uint16;
    }
  };
  var LayerRecord = class {
    constructor(p22) {
      this.gID = p22.uint16;
      this.paletteIndex = p22.uint16;
    }
  };
  var COLR$1 = Object.freeze({ __proto__: null, COLR });
  var CPAL = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.numPaletteEntries = p22.uint16;
      const numPalettes = this.numPalettes = p22.uint16;
      this.numColorRecords = p22.uint16;
      this.offsetFirstColorRecord = p22.Offset32;
      this.colorRecordIndices = [...new Array(this.numPalettes)].map(
        (_) => p22.uint16
      );
      lazy$1(this, `colorRecords`, () => {
        p22.currentPosition = this.tableStart + this.offsetFirstColorRecord;
        return [...new Array(this.numColorRecords)].map(
          (_) => new ColorRecord(p22)
        );
      });
      if (this.version === 1) {
        this.offsetPaletteTypeArray = p22.Offset32;
        this.offsetPaletteLabelArray = p22.Offset32;
        this.offsetPaletteEntryLabelArray = p22.Offset32;
        lazy$1(this, `paletteTypeArray`, () => {
          p22.currentPosition = this.tableStart + this.offsetPaletteTypeArray;
          return new PaletteTypeArray(p22, numPalettes);
        });
        lazy$1(this, `paletteLabelArray`, () => {
          p22.currentPosition = this.tableStart + this.offsetPaletteLabelArray;
          return new PaletteLabelsArray(p22, numPalettes);
        });
        lazy$1(this, `paletteEntryLabelArray`, () => {
          p22.currentPosition = this.tableStart + this.offsetPaletteEntryLabelArray;
          return new PaletteEntryLabelArray(p22, numPalettes);
        });
      }
    }
  };
  var ColorRecord = class {
    constructor(p22) {
      this.blue = p22.uint8;
      this.green = p22.uint8;
      this.red = p22.uint8;
      this.alpha = p22.uint8;
    }
  };
  var PaletteTypeArray = class {
    constructor(p22, numPalettes) {
      this.paletteTypes = [...new Array(numPalettes)].map(
        (_) => p22.uint32
      );
    }
  };
  var PaletteLabelsArray = class {
    constructor(p22, numPalettes) {
      this.paletteLabels = [...new Array(numPalettes)].map(
        (_) => p22.uint16
      );
    }
  };
  var PaletteEntryLabelArray = class {
    constructor(p22, numPalettes) {
      this.paletteEntryLabels = [...new Array(numPalettes)].map(
        (_) => p22.uint16
      );
    }
  };
  var CPAL$1 = Object.freeze({ __proto__: null, CPAL });
  var DSIG = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint32;
      this.numSignatures = p22.uint16;
      this.flags = p22.uint16;
      this.signatureRecords = [...new Array(this.numSignatures)].map(
        (_) => new SignatureRecord(p22)
      );
    }
    getData(signatureID) {
      const record = this.signatureRecords[signatureID];
      this.parser.currentPosition = this.tableStart + record.offset;
      return new SignatureBlockFormat1(this.parser);
    }
  };
  var SignatureRecord = class {
    constructor(p22) {
      this.format = p22.uint32;
      this.length = p22.uint32;
      this.offset = p22.Offset32;
    }
  };
  var SignatureBlockFormat1 = class {
    constructor(p22) {
      p22.uint16;
      p22.uint16;
      this.signatureLength = p22.uint32;
      this.signature = p22.readBytes(this.signatureLength);
    }
  };
  var DSIG$1 = Object.freeze({ __proto__: null, DSIG });
  var hdmx = class extends SimpleTable {
    constructor(dict, dataview, tables) {
      const { p: p22 } = super(dict, dataview);
      const numGlyphs = tables.hmtx.numGlyphs;
      this.version = p22.uint16;
      this.numRecords = p22.int16;
      this.sizeDeviceRecord = p22.int32;
      this.records = [...new Array(numRecords)].map(
        (_) => new DeviceRecord(p22, numGlyphs)
      );
    }
  };
  var DeviceRecord = class {
    constructor(p22, numGlyphs) {
      this.pixelSize = p22.uint8;
      this.maxWidth = p22.uint8;
      this.widths = p22.readBytes(numGlyphs);
    }
  };
  var hdmx$1 = Object.freeze({ __proto__: null, hdmx });
  var kern = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.nTables = p22.uint16;
      lazy$1(this, `tables`, () => {
        let offset = this.tableStart + 4;
        const tables = [];
        for (let i3 = 0; i3 < this.nTables; i3++) {
          p22.currentPosition = offset;
          let subtable = new KernSubTable(p22);
          tables.push(subtable);
          offset += subtable;
        }
        return tables;
      });
    }
  };
  var KernSubTable = class {
    constructor(p22) {
      this.version = p22.uint16;
      this.length = p22.uint16;
      this.coverage = p22.flags(8);
      this.format = p22.uint8;
      if (this.format === 0) {
        this.nPairs = p22.uint16;
        this.searchRange = p22.uint16;
        this.entrySelector = p22.uint16;
        this.rangeShift = p22.uint16;
        lazy$1(
          this,
          `pairs`,
          () => [...new Array(this.nPairs)].map((_) => new Pair(p22))
        );
      }
      if (this.format === 2) {
        console.warn(
          `Kern subtable format 2 is not supported: this parser currently only parses universal table data.`
        );
      }
    }
    get horizontal() {
      return this.coverage[0];
    }
    get minimum() {
      return this.coverage[1];
    }
    get crossstream() {
      return this.coverage[2];
    }
    get override() {
      return this.coverage[3];
    }
  };
  var Pair = class {
    constructor(p22) {
      this.left = p22.uint16;
      this.right = p22.uint16;
      this.value = p22.fword;
    }
  };
  var kern$1 = Object.freeze({ __proto__: null, kern });
  var LTSH = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.numGlyphs = p22.uint16;
      this.yPels = p22.readBytes(this.numGlyphs);
    }
  };
  var LTSH$1 = Object.freeze({ __proto__: null, LTSH });
  var MERG = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.mergeClassCount = p22.uint16;
      this.mergeDataOffset = p22.Offset16;
      this.classDefCount = p22.uint16;
      this.offsetToClassDefOffsets = p22.Offset16;
      lazy$1(
        this,
        `mergeEntryMatrix`,
        () => [...new Array(this.mergeClassCount)].map(
          (_) => p22.readBytes(this.mergeClassCount)
        )
      );
      console.warn(`Full MERG parsing is currently not supported.`);
      console.warn(
        `If you need this table parsed, please file an issue, or better yet, a PR.`
      );
    }
  };
  var MERG$1 = Object.freeze({ __proto__: null, MERG });
  var meta = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint32;
      this.flags = p22.uint32;
      p22.uint32;
      this.dataMapsCount = p22.uint32;
      this.dataMaps = [...new Array(this.dataMapsCount)].map(
        (_) => new DataMap(this.tableStart, p22)
      );
    }
  };
  var DataMap = class {
    constructor(tableStart, p22) {
      this.tableStart = tableStart;
      this.parser = p22;
      this.tag = p22.tag;
      this.dataOffset = p22.Offset32;
      this.dataLength = p22.uint32;
    }
    getData() {
      this.parser.currentField = this.tableStart + this.dataOffset;
      return this.parser.readBytes(this.dataLength);
    }
  };
  var meta$1 = Object.freeze({ __proto__: null, meta });
  var PCLT = class extends SimpleTable {
    constructor(dict, dataview) {
      super(dict, dataview);
      console.warn(
        `This font uses a PCLT table, which is currently not supported by this parser.`
      );
      console.warn(
        `If you need this table parsed, please file an issue, or better yet, a PR.`
      );
    }
  };
  var PCLT$1 = Object.freeze({ __proto__: null, PCLT });
  var VDMX = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.uint16;
      this.numRecs = p22.uint16;
      this.numRatios = p22.uint16;
      this.ratRanges = [...new Array(this.numRatios)].map(
        (_) => new RatioRange(p22)
      );
      this.offsets = [...new Array(this.numRatios)].map(
        (_) => p22.Offset16
      );
      this.VDMXGroups = [...new Array(this.numRecs)].map(
        (_) => new VDMXGroup(p22)
      );
    }
  };
  var RatioRange = class {
    constructor(p22) {
      this.bCharSet = p22.uint8;
      this.xRatio = p22.uint8;
      this.yStartRatio = p22.uint8;
      this.yEndRatio = p22.uint8;
    }
  };
  var VDMXGroup = class {
    constructor(p22) {
      this.recs = p22.uint16;
      this.startsz = p22.uint8;
      this.endsz = p22.uint8;
      this.records = [...new Array(this.recs)].map(
        (_) => new vTable(p22)
      );
    }
  };
  var vTable = class {
    constructor(p22) {
      this.yPelHeight = p22.uint16;
      this.yMax = p22.int16;
      this.yMin = p22.int16;
    }
  };
  var VDMX$1 = Object.freeze({ __proto__: null, VDMX });
  var vhea = class extends SimpleTable {
    constructor(dict, dataview) {
      const { p: p22 } = super(dict, dataview);
      this.version = p22.fixed;
      this.ascent = this.vertTypoAscender = p22.int16;
      this.descent = this.vertTypoDescender = p22.int16;
      this.lineGap = this.vertTypoLineGap = p22.int16;
      this.advanceHeightMax = p22.int16;
      this.minTopSideBearing = p22.int16;
      this.minBottomSideBearing = p22.int16;
      this.yMaxExtent = p22.int16;
      this.caretSlopeRise = p22.int16;
      this.caretSlopeRun = p22.int16;
      this.caretOffset = p22.int16;
      this.reserved = p22.int16;
      this.reserved = p22.int16;
      this.reserved = p22.int16;
      this.reserved = p22.int16;
      this.metricDataFormat = p22.int16;
      this.numOfLongVerMetrics = p22.uint16;
      p22.verifyLength();
    }
  };
  var vhea$1 = Object.freeze({ __proto__: null, vhea });
  var vmtx = class extends SimpleTable {
    constructor(dict, dataview, tables) {
      super(dict, dataview);
      const numOfLongVerMetrics = tables.vhea.numOfLongVerMetrics;
      const numGlyphs = tables.maxp.numGlyphs;
      const metricsStart = p.currentPosition;
      lazy(this, `vMetrics`, () => {
        p.currentPosition = metricsStart;
        return [...new Array(numOfLongVerMetrics)].map(
          (_) => new LongVertMetric(p.uint16, p.int16)
        );
      });
      if (numOfLongVerMetrics < numGlyphs) {
        const tsbStart = metricsStart + numOfLongVerMetrics * 4;
        lazy(this, `topSideBearings`, () => {
          p.currentPosition = tsbStart;
          return [...new Array(numGlyphs - numOfLongVerMetrics)].map(
            (_) => p.int16
          );
        });
      }
    }
  };
  var LongVertMetric = class {
    constructor(h3, b3) {
      this.advanceHeight = h3;
      this.topSideBearing = b3;
    }
  };
  var vmtx$1 = Object.freeze({ __proto__: null, vmtx });

  // packages/global-styles-ui/build-module/font-library/utils/make-families-from-faces.mjs
  var import_components121 = __toESM(require_components(), 1);
  var { kebabCase: kebabCase4 } = unlock5(import_components121.privateApis);
  function makeFamiliesFromFaces(fontFaces) {
    const fontFamiliesObject = fontFaces.reduce(
      (acc, item) => {
        if (!acc[item.fontFamily]) {
          acc[item.fontFamily] = {
            name: item.fontFamily,
            fontFamily: item.fontFamily,
            slug: kebabCase4(item.fontFamily.toLowerCase()),
            fontFace: []
          };
        }
        acc[item.fontFamily].fontFace.push(item);
        return acc;
      },
      {}
    );
    return Object.values(fontFamiliesObject);
  }

  // packages/global-styles-ui/build-module/font-library/upload-fonts.mjs
  var import_jsx_runtime282 = __toESM(require_jsx_runtime(), 1);
  function UploadFonts() {
    const { installFonts } = (0, import_element160.useContext)(FontLibraryContext);
    const [isUploading, setIsUploading] = (0, import_element160.useState)(false);
    const [notice, setNotice] = (0, import_element160.useState)(null);
    const handleDropZone = (files) => {
      handleFilesUpload(files);
    };
    const onFilesUpload = (event) => {
      handleFilesUpload(event.target.files);
    };
    const handleFilesUpload = async (files) => {
      if (!files) {
        return;
      }
      setNotice(null);
      setIsUploading(true);
      const uniqueFilenames = /* @__PURE__ */ new Set();
      const selectedFiles = [...files];
      let hasInvalidFiles = false;
      const checkFilesPromises = selectedFiles.map(async (file) => {
        const isFont = await isFontFile(file);
        if (!isFont) {
          hasInvalidFiles = true;
          return null;
        }
        if (uniqueFilenames.has(file.name)) {
          return null;
        }
        const fileExtension = (((file.name ?? "").split(".") ?? []).pop() ?? "").toLowerCase();
        if (ALLOWED_FILE_EXTENSIONS.includes(fileExtension)) {
          uniqueFilenames.add(file.name);
          return file;
        }
        return null;
      });
      const allowedFiles = (await Promise.all(checkFilesPromises)).filter((file) => null !== file);
      if (allowedFiles.length > 0) {
        loadFiles(allowedFiles);
      } else {
        const message2 = hasInvalidFiles ? (0, import_i18n153.__)("Sorry, you are not allowed to upload this file type.") : (0, import_i18n153.__)("No fonts found to install.");
        setNotice({
          type: "error",
          message: message2
        });
        setIsUploading(false);
      }
    };
    const loadFiles = async (files) => {
      const fontFacesLoaded = await Promise.all(
        files.map(async (fontFile) => {
          const fontFaceData = await getFontFaceMetadata(fontFile);
          await loadFontFaceInBrowser(
            fontFaceData,
            fontFaceData.file,
            "all"
          );
          return fontFaceData;
        })
      );
      handleInstall(fontFacesLoaded);
    };
    async function isFontFile(file) {
      const font2 = new Font("Uploaded Font");
      try {
        const buffer = await readFileAsArrayBuffer(file);
        await font2.fromDataBuffer(buffer, "font");
        return true;
      } catch {
        return false;
      }
    }
    async function readFileAsArrayBuffer(file) {
      return new Promise((resolve, reject) => {
        const reader = new window.FileReader();
        reader.readAsArrayBuffer(file);
        reader.onload = () => resolve(reader.result);
        reader.onerror = reject;
      });
    }
    const getFontFaceMetadata = async (fontFile) => {
      const buffer = await readFileAsArrayBuffer(fontFile);
      const fontObj = new Font("Uploaded Font");
      fontObj.fromDataBuffer(buffer, fontFile.name);
      const onloadEvent = await new Promise(
        (resolve) => fontObj.onload = resolve
      );
      const font2 = onloadEvent.detail.font;
      const { name: name2 } = font2.opentype.tables;
      const fontName = name2.get(16) || name2.get(1);
      const isItalic = name2.get(2).toLowerCase().includes("italic");
      const fontWeight = font2.opentype.tables["OS/2"].usWeightClass || "normal";
      const isVariable = !!font2.opentype.tables.fvar;
      const weightAxis = isVariable && font2.opentype.tables.fvar.axes.find(
        ({ tag }) => tag === "wght"
      );
      const weightRange = weightAxis ? `${weightAxis.minValue} ${weightAxis.maxValue}` : null;
      return {
        file: fontFile,
        fontFamily: fontName,
        fontStyle: isItalic ? "italic" : "normal",
        fontWeight: weightRange || fontWeight
      };
    };
    const handleInstall = async (fontFaces) => {
      const fontFamilies = makeFamiliesFromFaces(fontFaces);
      try {
        await installFonts(fontFamilies);
        setNotice({
          type: "success",
          message: (0, import_i18n153.__)("Fonts were installed successfully.")
        });
      } catch (error2) {
        const typedError = error2;
        setNotice({
          type: "error",
          message: typedError.message,
          errors: typedError?.installationErrors
        });
      }
      setIsUploading(false);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
      /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(import_components122.DropZone, { onFilesDrop: handleDropZone }),
      /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)(import_components122.__experimentalVStack, { className: "font-library__local-fonts", justify: "start", children: [
        notice && /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)(
          import_components122.Notice,
          {
            status: notice.type,
            __unstableHTML: true,
            onRemove: () => setNotice(null),
            children: [
              notice.message,
              notice.errors && /* @__PURE__ */ (0, import_jsx_runtime282.jsx)("ul", { children: notice.errors.map((error2, index) => /* @__PURE__ */ (0, import_jsx_runtime282.jsx)("li", { children: error2 }, index)) })
            ]
          }
        ),
        isUploading && /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(import_components122.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime282.jsx)("div", { className: "font-library__upload-area", children: /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(import_components122.ProgressBar, {}) }) }),
        !isUploading && /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(
          import_components122.FormFileUpload,
          {
            accept: ALLOWED_FILE_EXTENSIONS.map(
              (ext) => `.${ext}`
            ).join(","),
            multiple: true,
            onChange: onFilesUpload,
            render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(
              import_components122.Button,
              {
                __next40pxDefaultSize: true,
                className: "font-library__upload-area",
                onClick: openFileDialog,
                children: (0, import_i18n153.__)("Upload font")
              }
            )
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(import_components122.__experimentalText, { className: "font-library__upload-area__text", children: (0, import_i18n153.__)(
          "Uploaded fonts appear in your library and can be used in your theme. Supported formats: .ttf, .otf, .woff, and .woff2."
        ) })
      ] })
    ] });
  }
  var upload_fonts_default = UploadFonts;

  // packages/global-styles-ui/build-module/font-library/modal.mjs
  var import_jsx_runtime283 = __toESM(require_jsx_runtime(), 1);
  var { Tabs: Tabs2 } = unlock5(import_components123.privateApis);
  var DEFAULT_TAB = {
    id: "installed-fonts",
    title: (0, import_i18n154._x)("Library", "Font library")
  };
  var UPLOAD_TAB = {
    id: "upload-fonts",
    title: (0, import_i18n154._x)("Upload", "noun")
  };
  var tabsFromCollections = (collections) => collections.map(({ slug, name: name2 }) => ({
    id: slug,
    title: collections.length === 1 && slug === "google-fonts" ? (0, import_i18n154.__)("Install Fonts") : name2
  }));
  function FontLibraryModal({
    onRequestClose,
    defaultTabId = "installed-fonts"
  }) {
    const { records: collections = [] } = (0, import_core_data46.useEntityRecords)("root", "fontCollection", {
      _fields: "slug,name,description"
    });
    const canUserCreate = (0, import_data71.useSelect)((select7) => {
      return select7(import_core_data46.store).canUser("create", {
        kind: "postType",
        name: "wp_font_family"
      });
    }, []);
    const tabs = [DEFAULT_TAB];
    if (canUserCreate) {
      tabs.push(UPLOAD_TAB);
      tabs.push(...tabsFromCollections(collections || []));
    }
    return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
      import_components123.Modal,
      {
        title: (0, import_i18n154.__)("Fonts"),
        onRequestClose,
        isFullScreen: true,
        className: "font-library-modal",
        children: /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)(Tabs2, { defaultTabId, children: [
          /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("div", { className: "font-library-modal__tablist-container", children: /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(Tabs2.TabList, { children: tabs.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(Tabs2.Tab, { tabId: id, children: title }, id)) }) }),
          tabs.map(({ id }) => {
            let contents;
            switch (id) {
              case "upload-fonts":
                contents = /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(upload_fonts_default, {});
                break;
              case "installed-fonts":
                contents = /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(installed_fonts_default, {});
                break;
              default:
                contents = /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(font_collection_default, { slug: id });
            }
            return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
              Tabs2.TabPanel,
              {
                tabId: id,
                focusable: false,
                className: "font-library-modal__tab-panel",
                children: contents
              },
              id
            );
          })
        ] })
      }
    );
  }
  var modal_default2 = FontLibraryModal;

  // packages/global-styles-ui/build-module/font-family-item.mjs
  var import_i18n155 = __toESM(require_i18n(), 1);
  var import_components124 = __toESM(require_components(), 1);
  var import_element161 = __toESM(require_element(), 1);
  var import_jsx_runtime284 = __toESM(require_jsx_runtime(), 1);
  function FontFamilyItem({ font: font2 }) {
    const { handleSetLibraryFontSelected, setModalTabOpen } = (0, import_element161.useContext)(FontLibraryContext);
    const variantsCount = font2?.fontFace?.length || 1;
    const handleClick = () => {
      handleSetLibraryFontSelected?.(font2);
      setModalTabOpen?.("installed-fonts");
    };
    const previewStyle = getFamilyPreviewStyle(font2);
    return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(import_components124.__experimentalItem, { onClick: handleClick, children: /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(import_components124.__experimentalHStack, { justify: "space-between", children: [
      /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(import_components124.FlexItem, { style: previewStyle, children: font2.name }),
      /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(import_components124.FlexItem, { className: "global-styles-ui-screen-typography__font-variants-count", children: (0, import_i18n155.sprintf)(
        /* translators: %d: Number of font variants. */
        (0, import_i18n155._n)("%d variant", "%d variants", variantsCount),
        variantsCount
      ) })
    ] }) });
  }
  var font_family_item_default = FontFamilyItem;

  // packages/global-styles-ui/build-module/font-families.mjs
  var import_jsx_runtime285 = __toESM(require_jsx_runtime(), 1);
  function mapFontsWithSource(fonts, source) {
    return fonts ? fonts.map((f3) => setUIValuesNeeded(f3, { source })) : [];
  }
  function FontFamiliesInner() {
    const { baseCustomFonts, modalTabOpen, setModalTabOpen } = (0, import_element162.useContext)(FontLibraryContext);
    const [fontFamilies] = useSetting("typography.fontFamilies");
    const [baseFontFamilies] = useSetting(
      "typography.fontFamilies",
      void 0,
      "base"
    );
    const themeFonts = mapFontsWithSource(fontFamilies?.theme, "theme");
    const customFonts = mapFontsWithSource(fontFamilies?.custom, "custom");
    const activeFonts = [...themeFonts, ...customFonts].sort(
      (a3, b3) => a3.name.localeCompare(b3.name)
    );
    const hasFonts = 0 < activeFonts.length;
    const hasInstalledFonts = hasFonts || baseFontFamilies?.theme?.length > 0 || (baseCustomFonts?.length ?? 0) > 0;
    return /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(import_jsx_runtime285.Fragment, { children: [
      !!modalTabOpen && /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
        modal_default2,
        {
          onRequestClose: () => setModalTabOpen?.(""),
          defaultTabId: modalTabOpen
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(import_components125.__experimentalVStack, { spacing: 2, children: [
        /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(import_components125.__experimentalHStack, { justify: "space-between", children: [
          /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(Subtitle, { level: 3, children: (0, import_i18n156.__)("Fonts") }),
          /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
            import_components125.Button,
            {
              onClick: () => setModalTabOpen?.("installed-fonts"),
              label: (0, import_i18n156.__)("Manage fonts"),
              icon: settings_default,
              size: "small"
            }
          )
        ] }),
        activeFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(import_jsx_runtime285.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(import_components125.__experimentalItemGroup, { size: "large", isBordered: true, isSeparated: true, children: activeFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
          font_family_item_default,
          {
            font: font2
          },
          font2.slug
        )) }) }),
        !hasFonts && /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(import_jsx_runtime285.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(import_components125.__experimentalText, { as: "p", children: hasInstalledFonts ? (0, import_i18n156.__)("No fonts activated.") : (0, import_i18n156.__)("No fonts installed.") }),
          /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
            import_components125.Button,
            {
              className: "global-styles-ui-font-families__manage-fonts",
              variant: "secondary",
              __next40pxDefaultSize: true,
              onClick: () => {
                setModalTabOpen?.(
                  hasInstalledFonts ? "installed-fonts" : "upload-fonts"
                );
              },
              children: hasInstalledFonts ? (0, import_i18n156.__)("Manage fonts") : (0, import_i18n156.__)("Add fonts")
            }
          )
        ] })
      ] })
    ] });
  }
  function FontFamilies({ ...props }) {
    return /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(context_default, { children: /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(FontFamiliesInner, { ...props }) });
  }

  // packages/global-styles-ui/build-module/font-sizes/font-sizes-count.mjs
  var import_i18n157 = __toESM(require_i18n(), 1);
  var import_components126 = __toESM(require_components(), 1);
  var import_jsx_runtime286 = __toESM(require_jsx_runtime(), 1);
  function FontSizes() {
    return /* @__PURE__ */ (0, import_jsx_runtime286.jsxs)(import_components126.__experimentalVStack, { spacing: 2, children: [
      /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(import_components126.__experimentalHStack, { justify: "space-between", children: /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(Subtitle, { level: 3, children: (0, import_i18n157.__)("Font Sizes") }) }),
      /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(import_components126.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(NavigationButtonAsItem, { path: "/typography/font-sizes", children: /* @__PURE__ */ (0, import_jsx_runtime286.jsxs)(import_components126.__experimentalHStack, { direction: "row", children: [
        /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(import_components126.FlexItem, { children: (0, import_i18n157.__)("Font size presets") }),
        /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(icon_default, { icon: (0, import_i18n157.isRTL)() ? chevron_left_default : chevron_right_default })
      ] }) }) })
    ] });
  }
  var font_sizes_count_default = FontSizes;

  // packages/global-styles-ui/build-module/screen-typography.mjs
  var import_jsx_runtime287 = __toESM(require_jsx_runtime(), 1);
  function ScreenTypography() {
    const { fontLibraryEnabled } = (0, import_element163.useContext)(GlobalStylesContext);
    return /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(import_jsx_runtime287.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
        ScreenHeader,
        {
          title: (0, import_i18n158.__)("Typography"),
          description: (0, import_i18n158.__)(
            "Available fonts, typographic styles, and the application of those styles."
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(ScreenBody, { children: /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(import_components127.__experimentalVStack, { spacing: 7, children: [
        /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(TypographyVariations, { title: (0, import_i18n158.__)("Typesets") }),
        fontLibraryEnabled && /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(FontFamilies, {}),
        /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(typography_elements_default, {}),
        /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(font_sizes_count_default, {})
      ] }) })
    ] });
  }
  var screen_typography_default = ScreenTypography;

  // packages/global-styles-ui/build-module/screen-typography-element.mjs
  var import_i18n159 = __toESM(require_i18n(), 1);
  var import_components128 = __toESM(require_components(), 1);
  var import_element164 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/typography-panel.mjs
  var import_block_editor24 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime288 = __toESM(require_jsx_runtime(), 1);
  var { useSettingsForBlockElement: useSettingsForBlockElement4, TypographyPanel: StylesTypographyPanel2 } = unlock5(import_block_editor24.privateApis);
  function TypographyPanel({
    element,
    headingLevel
  }) {
    let prefixParts = [];
    if (element === "heading") {
      prefixParts = prefixParts.concat(["elements", headingLevel]);
    } else if (element && element !== "text") {
      prefixParts = prefixParts.concat(["elements", element]);
    }
    const prefix2 = prefixParts.join(".");
    const [style] = useStyle(prefix2, "", "user", false);
    const [inheritedStyle, setStyle2] = useStyle(
      prefix2,
      "",
      "merged",
      false
    );
    const [rawSettings] = useSetting("");
    const usedElement = element === "heading" ? headingLevel : element;
    const settings = useSettingsForBlockElement4(
      rawSettings,
      void 0,
      usedElement
    );
    return /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
      StylesTypographyPanel2,
      {
        inheritedValue: inheritedStyle,
        value: style,
        onChange: setStyle2,
        settings
      }
    );
  }

  // packages/global-styles-ui/build-module/typography-preview.mjs
  var import_jsx_runtime289 = __toESM(require_jsx_runtime(), 1);
  function TypographyPreview({
    name: name2,
    element,
    headingLevel
  }) {
    let prefix2 = "";
    if (element === "heading") {
      prefix2 = `elements.${headingLevel}.`;
    } else if (element && element !== "text") {
      prefix2 = `elements.${element}.`;
    }
    const [fontFamily] = useStyle(prefix2 + "typography.fontFamily", name2);
    const [gradientValue] = useStyle(prefix2 + "color.gradient", name2);
    const [backgroundColor] = useStyle(prefix2 + "color.background", name2);
    const [fallbackBackgroundColor] = useStyle("color.background");
    const [color] = useStyle(prefix2 + "color.text", name2);
    const [fontSize] = useStyle(prefix2 + "typography.fontSize", name2);
    const [fontStyle] = useStyle(prefix2 + "typography.fontStyle", name2);
    const [fontWeight] = useStyle(prefix2 + "typography.fontWeight", name2);
    const [letterSpacing] = useStyle(
      prefix2 + "typography.letterSpacing",
      name2
    );
    const extraStyles = element === "link" ? {
      textDecoration: "underline"
    } : {};
    return /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(
      "div",
      {
        className: "global-styles-ui-typography-preview",
        style: {
          fontFamily: fontFamily ?? "serif",
          background: gradientValue ?? backgroundColor ?? fallbackBackgroundColor,
          color,
          fontSize,
          fontStyle,
          fontWeight,
          letterSpacing,
          ...extraStyles
        },
        children: "Aa"
      }
    );
  }

  // packages/global-styles-ui/build-module/screen-typography-element.mjs
  var import_jsx_runtime290 = __toESM(require_jsx_runtime(), 1);
  var elements = {
    text: {
      description: (0, import_i18n159.__)("Manage the fonts used on the site."),
      title: (0, import_i18n159.__)("Text")
    },
    link: {
      description: (0, import_i18n159.__)("Manage the fonts and typography used on the links."),
      title: (0, import_i18n159.__)("Links")
    },
    heading: {
      description: (0, import_i18n159.__)("Manage the fonts and typography used on headings."),
      title: (0, import_i18n159.__)("Headings")
    },
    caption: {
      description: (0, import_i18n159.__)("Manage the fonts and typography used on captions."),
      title: (0, import_i18n159.__)("Captions")
    },
    button: {
      description: (0, import_i18n159.__)("Manage the fonts and typography used on buttons."),
      title: (0, import_i18n159.__)("Buttons")
    }
  };
  function ScreenTypographyElement({ element }) {
    const [headingLevel, setHeadingLevel] = (0, import_element164.useState)("heading");
    return /* @__PURE__ */ (0, import_jsx_runtime290.jsxs)(import_jsx_runtime290.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
        ScreenHeader,
        {
          title: elements[element].title,
          description: elements[element].description
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(import_components128.__experimentalSpacer, { marginX: 4, children: /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
        TypographyPreview,
        {
          element,
          headingLevel
        }
      ) }),
      element === "heading" && /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(import_components128.__experimentalSpacer, { marginX: 4, marginBottom: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime290.jsxs)(
        import_components128.__experimentalToggleGroupControl,
        {
          label: (0, import_i18n159.__)("Select heading level"),
          hideLabelFromVision: true,
          value: headingLevel,
          onChange: (value) => setHeadingLevel(value),
          isBlock: true,
          size: "__unstable-large",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
              import_components128.__experimentalToggleGroupControlOption,
              {
                value: "heading",
                showTooltip: true,
                "aria-label": (0, import_i18n159.__)("All headings"),
                label: (0, import_i18n159._x)("All", "heading levels")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
              import_components128.__experimentalToggleGroupControlOption,
              {
                value: "h1",
                showTooltip: true,
                "aria-label": (0, import_i18n159.__)("Heading 1"),
                label: (0, import_i18n159.__)("H1")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
              import_components128.__experimentalToggleGroupControlOption,
              {
                value: "h2",
                showTooltip: true,
                "aria-label": (0, import_i18n159.__)("Heading 2"),
                label: (0, import_i18n159.__)("H2")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
              import_components128.__experimentalToggleGroupControlOption,
              {
                value: "h3",
                showTooltip: true,
                "aria-label": (0, import_i18n159.__)("Heading 3"),
                label: (0, import_i18n159.__)("H3")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
              import_components128.__experimentalToggleGroupControlOption,
              {
                value: "h4",
                showTooltip: true,
                "aria-label": (0, import_i18n159.__)("Heading 4"),
                label: (0, import_i18n159.__)("H4")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
              import_components128.__experimentalToggleGroupControlOption,
              {
                value: "h5",
                showTooltip: true,
                "aria-label": (0, import_i18n159.__)("Heading 5"),
                label: (0, import_i18n159.__)("H5")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
              import_components128.__experimentalToggleGroupControlOption,
              {
                value: "h6",
                showTooltip: true,
                "aria-label": (0, import_i18n159.__)("Heading 6"),
                label: (0, import_i18n159.__)("H6")
              }
            )
          ]
        }
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
        TypographyPanel,
        {
          element,
          headingLevel
        }
      )
    ] });
  }
  var screen_typography_element_default = ScreenTypographyElement;

  // packages/global-styles-ui/build-module/screen-colors.mjs
  var import_i18n161 = __toESM(require_i18n(), 1);
  var import_components131 = __toESM(require_components(), 1);
  var import_block_editor25 = __toESM(require_block_editor(), 1);

  // packages/global-styles-ui/build-module/palette.mjs
  var import_components130 = __toESM(require_components(), 1);
  var import_i18n160 = __toESM(require_i18n(), 1);
  var import_element165 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/color-indicator-wrapper.mjs
  var import_components129 = __toESM(require_components(), 1);
  var import_jsx_runtime291 = __toESM(require_jsx_runtime(), 1);
  function ColorIndicatorWrapper({
    className,
    children,
    ...props
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(
      import_components129.Flex,
      {
        className: clsx_default(
          "global-styles-ui__color-indicator-wrapper",
          className
        ),
        ...props,
        children
      }
    );
  }
  var color_indicator_wrapper_default = ColorIndicatorWrapper;

  // packages/global-styles-ui/build-module/palette.mjs
  var import_jsx_runtime292 = __toESM(require_jsx_runtime(), 1);
  var EMPTY_COLORS = [];
  function Palette({ name: name2 }) {
    const [customColors] = useSetting("color.palette.custom");
    const [themeColors] = useSetting("color.palette.theme");
    const [defaultColors] = useSetting("color.palette.default");
    const [defaultPaletteEnabled] = useSetting(
      "color.defaultPalette",
      name2
    );
    const safeCustomColors = customColors || EMPTY_COLORS;
    const safeThemeColors = themeColors || EMPTY_COLORS;
    const safeDefaultColors = defaultColors || EMPTY_COLORS;
    const safeDefaultPaletteEnabled = defaultPaletteEnabled ?? true;
    const colors2 = (0, import_element165.useMemo)(
      () => [
        ...safeCustomColors,
        ...safeThemeColors,
        ...safeDefaultColors && safeDefaultPaletteEnabled ? safeDefaultColors : EMPTY_COLORS
      ],
      [
        safeCustomColors,
        safeThemeColors,
        safeDefaultColors,
        safeDefaultPaletteEnabled
      ]
    );
    const screenPath = !name2 ? "/colors/palette" : "/blocks/" + encodeURIComponent(name2) + "/colors/palette";
    return /* @__PURE__ */ (0, import_jsx_runtime292.jsxs)(import_components130.__experimentalVStack, { spacing: 3, children: [
      /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(Subtitle, { level: 3, children: (0, import_i18n160.__)("Palette") }),
      /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(import_components130.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(NavigationButtonAsItem, { path: screenPath, children: /* @__PURE__ */ (0, import_jsx_runtime292.jsxs)(import_components130.__experimentalHStack, { direction: "row", children: [
        colors2.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime292.jsxs)(import_jsx_runtime292.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(import_components130.__experimentalZStack, { isLayered: false, offset: -8, children: colors2.slice(0, 5).map(({ color }, index) => /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(
            color_indicator_wrapper_default,
            {
              children: /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(
                import_components130.ColorIndicator,
                {
                  colorValue: color
                }
              )
            },
            `${color}-${index}`
          )) }),
          /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(import_components130.FlexItem, { isBlock: true, children: (0, import_i18n160.__)("Edit palette") })
        ] }) : /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(import_components130.FlexItem, { children: (0, import_i18n160.__)("Add colors") }),
        /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(icon_default, { icon: (0, import_i18n160.isRTL)() ? chevron_left_default : chevron_right_default })
      ] }) }) })
    ] });
  }
  var palette_default = Palette;

  // packages/global-styles-ui/build-module/screen-colors.mjs
  var import_jsx_runtime293 = __toESM(require_jsx_runtime(), 1);
  var { useSettingsForBlockElement: useSettingsForBlockElement5, ColorPanel: StylesColorPanel2 } = unlock5(
    import_block_editor25.privateApis
  );
  function ScreenColors() {
    const [style, setStyle2] = useStyle(
      "",
      void 0,
      "user",
      false
    );
    const [inheritedStyle] = useStyle(
      "",
      void 0,
      "merged",
      false
    );
    const [rawSettings] = useSetting("");
    const settings = useSettingsForBlockElement5(rawSettings);
    return /* @__PURE__ */ (0, import_jsx_runtime293.jsxs)(import_jsx_runtime293.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
        ScreenHeader,
        {
          title: (0, import_i18n161.__)("Colors"),
          description: (0, import_i18n161.__)(
            "Palette colors and the application of those colors on site elements."
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(ScreenBody, { children: /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(import_components131.__experimentalVStack, { spacing: 7, children: /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(palette_default, {}) }) }),
      /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
        StylesColorPanel2,
        {
          inheritedValue: inheritedStyle,
          value: style,
          onChange: setStyle2,
          settings
        }
      )
    ] });
  }
  var screen_colors_default = ScreenColors;

  // packages/global-styles-ui/build-module/screen-color-palette.mjs
  var import_i18n164 = __toESM(require_i18n(), 1);
  var import_components136 = __toESM(require_components(), 1);

  // packages/global-styles-ui/build-module/color-palette-panel.mjs
  var import_compose27 = __toESM(require_compose(), 1);
  var import_components134 = __toESM(require_components(), 1);
  var import_i18n162 = __toESM(require_i18n(), 1);

  // packages/global-styles-ui/build-module/variations/variations-color.mjs
  var import_components133 = __toESM(require_components(), 1);

  // packages/global-styles-ui/build-module/preview-colors.mjs
  var import_components132 = __toESM(require_components(), 1);

  // packages/global-styles-ui/build-module/preset-colors.mjs
  var import_jsx_runtime294 = __toESM(require_jsx_runtime(), 1);
  function PresetColors() {
    const { paletteColors } = useStylesPreviewColors();
    return paletteColors.slice(0, 4).map(({ slug, color }, index) => /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(
      "div",
      {
        style: {
          flexGrow: 1,
          height: "100%",
          background: color
        }
      },
      `${slug}-${index}`
    ));
  }

  // packages/global-styles-ui/build-module/preview-colors.mjs
  var import_jsx_runtime295 = __toESM(require_jsx_runtime(), 1);
  var firstFrameVariants2 = {
    start: {
      scale: 1,
      opacity: 1
    },
    hover: {
      scale: 0,
      opacity: 0
    }
  };
  var StylesPreviewColors = ({
    label,
    isFocused,
    withHoverView
  }) => {
    return /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(
      preview_wrapper_default,
      {
        label,
        isFocused,
        withHoverView,
        children: ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(
          import_components132.__unstableMotion.div,
          {
            variants: firstFrameVariants2,
            style: {
              height: "100%",
              overflow: "hidden"
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(
              import_components132.__experimentalHStack,
              {
                spacing: 0,
                justify: "center",
                style: {
                  height: "100%",
                  overflow: "hidden"
                },
                children: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(PresetColors, {})
              }
            )
          },
          key
        )
      }
    );
  };
  var preview_colors_default = StylesPreviewColors;

  // packages/global-styles-ui/build-module/variations/variations-color.mjs
  var import_jsx_runtime296 = __toESM(require_jsx_runtime(), 1);
  var propertiesToFilter2 = ["color"];
  function ColorVariations({
    title,
    gap = 2
  }) {
    const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter2);
    if (colorVariations?.length <= 1) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime296.jsxs)(import_components133.__experimentalVStack, { spacing: 3, children: [
      title && /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(Subtitle, { level: 3, children: title }),
      /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(import_components133.__experimentalGrid, { gap, children: colorVariations.map((variation, index) => /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(
        Variation,
        {
          variation,
          isPill: true,
          properties: propertiesToFilter2,
          showTooltip: true,
          children: () => /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(preview_colors_default, {})
        },
        index
      )) })
    ] });
  }

  // packages/global-styles-ui/build-module/color-palette-panel.mjs
  var import_jsx_runtime297 = __toESM(require_jsx_runtime(), 1);
  var mobilePopoverProps = { placement: "bottom-start", offset: 8 };
  function ColorPalettePanel({ name: name2 }) {
    const [themeColors, setThemeColors] = useSetting(
      "color.palette.theme",
      name2
    );
    const [baseThemeColors] = useSetting(
      "color.palette.theme",
      name2,
      "base"
    );
    const [defaultColors, setDefaultColors] = useSetting(
      "color.palette.default",
      name2
    );
    const [baseDefaultColors] = useSetting(
      "color.palette.default",
      name2,
      "base"
    );
    const [customColors, setCustomColors] = useSetting(
      "color.palette.custom",
      name2
    );
    const [defaultPaletteEnabled] = useSetting(
      "color.defaultPalette",
      name2
    );
    const isMobileViewport = (0, import_compose27.useViewportMatch)("small", "<");
    const popoverProps = isMobileViewport ? mobilePopoverProps : void 0;
    const [randomizeThemeColors] = useColorRandomizer(name2);
    return /* @__PURE__ */ (0, import_jsx_runtime297.jsxs)(import_components134.__experimentalVStack, { className: "global-styles-ui-color-palette-panel", spacing: 8, children: [
      /* @__PURE__ */ (0, import_jsx_runtime297.jsxs)(import_components134.__experimentalVStack, { spacing: 4, children: [
        !!themeColors && !!themeColors.length && /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(
          import_components134.__experimentalPaletteEdit,
          {
            canReset: themeColors !== baseThemeColors,
            canOnlyChangeValues: true,
            colors: themeColors,
            onChange: setThemeColors,
            paletteLabel: (0, import_i18n162.__)("Theme"),
            paletteLabelHeadingLevel: 3,
            popoverProps
          }
        ),
        window.__experimentalEnableColorRandomizer && themeColors?.length > 0 && randomizeThemeColors && /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(
          import_components134.Button,
          {
            __next40pxDefaultSize: true,
            variant: "secondary",
            icon: shuffle_default,
            onClick: randomizeThemeColors,
            children: (0, import_i18n162.__)("Randomize colors")
          }
        )
      ] }),
      !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(
        import_components134.__experimentalPaletteEdit,
        {
          canReset: defaultColors !== baseDefaultColors,
          canOnlyChangeValues: true,
          colors: defaultColors,
          onChange: setDefaultColors,
          paletteLabel: (0, import_i18n162.__)("Default"),
          paletteLabelHeadingLevel: 3,
          popoverProps
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(
        import_components134.__experimentalPaletteEdit,
        {
          colors: customColors,
          onChange: setCustomColors,
          paletteLabel: (0, import_i18n162.__)("Custom"),
          paletteLabelHeadingLevel: 3,
          slugPrefix: "custom-",
          popoverProps
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(ColorVariations, { title: (0, import_i18n162.__)("Palettes") })
    ] });
  }

  // packages/global-styles-ui/build-module/gradients-palette-panel.mjs
  var import_compose28 = __toESM(require_compose(), 1);
  var import_components135 = __toESM(require_components(), 1);
  var import_i18n163 = __toESM(require_i18n(), 1);
  var import_jsx_runtime298 = __toESM(require_jsx_runtime(), 1);
  var mobilePopoverProps2 = { placement: "bottom-start", offset: 8 };
  var noop7 = () => {
  };
  function GradientPalettePanel({
    name: name2
  }) {
    const [themeGradients, setThemeGradients] = useSetting(
      "color.gradients.theme",
      name2
    );
    const [baseThemeGradients] = useSetting(
      "color.gradients.theme",
      name2,
      "base"
    );
    const [defaultGradients, setDefaultGradients] = useSetting(
      "color.gradients.default",
      name2
    );
    const [baseDefaultGradients] = useSetting(
      "color.gradients.default",
      name2,
      "base"
    );
    const [customGradients, setCustomGradients] = useSetting(
      "color.gradients.custom",
      name2
    );
    const [defaultPaletteEnabled] = useSetting(
      "color.defaultGradients",
      name2
    );
    const [customDuotone] = useSetting("color.duotone.custom") || [];
    const [defaultDuotone] = useSetting("color.duotone.default") || [];
    const [themeDuotone] = useSetting("color.duotone.theme") || [];
    const [defaultDuotoneEnabled] = useSetting("color.defaultDuotone");
    const duotonePalette = [
      ...customDuotone || [],
      ...themeDuotone || [],
      ...defaultDuotone && defaultDuotoneEnabled ? defaultDuotone : []
    ];
    const isMobileViewport = (0, import_compose28.useViewportMatch)("small", "<");
    const popoverProps = isMobileViewport ? mobilePopoverProps2 : void 0;
    return /* @__PURE__ */ (0, import_jsx_runtime298.jsxs)(
      import_components135.__experimentalVStack,
      {
        className: "global-styles-ui-gradient-palette-panel",
        spacing: 8,
        children: [
          !!themeGradients && !!themeGradients.length && /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(
            import_components135.__experimentalPaletteEdit,
            {
              canReset: themeGradients !== baseThemeGradients,
              canOnlyChangeValues: true,
              gradients: themeGradients,
              onChange: setThemeGradients,
              paletteLabel: (0, import_i18n163.__)("Theme"),
              paletteLabelHeadingLevel: 3,
              popoverProps
            }
          ),
          !!defaultGradients && !!defaultGradients.length && !!defaultPaletteEnabled && /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(
            import_components135.__experimentalPaletteEdit,
            {
              canReset: defaultGradients !== baseDefaultGradients,
              canOnlyChangeValues: true,
              gradients: defaultGradients,
              onChange: setDefaultGradients,
              paletteLabel: (0, import_i18n163.__)("Default"),
              paletteLabelHeadingLevel: 3,
              popoverProps
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(
            import_components135.__experimentalPaletteEdit,
            {
              gradients: customGradients,
              onChange: setCustomGradients,
              paletteLabel: (0, import_i18n163.__)("Custom"),
              paletteLabelHeadingLevel: 3,
              slugPrefix: "custom-",
              popoverProps
            }
          ),
          !!duotonePalette && !!duotonePalette.length && /* @__PURE__ */ (0, import_jsx_runtime298.jsxs)("div", { children: [
            /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(Subtitle, { level: 3, children: (0, import_i18n163.__)("Duotone") }),
            /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(import_components135.__experimentalSpacer, { margin: 3 }),
            /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(
              import_components135.DuotonePicker,
              {
                duotonePalette,
                disableCustomDuotone: true,
                disableCustomColors: true,
                clearable: false,
                onChange: noop7,
                colorPalette: []
              }
            )
          ] })
        ]
      }
    );
  }

  // packages/global-styles-ui/build-module/screen-color-palette.mjs
  var import_jsx_runtime299 = __toESM(require_jsx_runtime(), 1);
  var { Tabs: Tabs3 } = unlock5(import_components136.privateApis);
  function ScreenColorPalette({ name: name2 }) {
    return /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)(import_jsx_runtime299.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(
        ScreenHeader,
        {
          title: (0, import_i18n164.__)("Edit palette"),
          description: (0, import_i18n164.__)(
            "The combination of colors used across the site and in color pickers."
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)(Tabs3, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)(Tabs3.TabList, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(Tabs3.Tab, { tabId: "color", children: (0, import_i18n164.__)("Color") }),
          /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(Tabs3.Tab, { tabId: "gradient", children: (0, import_i18n164.__)("Gradient") })
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(Tabs3.TabPanel, { tabId: "color", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(ColorPalettePanel, { name: name2 }) }),
        /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(Tabs3.TabPanel, { tabId: "gradient", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(GradientPalettePanel, { name: name2 }) })
      ] })
    ] });
  }
  var screen_color_palette_default = ScreenColorPalette;

  // packages/global-styles-ui/build-module/screen-background.mjs
  var import_i18n165 = __toESM(require_i18n(), 1);
  var import_block_editor27 = __toESM(require_block_editor(), 1);
  var import_components137 = __toESM(require_components(), 1);

  // packages/global-styles-ui/build-module/background-panel.mjs
  var import_block_editor26 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime300 = __toESM(require_jsx_runtime(), 1);
  var BACKGROUND_DEFAULT_VALUES = {
    backgroundSize: "auto"
  };
  var { BackgroundPanel: StylesBackgroundPanel2 } = unlock5(
    import_block_editor26.privateApis
  );
  function BackgroundPanel() {
    const [style] = useStyle("", void 0, "user", false);
    const [inheritedStyle, setStyle2] = useStyle(
      "",
      void 0,
      "merged",
      false
    );
    const [settings] = useSetting("");
    return /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(
      StylesBackgroundPanel2,
      {
        inheritedValue: inheritedStyle,
        value: style,
        onChange: setStyle2,
        settings,
        defaultValues: BACKGROUND_DEFAULT_VALUES
      }
    );
  }

  // packages/global-styles-ui/build-module/screen-background.mjs
  var import_jsx_runtime301 = __toESM(require_jsx_runtime(), 1);
  var { useHasBackgroundPanel: useHasBackgroundPanel3 } = unlock5(import_block_editor27.privateApis);
  function ScreenBackground() {
    const [settings] = useSetting("");
    const hasBackgroundPanel = useHasBackgroundPanel3(settings);
    return /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)(import_jsx_runtime301.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(
        ScreenHeader,
        {
          title: (0, import_i18n165.__)("Background"),
          description: /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(import_components137.__experimentalText, { children: (0, import_i18n165.__)("Set styles for the site's background.") })
        }
      ),
      hasBackgroundPanel && /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(BackgroundPanel, {})
    ] });
  }
  var screen_background_default = ScreenBackground;

  // packages/global-styles-ui/build-module/shadows-panel.mjs
  var import_components139 = __toESM(require_components(), 1);
  var import_i18n167 = __toESM(require_i18n(), 1);
  var import_element166 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/confirm-reset-shadow-dialog.mjs
  var import_components138 = __toESM(require_components(), 1);
  var import_i18n166 = __toESM(require_i18n(), 1);
  var import_jsx_runtime302 = __toESM(require_jsx_runtime(), 1);
  function ConfirmResetShadowDialog({
    text,
    confirmButtonText,
    isOpen: isOpen2,
    toggleOpen,
    onConfirm
  }) {
    const handleConfirm = async () => {
      toggleOpen();
      onConfirm();
    };
    const handleCancel = () => {
      toggleOpen();
    };
    return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(
      import_components138.__experimentalConfirmDialog,
      {
        isOpen: isOpen2,
        cancelButtonText: (0, import_i18n166.__)("Cancel"),
        confirmButtonText,
        onCancel: handleCancel,
        onConfirm: handleConfirm,
        size: "medium",
        children: text
      }
    );
  }
  var confirm_reset_shadow_dialog_default = ConfirmResetShadowDialog;

  // packages/global-styles-ui/build-module/shadows-panel.mjs
  var import_jsx_runtime303 = __toESM(require_jsx_runtime(), 1);
  var { Menu: Menu6 } = unlock5(import_components139.privateApis);
  var defaultShadow = "6px 6px 9px rgba(0, 0, 0, 0.2)";
  function ShadowsPanel() {
    const [defaultShadows] = useSetting("shadow.presets.default");
    const [defaultShadowsEnabled] = useSetting("shadow.defaultPresets");
    const [themeShadows] = useSetting("shadow.presets.theme");
    const [customShadows, setCustomShadows] = useSetting(
      "shadow.presets.custom"
    );
    const onCreateShadow = (shadow) => {
      setCustomShadows([...customShadows || [], shadow]);
    };
    const handleResetShadows = () => {
      setCustomShadows([]);
    };
    const [isResetDialogOpen, setIsResetDialogOpen] = (0, import_element166.useState)(false);
    const toggleResetDialog = () => setIsResetDialogOpen(!isResetDialogOpen);
    return /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(import_jsx_runtime303.Fragment, { children: [
      isResetDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
        confirm_reset_shadow_dialog_default,
        {
          text: (0, import_i18n167.__)(
            "Are you sure you want to remove all custom shadows?"
          ),
          confirmButtonText: (0, import_i18n167.__)("Remove"),
          isOpen: isResetDialogOpen,
          toggleOpen: toggleResetDialog,
          onConfirm: handleResetShadows
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
        ScreenHeader,
        {
          title: (0, import_i18n167.__)("Shadows"),
          description: (0, import_i18n167.__)(
            "Manage and create shadow styles for use across the site."
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(ScreenBody, { children: /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(
        import_components139.__experimentalVStack,
        {
          className: "global-styles-ui__shadows-panel",
          spacing: 7,
          children: [
            defaultShadowsEnabled && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
              ShadowList,
              {
                label: (0, import_i18n167.__)("Default"),
                shadows: defaultShadows || [],
                category: "default"
              }
            ),
            themeShadows && themeShadows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
              ShadowList,
              {
                label: (0, import_i18n167.__)("Theme"),
                shadows: themeShadows || [],
                category: "theme"
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
              ShadowList,
              {
                label: (0, import_i18n167.__)("Custom"),
                shadows: customShadows || [],
                category: "custom",
                canCreate: true,
                onCreate: onCreateShadow,
                onReset: toggleResetDialog
              }
            )
          ]
        }
      ) })
    ] });
  }
  function ShadowList({
    label,
    shadows,
    category,
    canCreate,
    onCreate,
    onReset
  }) {
    const handleAddShadow = () => {
      const newIndex = getNewIndexFromPresets(shadows, "shadow-");
      onCreate?.({
        name: (0, import_i18n167.sprintf)(
          /* translators: %d: is an index for a preset */
          (0, import_i18n167.__)("Shadow %d"),
          newIndex
        ),
        shadow: defaultShadow,
        slug: `shadow-${newIndex}`
      });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(import_components139.__experimentalVStack, { spacing: 2, children: [
      /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(import_components139.__experimentalHStack, { justify: "space-between", children: [
        /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(Subtitle, { level: 3, children: label }),
        /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(import_components139.FlexItem, { className: "global-styles-ui__shadows-panel__options-container", children: [
          canCreate && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
            import_components139.Button,
            {
              size: "small",
              icon: plus_default,
              label: (0, import_i18n167.__)("Add shadow"),
              onClick: () => {
                handleAddShadow();
              }
            }
          ),
          !!shadows?.length && category === "custom" && /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(Menu6, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
              Menu6.TriggerButton,
              {
                render: /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
                  import_components139.Button,
                  {
                    size: "small",
                    icon: more_vertical_default,
                    label: (0, import_i18n167.__)("Shadow options")
                  }
                )
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(Menu6.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(Menu6.Item, { onClick: onReset, children: /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(Menu6.ItemLabel, { children: (0, import_i18n167.__)("Remove all custom shadows") }) }) })
          ] })
        ] })
      ] }),
      shadows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(import_components139.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: shadows.map((shadow) => /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
        ShadowItem,
        {
          shadow,
          category
        },
        shadow.slug
      )) })
    ] });
  }
  function ShadowItem({ shadow, category }) {
    return /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
      NavigationButtonAsItem,
      {
        path: `/shadows/edit/${category}/${shadow.slug}`,
        children: /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(import_components139.__experimentalHStack, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(import_components139.FlexItem, { children: shadow.name }),
          /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(icon_default, { icon: (0, import_i18n167.isRTL)() ? chevron_left_default : chevron_right_default })
        ] })
      }
    );
  }

  // packages/global-styles-ui/build-module/shadows-edit-panel.mjs
  var import_components140 = __toESM(require_components(), 1);
  var import_i18n168 = __toESM(require_i18n(), 1);
  var import_element167 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/shadow-utils.mjs
  function getShadowParts(shadow) {
    const shadowValues = shadow.match(/(?:[^,(]|\([^)]*\))+/g) || [];
    return shadowValues.map((value) => value.trim());
  }
  function shadowStringToObject(shadowValue) {
    const defaultShadow2 = {
      x: "0",
      y: "0",
      blur: "0",
      spread: "0",
      color: "#000",
      inset: false
    };
    if (!shadowValue) {
      return defaultShadow2;
    }
    if (shadowValue.includes("none")) {
      return defaultShadow2;
    }
    const lengthsRegex = /((?:^|\s+)(-?\d*\.?\d+(?:px|%|in|cm|mm|em|rem|ex|pt|pc|vh|vw|vmin|vmax|ch|lh)?)(?=\s|$)(?![^(]*\))){1,4}/g;
    const matches = shadowValue.match(lengthsRegex) || [];
    if (matches.length !== 1) {
      return defaultShadow2;
    }
    const lengths = matches[0].split(" ").map((value) => value.trim()).filter((value) => value);
    if (lengths.length < 2) {
      return defaultShadow2;
    }
    const insets = shadowValue.match(/inset/gi) || [];
    if (insets.length > 1) {
      return defaultShadow2;
    }
    const hasInset = insets.length === 1;
    let colorString = shadowValue.replace(lengthsRegex, "").trim();
    if (hasInset) {
      colorString = colorString.replace("inset", "").replace("INSET", "").trim();
    }
    const colorRegex2 = /^#([0-9a-f]{3}){1,2}$|^#([0-9a-f]{4}){1,2}$|^(?:rgb|hsl)a?\(?[\d*\.?\d+%?,?\/?\s]*\)$/gi;
    let colorMatches = (colorString.match(colorRegex2) || []).map((value) => value?.trim()).filter((value) => value);
    if (colorMatches.length > 1) {
      return defaultShadow2;
    } else if (colorMatches.length === 0) {
      colorMatches = colorString.trim().split(" ").filter((value) => value);
      if (colorMatches.length > 1) {
        return defaultShadow2;
      }
    }
    const [x2, y3, blur, spread] = lengths;
    return {
      x: x2,
      y: y3,
      blur: blur || defaultShadow2.blur,
      spread: spread || defaultShadow2.spread,
      inset: hasInset,
      color: colorString || defaultShadow2.color
    };
  }
  function shadowObjectToString(shadowObj) {
    const shadowString = `${shadowObj.x || "0px"} ${shadowObj.y || "0px"} ${shadowObj.blur || "0px"} ${shadowObj.spread || "0px"}`;
    return `${shadowObj.inset ? "inset" : ""} ${shadowString} ${shadowObj.color || ""}`.trim();
  }

  // packages/global-styles-ui/build-module/shadows-edit-panel.mjs
  var import_jsx_runtime304 = __toESM(require_jsx_runtime(), 1);
  var { Menu: Menu7 } = unlock5(import_components140.privateApis);
  var customShadowMenuItems = [
    {
      label: (0, import_i18n168.__)("Rename"),
      action: "rename"
    },
    {
      label: (0, import_i18n168.__)("Delete"),
      action: "delete"
    }
  ];
  var presetShadowMenuItems = [
    {
      label: (0, import_i18n168.__)("Reset"),
      action: "reset"
    }
  ];
  function ShadowsEditPanel() {
    const { goBack, params } = (0, import_components140.useNavigator)();
    const { category, slug } = params;
    const [shadows, setShadows] = useSetting(
      `shadow.presets.${category}`
    );
    (0, import_element167.useEffect)(() => {
      const hasCurrentShadow = shadows?.some(
        (shadow) => shadow.slug === slug
      );
      if (!!slug && !hasCurrentShadow) {
        goBack();
      }
    }, [shadows, slug, goBack]);
    const [baseShadows] = useSetting(
      `shadow.presets.${category}`,
      void 0,
      "base"
    );
    const [selectedShadow, setSelectedShadow] = (0, import_element167.useState)(
      () => (shadows || []).find((shadow) => shadow.slug === slug)
    );
    const baseSelectedShadow = (0, import_element167.useMemo)(
      () => (baseShadows || []).find((b3) => b3.slug === slug),
      [baseShadows, slug]
    );
    const [isConfirmDialogVisible, setIsConfirmDialogVisible] = (0, import_element167.useState)(false);
    const [isRenameModalVisible, setIsRenameModalVisible] = (0, import_element167.useState)(false);
    const [shadowName, setShadowName] = (0, import_element167.useState)(
      selectedShadow?.name
    );
    if (!category || !slug) {
      return null;
    }
    const onShadowChange = (shadow) => {
      setSelectedShadow({ ...selectedShadow, shadow });
      const updatedShadows = shadows.map(
        (s3) => s3.slug === slug ? { ...selectedShadow, shadow } : s3
      );
      setShadows(updatedShadows);
    };
    const onMenuClick = (action) => {
      if (action === "reset") {
        const updatedShadows = shadows.map(
          (s3) => s3.slug === slug ? baseSelectedShadow : s3
        );
        setSelectedShadow(baseSelectedShadow);
        setShadows(updatedShadows);
      } else if (action === "delete") {
        setIsConfirmDialogVisible(true);
      } else if (action === "rename") {
        setIsRenameModalVisible(true);
      }
    };
    const handleShadowDelete = () => {
      setShadows(shadows.filter((s3) => s3.slug !== slug));
    };
    const handleShadowRename = (newName) => {
      if (!newName) {
        return;
      }
      const updatedShadows = shadows.map(
        (s3) => s3.slug === slug ? { ...selectedShadow, name: newName } : s3
      );
      setSelectedShadow({ ...selectedShadow, name: newName });
      setShadows(updatedShadows);
    };
    return !selectedShadow ? /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(ScreenHeader, { title: "" }) : /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(import_jsx_runtime304.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(import_components140.__experimentalHStack, { justify: "space-between", children: [
        /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(ScreenHeader, { title: selectedShadow.name }),
        /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components140.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components140.__experimentalSpacer, { marginTop: 2, marginBottom: 0, paddingX: 4, children: /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(Menu7, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
            Menu7.TriggerButton,
            {
              render: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
                import_components140.Button,
                {
                  size: "small",
                  icon: more_vertical_default,
                  label: (0, import_i18n168.__)("Menu")
                }
              )
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(Menu7.Popover, { children: (category === "custom" ? customShadowMenuItems : presetShadowMenuItems).map((item) => /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
            Menu7.Item,
            {
              onClick: () => onMenuClick(item.action),
              disabled: item.action === "reset" && selectedShadow.shadow === baseSelectedShadow?.shadow,
              children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(Menu7.ItemLabel, { children: item.label })
            },
            item.action
          )) })
        ] }) }) })
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(ScreenBody, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(ShadowsPreview, { shadow: selectedShadow.shadow }),
        /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
          ShadowEditor,
          {
            shadow: selectedShadow.shadow,
            onChange: onShadowChange
          }
        )
      ] }),
      isConfirmDialogVisible && /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
        import_components140.__experimentalConfirmDialog,
        {
          isOpen: true,
          onConfirm: () => {
            handleShadowDelete();
            setIsConfirmDialogVisible(false);
          },
          onCancel: () => {
            setIsConfirmDialogVisible(false);
          },
          confirmButtonText: (0, import_i18n168.__)("Delete"),
          size: "medium",
          children: (0, import_i18n168.sprintf)(
            /* translators: %s: Name of the shadow preset. */
            (0, import_i18n168.__)(
              'Are you sure you want to delete "%s" shadow preset?'
            ),
            selectedShadow.name
          )
        }
      ),
      isRenameModalVisible && /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
        import_components140.Modal,
        {
          title: (0, import_i18n168.__)("Rename"),
          onRequestClose: () => setIsRenameModalVisible(false),
          size: "small",
          children: /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(
            "form",
            {
              onSubmit: (event) => {
                event.preventDefault();
                handleShadowRename(shadowName);
                setIsRenameModalVisible(false);
              },
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
                  import_components140.__experimentalInputControl,
                  {
                    __next40pxDefaultSize: true,
                    autoComplete: "off",
                    label: (0, import_i18n168.__)("Name"),
                    placeholder: (0, import_i18n168.__)("Shadow name"),
                    value: shadowName ?? "",
                    onChange: setShadowName
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components140.__experimentalSpacer, { marginBottom: 6 }),
                /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(
                  import_components140.Flex,
                  {
                    className: "block-editor-shadow-edit-modal__actions",
                    justify: "flex-end",
                    expanded: false,
                    children: [
                      /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components140.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
                        import_components140.Button,
                        {
                          __next40pxDefaultSize: true,
                          variant: "tertiary",
                          onClick: () => setIsRenameModalVisible(false),
                          children: (0, import_i18n168.__)("Cancel")
                        }
                      ) }),
                      /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components140.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
                        import_components140.Button,
                        {
                          __next40pxDefaultSize: true,
                          variant: "primary",
                          type: "submit",
                          children: (0, import_i18n168.__)("Save")
                        }
                      ) })
                    ]
                  }
                )
              ]
            }
          )
        }
      )
    ] });
  }
  function ShadowsPreview({ shadow }) {
    const shadowStyle = {
      boxShadow: shadow
    };
    return /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components140.__experimentalSpacer, { marginBottom: 4, marginTop: -2, children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
      import_components140.__experimentalHStack,
      {
        alignment: "center",
        justify: "center",
        className: "global-styles-ui__shadow-preview-panel",
        children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
          "div",
          {
            className: "global-styles-ui__shadow-preview-block",
            style: shadowStyle
          }
        )
      }
    ) });
  }
  function ShadowEditor({ shadow, onChange }) {
    const addShadowButtonRef = (0, import_element167.useRef)(null);
    const shadowParts = (0, import_element167.useMemo)(() => getShadowParts(shadow), [shadow]);
    const onChangeShadowPart = (index, part) => {
      const newShadowParts = [...shadowParts];
      newShadowParts[index] = part;
      onChange(newShadowParts.join(", "));
    };
    const onAddShadowPart = () => {
      onChange([...shadowParts, defaultShadow].join(", "));
    };
    const onRemoveShadowPart = (index) => {
      onChange(shadowParts.filter((p4, i3) => i3 !== index).join(", "));
      addShadowButtonRef.current?.focus();
    };
    return /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(import_jsx_runtime304.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components140.__experimentalVStack, { spacing: 2, children: /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(import_components140.__experimentalHStack, { justify: "space-between", children: [
        /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(Subtitle, { level: 3, children: (0, import_i18n168.__)("Shadows") }),
        /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components140.FlexItem, { className: "global-styles-ui__shadows-panel__options-container", children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
          import_components140.Button,
          {
            size: "small",
            icon: plus_default,
            label: (0, import_i18n168.__)("Add shadow"),
            onClick: () => {
              onAddShadowPart();
            },
            ref: addShadowButtonRef
          }
        ) })
      ] }) }),
      /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components140.__experimentalSpacer, {}),
      /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components140.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: shadowParts.map((part, index) => /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
        ShadowItem2,
        {
          shadow: part,
          onChange: (value) => onChangeShadowPart(index, value),
          canRemove: shadowParts.length > 1,
          onRemove: () => onRemoveShadowPart(index)
        },
        index
      )) })
    ] });
  }
  function ShadowItem2({
    shadow,
    onChange,
    canRemove,
    onRemove
  }) {
    const popoverProps = {
      placement: "left-start",
      offset: 36,
      shift: true
    };
    const shadowObj = (0, import_element167.useMemo)(
      () => shadowStringToObject(shadow),
      [shadow]
    );
    const onShadowChange = (newShadow) => {
      onChange(shadowObjectToString(newShadow));
    };
    return /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
      import_components140.Dropdown,
      {
        popoverProps,
        className: "global-styles-ui__shadow-editor__dropdown",
        renderToggle: ({ onToggle, isOpen: isOpen2 }) => {
          const toggleProps = {
            onClick: onToggle,
            className: clsx_default(
              "global-styles-ui__shadow-editor__dropdown-toggle",
              { "is-open": isOpen2 }
            ),
            "aria-expanded": isOpen2
          };
          const removeButtonProps = {
            onClick: () => {
              if (isOpen2) {
                onToggle();
              }
              onRemove();
            },
            className: clsx_default(
              "global-styles-ui__shadow-editor__remove-button",
              { "is-open": isOpen2 }
            ),
            label: (0, import_i18n168.__)("Remove shadow")
          };
          return /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(import_jsx_runtime304.Fragment, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
              import_components140.Button,
              {
                __next40pxDefaultSize: true,
                icon: shadow_default,
                ...toggleProps,
                children: shadowObj.inset ? (0, import_i18n168.__)("Inner shadow") : (0, import_i18n168.__)("Drop shadow")
              }
            ),
            canRemove && /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
              import_components140.Button,
              {
                size: "small",
                icon: reset_default,
                ...removeButtonProps
              }
            )
          ] });
        },
        renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
          import_components140.__experimentalDropdownContentWrapper,
          {
            paddingSize: "medium",
            className: "global-styles-ui__shadow-editor__dropdown-content",
            children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
              ShadowPopover,
              {
                shadowObj,
                onChange: onShadowChange
              }
            )
          }
        )
      }
    );
  }
  function ShadowPopover({ shadowObj, onChange }) {
    const __experimentalIsRenderedInSidebar = true;
    const enableAlpha = true;
    const onShadowChange = (key, value) => {
      const newShadow = {
        ...shadowObj,
        [key]: value
      };
      onChange(newShadow);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(import_components140.__experimentalVStack, { spacing: 4, className: "global-styles-ui__shadow-editor-panel", children: [
      /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
        import_components140.ColorPalette,
        {
          clearable: false,
          enableAlpha,
          __experimentalIsRenderedInSidebar,
          value: shadowObj.color,
          onChange: (value) => onShadowChange("color", value)
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(
        import_components140.__experimentalToggleGroupControl,
        {
          label: (0, import_i18n168.__)("Shadow Type"),
          value: shadowObj.inset ? "inset" : "outset",
          isBlock: true,
          onChange: (value) => onShadowChange("inset", value === "inset"),
          hideLabelFromVision: true,
          __next40pxDefaultSize: true,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
              import_components140.__experimentalToggleGroupControlOption,
              {
                value: "outset",
                label: (0, import_i18n168.__)("Outset")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
              import_components140.__experimentalToggleGroupControlOption,
              {
                value: "inset",
                label: (0, import_i18n168.__)("Inset")
              }
            )
          ]
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(import_components140.__experimentalGrid, { columns: 2, gap: 4, children: [
        /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
          ShadowInputControl,
          {
            label: (0, import_i18n168.__)("X Position"),
            value: shadowObj.x,
            onChange: (value) => onShadowChange("x", value)
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
          ShadowInputControl,
          {
            label: (0, import_i18n168.__)("Y Position"),
            value: shadowObj.y,
            onChange: (value) => onShadowChange("y", value)
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
          ShadowInputControl,
          {
            label: (0, import_i18n168.__)("Blur"),
            value: shadowObj.blur,
            onChange: (value) => onShadowChange("blur", value)
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
          ShadowInputControl,
          {
            label: (0, import_i18n168.__)("Spread"),
            value: shadowObj.spread,
            onChange: (value) => onShadowChange("spread", value)
          }
        )
      ] })
    ] });
  }
  function ShadowInputControl({
    label,
    value,
    onChange
  }) {
    const onValueChange = (next) => {
      const isNumeric = next !== void 0 && !isNaN(parseFloat(next));
      const nextValue = isNumeric ? next : "0px";
      onChange(nextValue);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
      import_components140.__experimentalUnitControl,
      {
        label,
        __next40pxDefaultSize: true,
        value,
        onChange: onValueChange
      }
    );
  }

  // packages/global-styles-ui/build-module/screen-shadows.mjs
  var import_jsx_runtime305 = __toESM(require_jsx_runtime(), 1);
  function ScreenShadows() {
    return /* @__PURE__ */ (0, import_jsx_runtime305.jsx)(ShadowsPanel, {});
  }
  function ScreenShadowsEdit() {
    return /* @__PURE__ */ (0, import_jsx_runtime305.jsx)(ShadowsEditPanel, {});
  }

  // packages/global-styles-ui/build-module/screen-layout.mjs
  var import_i18n169 = __toESM(require_i18n(), 1);
  var import_block_editor29 = __toESM(require_block_editor(), 1);

  // packages/global-styles-ui/build-module/dimensions-panel.mjs
  var import_block_editor28 = __toESM(require_block_editor(), 1);
  var import_element168 = __toESM(require_element(), 1);
  var import_jsx_runtime306 = __toESM(require_jsx_runtime(), 1);
  var { useSettingsForBlockElement: useSettingsForBlockElement6, DimensionsPanel: StylesDimensionsPanel2 } = unlock5(import_block_editor28.privateApis);
  var DEFAULT_CONTROLS = {
    contentSize: true,
    wideSize: true,
    padding: true,
    margin: true,
    blockGap: true,
    height: true,
    minHeight: true,
    minWidth: true,
    width: true,
    childLayout: false
  };
  function DimensionsPanel() {
    const [style] = useStyle("", void 0, "user", false);
    const [inheritedStyle, setStyle2] = useStyle(
      "",
      void 0,
      "merged",
      false
    );
    const [userSettings] = useSetting("", void 0, "user");
    const [rawSettings, setSettings] = useSetting("");
    const settings = useSettingsForBlockElement6(rawSettings);
    const inheritedStyleWithLayout = (0, import_element168.useMemo)(() => {
      return {
        ...inheritedStyle,
        layout: settings.layout
      };
    }, [inheritedStyle, settings.layout]);
    const styleWithLayout = (0, import_element168.useMemo)(() => {
      return {
        ...style,
        layout: userSettings.layout
      };
    }, [style, userSettings.layout]);
    const onChange = (newStyle) => {
      const updatedStyle = { ...newStyle };
      delete updatedStyle.layout;
      setStyle2(updatedStyle);
      if (newStyle.layout !== userSettings.layout) {
        const updatedSettings = {
          ...userSettings,
          layout: newStyle.layout
        };
        if (updatedSettings.layout?.definitions) {
          delete updatedSettings.layout.definitions;
        }
        setSettings(updatedSettings);
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
      StylesDimensionsPanel2,
      {
        inheritedValue: inheritedStyleWithLayout,
        value: styleWithLayout,
        onChange,
        settings,
        includeLayoutControls: true,
        defaultControls: DEFAULT_CONTROLS
      }
    );
  }

  // packages/global-styles-ui/build-module/screen-layout.mjs
  var import_jsx_runtime307 = __toESM(require_jsx_runtime(), 1);
  var { useHasDimensionsPanel: useHasDimensionsPanel4, useSettingsForBlockElement: useSettingsForBlockElement7 } = unlock5(
    import_block_editor29.privateApis
  );
  function ScreenLayout() {
    const [rawSettings] = useSetting("");
    const settings = useSettingsForBlockElement7(rawSettings);
    const hasDimensionsPanel = useHasDimensionsPanel4(settings);
    return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)(import_jsx_runtime307.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(ScreenHeader, { title: (0, import_i18n169.__)("Layout") }),
      hasDimensionsPanel && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(DimensionsPanel, {})
    ] });
  }
  var screen_layout_default = ScreenLayout;

  // packages/global-styles-ui/build-module/screen-style-variations.mjs
  var import_components143 = __toESM(require_components(), 1);
  var import_i18n172 = __toESM(require_i18n(), 1);

  // packages/global-styles-ui/build-module/style-variations-content.mjs
  var import_i18n171 = __toESM(require_i18n(), 1);
  var import_components142 = __toESM(require_components(), 1);

  // packages/global-styles-ui/build-module/style-variations-container.mjs
  var import_core_data47 = __toESM(require_core_data(), 1);
  var import_data72 = __toESM(require_data(), 1);
  var import_element169 = __toESM(require_element(), 1);
  var import_components141 = __toESM(require_components(), 1);
  var import_i18n170 = __toESM(require_i18n(), 1);
  var import_jsx_runtime308 = __toESM(require_jsx_runtime(), 1);
  function StyleVariationsContainer({
    gap = 2
  }) {
    const { user } = (0, import_element169.useContext)(GlobalStylesContext);
    const userStyles = user?.styles;
    const variations = (0, import_data72.useSelect)((select7) => {
      const result = select7(
        import_core_data47.store
      ).__experimentalGetCurrentThemeGlobalStylesVariations();
      return Array.isArray(result) ? result : void 0;
    }, []);
    const fullStyleVariations = variations?.filter(
      (variation) => {
        return !isVariationWithProperties(variation, ["color"]) && !isVariationWithProperties(variation, [
          "typography",
          "spacing"
        ]);
      }
    );
    const themeVariations = (0, import_element169.useMemo)(() => {
      const withEmptyVariation = [
        {
          title: (0, import_i18n170.__)("Default"),
          settings: {},
          styles: {}
        },
        ...fullStyleVariations ?? []
      ];
      return [
        ...withEmptyVariation.map((variation) => {
          const blockStyles = variation?.styles?.blocks ? { ...variation.styles.blocks } : {};
          if (userStyles?.blocks) {
            Object.keys(userStyles.blocks).forEach((blockName) => {
              if (userStyles.blocks?.[blockName]?.css) {
                const variationBlockStyles = blockStyles[blockName] || {};
                const customCSS = {
                  css: `${blockStyles[blockName]?.css || ""} ${userStyles.blocks?.[blockName]?.css?.trim() || ""}`
                };
                blockStyles[blockName] = {
                  ...variationBlockStyles,
                  ...customCSS
                };
              }
            });
          }
          const css = userStyles?.css || variation.styles?.css ? {
            css: `${variation.styles?.css || ""} ${userStyles?.css || ""}`
          } : {};
          const blocks = Object.keys(blockStyles).length > 0 ? { blocks: blockStyles } : {};
          const styles = {
            ...variation.styles,
            ...css,
            ...blocks
          };
          return {
            ...variation,
            settings: variation.settings ?? {},
            styles
          };
        })
      ];
    }, [fullStyleVariations, userStyles?.blocks, userStyles?.css]);
    if (!fullStyleVariations || fullStyleVariations.length < 1) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
      import_components141.__experimentalGrid,
      {
        columns: 2,
        className: "global-styles-ui-style-variations-container",
        gap,
        children: themeVariations.map(
          (variation, index) => /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(Variation, { variation, children: (isFocused) => /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
            preview_styles_default,
            {
              label: variation?.title,
              withHoverView: true,
              isFocused,
              variation
            }
          ) }, index)
        )
      }
    );
  }
  var style_variations_container_default = StyleVariationsContainer;

  // packages/global-styles-ui/build-module/style-variations-content.mjs
  var import_jsx_runtime309 = __toESM(require_jsx_runtime(), 1);
  function StyleVariationsContent() {
    const gap = 3;
    return /* @__PURE__ */ (0, import_jsx_runtime309.jsxs)(import_components142.__experimentalVStack, { spacing: 10, className: "global-styles-ui-variation-container", children: [
      /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(style_variations_container_default, { gap }),
      /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(ColorVariations, { title: (0, import_i18n171.__)("Color Variations"), gap }),
      /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(TypographyVariations, { title: (0, import_i18n171.__)("Typography"), gap })
    ] });
  }

  // packages/global-styles-ui/build-module/screen-style-variations.mjs
  var import_jsx_runtime310 = __toESM(require_jsx_runtime(), 1);
  function ScreenStyleVariations() {
    return /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)(import_jsx_runtime310.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(
        ScreenHeader,
        {
          title: (0, import_i18n172.__)("Browse styles"),
          description: (0, import_i18n172.__)(
            "Choose a variation to change the look of the site."
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(
        import_components143.Card,
        {
          size: "small",
          isBorderless: true,
          className: "global-styles-ui-screen-style-variations",
          children: /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(import_components143.CardBody, { children: /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(StyleVariationsContent, {}) })
        }
      )
    ] });
  }
  var screen_style_variations_default = ScreenStyleVariations;

  // packages/global-styles-ui/build-module/screen-css.mjs
  var import_i18n173 = __toESM(require_i18n(), 1);
  var import_components144 = __toESM(require_components(), 1);
  var import_block_editor30 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime311 = __toESM(require_jsx_runtime(), 1);
  var { AdvancedPanel: StylesAdvancedPanel2 } = unlock5(import_block_editor30.privateApis);
  function ScreenCSS() {
    const [style] = useStyle("", void 0, "user", false);
    const [inheritedStyle, setStyle2] = useStyle(
      "",
      void 0,
      "merged",
      false
    );
    return /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)(import_jsx_runtime311.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(
        ScreenHeader,
        {
          title: (0, import_i18n173.__)("Additional CSS"),
          description: /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)(import_jsx_runtime311.Fragment, { children: [
            (0, import_i18n173.__)(
              "You can add custom CSS to further customize the appearance and layout of your site."
            ),
            /* @__PURE__ */ (0, import_jsx_runtime311.jsx)("br", {}),
            /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(
              import_components144.ExternalLink,
              {
                href: (0, import_i18n173.__)(
                  "https://developer.wordpress.org/advanced-administration/wordpress/css/"
                ),
                className: "global-styles-ui-screen-css-help-link",
                children: (0, import_i18n173.__)("Learn more about CSS")
              }
            )
          ] })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "global-styles-ui-screen-css", children: /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(
        StylesAdvancedPanel2,
        {
          value: style,
          onChange: setStyle2,
          inheritedValue: inheritedStyle
        }
      ) })
    ] });
  }
  var screen_css_default = ScreenCSS;

  // packages/global-styles-ui/build-module/screen-revisions/index.mjs
  var import_i18n176 = __toESM(require_i18n(), 1);
  var import_components147 = __toESM(require_components(), 1);
  var import_element171 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/screen-revisions/use-global-styles-revisions.mjs
  var import_data73 = __toESM(require_data(), 1);
  var import_core_data48 = __toESM(require_core_data(), 1);
  var import_element170 = __toESM(require_element(), 1);
  var SITE_EDITOR_AUTHORS_QUERY = {
    per_page: -1,
    _fields: "id,name,avatar_urls",
    context: "view",
    capabilities: ["edit_theme_options"]
  };
  var DEFAULT_QUERY = { per_page: 100, page: 1 };
  var EMPTY_ARRAY10 = [];
  function useGlobalStylesRevisions({
    query
  } = {}) {
    const { user: userConfig } = (0, import_element170.useContext)(GlobalStylesContext);
    const _query = (0, import_element170.useMemo)(
      () => ({ ...DEFAULT_QUERY, ...query }),
      [query]
    );
    const {
      authors,
      currentUser,
      isDirty,
      revisions,
      isLoadingGlobalStylesRevisions,
      revisionsCount
    } = (0, import_data73.useSelect)(
      (select7) => {
        const {
          __experimentalGetDirtyEntityRecords,
          getCurrentUser,
          getUsers,
          getRevisions,
          __experimentalGetCurrentGlobalStylesId,
          getEntityRecord,
          isResolving
        } = select7(import_core_data48.store);
        const dirtyEntityRecords = __experimentalGetDirtyEntityRecords() || [];
        const _currentUser = getCurrentUser();
        const _isDirty = dirtyEntityRecords.length > 0;
        const globalStylesId = __experimentalGetCurrentGlobalStylesId();
        const globalStyles = globalStylesId ? getEntityRecord(
          "root",
          "globalStyles",
          globalStylesId
        ) : void 0;
        const _revisionsCount = (
          // @ts-expect-error - _links is not typed in GlobalStylesRevision
          globalStyles?._links?.["version-history"]?.[0]?.count ?? 0
        );
        const globalStylesRevisions = globalStylesId ? getRevisions(
          "root",
          "globalStyles",
          globalStylesId,
          _query
        ) || EMPTY_ARRAY10 : EMPTY_ARRAY10;
        const _authors = getUsers(SITE_EDITOR_AUTHORS_QUERY) || EMPTY_ARRAY10;
        const _isResolving = globalStylesId ? isResolving("getRevisions", [
          "root",
          "globalStyles",
          globalStylesId,
          _query
        ]) : false;
        return {
          authors: _authors,
          currentUser: _currentUser,
          isDirty: _isDirty,
          revisions: globalStylesRevisions,
          isLoadingGlobalStylesRevisions: _isResolving,
          revisionsCount: _revisionsCount
        };
      },
      [_query]
    );
    return (0, import_element170.useMemo)(() => {
      if (!authors.length || isLoadingGlobalStylesRevisions) {
        return {
          revisions: EMPTY_ARRAY10,
          hasUnsavedChanges: isDirty,
          isLoading: true,
          revisionsCount
        };
      }
      const _modifiedRevisions = revisions.map((revision) => {
        return {
          ...revision,
          author: authors.find(
            (author) => author.id === revision.author
          )
        };
      });
      const fetchedRevisionsCount = revisions.length;
      if (fetchedRevisionsCount) {
        if (_modifiedRevisions[0].id !== "unsaved" && _query.page === 1) {
          _modifiedRevisions[0].isLatest = true;
        }
        if (isDirty && userConfig && Object.keys(userConfig).length > 0 && currentUser && _query.page === 1) {
          const unsavedRevision = {
            id: "unsaved",
            styles: userConfig?.styles,
            settings: userConfig?.settings,
            _links: userConfig?._links,
            author: {
              name: currentUser?.name || "",
              // @ts-expect-error - avatar_urls is not typed in User
              avatar_urls: currentUser?.avatar_urls || {}
            },
            modified: /* @__PURE__ */ new Date()
          };
          _modifiedRevisions.unshift(unsavedRevision);
        }
        if (_query.per_page && _query.page === Math.ceil(revisionsCount / _query.per_page)) {
          _modifiedRevisions.push({
            id: "parent",
            styles: {},
            settings: {}
          });
        }
      }
      return {
        revisions: _modifiedRevisions,
        hasUnsavedChanges: isDirty,
        isLoading: false,
        revisionsCount
      };
    }, [
      isDirty,
      revisions,
      currentUser,
      authors,
      userConfig,
      isLoadingGlobalStylesRevisions,
      revisionsCount,
      _query.page,
      _query.per_page
    ]);
  }

  // packages/global-styles-ui/build-module/screen-revisions/revisions-buttons.mjs
  var import_i18n174 = __toESM(require_i18n(), 1);
  var import_components145 = __toESM(require_components(), 1);
  var import_date15 = __toESM(require_date(), 1);
  var import_core_data49 = __toESM(require_core_data(), 1);
  var import_data74 = __toESM(require_data(), 1);
  var import_keycodes5 = __toESM(require_keycodes(), 1);
  var import_jsx_runtime312 = __toESM(require_jsx_runtime(), 1);
  var DAY_IN_MILLISECONDS = 60 * 60 * 1e3 * 24;
  function ChangesSummary({ revision, previousRevision }) {
    const changes = getGlobalStylesChanges(
      revision,
      previousRevision,
      {
        maxResults: 7
      }
    );
    if (!changes.length) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
      "ul",
      {
        "data-testid": "global-styles-revision-changes",
        className: "global-styles-ui-screen-revisions__changes",
        children: changes.map((change) => /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("li", { children: change }, change))
      }
    );
  }
  function getRevisionLabel(id, authorDisplayName, formattedModifiedDate, areStylesEqual) {
    if ("parent" === id) {
      return (0, import_i18n174.__)("Reset the styles to the theme defaults");
    }
    if ("unsaved" === id) {
      return (0, import_i18n174.sprintf)(
        /* translators: %s: author display name */
        (0, import_i18n174.__)("Unsaved changes by %s"),
        authorDisplayName
      );
    }
    return areStylesEqual ? (0, import_i18n174.sprintf)(
      // translators: 1: author display name. 2: revision creation date.
      (0, import_i18n174.__)(
        "Changes saved by %1$s on %2$s. This revision matches current editor styles."
      ),
      authorDisplayName,
      formattedModifiedDate
    ) : (0, import_i18n174.sprintf)(
      // translators: 1: author display name. 2: revision creation date.
      (0, import_i18n174.__)("Changes saved by %1$s on %2$s"),
      authorDisplayName,
      formattedModifiedDate
    );
  }
  function RevisionsButtons({
    userRevisions,
    selectedRevisionId,
    onChange,
    canApplyRevision,
    onApplyRevision
  }) {
    const { currentThemeName, currentUser } = (0, import_data74.useSelect)((select7) => {
      const { getCurrentTheme, getCurrentUser } = select7(import_core_data49.store);
      const currentTheme = getCurrentTheme();
      return {
        currentThemeName: currentTheme?.name?.rendered || currentTheme?.stylesheet,
        currentUser: getCurrentUser()
      };
    }, []);
    const dateNowInMs = (0, import_date15.getDate)(null).getTime();
    const { datetimeAbbreviated } = (0, import_date15.getSettings)().formats;
    return /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
      import_components145.Composite,
      {
        orientation: "vertical",
        className: "global-styles-ui-screen-revisions__revisions-list",
        "aria-label": (0, import_i18n174.__)("Global styles revisions list"),
        role: "listbox",
        children: userRevisions.map((revision, index) => {
          const { id, author, modified } = revision;
          const isUnsaved = "unsaved" === id;
          const revisionAuthor = isUnsaved ? currentUser : author;
          const authorDisplayName = revisionAuthor?.name || (0, import_i18n174.__)("User");
          const authorAvatar = revisionAuthor?.avatar_urls?.["48"];
          const isFirstItem = index === 0;
          const isSelected2 = selectedRevisionId ? selectedRevisionId === id : isFirstItem;
          const areStylesEqual = !canApplyRevision && isSelected2;
          const isReset = "parent" === id;
          const modifiedString = modified instanceof Date ? modified.toISOString() : modified;
          const modifiedDate = (0, import_date15.getDate)(modifiedString ?? null);
          const displayDate = modifiedString && dateNowInMs - modifiedDate.getTime() > DAY_IN_MILLISECONDS ? (0, import_date15.dateI18n)(datetimeAbbreviated, modifiedDate) : (0, import_date15.humanTimeDiff)(
            modifiedString ?? modifiedDate,
            void 0
          );
          const revisionLabel = getRevisionLabel(
            id,
            authorDisplayName,
            (0, import_date15.dateI18n)(datetimeAbbreviated, modifiedDate),
            areStylesEqual
          );
          return /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(
            import_components145.Composite.Item,
            {
              className: "global-styles-ui-screen-revisions__revision-item",
              "aria-current": isSelected2,
              role: "option",
              onKeyDown: (event) => {
                const { keyCode } = event;
                if (keyCode === import_keycodes5.ENTER || keyCode === import_keycodes5.SPACE) {
                  onChange(revision);
                }
              },
              onClick: (event) => {
                event.preventDefault();
                onChange(revision);
              },
              "aria-selected": isSelected2,
              "aria-label": revisionLabel,
              render: /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("div", {}),
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("span", { className: "global-styles-ui-screen-revisions__revision-item-wrapper", children: isReset ? /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)("span", { className: "global-styles-ui-screen-revisions__description", children: [
                  (0, import_i18n174.__)("Default styles"),
                  /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("span", { className: "global-styles-ui-screen-revisions__meta", children: currentThemeName })
                ] }) : /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)("span", { className: "global-styles-ui-screen-revisions__description", children: [
                  isUnsaved ? /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("span", { className: "global-styles-ui-screen-revisions__date", children: (0, import_i18n174.__)("(Unsaved)") }) : /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
                    "time",
                    {
                      className: "global-styles-ui-screen-revisions__date",
                      dateTime: modifiedString,
                      children: displayDate
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)("span", { className: "global-styles-ui-screen-revisions__meta", children: [
                    /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
                      "img",
                      {
                        alt: authorDisplayName,
                        src: authorAvatar
                      }
                    ),
                    authorDisplayName
                  ] }),
                  isSelected2 && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
                    ChangesSummary,
                    {
                      revision,
                      previousRevision: index < userRevisions.length ? userRevisions[index + 1] : void 0
                    }
                  )
                ] }) }),
                isSelected2 && (areStylesEqual ? /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("p", { className: "global-styles-ui-screen-revisions__applied-text", children: (0, import_i18n174.__)(
                  "These styles are already applied to your site."
                ) }) : /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
                  import_components145.Button,
                  {
                    size: "compact",
                    variant: "primary",
                    className: "global-styles-ui-screen-revisions__apply-button",
                    onClick: onApplyRevision,
                    "aria-label": (0, import_i18n174.__)(
                      "Apply the selected revision to your site."
                    ),
                    children: isReset ? (0, import_i18n174.__)("Reset to defaults") : (0, import_i18n174.__)("Apply")
                  }
                ))
              ]
            },
            id
          );
        })
      }
    );
  }
  var revisions_buttons_default = RevisionsButtons;

  // packages/global-styles-ui/build-module/pagination/index.mjs
  var import_components146 = __toESM(require_components(), 1);
  var import_i18n175 = __toESM(require_i18n(), 1);
  var import_jsx_runtime313 = __toESM(require_jsx_runtime(), 1);
  function Pagination({
    currentPage,
    numPages,
    changePage,
    totalItems,
    className,
    disabled: disabled2 = false,
    buttonVariant = "tertiary",
    label = (0, import_i18n175.__)("Pagination")
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime313.jsxs)(
      import_components146.__experimentalHStack,
      {
        expanded: false,
        as: "nav",
        "aria-label": label,
        spacing: 3,
        justify: "flex-start",
        className: clsx_default("global-styles-ui-pagination", className),
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
            import_components146.__experimentalText,
            {
              variant: "muted",
              className: "global-styles-ui-pagination__total",
              children: (0, import_i18n175.sprintf)(
                // translators: %d: Total number of patterns.
                (0, import_i18n175._n)("%d item", "%d items", totalItems),
                totalItems
              )
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime313.jsxs)(import_components146.__experimentalHStack, { expanded: false, spacing: 1, children: [
            /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
              import_components146.Button,
              {
                variant: buttonVariant,
                onClick: () => changePage(1),
                accessibleWhenDisabled: true,
                disabled: disabled2 || currentPage === 1,
                label: (0, import_i18n175.__)("First page"),
                icon: (0, import_i18n175.isRTL)() ? next_default : previous_default,
                size: "compact"
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
              import_components146.Button,
              {
                variant: buttonVariant,
                onClick: () => changePage(currentPage - 1),
                accessibleWhenDisabled: true,
                disabled: disabled2 || currentPage === 1,
                label: (0, import_i18n175.__)("Previous page"),
                icon: (0, import_i18n175.isRTL)() ? chevron_right_default : chevron_left_default,
                size: "compact"
              }
            )
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(import_components146.__experimentalText, { variant: "muted", children: (0, import_i18n175.sprintf)(
            // translators: 1: Current page number. 2: Total number of pages.
            (0, import_i18n175._x)("%1$d of %2$d", "paging"),
            currentPage,
            numPages
          ) }),
          /* @__PURE__ */ (0, import_jsx_runtime313.jsxs)(import_components146.__experimentalHStack, { expanded: false, spacing: 1, children: [
            /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
              import_components146.Button,
              {
                variant: buttonVariant,
                onClick: () => changePage(currentPage + 1),
                accessibleWhenDisabled: true,
                disabled: disabled2 || currentPage === numPages,
                label: (0, import_i18n175.__)("Next page"),
                icon: (0, import_i18n175.isRTL)() ? chevron_left_default : chevron_right_default,
                size: "compact"
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
              import_components146.Button,
              {
                variant: buttonVariant,
                onClick: () => changePage(numPages),
                accessibleWhenDisabled: true,
                disabled: disabled2 || currentPage === numPages,
                label: (0, import_i18n175.__)("Last page"),
                icon: (0, import_i18n175.isRTL)() ? previous_default : next_default,
                size: "compact"
              }
            )
          ] })
        ]
      }
    );
  }

  // packages/global-styles-ui/build-module/screen-revisions/index.mjs
  var import_jsx_runtime314 = __toESM(require_jsx_runtime(), 1);
  var PAGE_SIZE = 10;
  function ScreenRevisions({ onClose } = {}) {
    const { user: currentEditorGlobalStyles, onChange: setUserConfig } = (0, import_element171.useContext)(GlobalStylesContext);
    const { params, goTo } = (0, import_components147.useNavigator)();
    const { revisionId: revisionId2 } = params;
    const [currentPage, setCurrentPage] = (0, import_element171.useState)(1);
    const { revisions, isLoading, hasUnsavedChanges, revisionsCount } = useGlobalStylesRevisions({
      query: {
        per_page: PAGE_SIZE,
        page: currentPage
      }
    });
    const numPages = Math.ceil(revisionsCount / PAGE_SIZE);
    const [
      isLoadingRevisionWithUnsavedChanges,
      setIsLoadingRevisionWithUnsavedChanges
    ] = (0, import_element171.useState)(false);
    const currentlySelectedRevision = (0, import_element171.useMemo)(() => {
      if (!revisionId2) {
        return currentEditorGlobalStyles;
      }
      const revision = revisions.find(
        (rev) => String(rev.id) === String(revisionId2)
      );
      return revision || currentEditorGlobalStyles;
    }, [revisionId2, revisions, currentEditorGlobalStyles]);
    const selectedRevisionMatchesEditorStyles = areGlobalStylesEqual(
      currentlySelectedRevision,
      currentEditorGlobalStyles
    );
    const onCloseRevisions = () => {
      if (onClose) {
        onClose();
      }
    };
    const restoreRevision2 = (revision) => {
      setUserConfig(revision);
      setIsLoadingRevisionWithUnsavedChanges(false);
      onCloseRevisions();
    };
    const handleRevisionSelect = (revision) => {
      goTo(`/revisions/${revision.id}`);
    };
    const currentlySelectedRevisionId = (
      // @ts-expect-error: revision id is not present in the fallback (default object).
      currentlySelectedRevision?.id ?? revisions[0]?.id
    );
    const isLoadButtonEnabled = !!currentlySelectedRevisionId && currentlySelectedRevisionId !== "unsaved" && !selectedRevisionMatchesEditorStyles;
    const hasRevisions = !!revisions.length;
    return /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)(import_jsx_runtime314.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
        ScreenHeader,
        {
          title: revisionsCount ? (0, import_i18n176.sprintf)(
            // translators: %d: number of revisions.
            (0, import_i18n176.__)("Revisions (%d)"),
            revisionsCount
          ) : (0, import_i18n176.__)("Revisions"),
          description: (0, import_i18n176.__)(
            `Click on previously saved styles to preview them. To restore a selected version to the editor, hit "Apply." When you're ready, use the Save button to save your changes.`
          ),
          onBack: onCloseRevisions
        }
      ),
      !hasRevisions && /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(import_components147.Spinner, { className: "global-styles-ui-screen-revisions__loading" }),
      /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
        revisions_buttons_default,
        {
          onChange: handleRevisionSelect,
          selectedRevisionId: currentlySelectedRevisionId,
          userRevisions: revisions,
          canApplyRevision: isLoadButtonEnabled,
          onApplyRevision: () => hasUnsavedChanges ? setIsLoadingRevisionWithUnsavedChanges(true) : restoreRevision2(currentlySelectedRevision)
        }
      ),
      numPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime314.jsx)("div", { className: "global-styles-ui-screen-revisions__footer", children: /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
        Pagination,
        {
          className: "global-styles-ui-screen-revisions__pagination",
          currentPage,
          numPages,
          changePage: setCurrentPage,
          totalItems: revisionsCount,
          disabled: isLoading,
          label: (0, import_i18n176.__)("Global Styles pagination")
        }
      ) }),
      isLoadingRevisionWithUnsavedChanges && /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
        import_components147.__experimentalConfirmDialog,
        {
          isOpen: isLoadingRevisionWithUnsavedChanges,
          confirmButtonText: (0, import_i18n176.__)("Apply"),
          onConfirm: () => restoreRevision2(currentlySelectedRevision),
          onCancel: () => setIsLoadingRevisionWithUnsavedChanges(false),
          size: "medium",
          children: (0, import_i18n176.__)(
            "Are you sure you want to apply this revision? Any unsaved changes will be lost."
          )
        }
      )
    ] });
  }
  var screen_revisions_default = ScreenRevisions;

  // packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs
  var import_i18n178 = __toESM(require_i18n(), 1);
  var import_components149 = __toESM(require_components(), 1);
  var import_element172 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/font-sizes/confirm-reset-font-sizes-dialog.mjs
  var import_components148 = __toESM(require_components(), 1);
  var import_i18n177 = __toESM(require_i18n(), 1);
  var import_jsx_runtime315 = __toESM(require_jsx_runtime(), 1);
  function ConfirmResetFontSizesDialog({
    text,
    confirmButtonText,
    isOpen: isOpen2,
    toggleOpen,
    onConfirm
  }) {
    const handleConfirm = async () => {
      toggleOpen();
      onConfirm();
    };
    const handleCancel = () => {
      toggleOpen();
    };
    return /* @__PURE__ */ (0, import_jsx_runtime315.jsx)(
      import_components148.__experimentalConfirmDialog,
      {
        isOpen: isOpen2,
        cancelButtonText: (0, import_i18n177.__)("Cancel"),
        confirmButtonText,
        onCancel: handleCancel,
        onConfirm: handleConfirm,
        size: "medium",
        children: text
      }
    );
  }
  var confirm_reset_font_sizes_dialog_default = ConfirmResetFontSizesDialog;

  // packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs
  var import_jsx_runtime316 = __toESM(require_jsx_runtime(), 1);
  var { Menu: Menu8 } = unlock5(import_components149.privateApis);
  function FontSizeGroup({
    label,
    origin,
    sizes,
    handleAddFontSize,
    handleResetFontSizes
  }) {
    const [isResetDialogOpen, setIsResetDialogOpen] = (0, import_element172.useState)(false);
    const toggleResetDialog = () => setIsResetDialogOpen(!isResetDialogOpen);
    const resetDialogText = origin === "custom" ? (0, import_i18n178.__)(
      "Are you sure you want to remove all custom font size presets?"
    ) : (0, import_i18n178.__)(
      "Are you sure you want to reset all font size presets to their default values?"
    );
    return /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_jsx_runtime316.Fragment, { children: [
      handleResetFontSizes && isResetDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
        confirm_reset_font_sizes_dialog_default,
        {
          text: resetDialogText,
          confirmButtonText: origin === "custom" ? (0, import_i18n178.__)("Remove") : (0, import_i18n178.__)("Reset"),
          isOpen: isResetDialogOpen,
          toggleOpen: toggleResetDialog,
          onConfirm: handleResetFontSizes
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_components149.__experimentalVStack, { spacing: 4, children: [
        /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_components149.__experimentalHStack, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(Subtitle, { level: 3, children: label }),
          /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_components149.FlexItem, { className: "global-styles-ui__typography-panel__options-container", children: [
            origin === "custom" && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
              import_components149.Button,
              {
                label: (0, import_i18n178.__)("Add font size"),
                icon: plus_default,
                size: "small",
                onClick: handleAddFontSize
              }
            ),
            !!handleResetFontSizes && /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(Menu8, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
                Menu8.TriggerButton,
                {
                  render: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
                    import_components149.Button,
                    {
                      size: "small",
                      icon: more_vertical_default,
                      label: (0, import_i18n178.__)(
                        "Font size presets options"
                      )
                    }
                  )
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(Menu8.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(Menu8.Item, { onClick: toggleResetDialog, children: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(Menu8.ItemLabel, { children: origin === "custom" ? (0, import_i18n178.__)(
                "Remove font size presets"
              ) : (0, import_i18n178.__)(
                "Reset font size presets"
              ) }) }) })
            ] })
          ] })
        ] }),
        !!sizes.length && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components149.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: sizes.map((size) => /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
          NavigationButtonAsItem,
          {
            path: `/typography/font-sizes/${origin}/${size.slug}`,
            children: /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_components149.__experimentalHStack, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components149.FlexItem, { className: "global-styles-ui-font-size__item", children: size.name }),
              /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components149.FlexItem, { display: "flex", children: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
                icon_default,
                {
                  icon: (0, import_i18n178.isRTL)() ? chevron_left_default : chevron_right_default
                }
              ) })
            ] })
          },
          size.slug
        )) })
      ] })
    ] });
  }
  function FontSizes2() {
    const [themeFontSizes, setThemeFontSizes] = useSetting(
      "typography.fontSizes.theme"
    );
    const [baseThemeFontSizes] = useSetting(
      "typography.fontSizes.theme",
      "base"
    );
    const [defaultFontSizes, setDefaultFontSizes] = useSetting(
      "typography.fontSizes.default"
    );
    const [baseDefaultFontSizes] = useSetting(
      "typography.fontSizes.default",
      "base"
    );
    const [customFontSizes = [], setCustomFontSizes] = useSetting(
      "typography.fontSizes.custom"
    );
    const [defaultFontSizesEnabled] = useSetting(
      "typography.defaultFontSizes"
    );
    const handleAddFontSize = () => {
      const index = getNewIndexFromPresets(customFontSizes, "custom-");
      const newFontSize = {
        /* translators: %d: font size index */
        name: (0, import_i18n178.sprintf)((0, import_i18n178.__)("New Font Size %d"), index),
        size: "16px",
        slug: `custom-${index}`
      };
      setCustomFontSizes([...customFontSizes, newFontSize]);
    };
    const hasSameSizeValues = (arr1, arr2) => arr1.map((item) => item.size).join("") === arr2.map((item) => item.size).join("");
    return /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_components149.__experimentalVStack, { spacing: 2, children: [
      /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
        ScreenHeader,
        {
          title: (0, import_i18n178.__)("Font size presets"),
          description: (0, import_i18n178.__)(
            "Create and edit the presets used for font sizes across the site."
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components149.__experimentalView, { children: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components149.__experimentalSpacer, { paddingX: 4, children: /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_components149.__experimentalVStack, { spacing: 8, children: [
        !!themeFontSizes?.length && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
          FontSizeGroup,
          {
            label: (0, import_i18n178.__)("Theme"),
            origin: "theme",
            sizes: themeFontSizes,
            handleAddFontSize,
            handleResetFontSizes: hasSameSizeValues(
              themeFontSizes,
              baseThemeFontSizes
            ) ? void 0 : () => setThemeFontSizes(
              baseThemeFontSizes
            )
          }
        ),
        defaultFontSizesEnabled && !!defaultFontSizes?.length && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
          FontSizeGroup,
          {
            label: (0, import_i18n178.__)("Default"),
            origin: "default",
            sizes: defaultFontSizes,
            handleAddFontSize,
            handleResetFontSizes: hasSameSizeValues(
              defaultFontSizes,
              baseDefaultFontSizes
            ) ? void 0 : () => setDefaultFontSizes(
              baseDefaultFontSizes
            )
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
          FontSizeGroup,
          {
            label: (0, import_i18n178.__)("Custom"),
            origin: "custom",
            sizes: customFontSizes,
            handleAddFontSize,
            handleResetFontSizes: customFontSizes.length > 0 ? () => setCustomFontSizes([]) : void 0
          }
        )
      ] }) }) })
    ] });
  }
  var font_sizes_default = FontSizes2;

  // packages/global-styles-ui/build-module/font-sizes/font-size.mjs
  var import_i18n182 = __toESM(require_i18n(), 1);
  var import_components153 = __toESM(require_components(), 1);
  var import_element174 = __toESM(require_element(), 1);

  // packages/global-styles-ui/build-module/font-sizes/font-size-preview.mjs
  var import_block_editor31 = __toESM(require_block_editor(), 1);
  var import_i18n179 = __toESM(require_i18n(), 1);
  var import_jsx_runtime317 = __toESM(require_jsx_runtime(), 1);
  function FontSizePreview({ fontSize }) {
    const [font2] = useStyle("typography");
    const input = typeof fontSize?.fluid === "object" && fontSize?.fluid?.min && fontSize?.fluid?.max ? {
      minimumFontSize: fontSize.fluid.min,
      maximumFontSize: fontSize.fluid.max
    } : {
      fontSize: fontSize.size
    };
    const computedFontSize = (0, import_block_editor31.getComputedFluidTypographyValue)(input);
    return /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(
      "div",
      {
        className: "global-styles-ui-typography-preview",
        style: {
          fontSize: computedFontSize,
          fontFamily: font2?.fontFamily ?? "serif"
        },
        children: (0, import_i18n179.__)("Aa")
      }
    );
  }
  var font_size_preview_default = FontSizePreview;

  // packages/global-styles-ui/build-module/font-sizes/confirm-delete-font-size-dialog.mjs
  var import_components150 = __toESM(require_components(), 1);
  var import_i18n180 = __toESM(require_i18n(), 1);
  var import_jsx_runtime318 = __toESM(require_jsx_runtime(), 1);
  function ConfirmDeleteFontSizeDialog({
    fontSize,
    isOpen: isOpen2,
    toggleOpen,
    handleRemoveFontSize
  }) {
    const handleConfirm = async () => {
      toggleOpen();
      handleRemoveFontSize(fontSize);
    };
    const handleCancel = () => {
      toggleOpen();
    };
    return /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(
      import_components150.__experimentalConfirmDialog,
      {
        isOpen: isOpen2,
        cancelButtonText: (0, import_i18n180.__)("Cancel"),
        confirmButtonText: (0, import_i18n180.__)("Delete"),
        onCancel: handleCancel,
        onConfirm: handleConfirm,
        size: "medium",
        children: fontSize && (0, import_i18n180.sprintf)(
          /* translators: %s: Name of the font size preset. */
          (0, import_i18n180.__)(
            'Are you sure you want to delete "%s" font size preset?'
          ),
          fontSize.name
        )
      }
    );
  }
  var confirm_delete_font_size_dialog_default = ConfirmDeleteFontSizeDialog;

  // packages/global-styles-ui/build-module/font-sizes/rename-font-size-dialog.mjs
  var import_components151 = __toESM(require_components(), 1);
  var import_i18n181 = __toESM(require_i18n(), 1);
  var import_element173 = __toESM(require_element(), 1);
  var import_jsx_runtime319 = __toESM(require_jsx_runtime(), 1);
  function RenameFontSizeDialog({
    fontSize,
    toggleOpen,
    handleRename
  }) {
    const [newName, setNewName] = (0, import_element173.useState)(
      fontSize.name
    );
    const handleConfirm = () => {
      if (newName && newName.trim()) {
        handleRename(newName);
      }
      toggleOpen();
    };
    return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
      import_components151.Modal,
      {
        onRequestClose: toggleOpen,
        focusOnMount: "firstContentElement",
        title: (0, import_i18n181.__)("Rename"),
        size: "small",
        children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
          "form",
          {
            onSubmit: (event) => {
              event.preventDefault();
              handleConfirm();
              toggleOpen();
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)(import_components151.__experimentalVStack, { spacing: "3", children: [
              /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
                import_components151.__experimentalInputControl,
                {
                  __next40pxDefaultSize: true,
                  autoComplete: "off",
                  value: newName,
                  onChange: setNewName,
                  label: (0, import_i18n181.__)("Name"),
                  placeholder: (0, import_i18n181.__)("Font size preset name")
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)(import_components151.__experimentalHStack, { justify: "right", children: [
                /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
                  import_components151.Button,
                  {
                    __next40pxDefaultSize: true,
                    variant: "tertiary",
                    onClick: toggleOpen,
                    children: (0, import_i18n181.__)("Cancel")
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
                  import_components151.Button,
                  {
                    __next40pxDefaultSize: true,
                    variant: "primary",
                    type: "submit",
                    children: (0, import_i18n181.__)("Save")
                  }
                )
              ] })
            ] })
          }
        )
      }
    );
  }
  var rename_font_size_dialog_default = RenameFontSizeDialog;

  // packages/global-styles-ui/build-module/size-control/index.mjs
  var import_components152 = __toESM(require_components(), 1);
  var import_jsx_runtime320 = __toESM(require_jsx_runtime(), 1);
  var DEFAULT_UNITS = ["px", "em", "rem", "vw", "vh"];
  function SizeControl(props) {
    const { baseControlProps } = (0, import_components152.useBaseControlProps)(props);
    const { value, onChange, fallbackValue, disabled: disabled2, label } = props;
    const units = (0, import_components152.__experimentalUseCustomUnits)({
      availableUnits: DEFAULT_UNITS
    });
    const [valueQuantity, valueUnit = "px"] = (0, import_components152.__experimentalParseQuantityAndUnitFromRawValue)(value, units);
    const isValueUnitRelative = !!valueUnit && ["em", "rem", "vw", "vh"].includes(valueUnit);
    const handleUnitControlChange = (newValue) => {
      onChange?.(newValue);
    };
    const handleRangeControlChange = (newValue) => {
      if (newValue !== void 0) {
        onChange?.(newValue + valueUnit);
      } else {
        onChange?.(void 0);
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(import_components152.BaseControl, { ...baseControlProps, children: /* @__PURE__ */ (0, import_jsx_runtime320.jsxs)(import_components152.Flex, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(import_components152.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(
        import_components152.__experimentalUnitControl,
        {
          __next40pxDefaultSize: true,
          label,
          hideLabelFromVision: true,
          value,
          onChange: handleUnitControlChange,
          units,
          min: 0,
          disabled: disabled2
        }
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(import_components152.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(import_components152.__experimentalSpacer, { marginX: 2, marginBottom: 0, children: /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(
        import_components152.RangeControl,
        {
          __next40pxDefaultSize: true,
          label,
          hideLabelFromVision: true,
          value: valueQuantity,
          initialPosition: fallbackValue,
          withInputField: false,
          onChange: handleRangeControlChange,
          min: 0,
          max: isValueUnitRelative ? 10 : 100,
          step: isValueUnitRelative ? 0.1 : 1,
          disabled: disabled2
        }
      ) }) })
    ] }) });
  }

  // packages/global-styles-ui/build-module/font-sizes/font-size.mjs
  var import_jsx_runtime321 = __toESM(require_jsx_runtime(), 1);
  var { Menu: Menu9 } = unlock5(import_components153.privateApis);
  function FontSize() {
    const [isDeleteConfirmOpen, setIsDeleteConfirmOpen] = (0, import_element174.useState)(false);
    const [isRenameDialogOpen, setIsRenameDialogOpen] = (0, import_element174.useState)(false);
    const {
      params: { origin, slug },
      goBack
    } = (0, import_components153.useNavigator)();
    const [fontSizes, setFontSizes] = useSetting("typography.fontSizes");
    const [globalFluid] = useSetting("typography.fluid");
    const sizes = fontSizes?.[origin] ?? [];
    const fontSize = sizes.find(
      (size) => size.slug === slug
    );
    (0, import_element174.useEffect)(() => {
      if (!!slug && !fontSize) {
        goBack();
      }
    }, [slug, fontSize, goBack]);
    if (!origin || !slug || !fontSize) {
      return null;
    }
    const isFluid = fontSize?.fluid !== void 0 ? !!fontSize.fluid : !!globalFluid;
    const isCustomFluid = typeof fontSize?.fluid === "object";
    const handleNameChange = (value) => {
      updateFontSize("name", value);
    };
    const handleFontSizeChange = (value) => {
      updateFontSize("size", value);
    };
    const handleFluidChange = (value) => {
      updateFontSize("fluid", value);
    };
    const handleCustomFluidValues = (value) => {
      if (value) {
        updateFontSize("fluid", {
          min: fontSize.size,
          max: fontSize.size
        });
      } else {
        updateFontSize("fluid", true);
      }
    };
    const handleMinChange = (value) => {
      const fluid = typeof fontSize.fluid === "object" ? fontSize.fluid : {};
      updateFontSize("fluid", { ...fluid, min: value });
    };
    const handleMaxChange = (value) => {
      const fluid = typeof fontSize.fluid === "object" ? fontSize.fluid : {};
      updateFontSize("fluid", { ...fluid, max: value });
    };
    const updateFontSize = (key, value) => {
      const newFontSizes = sizes.map((size) => {
        if (size.slug === slug) {
          return { ...size, [key]: value };
        }
        return size;
      });
      setFontSizes({
        ...fontSizes,
        [origin]: newFontSizes
      });
    };
    const handleRemoveFontSize = () => {
      const newFontSizes = sizes.filter((size) => size.slug !== slug);
      setFontSizes({
        ...fontSizes,
        [origin]: newFontSizes
      });
    };
    const toggleDeleteConfirm = () => {
      setIsDeleteConfirmOpen(!isDeleteConfirmOpen);
    };
    const toggleRenameDialog = () => {
      setIsRenameDialogOpen(!isRenameDialogOpen);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(import_jsx_runtime321.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
        confirm_delete_font_size_dialog_default,
        {
          fontSize,
          isOpen: isDeleteConfirmOpen,
          toggleOpen: toggleDeleteConfirm,
          handleRemoveFontSize
        }
      ),
      isRenameDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
        rename_font_size_dialog_default,
        {
          fontSize,
          toggleOpen: toggleRenameDialog,
          handleRename: handleNameChange
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(import_components153.__experimentalVStack, { spacing: 4, children: [
        /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(import_components153.__experimentalHStack, { justify: "space-between", alignment: "flex-start", children: [
          /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
            ScreenHeader,
            {
              title: fontSize.name,
              description: (0, import_i18n182.sprintf)(
                /* translators: %s: font size preset name. */
                (0, import_i18n182.__)("Manage the font size %s."),
                fontSize.name
              )
            }
          ),
          origin === "custom" && /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_components153.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
            import_components153.__experimentalSpacer,
            {
              marginTop: 3,
              marginBottom: 0,
              paddingX: 4,
              children: /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(Menu9, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
                  Menu9.TriggerButton,
                  {
                    render: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
                      import_components153.Button,
                      {
                        size: "small",
                        icon: more_vertical_default,
                        label: (0, import_i18n182.__)(
                          "Font size options"
                        )
                      }
                    )
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(Menu9.Popover, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
                    Menu9.Item,
                    {
                      onClick: toggleRenameDialog,
                      children: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(Menu9.ItemLabel, { children: (0, import_i18n182.__)("Rename") })
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
                    Menu9.Item,
                    {
                      onClick: toggleDeleteConfirm,
                      children: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(Menu9.ItemLabel, { children: (0, import_i18n182.__)("Delete") })
                    }
                  )
                ] })
              ] })
            }
          ) })
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_components153.__experimentalView, { children: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
          import_components153.__experimentalSpacer,
          {
            paddingX: 4,
            marginBottom: 0,
            paddingBottom: 6,
            children: /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(import_components153.__experimentalVStack, { spacing: 4, children: [
              /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_components153.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(font_size_preview_default, { fontSize }) }),
              /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
                SizeControl,
                {
                  label: (0, import_i18n182.__)("Size"),
                  value: !isCustomFluid && fontSize.size ? String(fontSize.size) : "",
                  onChange: handleFontSizeChange,
                  disabled: isCustomFluid
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
                import_components153.ToggleControl,
                {
                  label: (0, import_i18n182.__)("Fluid typography"),
                  help: (0, import_i18n182.__)(
                    "Scale the font size dynamically to fit the screen or viewport."
                  ),
                  checked: isFluid,
                  onChange: handleFluidChange
                }
              ),
              isFluid && /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
                import_components153.ToggleControl,
                {
                  label: (0, import_i18n182.__)("Custom fluid values"),
                  help: (0, import_i18n182.__)(
                    "Set custom min and max values for the fluid font size."
                  ),
                  checked: isCustomFluid,
                  onChange: handleCustomFluidValues
                }
              ),
              isCustomFluid && /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(import_jsx_runtime321.Fragment, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
                  SizeControl,
                  {
                    label: (0, import_i18n182.__)("Minimum"),
                    value: typeof fontSize?.fluid === "object" ? fontSize.fluid?.min : void 0,
                    onChange: handleMinChange
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
                  SizeControl,
                  {
                    label: (0, import_i18n182.__)("Maximum"),
                    value: typeof fontSize?.fluid === "object" ? fontSize.fluid?.max : void 0,
                    onChange: handleMaxChange
                  }
                )
              ] })
            ] })
          }
        ) })
      ] })
    ] });
  }
  var font_size_default = FontSize;

  // packages/global-styles-ui/build-module/global-styles-ui.mjs
  var import_jsx_runtime322 = __toESM(require_jsx_runtime(), 1);
  function BlockStylesNavigationScreens({
    parentMenu,
    blockStyles,
    blockName
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(import_jsx_runtime322.Fragment, { children: blockStyles.map((style, index) => /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
      import_components154.Navigator.Screen,
      {
        path: parentMenu + "/variations/" + style.name,
        children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_block_default, { name: blockName, variation: style.name })
      },
      index
    )) });
  }
  function ContextScreens({ name: name2, parentMenu = "" }) {
    const blockStyleVariations = (0, import_data75.useSelect)(
      (select7) => {
        if (!name2) {
          return [];
        }
        const { getBlockStyles } = select7(import_blocks19.store);
        return getBlockStyles(name2);
      },
      [name2]
    );
    if (!blockStyleVariations?.length) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
      BlockStylesNavigationScreens,
      {
        parentMenu,
        blockStyles: blockStyleVariations,
        blockName: name2 || ""
      }
    );
  }
  function GlobalStylesUI({
    value,
    baseValue,
    onChange,
    path,
    onPathChange,
    fontLibraryEnabled = false,
    serverCSS,
    serverSettings
  }) {
    const blocks = (0, import_blocks19.getBlockTypes)();
    const mergedValue = (0, import_element175.useMemo)(() => {
      return mergeGlobalStyles(baseValue, value);
    }, [baseValue, value]);
    const [globalStylesCSS, globalSettings] = generateGlobalStyles(
      mergedValue,
      [],
      {
        styleOptions: { variationStyles: true }
      }
    );
    const styles = (0, import_element175.useMemo)(
      () => [...serverCSS ?? [], ...globalStylesCSS ?? []],
      [serverCSS, globalStylesCSS]
    );
    const settings = (0, import_element175.useMemo)(() => {
      return {
        ...serverSettings,
        __experimentalFeatures: globalSettings,
        styles
      };
    }, [globalSettings, serverSettings, styles]);
    return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
      GlobalStylesProvider,
      {
        value,
        baseValue,
        onChange,
        fontLibraryEnabled,
        children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(import_block_editor32.BlockEditorProvider, { settings, children: /* @__PURE__ */ (0, import_jsx_runtime322.jsxs)(
          import_components154.Navigator,
          {
            className: "global-styles-ui-sidebar__navigator-provider",
            initialPath: path || "/",
            children: [
              (path || onPathChange) && /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
                PathSynchronizer,
                {
                  path,
                  onPathChange
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_root_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/colors", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_colors_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/typography", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_typography_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/typography/font-sizes", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(font_sizes_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/typography/font-sizes/:origin/:slug", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(font_size_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/layout", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_layout_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/colors/palette", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_color_palette_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/variations", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_style_variations_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/css", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_css_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/revisions/:revisionId?", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_revisions_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/shadows", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(ScreenShadows, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/shadows/edit/:category/:slug", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(ScreenShadowsEdit, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/background", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_background_default, {}) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/typography/text", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_typography_element_default, { element: "text" }) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/typography/link", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_typography_element_default, { element: "link" }) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/typography/heading", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_typography_element_default, { element: "heading" }) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/typography/caption", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_typography_element_default, { element: "caption" }) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/typography/button", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_typography_element_default, { element: "button" }) }),
              /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(GlobalStylesNavigationScreen, { path: "/blocks", children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_block_list_default, {}) }),
              blocks.map((block) => /* @__PURE__ */ (0, import_jsx_runtime322.jsxs)(import_element175.Fragment, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
                  GlobalStylesNavigationScreen,
                  {
                    path: "/blocks/" + encodeURIComponent(block.name),
                    children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(screen_block_default, { name: block.name })
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
                  ContextScreens,
                  {
                    name: block.name,
                    parentMenu: "/blocks/" + encodeURIComponent(block.name)
                  }
                )
              ] }, block.name))
            ]
          }
        ) })
      }
    );
  }
  function GlobalStylesNavigationScreen({
    path,
    children
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
      import_components154.Navigator.Screen,
      {
        className: "global-styles-ui-sidebar__navigator-screen",
        path,
        children
      }
    );
  }
  function PathSynchronizer({
    path,
    onPathChange
  }) {
    const navigator2 = (0, import_components154.useNavigator)();
    const { path: childPath } = navigator2.location;
    const previousParentPath = (0, import_compose29.usePrevious)(path);
    const previousChildPath = (0, import_compose29.usePrevious)(childPath);
    (0, import_element175.useEffect)(() => {
      if (path && path !== childPath) {
        if (path !== previousParentPath) {
          navigator2.goTo(path);
        } else if (childPath !== previousChildPath && onPathChange) {
          onPathChange(childPath ?? "/");
        }
      }
    }, [
      onPathChange,
      path,
      previousChildPath,
      previousParentPath,
      childPath,
      navigator2
    ]);
    return null;
  }

  // packages/global-styles-ui/build-module/with-global-styles-provider.mjs
  var import_jsx_runtime323 = __toESM(require_jsx_runtime(), 1);
  function withGlobalStylesProvider(Component6) {
    return function WrappedComponent({
      value,
      baseValue,
      onChange,
      ...props
    }) {
      return /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(
        GlobalStylesProvider,
        {
          value,
          baseValue,
          onChange,
          children: /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(Component6, { ...props })
        }
      );
    };
  }

  // packages/global-styles-ui/build-module/style-variations.mjs
  var StyleVariations = withGlobalStylesProvider(style_variations_container_default);

  // packages/global-styles-ui/build-module/color-variations.mjs
  var ColorVariations2 = withGlobalStylesProvider(ColorVariations);

  // packages/global-styles-ui/build-module/typography-variations.mjs
  var TypographyVariations2 = withGlobalStylesProvider(TypographyVariations);

  // packages/global-styles-ui/build-module/font-library/font-library.mjs
  var import_jsx_runtime324 = __toESM(require_jsx_runtime(), 1);

  // packages/editor/build-module/components/global-styles/index.mjs
  var import_media_utils4 = __toESM(require_media_utils(), 1);

  // packages/editor/build-module/components/global-styles/block-link.mjs
  var import_data76 = __toESM(require_data(), 1);
  var import_element176 = __toESM(require_element(), 1);
  var import_block_editor33 = __toESM(require_block_editor(), 1);
  var import_compose30 = __toESM(require_compose(), 1);
  function GlobalStylesBlockLink({ path, onPathChange }) {
    const { selectedBlockName, selectedBlockClientId } = (0, import_data76.useSelect)(
      (select7) => {
        const { getSelectedBlockClientId: getSelectedBlockClientId2, getBlockName: getBlockName2 } = select7(import_block_editor33.store);
        const clientId = getSelectedBlockClientId2();
        return {
          selectedBlockName: getBlockName2(clientId),
          selectedBlockClientId: clientId
        };
      },
      []
    );
    const blockHasGlobalStyles = true;
    const previousBlockClientId = (0, import_compose30.usePrevious)(selectedBlockClientId);
    (0, import_element176.useEffect)(() => {
      if (selectedBlockClientId === previousBlockClientId) {
        return;
      }
      if (!selectedBlockClientId || !blockHasGlobalStyles) {
        return;
      }
      if (!path || path !== "/blocks" && !path.startsWith("/blocks/")) {
        return;
      }
      const newPath = "/blocks/" + encodeURIComponent(selectedBlockName);
      if (newPath !== path) {
        onPathChange?.(newPath);
      }
    }, [
      selectedBlockClientId,
      previousBlockClientId,
      selectedBlockName,
      blockHasGlobalStyles,
      path,
      onPathChange
    ]);
    return null;
  }

  // packages/editor/build-module/components/global-styles/hooks.mjs
  var import_element177 = __toESM(require_element(), 1);
  var import_core_data50 = __toESM(require_core_data(), 1);
  var import_data77 = __toESM(require_data(), 1);
  var import_block_editor34 = __toESM(require_block_editor(), 1);
  var { cleanEmptyObject: cleanEmptyObject2 } = unlock(import_block_editor34.privateApis);
  function useGlobalStylesUserConfig2() {
    const { globalStylesId, isReady: isReady2, settings, styles, _links } = (0, import_data77.useSelect)(
      (select7) => {
        const {
          getEntityRecord,
          getEditedEntityRecord: getEditedEntityRecord2,
          hasFinishedResolution,
          canUser
        } = select7(import_core_data50.store);
        const _globalStylesId = select7(import_core_data50.store).__experimentalGetCurrentGlobalStylesId();
        let record;
        const userCanEditGlobalStyles = _globalStylesId ? canUser("update", {
          kind: "root",
          name: "globalStyles",
          id: _globalStylesId
        }) : null;
        if (_globalStylesId && typeof userCanEditGlobalStyles === "boolean") {
          if (userCanEditGlobalStyles) {
            record = getEditedEntityRecord2(
              "root",
              "globalStyles",
              _globalStylesId
            );
          } else {
            record = getEntityRecord(
              "root",
              "globalStyles",
              _globalStylesId,
              { context: "view" }
            );
          }
        }
        let hasResolved = false;
        if (hasFinishedResolution(
          "__experimentalGetCurrentGlobalStylesId"
        )) {
          if (_globalStylesId) {
            hasResolved = userCanEditGlobalStyles ? hasFinishedResolution("getEditedEntityRecord", [
              "root",
              "globalStyles",
              _globalStylesId
            ]) : hasFinishedResolution("getEntityRecord", [
              "root",
              "globalStyles",
              _globalStylesId,
              { context: "view" }
            ]);
          } else {
            hasResolved = true;
          }
        }
        return {
          globalStylesId: _globalStylesId,
          isReady: hasResolved,
          settings: record?.settings,
          styles: record?.styles,
          _links: record?._links
        };
      },
      []
    );
    const { getEditedEntityRecord } = (0, import_data77.useSelect)(import_core_data50.store);
    const { editEntityRecord } = (0, import_data77.useDispatch)(import_core_data50.store);
    const config2 = (0, import_element177.useMemo)(() => {
      return {
        settings: settings ?? {},
        styles: styles ?? {},
        _links: _links ?? {}
      };
    }, [settings, styles, _links]);
    const setConfig = (0, import_element177.useCallback)(
      (callbackOrObject, options = {}) => {
        const record = getEditedEntityRecord(
          "root",
          "globalStyles",
          globalStylesId
        );
        const currentConfig = {
          styles: record?.styles ?? {},
          settings: record?.settings ?? {},
          _links: record?._links ?? {}
        };
        const updatedConfig = typeof callbackOrObject === "function" ? callbackOrObject(currentConfig) : callbackOrObject;
        editEntityRecord(
          "root",
          "globalStyles",
          globalStylesId,
          {
            styles: cleanEmptyObject2(updatedConfig.styles) || {},
            settings: cleanEmptyObject2(updatedConfig.settings) || {},
            _links: cleanEmptyObject2(updatedConfig._links) || {}
          },
          options
        );
      },
      [globalStylesId, editEntityRecord, getEditedEntityRecord]
    );
    return [isReady2, config2, setConfig];
  }
  function useGlobalStylesBaseConfig2() {
    const baseConfig = (0, import_data77.useSelect)(
      (select7) => select7(import_core_data50.store).__experimentalGetCurrentThemeBaseGlobalStyles(),
      []
    );
    return [!!baseConfig, baseConfig];
  }
  function useGlobalStyles() {
    const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig2();
    const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig2();
    const merged = (0, import_element177.useMemo)(() => {
      if (!isUserConfigReady || !isBaseConfigReady) {
        return {};
      }
      return mergeGlobalStyles(baseConfig || {}, userConfig);
    }, [isUserConfigReady, isBaseConfigReady, baseConfig, userConfig]);
    return {
      merged,
      base: baseConfig || {},
      user: userConfig,
      setUser: setUserConfig,
      isReady: isUserConfigReady && isBaseConfigReady
    };
  }
  function useStyle2(path, blockName) {
    const { merged } = useGlobalStyles();
    return (0, import_element177.useMemo)(
      () => getStyle(merged, path, blockName),
      [merged, path, blockName]
    );
  }
  function useSetting2(path, blockName) {
    const { merged } = useGlobalStyles();
    return (0, import_element177.useMemo)(
      () => getSetting(merged, path, blockName),
      [merged, path, blockName]
    );
  }

  // packages/editor/build-module/components/global-styles/index.mjs
  var import_jsx_runtime325 = __toESM(require_jsx_runtime(), 1);
  function useServerData(settings) {
    const styles = settings?.styles;
    const __unstableResolvedAssets = settings?.__unstableResolvedAssets;
    const colors2 = settings?.colors;
    const gradients = settings?.gradients;
    const __experimentalDiscussionSettings = settings?.__experimentalDiscussionSettings;
    const fontLibraryEnabled = settings?.fontLibraryEnabled ?? true;
    const mediaUploadHandler = (0, import_data78.useSelect)((select7) => {
      const { canUser } = select7(import_core_data51.store);
      const canUserUploadMedia = canUser("create", {
        kind: "postType",
        name: "attachment"
      });
      return canUserUploadMedia ? import_media_utils4.uploadMedia : void 0;
    }, []);
    const serverCSS = (0, import_element178.useMemo)(() => {
      if (!styles) {
        return [];
      }
      return styles.filter((style) => !style.isGlobalStyles);
    }, [styles]);
    const serverSettings = (0, import_element178.useMemo)(() => {
      return {
        __unstableResolvedAssets,
        settings: {
          color: {
            palette: {
              theme: colors2 ?? []
            },
            gradients: {
              theme: gradients ?? []
            },
            duotone: {
              theme: []
            }
          }
        },
        __experimentalDiscussionSettings,
        mediaUpload: mediaUploadHandler
      };
    }, [
      __unstableResolvedAssets,
      colors2,
      gradients,
      __experimentalDiscussionSettings,
      mediaUploadHandler
    ]);
    return { serverCSS, serverSettings, fontLibraryEnabled };
  }
  function GlobalStylesUIWrapper({
    path,
    onPathChange,
    settings
  }) {
    const {
      user: userConfig,
      base: baseConfig,
      setUser: setUserConfig,
      isReady: isReady2
    } = useGlobalStyles();
    const { serverCSS, serverSettings, fontLibraryEnabled } = useServerData(settings);
    if (!isReady2) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime325.jsxs)(import_jsx_runtime325.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(
        GlobalStylesUI,
        {
          value: userConfig,
          baseValue: baseConfig || {},
          onChange: setUserConfig,
          path,
          onPathChange,
          fontLibraryEnabled,
          serverCSS,
          serverSettings
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(
        GlobalStylesBlockLink,
        {
          path,
          onPathChange
        }
      )
    ] });
  }

  // packages/editor/build-module/dataviews/fields/content-preview/content-preview-view.mjs
  var import_jsx_runtime326 = __toESM(require_jsx_runtime(), 1);
  function PostPreviewContainer({
    template: template2,
    post: post2
  }) {
    const [backgroundColor = "white"] = useStyle2("color.background");
    const [postBlocks] = (0, import_core_data52.useEntityBlockEditor)("postType", post2.type, {
      id: post2.id
    });
    const [templateBlocks] = (0, import_core_data52.useEntityBlockEditor)(
      "postType",
      template2?.type,
      {
        id: template2?.id
      }
    );
    const blocks = template2 && templateBlocks ? templateBlocks : postBlocks;
    const isEmpty3 = !blocks?.length;
    return /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)(
      "div",
      {
        className: "editor-fields-content-preview",
        style: {
          backgroundColor
        },
        children: [
          isEmpty3 && /* @__PURE__ */ (0, import_jsx_runtime326.jsx)("span", { className: "editor-fields-content-preview__empty", children: (0, import_i18n183.__)("Empty content") }),
          !isEmpty3 && /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(import_block_editor35.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(import_block_editor35.BlockPreview, { blocks }) })
        ]
      }
    );
  }
  function PostPreviewView({ item }) {
    const { settings, template: template2 } = (0, import_data79.useSelect)(
      (select7) => {
        const { canUser, getPostType, getTemplateId, getEntityRecord } = unlock(select7(import_core_data52.store));
        const canViewTemplate = canUser("read", {
          kind: "postType",
          name: "wp_template"
        });
        const _settings = select7(store3).getEditorSettings();
        const supportsTemplateMode = _settings.supportsTemplateMode;
        const isViewable = getPostType(item.type)?.viewable ?? false;
        const templateId2 = supportsTemplateMode && isViewable && canViewTemplate ? getTemplateId(item.type, item.id) : null;
        return {
          settings: _settings,
          template: templateId2 ? getEntityRecord("postType", "wp_template", templateId2) : void 0
        };
      },
      [item.type, item.id]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(
      EditorProvider,
      {
        post: item,
        settings,
        __unstableTemplate: template2,
        children: /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostPreviewContainer, { template: template2, post: item })
      }
    );
  }

  // packages/editor/build-module/dataviews/fields/content-preview/index.mjs
  var postPreviewField = {
    type: "media",
    id: "content-preview",
    label: (0, import_i18n184.__)("Content preview"),
    render: PostPreviewView,
    enableSorting: false
  };
  var content_preview_default = postPreviewField;

  // packages/editor/build-module/dataviews/store/private-actions.mjs
  function hasEditorNotesSupport(supports) {
    const editor = supports?.editor;
    if (Array.isArray(editor)) {
      return !!editor[0]?.notes;
    }
    return false;
  }
  function registerEntityAction(kind, name2, config2) {
    return {
      type: "REGISTER_ENTITY_ACTION",
      kind,
      name: name2,
      config: config2
    };
  }
  function unregisterEntityAction(kind, name2, actionId) {
    return {
      type: "UNREGISTER_ENTITY_ACTION",
      kind,
      name: name2,
      actionId
    };
  }
  function registerEntityField(kind, name2, config2) {
    return {
      type: "REGISTER_ENTITY_FIELD",
      kind,
      name: name2,
      config: config2
    };
  }
  function unregisterEntityField(kind, name2, fieldId) {
    return {
      type: "UNREGISTER_ENTITY_FIELD",
      kind,
      name: name2,
      fieldId
    };
  }
  function setIsReady(kind, name2) {
    return {
      type: "SET_IS_READY",
      kind,
      name: name2
    };
  }
  var ORDERED_MEDIA_FIELDS = [
    // Metadata in panels (collapsed by default).
    date_added_default,
    author_default2,
    filename_default,
    mime_type_default,
    filesize_default,
    media_dimensions_default,
    attached_to_default,
    // Regular layout fields (always visible).
    title_default,
    alt_text_default,
    caption_default,
    description_default
  ];
  var registerPostTypeSchema = (postType2) => async ({ registry }) => {
    const isReady2 = unlock(registry.select(store3)).isEntityReady(
      "postType",
      postType2
    );
    if (isReady2) {
      return;
    }
    unlock(registry.dispatch(store3)).setIsReady(
      "postType",
      postType2
    );
    const postTypeConfig = await registry.resolveSelect(import_core_data53.store).getPostType(postType2);
    const canCreate = await registry.resolveSelect(import_core_data53.store).canUser("create", {
      kind: "postType",
      name: postType2
    });
    const currentTheme = await registry.resolveSelect(import_core_data53.store).getCurrentTheme();
    const { disablePostFormats } = registry.select(store3).getEditorSettings();
    let canDuplicate = !["wp_block", "wp_template_part"].includes(
      postTypeConfig.slug
    ) && canCreate && duplicate_post_default;
    if (false) {
      if ("wp_template" !== postTypeConfig.slug) {
        canDuplicate = void 0;
      }
    }
    if (postTypeConfig.slug === "wp_template" && !window?.__experimentalTemplateActivate) {
      canDuplicate = void 0;
    }
    const actions2 = [
      postTypeConfig.viewable ? view_post_default : void 0,
      !!postTypeConfig.supports?.revisions ? view_post_revisions_default : void 0,
      // @ts-ignore
      canDuplicate,
      postTypeConfig.slug === "wp_template_part" && canCreate && currentTheme?.is_block_theme ? duplicate_template_part_default : void 0,
      canCreate && postTypeConfig.slug === "wp_block" ? duplicate_pattern_default : void 0,
      postTypeConfig.supports?.title ? rename_post_default : void 0,
      postTypeConfig.supports?.["page-attributes"] ? reorder_page_default : void 0,
      postTypeConfig.slug === "wp_block" ? export_pattern_default : void 0,
      restore_post_default,
      reset_post_default,
      delete_post_default,
      trash_post_default,
      permanently_delete_post_default
    ].filter(Boolean);
    let fields3;
    if (postType2 === ATTACHMENT_POST_TYPE) {
      fields3 = ORDERED_MEDIA_FIELDS;
    } else {
      fields3 = [
        postTypeConfig.supports?.thumbnail && currentTheme?.theme_supports?.["post-thumbnails"] && featured_image_default,
        postTypeConfig.supports?.author && author_default,
        status_default,
        !DESIGN_POST_TYPES.includes(postTypeConfig.slug) && date_default,
        !DESIGN_POST_TYPES.includes(postTypeConfig.slug) && scheduled_default2,
        slug_default,
        !DESIGN_POST_TYPES.includes(postTypeConfig.slug) && postTypeConfig.supports?.excerpt && excerpt_default,
        postTypeConfig.supports?.["page-attributes"] && parent_default,
        postTypeConfig.supports?.comments && comment_status_default,
        postTypeConfig.supports?.trackbacks && ping_status_default,
        (postTypeConfig.supports?.comments || postTypeConfig.supports?.trackbacks) && discussion_default,
        template_default,
        postTypeConfig.supports?.["post-formats"] && !disablePostFormats && format_default,
        !DESIGN_POST_TYPES.includes(postTypeConfig.slug) && postTypeConfig.supports?.editor && post_content_info_default,
        password_default,
        postTypeConfig.slug === "post" && sticky_default,
        postTypeConfig.supports?.editor && postTypeConfig.viewable && content_preview_default,
        hasEditorNotesSupport(postTypeConfig.supports) && notes_default
      ].filter(Boolean);
      if (postTypeConfig.supports?.title) {
        let _titleField;
        if (postType2 === "page") {
          _titleField = page_title_default;
        } else if (postType2 === "wp_template") {
          _titleField = template_title_default;
        } else if (postType2 === "wp_block") {
          _titleField = pattern_title_default;
        } else {
          _titleField = title_default;
        }
        fields3.push(_titleField);
      }
    }
    registry.batch(() => {
      actions2.forEach((action) => {
        unlock(registry.dispatch(store3)).registerEntityAction(
          "postType",
          postType2,
          action
        );
      });
      fields3.forEach((field) => {
        unlock(registry.dispatch(store3)).registerEntityField(
          "postType",
          postType2,
          field
        );
      });
    });
    (0, import_hooks38.doAction)("core.registerPostTypeSchema", postType2);
  };

  // packages/editor/build-module/store/private-actions.mjs
  function setCurrentTemplateId(id) {
    return {
      type: "SET_CURRENT_TEMPLATE_ID",
      id
    };
  }
  var createTemplate = (template2) => async ({ select: select7, dispatch: dispatch7, registry }) => {
    const savedTemplate = await registry.dispatch(import_core_data54.store).saveEntityRecord("postType", "wp_template", template2);
    registry.dispatch(import_core_data54.store).editEntityRecord(
      "postType",
      select7.getCurrentPostType(),
      select7.getCurrentPostId(),
      {
        template: savedTemplate.slug
      }
    );
    registry.dispatch(import_notices18.store).createSuccessNotice(
      (0, import_i18n185.__)("Custom template created. You're in template mode now."),
      {
        type: "snackbar",
        actions: [
          {
            label: (0, import_i18n185.__)("Go back"),
            onClick: () => dispatch7.setRenderingMode(
              select7.getEditorSettings().defaultRenderingMode
            )
          }
        ]
      }
    );
    return savedTemplate;
  };
  var showBlockTypes = (blockNames) => ({ registry }) => {
    const existingBlockNames = registry.select(import_preferences9.store).get("core", "hiddenBlockTypes") ?? [];
    const newBlockNames = existingBlockNames.filter(
      (type) => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type)
    );
    registry.dispatch(import_preferences9.store).set("core", "hiddenBlockTypes", newBlockNames);
  };
  var hideBlockTypes = (blockNames) => ({ registry }) => {
    const existingBlockNames = registry.select(import_preferences9.store).get("core", "hiddenBlockTypes") ?? [];
    const mergedBlockNames = /* @__PURE__ */ new Set([
      ...existingBlockNames,
      ...Array.isArray(blockNames) ? blockNames : [blockNames]
    ]);
    registry.dispatch(import_preferences9.store).set("core", "hiddenBlockTypes", [...mergedBlockNames]);
  };
  var saveDirtyEntities = ({
    onSave,
    dirtyEntityRecords = [],
    entitiesToSkip = [],
    close,
    successNoticeContent
  } = {}) => ({ registry }) => {
    const PUBLISH_ON_SAVE_ENTITIES = [
      { kind: "postType", name: "wp_navigation" }
    ];
    const saveNoticeId = "site-editor-save-success";
    const homeUrl = registry.select(import_core_data54.store).getEntityRecord("root", "__unstableBase")?.home;
    registry.dispatch(import_notices18.store).removeNotice(saveNoticeId);
    const entitiesToSave = dirtyEntityRecords.filter(
      ({ kind, name: name2, key, property }) => {
        return !entitiesToSkip.some(
          (elt) => elt.kind === kind && elt.name === name2 && elt.key === key && elt.property === property
        );
      }
    );
    close?.(entitiesToSave);
    const siteItemsToSave = [];
    const pendingSavedRecords = [];
    entitiesToSave.forEach(({ kind, name: name2, key, property }) => {
      if ("root" === kind && "site" === name2) {
        siteItemsToSave.push(property);
      } else {
        if (PUBLISH_ON_SAVE_ENTITIES.some(
          (typeToPublish) => typeToPublish.kind === kind && typeToPublish.name === name2
        )) {
          registry.dispatch(import_core_data54.store).editEntityRecord(kind, name2, key, {
            status: "publish"
          });
        }
        pendingSavedRecords.push(
          registry.dispatch(import_core_data54.store).saveEditedEntityRecord(kind, name2, key)
        );
      }
    });
    if (siteItemsToSave.length) {
      pendingSavedRecords.push(
        registry.dispatch(import_core_data54.store).__experimentalSaveSpecifiedEntityEdits(
          "root",
          "site",
          void 0,
          siteItemsToSave
        )
      );
    }
    registry.dispatch(import_block_editor36.store).__unstableMarkLastChangeAsPersistent();
    Promise.all(pendingSavedRecords).then((values) => {
      return onSave ? onSave(values) : values;
    }).then((values) => {
      if (values.some((value) => typeof value === "undefined")) {
        registry.dispatch(import_notices18.store).createErrorNotice((0, import_i18n185.__)("Saving failed."));
      } else {
        registry.dispatch(import_notices18.store).createSuccessNotice(
          successNoticeContent || (0, import_i18n185.__)("Site updated."),
          {
            type: "snackbar",
            id: saveNoticeId,
            actions: [
              {
                label: (0, import_i18n185.__)("View site"),
                url: homeUrl,
                openInNewTab: true
              }
            ]
          }
        );
      }
    }).catch(
      (error2) => registry.dispatch(import_notices18.store).createErrorNotice(
        `${(0, import_i18n185.__)("Saving failed.")} ${error2}`
      )
    );
  };
  var revertTemplate2 = (template2, { allowUndo = true } = {}) => async ({ registry }) => {
    const noticeId = "edit-site-template-reverted";
    registry.dispatch(import_notices18.store).removeNotice(noticeId);
    if (!isTemplateRevertable(template2)) {
      registry.dispatch(import_notices18.store).createErrorNotice((0, import_i18n185.__)("This template is not revertable."), {
        type: "snackbar"
      });
      return;
    }
    try {
      const templateEntityConfig = registry.select(import_core_data54.store).getEntityConfig("postType", template2.type);
      if (!templateEntityConfig) {
        registry.dispatch(import_notices18.store).createErrorNotice(
          (0, import_i18n185.__)(
            "The editor has encountered an unexpected error. Please reload."
          ),
          { type: "snackbar" }
        );
        return;
      }
      const fileTemplatePath = (0, import_url13.addQueryArgs)(
        `${templateEntityConfig.baseURL}/${template2.id}`,
        { context: "edit", source: template2.origin }
      );
      const fileTemplate = await (0, import_api_fetch6.default)({ path: fileTemplatePath });
      if (!fileTemplate) {
        registry.dispatch(import_notices18.store).createErrorNotice(
          (0, import_i18n185.__)(
            "The editor has encountered an unexpected error. Please reload."
          ),
          { type: "snackbar" }
        );
        return;
      }
      const serializeBlocks = ({
        blocks: blocksForSerialization = []
      }) => (0, import_blocks20.__unstableSerializeAndClean)(blocksForSerialization);
      const edited = registry.select(import_core_data54.store).getEditedEntityRecord(
        "postType",
        template2.type,
        template2.id
      );
      registry.dispatch(import_core_data54.store).editEntityRecord(
        "postType",
        template2.type,
        template2.id,
        {
          content: serializeBlocks,
          // Required to make the `undo` behave correctly.
          blocks: edited.blocks,
          // Required to revert the blocks in the editor.
          source: "custom"
          // required to avoid turning the editor into a dirty state
        },
        {
          undoIgnore: true
          // Required to merge this edit with the last undo level.
        }
      );
      const blocks = (0, import_blocks20.parse)(fileTemplate?.content?.raw);
      registry.dispatch(import_core_data54.store).editEntityRecord("postType", template2.type, fileTemplate.id, {
        content: serializeBlocks,
        blocks,
        source: "theme"
      });
      if (allowUndo) {
        const undoRevert = () => {
          registry.dispatch(import_core_data54.store).editEntityRecord(
            "postType",
            template2.type,
            edited.id,
            {
              content: serializeBlocks,
              blocks: edited.blocks,
              source: "custom"
            }
          );
        };
        registry.dispatch(import_notices18.store).createSuccessNotice((0, import_i18n185.__)("Template reset."), {
          type: "snackbar",
          id: noticeId,
          actions: [
            {
              label: (0, import_i18n185.__)("Undo"),
              onClick: undoRevert
            }
          ]
        });
      }
    } catch (error2) {
      const errorMessage = error2.message && error2.code !== "unknown_error" ? error2.message : (0, import_i18n185.__)("Template revert failed. Please reload.");
      registry.dispatch(import_notices18.store).createErrorNotice(errorMessage, { type: "snackbar" });
    }
  };
  var removeTemplates = (items) => async ({ registry }) => {
    const isResetting = items.every((item) => item?.has_theme_file);
    const promiseResult = await Promise.allSettled(
      items.map((item) => {
        return registry.dispatch(import_core_data54.store).deleteEntityRecord(
          "postType",
          item.type,
          item.id,
          { force: true },
          { throwOnError: true }
        );
      })
    );
    if (promiseResult.every(({ status }) => status === "fulfilled")) {
      let successMessage;
      if (items.length === 1) {
        let title;
        if (typeof items[0].title === "string") {
          title = items[0].title;
        } else if (typeof items[0].title?.rendered === "string") {
          title = items[0].title?.rendered;
        } else if (typeof items[0].title?.raw === "string") {
          title = items[0].title?.raw;
        }
        successMessage = isResetting ? (0, import_i18n185.sprintf)(
          /* translators: %s: The template/part's name. */
          (0, import_i18n185.__)('"%s" reset.'),
          (0, import_html_entities10.decodeEntities)(title)
        ) : (0, import_i18n185.sprintf)(
          /* translators: %s: The template/part's name. */
          (0, import_i18n185._x)('"%s" deleted.', "template part"),
          (0, import_html_entities10.decodeEntities)(title)
        );
      } else {
        successMessage = isResetting ? (0, import_i18n185.__)("Items reset.") : (0, import_i18n185.__)("Items deleted.");
      }
      registry.dispatch(import_notices18.store).createSuccessNotice(successMessage, {
        type: "snackbar",
        id: "editor-template-deleted-success"
      });
    } else {
      let errorMessage;
      if (promiseResult.length === 1) {
        if (promiseResult[0].reason?.message) {
          errorMessage = promiseResult[0].reason.message;
        } else {
          errorMessage = isResetting ? (0, import_i18n185.__)("An error occurred while reverting the item.") : (0, import_i18n185.__)("An error occurred while deleting the item.");
        }
      } else {
        const errorMessages = /* @__PURE__ */ new Set();
        const failedPromises = promiseResult.filter(
          ({ status }) => status === "rejected"
        );
        for (const failedPromise of failedPromises) {
          if (failedPromise.reason?.message) {
            errorMessages.add(failedPromise.reason.message);
          }
        }
        if (errorMessages.size === 0) {
          errorMessage = (0, import_i18n185.__)(
            "An error occurred while deleting the items."
          );
        } else if (errorMessages.size === 1) {
          errorMessage = isResetting ? (0, import_i18n185.sprintf)(
            /* translators: %s: an error message */
            (0, import_i18n185.__)(
              "An error occurred while reverting the items: %s"
            ),
            [...errorMessages][0]
          ) : (0, import_i18n185.sprintf)(
            /* translators: %s: an error message */
            (0, import_i18n185.__)(
              "An error occurred while deleting the items: %s"
            ),
            [...errorMessages][0]
          );
        } else {
          errorMessage = isResetting ? (0, import_i18n185.sprintf)(
            /* translators: %s: a list of comma separated error messages */
            (0, import_i18n185.__)(
              "Some errors occurred while reverting the items: %s"
            ),
            [...errorMessages].join(",")
          ) : (0, import_i18n185.sprintf)(
            /* translators: %s: a list of comma separated error messages */
            (0, import_i18n185.__)(
              "Some errors occurred while deleting the items: %s"
            ),
            [...errorMessages].join(",")
          );
        }
      }
      registry.dispatch(import_notices18.store).createErrorNotice(errorMessage, { type: "snackbar" });
    }
  };
  var setDefaultRenderingMode = (mode) => ({ select: select7, registry }) => {
    const postType2 = select7.getCurrentPostType();
    const theme = registry.select(import_core_data54.store).getCurrentTheme()?.stylesheet;
    const renderingModes = registry.select(import_preferences9.store).get("core", "renderingModes")?.[theme] ?? {};
    if (renderingModes[postType2] === mode) {
      return;
    }
    const newModes = {
      [theme]: {
        ...renderingModes,
        [postType2]: mode
      }
    };
    registry.dispatch(import_preferences9.store).set("core", "renderingModes", newModes);
  };
  function setStylesPath(path) {
    return {
      type: "SET_STYLES_PATH",
      path
    };
  }
  function setShowStylebook(show) {
    return {
      type: "SET_SHOW_STYLEBOOK",
      show
    };
  }
  function resetStylesNavigation() {
    return {
      type: "RESET_STYLES_NAVIGATION"
    };
  }
  function setCurrentRevisionId(revisionId2) {
    return {
      type: "SET_CURRENT_REVISION_ID",
      revisionId: revisionId2
    };
  }
  function setShowRevisionDiff(showDiff) {
    return {
      type: "SET_SHOW_REVISION_DIFF",
      showDiff
    };
  }
  var restoreRevision = (revisionId2) => async ({ select: select7, dispatch: dispatch7, registry }) => {
    const postType2 = select7.getCurrentPostType();
    const postId2 = select7.getCurrentPostId();
    const entityConfig = registry.select(import_core_data54.store).getEntityConfig("postType", postType2);
    const revisionKey = entityConfig?.revisionKey || "id";
    const revision = await registry.resolveSelect(import_core_data54.store).getRevision("postType", postType2, postId2, revisionId2, {
      context: "edit",
      _fields: [
        .../* @__PURE__ */ new Set([
          "id",
          "date",
          "modified",
          "author",
          "meta",
          "title.raw",
          "excerpt.raw",
          "content.raw",
          revisionKey
        ])
      ].join()
    });
    if (!revision) {
      return;
    }
    const edits = {
      blocks: void 0,
      content: revision.content.raw
    };
    if (revision.title?.raw !== void 0) {
      edits.title = revision.title.raw;
    }
    if (revision.excerpt?.raw !== void 0) {
      edits.excerpt = revision.excerpt.raw;
    }
    if (revision.meta !== void 0) {
      edits.meta = revision.meta;
    }
    dispatch7.editPost(edits);
    dispatch7.setCurrentRevisionId(null);
    await dispatch7.savePost();
    registry.dispatch(import_notices18.store).createSuccessNotice(
      (0, import_i18n185.sprintf)(
        /* translators: %s: Date and time of the revision. */
        (0, import_i18n185.__)("Restored to revision from %s."),
        (0, import_date16.dateI18n)((0, import_date16.getSettings)().formats.datetime, revision.date)
      ),
      {
        type: "snackbar",
        id: "editor-revision-restored"
      }
    );
  };
  function selectNote(noteId, options = { focus: false }) {
    return {
      type: "SELECT_NOTE",
      noteId,
      options
    };
  }

  // packages/editor/build-module/store/private-selectors.mjs
  var private_selectors_exports = {};
  __export(private_selectors_exports, {
    getCurrentRevision: () => getCurrentRevision,
    getCurrentRevisionId: () => getCurrentRevisionId,
    getDefaultRenderingMode: () => getDefaultRenderingMode,
    getEntityActions: () => getEntityActions2,
    getEntityFields: () => getEntityFields2,
    getInserter: () => getInserter,
    getInserterSidebarToggleRef: () => getInserterSidebarToggleRef,
    getListViewToggleRef: () => getListViewToggleRef,
    getPostBlocksByName: () => getPostBlocksByName,
    getPostIcon: () => getPostIcon,
    getPreviousRevision: () => getPreviousRevision,
    getSelectedNote: () => getSelectedNote,
    getShowStylebook: () => getShowStylebook,
    getStylesPath: () => getStylesPath,
    hasPostMetaChanges: () => hasPostMetaChanges,
    isEntityReady: () => isEntityReady2,
    isNoteFocused: () => isNoteFocused,
    isRevisionsMode: () => isRevisionsMode,
    isShowingRevisionDiff: () => isShowingRevisionDiff
  });
  var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
  var import_block_editor37 = __toESM(require_block_editor(), 1);
  var import_data80 = __toESM(require_data(), 1);
  var import_core_data55 = __toESM(require_core_data(), 1);
  var import_preferences10 = __toESM(require_preferences(), 1);

  // packages/editor/build-module/dataviews/store/private-selectors.mjs
  var EMPTY_ARRAY11 = [];
  function getEntityActions(state, kind, name2) {
    return state.actions[kind]?.[name2] ?? EMPTY_ARRAY11;
  }
  function getEntityFields(state, kind, name2) {
    return state.fields[kind]?.[name2] ?? EMPTY_ARRAY11;
  }
  function isEntityReady(state, kind, name2) {
    return state.isReady[kind]?.[name2];
  }

  // packages/editor/build-module/store/private-selectors.mjs
  var EMPTY_INSERTION_POINT = {
    rootClientId: void 0,
    insertionIndex: void 0,
    filterValue: void 0
  };
  var RENDERING_MODES = ["post-only", "template-locked"];
  var getInserter = (0, import_data80.createRegistrySelector)(
    (select7) => (0, import_data80.createSelector)(
      (state) => {
        if (typeof state.blockInserterPanel === "object") {
          return state.blockInserterPanel;
        }
        if (getRenderingMode(state) === "template-locked") {
          const {
            getBlocksByName,
            getSelectedBlockClientId: getSelectedBlockClientId2,
            getBlockParents,
            getBlockOrder: getBlockOrder2
          } = select7(import_block_editor37.store);
          const [postContentClientId] = getBlocksByName("core/post-content");
          if (postContentClientId) {
            const selectedBlockClientId = getSelectedBlockClientId2();
            if (selectedBlockClientId && selectedBlockClientId !== postContentClientId && getBlockParents(selectedBlockClientId).includes(
              postContentClientId
            )) {
              return EMPTY_INSERTION_POINT;
            }
            return {
              rootClientId: postContentClientId,
              insertionIndex: getBlockOrder2(postContentClientId).length,
              filterValue: void 0
            };
          }
        }
        return EMPTY_INSERTION_POINT;
      },
      (state) => {
        const {
          getBlocksByName,
          getSelectedBlockClientId: getSelectedBlockClientId2,
          getBlockParents,
          getBlockOrder: getBlockOrder2
        } = select7(import_block_editor37.store);
        const [postContentClientId] = getBlocksByName("core/post-content");
        const selectedBlockClientId = getSelectedBlockClientId2();
        return [
          state.blockInserterPanel,
          getRenderingMode(state),
          postContentClientId,
          selectedBlockClientId,
          selectedBlockClientId ? getBlockParents(selectedBlockClientId) : void 0,
          postContentClientId ? getBlockOrder2(postContentClientId).length : void 0
        ];
      }
    )
  );
  function getListViewToggleRef(state) {
    return state.listViewToggleRef;
  }
  function getInserterSidebarToggleRef(state) {
    return state.inserterSidebarToggleRef;
  }
  var CARD_ICONS = {
    wp_block: symbol_default,
    wp_navigation: navigation_default,
    page: page_default,
    post: verse_default
  };
  var getPostIcon = (0, import_data80.createRegistrySelector)(
    (select7) => (state, postType2, options) => {
      {
        if (postType2 === "wp_template_part" || postType2 === "wp_template") {
          const templateAreas = select7(import_core_data55.store).getCurrentTheme()?.default_template_part_areas || [];
          const areaData = templateAreas.find(
            (item) => options.area === item.area
          );
          if (areaData?.icon) {
            return getTemplatePartIcon(areaData.icon);
          }
          return layout_default;
        }
        if (CARD_ICONS[postType2]) {
          return CARD_ICONS[postType2];
        }
        const postTypeEntity = select7(import_core_data55.store).getPostType(postType2);
        if (typeof postTypeEntity?.icon === "string" && postTypeEntity.icon.startsWith("dashicons-")) {
          return postTypeEntity.icon.slice(10);
        }
        return page_default;
      }
    }
  );
  var hasPostMetaChanges = (0, import_data80.createRegistrySelector)(
    (select7) => (state, postType2, postId2) => {
      const { type: currentPostType, id: currentPostId } = getCurrentPost(state);
      const edits = select7(import_core_data55.store).getEntityRecordNonTransientEdits(
        "postType",
        postType2 || currentPostType,
        postId2 || currentPostId
      );
      if (!edits?.meta) {
        return false;
      }
      const originalPostMeta = select7(import_core_data55.store).getEntityRecord(
        "postType",
        postType2 || currentPostType,
        postId2 || currentPostId
      )?.meta;
      return !(0, import_fast_deep_equal.default)(
        { ...originalPostMeta, footnotes: void 0 },
        { ...edits.meta, footnotes: void 0 }
      );
    }
  );
  function getEntityActions2(state, ...args) {
    return getEntityActions(state.dataviews, ...args);
  }
  function isEntityReady2(state, ...args) {
    return isEntityReady(state.dataviews, ...args);
  }
  function getEntityFields2(state, ...args) {
    return getEntityFields(state.dataviews, ...args);
  }
  var getPostBlocksByName = (0, import_data80.createRegistrySelector)(
    (select7) => (0, import_data80.createSelector)(
      (state, blockNames) => {
        blockNames = Array.isArray(blockNames) ? blockNames : [blockNames];
        const { getBlocksByName, getBlockParents, getBlockName: getBlockName2 } = select7(import_block_editor37.store);
        return getBlocksByName(blockNames).filter(
          (clientId) => getBlockParents(clientId).every((parentClientId) => {
            const parentBlockName = getBlockName2(parentClientId);
            return (
              // Ignore descendents of the query block.
              parentBlockName !== "core/query" && // Enable only the top-most block.
              !blockNames.includes(parentBlockName)
            );
          })
        );
      },
      (state, blockNames) => {
        blockNames = Array.isArray(blockNames) ? blockNames : [blockNames];
        const { getBlocksByName, getBlockParents } = select7(import_block_editor37.store);
        const clientIds = getBlocksByName(blockNames);
        const parentsOfClientIds = clientIds.map(
          (id) => getBlockParents(id)
        );
        return [clientIds, ...parentsOfClientIds];
      }
    )
  );
  var getDefaultRenderingMode = (0, import_data80.createRegistrySelector)(
    (select7) => (state, postType2) => {
      const { getPostType, getCurrentTheme, hasFinishedResolution } = select7(import_core_data55.store);
      const currentTheme = getCurrentTheme();
      const postTypeEntity = getPostType(postType2);
      if (!hasFinishedResolution("getPostType", [postType2]) || !hasFinishedResolution("getCurrentTheme")) {
        return void 0;
      }
      const theme = currentTheme?.stylesheet;
      const defaultModePreference = select7(import_preferences10.store).get(
        "core",
        "renderingModes"
      )?.[theme]?.[postType2];
      const postTypeDefaultMode = Array.isArray(
        postTypeEntity?.supports?.editor
      ) ? postTypeEntity.supports.editor.find(
        (features) => "default-mode" in features
      )?.["default-mode"] : void 0;
      const defaultMode = defaultModePreference || postTypeDefaultMode;
      if (!RENDERING_MODES.includes(defaultMode)) {
        return "post-only";
      }
      return defaultMode;
    }
  );
  function getStylesPath(state) {
    return state.stylesPath ?? "/";
  }
  function getShowStylebook(state) {
    return state.showStylebook ?? false;
  }
  function isRevisionsMode(state) {
    return state.revisionId !== null;
  }
  function isShowingRevisionDiff(state) {
    return state.showRevisionDiff;
  }
  function getCurrentRevisionId(state) {
    return state.revisionId;
  }
  var getCurrentRevision = (0, import_data80.createRegistrySelector)(
    (select7) => (state) => {
      const revisionId2 = getCurrentRevisionId(state);
      if (!revisionId2) {
        return void 0;
      }
      const { type: postType2, id: postId2 } = getCurrentPost(state);
      const entityConfig = select7(import_core_data55.store).getEntityConfig(
        "postType",
        postType2
      );
      const revisionKey = entityConfig?.revisionKey || "id";
      const revisions = select7(import_core_data55.store).getRevisions(
        "postType",
        postType2,
        postId2,
        {
          per_page: -1,
          context: "edit",
          _fields: [
            .../* @__PURE__ */ new Set([
              "id",
              "date",
              "modified",
              "author",
              "meta",
              "title.raw",
              "excerpt.raw",
              "content.raw",
              revisionKey
            ])
          ].join()
        }
      );
      if (!revisions) {
        return null;
      }
      return revisions.find((r4) => r4[revisionKey] === revisionId2) ?? null;
    }
  );
  function getSelectedNote(state) {
    return state.selectedNote?.noteId;
  }
  function isNoteFocused(state) {
    return !!state.selectedNote?.options?.focus;
  }
  var getPreviousRevision = (0, import_data80.createRegistrySelector)(
    (select7) => (state) => {
      const currentRevisionId = getCurrentRevisionId(state);
      if (!currentRevisionId) {
        return void 0;
      }
      const { type: postType2, id: postId2 } = getCurrentPost(state);
      const entityConfig = select7(import_core_data55.store).getEntityConfig(
        "postType",
        postType2
      );
      const revisionKey = entityConfig?.revisionKey || "id";
      const revisions = select7(import_core_data55.store).getRevisions(
        "postType",
        postType2,
        postId2,
        {
          per_page: -1,
          context: "edit",
          orderby: "date",
          order: "asc",
          _fields: [
            .../* @__PURE__ */ new Set([
              "id",
              "date",
              "modified",
              "author",
              "meta",
              "title.raw",
              "excerpt.raw",
              "content.raw",
              revisionKey
            ])
          ].join()
        }
      );
      if (!revisions) {
        return null;
      }
      const currentIndex = revisions.findIndex(
        (r4) => r4[revisionKey] === currentRevisionId
      );
      if (currentIndex > 0) {
        return revisions[currentIndex - 1];
      }
      return null;
    }
  );

  // packages/editor/build-module/store/index.mjs
  var storeConfig = {
    reducer: reducer_default2,
    selectors: selectors_exports,
    actions: actions_exports
  };
  var store3 = (0, import_data81.createReduxStore)(STORE_NAME, {
    ...storeConfig
  });
  (0, import_data81.register)(store3);
  unlock(store3).registerPrivateActions(private_actions_exports);
  unlock(store3).registerPrivateSelectors(private_selectors_exports);

  // packages/editor/build-module/hooks/custom-sources-backwards-compatibility.mjs
  var import_jsx_runtime327 = __toESM(require_jsx_runtime(), 1);
  var createWithMetaAttributeSource = (metaAttributes) => (0, import_compose31.createHigherOrderComponent)(
    (BlockEdit2) => ({ attributes, setAttributes, ...props }) => {
      const postType2 = (0, import_data82.useSelect)(
        (select7) => select7(store3).getCurrentPostType(),
        []
      );
      const [meta2, setMeta] = (0, import_core_data56.useEntityProp)(
        "postType",
        postType2,
        "meta"
      );
      const mergedAttributes = (0, import_element179.useMemo)(
        () => ({
          ...attributes,
          ...Object.fromEntries(
            Object.entries(metaAttributes).map(
              ([attributeKey, metaKey]) => [
                attributeKey,
                meta2[metaKey]
              ]
            )
          )
        }),
        [attributes, meta2]
      );
      return /* @__PURE__ */ (0, import_jsx_runtime327.jsx)(
        BlockEdit2,
        {
          attributes: mergedAttributes,
          setAttributes: (nextAttributes) => {
            const nextMeta = Object.fromEntries(
              Object.entries(nextAttributes ?? {}).filter(
                // Filter to intersection of keys between the updated
                // attributes and those with an associated meta key.
                ([key]) => key in metaAttributes
              ).map(([attributeKey, value]) => [
                // Rename the keys to the expected meta key name.
                metaAttributes[attributeKey],
                value
              ])
            );
            if (Object.entries(nextMeta).length) {
              setMeta(nextMeta);
            }
            setAttributes(nextAttributes);
          },
          ...props
        }
      );
    },
    "withMetaAttributeSource"
  );
  function shimAttributeSource(settings) {
    const metaAttributes = Object.fromEntries(
      Object.entries(settings.attributes ?? {}).filter(([, { source }]) => source === "meta").map(([attributeKey, { meta: meta2 }]) => [attributeKey, meta2])
    );
    if (Object.entries(metaAttributes).length) {
      settings.edit = createWithMetaAttributeSource(metaAttributes)(
        settings.edit
      );
    }
    return settings;
  }
  (0, import_hooks39.addFilter)(
    "blocks.registerBlockType",
    "core/editor/custom-sources-backwards-compatibility/shim-attribute-source",
    shimAttributeSource
  );

  // packages/editor/build-module/hooks/default-autocompleters.mjs
  var import_hooks50 = __toESM(require_hooks(), 1);

  // packages/editor/build-module/components/autocompleters/link.mjs
  var import_api_fetch7 = __toESM(require_api_fetch(), 1);
  var import_url14 = __toESM(require_url(), 1);
  var import_html_entities11 = __toESM(require_html_entities(), 1);
  var import_jsx_runtime328 = __toESM(require_jsx_runtime(), 1);
  var SHOWN_SUGGESTIONS = 10;
  var link_default2 = {
    name: "links",
    className: "editor-autocompleters__link",
    triggerPrefix: "[[",
    isDebounced: true,
    async options(filterValue) {
      const options = await (0, import_api_fetch7.default)({
        path: (0, import_url14.addQueryArgs)("/wp/v2/search", {
          per_page: SHOWN_SUGGESTIONS,
          search: filterValue,
          type: "post"
        })
      });
      return options.filter((option) => option.title !== "");
    },
    getOptionKeywords(item) {
      const expansionWords = item.title.split(/\s+/);
      return [...expansionWords];
    },
    getOptionLabel(item) {
      return /* @__PURE__ */ (0, import_jsx_runtime328.jsxs)(import_jsx_runtime328.Fragment, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(icon_default, { icon: item.subtype === "page" ? page_default : post_default }),
        (0, import_html_entities11.decodeEntities)(item.title)
      ] });
    },
    getOptionCompletion(item) {
      return /* @__PURE__ */ (0, import_jsx_runtime328.jsx)("a", { href: item.url, children: item.title });
    }
  };

  // packages/editor/build-module/components/autocompleters/user.mjs
  var import_element180 = __toESM(require_element(), 1);
  var import_data83 = __toESM(require_data(), 1);
  var import_core_data57 = __toESM(require_core_data(), 1);
  var import_jsx_runtime329 = __toESM(require_jsx_runtime(), 1);
  function getUserLabel(user) {
    const avatar = user.avatar_urls && user.avatar_urls[24] ? /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(
      "img",
      {
        className: "editor-autocompleters__user-avatar",
        alt: "",
        src: user.avatar_urls[24]
      }
    ) : /* @__PURE__ */ (0, import_jsx_runtime329.jsx)("span", { className: "editor-autocompleters__no-avatar" });
    return /* @__PURE__ */ (0, import_jsx_runtime329.jsxs)(import_jsx_runtime329.Fragment, { children: [
      avatar,
      /* @__PURE__ */ (0, import_jsx_runtime329.jsx)("span", { className: "editor-autocompleters__user-name", children: user.name }),
      /* @__PURE__ */ (0, import_jsx_runtime329.jsx)("span", { className: "editor-autocompleters__user-slug", children: user.slug })
    ] });
  }
  var user_default = {
    name: "users",
    className: "editor-autocompleters__user",
    triggerPrefix: "@",
    useItems(filterValue) {
      const users = (0, import_data83.useSelect)(
        (select7) => {
          const { getUsers } = select7(import_core_data57.store);
          return getUsers({
            context: "view",
            search: encodeURIComponent(filterValue)
          });
        },
        [filterValue]
      );
      const options = (0, import_element180.useMemo)(
        () => users ? users.map((user) => ({
          key: `user-${user.slug}`,
          value: user,
          label: getUserLabel(user)
        })) : [],
        [users]
      );
      return [options];
    },
    getOptionCompletion(user) {
      return `@${user.slug}`;
    }
  };

  // packages/editor/build-module/components/autosave-monitor/index.mjs
  var import_element181 = __toESM(require_element(), 1);
  var import_compose32 = __toESM(require_compose(), 1);
  var import_data84 = __toESM(require_data(), 1);
  var import_core_data58 = __toESM(require_core_data(), 1);
  var AutosaveMonitor = class extends import_element181.Component {
    constructor(props) {
      super(props);
      this.needsAutosave = !!(props.isDirty && props.isAutosaveable);
    }
    componentDidMount() {
      if (!this.props.disableIntervalChecks) {
        this.setAutosaveTimer();
      }
    }
    componentDidUpdate(prevProps) {
      if (this.props.disableIntervalChecks) {
        if (this.props.editsReference !== prevProps.editsReference) {
          this.props.autosave();
        }
        return;
      }
      if (this.props.interval !== prevProps.interval) {
        clearTimeout(this.timerId);
        this.setAutosaveTimer();
      }
      if (!this.props.isDirty) {
        this.needsAutosave = false;
        return;
      }
      if (this.props.isAutosaving && !prevProps.isAutosaving) {
        this.needsAutosave = false;
        return;
      }
      if (this.props.editsReference !== prevProps.editsReference) {
        this.needsAutosave = true;
      }
    }
    componentWillUnmount() {
      clearTimeout(this.timerId);
    }
    setAutosaveTimer(timeout = this.props.interval * 1e3) {
      this.timerId = setTimeout(() => {
        this.autosaveTimerHandler();
      }, timeout);
    }
    autosaveTimerHandler() {
      if (!this.props.isAutosaveable) {
        this.setAutosaveTimer(1e3);
        return;
      }
      if (this.needsAutosave) {
        this.needsAutosave = false;
        this.props.autosave();
      }
      this.setAutosaveTimer();
    }
    render() {
      return null;
    }
  };
  var autosave_monitor_default = (0, import_compose32.compose)([
    (0, import_data84.withSelect)((select7, ownProps) => {
      const { getReferenceByDistinctEdits } = select7(import_core_data58.store);
      const {
        isEditedPostDirty: isEditedPostDirty2,
        isEditedPostAutosaveable: isEditedPostAutosaveable2,
        isAutosavingPost: isAutosavingPost2,
        getEditorSettings: getEditorSettings2
      } = select7(store3);
      const { interval = getEditorSettings2().autosaveInterval } = ownProps;
      return {
        editsReference: getReferenceByDistinctEdits(),
        isDirty: isEditedPostDirty2(),
        isAutosaveable: isEditedPostAutosaveable2(),
        isAutosaving: isAutosavingPost2(),
        interval
      };
    }),
    (0, import_data84.withDispatch)((dispatch7, ownProps) => ({
      autosave() {
        const { autosave: autosave2 = dispatch7(store3).autosave } = ownProps;
        autosave2();
      }
    }))
  ])(AutosaveMonitor);

  // packages/editor/build-module/components/document-bar/index.mjs
  var import_i18n192 = __toESM(require_i18n(), 1);
  var import_data92 = __toESM(require_data(), 1);
  var import_components162 = __toESM(require_components(), 1);
  var import_block_editor42 = __toESM(require_block_editor(), 1);
  var import_keycodes9 = __toESM(require_keycodes(), 1);
  var import_core_data62 = __toESM(require_core_data(), 1);
  var import_commands3 = __toESM(require_commands(), 1);
  var import_element188 = __toESM(require_element(), 1);
  var import_compose34 = __toESM(require_compose(), 1);
  var import_html_entities13 = __toESM(require_html_entities(), 1);
  var import_dom11 = __toESM(require_dom(), 1);

  // packages/editor/build-module/utils/pageTypeBadge.mjs
  var import_i18n186 = __toESM(require_i18n(), 1);
  var import_data85 = __toESM(require_data(), 1);
  var import_core_data59 = __toESM(require_core_data(), 1);
  function usePageTypeBadge(postId2) {
    const { isFrontPage, isPostsPage } = (0, import_data85.useSelect)((select7) => {
      const { canUser, getEditedEntityRecord } = select7(import_core_data59.store);
      const siteSettings = canUser("read", {
        kind: "root",
        name: "site"
      }) ? getEditedEntityRecord("root", "site") : void 0;
      const _postId = parseInt(postId2, 10);
      return {
        isFrontPage: siteSettings?.page_on_front === _postId,
        isPostsPage: siteSettings?.page_for_posts === _postId
      };
    });
    if (isFrontPage) {
      return (0, import_i18n186.__)("Homepage");
    } else if (isPostsPage) {
      return (0, import_i18n186.__)("Posts Page");
    }
    return false;
  }

  // packages/editor/build-module/components/styles-canvas/index.mjs
  var import_components161 = __toESM(require_components(), 1);
  var import_keycodes8 = __toESM(require_keycodes(), 1);
  var import_i18n191 = __toESM(require_i18n(), 1);
  var import_data90 = __toESM(require_data(), 1);
  var import_compose33 = __toESM(require_compose(), 1);
  var import_preferences11 = __toESM(require_preferences(), 1);

  // packages/editor/build-module/components/styles-canvas/style-book.mjs
  var import_element185 = __toESM(require_element(), 1);

  // packages/editor/build-module/components/style-book/index.mjs
  var import_components157 = __toESM(require_components(), 1);
  var import_i18n189 = __toESM(require_i18n(), 1);
  var import_block_editor39 = __toESM(require_block_editor(), 1);
  var import_data88 = __toESM(require_data(), 1);
  var import_element184 = __toESM(require_element(), 1);
  var import_keycodes6 = __toESM(require_keycodes(), 1);
  var import_media_utils5 = __toESM(require_media_utils(), 1);
  var import_core_data60 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/style-book/constants.mjs
  var import_i18n187 = __toESM(require_i18n(), 1);
  var STYLE_BOOK_COLOR_GROUPS = [
    {
      slug: "theme-colors",
      title: (0, import_i18n187.__)("Theme Colors"),
      origin: "theme",
      type: "colors"
    },
    {
      slug: "theme-gradients",
      title: (0, import_i18n187.__)("Theme Gradients"),
      origin: "theme",
      type: "gradients"
    },
    {
      slug: "custom-colors",
      title: (0, import_i18n187.__)("Custom Colors"),
      origin: "custom",
      type: "colors"
    },
    {
      slug: "custom-gradients",
      title: (0, import_i18n187.__)("Custom Gradients"),
      origin: "custom",
      // User.
      type: "gradients"
    },
    {
      slug: "duotones",
      title: (0, import_i18n187.__)("Duotones"),
      origin: "theme",
      type: "duotones"
    },
    {
      slug: "default-colors",
      title: (0, import_i18n187.__)("Default Colors"),
      origin: "default",
      type: "colors"
    },
    {
      slug: "default-gradients",
      title: (0, import_i18n187.__)("Default Gradients"),
      origin: "default",
      type: "gradients"
    }
  ];
  var STYLE_BOOK_THEME_SUBCATEGORIES = [
    {
      slug: "site-identity",
      title: (0, import_i18n187.__)("Site Identity"),
      blocks: ["core/site-logo", "core/site-title", "core/site-tagline"]
    },
    {
      slug: "design",
      title: (0, import_i18n187.__)("Design"),
      blocks: ["core/navigation", "core/avatar", "core/post-time-to-read"],
      exclude: ["core/home-link", "core/navigation-link"]
    },
    {
      slug: "posts",
      title: (0, import_i18n187.__)("Posts"),
      blocks: [
        "core/post-title",
        "core/post-excerpt",
        "core/post-author",
        "core/post-author-name",
        "core/post-author-biography",
        "core/post-date",
        "core/post-terms",
        "core/term-description",
        "core/query-title",
        "core/query-no-results",
        "core/query-pagination",
        "core/query-numbers"
      ]
    },
    {
      slug: "comments",
      title: (0, import_i18n187.__)("Comments"),
      blocks: [
        "core/comments-title",
        "core/comments-pagination",
        "core/comments-pagination-numbers",
        "core/comments",
        "core/comments-author-name",
        "core/comment-content",
        "core/comment-date",
        "core/comment-edit-link",
        "core/comment-reply-link",
        "core/comment-template",
        "core/post-comments-count",
        "core/post-comments-link"
      ]
    }
  ];
  var STYLE_BOOK_CATEGORIES = [
    {
      slug: "overview",
      title: (0, import_i18n187.__)("Overview"),
      blocks: []
    },
    {
      slug: "text",
      title: (0, import_i18n187.__)("Text"),
      blocks: [
        "core/post-content",
        "core/home-link",
        "core/navigation-link"
      ]
    },
    {
      slug: "colors",
      title: (0, import_i18n187.__)("Colors"),
      blocks: []
    },
    {
      slug: "theme",
      title: (0, import_i18n187.__)("Theme"),
      subcategories: STYLE_BOOK_THEME_SUBCATEGORIES
    },
    {
      slug: "media",
      title: (0, import_i18n187.__)("Media"),
      blocks: ["core/post-featured-image"]
    },
    {
      slug: "widgets",
      title: (0, import_i18n187.__)("Widgets"),
      blocks: []
    },
    {
      slug: "embed",
      title: (0, import_i18n187.__)("Embeds"),
      include: []
    }
  ];
  var STYLE_BOOK_ALL_BLOCKS_SUBCATEGORIES = [
    ...STYLE_BOOK_THEME_SUBCATEGORIES,
    {
      slug: "media",
      title: (0, import_i18n187.__)("Media"),
      blocks: ["core/post-featured-image"]
    },
    {
      slug: "widgets",
      title: (0, import_i18n187.__)("Widgets"),
      blocks: []
    },
    {
      slug: "embed",
      title: (0, import_i18n187.__)("Embeds"),
      include: []
    }
  ];
  var STYLE_BOOK_PREVIEW_CATEGORIES = [
    {
      slug: "overview",
      title: (0, import_i18n187.__)("Overview"),
      blocks: []
    },
    {
      slug: "text",
      title: (0, import_i18n187.__)("Text"),
      blocks: [
        "core/post-content",
        "core/home-link",
        "core/navigation-link"
      ]
    },
    {
      slug: "colors",
      title: (0, import_i18n187.__)("Colors"),
      blocks: []
    },
    {
      slug: "blocks",
      title: (0, import_i18n187.__)("All Blocks"),
      blocks: [],
      subcategories: STYLE_BOOK_ALL_BLOCKS_SUBCATEGORIES
    }
  ];
  var ROOT_CONTAINER = `
	.is-root-container {
		display: flow-root;
	}
`;
  var STYLE_BOOK_IFRAME_STYLES = `
	body {
		position: relative;
		padding: 32px !important;
	}

	${ROOT_CONTAINER}

	.editor-style-book__examples {
		max-width: 1200px;
		margin: 0 auto;
	}

	.editor-style-book__example {
	    max-width: 900px;
		border-radius: 2px;
		cursor: var(--wpds-cursor-control, pointer);
		display: flex;
		flex-direction: column;
		gap: 40px;
		padding: 16px;
		width: 100%;
		box-sizing: border-box;
		scroll-margin-top: 32px;
		scroll-margin-bottom: 32px;
		margin: 0 auto 40px auto;
	}

	.editor-style-book__example.is-selected {
		box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
	}

	.editor-style-book__example.is-disabled-example {
		pointer-events: none;
	}

	.editor-style-book__example:focus:not(:disabled) {
		box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
		outline: 3px solid transparent;
	}

	.editor-style-book__duotone-example > div:first-child {
		display: flex;
		aspect-ratio: 16 / 9;
		grid-row: span 1;
		grid-column: span 2;
	}
	.editor-style-book__duotone-example img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
	.editor-style-book__duotone-example > div:not(:first-child) {
		height: 20px;
		border: 1px solid color-mix( in srgb, currentColor 10%, transparent );
	}

	.editor-style-book__color-example {
		border: 1px solid color-mix( in srgb, currentColor 10%, transparent );
	}

	.editor-style-book__subcategory-title,
	.editor-style-book__example-title {
		font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
		font-size: 13px;
		font-weight: normal;
		line-height: normal;
		margin: 0;
		text-align: left;
		padding-top: 8px;
		border-top: 1px solid color-mix( in srgb, currentColor 10%, transparent );
		color: color-mix( in srgb, currentColor 60%, transparent );
	}

	.editor-style-book__subcategory-title {
		font-size: 16px;
		margin-bottom: 40px;
    	padding-bottom: 8px;
	}

	.editor-style-book__example-preview {
		width: 100%;
	}

	.editor-style-book__example-preview .block-editor-block-list__insertion-point,
	.editor-style-book__example-preview .block-list-appender {
		display: none;
	}
	:where(.is-root-container > .wp-block:first-child) {
		margin-top: 0;
	}
	:where(.is-root-container > .wp-block:last-child) {
		margin-bottom: 0;
	}
`;

  // packages/editor/build-module/components/style-book/categories.mjs
  var import_blocks21 = __toESM(require_blocks(), 1);
  function getExamplesByCategory(categoryDefinition, examples) {
    if (!categoryDefinition?.slug || !examples?.length) {
      return;
    }
    const categories = categoryDefinition?.subcategories ?? [];
    if (categories.length) {
      return categories.reduce(
        (acc, subcategoryDefinition) => {
          const subcategoryExamples = getExamplesByCategory(
            subcategoryDefinition,
            examples
          );
          if (subcategoryExamples) {
            if (!acc.subcategories) {
              acc.subcategories = [];
            }
            acc.subcategories = [
              ...acc.subcategories,
              subcategoryExamples
            ];
          }
          return acc;
        },
        {
          title: categoryDefinition.title,
          slug: categoryDefinition.slug
        }
      );
    }
    const blocksToInclude = categoryDefinition?.blocks || [];
    const blocksToExclude = categoryDefinition?.exclude || [];
    const categoryExamples = examples.filter((example) => {
      return !blocksToExclude.includes(example.name) && (example.category === categoryDefinition.slug || blocksToInclude.includes(example.name));
    });
    if (!categoryExamples.length) {
      return;
    }
    return {
      title: categoryDefinition.title,
      slug: categoryDefinition.slug,
      examples: categoryExamples
    };
  }
  function getTopLevelStyleBookCategories() {
    const reservedCategories = [
      ...STYLE_BOOK_THEME_SUBCATEGORIES,
      ...STYLE_BOOK_CATEGORIES
    ].map(({ slug }) => slug);
    const extraCategories = (0, import_blocks21.getCategories)();
    const extraCategoriesFiltered = extraCategories.filter(
      ({ slug }) => !reservedCategories.includes(slug)
    );
    return [...STYLE_BOOK_CATEGORIES, ...extraCategoriesFiltered];
  }

  // packages/editor/build-module/components/style-book/examples.mjs
  var import_i18n188 = __toESM(require_i18n(), 1);
  var import_blocks22 = __toESM(require_blocks(), 1);

  // packages/editor/build-module/components/style-book/color-examples.mjs
  var import_components155 = __toESM(require_components(), 1);
  var import_block_editor38 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime330 = __toESM(require_jsx_runtime(), 1);
  var ColorExamples = ({
    colors: colors2,
    type,
    templateColumns = "1fr 1fr",
    itemHeight = "52px"
  }) => {
    if (!colors2) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(import_components155.__experimentalGrid, { templateColumns, rowGap: 8, columnGap: 16, children: colors2.map((color) => {
      const className = type === "gradients" ? (0, import_block_editor38.__experimentalGetGradientClass)(color.slug) : (0, import_block_editor38.getColorClassName)("background-color", color.slug);
      const classes = clsx_default(
        "editor-style-book__color-example",
        className
      );
      return /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(
        "div",
        {
          className: classes,
          style: { height: itemHeight }
        },
        color.slug
      );
    }) });
  };
  var color_examples_default = ColorExamples;

  // packages/editor/build-module/components/style-book/duotone-examples.mjs
  var import_components156 = __toESM(require_components(), 1);
  var import_jsx_runtime331 = __toESM(require_jsx_runtime(), 1);
  var DuotoneExamples = ({ duotones }) => {
    if (!duotones) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(import_components156.__experimentalGrid, { columns: 2, rowGap: 16, columnGap: 16, children: duotones.map((duotone) => {
      return /* @__PURE__ */ (0, import_jsx_runtime331.jsxs)(
        import_components156.__experimentalGrid,
        {
          className: "editor-style-book__duotone-example",
          columns: 2,
          rowGap: 8,
          columnGap: 8,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime331.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(
              "img",
              {
                alt: `Duotone example: ${duotone.slug}`,
                src: "https://s.w.org/images/core/5.3/MtBlanc1.jpg",
                style: {
                  filter: `url(#wp-duotone-${duotone.slug})`
                }
              }
            ) }),
            duotone.colors.map((color) => {
              return /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(
                "div",
                {
                  className: "editor-style-book__color-example",
                  style: { backgroundColor: color }
                },
                color
              );
            })
          ]
        },
        duotone.slug
      );
    }) });
  };
  var duotone_examples_default = DuotoneExamples;

  // packages/editor/build-module/components/style-book/examples.mjs
  var import_jsx_runtime332 = __toESM(require_jsx_runtime(), 1);
  function getColorExamples(colors2) {
    if (!colors2) {
      return [];
    }
    const examples = [];
    STYLE_BOOK_COLOR_GROUPS.forEach((group) => {
      const palette = colors2[group.type];
      const paletteFiltered = Array.isArray(palette) ? palette.find(
        (origin) => origin.slug === group.origin
      ) : void 0;
      if (paletteFiltered?.[group.type]) {
        const example = {
          name: group.slug,
          title: group.title,
          category: "colors"
        };
        if (group.type === "duotones") {
          example.content = /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(
            duotone_examples_default,
            {
              duotones: paletteFiltered[group.type]
            }
          );
          examples.push(example);
        } else {
          example.content = /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(
            color_examples_default,
            {
              colors: paletteFiltered[group.type],
              type: group.type
            }
          );
          examples.push(example);
        }
      }
    });
    return examples;
  }
  function getOverviewBlockExamples(colors2) {
    const examples = [];
    const themePalette = Array.isArray(colors2?.colors) ? colors2.colors.find(
      (origin) => origin.slug === "theme"
    ) : void 0;
    if (themePalette) {
      const themeColorexample = {
        name: "theme-colors",
        title: (0, import_i18n188.__)("Colors"),
        category: "overview",
        content: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(
          color_examples_default,
          {
            colors: themePalette.colors,
            type: "colors",
            templateColumns: "repeat(auto-fill, minmax( 200px, 1fr ))",
            itemHeight: "32px"
          }
        )
      };
      examples.push(themeColorexample);
    }
    const typographyBlockExamples = [];
    if ((0, import_blocks22.getBlockType)("core/heading")) {
      const headingBlock = (0, import_blocks22.createBlock)("core/heading", {
        // translators: Typography example. Your local alphabet, numbers and some common special characters.
        content: (0, import_i18n188.__)(
          `AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789X{(\u2026)},.-<>?!*&:/A@HELFO\u2122\xA9`
        ),
        level: 1
      });
      typographyBlockExamples.push(headingBlock);
    }
    if ((0, import_blocks22.getBlockType)("core/paragraph")) {
      const firstParagraphBlock = (0, import_blocks22.createBlock)("core/paragraph", {
        content: (0, import_i18n188.__)(
          `A paragraph in a website refers to a distinct block of text that is used to present and organize information. It is a fundamental unit of content in web design and is typically composed of a group of related sentences or thoughts focused on a particular topic or idea. Paragraphs play a crucial role in improving the readability and user experience of a website. They break down the text into smaller, manageable chunks, allowing readers to scan the content more easily.`
        )
      });
      const secondParagraphBlock = (0, import_blocks22.createBlock)("core/paragraph", {
        content: (0, import_i18n188.__)(
          `Additionally, paragraphs help structure the flow of information and provide logical breaks between different concepts or pieces of information. In terms of formatting, paragraphs in websites are commonly denoted by a vertical gap or indentation between each block of text. This visual separation helps visually distinguish one paragraph from another, creating a clear and organized layout that guides the reader through the content smoothly.`
        )
      });
      if ((0, import_blocks22.getBlockType)("core/group")) {
        const groupBlock = (0, import_blocks22.createBlock)(
          "core/group",
          {
            layout: {
              type: "grid",
              columnCount: 2,
              minimumColumnWidth: "12rem"
            },
            style: {
              spacing: {
                blockGap: "1.5rem"
              }
            }
          },
          [firstParagraphBlock, secondParagraphBlock]
        );
        typographyBlockExamples.push(groupBlock);
      } else {
        typographyBlockExamples.push(firstParagraphBlock);
      }
    }
    if (!!typographyBlockExamples.length) {
      examples.push({
        name: "typography",
        title: (0, import_i18n188.__)("Typography"),
        category: "overview",
        blocks: typographyBlockExamples
      });
    }
    const otherBlockExamples = [
      "core/image",
      "core/separator",
      "core/buttons",
      "core/pullquote",
      "core/search"
    ];
    otherBlockExamples.forEach((blockName) => {
      const blockType = (0, import_blocks22.getBlockType)(blockName);
      if (blockType && blockType.example) {
        const blockExample = {
          name: blockName,
          title: blockType.title,
          category: "overview",
          /*
           * CSS generated from style attributes will take precedence over global styles CSS,
           * so remove the style attribute from the example to ensure the example
           * demonstrates changes to global styles.
           */
          blocks: (0, import_blocks22.getBlockFromExample)(blockName, {
            ...blockType.example,
            attributes: {
              ...blockType.example.attributes,
              style: void 0
            }
          })
        };
        examples.push(blockExample);
      }
    });
    return examples;
  }
  function getExamples(colors2) {
    const nonHeadingBlockExamples = (0, import_blocks22.getBlockTypes)().filter((blockType) => {
      const { name: name2, example, supports } = blockType;
      return name2 !== "core/heading" && !!example && supports?.inserter !== false;
    }).map((blockType) => ({
      name: blockType.name,
      title: blockType.title,
      category: blockType.category,
      /*
       * CSS generated from style attributes will take precedence over global styles CSS,
       * so remove the style attribute from the example to ensure the example
       * demonstrates changes to global styles.
       */
      blocks: (0, import_blocks22.getBlockFromExample)(blockType.name, {
        ...blockType.example,
        attributes: {
          ...blockType.example?.attributes,
          style: void 0
        }
      })
    }));
    const isHeadingBlockRegistered = !!(0, import_blocks22.getBlockType)("core/heading");
    if (!isHeadingBlockRegistered) {
      return nonHeadingBlockExamples;
    }
    const headingsExample = {
      name: "core/heading",
      title: (0, import_i18n188.__)("Headings"),
      category: "text",
      blocks: [1, 2, 3, 4, 5, 6].map((level) => {
        return (0, import_blocks22.createBlock)("core/heading", {
          content: (0, import_i18n188.sprintf)(
            // translators: %d: heading level e.g: "1", "2", "3"
            (0, import_i18n188.__)("Heading %d"),
            level
          ),
          level
        });
      })
    };
    const colorExamples = getColorExamples(colors2);
    const overviewBlockExamples = getOverviewBlockExamples(colors2);
    return [
      headingsExample,
      ...colorExamples,
      ...nonHeadingBlockExamples,
      ...overviewBlockExamples
    ];
  }

  // packages/editor/build-module/components/global-styles-renderer/index.mjs
  var import_element183 = __toESM(require_element(), 1);
  var import_data87 = __toESM(require_data(), 1);

  // packages/editor/build-module/hooks/use-global-styles-output.mjs
  var import_blocks23 = __toESM(require_blocks(), 1);
  var import_data86 = __toESM(require_data(), 1);
  var import_element182 = __toESM(require_element(), 1);
  function useGlobalStylesOutputWithConfig(mergedConfig = {}, disableRootPadding = false) {
    const blockGap = useSetting2("spacing.blockGap");
    const hasBlockGapSupport = blockGap !== null;
    const hasFallbackGapSupport = !hasBlockGapSupport;
    const { disableLayoutStyles, getBlockStyles } = (0, import_data86.useSelect)((select7) => {
      const { getEditorSettings: getEditorSettings2 } = select7(store3);
      const { getBlockStyles: getBlockStylesSelector } = select7(import_blocks23.store);
      const settings = getEditorSettings2();
      return {
        disableLayoutStyles: !!settings?.disableLayoutStyles,
        getBlockStyles: getBlockStylesSelector
      };
    }, []);
    return (0, import_element182.useMemo)(() => {
      if (!mergedConfig?.styles || !mergedConfig?.settings) {
        return [[], {}];
      }
      const blockTypes = (0, import_blocks23.getBlockTypes)();
      return generateGlobalStyles(mergedConfig, blockTypes, {
        hasBlockGapSupport,
        hasFallbackGapSupport,
        disableLayoutStyles,
        disableRootPadding,
        getBlockStyles
      });
    }, [
      hasBlockGapSupport,
      hasFallbackGapSupport,
      mergedConfig,
      disableLayoutStyles,
      disableRootPadding,
      getBlockStyles
    ]);
  }
  function useGlobalStylesOutput(disableRootPadding = false) {
    const { merged: mergedConfig } = useGlobalStyles();
    return useGlobalStylesOutputWithConfig(mergedConfig, disableRootPadding);
  }

  // packages/editor/build-module/components/global-styles-renderer/index.mjs
  function useGlobalStylesRenderer(disableRootPadding) {
    const [styles, settings] = useGlobalStylesOutput(disableRootPadding);
    const { getEditorSettings: getEditorSettings2 } = (0, import_data87.useSelect)(store3);
    const { updateEditorSettings: updateEditorSettings2 } = (0, import_data87.useDispatch)(store3);
    (0, import_element183.useEffect)(() => {
      if (!styles || !settings) {
        return;
      }
      const currentStoreSettings = getEditorSettings2();
      const nonGlobalStyles = Object.values(
        currentStoreSettings.styles ?? []
      ).filter((style) => !style.isGlobalStyles);
      updateEditorSettings2({
        ...currentStoreSettings,
        styles: [...nonGlobalStyles, ...styles],
        __experimentalFeatures: settings
      });
    }, [styles, settings, updateEditorSettings2, getEditorSettings2]);
  }
  function GlobalStylesRenderer({ disableRootPadding }) {
    useGlobalStylesRenderer(disableRootPadding);
    return null;
  }

  // packages/editor/build-module/components/style-book/index.mjs
  var import_jsx_runtime333 = __toESM(require_jsx_runtime(), 1);
  var { ExperimentalBlockEditorProvider: ExperimentalBlockEditorProvider2 } = unlock(import_block_editor39.privateApis);
  var { Tabs: Tabs4 } = unlock(import_components157.privateApis);
  function isObjectEmpty(object) {
    return !object || Object.keys(object).length === 0;
  }
  var scrollToSection = (anchorId, iframe) => {
    if (!anchorId || !iframe || !iframe?.contentDocument) {
      return;
    }
    const element = anchorId === "top" ? iframe.contentDocument.body : iframe.contentDocument.getElementById(anchorId);
    if (element) {
      element.scrollIntoView({
        behavior: "smooth"
      });
    }
  };
  var getStyleBookNavigationFromPath = (path) => {
    if (path && typeof path === "string") {
      if (path === "/" || path.startsWith("/typography") || path.startsWith("/colors") || path.startsWith("/blocks")) {
        return {
          top: true
        };
      }
    }
    return null;
  };
  function useMultiOriginPalettes() {
    const { colors: colors2, gradients } = (0, import_block_editor39.__experimentalUseMultipleOriginColorsAndGradients)();
    const [
      shouldDisplayDefaultDuotones,
      customDuotones,
      themeDuotones,
      defaultDuotones
    ] = (0, import_block_editor39.useSettings)(
      "color.defaultDuotone",
      "color.duotone.custom",
      "color.duotone.theme",
      "color.duotone.default"
    );
    const palettes = (0, import_element184.useMemo)(() => {
      const result = { colors: colors2, gradients, duotones: [] };
      if (themeDuotones && themeDuotones.length) {
        result.duotones.push({
          name: (0, import_i18n189._x)(
            "Theme",
            "Indicates these duotone filters come from the theme."
          ),
          slug: "theme",
          duotones: themeDuotones
        });
      }
      if (shouldDisplayDefaultDuotones && defaultDuotones && defaultDuotones.length) {
        result.duotones.push({
          name: (0, import_i18n189._x)(
            "Default",
            "Indicates these duotone filters come from WordPress."
          ),
          slug: "default",
          duotones: defaultDuotones
        });
      }
      if (customDuotones && customDuotones.length) {
        result.duotones.push({
          name: (0, import_i18n189._x)(
            "Custom",
            "Indicates these doutone filters are created by the user."
          ),
          slug: "custom",
          duotones: customDuotones
        });
      }
      return result;
    }, [
      colors2,
      gradients,
      customDuotones,
      themeDuotones,
      defaultDuotones,
      shouldDisplayDefaultDuotones
    ]);
    return palettes;
  }
  function getExamplesForSinglePageUse(examples) {
    const examplesForSinglePageUse = [];
    const overviewCategoryExamples = getExamplesByCategory(
      { slug: "overview" },
      examples
    );
    examplesForSinglePageUse.push(...overviewCategoryExamples.examples);
    const otherExamples = examples.filter((example) => {
      return example.category !== "overview" && !overviewCategoryExamples.examples.find(
        (overviewExample) => overviewExample.name === example.name
      );
    });
    examplesForSinglePageUse.push(...otherExamples);
    return examplesForSinglePageUse;
  }
  function applyBlockVariationsToExamples(examples, variation) {
    if (!variation) {
      return examples;
    }
    return examples.map((example) => {
      return {
        ...example,
        variation,
        blocks: Array.isArray(example.blocks) ? example.blocks.map((block) => ({
          ...block,
          attributes: {
            ...block.attributes,
            style: void 0,
            className: `is-style-${variation}`
          }
        })) : {
          ...example.blocks,
          attributes: {
            ...example.blocks.attributes,
            style: void 0,
            className: `is-style-${variation}`
          }
        }
      };
    });
  }
  function StyleBook({
    isSelected: isSelected2,
    onClick,
    onSelect,
    showTabs = true,
    userConfig = {},
    path = ""
  }, ref) {
    const textColor = useStyle2("color.text");
    const backgroundColor = useStyle2("color.background");
    const colors2 = useMultiOriginPalettes();
    const examples = (0, import_element184.useMemo)(() => getExamples(colors2), [colors2]);
    const tabs = (0, import_element184.useMemo)(
      () => getTopLevelStyleBookCategories().filter(
        (category) => examples.some(
          (example) => example.category === category.slug
        )
      ),
      [examples]
    );
    const examplesForSinglePageUse = getExamplesForSinglePageUse(examples);
    const { base: baseConfig } = useGlobalStyles();
    const goTo = getStyleBookNavigationFromPath(path);
    const mergedConfig = (0, import_element184.useMemo)(() => {
      if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) {
        return mergeGlobalStyles(baseConfig, userConfig);
      }
      return {};
    }, [baseConfig, userConfig]);
    const originalSettings = (0, import_data88.useSelect)(
      (select7) => select7(import_block_editor39.store).getSettings(),
      []
    );
    const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig);
    const settings = (0, import_element184.useMemo)(
      () => ({
        ...originalSettings,
        styles: !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : originalSettings.styles,
        isPreviewMode: true
      }),
      [globalStyles, originalSettings, userConfig]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
      "div",
      {
        ref,
        className: clsx_default("editor-style-book", {
          "is-button": !!onClick
        }),
        style: {
          color: textColor,
          background: backgroundColor
        },
        children: showTabs ? /* @__PURE__ */ (0, import_jsx_runtime333.jsxs)(Tabs4, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime333.jsx)("div", { className: "editor-style-book__tablist-container", children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(Tabs4.TabList, { children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(Tabs4.Tab, { tabId: tab.slug, children: tab.title }, tab.slug)) }) }),
          tabs.map((tab) => {
            const categoryDefinition = tab.slug ? getTopLevelStyleBookCategories().find(
              (_category) => _category.slug === tab.slug
            ) : null;
            const filteredExamples = categoryDefinition ? getExamplesByCategory(
              categoryDefinition,
              examples
            ) : { examples };
            return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
              Tabs4.TabPanel,
              {
                tabId: tab.slug,
                focusable: false,
                className: "editor-style-book__tabpanel",
                children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
                  StyleBookBody,
                  {
                    category: tab.slug,
                    examples: filteredExamples,
                    isSelected: isSelected2,
                    onSelect,
                    settings,
                    title: tab.title,
                    goTo
                  }
                )
              },
              tab.slug
            );
          })
        ] }) : /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
          StyleBookBody,
          {
            examples: { examples: examplesForSinglePageUse },
            isSelected: isSelected2,
            onClick,
            onSelect,
            settings,
            goTo
          }
        )
      }
    );
  }
  var StyleBookPreview = ({
    userConfig = {},
    isStatic = false,
    path,
    onPathChange,
    settings: settingsProp
  }) => {
    const editorSettings2 = (0, import_data88.useSelect)(
      (select7) => settingsProp ?? select7(store3).getEditorSettings(),
      [settingsProp]
    );
    const canUserUploadMedia = (0, import_data88.useSelect)(
      (select7) => select7(import_core_data60.store).canUser("create", {
        kind: "postType",
        name: "attachment"
      }),
      []
    );
    (0, import_element184.useEffect)(() => {
      (0, import_data88.dispatch)(import_block_editor39.store).updateSettings({
        ...editorSettings2,
        mediaUpload: canUserUploadMedia ? import_media_utils5.uploadMedia : void 0
      });
    }, [editorSettings2, canUserUploadMedia]);
    const [internalPath, setInternalPath] = (0, import_element184.useState)("/");
    const section = path ?? internalPath;
    const onChangeSection = onPathChange ?? setInternalPath;
    const isSelected2 = (blockName) => {
      return section === `/blocks/${encodeURIComponent(blockName)}` || section.startsWith(
        `/blocks/${encodeURIComponent(blockName)}/`
      );
    };
    const onSelect = (blockName, isBlockVariation = false) => {
      if (STYLE_BOOK_COLOR_GROUPS.find(
        (group) => group.slug === blockName
      )) {
        onChangeSection("/colors/palette");
        return;
      }
      if (blockName === "typography") {
        onChangeSection("/typography");
        return;
      }
      if (isBlockVariation) {
        return;
      }
      onChangeSection(`/blocks/${encodeURIComponent(blockName)}`);
    };
    const colors2 = useMultiOriginPalettes();
    const examples = getExamples(colors2);
    const examplesForSinglePageUse = getExamplesForSinglePageUse(examples);
    let previewCategory = null;
    let blockVariation = null;
    if (section.includes("/colors")) {
      previewCategory = "colors";
    } else if (section.includes("/typography")) {
      previewCategory = "text";
    } else if (section.includes("/blocks")) {
      previewCategory = "blocks";
      let blockName = decodeURIComponent(section).split("/blocks/")[1];
      if (blockName?.includes("/variations")) {
        [blockName, blockVariation] = blockName.split("/variations/");
      }
      if (blockName && examples.find((example) => example.name === blockName)) {
        previewCategory = blockName;
      }
    } else if (!isStatic) {
      previewCategory = "overview";
    }
    const categoryDefinition = STYLE_BOOK_PREVIEW_CATEGORIES.find(
      (category) => category.slug === previewCategory
    );
    const filteredExamples = (0, import_element184.useMemo)(() => {
      if (!categoryDefinition) {
        return {
          examples: [
            examples.find(
              (example) => example.name === previewCategory
            )
          ]
        };
      }
      return getExamplesByCategory(categoryDefinition, examples);
    }, [categoryDefinition, examples, previewCategory]);
    const displayedExamples = (0, import_element184.useMemo)(() => {
      if (!previewCategory) {
        return { examples: examplesForSinglePageUse };
      }
      if (blockVariation) {
        return {
          examples: applyBlockVariationsToExamples(
            filteredExamples.examples,
            blockVariation
          )
        };
      }
      return filteredExamples;
    }, [
      previewCategory,
      examplesForSinglePageUse,
      blockVariation,
      filteredExamples
    ]);
    const { base: baseConfig } = useGlobalStyles();
    const goTo = getStyleBookNavigationFromPath(section);
    const mergedConfig = (0, import_element184.useMemo)(() => {
      if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) {
        return mergeGlobalStyles(baseConfig, userConfig);
      }
      return {};
    }, [baseConfig, userConfig]);
    const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig);
    const settings = (0, import_element184.useMemo)(
      () => ({
        ...editorSettings2,
        styles: !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : editorSettings2.styles,
        isPreviewMode: true
      }),
      [globalStyles, editorSettings2, userConfig]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)("div", { className: "editor-style-book", children: /* @__PURE__ */ (0, import_jsx_runtime333.jsxs)(import_block_editor39.BlockEditorProvider, { settings, children: [
      /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(GlobalStylesRenderer, { disableRootPadding: true }),
      /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
        StyleBookBody,
        {
          examples: displayedExamples,
          settings,
          goTo,
          isSelected: !isStatic ? isSelected2 : null,
          onSelect: !isStatic ? onSelect : null
        }
      )
    ] }) });
  };
  var StyleBookBody = ({
    examples,
    isSelected: isSelected2,
    onClick,
    onSelect,
    settings,
    title,
    goTo
  }) => {
    const [isFocused, setIsFocused] = (0, import_element184.useState)(false);
    const [hasIframeLoaded, setHasIframeLoaded] = (0, import_element184.useState)(false);
    const iframeRef = (0, import_element184.useRef)(null);
    const buttonModeProps = {
      role: "button",
      onFocus: () => setIsFocused(true),
      onBlur: () => setIsFocused(false),
      onKeyDown: (event) => {
        if (event.defaultPrevented) {
          return;
        }
        const { keyCode } = event;
        if (onClick && (keyCode === import_keycodes6.ENTER || keyCode === import_keycodes6.SPACE)) {
          event.preventDefault();
          onClick(event);
        }
      },
      onClick: (event) => {
        if (event.defaultPrevented) {
          return;
        }
        if (onClick) {
          event.preventDefault();
          onClick(event);
        }
      },
      readonly: true
    };
    const handleLoad = () => setHasIframeLoaded(true);
    (0, import_element184.useLayoutEffect)(() => {
      if (hasIframeLoaded && iframeRef.current && goTo?.top) {
        scrollToSection("top", iframeRef.current);
      }
    }, [goTo?.top, hasIframeLoaded]);
    return /* @__PURE__ */ (0, import_jsx_runtime333.jsxs)(
      import_block_editor39.__unstableIframe,
      {
        onLoad: handleLoad,
        ref: iframeRef,
        className: clsx_default("editor-style-book__iframe", {
          "is-focused": isFocused && !!onClick,
          "is-button": !!onClick
        }),
        name: "style-book-canvas",
        tabIndex: 0,
        ...onClick ? buttonModeProps : {},
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_block_editor39.__unstableEditorStyles, { styles: settings.styles }),
          /* @__PURE__ */ (0, import_jsx_runtime333.jsxs)("style", { children: [
            STYLE_BOOK_IFRAME_STYLES,
            !!onClick && "body { cursor: var(--wpds-cursor-control, pointer); } body * { pointer-events: none; }"
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
            Examples,
            {
              className: "editor-style-book__examples",
              filteredExamples: examples,
              label: title ? (0, import_i18n189.sprintf)(
                // translators: %s: Category of blocks, e.g. Text.
                (0, import_i18n189.__)("Examples of blocks in the %s category"),
                title
              ) : (0, import_i18n189.__)("Examples of blocks"),
              isSelected: isSelected2,
              onSelect
            },
            title
          )
        ]
      }
    );
  };
  var Examples = (0, import_element184.memo)(
    ({ className, filteredExamples, label, isSelected: isSelected2, onSelect }) => {
      return /* @__PURE__ */ (0, import_jsx_runtime333.jsxs)(
        import_components157.Composite,
        {
          orientation: "vertical",
          className,
          "aria-label": label,
          role: "grid",
          children: [
            !!filteredExamples?.examples?.length && filteredExamples.examples.map((example) => /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
              Example,
              {
                id: `example-${example.name}`,
                title: example.title,
                content: example.content,
                blocks: example.blocks,
                isSelected: isSelected2?.(example.name),
                onClick: !!onSelect ? () => onSelect(
                  example.name,
                  !!example.variation
                ) : null
              },
              example.name
            )),
            !!filteredExamples?.subcategories?.length && filteredExamples.subcategories.map((subcategory) => /* @__PURE__ */ (0, import_jsx_runtime333.jsxs)(
              import_components157.Composite.Group,
              {
                className: "editor-style-book__subcategory",
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_components157.Composite.GroupLabel, { children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)("h2", { className: "editor-style-book__subcategory-title", children: subcategory.title }) }),
                  /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
                    Subcategory,
                    {
                      examples: subcategory.examples,
                      isSelected: isSelected2,
                      onSelect
                    }
                  )
                ]
              },
              `subcategory-${subcategory.slug}`
            ))
          ]
        }
      );
    }
  );
  var Subcategory = ({ examples, isSelected: isSelected2, onSelect }) => {
    return !!examples?.length && examples.map((example) => /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
      Example,
      {
        id: `example-${example.name}`,
        title: example.title,
        content: example.content,
        blocks: example.blocks,
        isSelected: isSelected2?.(example.name),
        onClick: !!onSelect ? () => onSelect(example.name) : null
      },
      example.name
    ));
  };
  var disabledExamples = ["example-duotones"];
  var Example = ({ id, title, blocks, isSelected: isSelected2, onClick, content }) => {
    const originalSettings = (0, import_data88.useSelect)(
      (select7) => select7(import_block_editor39.store).getSettings(),
      []
    );
    const settings = (0, import_element184.useMemo)(
      () => ({
        ...originalSettings,
        focusMode: false,
        // Disable "Spotlight mode".
        isPreviewMode: true
      }),
      [originalSettings]
    );
    const renderedBlocks = (0, import_element184.useMemo)(
      () => Array.isArray(blocks) ? blocks : [blocks],
      [blocks]
    );
    const disabledProps = disabledExamples.includes(id) || !onClick ? {
      disabled: true,
      accessibleWhenDisabled: !!onClick
    } : {};
    return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)("div", { role: "row", children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime333.jsxs)(
      import_components157.Composite.Item,
      {
        className: clsx_default("editor-style-book__example", {
          "is-selected": isSelected2,
          "is-disabled-example": !!disabledProps?.disabled
        }),
        id,
        "aria-label": !!onClick ? (0, import_i18n189.sprintf)(
          // translators: %s: Title of a block, e.g. Heading.
          (0, import_i18n189.__)("Open %s styles in Styles panel"),
          title
        ) : void 0,
        render: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)("div", {}),
        role: !!onClick ? "button" : null,
        onClick,
        ...disabledProps,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime333.jsx)("span", { className: "editor-style-book__example-title", children: title }),
          /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
            "div",
            {
              className: "editor-style-book__example-preview",
              "aria-hidden": true,
              children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_components157.Disabled, { className: "editor-style-book__example-preview__content", children: content ? content : /* @__PURE__ */ (0, import_jsx_runtime333.jsxs)(
                ExperimentalBlockEditorProvider2,
                {
                  value: renderedBlocks,
                  settings,
                  children: [
                    /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_block_editor39.__unstableEditorStyles, {}),
                    /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_block_editor39.BlockList, { renderAppender: false })
                  ]
                }
              ) })
            }
          )
        ]
      }
    ) }) });
  };
  var style_book_default = (0, import_element184.forwardRef)(StyleBook);

  // packages/editor/build-module/components/styles-canvas/style-book.mjs
  var import_jsx_runtime334 = __toESM(require_jsx_runtime(), 1);
  function StylesCanvasStyleBook({ path, onPathChange }, ref) {
    return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
      style_book_default,
      {
        ref,
        isSelected: (blockName) => (
          // Match '/blocks/core%2Fbutton' and
          // '/blocks/core%2Fbutton/typography', but not
          // '/blocks/core%2Fbuttons'.
          path === `/blocks/${encodeURIComponent(blockName)}` || path?.startsWith(
            `/blocks/${encodeURIComponent(blockName)}/`
          )
        ),
        onSelect: (blockName) => {
          if (STYLE_BOOK_COLOR_GROUPS.find(
            (group) => group.slug === blockName
          )) {
            onPathChange?.("/colors/palette");
            return;
          }
          if (blockName === "typography") {
            onPathChange?.("/typography");
            return;
          }
          onPathChange?.("/blocks/" + encodeURIComponent(blockName));
        }
      }
    );
  }
  var style_book_default2 = (0, import_element185.forwardRef)(StylesCanvasStyleBook);

  // packages/editor/build-module/components/styles-canvas/revisions.mjs
  var import_components158 = __toESM(require_components(), 1);
  var import_block_editor40 = __toESM(require_block_editor(), 1);
  var import_data89 = __toESM(require_data(), 1);
  var import_element186 = __toESM(require_element(), 1);
  var import_jsx_runtime335 = __toESM(require_jsx_runtime(), 1);
  var {
    ExperimentalBlockEditorProvider: ExperimentalBlockEditorProvider3,
    BlockStyleVariationOverridesWithConfig
  } = unlock(import_block_editor40.privateApis);
  function isObjectEmpty2(object) {
    return !object || Object.keys(object).length === 0;
  }
  function StylesCanvasRevisions({ path }, ref) {
    const blocks = (0, import_data89.useSelect)((select7) => {
      return select7(import_block_editor40.store).getBlocks();
    }, []);
    const { user: userConfig, base: baseConfig } = useGlobalStyles();
    const { revisions, isLoading } = useGlobalStylesRevisions();
    const revisionId2 = (0, import_element186.useMemo)(() => {
      const match3 = path?.match(/^\/revisions\/(.+)$/);
      return match3 ? match3[1] : null;
    }, [path]);
    const selectedRevision = (0, import_element186.useMemo)(() => {
      if (!revisionId2 || !revisions.length) {
        return null;
      }
      return revisions.find(
        (rev) => String(rev.id) === String(revisionId2)
      );
    }, [revisionId2, revisions]);
    const displayConfig = selectedRevision || userConfig;
    const mergedConfig = (0, import_element186.useMemo)(() => {
      if (!isObjectEmpty2(displayConfig) && !isObjectEmpty2(baseConfig)) {
        return mergeGlobalStyles(baseConfig, displayConfig);
      }
      return {};
    }, [baseConfig, displayConfig]);
    const renderedBlocksArray = (0, import_element186.useMemo)(
      () => Array.isArray(blocks) ? blocks : [blocks],
      [blocks]
    );
    const originalSettings = (0, import_data89.useSelect)(
      (select7) => select7(import_block_editor40.store).getSettings(),
      []
    );
    const settings = (0, import_element186.useMemo)(
      () => ({
        ...originalSettings,
        isPreviewMode: true
      }),
      [originalSettings]
    );
    const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig);
    const editorStyles = !isObjectEmpty2(globalStyles) && !isObjectEmpty2(displayConfig) ? globalStyles : settings.styles;
    if (isLoading) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)(
      import_block_editor40.__unstableIframe,
      {
        ref,
        className: "editor-revisions__iframe",
        name: "revisions",
        tabIndex: 0,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime335.jsx)("style", {
            // Forming a "block formatting context" to prevent margin collapsing.
            // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
            children: `.is-root-container { display: flow-root; }`
          }),
          /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_components158.Disabled, { className: "editor-revisions__example-preview__content", children: /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)(
            ExperimentalBlockEditorProvider3,
            {
              value: renderedBlocksArray,
              settings,
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_block_editor40.BlockList, { renderAppender: false }),
                /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_block_editor40.__unstableEditorStyles, { styles: editorStyles }),
                /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(
                  BlockStyleVariationOverridesWithConfig,
                  {
                    config: mergedConfig
                  }
                )
              ]
            }
          ) })
        ]
      }
    );
  }
  var revisions_default = (0, import_element186.forwardRef)(StylesCanvasRevisions);

  // packages/editor/build-module/components/resizable-editor/index.mjs
  var import_element187 = __toESM(require_element(), 1);
  var import_components160 = __toESM(require_components(), 1);

  // packages/editor/build-module/components/resizable-editor/resize-handle.mjs
  var import_i18n190 = __toESM(require_i18n(), 1);
  var import_keycodes7 = __toESM(require_keycodes(), 1);
  var import_components159 = __toESM(require_components(), 1);
  var import_jsx_runtime336 = __toESM(require_jsx_runtime(), 1);
  var DELTA_DISTANCE = 20;
  function ResizeHandle({ direction, resizeWidthBy }) {
    function handleKeyDown(event) {
      const { keyCode } = event;
      if (keyCode !== import_keycodes7.LEFT && keyCode !== import_keycodes7.RIGHT) {
        return;
      }
      event.preventDefault();
      if (direction === "left" && keyCode === import_keycodes7.LEFT || direction === "right" && keyCode === import_keycodes7.RIGHT) {
        resizeWidthBy(DELTA_DISTANCE);
      } else if (direction === "left" && keyCode === import_keycodes7.RIGHT || direction === "right" && keyCode === import_keycodes7.LEFT) {
        resizeWidthBy(-DELTA_DISTANCE);
      }
    }
    const resizeHandleVariants = {
      active: {
        opacity: 1,
        scaleY: 1.3
      }
    };
    const resizableHandleHelpId = `resizable-editor__resize-help-${direction}`;
    return /* @__PURE__ */ (0, import_jsx_runtime336.jsxs)(import_jsx_runtime336.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(import_components159.Tooltip, { text: (0, import_i18n190.__)("Drag to resize"), children: /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(
        import_components159.__unstableMotion.button,
        {
          className: `editor-resizable-editor__resize-handle is-${direction}`,
          "aria-label": (0, import_i18n190.__)("Drag to resize"),
          "aria-describedby": resizableHandleHelpId,
          onKeyDown: handleKeyDown,
          variants: resizeHandleVariants,
          whileFocus: "active",
          whileHover: "active",
          whileTap: "active",
          role: "separator",
          "aria-orientation": "vertical"
        },
        "handle"
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(VisuallyHidden, { id: resizableHandleHelpId, children: (0, import_i18n190.__)("Use left and right arrow keys to resize the canvas.") })
    ] });
  }

  // packages/editor/build-module/components/resizable-editor/index.mjs
  var import_jsx_runtime337 = __toESM(require_jsx_runtime(), 1);
  var HANDLE_STYLES_OVERRIDE = {
    position: void 0,
    userSelect: void 0,
    cursor: void 0,
    width: void 0,
    height: void 0,
    top: void 0,
    right: void 0,
    bottom: void 0,
    left: void 0
  };
  function ResizableEditor({ className, enableResizing, height, children }) {
    const [width, setWidth] = (0, import_element187.useState)("100%");
    const resizableRef = (0, import_element187.useRef)();
    const resizeWidthBy = (0, import_element187.useCallback)((deltaPixels) => {
      if (resizableRef.current) {
        setWidth(resizableRef.current.offsetWidth + deltaPixels);
      }
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
      import_components160.ResizableBox,
      {
        className: clsx_default("editor-resizable-editor", className, {
          "is-resizable": enableResizing
        }),
        ref: (api) => {
          resizableRef.current = api?.resizable;
        },
        size: {
          width: enableResizing ? width : "100%",
          height: enableResizing && height ? height : "100%"
        },
        onResizeStop: (event, direction, element) => {
          setWidth(element.style.width);
        },
        minWidth: 300,
        maxWidth: "100%",
        maxHeight: "100%",
        enable: {
          left: enableResizing,
          right: enableResizing
        },
        showHandle: enableResizing,
        resizeRatio: 2,
        handleComponent: {
          left: /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
            ResizeHandle,
            {
              direction: "left",
              resizeWidthBy
            }
          ),
          right: /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
            ResizeHandle,
            {
              direction: "right",
              resizeWidthBy
            }
          )
        },
        handleClasses: void 0,
        handleStyles: {
          left: HANDLE_STYLES_OVERRIDE,
          right: HANDLE_STYLES_OVERRIDE
        },
        children
      }
    );
  }
  var resizable_editor_default = ResizableEditor;

  // packages/editor/build-module/components/styles-canvas/index.mjs
  var import_jsx_runtime338 = __toESM(require_jsx_runtime(), 1);
  function getStylesCanvasTitle(path, showStylebook2) {
    if (showStylebook2) {
      return (0, import_i18n191.__)("Style Book");
    }
    if (path?.startsWith("/revisions")) {
      return (0, import_i18n191.__)("Style Revisions");
    }
    return "";
  }
  function StylesCanvas() {
    const { stylesPath: stylesPath2, showStylebook: showStylebook2, showListViewByDefault } = (0, import_data90.useSelect)(
      (select7) => {
        const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock(
          select7(store3)
        );
        const _showListViewByDefault = select7(import_preferences11.store).get(
          "core",
          "showListViewByDefault"
        );
        return {
          stylesPath: getStylesPath2(),
          showStylebook: getShowStylebook2(),
          showListViewByDefault: _showListViewByDefault
        };
      },
      []
    );
    const { resetStylesNavigation: resetStylesNavigation2, setStylesPath: setStylesPath2 } = unlock(
      (0, import_data90.useDispatch)(store3)
    );
    const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data90.useDispatch)(store3);
    const focusOnMountRef = (0, import_compose33.useFocusOnMount)("firstElement");
    const sectionFocusReturnRef = (0, import_compose33.useFocusReturn)();
    let content = null;
    if (showStylebook2) {
      content = /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
        style_book_default2,
        {
          path: stylesPath2,
          onPathChange: setStylesPath2,
          ref: sectionFocusReturnRef
        }
      );
    } else if (stylesPath2?.startsWith("/revisions")) {
      content = /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
        revisions_default,
        {
          path: stylesPath2,
          ref: sectionFocusReturnRef
        }
      );
    }
    const title = getStylesCanvasTitle(stylesPath2, showStylebook2);
    const onCloseCanvas = () => {
      setIsListViewOpened2(showListViewByDefault);
      resetStylesNavigation2();
    };
    const closeOnEscape = (event) => {
      if (event.keyCode === import_keycodes8.ESCAPE && !event.defaultPrevented) {
        event.preventDefault();
        onCloseCanvas();
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime338.jsx)("div", { className: "editor-styles-canvas", children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(resizable_editor_default, { enableResizing: false, children: /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(
      "section",
      {
        className: "editor-styles-canvas__section",
        ref: focusOnMountRef,
        onKeyDown: closeOnEscape,
        "aria-label": title,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
            import_components161.Button,
            {
              size: "compact",
              className: "editor-styles-canvas__close-button",
              icon: close_small_default,
              label: (0, import_i18n191.__)("Close"),
              onClick: onCloseCanvas
            }
          ),
          content
        ]
      }
    ) }) });
  }

  // packages/editor/build-module/components/document-bar/useEditedSectionDetails.mjs
  var import_data91 = __toESM(require_data(), 1);
  var import_html_entities12 = __toESM(require_html_entities(), 1);
  var import_block_editor41 = __toESM(require_block_editor(), 1);
  var import_core_data61 = __toESM(require_core_data(), 1);
  function useEditedSectionDetails() {
    return (0, import_data91.useSelect)((select7) => {
      const {
        getBlockAttributes: getBlockAttributes2,
        getBlockName: getBlockName2,
        __experimentalGetParsedPattern
      } = select7(import_block_editor41.store);
      const { getEditedEntityRecord, getCurrentTheme } = select7(import_core_data61.store);
      const { getEditedContentOnlySection } = unlock(
        select7(import_block_editor41.store)
      );
      const editedSectionId = getEditedContentOnlySection();
      if (!editedSectionId) {
        return null;
      }
      const attributes = getBlockAttributes2(editedSectionId);
      const patternName = attributes?.metadata?.patternName;
      if (patternName) {
        const pattern = typeof __experimentalGetParsedPattern === "function" ? __experimentalGetParsedPattern(patternName) : null;
        return {
          patternName,
          patternTitle: pattern?.title || attributes?.metadata?.name,
          type: "pattern"
        };
      }
      const blockName = getBlockName2(editedSectionId);
      if (blockName === "core/block" && !!attributes?.ref) {
        const entity = getEditedEntityRecord(
          "postType",
          "wp_block",
          attributes.ref
        );
        if (entity?.title) {
          return {
            patternName: attributes.ref,
            patternTitle: (0, import_html_entities12.decodeEntities)(entity.title),
            type: "synced-pattern"
          };
        }
      }
      if (blockName === "core/template-part" && !!attributes?.slug) {
        const theme = attributes.theme || getCurrentTheme()?.stylesheet;
        const templatePartId = theme ? `${theme}//${attributes.slug}` : null;
        if (templatePartId) {
          const entity = getEditedEntityRecord(
            "postType",
            "wp_template_part",
            templatePartId
          );
          if (entity?.title) {
            return {
              patternName: attributes.slug,
              patternTitle: (0, import_html_entities12.decodeEntities)(entity.title),
              type: "template-part"
            };
          }
        }
      }
      return null;
    }, []);
  }

  // packages/editor/build-module/components/document-bar/index.mjs
  var import_jsx_runtime339 = __toESM(require_jsx_runtime(), 1);
  var MotionButton = import_components162.__unstableMotion.create(import_components162.Button);
  function DocumentBar(props) {
    const { stopEditingContentOnlySection } = unlock(
      (0, import_data92.useDispatch)(import_block_editor42.store)
    );
    const unlockedPatternInfo = useEditedSectionDetails();
    const {
      postId: postId2,
      postType: postType2,
      postTypeLabel,
      documentTitle,
      isNotFound,
      templateTitle,
      onNavigateToPreviousEntityRecord,
      isTemplatePreview,
      stylesCanvasTitle
    } = (0, import_data92.useSelect)((select7) => {
      const {
        getCurrentPostType: getCurrentPostType2,
        getCurrentPostId: getCurrentPostId2,
        getEditorSettings: getEditorSettings2,
        getRenderingMode: getRenderingMode2
      } = select7(store3);
      const {
        getEditedEntityRecord,
        getPostType,
        getCurrentTheme,
        isResolving: isResolvingSelector
      } = select7(import_core_data62.store);
      const _postType = getCurrentPostType2();
      const _postId = getCurrentPostId2();
      const _document = getEditedEntityRecord(
        "postType",
        _postType,
        _postId
      );
      const { default_template_types: templateTypes = [] } = getCurrentTheme() ?? {};
      const _templateInfo = getTemplateInfo({
        templateTypes,
        template: _document
      });
      const _postTypeLabel = getPostType(_postType)?.labels?.singular_name;
      const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock(
        select7(store3)
      );
      const _stylesPath = getStylesPath2();
      const _showStylebook = getShowStylebook2();
      const _stylesCanvasTitle = getStylesCanvasTitle(
        _stylesPath,
        _showStylebook
      );
      return {
        postId: _postId,
        postType: _postType,
        postTypeLabel: _postTypeLabel,
        documentTitle: _document.title,
        isNotFound: !_document && !isResolvingSelector(
          "getEditedEntityRecord",
          "postType",
          _postType,
          _postId
        ),
        templateTitle: _templateInfo.title,
        onNavigateToPreviousEntityRecord: getEditorSettings2().onNavigateToPreviousEntityRecord,
        isTemplatePreview: getRenderingMode2() === "template-locked",
        stylesCanvasTitle: _stylesCanvasTitle
      };
    }, []);
    const { open: openCommandCenter } = (0, import_data92.useDispatch)(import_commands3.store);
    const isReducedMotion = (0, import_compose34.useReducedMotion)();
    const isTemplate2 = TEMPLATE_POST_TYPES.includes(postType2);
    const hasBackButton = !!onNavigateToPreviousEntityRecord || !!unlockedPatternInfo;
    const entityTitle = isTemplate2 ? templateTitle : documentTitle;
    const title = unlockedPatternInfo?.patternTitle || props.title || stylesCanvasTitle || entityTitle;
    const icon = props.icon;
    const handleBackClick = (event) => {
      event.stopPropagation();
      if (unlockedPatternInfo) {
        stopEditingContentOnlySection();
      } else if (onNavigateToPreviousEntityRecord) {
        onNavigateToPreviousEntityRecord();
      }
    };
    const pageTypeBadge = usePageTypeBadge(postId2);
    const mountedRef = (0, import_element188.useRef)(false);
    (0, import_element188.useEffect)(() => {
      mountedRef.current = true;
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(
      "div",
      {
        className: clsx_default("editor-document-bar", {
          "has-back-button": hasBackButton
        }),
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(import_components162.__unstableAnimatePresence, { children: hasBackButton && /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
            MotionButton,
            {
              className: "editor-document-bar__back",
              icon: (0, import_i18n192.isRTL)() ? chevron_right_small_default : chevron_left_small_default,
              onClick: handleBackClick,
              size: "compact",
              initial: mountedRef.current ? { opacity: 0, transform: "translateX(15%)" } : false,
              animate: { opacity: 1, transform: "translateX(0%)" },
              exit: { opacity: 0, transform: "translateX(15%)" },
              transition: isReducedMotion ? { duration: 0 } : void 0,
              children: (0, import_i18n192.__)("Back")
            }
          ) }),
          !isTemplate2 && isTemplatePreview && !hasBackButton && /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
            import_block_editor42.BlockIcon,
            {
              icon: layout_default,
              className: "editor-document-bar__icon-layout"
            }
          ),
          isNotFound ? /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(import_components162.__experimentalText, { children: (0, import_i18n192.__)("Document not found") }) : /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(
            import_components162.Button,
            {
              className: "editor-document-bar__command",
              onClick: () => openCommandCenter(),
              size: "compact",
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(
                  import_components162.__unstableMotion.div,
                  {
                    className: "editor-document-bar__title",
                    initial: mountedRef.current ? {
                      opacity: 0,
                      transform: hasBackButton ? "translateX(15%)" : "translateX(-15%)"
                    } : false,
                    animate: {
                      opacity: 1,
                      transform: "translateX(0%)"
                    },
                    transition: isReducedMotion ? { duration: 0 } : void 0,
                    children: [
                      icon && /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(import_block_editor42.BlockIcon, { icon }),
                      /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(import_components162.__experimentalText, { size: "body", as: "h1", children: [
                        /* @__PURE__ */ (0, import_jsx_runtime339.jsx)("span", { className: "editor-document-bar__post-title", children: title ? (0, import_dom11.__unstableStripHTML)(title) : (0, import_i18n192.__)("No title") }),
                        unlockedPatternInfo && /* @__PURE__ */ (0, import_jsx_runtime339.jsx)("span", { className: "editor-document-bar__post-type-label", children: unlockedPatternInfo.type === "template-part" ? `\xB7 ${(0, import_i18n192.__)("Template Part")}` : `\xB7 ${(0, import_i18n192.__)("Pattern")}` }),
                        !unlockedPatternInfo && pageTypeBadge && /* @__PURE__ */ (0, import_jsx_runtime339.jsx)("span", { className: "editor-document-bar__post-type-label", children: `\xB7 ${pageTypeBadge}` }),
                        !unlockedPatternInfo && postTypeLabel && !props.title && !pageTypeBadge && /* @__PURE__ */ (0, import_jsx_runtime339.jsx)("span", { className: "editor-document-bar__post-type-label", children: `\xB7 ${(0, import_html_entities13.decodeEntities)(
                          postTypeLabel
                        )}` })
                      ] })
                    ]
                  },
                  hasBackButton
                ),
                /* @__PURE__ */ (0, import_jsx_runtime339.jsx)("span", { className: "editor-document-bar__shortcut", children: import_keycodes9.displayShortcut.primary("k") })
              ]
            }
          )
        ]
      }
    );
  }

  // packages/editor/build-module/components/document-outline/index.mjs
  var import_i18n193 = __toESM(require_i18n(), 1);
  var import_data93 = __toESM(require_data(), 1);
  var import_element189 = __toESM(require_element(), 1);
  var import_rich_text2 = __toESM(require_rich_text(), 1);
  var import_block_editor43 = __toESM(require_block_editor(), 1);
  var import_core_data63 = __toESM(require_core_data(), 1);
  var import_components163 = __toESM(require_components(), 1);

  // packages/editor/build-module/components/document-outline/item.mjs
  var import_jsx_runtime340 = __toESM(require_jsx_runtime(), 1);
  var TableOfContentsItem = ({
    children,
    isValid: isValid2,
    isDisabled,
    level,
    href,
    onSelect
  }) => {
    function handleClick(event) {
      if (isDisabled) {
        event.preventDefault();
        return;
      }
      onSelect();
    }
    return /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(
      "li",
      {
        className: clsx_default(
          "document-outline__item",
          `is-${level.toLowerCase()}`,
          {
            "is-invalid": !isValid2,
            "is-disabled": isDisabled
          }
        ),
        children: /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)(
          "a",
          {
            href,
            className: "document-outline__button",
            "aria-disabled": isDisabled,
            onClick: handleClick,
            children: [
              /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(
                "span",
                {
                  className: "document-outline__emdash",
                  "aria-hidden": "true"
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime340.jsx)("strong", { className: "document-outline__level", children: level }),
              /* @__PURE__ */ (0, import_jsx_runtime340.jsx)("span", { className: "document-outline__item-content", children })
            ]
          }
        )
      }
    );
  };
  var item_default = TableOfContentsItem;

  // packages/editor/build-module/components/document-outline/index.mjs
  var import_jsx_runtime341 = __toESM(require_jsx_runtime(), 1);
  var emptyHeadingContent = /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("em", { children: (0, import_i18n193.__)("(Empty heading)") });
  var incorrectLevelContent = [
    /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("br", {}, "incorrect-break"),
    /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("em", { children: (0, import_i18n193.__)("(Incorrect heading level)") }, "incorrect-message")
  ];
  var singleH1Headings = [
    /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("br", {}, "incorrect-break-h1"),
    /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("em", { children: (0, import_i18n193.__)("(Your theme may already use a H1 for the post title)") }, "incorrect-message-h1")
  ];
  var multipleH1Headings = [
    /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("br", {}, "incorrect-break-multiple-h1"),
    /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("em", { children: (0, import_i18n193.__)("(Multiple H1 headings are not recommended)") }, "incorrect-message-multiple-h1")
  ];
  function EmptyOutlineIllustration() {
    return /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(
      import_components163.SVG,
      {
        width: "138",
        height: "148",
        viewBox: "0 0 138 148",
        fill: "none",
        xmlns: "http://www.w3.org/2000/svg",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_components163.Rect, { width: "138", height: "148", rx: "4", fill: "#F0F6FC" }),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_components163.Line, { x1: "44", y1: "28", x2: "24", y2: "28", stroke: "#DDDDDD" }),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_components163.Rect, { x: "48", y: "16", width: "27", height: "23", rx: "4", fill: "#DDDDDD" }),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
            import_components163.Path,
            {
              d: "M54.7585 32V23.2727H56.6037V26.8736H60.3494V23.2727H62.1903V32H60.3494V28.3949H56.6037V32H54.7585ZM67.4574 23.2727V32H65.6122V25.0241H65.5611L63.5625 26.277V24.6406L65.723 23.2727H67.4574Z",
              fill: "black"
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_components163.Line, { x1: "55", y1: "59", x2: "24", y2: "59", stroke: "#DDDDDD" }),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_components163.Rect, { x: "59", y: "47", width: "29", height: "23", rx: "4", fill: "#DDDDDD" }),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
            import_components163.Path,
            {
              d: "M65.7585 63V54.2727H67.6037V57.8736H71.3494V54.2727H73.1903V63H71.3494V59.3949H67.6037V63H65.7585ZM74.6605 63V61.6705L77.767 58.794C78.0313 58.5384 78.2528 58.3082 78.4318 58.1037C78.6136 57.8991 78.7514 57.6989 78.8452 57.5028C78.9389 57.304 78.9858 57.0895 78.9858 56.8594C78.9858 56.6037 78.9276 56.3835 78.8111 56.1989C78.6946 56.0114 78.5355 55.8679 78.3338 55.7685C78.1321 55.6662 77.9034 55.6151 77.6477 55.6151C77.3807 55.6151 77.1477 55.669 76.9489 55.777C76.75 55.8849 76.5966 56.0398 76.4886 56.2415C76.3807 56.4432 76.3267 56.6832 76.3267 56.9616H74.5753C74.5753 56.3906 74.7045 55.8949 74.9631 55.4744C75.2216 55.054 75.5838 54.7287 76.0497 54.4986C76.5156 54.2685 77.0526 54.1534 77.6605 54.1534C78.2855 54.1534 78.8295 54.2642 79.2926 54.4858C79.7585 54.7045 80.1207 55.0085 80.3793 55.3977C80.6378 55.7869 80.767 56.233 80.767 56.7358C80.767 57.0653 80.7017 57.3906 80.571 57.7116C80.4432 58.0327 80.2145 58.3892 79.8849 58.7812C79.5554 59.1705 79.0909 59.6378 78.4915 60.1832L77.2173 61.4318V61.4915H80.8821V63H74.6605Z",
              fill: "black"
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_components163.Line, { x1: "80", y1: "90", x2: "24", y2: "90", stroke: "#DDDDDD" }),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_components163.Rect, { x: "84", y: "78", width: "30", height: "23", rx: "4", fill: "#F0B849" }),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
            import_components163.Path,
            {
              d: "M90.7585 94V85.2727H92.6037V88.8736H96.3494V85.2727H98.1903V94H96.3494V90.3949H92.6037V94H90.7585ZM99.5284 92.4659V91.0128L103.172 85.2727H104.425V87.2841H103.683L101.386 90.919V90.9872H106.564V92.4659H99.5284ZM103.717 94V92.0227L103.751 91.3793V85.2727H105.482V94H103.717Z",
              fill: "black"
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_components163.Line, { x1: "66", y1: "121", x2: "24", y2: "121", stroke: "#DDDDDD" }),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_components163.Rect, { x: "70", y: "109", width: "29", height: "23", rx: "4", fill: "#DDDDDD" }),
          /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
            import_components163.Path,
            {
              d: "M76.7585 125V116.273H78.6037V119.874H82.3494V116.273H84.1903V125H82.3494V121.395H78.6037V125H76.7585ZM88.8864 125.119C88.25 125.119 87.6832 125.01 87.1861 124.791C86.6918 124.57 86.3011 124.266 86.0142 123.879C85.7301 123.49 85.5838 123.041 85.5753 122.533H87.4332C87.4446 122.746 87.5142 122.933 87.642 123.095C87.7727 123.254 87.946 123.378 88.1619 123.466C88.3778 123.554 88.6207 123.598 88.8906 123.598C89.1719 123.598 89.4205 123.548 89.6364 123.449C89.8523 123.349 90.0213 123.212 90.1435 123.036C90.2656 122.859 90.3267 122.656 90.3267 122.426C90.3267 122.193 90.2614 121.987 90.1307 121.808C90.0028 121.626 89.8182 121.484 89.5767 121.382C89.3381 121.28 89.054 121.229 88.7244 121.229H87.9105V119.874H88.7244C89.0028 119.874 89.2486 119.825 89.4616 119.729C89.6776 119.632 89.8452 119.499 89.9645 119.328C90.0838 119.155 90.1435 118.953 90.1435 118.723C90.1435 118.504 90.0909 118.312 89.9858 118.148C89.8835 117.98 89.7386 117.849 89.5511 117.756C89.3665 117.662 89.1506 117.615 88.9034 117.615C88.6534 117.615 88.4247 117.661 88.2173 117.751C88.0099 117.839 87.8438 117.966 87.7188 118.131C87.5938 118.295 87.527 118.489 87.5185 118.71H85.75C85.7585 118.207 85.902 117.764 86.1804 117.381C86.4588 116.997 86.8338 116.697 87.3054 116.482C87.7798 116.263 88.3153 116.153 88.9119 116.153C89.5142 116.153 90.0412 116.263 90.4929 116.482C90.9446 116.7 91.2955 116.996 91.5455 117.368C91.7983 117.737 91.9233 118.152 91.9205 118.612C91.9233 119.101 91.7713 119.509 91.4645 119.835C91.1605 120.162 90.7642 120.369 90.2756 120.457V120.526C90.9176 120.608 91.4063 120.831 91.7415 121.195C92.0795 121.555 92.2472 122.007 92.2443 122.55C92.2472 123.047 92.1037 123.489 91.8139 123.875C91.527 124.261 91.1307 124.565 90.625 124.787C90.1193 125.009 89.5398 125.119 88.8864 125.119Z",
              fill: "black"
            }
          )
        ]
      }
    );
  }
  var computeOutlineHeadings = (blocks = []) => {
    return blocks.filter((block) => block.name === "core/heading").map((block) => ({
      ...block,
      level: block.attributes.level,
      isEmpty: isEmptyHeading(block)
    }));
  };
  var isEmptyHeading = (heading) => !heading.attributes.content || heading.attributes.content.trim().length === 0;
  function DocumentOutline({
    onSelect,
    hasOutlineItemsDisabled
  }) {
    const { selectBlock: selectBlock2 } = (0, import_data93.useDispatch)(import_block_editor43.store);
    const { title, isTitleSupported } = (0, import_data93.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
      const { getPostType } = select7(import_core_data63.store);
      const postType2 = getPostType(getEditedPostAttribute2("type"));
      return {
        title: getEditedPostAttribute2("title"),
        isTitleSupported: postType2?.supports?.title ?? false
      };
    });
    const blocks = (0, import_data93.useSelect)((select7) => {
      const { getClientIdsWithDescendants: getClientIdsWithDescendants2, getBlock: getBlock2 } = select7(import_block_editor43.store);
      const clientIds = getClientIdsWithDescendants2();
      return clientIds.map((id) => getBlock2(id));
    });
    const contentBlocks = (0, import_data93.useSelect)((select7) => {
      if (select7(store3).getRenderingMode() === "post-only") {
        return void 0;
      }
      const { getBlocksByName, getClientIdsOfDescendants: getClientIdsOfDescendants2 } = select7(import_block_editor43.store);
      const [postContentClientId] = getBlocksByName("core/post-content");
      if (!postContentClientId) {
        return void 0;
      }
      return getClientIdsOfDescendants2(postContentClientId);
    }, []);
    const prevHeadingLevelRef = (0, import_element189.useRef)(1);
    const headings = (0, import_element189.useMemo)(
      () => computeOutlineHeadings(blocks),
      [blocks]
    );
    if (headings.length < 1) {
      return /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)("div", { className: "editor-document-outline has-no-headings", children: [
        /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(EmptyOutlineIllustration, {}),
        /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("p", { children: (0, import_i18n193.__)(
          "Navigate the structure of your document and address issues like empty or incorrect heading levels."
        ) })
      ] });
    }
    const titleNode = document.querySelector(".editor-post-title__input");
    const hasTitle = isTitleSupported && title && titleNode;
    const countByLevel = headings.reduce(
      (acc, heading) => ({
        ...acc,
        [heading.level]: (acc[heading.level] || 0) + 1
      }),
      {}
    );
    const hasMultipleH1 = countByLevel[1] > 1;
    function isContentBlock(clientId) {
      return Array.isArray(contentBlocks) ? contentBlocks.includes(clientId) : true;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("div", { className: "document-outline", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)("ul", { children: [
      hasTitle && /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
        item_default,
        {
          level: (0, import_i18n193.__)("Title"),
          isValid: true,
          onSelect,
          href: `#${titleNode.id}`,
          isDisabled: hasOutlineItemsDisabled,
          children: title
        }
      ),
      headings.map((item) => {
        const isIncorrectLevel = item.level > prevHeadingLevelRef.current + 1;
        const isValid2 = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle);
        prevHeadingLevelRef.current = item.level;
        return /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(
          item_default,
          {
            level: `H${item.level}`,
            isValid: isValid2,
            isDisabled: hasOutlineItemsDisabled || !isContentBlock(item.clientId),
            href: `#block-${item.clientId}`,
            onSelect: () => {
              selectBlock2(item.clientId);
              onSelect?.();
            },
            children: [
              item.isEmpty ? emptyHeadingContent : (0, import_rich_text2.getTextContent)(
                (0, import_rich_text2.create)({
                  html: item.attributes.content
                })
              ),
              isIncorrectLevel && incorrectLevelContent,
              item.level === 1 && hasMultipleH1 && multipleH1Headings,
              hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings
            ]
          },
          item.clientId
        );
      })
    ] }) });
  }

  // packages/editor/build-module/components/document-outline/check.mjs
  var import_data94 = __toESM(require_data(), 1);
  var import_block_editor44 = __toESM(require_block_editor(), 1);
  function DocumentOutlineCheck({ children }) {
    const hasHeadings = (0, import_data94.useSelect)((select7) => {
      const { getGlobalBlockCount: getGlobalBlockCount2 } = select7(import_block_editor44.store);
      return getGlobalBlockCount2("core/heading") > 0;
    });
    if (!hasHeadings) {
      return null;
    }
    return children;
  }

  // packages/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.mjs
  var import_element190 = __toESM(require_element(), 1);
  var import_data95 = __toESM(require_data(), 1);
  var import_i18n194 = __toESM(require_i18n(), 1);
  var import_block_editor45 = __toESM(require_block_editor(), 1);
  var import_keyboard_shortcuts4 = __toESM(require_keyboard_shortcuts(), 1);
  var import_keycodes10 = __toESM(require_keycodes(), 1);
  var import_jsx_runtime342 = __toESM(require_jsx_runtime(), 1);
  function EditorKeyboardShortcutsRegister() {
    const { registerShortcut } = (0, import_data95.useDispatch)(import_keyboard_shortcuts4.store);
    (0, import_element190.useEffect)(() => {
      registerShortcut({
        name: "core/editor/toggle-mode",
        category: "global",
        description: (0, import_i18n194.__)("Switch between visual editor and code editor."),
        keyCombination: {
          modifier: "secondary",
          character: "m"
        }
      });
      registerShortcut({
        name: "core/editor/save",
        category: "global",
        description: (0, import_i18n194.__)("Save your changes."),
        keyCombination: {
          modifier: "primary",
          character: "s"
        }
      });
      registerShortcut({
        name: "core/editor/undo",
        category: "global",
        description: (0, import_i18n194.__)("Undo your last changes."),
        keyCombination: {
          modifier: "primary",
          character: "z"
        }
      });
      registerShortcut({
        name: "core/editor/redo",
        category: "global",
        description: (0, import_i18n194.__)("Redo your last undo."),
        keyCombination: {
          modifier: "primaryShift",
          character: "z"
        },
        // Disable on Apple OS because it conflicts with the browser's
        // history shortcut. It's a fine alias for both Windows and Linux.
        // Since there's no conflict for Ctrl+Shift+Z on both Windows and
        // Linux, we keep it as the default for consistency.
        aliases: (0, import_keycodes10.isAppleOS)() ? [] : [
          {
            modifier: "primary",
            character: "y"
          }
        ]
      });
      registerShortcut({
        name: "core/editor/toggle-list-view",
        category: "global",
        description: (0, import_i18n194.__)("Show or hide the List View."),
        keyCombination: {
          modifier: "access",
          character: "o"
        }
      });
      registerShortcut({
        name: "core/editor/toggle-distraction-free",
        category: "global",
        description: (0, import_i18n194.__)("Enter or exit distraction free mode."),
        keyCombination: {
          modifier: "primaryShift",
          character: "\\"
        }
      });
      registerShortcut({
        name: "core/editor/toggle-sidebar",
        category: "global",
        description: (0, import_i18n194.__)("Show or hide the Settings panel."),
        keyCombination: {
          modifier: "primaryShift",
          character: ","
        }
      });
      registerShortcut({
        name: "core/editor/keyboard-shortcuts",
        category: "main",
        description: (0, import_i18n194.__)("Display these keyboard shortcuts."),
        keyCombination: {
          modifier: "access",
          character: "h"
        }
      });
      registerShortcut({
        name: "core/editor/new-note",
        category: "block",
        description: (0, import_i18n194.__)("Add a new note."),
        keyCombination: {
          modifier: "primaryAlt",
          character: "m"
        }
      });
      registerShortcut({
        name: "core/editor/next-region",
        category: "global",
        description: (0, import_i18n194.__)("Navigate to the next part of the editor."),
        keyCombination: {
          modifier: "ctrl",
          character: "`"
        },
        aliases: [
          {
            modifier: "access",
            character: "n"
          }
        ]
      });
      registerShortcut({
        name: "core/editor/previous-region",
        category: "global",
        description: (0, import_i18n194.__)("Navigate to the previous part of the editor."),
        keyCombination: {
          modifier: "ctrlShift",
          character: "`"
        },
        aliases: [
          {
            modifier: "access",
            character: "p"
          },
          {
            modifier: "ctrlShift",
            character: "~"
          }
        ]
      });
    }, [registerShortcut]);
    return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(import_block_editor45.BlockEditorKeyboardShortcuts.Register, {});
  }
  var register_shortcuts_default = EditorKeyboardShortcutsRegister;

  // packages/editor/build-module/components/editor-history/redo.mjs
  var import_i18n195 = __toESM(require_i18n(), 1);
  var import_components164 = __toESM(require_components(), 1);
  var import_data96 = __toESM(require_data(), 1);
  var import_keycodes11 = __toESM(require_keycodes(), 1);
  var import_element191 = __toESM(require_element(), 1);
  var import_jsx_runtime343 = __toESM(require_jsx_runtime(), 1);
  function EditorHistoryRedo(props, ref) {
    const shortcut = (0, import_keycodes11.isAppleOS)() ? import_keycodes11.displayShortcut.primaryShift("z") : import_keycodes11.displayShortcut.primary("y");
    const hasRedo = (0, import_data96.useSelect)(
      (select7) => select7(store3).hasEditorRedo(),
      []
    );
    const { redo: redo2 } = (0, import_data96.useDispatch)(store3);
    return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(
      import_components164.Button,
      {
        __next40pxDefaultSize: true,
        ...props,
        ref,
        icon: !(0, import_i18n195.isRTL)() ? redo_default : undo_default,
        label: (0, import_i18n195.__)("Redo"),
        shortcut,
        "aria-disabled": !hasRedo,
        onClick: hasRedo ? redo2 : void 0,
        className: "editor-history__redo"
      }
    );
  }
  var redo_default2 = (0, import_element191.forwardRef)(EditorHistoryRedo);

  // packages/editor/build-module/components/editor-history/undo.mjs
  var import_i18n196 = __toESM(require_i18n(), 1);
  var import_components165 = __toESM(require_components(), 1);
  var import_data97 = __toESM(require_data(), 1);
  var import_keycodes12 = __toESM(require_keycodes(), 1);
  var import_element192 = __toESM(require_element(), 1);
  var import_jsx_runtime344 = __toESM(require_jsx_runtime(), 1);
  function EditorHistoryUndo(props, ref) {
    const hasUndo = (0, import_data97.useSelect)(
      (select7) => select7(store3).hasEditorUndo(),
      []
    );
    const { undo: undo2 } = (0, import_data97.useDispatch)(store3);
    return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
      import_components165.Button,
      {
        __next40pxDefaultSize: true,
        ...props,
        ref,
        icon: !(0, import_i18n196.isRTL)() ? undo_default : redo_default,
        label: (0, import_i18n196.__)("Undo"),
        shortcut: import_keycodes12.displayShortcut.primary("z"),
        "aria-disabled": !hasUndo,
        onClick: hasUndo ? undo2 : void 0,
        className: "editor-history__undo"
      }
    );
  }
  var undo_default2 = (0, import_element192.forwardRef)(EditorHistoryUndo);

  // packages/editor/build-module/components/editor-notices/index.mjs
  var import_deprecated9 = __toESM(require_deprecated(), 1);
  var import_notices19 = __toESM(require_notices(), 1);

  // packages/editor/build-module/components/template-validation-notice/index.mjs
  var import_components166 = __toESM(require_components(), 1);
  var import_i18n197 = __toESM(require_i18n(), 1);
  var import_data98 = __toESM(require_data(), 1);
  var import_element193 = __toESM(require_element(), 1);
  var import_block_editor46 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime345 = __toESM(require_jsx_runtime(), 1);
  function TemplateValidationNotice() {
    const [showConfirmDialog, setShowConfirmDialog] = (0, import_element193.useState)(false);
    const isValid2 = (0, import_data98.useSelect)((select7) => {
      return select7(import_block_editor46.store).isValidTemplate();
    }, []);
    const { setTemplateValidity: setTemplateValidity2, synchronizeTemplate: synchronizeTemplate2 } = (0, import_data98.useDispatch)(import_block_editor46.store);
    if (isValid2) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime345.jsxs)(import_jsx_runtime345.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
        import_components166.Notice,
        {
          className: "editor-template-validation-notice",
          isDismissible: false,
          status: "warning",
          actions: [
            {
              label: (0, import_i18n197.__)("Keep it as is"),
              onClick: () => setTemplateValidity2(true)
            },
            {
              label: (0, import_i18n197.__)("Reset the template"),
              onClick: () => setShowConfirmDialog(true)
            }
          ],
          children: (0, import_i18n197.__)(
            "The content of your post doesn\u2019t match the template assigned to your post type."
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
        import_components166.__experimentalConfirmDialog,
        {
          isOpen: showConfirmDialog,
          confirmButtonText: (0, import_i18n197.__)("Reset"),
          onConfirm: () => {
            setShowConfirmDialog(false);
            synchronizeTemplate2();
          },
          onCancel: () => setShowConfirmDialog(false),
          size: "medium",
          children: (0, import_i18n197.__)(
            "Resetting the template may result in loss of content, do you want to continue?"
          )
        }
      )
    ] });
  }

  // packages/editor/build-module/components/editor-notices/index.mjs
  var import_jsx_runtime346 = __toESM(require_jsx_runtime(), 1);
  function EditorNotices() {
    (0, import_deprecated9.default)("wp.editor.EditorNotices", {
      since: "7.0",
      version: "7.2",
      alternative: "wp.notices.InlineNotices"
    });
    return /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(
      import_notices19.InlineNotices,
      {
        pinnedNoticesClassName: "components-editor-notices__pinned",
        dismissibleNoticesClassName: "components-editor-notices__dismissible",
        children: /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(TemplateValidationNotice, {})
      }
    );
  }
  var editor_notices_default = EditorNotices;

  // packages/editor/build-module/components/editor-snackbars/index.mjs
  var import_deprecated10 = __toESM(require_deprecated(), 1);
  var import_notices20 = __toESM(require_notices(), 1);
  var import_jsx_runtime347 = __toESM(require_jsx_runtime(), 1);
  function EditorSnackbars() {
    (0, import_deprecated10.default)("wp.editor.EditorSnackbars", {
      since: "7.0",
      version: "7.2",
      alternative: "wp.notices.SnackbarNotices"
    });
    return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(import_notices20.SnackbarNotices, { className: "components-editor-notices__snackbar" });
  }

  // packages/editor/build-module/components/entities-saved-states/index.mjs
  var import_components169 = __toESM(require_components(), 1);
  var import_i18n200 = __toESM(require_i18n(), 1);
  var import_element195 = __toESM(require_element(), 1);
  var import_compose35 = __toESM(require_compose(), 1);
  var import_data102 = __toESM(require_data(), 1);

  // packages/editor/build-module/components/entities-saved-states/entity-type-list.mjs
  var import_i18n199 = __toESM(require_i18n(), 1);
  var import_data100 = __toESM(require_data(), 1);
  var import_components168 = __toESM(require_components(), 1);
  var import_core_data65 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/entities-saved-states/entity-record-item.mjs
  var import_components167 = __toESM(require_components(), 1);
  var import_i18n198 = __toESM(require_i18n(), 1);
  var import_data99 = __toESM(require_data(), 1);
  var import_core_data64 = __toESM(require_core_data(), 1);
  var import_html_entities14 = __toESM(require_html_entities(), 1);
  var import_jsx_runtime348 = __toESM(require_jsx_runtime(), 1);
  function EntityRecordItem({ record, checked, onChange }) {
    const { name: name2, kind, title, key } = record;
    const { entityRecordTitle, hasPostMetaChanges: hasPostMetaChanges2 } = (0, import_data99.useSelect)(
      (select7) => {
        if ("postType" !== kind || "wp_template" !== name2) {
          return {
            entityRecordTitle: title,
            hasPostMetaChanges: unlock(
              select7(store3)
            ).hasPostMetaChanges(name2, key)
          };
        }
        const template2 = select7(import_core_data64.store).getEditedEntityRecord(
          kind,
          name2,
          key
        );
        const { default_template_types: templateTypes = [] } = select7(import_core_data64.store).getCurrentTheme() ?? {};
        return {
          entityRecordTitle: getTemplateInfo({
            template: template2,
            templateTypes
          }).title,
          hasPostMetaChanges: unlock(
            select7(store3)
          ).hasPostMetaChanges(name2, key)
        };
      },
      [name2, kind, title, key]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime348.jsxs)(import_jsx_runtime348.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(import_components167.PanelRow, { children: /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
        import_components167.CheckboxControl,
        {
          label: (0, import_html_entities14.decodeEntities)(entityRecordTitle) || (0, import_i18n198.__)("Untitled"),
          checked,
          onChange,
          className: "entities-saved-states__change-control"
        }
      ) }),
      hasPostMetaChanges2 && /* @__PURE__ */ (0, import_jsx_runtime348.jsx)("ul", { className: "entities-saved-states__changes", children: /* @__PURE__ */ (0, import_jsx_runtime348.jsx)("li", { children: (0, import_i18n198.__)("Post Meta.") }) })
    ] });
  }

  // packages/editor/build-module/components/entities-saved-states/entity-type-list.mjs
  var import_jsx_runtime349 = __toESM(require_jsx_runtime(), 1);
  function getEntityDescription(entity, count) {
    switch (entity) {
      case "site":
        return 1 === count ? (0, import_i18n199.__)("This change will affect your whole site.") : (0, import_i18n199.__)("These changes will affect your whole site.");
      case "wp_template":
        return (0, import_i18n199.__)(
          "This change will affect other parts of your site that use this template."
        );
      case "page":
      case "post":
        return (0, import_i18n199.__)("The following has been modified.");
    }
  }
  function GlobalStylesDescription({ record }) {
    const { editedRecord, savedRecord } = (0, import_data100.useSelect)(
      (select7) => {
        const { getEditedEntityRecord, getEntityRecord } = select7(import_core_data65.store);
        return {
          editedRecord: getEditedEntityRecord(
            record.kind,
            record.name,
            record.key
          ),
          savedRecord: getEntityRecord(
            record.kind,
            record.name,
            record.key
          )
        };
      },
      [record.kind, record.name, record.key]
    );
    const globalStylesChanges = getGlobalStylesChanges(
      editedRecord,
      savedRecord,
      {
        maxResults: 10
      }
    );
    return globalStylesChanges.length ? /* @__PURE__ */ (0, import_jsx_runtime349.jsx)("ul", { className: "entities-saved-states__changes", children: globalStylesChanges.map((change) => /* @__PURE__ */ (0, import_jsx_runtime349.jsx)("li", { children: change }, change)) }) : null;
  }
  function EntityDescription({ record, count }) {
    if ("globalStyles" === record?.name) {
      return null;
    }
    const description = getEntityDescription(record?.name, count);
    return description ? /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(import_components168.PanelRow, { children: description }) : null;
  }
  function EntityTypeList({
    list,
    unselectedEntities,
    setUnselectedEntities
  }) {
    const count = list.length;
    const firstRecord = list[0];
    const entityConfig = (0, import_data100.useSelect)(
      (select7) => select7(import_core_data65.store).getEntityConfig(
        firstRecord.kind,
        firstRecord.name
      ),
      [firstRecord.kind, firstRecord.name]
    );
    let entityLabel = entityConfig.label;
    if (firstRecord?.name === "wp_template_part") {
      entityLabel = 1 === count ? (0, import_i18n199.__)("Template Part") : (0, import_i18n199.__)("Template Parts");
    }
    return /* @__PURE__ */ (0, import_jsx_runtime349.jsxs)(
      import_components168.PanelBody,
      {
        title: entityLabel,
        initialOpen: true,
        className: "entities-saved-states__panel-body",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(EntityDescription, { record: firstRecord, count }),
          list.map((record) => {
            return /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(
              EntityRecordItem,
              {
                record,
                checked: !unselectedEntities.some(
                  (elt) => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property
                ),
                onChange: (value) => setUnselectedEntities(record, value)
              },
              record.key || record.property
            );
          }),
          "globalStyles" === firstRecord?.name && /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(GlobalStylesDescription, { record: firstRecord })
        ]
      }
    );
  }

  // packages/editor/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs
  var import_data101 = __toESM(require_data(), 1);
  var import_core_data66 = __toESM(require_core_data(), 1);
  var import_element194 = __toESM(require_element(), 1);
  var useIsDirty = () => {
    const { editedEntities, siteEdits, siteEntityConfig } = (0, import_data101.useSelect)(
      (select7) => {
        const {
          __experimentalGetDirtyEntityRecords,
          getEntityRecordEdits,
          getEntityConfig
        } = select7(import_core_data66.store);
        return {
          editedEntities: __experimentalGetDirtyEntityRecords(),
          siteEdits: getEntityRecordEdits("root", "site"),
          siteEntityConfig: getEntityConfig("root", "site")
        };
      },
      []
    );
    const dirtyEntityRecords = (0, import_element194.useMemo)(() => {
      const editedEntitiesWithoutSite = editedEntities.filter(
        (record) => !(record.kind === "root" && record.name === "site")
      );
      const siteEntityLabels = siteEntityConfig?.meta?.labels ?? {};
      const {
        site_logo: siteLogoEdit,
        site_icon: siteIconEdit,
        ...otherSiteEdits
      } = siteEdits ?? {};
      const orderedSiteProperties = [
        siteLogoEdit !== void 0 && "site_logo",
        siteIconEdit !== void 0 && "site_icon",
        ...Object.keys(otherSiteEdits)
      ].filter(Boolean);
      const editedSiteEntities = orderedSiteProperties.map(
        (property) => ({
          kind: "root",
          name: "site",
          title: siteEntityLabels[property] || property,
          property
        })
      );
      return [...editedEntitiesWithoutSite, ...editedSiteEntities];
    }, [editedEntities, siteEdits, siteEntityConfig]);
    const [unselectedEntities, _setUnselectedEntities] = (0, import_element194.useState)([]);
    const setUnselectedEntities = ({ kind, name: name2, key, property }, checked) => {
      if (checked) {
        _setUnselectedEntities(
          unselectedEntities.filter(
            (elt) => elt.kind !== kind || elt.name !== name2 || elt.key !== key || elt.property !== property
          )
        );
      } else {
        _setUnselectedEntities([
          ...unselectedEntities,
          { kind, name: name2, key, property }
        ]);
      }
    };
    const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
    return {
      dirtyEntityRecords,
      isDirty,
      setUnselectedEntities,
      unselectedEntities
    };
  };

  // packages/editor/build-module/components/entities-saved-states/index.mjs
  var import_jsx_runtime350 = __toESM(require_jsx_runtime(), 1);
  function identity3(values) {
    return values;
  }
  function EntitiesSavedStates({
    close,
    renderDialog,
    variant
  }) {
    const isDirtyProps = useIsDirty();
    return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
      EntitiesSavedStatesExtensible,
      {
        close,
        renderDialog,
        variant,
        ...isDirtyProps
      }
    );
  }
  function EntitiesSavedStatesExtensible({
    additionalPrompt = void 0,
    close,
    onSave = identity3,
    saveEnabled: saveEnabledProp = void 0,
    saveLabel = (0, import_i18n200.__)("Save"),
    renderDialog,
    dirtyEntityRecords,
    isDirty,
    setUnselectedEntities,
    unselectedEntities,
    variant = "default",
    successNoticeContent
  }) {
    const saveButtonRef = (0, import_element195.useRef)();
    const { saveDirtyEntities: saveDirtyEntities2 } = unlock((0, import_data102.useDispatch)(store3));
    const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
      const { name: name2 } = record;
      if (!acc[name2]) {
        acc[name2] = [];
      }
      acc[name2].push(record);
      return acc;
    }, {});
    const {
      site: siteSavables,
      wp_template: templateSavables,
      wp_template_part: templatePartSavables,
      ...contentSavables
    } = partitionedSavables;
    const sortedPartitionedSavables = [
      siteSavables,
      templateSavables,
      templatePartSavables,
      ...Object.values(contentSavables)
    ].filter(Array.isArray);
    const saveEnabled = saveEnabledProp ?? isDirty;
    const dismissPanel = (0, import_element195.useCallback)(() => close(), [close]);
    const [saveDialogRef, saveDialogProps] = (0, import_compose35.__experimentalUseDialog)({
      onClose: () => dismissPanel()
    });
    const dialogLabelId = (0, import_compose35.useInstanceId)(
      EntitiesSavedStatesExtensible,
      "entities-saved-states__panel-label"
    );
    const dialogDescriptionId = (0, import_compose35.useInstanceId)(
      EntitiesSavedStatesExtensible,
      "entities-saved-states__panel-description"
    );
    const selectItemsToSaveDescription = !!dirtyEntityRecords.length ? (0, import_i18n200.__)("Select the items you want to save.") : void 0;
    const isInline = variant === "inline";
    const actionButtons = /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(import_jsx_runtime350.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
        import_components169.FlexItem,
        {
          isBlock: isInline ? false : true,
          as: import_components169.Button,
          variant: isInline ? "tertiary" : "secondary",
          size: isInline ? void 0 : "compact",
          onClick: dismissPanel,
          children: (0, import_i18n200.__)("Cancel")
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
        import_components169.FlexItem,
        {
          isBlock: isInline ? false : true,
          as: import_components169.Button,
          ref: saveButtonRef,
          variant: "primary",
          size: isInline ? void 0 : "compact",
          disabled: !saveEnabled,
          accessibleWhenDisabled: true,
          onClick: () => saveDirtyEntities2({
            onSave,
            dirtyEntityRecords,
            entitiesToSkip: unselectedEntities,
            close,
            successNoticeContent
          }),
          className: "editor-entities-saved-states__save-button",
          children: saveLabel
        }
      )
    ] });
    return /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(
      "div",
      {
        ref: renderDialog ? saveDialogRef : void 0,
        ...renderDialog && saveDialogProps,
        className: clsx_default("entities-saved-states__panel", {
          "is-inline": isInline
        }),
        role: renderDialog ? "dialog" : void 0,
        "aria-labelledby": renderDialog ? dialogLabelId : void 0,
        "aria-describedby": renderDialog ? dialogDescriptionId : void 0,
        children: [
          !isInline && /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(import_components169.Flex, { className: "entities-saved-states__panel-header", gap: 2, children: actionButtons }),
          /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)("div", { className: "entities-saved-states__text-prompt", children: [
            /* @__PURE__ */ (0, import_jsx_runtime350.jsx)("div", { className: "entities-saved-states__text-prompt--header-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
              "strong",
              {
                id: renderDialog ? dialogLabelId : void 0,
                className: "entities-saved-states__text-prompt--header",
                children: (0, import_i18n200.__)("Are you ready to save?")
              }
            ) }),
            /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)("div", { id: renderDialog ? dialogDescriptionId : void 0, children: [
              additionalPrompt,
              /* @__PURE__ */ (0, import_jsx_runtime350.jsx)("p", { className: "entities-saved-states__text-prompt--changes-count", children: isDirty ? (0, import_element195.createInterpolateElement)(
                (0, import_i18n200.sprintf)(
                  /* translators: %d: number of site changes waiting to be saved. */
                  (0, import_i18n200._n)(
                    "There is <strong>%d site change</strong> waiting to be saved.",
                    "There are <strong>%d site changes</strong> waiting to be saved.",
                    dirtyEntityRecords.length
                  ),
                  dirtyEntityRecords.length
                ),
                { strong: /* @__PURE__ */ (0, import_jsx_runtime350.jsx)("strong", {}) }
              ) : selectItemsToSaveDescription })
            ] })
          ] }),
          sortedPartitionedSavables.map((list) => {
            return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
              EntityTypeList,
              {
                list,
                unselectedEntities,
                setUnselectedEntities
              },
              list[0].name
            );
          }),
          isInline && /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
            import_components169.Flex,
            {
              direction: "row",
              justify: "flex-end",
              className: "entities-saved-states__panel-footer",
              children: actionButtons
            }
          )
        ]
      }
    );
  }

  // packages/editor/build-module/components/error-boundary/index.mjs
  var import_element196 = __toESM(require_element(), 1);
  var import_i18n201 = __toESM(require_i18n(), 1);
  var import_components170 = __toESM(require_components(), 1);
  var import_data103 = __toESM(require_data(), 1);
  var import_compose36 = __toESM(require_compose(), 1);
  var import_hooks41 = __toESM(require_hooks(), 1);
  var import_jsx_runtime351 = __toESM(require_jsx_runtime(), 1);
  function getContent() {
    try {
      return (0, import_data103.select)(store3).getEditedPostContent();
    } catch {
    }
  }
  function CopyButton({ text, children, variant = "secondary" }) {
    const ref = (0, import_compose36.useCopyToClipboard)(text);
    return /* @__PURE__ */ (0, import_jsx_runtime351.jsx)(import_components170.Button, { __next40pxDefaultSize: true, variant, ref, children });
  }
  var ErrorBoundary = class extends import_element196.Component {
    constructor() {
      super(...arguments);
      this.state = {
        error: null
      };
    }
    componentDidCatch(error2) {
      (0, import_hooks41.doAction)("editor.ErrorBoundary.errorLogged", error2);
    }
    static getDerivedStateFromError(error2) {
      return { error: error2 };
    }
    render() {
      const { error: error2 } = this.state;
      const { canCopyContent = false } = this.props;
      if (!error2) {
        return this.props.children;
      }
      return /* @__PURE__ */ (0, import_jsx_runtime351.jsxs)(
        import_components170.__experimentalHStack,
        {
          className: "editor-error-boundary",
          alignment: "baseline",
          spacing: 4,
          justify: "space-between",
          expanded: false,
          wrap: true,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime351.jsx)(import_components170.__experimentalText, { as: "p", children: (0, import_i18n201.__)("The editor has encountered an unexpected error.") }),
            /* @__PURE__ */ (0, import_jsx_runtime351.jsxs)(import_components170.__experimentalHStack, { expanded: false, children: [
              canCopyContent && /* @__PURE__ */ (0, import_jsx_runtime351.jsx)(CopyButton, { text: getContent, children: (0, import_i18n201.__)("Copy contents") }),
              /* @__PURE__ */ (0, import_jsx_runtime351.jsx)(CopyButton, { variant: "primary", text: error2?.stack, children: (0, import_i18n201.__)("Copy error") })
            ] })
          ]
        }
      );
    }
  };
  var error_boundary_default = ErrorBoundary;

  // packages/editor/build-module/components/local-autosave-monitor/index.mjs
  var import_element197 = __toESM(require_element(), 1);
  var import_compose37 = __toESM(require_compose(), 1);
  var import_data104 = __toESM(require_data(), 1);
  var import_i18n202 = __toESM(require_i18n(), 1);
  var import_blocks24 = __toESM(require_blocks(), 1);
  var import_notices21 = __toESM(require_notices(), 1);
  var import_jsx_runtime352 = __toESM(require_jsx_runtime(), 1);
  var requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
  var hasStorageSupport;
  var hasSessionStorageSupport = () => {
    if (hasStorageSupport !== void 0) {
      return hasStorageSupport;
    }
    try {
      window.sessionStorage.setItem("__wpEditorTestSessionStorage", "");
      window.sessionStorage.removeItem("__wpEditorTestSessionStorage");
      hasStorageSupport = true;
    } catch {
      hasStorageSupport = false;
    }
    return hasStorageSupport;
  };
  function useAutosaveNotice() {
    const { postId: postId2, isEditedPostNew: isEditedPostNew2, hasRemoteAutosave } = (0, import_data104.useSelect)(
      (select7) => ({
        postId: select7(store3).getCurrentPostId(),
        isEditedPostNew: select7(store3).isEditedPostNew(),
        hasRemoteAutosave: !!select7(store3).getEditorSettings().autosave
      }),
      []
    );
    const { getEditedPostAttribute: getEditedPostAttribute2 } = (0, import_data104.useSelect)(store3);
    const { createWarningNotice, removeNotice } = (0, import_data104.useDispatch)(import_notices21.store);
    const { editPost: editPost2, resetEditorBlocks: resetEditorBlocks2 } = (0, import_data104.useDispatch)(store3);
    (0, import_element197.useEffect)(() => {
      let localAutosave = localAutosaveGet(postId2, isEditedPostNew2);
      if (!localAutosave) {
        return;
      }
      try {
        localAutosave = JSON.parse(localAutosave);
      } catch {
        return;
      }
      const { post_title: title, content, excerpt } = localAutosave;
      const edits = { title, content, excerpt };
      {
        const hasDifference = Object.keys(edits).some((key) => {
          return edits[key] !== getEditedPostAttribute2(key);
        });
        if (!hasDifference) {
          localAutosaveClear(postId2, isEditedPostNew2);
          return;
        }
      }
      if (hasRemoteAutosave) {
        return;
      }
      const id = "wpEditorAutosaveRestore";
      createWarningNotice(
        (0, import_i18n202.__)(
          "The backup of this post in your browser is different from the version below."
        ),
        {
          id,
          actions: [
            {
              label: (0, import_i18n202.__)("Restore the backup"),
              onClick() {
                const {
                  content: editsContent,
                  ...editsWithoutContent
                } = edits;
                editPost2(editsWithoutContent);
                resetEditorBlocks2((0, import_blocks24.parse)(edits.content));
                removeNotice(id);
              }
            }
          ]
        }
      );
    }, [isEditedPostNew2, postId2]);
  }
  function useAutosavePurge() {
    const { postId: postId2, isEditedPostNew: isEditedPostNew2, isDirty, isAutosaving, didError } = (0, import_data104.useSelect)(
      (select7) => ({
        postId: select7(store3).getCurrentPostId(),
        isEditedPostNew: select7(store3).isEditedPostNew(),
        isDirty: select7(store3).isEditedPostDirty(),
        isAutosaving: select7(store3).isAutosavingPost(),
        didError: select7(store3).didPostSaveRequestFail()
      }),
      []
    );
    const lastIsDirtyRef = (0, import_element197.useRef)(isDirty);
    const lastIsAutosavingRef = (0, import_element197.useRef)(isAutosaving);
    (0, import_element197.useEffect)(() => {
      if (!didError && (lastIsAutosavingRef.current && !isAutosaving || lastIsDirtyRef.current && !isDirty)) {
        localAutosaveClear(postId2, isEditedPostNew2);
      }
      lastIsDirtyRef.current = isDirty;
      lastIsAutosavingRef.current = isAutosaving;
    }, [isDirty, isAutosaving, didError]);
    const wasEditedPostNew = (0, import_compose37.usePrevious)(isEditedPostNew2);
    const prevPostId = (0, import_compose37.usePrevious)(postId2);
    (0, import_element197.useEffect)(() => {
      if (prevPostId === postId2 && wasEditedPostNew && !isEditedPostNew2) {
        localAutosaveClear(postId2, true);
      }
    }, [isEditedPostNew2, postId2]);
  }
  function LocalAutosaveMonitor() {
    const { autosave: autosave2 } = (0, import_data104.useDispatch)(store3);
    const deferredAutosave = (0, import_element197.useCallback)(() => {
      requestIdleCallback(() => autosave2({ local: true }));
    }, []);
    useAutosaveNotice();
    useAutosavePurge();
    const localAutosaveInterval = (0, import_data104.useSelect)(
      (select7) => select7(store3).getEditorSettings().localAutosaveInterval,
      []
    );
    return /* @__PURE__ */ (0, import_jsx_runtime352.jsx)(
      autosave_monitor_default,
      {
        interval: localAutosaveInterval,
        autosave: deferredAutosave
      }
    );
  }
  var local_autosave_monitor_default = (0, import_compose37.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor);

  // packages/editor/build-module/components/page-attributes/check.mjs
  var import_data105 = __toESM(require_data(), 1);
  var import_core_data67 = __toESM(require_core_data(), 1);
  function PageAttributesCheck({ children }) {
    const supportsPageAttributes = (0, import_data105.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
      const { getPostType } = select7(import_core_data67.store);
      const postType2 = getPostType(getEditedPostAttribute2("type"));
      return !!postType2?.supports?.["page-attributes"];
    }, []);
    if (!supportsPageAttributes) {
      return null;
    }
    return children;
  }
  var check_default2 = PageAttributesCheck;

  // packages/editor/build-module/components/page-attributes/order.mjs
  var import_i18n203 = __toESM(require_i18n(), 1);
  var import_components171 = __toESM(require_components(), 1);
  var import_data107 = __toESM(require_data(), 1);
  var import_element198 = __toESM(require_element(), 1);

  // packages/editor/build-module/components/post-type-support-check/index.mjs
  var import_data106 = __toESM(require_data(), 1);
  var import_core_data68 = __toESM(require_core_data(), 1);
  function checkSupport(supports = {}, key) {
    if (supports[key] !== void 0) {
      return !!supports[key];
    }
    const [topKey, subKey] = key.split(".");
    const [subProperties] = Array.isArray(supports[topKey]) ? supports[topKey] : [];
    return Array.isArray(subProperties) ? subProperties.includes(subKey) : !!subProperties?.[subKey];
  }
  function PostTypeSupportCheck({ children, supportKeys }) {
    const postType2 = (0, import_data106.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
      const { getPostType } = select7(import_core_data68.store);
      return getPostType(getEditedPostAttribute2("type"));
    }, []);
    let isSupported = !!postType2;
    if (postType2) {
      isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some((key) => checkSupport(postType2.supports, key));
    }
    if (!isSupported) {
      return null;
    }
    return children;
  }
  var post_type_support_check_default = PostTypeSupportCheck;

  // packages/editor/build-module/components/page-attributes/order.mjs
  var import_jsx_runtime353 = __toESM(require_jsx_runtime(), 1);
  function PageAttributesOrder() {
    const order = (0, import_data107.useSelect)(
      (select7) => select7(store3).getEditedPostAttribute("menu_order") ?? 0,
      []
    );
    const { editPost: editPost2 } = (0, import_data107.useDispatch)(store3);
    const [orderInput, setOrderInput] = (0, import_element198.useState)(null);
    const setUpdatedOrder = (value2) => {
      setOrderInput(value2);
      const newOrder = Number(value2);
      if (Number.isInteger(newOrder) && value2.trim?.() !== "") {
        editPost2({ menu_order: newOrder });
      }
    };
    const value = orderInput ?? order;
    return /* @__PURE__ */ (0, import_jsx_runtime353.jsx)(import_components171.Flex, { children: /* @__PURE__ */ (0, import_jsx_runtime353.jsx)(import_components171.FlexBlock, { children: /* @__PURE__ */ (0, import_jsx_runtime353.jsx)(
      import_components171.__experimentalNumberControl,
      {
        __next40pxDefaultSize: true,
        label: (0, import_i18n203.__)("Order"),
        help: (0, import_i18n203.__)("Set the page order."),
        value,
        onChange: setUpdatedOrder,
        hideLabelFromVision: true,
        onBlur: () => {
          setOrderInput(null);
        }
      }
    ) }) });
  }
  function PageAttributesOrderWithChecks() {
    return /* @__PURE__ */ (0, import_jsx_runtime353.jsx)(post_type_support_check_default, { supportKeys: "page-attributes", children: /* @__PURE__ */ (0, import_jsx_runtime353.jsx)(PageAttributesOrder, {}) });
  }

  // packages/editor/build-module/components/page-attributes/panel.mjs
  var import_data109 = __toESM(require_data(), 1);
  var import_core_data70 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/page-attributes/parent.mjs
  var import_remove_accents3 = __toESM(require_remove_accents(), 1);
  var import_i18n204 = __toESM(require_i18n(), 1);
  var import_components173 = __toESM(require_components(), 1);
  var import_compose38 = __toESM(require_compose(), 1);
  var import_element200 = __toESM(require_element(), 1);
  var import_data108 = __toESM(require_data(), 1);
  var import_html_entities16 = __toESM(require_html_entities(), 1);
  var import_core_data69 = __toESM(require_core_data(), 1);
  var import_block_editor47 = __toESM(require_block_editor(), 1);
  var import_url15 = __toESM(require_url(), 1);

  // packages/editor/build-module/components/post-panel-row/index.mjs
  var import_components172 = __toESM(require_components(), 1);
  var import_element199 = __toESM(require_element(), 1);
  var import_jsx_runtime354 = __toESM(require_jsx_runtime(), 1);
  var PostPanelRow = (0, import_element199.forwardRef)(({ className, label, children }, ref) => {
    return /* @__PURE__ */ (0, import_jsx_runtime354.jsxs)(
      import_components172.__experimentalHStack,
      {
        className: clsx_default("editor-post-panel__row", className),
        ref,
        children: [
          label && /* @__PURE__ */ (0, import_jsx_runtime354.jsx)("div", { className: "editor-post-panel__row-label", children: label }),
          /* @__PURE__ */ (0, import_jsx_runtime354.jsx)("div", { className: "editor-post-panel__row-control", children })
        ]
      }
    );
  });
  var post_panel_row_default = PostPanelRow;

  // packages/editor/build-module/utils/terms.mjs
  var import_html_entities15 = __toESM(require_html_entities(), 1);
  function buildTermsTree2(flatTerms) {
    const flatTermsWithParentAndChildren = flatTerms.map((term) => {
      return {
        children: [],
        parent: void 0,
        ...term
      };
    });
    if (flatTermsWithParentAndChildren.some(
      ({ parent }) => parent === void 0
    )) {
      return flatTermsWithParentAndChildren;
    }
    const termsByParent = flatTermsWithParentAndChildren.reduce(
      (acc, term) => {
        const { parent } = term;
        if (!acc[parent]) {
          acc[parent] = [];
        }
        acc[parent].push(term);
        return acc;
      },
      {}
    );
    const fillWithChildren = (terms) => {
      return terms.map((term) => {
        const children = termsByParent[term.id];
        return {
          ...term,
          children: children && children.length ? fillWithChildren(children) : []
        };
      });
    };
    return fillWithChildren(termsByParent["0"] || []);
  }
  var unescapeString = (arg) => {
    return (0, import_html_entities15.decodeEntities)(arg);
  };
  var unescapeTerm = (term) => {
    return {
      ...term,
      name: unescapeString(term.name)
    };
  };
  var unescapeTerms = (terms) => {
    return (terms ?? []).map(unescapeTerm);
  };

  // packages/editor/build-module/components/page-attributes/parent.mjs
  var import_jsx_runtime355 = __toESM(require_jsx_runtime(), 1);
  function getTitle(post2) {
    return post2?.title?.rendered ? (0, import_html_entities16.decodeEntities)(post2.title.rendered) : `#${post2.id} (${(0, import_i18n204.__)("no title")})`;
  }
  var getItemPriority2 = (name2, searchValue) => {
    const normalizedName = (0, import_remove_accents3.default)(name2 || "").toLowerCase();
    const normalizedSearch = (0, import_remove_accents3.default)(searchValue || "").toLowerCase();
    if (normalizedName === normalizedSearch) {
      return 0;
    }
    if (normalizedName.startsWith(normalizedSearch)) {
      return normalizedName.length;
    }
    return Infinity;
  };
  function PageAttributesParent2() {
    const { editPost: editPost2 } = (0, import_data108.useDispatch)(store3);
    const [fieldValue, setFieldValue] = (0, import_element200.useState)("");
    const {
      isHierarchical,
      parentPostId,
      parentPostTitle,
      pageItems,
      isLoading
    } = (0, import_data108.useSelect)(
      (select7) => {
        const {
          getPostType,
          getEntityRecords,
          getEntityRecord,
          isResolving
        } = select7(import_core_data69.store);
        const { getCurrentPostId: getCurrentPostId2, getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
        const postTypeSlug = getEditedPostAttribute2("type");
        const pageId = getEditedPostAttribute2("parent");
        const pType = getPostType(postTypeSlug);
        const postId2 = getCurrentPostId2();
        const postIsHierarchical = pType?.hierarchical ?? false;
        const query = {
          per_page: 100,
          exclude: postId2,
          parent_exclude: postId2,
          orderby: "menu_order",
          order: "asc",
          _fields: "id,title,parent"
        };
        if (!!fieldValue) {
          query.search = fieldValue;
          query.orderby = "relevance";
        }
        const parentPost = pageId ? getEntityRecord("postType", postTypeSlug, pageId) : null;
        return {
          isHierarchical: postIsHierarchical,
          parentPostId: pageId,
          parentPostTitle: parentPost ? getTitle(parentPost) : "",
          pageItems: postIsHierarchical ? getEntityRecords("postType", postTypeSlug, query) : null,
          isLoading: postIsHierarchical ? isResolving("getEntityRecords", [
            "postType",
            postTypeSlug,
            query
          ]) : false
        };
      },
      [fieldValue]
    );
    const parentOptions = (0, import_element200.useMemo)(() => {
      const getOptionsFromTree = (tree2, level = 0) => {
        const mappedNodes = tree2.map((treeNode) => [
          {
            value: treeNode.id,
            label: "\u2014 ".repeat(level) + (0, import_html_entities16.decodeEntities)(treeNode.name),
            rawName: treeNode.name
          },
          ...getOptionsFromTree(treeNode.children || [], level + 1)
        ]);
        const sortedNodes = mappedNodes.sort(([a3], [b3]) => {
          const priorityA = getItemPriority2(a3.rawName, fieldValue);
          const priorityB = getItemPriority2(b3.rawName, fieldValue);
          return priorityA >= priorityB ? 1 : -1;
        });
        return sortedNodes.flat();
      };
      if (!pageItems) {
        return [];
      }
      let tree = pageItems.map((item) => ({
        id: item.id,
        parent: item.parent,
        name: getTitle(item)
      }));
      if (!fieldValue) {
        tree = buildTermsTree2(tree);
      }
      const opts = getOptionsFromTree(tree);
      const optsHasParent = opts.find(
        (item) => item.value === parentPostId
      );
      if (parentPostTitle && !optsHasParent) {
        opts.unshift({
          value: parentPostId,
          label: parentPostTitle
        });
      }
      return opts;
    }, [pageItems, fieldValue, parentPostTitle, parentPostId]);
    if (!isHierarchical) {
      return null;
    }
    const handleKeydown = (inputValue) => {
      setFieldValue(inputValue);
    };
    const handleChange = (selectedPostId) => {
      editPost2({ parent: selectedPostId });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(
      import_components173.ComboboxControl,
      {
        __next40pxDefaultSize: true,
        className: "editor-page-attributes__parent",
        label: (0, import_i18n204.__)("Parent"),
        help: (0, import_i18n204.__)("Choose a parent page."),
        value: parentPostId,
        options: parentOptions,
        onFilterValueChange: (0, import_compose38.debounce)(handleKeydown, 300),
        onChange: handleChange,
        hideLabelFromVision: true,
        isLoading
      }
    );
  }
  function PostParentToggle({ isOpen: isOpen2, onClick }) {
    const parentPost = (0, import_data108.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
      const parentPostId = getEditedPostAttribute2("parent");
      if (!parentPostId) {
        return null;
      }
      const { getEntityRecord } = select7(import_core_data69.store);
      const postTypeSlug = getEditedPostAttribute2("type");
      return getEntityRecord("postType", postTypeSlug, parentPostId);
    }, []);
    const parentTitle = (0, import_element200.useMemo)(
      () => !parentPost ? (0, import_i18n204.__)("None") : getTitle(parentPost),
      [parentPost]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(
      import_components173.Button,
      {
        size: "compact",
        className: "editor-post-parent__panel-toggle",
        variant: "tertiary",
        "aria-expanded": isOpen2,
        "aria-label": (
          // translators: %s: Current post parent.
          (0, import_i18n204.sprintf)((0, import_i18n204.__)("Change parent: %s"), parentTitle)
        ),
        onClick,
        children: parentTitle
      }
    );
  }
  function ParentRow() {
    const homeUrl = (0, import_data108.useSelect)((select7) => {
      return select7(import_core_data69.store).getEntityRecord("root", "__unstableBase")?.home;
    }, []);
    const [popoverAnchor, setPopoverAnchor] = (0, import_element200.useState)(null);
    const popoverProps = (0, import_element200.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(post_panel_row_default, { label: (0, import_i18n204.__)("Parent"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(
      import_components173.Dropdown,
      {
        popoverProps,
        className: "editor-post-parent__panel-dropdown",
        contentClassName: "editor-post-parent__panel-dialog",
        focusOnMount: true,
        renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(PostParentToggle, { isOpen: isOpen2, onClick: onToggle }),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime355.jsxs)("div", { className: "editor-post-parent", children: [
          /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(
            import_block_editor47.__experimentalInspectorPopoverHeader,
            {
              title: (0, import_i18n204.__)("Parent"),
              onClose
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime355.jsxs)("div", { children: [
            (0, import_element200.createInterpolateElement)(
              (0, import_i18n204.sprintf)(
                /* translators: %s: The home URL of the WordPress installation without the scheme. */
                (0, import_i18n204.__)(
                  'Child pages inherit characteristics from their parent, such as URL structure. For instance, if "Pricing" is a child of "Services", its URL would be %s<wbr />/services<wbr />/pricing.'
                ),
                (0, import_url15.filterURLForDisplay)(homeUrl).replace(
                  /([/.])/g,
                  "<wbr />$1"
                )
              ),
              {
                wbr: /* @__PURE__ */ (0, import_jsx_runtime355.jsx)("wbr", {})
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime355.jsx)("p", { children: (0, import_element200.createInterpolateElement)(
              (0, import_i18n204.__)(
                "They also show up as sub-items in the default navigation menu. <a>Learn more.</a>"
              ),
              {
                a: /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(
                  import_components173.ExternalLink,
                  {
                    href: (0, import_i18n204.__)(
                      "https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes"
                    )
                  }
                )
              }
            ) })
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(PageAttributesParent2, {})
        ] })
      }
    ) });
  }
  var parent_default2 = PageAttributesParent2;

  // packages/editor/build-module/components/page-attributes/panel.mjs
  var import_jsx_runtime356 = __toESM(require_jsx_runtime(), 1);
  var PANEL_NAME = "page-attributes";
  function AttributesPanel() {
    const { isEnabled, postType: postType2 } = (0, import_data109.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2, isEditorPanelEnabled: isEditorPanelEnabled2 } = select7(store3);
      const { getPostType } = select7(import_core_data70.store);
      return {
        isEnabled: isEditorPanelEnabled2(PANEL_NAME),
        postType: getPostType(getEditedPostAttribute2("type"))
      };
    }, []);
    if (!isEnabled || !postType2) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime356.jsx)(ParentRow, {});
  }
  function PageAttributesPanel() {
    return /* @__PURE__ */ (0, import_jsx_runtime356.jsx)(check_default2, { children: /* @__PURE__ */ (0, import_jsx_runtime356.jsx)(AttributesPanel, {}) });
  }

  // packages/editor/build-module/components/post-template/classic-theme.mjs
  var import_i18n207 = __toESM(require_i18n(), 1);
  var import_components175 = __toESM(require_components(), 1);
  var import_data112 = __toESM(require_data(), 1);
  var import_core_data72 = __toESM(require_core_data(), 1);
  var import_block_editor48 = __toESM(require_block_editor(), 1);
  var import_element203 = __toESM(require_element(), 1);
  var import_notices22 = __toESM(require_notices(), 1);

  // packages/editor/build-module/components/post-template/create-new-template-modal.mjs
  var import_data110 = __toESM(require_data(), 1);
  var import_element201 = __toESM(require_element(), 1);
  var import_blocks25 = __toESM(require_blocks(), 1);
  var import_components174 = __toESM(require_components(), 1);
  var import_i18n205 = __toESM(require_i18n(), 1);
  var import_jsx_runtime357 = __toESM(require_jsx_runtime(), 1);
  var DEFAULT_TITLE = (0, import_i18n205.__)("Custom Template");
  function CreateNewTemplateModal({ onClose }) {
    const { defaultBlockTemplate, onNavigateToEntityRecord } = (0, import_data110.useSelect)(
      (select7) => {
        const { getEditorSettings: getEditorSettings2, getCurrentTemplateId: getCurrentTemplateId2 } = select7(store3);
        return {
          defaultBlockTemplate: getEditorSettings2().defaultBlockTemplate,
          onNavigateToEntityRecord: getEditorSettings2().onNavigateToEntityRecord,
          getTemplateId: getCurrentTemplateId2
        };
      }
    );
    const { createTemplate: createTemplate2 } = unlock((0, import_data110.useDispatch)(store3));
    const [title, setTitle] = (0, import_element201.useState)("");
    const [isBusy, setIsBusy] = (0, import_element201.useState)(false);
    const cancel = () => {
      setTitle("");
      onClose();
    };
    const submit = async (event) => {
      event.preventDefault();
      if (isBusy) {
        return;
      }
      setIsBusy(true);
      const newTemplateContent = defaultBlockTemplate ?? (0, import_blocks25.serialize)([
        (0, import_blocks25.createBlock)(
          "core/group",
          {
            tagName: "header",
            layout: { inherit: true }
          },
          [
            (0, import_blocks25.createBlock)("core/site-title"),
            (0, import_blocks25.createBlock)("core/site-tagline")
          ]
        ),
        (0, import_blocks25.createBlock)("core/separator"),
        (0, import_blocks25.createBlock)(
          "core/group",
          {
            tagName: "main"
          },
          [
            (0, import_blocks25.createBlock)(
              "core/group",
              {
                layout: { inherit: true }
              },
              [(0, import_blocks25.createBlock)("core/post-title")]
            ),
            (0, import_blocks25.createBlock)("core/post-content", {
              layout: { inherit: true }
            })
          ]
        )
      ]);
      const newTemplate = await createTemplate2({
        slug: paramCase(title || DEFAULT_TITLE) || "wp-custom-template",
        content: newTemplateContent,
        title: title || DEFAULT_TITLE,
        status: "publish"
      });
      setIsBusy(false);
      onNavigateToEntityRecord({
        postId: newTemplate.id,
        postType: "wp_template"
      });
      cancel();
    };
    return /* @__PURE__ */ (0, import_jsx_runtime357.jsx)(
      import_components174.Modal,
      {
        title: (0, import_i18n205.__)("Create custom template"),
        onRequestClose: cancel,
        focusOnMount: "firstContentElement",
        size: "small",
        overlayClassName: "editor-post-template__create-template-modal",
        children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)("form", { onSubmit: submit, children: /* @__PURE__ */ (0, import_jsx_runtime357.jsxs)(import_components174.__experimentalVStack, { spacing: "3", children: [
          /* @__PURE__ */ (0, import_jsx_runtime357.jsx)(
            import_components174.TextControl,
            {
              __next40pxDefaultSize: true,
              label: (0, import_i18n205.__)("Name"),
              value: title,
              onChange: setTitle,
              placeholder: DEFAULT_TITLE,
              disabled: isBusy,
              help: (0, import_i18n205.__)(
                // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
                'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.'
              )
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime357.jsxs)(import_components174.__experimentalHStack, { justify: "right", children: [
            /* @__PURE__ */ (0, import_jsx_runtime357.jsx)(
              import_components174.Button,
              {
                __next40pxDefaultSize: true,
                variant: "tertiary",
                onClick: cancel,
                children: (0, import_i18n205.__)("Cancel")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime357.jsx)(
              import_components174.Button,
              {
                __next40pxDefaultSize: true,
                variant: "primary",
                type: "submit",
                isBusy,
                "aria-disabled": isBusy,
                children: (0, import_i18n205.__)("Create")
              }
            )
          ] })
        ] }) })
      }
    );
  }

  // packages/editor/build-module/components/post-template/hooks.mjs
  var import_data111 = __toESM(require_data(), 1);
  var import_element202 = __toESM(require_element(), 1);
  var import_core_data71 = __toESM(require_core_data(), 1);
  var import_i18n206 = __toESM(require_i18n(), 1);
  function useEditedPostContext() {
    return (0, import_data111.useSelect)((select7) => {
      const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
      return {
        postId: getCurrentPostId2(),
        postType: getCurrentPostType2()
      };
    }, []);
  }
  function useAllowSwitchingTemplates() {
    const { postType: postType2, postId: postId2 } = useEditedPostContext();
    return (0, import_data111.useSelect)(
      (select7) => {
        const { canUser, getEntityRecord, getEntityRecords } = select7(import_core_data71.store);
        const siteSettings = canUser("read", {
          kind: "root",
          name: "site"
        }) ? getEntityRecord("root", "site") : void 0;
        const isPostsPage = +postId2 === siteSettings?.page_for_posts;
        const isFrontPage = postType2 === "page" && +postId2 === siteSettings?.page_on_front;
        const templates = isFrontPage ? getEntityRecords("postType", "wp_template", {
          per_page: -1
        }) : [];
        const hasFrontPage = isFrontPage && !!templates?.some(({ slug }) => slug === "front-page");
        return !isPostsPage && !hasFrontPage;
      },
      [postId2, postType2]
    );
  }
  function useTemplates(postType2) {
    return (0, import_data111.useSelect)(
      (select7) => select7(import_core_data71.store).getEntityRecords("postType", "wp_template", {
        per_page: -1,
        post_type: postType2
        // We look at the combined templates for now (old endpoint)
        // because posts only accept slugs for templates, not IDs.
      }),
      [postType2]
    );
  }
  function useAvailableTemplates() {
    const { postType: postType2, postId: postId2 } = useEditedPostContext();
    const [postSlug] = (0, import_core_data71.useEntityProp)("postType", postType2, "slug", postId2);
    const currentTemplateSlug = useCurrentTemplateSlug();
    const allowSwitchingTemplate = useAllowSwitchingTemplates();
    const templates = useTemplates(postType2);
    const defaultTemplate = (0, import_data111.useSelect)(
      (select7) => {
        if (!window?.__experimentalDataFormInspector) {
          return null;
        }
        if (!currentTemplateSlug) {
          return null;
        }
        const { getDefaultTemplateId, getEntityRecord } = select7(import_core_data71.store);
        let slug;
        if (postSlug) {
          slug = postType2 === "page" ? `${postType2}-${postSlug}` : `single-${postType2}-${postSlug}`;
        } else {
          slug = postType2 === "page" ? "page" : `single-${postType2}`;
        }
        const templateId2 = getDefaultTemplateId({ slug });
        if (!templateId2) {
          return null;
        }
        return getEntityRecord("postType", "wp_template", templateId2);
      },
      [currentTemplateSlug, postSlug, postType2]
    );
    return (0, import_element202.useMemo)(
      () => allowSwitchingTemplate && [
        ...(templates || []).filter(
          (template2) => template2.is_custom && template2.slug !== currentTemplateSlug && !!template2.content.raw
          // Skip empty templates.
        ),
        defaultTemplate && {
          ...defaultTemplate,
          title: {
            rendered: (0, import_i18n206.sprintf)(
              // translators: %s: Template name
              (0, import_i18n206.__)("%s (default)"),
              defaultTemplate.title.rendered
            )
          },
          // That's extra custom prop in order to update to an empty template
          // when we select the default template.
          isDefault: true
        }
      ].filter(Boolean),
      [
        templates,
        defaultTemplate,
        currentTemplateSlug,
        allowSwitchingTemplate
      ]
    );
  }
  function usePostTemplatePanelMode() {
    return (0, import_data111.useSelect)((select7) => {
      const { getEditorSettings: getEditorSettings2, getCurrentTemplateId: getCurrentTemplateId2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
      const { getPostType, canUser } = select7(import_core_data71.store);
      const postTypeSlug = getCurrentPostType2();
      const postType2 = getPostType(postTypeSlug);
      const settings = getEditorSettings2();
      const isBlockTheme = settings.__unstableIsBlockBasedTheme;
      const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
      let isVisible2;
      if (!postType2?.viewable) {
        isVisible2 = false;
      } else if (hasTemplates) {
        isVisible2 = true;
      } else if (!settings.supportsTemplateMode) {
        isVisible2 = false;
      } else {
        isVisible2 = canUser("create", {
          kind: "postType",
          name: "wp_template"
        }) ?? false;
      }
      const canViewTemplates = isVisible2 ? !!canUser("read", {
        kind: "postType",
        name: "wp_template"
      }) : false;
      if ((!isBlockTheme || !canViewTemplates) && isVisible2) {
        return "classic";
      }
      if (isBlockTheme && !!getCurrentTemplateId2()) {
        return "block-theme";
      }
      return null;
    }, []);
  }
  function useCurrentTemplateSlug() {
    const { postType: postType2, postId: postId2 } = useEditedPostContext();
    const templates = useTemplates(postType2);
    const entityTemplate = (0, import_data111.useSelect)(
      (select7) => {
        const post2 = select7(import_core_data71.store).getEditedEntityRecord(
          "postType",
          postType2,
          postId2
        );
        return post2?.template;
      },
      [postType2, postId2]
    );
    if (!entityTemplate) {
      return;
    }
    return templates?.find((template2) => template2.slug === entityTemplate)?.slug;
  }

  // packages/editor/build-module/components/post-template/classic-theme.mjs
  var import_jsx_runtime358 = __toESM(require_jsx_runtime(), 1);
  function PostTemplateToggle({ isOpen: isOpen2, onClick }) {
    const templateTitle = (0, import_data112.useSelect)((select7) => {
      const templateSlug = select7(store3).getEditedPostAttribute("template");
      const { supportsTemplateMode, availableTemplates } = select7(store3).getEditorSettings();
      if (!supportsTemplateMode && availableTemplates[templateSlug]) {
        return availableTemplates[templateSlug];
      }
      const template2 = select7(import_core_data72.store).canUser("create", {
        kind: "postType",
        name: "wp_template"
      }) && select7(store3).getCurrentTemplateId();
      return template2?.title || template2?.slug || availableTemplates?.[templateSlug];
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(
      import_components175.Button,
      {
        __next40pxDefaultSize: true,
        variant: "tertiary",
        "aria-expanded": isOpen2,
        "aria-label": (0, import_i18n207.__)("Template options"),
        onClick,
        children: templateTitle ?? (0, import_i18n207.__)("Default template")
      }
    );
  }
  function PostTemplateDropdownContent({ onClose }) {
    const allowSwitchingTemplate = useAllowSwitchingTemplates();
    const {
      availableTemplates,
      fetchedTemplates,
      selectedTemplateSlug,
      canCreate,
      canEdit,
      currentTemplateId,
      onNavigateToEntityRecord,
      getEditorSettings: getEditorSettings2
    } = (0, import_data112.useSelect)(
      (select7) => {
        const { canUser, getEntityRecords } = select7(import_core_data72.store);
        const editorSettings2 = select7(store3).getEditorSettings();
        const canCreateTemplates = canUser("create", {
          kind: "postType",
          name: "wp_template"
        });
        const _currentTemplateId = select7(store3).getCurrentTemplateId();
        return {
          availableTemplates: editorSettings2.availableTemplates,
          fetchedTemplates: canCreateTemplates ? getEntityRecords("postType", "wp_template", {
            post_type: select7(store3).getCurrentPostType(),
            per_page: -1
          }) : void 0,
          selectedTemplateSlug: select7(store3).getEditedPostAttribute("template"),
          canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings2.supportsTemplateMode,
          canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings2.supportsTemplateMode && !!_currentTemplateId,
          currentTemplateId: _currentTemplateId,
          onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord,
          getEditorSettings: select7(store3).getEditorSettings
        };
      },
      [allowSwitchingTemplate]
    );
    const options = (0, import_element203.useMemo)(
      () => Object.entries({
        ...availableTemplates,
        ...Object.fromEntries(
          (fetchedTemplates ?? []).map(({ slug, title }) => [
            slug,
            title.rendered
          ])
        )
      }).map(([slug, title]) => ({ value: slug, label: title })),
      [availableTemplates, fetchedTemplates]
    );
    const selectedOption = options.find((option) => option.value === selectedTemplateSlug) ?? options.find((option) => !option.value);
    const { editPost: editPost2 } = (0, import_data112.useDispatch)(store3);
    const { createSuccessNotice } = (0, import_data112.useDispatch)(import_notices22.store);
    const [isCreateModalOpen, setIsCreateModalOpen] = (0, import_element203.useState)(false);
    return /* @__PURE__ */ (0, import_jsx_runtime358.jsxs)("div", { className: "editor-post-template__classic-theme-dropdown", children: [
      /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(
        import_block_editor48.__experimentalInspectorPopoverHeader,
        {
          title: (0, import_i18n207.__)("Template"),
          help: (0, import_i18n207.__)(
            "Templates define the way content is displayed when viewing your site."
          ),
          actions: canCreate ? [
            {
              icon: add_template_default,
              label: (0, import_i18n207.__)("Add template"),
              onClick: () => setIsCreateModalOpen(true)
            }
          ] : [],
          onClose
        }
      ),
      !allowSwitchingTemplate ? /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(import_components175.Notice, { status: "warning", isDismissible: false, children: (0, import_i18n207.__)("The posts page template cannot be changed.") }) : /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(
        import_components175.SelectControl,
        {
          __next40pxDefaultSize: true,
          hideLabelFromVision: true,
          label: (0, import_i18n207.__)("Template"),
          value: selectedOption?.value ?? "",
          options,
          onChange: (slug) => editPost2({ template: slug || "" })
        }
      ),
      canEdit && onNavigateToEntityRecord && /* @__PURE__ */ (0, import_jsx_runtime358.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(
        import_components175.Button,
        {
          __next40pxDefaultSize: true,
          variant: "link",
          onClick: () => {
            onNavigateToEntityRecord({
              postId: currentTemplateId,
              postType: "wp_template"
            });
            onClose();
            createSuccessNotice(
              (0, import_i18n207.__)(
                "Editing template. Changes made here affect all posts and pages that use the template."
              ),
              {
                type: "snackbar",
                actions: [
                  {
                    label: (0, import_i18n207.__)("Go back"),
                    onClick: () => getEditorSettings2().onNavigateToPreviousEntityRecord()
                  }
                ]
              }
            );
          },
          children: (0, import_i18n207.__)("Edit template")
        }
      ) }),
      isCreateModalOpen && /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(
        CreateNewTemplateModal,
        {
          onClose: () => setIsCreateModalOpen(false)
        }
      )
    ] });
  }
  function ClassicThemeControl() {
    const [popoverAnchor, setPopoverAnchor] = (0, import_element203.useState)(null);
    const popoverProps = (0, import_element203.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        className: "editor-post-template__dropdown",
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(post_panel_row_default, { label: (0, import_i18n207.__)("Template"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(
      import_components175.Dropdown,
      {
        popoverProps,
        focusOnMount: true,
        renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(
          PostTemplateToggle,
          {
            isOpen: isOpen2,
            onClick: onToggle
          }
        ),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(PostTemplateDropdownContent, { onClose })
      }
    ) });
  }
  var classic_theme_default = ClassicThemeControl;

  // packages/editor/build-module/components/plugin-document-setting-panel/index.mjs
  var import_components177 = __toESM(require_components(), 1);
  var import_plugins3 = __toESM(require_plugins(), 1);
  var import_data114 = __toESM(require_data(), 1);
  var import_warning2 = __toESM(require_warning(), 1);

  // packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.mjs
  var import_components176 = __toESM(require_components(), 1);

  // packages/editor/build-module/components/preferences-modal/enable-panel.mjs
  var import_data113 = __toESM(require_data(), 1);
  var import_preferences12 = __toESM(require_preferences(), 1);
  var import_jsx_runtime359 = __toESM(require_jsx_runtime(), 1);
  var { PreferenceBaseOption } = unlock(import_preferences12.privateApis);
  function EnablePanelOption(props) {
    const { toggleEditorPanelEnabled: toggleEditorPanelEnabled2 } = (0, import_data113.useDispatch)(store3);
    const { isChecked, isRemoved } = (0, import_data113.useSelect)(
      (select7) => {
        const { isEditorPanelEnabled: isEditorPanelEnabled2, isEditorPanelRemoved: isEditorPanelRemoved2 } = select7(store3);
        return {
          isChecked: isEditorPanelEnabled2(props.panelName),
          isRemoved: isEditorPanelRemoved2(props.panelName)
        };
      },
      [props.panelName]
    );
    if (isRemoved) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime359.jsx)(
      PreferenceBaseOption,
      {
        isChecked,
        onChange: () => toggleEditorPanelEnabled2(props.panelName),
        ...props
      }
    );
  }

  // packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.mjs
  var import_jsx_runtime360 = __toESM(require_jsx_runtime(), 1);
  var { Fill: Fill4, Slot: Slot4 } = (0, import_components176.createSlotFill)(
    "EnablePluginDocumentSettingPanelOption"
  );
  var EnablePluginDocumentSettingPanelOption = ({ label, panelName }) => /* @__PURE__ */ (0, import_jsx_runtime360.jsx)(Fill4, { children: /* @__PURE__ */ (0, import_jsx_runtime360.jsx)(EnablePanelOption, { label, panelName }) });
  EnablePluginDocumentSettingPanelOption.Slot = Slot4;
  var enable_plugin_document_setting_panel_default = EnablePluginDocumentSettingPanelOption;

  // packages/editor/build-module/components/plugin-document-setting-panel/index.mjs
  var import_jsx_runtime361 = __toESM(require_jsx_runtime(), 1);
  var { Fill: Fill5, Slot: Slot5 } = (0, import_components177.createSlotFill)("PluginDocumentSettingPanel");
  var PluginDocumentSettingPanel = ({
    name: name2,
    className,
    title,
    icon,
    children
  }) => {
    const { name: pluginName } = (0, import_plugins3.usePluginContext)();
    const panelName = `${pluginName}/${name2}`;
    const { opened, isEnabled } = (0, import_data114.useSelect)(
      (select7) => {
        const { isEditorPanelOpened: isEditorPanelOpened2, isEditorPanelEnabled: isEditorPanelEnabled2 } = select7(store3);
        return {
          opened: isEditorPanelOpened2(panelName),
          isEnabled: isEditorPanelEnabled2(panelName)
        };
      },
      [panelName]
    );
    const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data114.useDispatch)(store3);
    if (void 0 === name2) {
      (0, import_warning2.default)("PluginDocumentSettingPanel requires a name property.");
    }
    return /* @__PURE__ */ (0, import_jsx_runtime361.jsxs)(import_jsx_runtime361.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime361.jsx)(
        enable_plugin_document_setting_panel_default,
        {
          label: title,
          panelName
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime361.jsx)(Fill5, { children: isEnabled && /* @__PURE__ */ (0, import_jsx_runtime361.jsx)(
        import_components177.PanelBody,
        {
          className,
          title,
          icon,
          opened,
          onToggle: () => toggleEditorPanelOpened2(panelName),
          children
        }
      ) })
    ] });
  };
  PluginDocumentSettingPanel.Slot = Slot5;
  var plugin_document_setting_panel_default = PluginDocumentSettingPanel;

  // packages/editor/build-module/components/block-settings-menu/plugin-block-settings-menu-item.mjs
  var import_block_editor49 = __toESM(require_block_editor(), 1);
  var import_components178 = __toESM(require_components(), 1);
  var import_compose39 = __toESM(require_compose(), 1);
  var import_jsx_runtime362 = __toESM(require_jsx_runtime(), 1);
  var isEverySelectedBlockAllowed = (selected, allowed) => selected.filter((id) => !allowed.includes(id)).length === 0;
  var shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks);
  var PluginBlockSettingsMenuItem = ({
    allowedBlocks,
    icon,
    label,
    onClick,
    small,
    role
  }) => /* @__PURE__ */ (0, import_jsx_runtime362.jsx)(import_block_editor49.BlockSettingsMenuControls, { children: ({ selectedBlocks, onClose }) => {
    if (!shouldRenderItem(selectedBlocks, allowedBlocks)) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime362.jsx)(
      import_components178.MenuItem,
      {
        onClick: (0, import_compose39.compose)(onClick, onClose),
        icon,
        label: small ? label : void 0,
        role,
        children: !small && label
      }
    );
  } });
  var plugin_block_settings_menu_item_default = PluginBlockSettingsMenuItem;

  // packages/editor/build-module/components/plugin-more-menu-item/index.mjs
  var import_components179 = __toESM(require_components(), 1);
  var import_plugins4 = __toESM(require_plugins(), 1);
  var import_jsx_runtime363 = __toESM(require_jsx_runtime(), 1);
  function PluginMoreMenuItem(props) {
    const context = (0, import_plugins4.usePluginContext)();
    return /* @__PURE__ */ (0, import_jsx_runtime363.jsx)(
      action_item_default,
      {
        name: "core/plugin-more-menu",
        as: props.as ?? import_components179.MenuItem,
        icon: props.icon || context.icon,
        ...props
      }
    );
  }

  // packages/editor/build-module/components/plugin-post-publish-panel/index.mjs
  var import_plugins5 = __toESM(require_plugins(), 1);
  var import_components180 = __toESM(require_components(), 1);
  var import_jsx_runtime364 = __toESM(require_jsx_runtime(), 1);
  var { Fill: Fill6, Slot: Slot6 } = (0, import_components180.createSlotFill)("PluginPostPublishPanel");
  var PluginPostPublishPanel = ({
    children,
    className,
    title,
    initialOpen = false,
    icon
  }) => {
    const { icon: pluginIcon } = (0, import_plugins5.usePluginContext)();
    return /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(Fill6, { children: /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(
      import_components180.PanelBody,
      {
        className,
        initialOpen: initialOpen || !title,
        title,
        icon: icon ?? pluginIcon,
        children
      }
    ) });
  };
  PluginPostPublishPanel.Slot = Slot6;
  var plugin_post_publish_panel_default = PluginPostPublishPanel;

  // packages/editor/build-module/components/plugin-post-status-info/index.mjs
  var import_components181 = __toESM(require_components(), 1);
  var import_jsx_runtime365 = __toESM(require_jsx_runtime(), 1);
  var { Fill: Fill7, Slot: Slot7 } = (0, import_components181.createSlotFill)("PluginPostStatusInfo");
  var PluginPostStatusInfo = ({ children, className }) => /* @__PURE__ */ (0, import_jsx_runtime365.jsx)(Fill7, { children: /* @__PURE__ */ (0, import_jsx_runtime365.jsx)(import_components181.PanelRow, { className, children }) });
  PluginPostStatusInfo.Slot = Slot7;
  var plugin_post_status_info_default = PluginPostStatusInfo;

  // packages/editor/build-module/components/plugin-pre-publish-panel/index.mjs
  var import_components182 = __toESM(require_components(), 1);
  var import_plugins6 = __toESM(require_plugins(), 1);
  var import_jsx_runtime366 = __toESM(require_jsx_runtime(), 1);
  var { Fill: Fill8, Slot: Slot8 } = (0, import_components182.createSlotFill)("PluginPrePublishPanel");
  var PluginPrePublishPanel = ({
    children,
    className,
    title,
    initialOpen = false,
    icon
  }) => {
    const { icon: pluginIcon } = (0, import_plugins6.usePluginContext)();
    return /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(Fill8, { children: /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(
      import_components182.PanelBody,
      {
        className,
        initialOpen: initialOpen || !title,
        title,
        icon: icon ?? pluginIcon,
        children
      }
    ) });
  };
  PluginPrePublishPanel.Slot = Slot8;
  var plugin_pre_publish_panel_default = PluginPrePublishPanel;

  // packages/editor/build-module/components/plugin-preview-menu-item/index.mjs
  var import_components183 = __toESM(require_components(), 1);
  var import_plugins7 = __toESM(require_plugins(), 1);
  var import_jsx_runtime367 = __toESM(require_jsx_runtime(), 1);
  function PluginPreviewMenuItem(props) {
    const context = (0, import_plugins7.usePluginContext)();
    return /* @__PURE__ */ (0, import_jsx_runtime367.jsx)(
      action_item_default,
      {
        name: "core/plugin-preview-menu",
        as: props.as ?? import_components183.MenuItem,
        icon: props.icon || context.icon,
        ...props
      }
    );
  }

  // packages/editor/build-module/components/plugin-sidebar/index.mjs
  var import_jsx_runtime368 = __toESM(require_jsx_runtime(), 1);
  function PluginSidebar({ className, ...props }) {
    return /* @__PURE__ */ (0, import_jsx_runtime368.jsx)(
      complementary_area_default,
      {
        panelClassName: className,
        className: "editor-sidebar",
        scope: "core",
        ...props
      }
    );
  }

  // packages/editor/build-module/components/plugin-sidebar-more-menu-item/index.mjs
  var import_jsx_runtime369 = __toESM(require_jsx_runtime(), 1);
  function PluginSidebarMoreMenuItem(props) {
    return /* @__PURE__ */ (0, import_jsx_runtime369.jsx)(
      ComplementaryAreaMoreMenuItem,
      {
        __unstableExplicitMenuItem: true,
        scope: "core",
        ...props
      }
    );
  }

  // packages/editor/build-module/components/post-template/block-theme.mjs
  var import_data118 = __toESM(require_data(), 1);
  var import_html_entities18 = __toESM(require_html_entities(), 1);
  var import_components187 = __toESM(require_components(), 1);
  var import_element206 = __toESM(require_element(), 1);
  var import_i18n211 = __toESM(require_i18n(), 1);
  var import_core_data76 = __toESM(require_core_data(), 1);
  var import_notices23 = __toESM(require_notices(), 1);
  var import_preferences13 = __toESM(require_preferences(), 1);

  // packages/editor/build-module/components/post-template/swap-template-button.mjs
  var import_element204 = __toESM(require_element(), 1);
  var import_html_entities17 = __toESM(require_html_entities(), 1);
  var import_block_editor50 = __toESM(require_block_editor(), 1);
  var import_components184 = __toESM(require_components(), 1);
  var import_i18n208 = __toESM(require_i18n(), 1);
  var import_data115 = __toESM(require_data(), 1);
  var import_core_data73 = __toESM(require_core_data(), 1);
  var import_blocks26 = __toESM(require_blocks(), 1);

  // packages/editor/build-module/utils/search-templates.mjs
  var import_remove_accents4 = __toESM(require_remove_accents(), 1);
  function normalizeSearchInput2(input = "") {
    input = (0, import_remove_accents4.default)(input);
    input = input.trim().toLowerCase();
    return input;
  }
  function getTemplateSearchRank(template2, searchValue) {
    const normalizedSearchValue = normalizeSearchInput2(searchValue);
    const normalizedTitle = normalizeSearchInput2(template2.title);
    let rank = 0;
    if (normalizedSearchValue === normalizedTitle) {
      rank += 30;
    } else if (normalizedTitle.startsWith(normalizedSearchValue)) {
      rank += 20;
    } else {
      const searchTerms = normalizedSearchValue.split(" ");
      const hasMatchedTerms = searchTerms.every(
        (searchTerm) => normalizedTitle.includes(searchTerm)
      );
      if (hasMatchedTerms) {
        rank += 10;
      }
    }
    return rank;
  }
  function searchTemplates(templates = [], searchValue = "") {
    if (!searchValue) {
      return templates;
    }
    const rankedTemplates = templates.map((template2) => {
      return [template2, getTemplateSearchRank(template2, searchValue)];
    }).filter(([, rank]) => rank > 0);
    rankedTemplates.sort(([, rank1], [, rank2]) => rank2 - rank1);
    return rankedTemplates.map(([template2]) => template2);
  }

  // packages/editor/build-module/components/post-template/swap-template-button.mjs
  var import_jsx_runtime370 = __toESM(require_jsx_runtime(), 1);
  function SwapTemplateModal({ onRequestClose, onSelect }) {
    const { postType: postType2, postId: postId2 } = useEditedPostContext();
    const { editEntityRecord } = (0, import_data115.useDispatch)(import_core_data73.store);
    const onTemplateSelect = async (template2) => {
      editEntityRecord(
        "postType",
        postType2,
        postId2,
        // Since we append the default template we need to properly
        // update to an empty string.
        { template: template2.isDefault ? "" : template2.name },
        { undoIgnore: true }
      );
      onRequestClose();
      onSelect?.();
    };
    return /* @__PURE__ */ (0, import_jsx_runtime370.jsx)(
      import_components184.Modal,
      {
        title: (0, import_i18n208.__)("Choose a template"),
        onRequestClose,
        overlayClassName: "editor-post-template__swap-template-modal",
        isFullScreen: true,
        children: /* @__PURE__ */ (0, import_jsx_runtime370.jsx)("div", { className: "editor-post-template__swap-template-modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime370.jsx)(TemplatesList, { onSelect: onTemplateSelect }) })
      }
    );
  }
  function SwapTemplateButton({ onClick }) {
    const [showModal, setShowModal] = (0, import_element204.useState)(false);
    const availableTemplates = useAvailableTemplates();
    return /* @__PURE__ */ (0, import_jsx_runtime370.jsxs)(import_jsx_runtime370.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime370.jsx)(
        import_components184.MenuItem,
        {
          disabled: !availableTemplates?.length,
          accessibleWhenDisabled: true,
          onClick: () => setShowModal(true),
          children: (0, import_i18n208.__)("Change template")
        }
      ),
      showModal && /* @__PURE__ */ (0, import_jsx_runtime370.jsx)(
        SwapTemplateModal,
        {
          onRequestClose: () => setShowModal(false),
          onSelect: onClick
        }
      )
    ] });
  }
  function TemplatesList({ onSelect }) {
    const [searchValue, setSearchValue] = (0, import_element204.useState)("");
    const availableTemplates = useAvailableTemplates();
    const templatesAsPatterns = (0, import_element204.useMemo)(
      () => availableTemplates.map((template2) => ({
        name: template2.slug,
        blocks: (0, import_blocks26.parse)(template2.content.raw),
        title: (0, import_html_entities17.decodeEntities)(template2.title.rendered),
        id: template2.id,
        isDefault: template2.isDefault
      })),
      [availableTemplates]
    );
    const filteredBlockTemplates = (0, import_element204.useMemo)(() => {
      return searchTemplates(templatesAsPatterns, searchValue);
    }, [templatesAsPatterns, searchValue]);
    return /* @__PURE__ */ (0, import_jsx_runtime370.jsxs)(import_jsx_runtime370.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime370.jsx)(
        import_components184.SearchControl,
        {
          onChange: setSearchValue,
          value: searchValue,
          label: (0, import_i18n208.__)("Search"),
          placeholder: (0, import_i18n208.__)("Search"),
          className: "editor-post-template__swap-template-search"
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime370.jsx)(
        import_block_editor50.__experimentalBlockPatternsList,
        {
          label: (0, import_i18n208.__)("Templates"),
          blockPatterns: filteredBlockTemplates,
          onClickPattern: onSelect
        }
      )
    ] });
  }

  // packages/editor/build-module/components/post-template/reset-default-template.mjs
  var import_components185 = __toESM(require_components(), 1);
  var import_i18n209 = __toESM(require_i18n(), 1);
  var import_data116 = __toESM(require_data(), 1);
  var import_core_data74 = __toESM(require_core_data(), 1);
  var import_jsx_runtime371 = __toESM(require_jsx_runtime(), 1);
  function ResetDefaultTemplate({ onClick }) {
    const currentTemplateSlug = useCurrentTemplateSlug();
    const allowSwitchingTemplate = useAllowSwitchingTemplates();
    const { postType: postType2, postId: postId2 } = useEditedPostContext();
    const { editEntityRecord } = (0, import_data116.useDispatch)(import_core_data74.store);
    if (!currentTemplateSlug || !allowSwitchingTemplate) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime371.jsx)(
      import_components185.MenuItem,
      {
        onClick: () => {
          editEntityRecord(
            "postType",
            postType2,
            postId2,
            { template: "" },
            { undoIgnore: true }
          );
          onClick();
        },
        children: (0, import_i18n209.__)("Use default template")
      }
    );
  }

  // packages/editor/build-module/components/post-template/create-new-template.mjs
  var import_components186 = __toESM(require_components(), 1);
  var import_i18n210 = __toESM(require_i18n(), 1);
  var import_data117 = __toESM(require_data(), 1);
  var import_core_data75 = __toESM(require_core_data(), 1);
  var import_element205 = __toESM(require_element(), 1);
  var import_jsx_runtime372 = __toESM(require_jsx_runtime(), 1);
  function CreateNewTemplate() {
    const { canCreateTemplates } = (0, import_data117.useSelect)((select7) => {
      const { canUser } = select7(import_core_data75.store);
      return {
        canCreateTemplates: canUser("create", {
          kind: "postType",
          name: "wp_template"
        })
      };
    }, []);
    const [isCreateModalOpen, setIsCreateModalOpen] = (0, import_element205.useState)(false);
    const allowSwitchingTemplate = useAllowSwitchingTemplates();
    if (!canCreateTemplates || !allowSwitchingTemplate) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime372.jsxs)(import_jsx_runtime372.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(
        import_components186.MenuItem,
        {
          onClick: () => {
            setIsCreateModalOpen(true);
          },
          children: (0, import_i18n210.__)("Create new template")
        }
      ),
      isCreateModalOpen && /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(
        CreateNewTemplateModal,
        {
          onClose: () => {
            setIsCreateModalOpen(false);
          }
        }
      )
    ] });
  }

  // packages/editor/build-module/components/post-template/block-theme.mjs
  var import_jsx_runtime373 = __toESM(require_jsx_runtime(), 1);
  function BlockThemeControl() {
    const {
      isTemplateHidden,
      onNavigateToEntityRecord,
      getEditorSettings: getEditorSettings2,
      hasGoBack,
      hasSpecificTemplate,
      id
    } = (0, import_data118.useSelect)((select7) => {
      const {
        getRenderingMode: getRenderingMode2,
        getEditorSettings: _getEditorSettings,
        getCurrentPost: getCurrentPost2,
        getCurrentTemplateId: getCurrentTemplateId2
      } = unlock(select7(store3));
      const editorSettings2 = _getEditorSettings();
      const currentPost = getCurrentPost2();
      return {
        isTemplateHidden: getRenderingMode2() === "post-only",
        onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord,
        getEditorSettings: _getEditorSettings,
        hasGoBack: editorSettings2.hasOwnProperty(
          "onNavigateToPreviousEntityRecord"
        ),
        hasSpecificTemplate: !!currentPost.template,
        id: getCurrentTemplateId2()
      };
    }, []);
    const { get: getPreference } = (0, import_data118.useSelect)(import_preferences13.store);
    const { editedRecord: template2, hasResolved } = (0, import_core_data76.useEntityRecord)(
      "postType",
      "wp_template",
      id
    );
    const { getEntityRecord } = (0, import_data118.useSelect)(import_core_data76.store);
    const { editEntityRecord } = (0, import_data118.useDispatch)(import_core_data76.store);
    const { createSuccessNotice } = (0, import_data118.useDispatch)(import_notices23.store);
    const { setRenderingMode: setRenderingMode2, setDefaultRenderingMode: setDefaultRenderingMode2 } = unlock(
      (0, import_data118.useDispatch)(store3)
    );
    const canCreateTemplate = (0, import_data118.useSelect)(
      (select7) => !!select7(import_core_data76.store).canUser("create", {
        kind: "postType",
        name: "wp_template"
      }),
      []
    );
    const [popoverAnchor, setPopoverAnchor] = (0, import_element206.useState)(null);
    const popoverProps = (0, import_element206.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        className: "editor-post-template__dropdown",
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    if (!hasResolved) {
      return null;
    }
    const notificationAction = hasGoBack ? [
      {
        label: (0, import_i18n211.__)("Go back"),
        onClick: () => getEditorSettings2().onNavigateToPreviousEntityRecord()
      }
    ] : void 0;
    const mayShowTemplateEditNotice = () => {
      if (!getPreference("core/edit-site", "welcomeGuideTemplate")) {
        createSuccessNotice(
          (0, import_i18n211.__)(
            "Editing template. Changes made here affect all posts and pages that use the template."
          ),
          { type: "snackbar", actions: notificationAction }
        );
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(post_panel_row_default, { label: (0, import_i18n211.__)("Template"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(
      import_components187.DropdownMenu,
      {
        popoverProps,
        focusOnMount: true,
        toggleProps: {
          size: "compact",
          variant: "tertiary",
          tooltipPosition: "middle left"
        },
        label: (0, import_i18n211.__)("Template options"),
        text: (0, import_html_entities18.decodeEntities)(template2.title),
        icon: null,
        children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime373.jsxs)(import_jsx_runtime373.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime373.jsxs)(import_components187.MenuGroup, { children: [
            canCreateTemplate && /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(
              import_components187.MenuItem,
              {
                onClick: async () => {
                  onNavigateToEntityRecord({
                    postId: template2.id,
                    postType: "wp_template"
                  });
                  if (!hasSpecificTemplate && window?.__experimentalTemplateActivate) {
                    const activeTemplates = await getEntityRecord(
                      "root",
                      "site"
                    ).active_templates;
                    if (activeTemplates[template2.slug] !== template2.id) {
                      editEntityRecord(
                        "root",
                        "site",
                        void 0,
                        {
                          active_templates: {
                            ...activeTemplates,
                            [template2.slug]: template2.id
                          }
                        }
                      );
                    }
                  }
                  onClose();
                  mayShowTemplateEditNotice();
                },
                children: (0, import_i18n211.__)("Edit template")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(SwapTemplateButton, { onClick: onClose }),
            /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(ResetDefaultTemplate, { onClick: onClose }),
            canCreateTemplate && /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(CreateNewTemplate, {})
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(import_components187.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(
            import_components187.MenuItem,
            {
              icon: !isTemplateHidden ? check_default : void 0,
              isSelected: !isTemplateHidden,
              role: "menuitemcheckbox",
              onClick: () => {
                const newRenderingMode = isTemplateHidden ? "template-locked" : "post-only";
                setRenderingMode2(newRenderingMode);
                setDefaultRenderingMode2(newRenderingMode);
              },
              children: (0, import_i18n211.__)("Show template")
            }
          ) })
        ] })
      }
    ) });
  }

  // packages/editor/build-module/components/post-template/panel.mjs
  var import_jsx_runtime374 = __toESM(require_jsx_runtime(), 1);
  function PostTemplatePanel() {
    const mode = usePostTemplatePanelMode();
    if (mode === "classic") {
      return /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(classic_theme_default, {});
    }
    if (mode === "block-theme") {
      return /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(BlockThemeControl, {});
    }
    return null;
  }

  // packages/editor/build-module/components/post-author/index.mjs
  var import_data122 = __toESM(require_data(), 1);
  var import_core_data78 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/post-author/combobox.mjs
  var import_compose40 = __toESM(require_compose(), 1);
  var import_element208 = __toESM(require_element(), 1);
  var import_data120 = __toESM(require_data(), 1);
  var import_i18n213 = __toESM(require_i18n(), 1);
  var import_components188 = __toESM(require_components(), 1);

  // packages/editor/build-module/components/post-author/hook.mjs
  var import_i18n212 = __toESM(require_i18n(), 1);
  var import_element207 = __toESM(require_element(), 1);
  var import_data119 = __toESM(require_data(), 1);
  var import_html_entities19 = __toESM(require_html_entities(), 1);
  var import_core_data77 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/post-author/constants.mjs
  var BASE_QUERY = {
    _fields: "id,name",
    context: "view"
    // Allows non-admins to perform requests.
  };
  var AUTHORS_QUERY = {
    who: "authors",
    per_page: 100,
    ...BASE_QUERY
  };

  // packages/editor/build-module/components/post-author/hook.mjs
  function useAuthorsQuery(search) {
    const { authorId, authors, postAuthor, isLoading } = (0, import_data119.useSelect)(
      (select7) => {
        const { getUser, getUsers, isResolving } = select7(import_core_data77.store);
        const { getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
        const _authorId = getEditedPostAttribute2("author");
        const query = { ...AUTHORS_QUERY };
        if (search) {
          query.search = search;
          query.search_columns = ["name"];
        }
        return {
          authorId: _authorId,
          authors: getUsers(query),
          postAuthor: getUser(_authorId, BASE_QUERY),
          isLoading: isResolving("getUsers", [query])
        };
      },
      [search]
    );
    const authorOptions = (0, import_element207.useMemo)(() => {
      const fetchedAuthors = (authors ?? []).map((author) => {
        return {
          value: author.id,
          label: (0, import_html_entities19.decodeEntities)(author.name)
        };
      });
      const foundAuthor = fetchedAuthors.findIndex(
        ({ value }) => postAuthor?.id === value
      );
      let currentAuthor = [];
      if (foundAuthor < 0 && postAuthor) {
        currentAuthor = [
          {
            value: postAuthor.id,
            label: (0, import_html_entities19.decodeEntities)(postAuthor.name)
          }
        ];
      } else if (foundAuthor < 0 && !postAuthor) {
        currentAuthor = [
          {
            value: 0,
            label: (0, import_i18n212.__)("(No author)")
          }
        ];
      }
      return [...currentAuthor, ...fetchedAuthors];
    }, [authors, postAuthor]);
    return { authorId, authorOptions, postAuthor, isLoading };
  }

  // packages/editor/build-module/components/post-author/combobox.mjs
  var import_jsx_runtime375 = __toESM(require_jsx_runtime(), 1);
  function PostAuthorCombobox() {
    const [fieldValue, setFieldValue] = (0, import_element208.useState)();
    const { editPost: editPost2 } = (0, import_data120.useDispatch)(store3);
    const { authorId, authorOptions, isLoading } = useAuthorsQuery(fieldValue);
    const handleSelect = (postAuthorId) => {
      if (!postAuthorId) {
        return;
      }
      editPost2({ author: postAuthorId });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime375.jsx)(
      import_components188.ComboboxControl,
      {
        __next40pxDefaultSize: true,
        label: (0, import_i18n213.__)("Author"),
        options: authorOptions,
        value: authorId,
        onFilterValueChange: (0, import_compose40.debounce)(setFieldValue, 300),
        onChange: handleSelect,
        allowReset: false,
        hideLabelFromVision: true,
        isLoading
      }
    );
  }

  // packages/editor/build-module/components/post-author/select.mjs
  var import_i18n214 = __toESM(require_i18n(), 1);
  var import_data121 = __toESM(require_data(), 1);
  var import_components189 = __toESM(require_components(), 1);
  var import_jsx_runtime376 = __toESM(require_jsx_runtime(), 1);
  function PostAuthorSelect() {
    const { editPost: editPost2 } = (0, import_data121.useDispatch)(store3);
    const { authorId, authorOptions } = useAuthorsQuery();
    const setAuthorId = (value) => {
      const author = Number(value);
      editPost2({ author });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(
      import_components189.SelectControl,
      {
        __next40pxDefaultSize: true,
        className: "post-author-selector",
        label: (0, import_i18n214.__)("Author"),
        options: authorOptions,
        onChange: setAuthorId,
        value: authorId,
        hideLabelFromVision: true
      }
    );
  }

  // packages/editor/build-module/components/post-author/index.mjs
  var import_jsx_runtime377 = __toESM(require_jsx_runtime(), 1);
  var minimumUsersForCombobox = 25;
  function PostAuthor() {
    const showCombobox = (0, import_data122.useSelect)((select7) => {
      const authors = select7(import_core_data78.store).getUsers(AUTHORS_QUERY);
      return authors?.length >= minimumUsersForCombobox;
    }, []);
    if (showCombobox) {
      return /* @__PURE__ */ (0, import_jsx_runtime377.jsx)(PostAuthorCombobox, {});
    }
    return /* @__PURE__ */ (0, import_jsx_runtime377.jsx)(PostAuthorSelect, {});
  }
  var post_author_default = PostAuthor;

  // packages/editor/build-module/components/post-author/check.mjs
  var import_data123 = __toESM(require_data(), 1);
  var import_jsx_runtime378 = __toESM(require_jsx_runtime(), 1);
  function PostAuthorCheck({ children }) {
    const { hasAssignAuthorAction } = (0, import_data123.useSelect)((select7) => {
      const post2 = select7(store3).getCurrentPost();
      const canAssignAuthor = post2?._links?.["wp:action-assign-author"] ? true : false;
      return {
        hasAssignAuthorAction: canAssignAuthor
      };
    }, []);
    if (!hasAssignAuthorAction) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime378.jsx)(post_type_support_check_default, { supportKeys: "author", children });
  }

  // packages/editor/build-module/components/post-author/panel.mjs
  var import_i18n215 = __toESM(require_i18n(), 1);
  var import_components190 = __toESM(require_components(), 1);
  var import_element209 = __toESM(require_element(), 1);
  var import_html_entities20 = __toESM(require_html_entities(), 1);
  var import_block_editor51 = __toESM(require_block_editor(), 1);
  var import_data124 = __toESM(require_data(), 1);
  var import_core_data79 = __toESM(require_core_data(), 1);
  var import_jsx_runtime379 = __toESM(require_jsx_runtime(), 1);
  function PostAuthorToggle({ isOpen: isOpen2, onClick }) {
    const { postAuthor } = (0, import_data124.useSelect)((select7) => {
      const id = select7(store3).getEditedPostAttribute("author");
      return {
        postAuthor: select7(import_core_data79.store).getUser(id, BASE_QUERY)
      };
    }, []);
    const authorName = (0, import_html_entities20.decodeEntities)(postAuthor?.name) || (0, import_i18n215.__)("(No author)");
    return /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(
      import_components190.Button,
      {
        size: "compact",
        variant: "tertiary",
        "aria-expanded": isOpen2,
        "aria-label": (
          // translators: %s: Author name.
          (0, import_i18n215.sprintf)((0, import_i18n215.__)("Change author: %s"), authorName)
        ),
        onClick,
        children: authorName
      }
    );
  }
  function PostAuthor2() {
    const [popoverAnchor, setPopoverAnchor] = (0, import_element209.useState)(null);
    const popoverProps = (0, import_element209.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(PostAuthorCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(post_panel_row_default, { label: (0, import_i18n215.__)("Author"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(
      import_components190.Dropdown,
      {
        popoverProps,
        contentClassName: "editor-post-author__panel-dialog",
        focusOnMount: true,
        renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(
          PostAuthorToggle,
          {
            isOpen: isOpen2,
            onClick: onToggle
          }
        ),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)("div", { className: "editor-post-author", children: [
          /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(
            import_block_editor51.__experimentalInspectorPopoverHeader,
            {
              title: (0, import_i18n215.__)("Author"),
              onClose
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(post_author_default, { onClose })
        ] })
      }
    ) }) });
  }
  var panel_default = PostAuthor2;

  // packages/editor/build-module/components/post-comments/index.mjs
  var import_i18n216 = __toESM(require_i18n(), 1);
  var import_components191 = __toESM(require_components(), 1);
  var import_data125 = __toESM(require_data(), 1);
  var import_jsx_runtime380 = __toESM(require_jsx_runtime(), 1);
  var COMMENT_OPTIONS = [
    {
      label: (0, import_i18n216._x)("Open", 'Adjective: e.g. "Comments are open"'),
      value: "open",
      description: (0, import_i18n216.__)("Visitors can add new comments and replies.")
    },
    {
      label: (0, import_i18n216.__)("Closed"),
      value: "closed",
      description: [
        (0, import_i18n216.__)("Visitors cannot add new comments or replies."),
        (0, import_i18n216.__)("Existing comments remain visible.")
      ].join(" ")
    }
  ];
  function PostComments() {
    const commentStatus = (0, import_data125.useSelect)(
      (select7) => select7(store3).getEditedPostAttribute("comment_status") ?? "open",
      []
    );
    const { editPost: editPost2 } = (0, import_data125.useDispatch)(store3);
    const handleStatus = (newCommentStatus) => editPost2({
      comment_status: newCommentStatus
    });
    return /* @__PURE__ */ (0, import_jsx_runtime380.jsx)("form", { children: /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(import_components191.__experimentalVStack, { spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(
      import_components191.RadioControl,
      {
        className: "editor-change-status__options",
        hideLabelFromVision: true,
        label: (0, import_i18n216.__)("Comment status"),
        options: COMMENT_OPTIONS,
        onChange: handleStatus,
        selected: commentStatus
      }
    ) }) });
  }
  var post_comments_default = PostComments;

  // packages/editor/build-module/components/post-discussion/panel.mjs
  var import_i18n218 = __toESM(require_i18n(), 1);
  var import_components193 = __toESM(require_components(), 1);
  var import_data127 = __toESM(require_data(), 1);
  var import_element210 = __toESM(require_element(), 1);
  var import_block_editor52 = __toESM(require_block_editor(), 1);
  var import_core_data80 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/post-pingbacks/index.mjs
  var import_i18n217 = __toESM(require_i18n(), 1);
  var import_components192 = __toESM(require_components(), 1);
  var import_data126 = __toESM(require_data(), 1);
  var import_jsx_runtime381 = __toESM(require_jsx_runtime(), 1);
  function PostPingbacks() {
    const pingStatus = (0, import_data126.useSelect)(
      (select7) => select7(store3).getEditedPostAttribute("ping_status") ?? "open",
      []
    );
    const { editPost: editPost2 } = (0, import_data126.useDispatch)(store3);
    const onTogglePingback = () => editPost2({
      ping_status: pingStatus === "open" ? "closed" : "open"
    });
    return /* @__PURE__ */ (0, import_jsx_runtime381.jsx)(
      import_components192.CheckboxControl,
      {
        label: (0, import_i18n217.__)("Enable pingbacks & trackbacks"),
        checked: pingStatus === "open",
        onChange: onTogglePingback,
        help: /* @__PURE__ */ (0, import_jsx_runtime381.jsx)(
          import_components192.ExternalLink,
          {
            href: (0, import_i18n217.__)(
              "https://wordpress.org/documentation/article/trackbacks-and-pingbacks/"
            ),
            children: (0, import_i18n217.__)("Learn more about pingbacks & trackbacks")
          }
        )
      }
    );
  }
  var post_pingbacks_default = PostPingbacks;

  // packages/editor/build-module/components/post-discussion/panel.mjs
  var import_jsx_runtime382 = __toESM(require_jsx_runtime(), 1);
  var PANEL_NAME2 = "discussion-panel";
  function ModalContents({ onClose }) {
    return /* @__PURE__ */ (0, import_jsx_runtime382.jsxs)("div", { className: "editor-post-discussion", children: [
      /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(
        import_block_editor52.__experimentalInspectorPopoverHeader,
        {
          title: (0, import_i18n218.__)("Discussion"),
          onClose
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime382.jsxs)(import_components193.__experimentalVStack, { spacing: 4, children: [
        /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(post_type_support_check_default, { supportKeys: "comments", children: /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(post_comments_default, {}) }),
        /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(post_type_support_check_default, { supportKeys: "trackbacks", children: /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(post_pingbacks_default, {}) })
      ] })
    ] });
  }
  function PostDiscussionToggle({ isOpen: isOpen2, onClick }) {
    const {
      commentStatus,
      pingStatus,
      commentsSupported,
      trackbacksSupported
    } = (0, import_data127.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
      const { getPostType } = select7(import_core_data80.store);
      const postType2 = getPostType(getEditedPostAttribute2("type"));
      return {
        commentStatus: getEditedPostAttribute2("comment_status") ?? "open",
        pingStatus: getEditedPostAttribute2("ping_status") ?? "open",
        commentsSupported: !!postType2.supports.comments,
        trackbacksSupported: !!postType2.supports.trackbacks
      };
    }, []);
    let label;
    if (commentStatus === "open") {
      if (pingStatus === "open") {
        label = (0, import_i18n218._x)("Open", 'Adjective: e.g. "Comments are open"');
      } else {
        label = trackbacksSupported ? (0, import_i18n218.__)("Comments only") : (0, import_i18n218._x)("Open", 'Adjective: e.g. "Comments are open"');
      }
    } else if (pingStatus === "open") {
      label = commentsSupported ? (0, import_i18n218.__)("Pings only") : (0, import_i18n218.__)("Pings enabled");
    } else {
      label = (0, import_i18n218.__)("Closed");
    }
    return /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(
      import_components193.Button,
      {
        size: "compact",
        className: "editor-post-discussion__panel-toggle",
        variant: "tertiary",
        "aria-label": (0, import_i18n218.__)("Change discussion options"),
        "aria-expanded": isOpen2,
        onClick,
        children: label
      }
    );
  }
  function PostDiscussionPanel() {
    const { isEnabled } = (0, import_data127.useSelect)((select7) => {
      const { isEditorPanelEnabled: isEditorPanelEnabled2 } = select7(store3);
      return {
        isEnabled: isEditorPanelEnabled2(PANEL_NAME2)
      };
    }, []);
    const [popoverAnchor, setPopoverAnchor] = (0, import_element210.useState)(null);
    const popoverProps = (0, import_element210.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    if (!isEnabled) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(post_type_support_check_default, { supportKeys: ["comments", "trackbacks"], children: /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(post_panel_row_default, { label: (0, import_i18n218.__)("Discussion"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(
      import_components193.Dropdown,
      {
        popoverProps,
        className: "editor-post-discussion__panel-dropdown",
        contentClassName: "editor-post-discussion__panel-dialog",
        focusOnMount: true,
        renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(
          PostDiscussionToggle,
          {
            isOpen: isOpen2,
            onClick: onToggle
          }
        ),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(ModalContents, { onClose })
      }
    ) }) });
  }

  // packages/editor/build-module/components/post-excerpt/index.mjs
  var import_i18n219 = __toESM(require_i18n(), 1);
  var import_components194 = __toESM(require_components(), 1);
  var import_data128 = __toESM(require_data(), 1);
  var import_element211 = __toESM(require_element(), 1);
  var import_html_entities21 = __toESM(require_html_entities(), 1);
  var import_jsx_runtime383 = __toESM(require_jsx_runtime(), 1);
  function PostExcerpt({
    hideLabelFromVision = false,
    updateOnBlur = false
  }) {
    const { excerpt, shouldUseDescriptionLabel, usedAttribute } = (0, import_data128.useSelect)(
      (select7) => {
        const { getCurrentPostType: getCurrentPostType2, getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
        const postType2 = getCurrentPostType2();
        const _usedAttribute = [
          "wp_template",
          "wp_template_part"
        ].includes(postType2) ? "description" : "excerpt";
        return {
          excerpt: getEditedPostAttribute2(_usedAttribute),
          // There are special cases where we want to label the excerpt as a description.
          shouldUseDescriptionLabel: [
            "wp_template",
            "wp_template_part",
            "wp_block"
          ].includes(postType2),
          usedAttribute: _usedAttribute
        };
      },
      []
    );
    const { editPost: editPost2 } = (0, import_data128.useDispatch)(store3);
    const [localExcerpt, setLocalExcerpt] = (0, import_element211.useState)(
      (0, import_html_entities21.decodeEntities)(excerpt)
    );
    const updatePost2 = (value) => {
      editPost2({ [usedAttribute]: value });
    };
    const label = shouldUseDescriptionLabel ? (0, import_i18n219.__)("Write a description (optional)") : (0, import_i18n219.__)("Write an excerpt (optional)");
    return /* @__PURE__ */ (0, import_jsx_runtime383.jsx)("div", { className: "editor-post-excerpt", children: /* @__PURE__ */ (0, import_jsx_runtime383.jsx)(
      import_components194.TextareaControl,
      {
        label,
        hideLabelFromVision,
        className: "editor-post-excerpt__textarea",
        onChange: updateOnBlur ? setLocalExcerpt : updatePost2,
        onBlur: updateOnBlur ? () => updatePost2(localExcerpt) : void 0,
        value: updateOnBlur ? localExcerpt : excerpt,
        help: !shouldUseDescriptionLabel ? /* @__PURE__ */ (0, import_jsx_runtime383.jsx)(
          import_components194.ExternalLink,
          {
            href: (0, import_i18n219.__)(
              "https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt"
            ),
            children: (0, import_i18n219.__)("Learn more about manual excerpts")
          }
        ) : (0, import_i18n219.__)("Write a description")
      }
    ) });
  }

  // packages/editor/build-module/components/post-excerpt/check.mjs
  var import_jsx_runtime384 = __toESM(require_jsx_runtime(), 1);
  function PostExcerptCheck({ children }) {
    return /* @__PURE__ */ (0, import_jsx_runtime384.jsx)(post_type_support_check_default, { supportKeys: "excerpt", children });
  }
  var check_default3 = PostExcerptCheck;

  // packages/editor/build-module/components/post-excerpt/panel.mjs
  var import_i18n220 = __toESM(require_i18n(), 1);
  var import_components196 = __toESM(require_components(), 1);
  var import_data129 = __toESM(require_data(), 1);
  var import_element212 = __toESM(require_element(), 1);
  var import_block_editor53 = __toESM(require_block_editor(), 1);
  var import_core_data81 = __toESM(require_core_data(), 1);
  var import_html_entities22 = __toESM(require_html_entities(), 1);

  // packages/editor/build-module/components/post-excerpt/plugin.mjs
  var import_components195 = __toESM(require_components(), 1);
  var import_jsx_runtime385 = __toESM(require_jsx_runtime(), 1);
  var { Fill: Fill9, Slot: Slot9 } = (0, import_components195.createSlotFill)("PluginPostExcerpt");
  var PluginPostExcerpt = ({ children, className }) => {
    return /* @__PURE__ */ (0, import_jsx_runtime385.jsx)(Fill9, { children: /* @__PURE__ */ (0, import_jsx_runtime385.jsx)(import_components195.PanelRow, { className, children }) });
  };
  PluginPostExcerpt.Slot = Slot9;
  var plugin_default = PluginPostExcerpt;

  // packages/editor/build-module/components/post-excerpt/panel.mjs
  var import_jsx_runtime386 = __toESM(require_jsx_runtime(), 1);
  var PANEL_NAME3 = "post-excerpt";
  function ExcerptPanel() {
    const { isOpened, isEnabled, postType: postType2 } = (0, import_data129.useSelect)((select7) => {
      const {
        isEditorPanelOpened: isEditorPanelOpened2,
        isEditorPanelEnabled: isEditorPanelEnabled2,
        getCurrentPostType: getCurrentPostType2
      } = select7(store3);
      return {
        isOpened: isEditorPanelOpened2(PANEL_NAME3),
        isEnabled: isEditorPanelEnabled2(PANEL_NAME3),
        postType: getCurrentPostType2()
      };
    }, []);
    const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data129.useDispatch)(store3);
    const toggleExcerptPanel = () => toggleEditorPanelOpened2(PANEL_NAME3);
    if (!isEnabled) {
      return null;
    }
    const shouldUseDescriptionLabel = [
      "wp_template",
      "wp_template_part",
      "wp_block"
    ].includes(postType2);
    return /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(
      import_components196.PanelBody,
      {
        title: shouldUseDescriptionLabel ? (0, import_i18n220.__)("Description") : (0, import_i18n220.__)("Excerpt"),
        opened: isOpened,
        onToggle: toggleExcerptPanel,
        children: /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(plugin_default.Slot, { children: (fills) => /* @__PURE__ */ (0, import_jsx_runtime386.jsxs)(import_jsx_runtime386.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(PostExcerpt, {}),
          fills
        ] }) })
      }
    );
  }
  function PostExcerptPanel() {
    return /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(check_default3, { children: /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(ExcerptPanel, {}) });
  }
  function PrivatePostExcerptPanel() {
    return /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(check_default3, { children: /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(PrivateExcerpt, {}) });
  }
  function PrivateExcerpt() {
    const { shouldRender, excerpt, shouldBeUsedAsDescription, allowEditing } = (0, import_data129.useSelect)((select7) => {
      const {
        getCurrentPostType: getCurrentPostType2,
        getCurrentPostId: getCurrentPostId2,
        getEditedPostAttribute: getEditedPostAttribute2,
        isEditorPanelEnabled: isEditorPanelEnabled2
      } = select7(store3);
      const postType2 = getCurrentPostType2();
      const isTemplateOrTemplatePart2 = [
        "wp_template",
        "wp_template_part"
      ].includes(postType2);
      const isPattern = postType2 === "wp_block";
      const _shouldBeUsedAsDescription = isTemplateOrTemplatePart2 || isPattern;
      const _usedAttribute = isTemplateOrTemplatePart2 ? "description" : "excerpt";
      const _excerpt = getEditedPostAttribute2(_usedAttribute);
      const template2 = isTemplateOrTemplatePart2 && select7(import_core_data81.store).getEntityRecord(
        "postType",
        postType2,
        getCurrentPostId2()
      );
      const fallback = !_excerpt && isTemplateOrTemplatePart2 ? getTemplateInfo({
        template: template2,
        templateTypes: select7(import_core_data81.store).getCurrentTheme()?.default_template_types
      })?.description : void 0;
      const _shouldRender = isEditorPanelEnabled2(PANEL_NAME3) || _shouldBeUsedAsDescription;
      return {
        excerpt: _excerpt ?? fallback,
        shouldRender: _shouldRender,
        shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
        // If we should render, allow editing for all post types that are not used as description.
        // For the rest allow editing only for user generated entities.
        allowEditing: _shouldRender && (!_shouldBeUsedAsDescription || isPattern || template2 && template2.source === TEMPLATE_ORIGINS.custom && !template2.has_theme_file && template2.is_custom)
      };
    }, []);
    const [popoverAnchor, setPopoverAnchor] = (0, import_element212.useState)(null);
    const label = shouldBeUsedAsDescription ? (0, import_i18n220.__)("Description") : (0, import_i18n220.__)("Excerpt");
    const popoverProps = (0, import_element212.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        "aria-label": label,
        headerTitle: label,
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor, label]
    );
    if (!shouldRender) {
      return false;
    }
    const excerptText = !!excerpt && /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(import_components196.__experimentalText, { align: "left", numberOfLines: 4, truncate: allowEditing, children: (0, import_html_entities22.decodeEntities)(excerpt) });
    if (!allowEditing) {
      return excerptText;
    }
    const excerptPlaceholder = shouldBeUsedAsDescription ? (0, import_i18n220.__)("Add a description\u2026") : (0, import_i18n220.__)("Add an excerpt\u2026");
    const triggerEditLabel = shouldBeUsedAsDescription ? (0, import_i18n220.__)("Edit description") : (0, import_i18n220.__)("Edit excerpt");
    return /* @__PURE__ */ (0, import_jsx_runtime386.jsxs)(import_components196.__experimentalVStack, { children: [
      excerptText,
      /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(
        import_components196.Dropdown,
        {
          className: "editor-post-excerpt__dropdown",
          contentClassName: "editor-post-excerpt__dropdown__content",
          popoverProps,
          focusOnMount: true,
          ref: setPopoverAnchor,
          renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(
            import_components196.Button,
            {
              __next40pxDefaultSize: true,
              onClick: onToggle,
              variant: "link",
              children: excerptText ? triggerEditLabel : excerptPlaceholder
            }
          ),
          renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime386.jsxs)(import_jsx_runtime386.Fragment, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(
              import_block_editor53.__experimentalInspectorPopoverHeader,
              {
                title: label,
                onClose
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(import_components196.__experimentalVStack, { spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(plugin_default.Slot, { children: (fills) => /* @__PURE__ */ (0, import_jsx_runtime386.jsxs)(import_jsx_runtime386.Fragment, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(
                PostExcerpt,
                {
                  hideLabelFromVision: true,
                  updateOnBlur: true
                }
              ),
              fills
            ] }) }) })
          ] })
        }
      )
    ] });
  }

  // packages/editor/build-module/components/post-featured-image/index.mjs
  var import_i18n221 = __toESM(require_i18n(), 1);
  var import_hooks47 = __toESM(require_hooks(), 1);
  var import_components197 = __toESM(require_components(), 1);
  var import_blob3 = __toESM(require_blob(), 1);
  var import_element213 = __toESM(require_element(), 1);
  var import_compose41 = __toESM(require_compose(), 1);
  var import_data131 = __toESM(require_data(), 1);
  var import_block_editor54 = __toESM(require_block_editor(), 1);
  var import_core_data83 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/theme-support-check/index.mjs
  var import_data130 = __toESM(require_data(), 1);
  var import_core_data82 = __toESM(require_core_data(), 1);
  function ThemeSupportCheck({ children, supportKeys }) {
    const { postType: postType2, themeSupports } = (0, import_data130.useSelect)((select7) => {
      return {
        postType: select7(store3).getEditedPostAttribute("type"),
        themeSupports: select7(import_core_data82.store).getThemeSupports()
      };
    }, []);
    const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some((key) => {
      const supported = themeSupports?.[key] ?? false;
      if ("post-thumbnails" === key && Array.isArray(supported)) {
        return supported.includes(postType2);
      }
      return supported;
    });
    if (!isSupported) {
      return null;
    }
    return children;
  }

  // packages/editor/build-module/components/post-featured-image/check.mjs
  var import_jsx_runtime387 = __toESM(require_jsx_runtime(), 1);
  function PostFeaturedImageCheck({ children }) {
    return /* @__PURE__ */ (0, import_jsx_runtime387.jsx)(ThemeSupportCheck, { supportKeys: "post-thumbnails", children: /* @__PURE__ */ (0, import_jsx_runtime387.jsx)(post_type_support_check_default, { supportKeys: "thumbnail", children }) });
  }
  var check_default4 = PostFeaturedImageCheck;

  // packages/editor/build-module/components/post-featured-image/index.mjs
  var import_jsx_runtime388 = __toESM(require_jsx_runtime(), 1);
  var ALLOWED_MEDIA_TYPES = ["image"];
  var DEFAULT_FEATURE_IMAGE_LABEL = (0, import_i18n221.__)("Featured image");
  var DEFAULT_SET_FEATURE_IMAGE_LABEL = (0, import_i18n221.__)("Add a featured image");
  var instructions = /* @__PURE__ */ (0, import_jsx_runtime388.jsx)("p", { children: (0, import_i18n221.__)(
    "To edit the featured image, you need permission to upload media."
  ) });
  function getMediaDetails(media, postId2) {
    if (!media) {
      return {};
    }
    const defaultSize = (0, import_hooks47.applyFilters)(
      "editor.PostFeaturedImage.imageSize",
      "large",
      media.id,
      postId2
    );
    if (defaultSize in (media?.media_details?.sizes ?? {})) {
      return {
        mediaWidth: media.media_details.sizes[defaultSize].width,
        mediaHeight: media.media_details.sizes[defaultSize].height,
        mediaSourceUrl: media.media_details.sizes[defaultSize].source_url
      };
    }
    const fallbackSize = (0, import_hooks47.applyFilters)(
      "editor.PostFeaturedImage.imageSize",
      "thumbnail",
      media.id,
      postId2
    );
    if (fallbackSize in (media?.media_details?.sizes ?? {})) {
      return {
        mediaWidth: media.media_details.sizes[fallbackSize].width,
        mediaHeight: media.media_details.sizes[fallbackSize].height,
        mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url
      };
    }
    return {
      mediaWidth: media.media_details.width,
      mediaHeight: media.media_details.height,
      mediaSourceUrl: media.source_url
    };
  }
  function PostFeaturedImage({
    currentPostId,
    featuredImageId,
    onUpdateImage,
    onRemoveImage,
    media,
    postType: postType2,
    noticeUI,
    noticeOperations,
    isRequestingFeaturedImageMedia
  }) {
    const returnsFocusRef = (0, import_element213.useRef)(false);
    const [isLoading, setIsLoading] = (0, import_element213.useState)(false);
    const { getSettings: getSettings11 } = (0, import_data131.useSelect)(import_block_editor54.store);
    const { mediaSourceUrl } = getMediaDetails(media, currentPostId);
    function onDropFiles(filesList) {
      getSettings11().mediaUpload({
        allowedTypes: ALLOWED_MEDIA_TYPES,
        filesList,
        onFileChange([image]) {
          if ((0, import_blob3.isBlobURL)(image?.url)) {
            setIsLoading(true);
            return;
          }
          if (image) {
            onUpdateImage(image);
          }
          setIsLoading(false);
        },
        onError(message2) {
          noticeOperations.removeAllNotices();
          noticeOperations.createErrorNotice(message2);
        },
        multiple: false
      });
    }
    function getImageDescription(imageMedia) {
      if (imageMedia.alt_text) {
        return (0, import_i18n221.sprintf)(
          // Translators: %s: The selected image alt text.
          (0, import_i18n221.__)("Current image: %s"),
          imageMedia.alt_text
        );
      }
      return (0, import_i18n221.sprintf)(
        // Translators: %s: The selected image filename.
        (0, import_i18n221.__)(
          "The current image has no alternative text. The file name is: %s"
        ),
        imageMedia.media_details.sizes?.full?.file || imageMedia.slug
      );
    }
    function returnFocus(node) {
      if (returnsFocusRef.current && node) {
        node.focus();
        returnsFocusRef.current = false;
      }
    }
    const isMissingMedia = !isRequestingFeaturedImageMedia && !!featuredImageId && !media;
    return /* @__PURE__ */ (0, import_jsx_runtime388.jsxs)(check_default4, { children: [
      noticeUI,
      /* @__PURE__ */ (0, import_jsx_runtime388.jsxs)("div", { className: "editor-post-featured-image", children: [
        media && /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(
          "div",
          {
            id: `editor-post-featured-image-${featuredImageId}-describedby`,
            className: "hidden",
            children: getImageDescription(media)
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(import_block_editor54.MediaUploadCheck, { fallback: instructions, children: /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(
          import_block_editor54.MediaUpload,
          {
            title: postType2?.labels?.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
            onSelect: onUpdateImage,
            unstableFeaturedImageFlow: true,
            allowedTypes: ALLOWED_MEDIA_TYPES,
            modalClass: "editor-post-featured-image__media-modal",
            render: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime388.jsxs)("div", { className: "editor-post-featured-image__container", children: [
              isMissingMedia ? /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(
                import_components197.Notice,
                {
                  status: "warning",
                  isDismissible: false,
                  children: (0, import_i18n221.__)(
                    "Could not retrieve the featured image data."
                  )
                }
              ) : /* @__PURE__ */ (0, import_jsx_runtime388.jsxs)(
                import_components197.Button,
                {
                  __next40pxDefaultSize: true,
                  ref: returnFocus,
                  className: !featuredImageId ? "editor-post-featured-image__toggle" : "editor-post-featured-image__preview",
                  onClick: open,
                  "aria-label": !featuredImageId ? null : (0, import_i18n221.__)(
                    "Edit or replace the featured image"
                  ),
                  "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-${featuredImageId}-describedby`,
                  "aria-haspopup": "dialog",
                  disabled: isLoading,
                  accessibleWhenDisabled: true,
                  children: [
                    !!featuredImageId && media && /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(
                      "img",
                      {
                        className: "editor-post-featured-image__preview-image",
                        src: mediaSourceUrl,
                        alt: getImageDescription(
                          media
                        )
                      }
                    ),
                    (isLoading || isRequestingFeaturedImageMedia) && /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(import_components197.Spinner, {}),
                    !featuredImageId && !isLoading && (postType2?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)
                  ]
                }
              ),
              !!featuredImageId && /* @__PURE__ */ (0, import_jsx_runtime388.jsxs)(
                import_components197.__experimentalHStack,
                {
                  className: clsx_default(
                    "editor-post-featured-image__actions",
                    {
                      "editor-post-featured-image__actions-missing-image": isMissingMedia,
                      "editor-post-featured-image__actions-is-requesting-image": isRequestingFeaturedImageMedia
                    }
                  ),
                  children: [
                    /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(
                      import_components197.Button,
                      {
                        __next40pxDefaultSize: true,
                        className: "editor-post-featured-image__action",
                        onClick: open,
                        "aria-haspopup": "dialog",
                        variant: isMissingMedia ? "secondary" : void 0,
                        children: (0, import_i18n221.__)("Replace")
                      }
                    ),
                    /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(
                      import_components197.Button,
                      {
                        __next40pxDefaultSize: true,
                        className: "editor-post-featured-image__action",
                        onClick: () => {
                          onRemoveImage();
                          returnsFocusRef.current = true;
                        },
                        variant: isMissingMedia ? "secondary" : void 0,
                        isDestructive: isMissingMedia,
                        children: (0, import_i18n221.__)("Remove")
                      }
                    )
                  ]
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(import_components197.DropZone, { onFilesDrop: onDropFiles })
            ] }),
            value: featuredImageId
          }
        ) })
      ] })
    ] });
  }
  var applyWithSelect = (0, import_data131.withSelect)((select7) => {
    const { getEntityRecord, getPostType, hasFinishedResolution } = select7(import_core_data83.store);
    const { getCurrentPostId: getCurrentPostId2, getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
    const featuredImageId = getEditedPostAttribute2("featured_media");
    return {
      media: featuredImageId ? getEntityRecord("postType", "attachment", featuredImageId, {
        context: "view"
      }) : null,
      currentPostId: getCurrentPostId2(),
      postType: getPostType(getEditedPostAttribute2("type")),
      featuredImageId,
      isRequestingFeaturedImageMedia: !!featuredImageId && !hasFinishedResolution("getEntityRecord", [
        "postType",
        "attachment",
        featuredImageId,
        { context: "view" }
      ])
    };
  });
  var applyWithDispatch = (0, import_data131.withDispatch)(
    (dispatch7, { noticeOperations }, { select: select7 }) => {
      const { editPost: editPost2 } = dispatch7(store3);
      return {
        onUpdateImage(image) {
          editPost2({ featured_media: image.id });
        },
        onDropImage(filesList) {
          select7(import_block_editor54.store).getSettings().mediaUpload({
            allowedTypes: ["image"],
            filesList,
            onFileChange([image]) {
              editPost2({ featured_media: image.id });
            },
            onError(message2) {
              noticeOperations.removeAllNotices();
              noticeOperations.createErrorNotice(message2);
            },
            multiple: false
          });
        },
        onRemoveImage() {
          editPost2({ featured_media: 0 });
        }
      };
    }
  );
  var post_featured_image_default = (0, import_compose41.compose)(
    import_components197.withNotices,
    applyWithSelect,
    applyWithDispatch,
    (0, import_components197.withFilters)("editor.PostFeaturedImage")
  )(PostFeaturedImage);

  // packages/editor/build-module/components/post-featured-image/panel.mjs
  var import_i18n222 = __toESM(require_i18n(), 1);
  var import_components198 = __toESM(require_components(), 1);
  var import_data132 = __toESM(require_data(), 1);
  var import_core_data84 = __toESM(require_core_data(), 1);
  var import_jsx_runtime389 = __toESM(require_jsx_runtime(), 1);
  var PANEL_NAME4 = "featured-image";
  function PostFeaturedImagePanel({ withPanelBody = true }) {
    const { postType: postType2, isEnabled, isOpened } = (0, import_data132.useSelect)((select7) => {
      const {
        getEditedPostAttribute: getEditedPostAttribute2,
        isEditorPanelEnabled: isEditorPanelEnabled2,
        isEditorPanelOpened: isEditorPanelOpened2
      } = select7(store3);
      const { getPostType } = select7(import_core_data84.store);
      return {
        postType: getPostType(getEditedPostAttribute2("type")),
        isEnabled: isEditorPanelEnabled2(PANEL_NAME4),
        isOpened: isEditorPanelOpened2(PANEL_NAME4)
      };
    }, []);
    const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data132.useDispatch)(store3);
    if (!isEnabled) {
      return null;
    }
    if (!withPanelBody) {
      return /* @__PURE__ */ (0, import_jsx_runtime389.jsx)(check_default4, { children: /* @__PURE__ */ (0, import_jsx_runtime389.jsx)(post_featured_image_default, {}) });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime389.jsx)(check_default4, { children: /* @__PURE__ */ (0, import_jsx_runtime389.jsx)(
      import_components198.PanelBody,
      {
        title: postType2?.labels?.featured_image ?? (0, import_i18n222.__)("Featured image"),
        opened: isOpened,
        onToggle: () => toggleEditorPanelOpened2(PANEL_NAME4),
        children: /* @__PURE__ */ (0, import_jsx_runtime389.jsx)(post_featured_image_default, {})
      }
    ) });
  }

  // packages/editor/build-module/components/post-format/index.mjs
  var import_i18n223 = __toESM(require_i18n(), 1);
  var import_components199 = __toESM(require_components(), 1);
  var import_data134 = __toESM(require_data(), 1);
  var import_compose42 = __toESM(require_compose(), 1);
  var import_core_data85 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/post-format/check.mjs
  var import_data133 = __toESM(require_data(), 1);
  var import_jsx_runtime390 = __toESM(require_jsx_runtime(), 1);
  function PostFormatCheck({ children }) {
    const disablePostFormats = (0, import_data133.useSelect)(
      (select7) => select7(store3).getEditorSettings().disablePostFormats,
      []
    );
    if (disablePostFormats) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(post_type_support_check_default, { supportKeys: "post-formats", children });
  }

  // packages/editor/build-module/components/post-format/index.mjs
  var import_jsx_runtime391 = __toESM(require_jsx_runtime(), 1);
  var POST_FORMATS2 = [
    { id: "aside", caption: (0, import_i18n223.__)("Aside") },
    { id: "audio", caption: (0, import_i18n223.__)("Audio") },
    { id: "chat", caption: (0, import_i18n223.__)("Chat") },
    { id: "gallery", caption: (0, import_i18n223.__)("Gallery") },
    { id: "image", caption: (0, import_i18n223.__)("Image") },
    { id: "link", caption: (0, import_i18n223.__)("Link") },
    { id: "quote", caption: (0, import_i18n223.__)("Quote") },
    { id: "standard", caption: (0, import_i18n223.__)("Standard") },
    { id: "status", caption: (0, import_i18n223.__)("Status") },
    { id: "video", caption: (0, import_i18n223.__)("Video") }
  ].sort((a3, b3) => {
    const normalizedA = a3.caption.toUpperCase();
    const normalizedB = b3.caption.toUpperCase();
    if (normalizedA < normalizedB) {
      return -1;
    }
    if (normalizedA > normalizedB) {
      return 1;
    }
    return 0;
  });
  function PostFormat() {
    const instanceId = (0, import_compose42.useInstanceId)(PostFormat);
    const postFormatSelectorId = `post-format-selector-${instanceId}`;
    const { postFormat, suggestedFormat, supportedFormats } = (0, import_data134.useSelect)(
      (select7) => {
        const { getEditedPostAttribute: getEditedPostAttribute2, getSuggestedPostFormat: getSuggestedPostFormat2 } = select7(store3);
        const _postFormat = getEditedPostAttribute2("format");
        const themeSupports = select7(import_core_data85.store).getThemeSupports();
        return {
          postFormat: _postFormat ?? "standard",
          suggestedFormat: getSuggestedPostFormat2(),
          supportedFormats: themeSupports.formats
        };
      },
      []
    );
    const formats = POST_FORMATS2.filter((format6) => {
      return supportedFormats?.includes(format6.id) || postFormat === format6.id;
    });
    const suggestion = formats.find(
      (format6) => format6.id === suggestedFormat
    );
    const { editPost: editPost2 } = (0, import_data134.useDispatch)(store3);
    const onUpdatePostFormat = (format6) => editPost2({ format: format6 });
    return /* @__PURE__ */ (0, import_jsx_runtime391.jsx)(PostFormatCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime391.jsxs)("div", { className: "editor-post-format", children: [
      /* @__PURE__ */ (0, import_jsx_runtime391.jsx)(
        import_components199.RadioControl,
        {
          className: "editor-post-format__options",
          label: (0, import_i18n223.__)("Post Format"),
          selected: postFormat,
          onChange: (format6) => onUpdatePostFormat(format6),
          id: postFormatSelectorId,
          options: formats.map((format6) => ({
            label: format6.caption,
            value: format6.id
          })),
          hideLabelFromVision: true
        }
      ),
      suggestion && suggestion.id !== postFormat && /* @__PURE__ */ (0, import_jsx_runtime391.jsx)("p", { className: "editor-post-format__suggestion", children: /* @__PURE__ */ (0, import_jsx_runtime391.jsx)(
        import_components199.Button,
        {
          __next40pxDefaultSize: true,
          variant: "link",
          onClick: () => onUpdatePostFormat(suggestion.id),
          children: (0, import_i18n223.sprintf)(
            /* translators: %s: post format */
            (0, import_i18n223.__)("Apply suggested format: %s"),
            suggestion.caption
          )
        }
      ) })
    ] }) });
  }

  // packages/editor/build-module/components/post-last-revision/index.mjs
  var import_i18n224 = __toESM(require_i18n(), 1);
  var import_components200 = __toESM(require_components(), 1);
  var import_data136 = __toESM(require_data(), 1);

  // packages/editor/build-module/components/post-last-revision/check.mjs
  var import_data135 = __toESM(require_data(), 1);
  var import_jsx_runtime392 = __toESM(require_jsx_runtime(), 1);
  function PostLastRevisionCheck({ children }) {
    const { lastRevisionId, revisionsCount } = (0, import_data135.useSelect)((select7) => {
      const { getCurrentPostLastRevisionId: getCurrentPostLastRevisionId2, getCurrentPostRevisionsCount: getCurrentPostRevisionsCount2 } = select7(store3);
      return {
        lastRevisionId: getCurrentPostLastRevisionId2(),
        revisionsCount: getCurrentPostRevisionsCount2()
      };
    }, []);
    if (!lastRevisionId || revisionsCount < 2) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime392.jsx)(post_type_support_check_default, { supportKeys: "revisions", children });
  }
  var check_default5 = PostLastRevisionCheck;

  // packages/editor/build-module/components/post-last-revision/index.mjs
  var import_jsx_runtime393 = __toESM(require_jsx_runtime(), 1);
  function usePostLastRevisionInfo() {
    return (0, import_data136.useSelect)((select7) => {
      const { getCurrentPostLastRevisionId: getCurrentPostLastRevisionId2, getCurrentPostRevisionsCount: getCurrentPostRevisionsCount2 } = select7(store3);
      return {
        lastRevisionId: getCurrentPostLastRevisionId2(),
        revisionsCount: getCurrentPostRevisionsCount2()
      };
    }, []);
  }
  function PostLastRevision() {
    const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
    const { setCurrentRevisionId: setCurrentRevisionId2 } = unlock((0, import_data136.useDispatch)(store3));
    return /* @__PURE__ */ (0, import_jsx_runtime393.jsx)(check_default5, { children: /* @__PURE__ */ (0, import_jsx_runtime393.jsx)(
      import_components200.Button,
      {
        __next40pxDefaultSize: true,
        onClick: () => setCurrentRevisionId2(lastRevisionId),
        className: "editor-post-last-revision__title",
        icon: backup_default,
        iconPosition: "right",
        text: (0, import_i18n224.sprintf)(
          /* translators: %s: number of revisions. */
          (0, import_i18n224.__)("Revisions (%s)"),
          revisionsCount
        )
      }
    ) });
  }
  function PrivatePostLastRevision() {
    const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
    const { setCurrentRevisionId: setCurrentRevisionId2 } = unlock((0, import_data136.useDispatch)(store3));
    return /* @__PURE__ */ (0, import_jsx_runtime393.jsx)(check_default5, { children: /* @__PURE__ */ (0, import_jsx_runtime393.jsx)(post_panel_row_default, { label: (0, import_i18n224.__)("Revisions"), children: /* @__PURE__ */ (0, import_jsx_runtime393.jsx)(
      import_components200.Button,
      {
        onClick: () => setCurrentRevisionId2(lastRevisionId),
        className: "editor-private-post-last-revision__button",
        text: revisionsCount,
        variant: "tertiary",
        size: "compact"
      }
    ) }) });
  }
  var post_last_revision_default = PostLastRevision;

  // packages/editor/build-module/components/post-last-revision/panel.mjs
  var import_components201 = __toESM(require_components(), 1);
  var import_jsx_runtime394 = __toESM(require_jsx_runtime(), 1);
  function PostLastRevisionPanel() {
    return /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(check_default5, { children: /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(import_components201.PanelBody, { className: "editor-post-last-revision__panel", children: /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(post_last_revision_default, {}) }) });
  }
  var panel_default2 = PostLastRevisionPanel;

  // packages/editor/build-module/components/post-locked-modal/index.mjs
  var import_i18n226 = __toESM(require_i18n(), 1);
  var import_components202 = __toESM(require_components(), 1);
  var import_data137 = __toESM(require_data(), 1);
  var import_url16 = __toESM(require_url(), 1);
  var import_element214 = __toESM(require_element(), 1);
  var import_hooks48 = __toESM(require_hooks(), 1);
  var import_compose43 = __toESM(require_compose(), 1);
  var import_core_data86 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/utils/sync-error-messages.mjs
  var import_i18n225 = __toESM(require_i18n(), 1);
  var AUTHENTICATION_FAILED = "authentication-failed";
  var CONNECTION_EXPIRED = "connection-expired";
  var CONNECTION_LIMIT_EXCEEDED = "connection-limit-exceeded";
  var DOCUMENT_SIZE_LIMIT_EXCEEDED = "document-size-limit-exceeded";
  var UNKNOWN_ERROR = "unknown-error";
  var ERROR_MESSAGES = {
    [AUTHENTICATION_FAILED]: {
      title: (0, import_i18n225.__)("Unable to connect"),
      description: (0, import_i18n225.__)(
        "Real-time collaboration couldn't verify your permissions. Check that you have access to edit this post or contact your site administrator."
      )
    },
    [CONNECTION_EXPIRED]: {
      title: (0, import_i18n225.__)("Connection expired"),
      description: (0, import_i18n225.__)(
        "Your connection to real-time collaboration has timed out. Editing is paused to prevent conflicts with other editors."
      )
    },
    [CONNECTION_LIMIT_EXCEEDED]: {
      title: (0, import_i18n225.__)("Too many editors connected"),
      description: (0, import_i18n225.__)(
        "Real-time collaboration has reached its connection limit. Try again later or contact your site administrator."
      )
    },
    // DOCUMENT_SIZE_LIMIT_EXCEEDED is not included here because it results in
    // collaboration being disabled entirely.
    [UNKNOWN_ERROR]: {
      title: (0, import_i18n225.__)("Connection lost"),
      description: (0, import_i18n225.__)(
        "The connection to real-time collaboration was interrupted. Editing is paused to prevent conflicts with other editors."
      )
    }
  };
  function getSyncErrorMessages(error2) {
    if (error2?.code && ERROR_MESSAGES[error2?.code]) {
      return ERROR_MESSAGES[error2.code];
    }
    return ERROR_MESSAGES[UNKNOWN_ERROR];
  }

  // packages/editor/build-module/components/post-locked-modal/index.mjs
  var import_jsx_runtime395 = __toESM(require_jsx_runtime(), 1);
  function CollaborationContext() {
    const { isCollaborationSupported, syncConnectionStatus } = (0, import_data137.useSelect)(
      (select7) => {
        const selectors = unlock(select7(import_core_data86.store));
        return {
          isCollaborationSupported: selectors.isCollaborationSupported(),
          syncConnectionStatus: selectors.getSyncConnectionStatus()
        };
      },
      []
    );
    if (isCollaborationSupported) {
      return null;
    }
    if (DOCUMENT_SIZE_LIMIT_EXCEEDED === syncConnectionStatus?.error?.code) {
      return /* @__PURE__ */ (0, import_jsx_runtime395.jsx)("p", { children: (0, import_i18n226.__)(
        "Because this post is too large for real-time collaboration, only one person can edit at a time."
      ) });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime395.jsx)("p", { children: (0, import_i18n226.__)(
      "Because this post uses plugins that aren\u2019t compatible with real-time collaboration, only one person can edit at a time."
    ) });
  }
  function PostLockedModal() {
    const instanceId = (0, import_compose43.useInstanceId)(PostLockedModal);
    const hookName = "core/editor/post-locked-modal-" + instanceId;
    const { autosave: autosave2, updatePostLock: updatePostLock2 } = (0, import_data137.useDispatch)(store3);
    const {
      isCollaborationEnabled,
      isLocked,
      isTakeover,
      user,
      postId: postId2,
      postLockUtils,
      activePostLock,
      postType: postType2,
      previewLink
    } = (0, import_data137.useSelect)((select7) => {
      const {
        isCollaborationEnabledForCurrentPost: isCollaborationEnabledForCurrentPost2,
        isPostLocked: isPostLocked2,
        isPostLockTakeover: isPostLockTakeover2,
        getPostLockUser: getPostLockUser2,
        getCurrentPostId: getCurrentPostId2,
        getActivePostLock: getActivePostLock2,
        getEditedPostAttribute: getEditedPostAttribute2,
        getEditedPostPreviewLink: getEditedPostPreviewLink2,
        getEditorSettings: getEditorSettings2
      } = select7(store3);
      const { getPostType } = select7(import_core_data86.store);
      return {
        isCollaborationEnabled: isCollaborationEnabledForCurrentPost2(),
        isLocked: isPostLocked2(),
        isTakeover: isPostLockTakeover2(),
        user: getPostLockUser2(),
        postId: getCurrentPostId2(),
        postLockUtils: getEditorSettings2().postLockUtils,
        activePostLock: getActivePostLock2(),
        postType: getPostType(getEditedPostAttribute2("type")),
        previewLink: getEditedPostPreviewLink2()
      };
    }, []);
    (0, import_element214.useEffect)(() => {
      function sendPostLock(data) {
        if (isLocked) {
          return;
        }
        data["wp-refresh-post-lock"] = {
          lock: activePostLock,
          post_id: postId2
        };
      }
      function receivePostLock(data) {
        if (!data["wp-refresh-post-lock"]) {
          return;
        }
        const received = data["wp-refresh-post-lock"];
        if (received.lock_error) {
          autosave2();
          updatePostLock2({
            isLocked: true,
            isTakeover: true,
            user: {
              name: received.lock_error.name,
              avatar: received.lock_error.avatar_src_2x
            }
          });
        } else if (received.new_lock) {
          updatePostLock2({
            isLocked: false,
            activePostLock: received.new_lock
          });
        }
      }
      function releasePostLock() {
        if (isLocked || !activePostLock) {
          return;
        }
        const data = new window.FormData();
        data.append("action", "wp-remove-post-lock");
        data.append("_wpnonce", postLockUtils.unlockNonce);
        data.append("post_ID", postId2);
        data.append("active_post_lock", activePostLock);
        if (window.navigator.sendBeacon) {
          window.navigator.sendBeacon(postLockUtils.ajaxUrl, data);
        } else {
          const xhr = new window.XMLHttpRequest();
          xhr.open("POST", postLockUtils.ajaxUrl, false);
          xhr.send(data);
        }
      }
      (0, import_hooks48.addAction)("heartbeat.send", hookName, sendPostLock);
      (0, import_hooks48.addAction)("heartbeat.tick", hookName, receivePostLock);
      window.addEventListener("beforeunload", releasePostLock);
      return () => {
        (0, import_hooks48.removeAction)("heartbeat.send", hookName);
        (0, import_hooks48.removeAction)("heartbeat.tick", hookName);
        window.removeEventListener("beforeunload", releasePostLock);
      };
    }, []);
    if (!isLocked) {
      return null;
    }
    if (isCollaborationEnabled) {
      return null;
    }
    const userDisplayName = user.name;
    const userAvatar = user.avatar;
    const unlockUrl = (0, import_url16.addQueryArgs)("post.php", {
      "get-post-lock": "1",
      lockKey: true,
      post: postId2,
      action: "edit",
      _wpnonce: postLockUtils.nonce
    });
    const allPostsUrl = (0, import_url16.addQueryArgs)("edit.php", {
      post_type: postType2?.slug
    });
    const allPostsLabel = (0, import_i18n226.__)("Exit editor");
    return /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(
      import_components202.Modal,
      {
        title: isTakeover ? (0, import_i18n226.__)("Someone else has taken over this post") : (0, import_i18n226.__)("This post is already being edited"),
        focusOnMount: true,
        shouldCloseOnClickOutside: false,
        shouldCloseOnEsc: false,
        isDismissible: false,
        className: "editor-post-locked-modal",
        size: "medium",
        children: /* @__PURE__ */ (0, import_jsx_runtime395.jsxs)(import_components202.__experimentalHStack, { alignment: "top", spacing: 6, children: [
          !!userAvatar && /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(
            "img",
            {
              src: userAvatar,
              alt: (0, import_i18n226.__)("Avatar"),
              className: "editor-post-locked-modal__avatar",
              width: 64,
              height: 64
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime395.jsxs)("div", { children: [
            !!isTakeover && /* @__PURE__ */ (0, import_jsx_runtime395.jsxs)(import_jsx_runtime395.Fragment, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime395.jsx)("p", { children: (0, import_element214.createInterpolateElement)(
                userDisplayName ? (0, import_i18n226.sprintf)(
                  /* translators: %s: user's display name */
                  (0, import_i18n226.__)(
                    "<strong>%s</strong> now has editing control of this post (<PreviewLink />). Don\u2019t worry, your changes up to this moment have been saved."
                  ),
                  userDisplayName
                ) : (0, import_i18n226.__)(
                  "Another user now has editing control of this post (<PreviewLink />). Don\u2019t worry, your changes up to this moment have been saved."
                ),
                {
                  strong: /* @__PURE__ */ (0, import_jsx_runtime395.jsx)("strong", {}),
                  PreviewLink: /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(import_components202.ExternalLink, { href: previewLink, children: (0, import_i18n226.__)("preview") })
                }
              ) }),
              /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(CollaborationContext, {})
            ] }),
            !isTakeover && /* @__PURE__ */ (0, import_jsx_runtime395.jsxs)(import_jsx_runtime395.Fragment, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime395.jsx)("p", { children: (0, import_element214.createInterpolateElement)(
                userDisplayName ? (0, import_i18n226.sprintf)(
                  /* translators: %s: user's display name */
                  (0, import_i18n226.__)(
                    "<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over."
                  ),
                  userDisplayName
                ) : (0, import_i18n226.__)(
                  "Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over."
                ),
                {
                  strong: /* @__PURE__ */ (0, import_jsx_runtime395.jsx)("strong", {}),
                  PreviewLink: /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(import_components202.ExternalLink, { href: previewLink, children: (0, import_i18n226.__)("preview") })
                }
              ) }),
              /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(CollaborationContext, {}),
              /* @__PURE__ */ (0, import_jsx_runtime395.jsx)("p", { children: (0, import_i18n226.__)(
                "If you take over, the other user will lose editing control to the post, but their changes will be saved."
              ) })
            ] }),
            /* @__PURE__ */ (0, import_jsx_runtime395.jsxs)(
              import_components202.__experimentalHStack,
              {
                className: "editor-post-locked-modal__buttons",
                justify: "flex-end",
                children: [
                  !isTakeover && /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(
                    import_components202.Button,
                    {
                      __next40pxDefaultSize: true,
                      variant: "tertiary",
                      href: unlockUrl,
                      children: (0, import_i18n226.__)("Take over")
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(
                    import_components202.Button,
                    {
                      __next40pxDefaultSize: true,
                      variant: "primary",
                      href: allPostsUrl,
                      children: allPostsLabel
                    }
                  )
                ]
              }
            )
          ] })
        ] })
      }
    );
  }
  var post_locked_modal_default = true ? (0, import_components202.withFilters)("editor.PostLockedModal")(PostLockedModal) : PostLockedModal;

  // packages/editor/build-module/components/post-pending-status/index.mjs
  var import_i18n227 = __toESM(require_i18n(), 1);
  var import_components203 = __toESM(require_components(), 1);
  var import_data139 = __toESM(require_data(), 1);

  // packages/editor/build-module/components/post-pending-status/check.mjs
  var import_data138 = __toESM(require_data(), 1);
  function PostPendingStatusCheck({ children }) {
    const { hasPublishAction, isPublished } = (0, import_data138.useSelect)((select7) => {
      const { isCurrentPostPublished: isCurrentPostPublished2, getCurrentPost: getCurrentPost2 } = select7(store3);
      return {
        hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false,
        isPublished: isCurrentPostPublished2()
      };
    }, []);
    if (isPublished || !hasPublishAction) {
      return null;
    }
    return children;
  }
  var check_default6 = PostPendingStatusCheck;

  // packages/editor/build-module/components/post-pending-status/index.mjs
  var import_jsx_runtime396 = __toESM(require_jsx_runtime(), 1);
  function PostPendingStatus() {
    const status = (0, import_data139.useSelect)(
      (select7) => select7(store3).getEditedPostAttribute("status"),
      []
    );
    const { editPost: editPost2 } = (0, import_data139.useDispatch)(store3);
    const togglePendingStatus = () => {
      const updatedStatus = status === "pending" ? "draft" : "pending";
      editPost2({ status: updatedStatus });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime396.jsx)(check_default6, { children: /* @__PURE__ */ (0, import_jsx_runtime396.jsx)(
      import_components203.CheckboxControl,
      {
        label: (0, import_i18n227.__)("Pending review"),
        checked: status === "pending",
        onChange: togglePendingStatus
      }
    ) });
  }
  var post_pending_status_default = PostPendingStatus;

  // packages/editor/build-module/components/post-preview-button/index.mjs
  var import_element215 = __toESM(require_element(), 1);
  var import_components204 = __toESM(require_components(), 1);
  var import_i18n228 = __toESM(require_i18n(), 1);
  var import_data140 = __toESM(require_data(), 1);
  var import_hooks49 = __toESM(require_hooks(), 1);
  var import_core_data87 = __toESM(require_core_data(), 1);
  var import_jsx_runtime397 = __toESM(require_jsx_runtime(), 1);
  function writeInterstitialMessage(targetDocument) {
    let markup = (0, import_element215.renderToString)(
      /* @__PURE__ */ (0, import_jsx_runtime397.jsxs)("div", { className: "editor-post-preview-button__interstitial-message", children: [
        /* @__PURE__ */ (0, import_jsx_runtime397.jsxs)(import_components204.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 96 96", children: [
          /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(
            import_components204.Path,
            {
              className: "outer",
              d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36",
              fill: "none"
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(
            import_components204.Path,
            {
              className: "inner",
              d: "M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z",
              fill: "none"
            }
          )
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime397.jsx)("p", { children: (0, import_i18n228.__)("Generating preview\u2026") })
      ] })
    );
    markup += `
		<style>
			body {
				margin: 0;
			}
			.editor-post-preview-button__interstitial-message {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				height: 100vh;
				width: 100vw;
			}
			@-webkit-keyframes paint {
				0% {
					stroke-dashoffset: 0;
				}
			}
			@-moz-keyframes paint {
				0% {
					stroke-dashoffset: 0;
				}
			}
			@-o-keyframes paint {
				0% {
					stroke-dashoffset: 0;
				}
			}
			@keyframes paint {
				0% {
					stroke-dashoffset: 0;
				}
			}
			.editor-post-preview-button__interstitial-message svg {
				width: 192px;
				height: 192px;
				stroke: #555d66;
				stroke-width: 0.75;
			}
			.editor-post-preview-button__interstitial-message svg .outer,
			.editor-post-preview-button__interstitial-message svg .inner {
				stroke-dasharray: 280;
				stroke-dashoffset: 280;
				-webkit-animation: paint 1.5s ease infinite alternate;
				-moz-animation: paint 1.5s ease infinite alternate;
				-o-animation: paint 1.5s ease infinite alternate;
				animation: paint 1.5s ease infinite alternate;
			}
			p {
				text-align: center;
				font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
			}
		</style>
	`;
    markup = (0, import_hooks49.applyFilters)("editor.PostPreview.interstitialMarkup", markup);
    targetDocument.write(markup);
    targetDocument.title = (0, import_i18n228.__)("Generating preview\u2026");
    targetDocument.close();
  }
  function PostPreviewButton({
    className,
    textContent,
    forceIsAutosaveable,
    role,
    onPreview
  }) {
    const { postId: postId2, currentPostLink, previewLink, isSaveable, isViewable } = (0, import_data140.useSelect)((select7) => {
      const editor = select7(store3);
      const core = select7(import_core_data87.store);
      const postType2 = core.getPostType(
        editor.getCurrentPostType("type")
      );
      const canView = postType2?.viewable ?? false;
      if (!canView) {
        return { isViewable: canView };
      }
      return {
        postId: editor.getCurrentPostId(),
        currentPostLink: editor.getCurrentPostAttribute("link"),
        previewLink: editor.getEditedPostPreviewLink(),
        isSaveable: editor.isEditedPostSaveable(),
        isViewable: canView
      };
    }, []);
    const { __unstableSaveForPreview: __unstableSaveForPreview2 } = (0, import_data140.useDispatch)(store3);
    if (!isViewable) {
      return null;
    }
    const targetId = `wp-preview-${postId2}`;
    const openPreviewWindow = async (event) => {
      event.preventDefault();
      const previewWindow = window.open("", targetId);
      previewWindow.focus();
      writeInterstitialMessage(previewWindow.document);
      const link = await __unstableSaveForPreview2({ forceIsAutosaveable });
      previewWindow.location = link;
      onPreview?.();
    };
    const href = previewLink || currentPostLink;
    return /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(
      import_components204.Button,
      {
        variant: !className ? "tertiary" : void 0,
        className: className || "editor-post-preview",
        href,
        target: targetId,
        accessibleWhenDisabled: true,
        disabled: !isSaveable,
        onClick: openPreviewWindow,
        role,
        size: "compact",
        children: textContent || /* @__PURE__ */ (0, import_jsx_runtime397.jsxs)(import_jsx_runtime397.Fragment, { children: [
          (0, import_i18n228._x)("Preview", "imperative verb"),
          /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(VisuallyHidden, {
            render: /* @__PURE__ */ (0, import_jsx_runtime397.jsx)("span", {}),
            /* translators: accessibility text */
            children: (0, import_i18n228.__)("(opens in a new tab)")
          })
        ] })
      }
    );
  }

  // packages/editor/build-module/components/post-publish-button/index.mjs
  var import_components205 = __toESM(require_components(), 1);
  var import_element216 = __toESM(require_element(), 1);
  var import_data142 = __toESM(require_data(), 1);
  var import_compose45 = __toESM(require_compose(), 1);

  // packages/editor/build-module/components/post-publish-button/label.mjs
  var import_i18n229 = __toESM(require_i18n(), 1);
  var import_data141 = __toESM(require_data(), 1);
  var import_compose44 = __toESM(require_compose(), 1);
  function PublishButtonLabel() {
    const isSmallerThanMediumViewport = (0, import_compose44.useViewportMatch)("medium", "<");
    const {
      isPublished,
      isBeingScheduled,
      isSaving,
      isPublishing,
      hasPublishAction,
      isAutosaving,
      hasNonPostEntityChanges: hasNonPostEntityChanges2,
      postStatusHasChanged,
      postStatus,
      postType: postType2,
      isPostSavingLocked: isPostSavingLocked2
    } = (0, import_data141.useSelect)((select7) => {
      const {
        isCurrentPostPublished: isCurrentPostPublished2,
        isEditedPostBeingScheduled: isEditedPostBeingScheduled2,
        isSavingPost: isSavingPost2,
        isPublishingPost: isPublishingPost2,
        getCurrentPost: getCurrentPost2,
        getCurrentPostType: getCurrentPostType2,
        isAutosavingPost: isAutosavingPost2,
        getPostEdits: getPostEdits2,
        getEditedPostAttribute: getEditedPostAttribute2
      } = select7(store3);
      return {
        isPublished: isCurrentPostPublished2(),
        isBeingScheduled: isEditedPostBeingScheduled2(),
        isSaving: isSavingPost2(),
        isPublishing: isPublishingPost2(),
        hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false,
        postType: getCurrentPostType2(),
        isAutosaving: isAutosavingPost2(),
        hasNonPostEntityChanges: select7(store3).hasNonPostEntityChanges(),
        isPostSavingLocked: select7(store3).isPostSavingLocked(),
        postStatusHasChanged: !!getPostEdits2()?.status,
        postStatus: getEditedPostAttribute2("status")
      };
    }, []);
    if (isPublishing) {
      return (0, import_i18n229.__)("Publishing\u2026");
    } else if ((isPublished || isBeingScheduled) && isSaving && !isAutosaving) {
      return (0, import_i18n229.__)("Saving\u2026");
    }
    if (!hasPublishAction) {
      if (postType2 === ATTACHMENT_POST_TYPE && window?.__experimentalMediaEditor) {
        return (0, import_i18n229.__)("Save");
      }
      return isSmallerThanMediumViewport ? (0, import_i18n229.__)("Publish") : (0, import_i18n229.__)("Submit for Review");
    }
    if (hasNonPostEntityChanges2 && !isPostSavingLocked2 || isPublished || postStatusHasChanged && !["future", "publish"].includes(postStatus) || !postStatusHasChanged && postStatus === "future") {
      return (0, import_i18n229.__)("Save");
    }
    if (isBeingScheduled) {
      return (0, import_i18n229.__)("Schedule");
    }
    return (0, import_i18n229.__)("Publish");
  }

  // packages/editor/build-module/components/post-publish-button/index.mjs
  var import_jsx_runtime398 = __toESM(require_jsx_runtime(), 1);
  var noop8 = () => {
  };
  var PostPublishButton = class extends import_element216.Component {
    constructor(props) {
      super(props);
      this.createOnClick = this.createOnClick.bind(this);
      this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this);
      this.state = {
        entitiesSavedStatesCallback: false
      };
    }
    createOnClick(callback) {
      return (...args) => {
        const { hasNonPostEntityChanges: hasNonPostEntityChanges2, setEntitiesSavedStatesCallback } = this.props;
        if (hasNonPostEntityChanges2 && setEntitiesSavedStatesCallback) {
          this.setState({
            entitiesSavedStatesCallback: () => callback(...args)
          });
          setEntitiesSavedStatesCallback(
            () => this.closeEntitiesSavedStates
          );
          return noop8;
        }
        return callback(...args);
      };
    }
    closeEntitiesSavedStates(savedEntities) {
      const { postType: postType2, postId: postId2 } = this.props;
      const { entitiesSavedStatesCallback } = this.state;
      this.setState({ entitiesSavedStatesCallback: false }, () => {
        if (savedEntities && savedEntities.some(
          (elt) => elt.kind === "postType" && elt.name === postType2 && elt.key === postId2
        )) {
          entitiesSavedStatesCallback();
        }
      });
    }
    render() {
      const {
        forceIsDirty,
        hasPublishAction,
        isBeingScheduled,
        isOpen: isOpen2,
        isPostSavingLocked: isPostSavingLocked2,
        isPublishable,
        isPublished,
        isSaveable,
        isSaving,
        isAutoSaving,
        isToggle,
        savePostStatus,
        onSubmit = noop8,
        onToggle,
        visibility,
        hasNonPostEntityChanges: hasNonPostEntityChanges2,
        isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2,
        postStatus,
        postStatusHasChanged
      } = this.props;
      const isButtonDisabled = isPostSavingLocked2 || (isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges2 || isSavingNonPostEntityChanges2);
      const isToggleDisabled = isPostSavingLocked2 || (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges2 || isSavingNonPostEntityChanges2);
      let publishStatus = "publish";
      if (postStatusHasChanged) {
        publishStatus = postStatus;
      } else if (!hasPublishAction) {
        publishStatus = "pending";
      } else if (visibility === "private") {
        publishStatus = "private";
      } else if (isBeingScheduled) {
        publishStatus = "future";
      }
      const onClickButton = () => {
        if (isButtonDisabled) {
          return;
        }
        onSubmit();
        savePostStatus(publishStatus);
      };
      const onClickToggle = () => {
        if (isToggleDisabled) {
          return;
        }
        onToggle();
      };
      const buttonProps = {
        "aria-disabled": isButtonDisabled,
        className: "editor-post-publish-button",
        isBusy: !isAutoSaving && isSaving,
        variant: "primary",
        onClick: this.createOnClick(onClickButton),
        "aria-haspopup": hasNonPostEntityChanges2 ? "dialog" : void 0
      };
      const toggleProps = {
        "aria-disabled": isToggleDisabled,
        "aria-expanded": isOpen2,
        className: "editor-post-publish-panel__toggle",
        isBusy: isSaving && isPublished,
        variant: "primary",
        size: "compact",
        onClick: this.createOnClick(onClickToggle),
        "aria-haspopup": hasNonPostEntityChanges2 ? "dialog" : void 0
      };
      const componentProps = isToggle ? toggleProps : buttonProps;
      return /* @__PURE__ */ (0, import_jsx_runtime398.jsx)(import_jsx_runtime398.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime398.jsx)(
        import_components205.Button,
        {
          ...componentProps,
          className: `${componentProps.className} editor-post-publish-button__button`,
          size: "compact",
          children: /* @__PURE__ */ (0, import_jsx_runtime398.jsx)(PublishButtonLabel, {})
        }
      ) });
    }
  };
  var post_publish_button_default = (0, import_compose45.compose)([
    (0, import_data142.withSelect)((select7) => {
      const {
        isSavingPost: isSavingPost2,
        isAutosavingPost: isAutosavingPost2,
        isEditedPostBeingScheduled: isEditedPostBeingScheduled2,
        getEditedPostVisibility: getEditedPostVisibility2,
        isCurrentPostPublished: isCurrentPostPublished2,
        isEditedPostSaveable: isEditedPostSaveable2,
        isEditedPostPublishable: isEditedPostPublishable2,
        isPostSavingLocked: isPostSavingLocked2,
        getCurrentPost: getCurrentPost2,
        getCurrentPostType: getCurrentPostType2,
        getCurrentPostId: getCurrentPostId2,
        hasNonPostEntityChanges: hasNonPostEntityChanges2,
        isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2,
        getEditedPostAttribute: getEditedPostAttribute2,
        getPostEdits: getPostEdits2
      } = select7(store3);
      return {
        isSaving: isSavingPost2(),
        isAutoSaving: isAutosavingPost2(),
        isBeingScheduled: isEditedPostBeingScheduled2(),
        visibility: getEditedPostVisibility2(),
        isSaveable: isEditedPostSaveable2(),
        isPostSavingLocked: isPostSavingLocked2(),
        isPublishable: isEditedPostPublishable2(),
        isPublished: isCurrentPostPublished2(),
        hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false,
        postType: getCurrentPostType2(),
        postId: getCurrentPostId2(),
        postStatus: getEditedPostAttribute2("status"),
        postStatusHasChanged: getPostEdits2()?.status,
        hasNonPostEntityChanges: hasNonPostEntityChanges2(),
        isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2()
      };
    }),
    (0, import_data142.withDispatch)((dispatch7) => {
      const { editPost: editPost2, savePost: savePost2 } = dispatch7(store3);
      return {
        savePostStatus: (status) => {
          editPost2({ status }, { undoIgnore: true });
          savePost2();
        }
      };
    })
  ])(PostPublishButton);

  // packages/editor/build-module/components/post-publish-panel/index.mjs
  var import_i18n242 = __toESM(require_i18n(), 1);
  var import_element225 = __toESM(require_element(), 1);
  var import_components216 = __toESM(require_components(), 1);
  var import_data156 = __toESM(require_data(), 1);
  var import_compose50 = __toESM(require_compose(), 1);
  var import_core_data97 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/post-publish-panel/prepublish.mjs
  var import_i18n240 = __toESM(require_i18n(), 1);
  var import_components214 = __toESM(require_components(), 1);
  var import_data154 = __toESM(require_data(), 1);
  var import_url18 = __toESM(require_url(), 1);
  var import_core_data95 = __toESM(require_core_data(), 1);
  var import_html_entities24 = __toESM(require_html_entities(), 1);

  // packages/editor/build-module/components/post-visibility/index.mjs
  var import_i18n231 = __toESM(require_i18n(), 1);
  var import_element217 = __toESM(require_element(), 1);
  var import_components206 = __toESM(require_components(), 1);
  var import_compose46 = __toESM(require_compose(), 1);
  var import_data143 = __toESM(require_data(), 1);
  var import_block_editor55 = __toESM(require_block_editor(), 1);

  // packages/editor/build-module/components/post-visibility/utils.mjs
  var import_i18n230 = __toESM(require_i18n(), 1);
  var VISIBILITY_OPTIONS = [
    {
      label: (0, import_i18n230.__)("Public"),
      value: "public",
      description: (0, import_i18n230.__)("Visible to everyone.")
    },
    {
      label: (0, import_i18n230.__)("Private"),
      value: "private",
      description: (0, import_i18n230.__)("Only visible to site admins and editors.")
    },
    {
      label: (0, import_i18n230.__)("Password protected"),
      value: "password",
      description: (0, import_i18n230.__)("Only visible to those who know the password.")
    }
  ];

  // packages/editor/build-module/components/post-visibility/index.mjs
  var import_jsx_runtime399 = __toESM(require_jsx_runtime(), 1);
  function PostVisibility({ onClose }) {
    const instanceId = (0, import_compose46.useInstanceId)(PostVisibility);
    const { status, visibility, password } = (0, import_data143.useSelect)((select7) => ({
      status: select7(store3).getEditedPostAttribute("status"),
      visibility: select7(store3).getEditedPostVisibility(),
      password: select7(store3).getEditedPostAttribute("password")
    }));
    const { editPost: editPost2 } = (0, import_data143.useDispatch)(store3);
    const [hasPassword, setHasPassword] = (0, import_element217.useState)(!!password);
    function updateVisibility(value) {
      const nextValues = {
        public: {
          status: visibility === "private" ? "draft" : status,
          password: ""
        },
        private: { status: "private", password: "" },
        password: {
          status: visibility === "private" ? "draft" : status,
          password: password || ""
        }
      };
      editPost2(nextValues[value]);
      setHasPassword(value === "password");
    }
    const updatePassword = (value) => {
      editPost2({ password: value });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime399.jsxs)("div", { className: "editor-post-visibility", children: [
      /* @__PURE__ */ (0, import_jsx_runtime399.jsx)(
        import_block_editor55.__experimentalInspectorPopoverHeader,
        {
          title: (0, import_i18n231.__)("Visibility"),
          help: (0, import_i18n231.__)("Control how this post is viewed."),
          onClose
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime399.jsxs)(import_components206.__experimentalVStack, { spacing: 4, children: [
        /* @__PURE__ */ (0, import_jsx_runtime399.jsx)(
          import_components206.RadioControl,
          {
            label: (0, import_i18n231.__)("Visibility"),
            hideLabelFromVision: true,
            options: VISIBILITY_OPTIONS,
            selected: hasPassword ? "password" : visibility,
            onChange: updateVisibility
          }
        ),
        hasPassword && /* @__PURE__ */ (0, import_jsx_runtime399.jsx)(
          import_components206.TextControl,
          {
            label: (0, import_i18n231.__)("Password"),
            onChange: updatePassword,
            value: password,
            placeholder: (0, import_i18n231.__)("Use a secure password"),
            type: "text",
            id: `editor-post-visibility__password-input-${instanceId}`,
            __next40pxDefaultSize: true,
            maxLength: 255
          }
        )
      ] })
    ] });
  }

  // packages/editor/build-module/components/post-visibility/label.mjs
  var import_data144 = __toESM(require_data(), 1);
  function PostVisibilityLabel() {
    return usePostVisibilityLabel();
  }
  function usePostVisibilityLabel() {
    const visibility = (0, import_data144.useSelect)(
      (select7) => select7(store3).getEditedPostVisibility(),
      []
    );
    return VISIBILITY_OPTIONS.find((option) => option.value === visibility)?.label;
  }

  // node_modules/date-fns/toDate.mjs
  function toDate2(argument) {
    const argStr = Object.prototype.toString.call(argument);
    if (argument instanceof Date || typeof argument === "object" && argStr === "[object Date]") {
      return new argument.constructor(+argument);
    } else if (typeof argument === "number" || argStr === "[object Number]" || typeof argument === "string" || argStr === "[object String]") {
      return new Date(argument);
    } else {
      return /* @__PURE__ */ new Date(NaN);
    }
  }

  // node_modules/date-fns/constants.mjs
  var daysInYear2 = 365.2425;
  var maxTime2 = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
  var minTime2 = -maxTime2;
  var millisecondsInMinute = 6e4;
  var millisecondsInHour = 36e5;
  var secondsInHour2 = 3600;
  var secondsInDay2 = secondsInHour2 * 24;
  var secondsInWeek2 = secondsInDay2 * 7;
  var secondsInYear2 = secondsInDay2 * daysInYear2;
  var secondsInMonth2 = secondsInYear2 / 12;
  var secondsInQuarter2 = secondsInMonth2 * 3;

  // node_modules/date-fns/endOfMonth.mjs
  function endOfMonth(date) {
    const _date = toDate2(date);
    const month = _date.getMonth();
    _date.setFullYear(_date.getFullYear(), month + 1, 0);
    _date.setHours(23, 59, 59, 999);
    return _date;
  }

  // node_modules/date-fns/startOfMonth.mjs
  function startOfMonth2(date) {
    const _date = toDate2(date);
    _date.setDate(1);
    _date.setHours(0, 0, 0, 0);
    return _date;
  }

  // node_modules/date-fns/parseISO.mjs
  function parseISO(argument, options) {
    const additionalDigits = options?.additionalDigits ?? 2;
    const dateStrings = splitDateString(argument);
    let date;
    if (dateStrings.date) {
      const parseYearResult = parseYear(dateStrings.date, additionalDigits);
      date = parseDate2(parseYearResult.restDateString, parseYearResult.year);
    }
    if (!date || isNaN(date.getTime())) {
      return /* @__PURE__ */ new Date(NaN);
    }
    const timestamp = date.getTime();
    let time = 0;
    let offset;
    if (dateStrings.time) {
      time = parseTime(dateStrings.time);
      if (isNaN(time)) {
        return /* @__PURE__ */ new Date(NaN);
      }
    }
    if (dateStrings.timezone) {
      offset = parseTimezone(dateStrings.timezone);
      if (isNaN(offset)) {
        return /* @__PURE__ */ new Date(NaN);
      }
    } else {
      const dirtyDate = new Date(timestamp + time);
      const result = /* @__PURE__ */ new Date(0);
      result.setFullYear(
        dirtyDate.getUTCFullYear(),
        dirtyDate.getUTCMonth(),
        dirtyDate.getUTCDate()
      );
      result.setHours(
        dirtyDate.getUTCHours(),
        dirtyDate.getUTCMinutes(),
        dirtyDate.getUTCSeconds(),
        dirtyDate.getUTCMilliseconds()
      );
      return result;
    }
    return new Date(timestamp + time + offset);
  }
  var patterns = {
    dateTimeDelimiter: /[T ]/,
    timeZoneDelimiter: /[Z ]/i,
    timezone: /([Z+-].*)$/
  };
  var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
  var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
  var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
  function splitDateString(dateString) {
    const dateStrings = {};
    const array = dateString.split(patterns.dateTimeDelimiter);
    let timeString;
    if (array.length > 2) {
      return dateStrings;
    }
    if (/:/.test(array[0])) {
      timeString = array[0];
    } else {
      dateStrings.date = array[0];
      timeString = array[1];
      if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
        dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
        timeString = dateString.substr(
          dateStrings.date.length,
          dateString.length
        );
      }
    }
    if (timeString) {
      const token = patterns.timezone.exec(timeString);
      if (token) {
        dateStrings.time = timeString.replace(token[1], "");
        dateStrings.timezone = token[1];
      } else {
        dateStrings.time = timeString;
      }
    }
    return dateStrings;
  }
  function parseYear(dateString, additionalDigits) {
    const regex = new RegExp(
      "^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)"
    );
    const captures = dateString.match(regex);
    if (!captures) return { year: NaN, restDateString: "" };
    const year = captures[1] ? parseInt(captures[1]) : null;
    const century = captures[2] ? parseInt(captures[2]) : null;
    return {
      year: century === null ? year : century * 100,
      restDateString: dateString.slice((captures[1] || captures[2]).length)
    };
  }
  function parseDate2(dateString, year) {
    if (year === null) return /* @__PURE__ */ new Date(NaN);
    const captures = dateString.match(dateRegex);
    if (!captures) return /* @__PURE__ */ new Date(NaN);
    const isWeekDate = !!captures[4];
    const dayOfYear = parseDateUnit(captures[1]);
    const month = parseDateUnit(captures[2]) - 1;
    const day = parseDateUnit(captures[3]);
    const week = parseDateUnit(captures[4]);
    const dayOfWeek = parseDateUnit(captures[5]) - 1;
    if (isWeekDate) {
      if (!validateWeekDate(year, week, dayOfWeek)) {
        return /* @__PURE__ */ new Date(NaN);
      }
      return dayOfISOWeekYear(year, week, dayOfWeek);
    } else {
      const date = /* @__PURE__ */ new Date(0);
      if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
        return /* @__PURE__ */ new Date(NaN);
      }
      date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
      return date;
    }
  }
  function parseDateUnit(value) {
    return value ? parseInt(value) : 1;
  }
  function parseTime(timeString) {
    const captures = timeString.match(timeRegex);
    if (!captures) return NaN;
    const hours = parseTimeUnit(captures[1]);
    const minutes = parseTimeUnit(captures[2]);
    const seconds = parseTimeUnit(captures[3]);
    if (!validateTime(hours, minutes, seconds)) {
      return NaN;
    }
    return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
  }
  function parseTimeUnit(value) {
    return value && parseFloat(value.replace(",", ".")) || 0;
  }
  function parseTimezone(timezoneString) {
    if (timezoneString === "Z") return 0;
    const captures = timezoneString.match(timezoneRegex);
    if (!captures) return 0;
    const sign = captures[1] === "+" ? -1 : 1;
    const hours = parseInt(captures[2]);
    const minutes = captures[3] && parseInt(captures[3]) || 0;
    if (!validateTimezone(hours, minutes)) {
      return NaN;
    }
    return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
  }
  function dayOfISOWeekYear(isoWeekYear, week, day) {
    const date = /* @__PURE__ */ new Date(0);
    date.setUTCFullYear(isoWeekYear, 0, 4);
    const fourthOfJanuaryDay = date.getUTCDay() || 7;
    const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
    date.setUTCDate(date.getUTCDate() + diff);
    return date;
  }
  var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  function isLeapYearIndex(year) {
    return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
  }
  function validateDate(year, month, date) {
    return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
  }
  function validateDayOfYearDate(year, dayOfYear) {
    return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
  }
  function validateWeekDate(_year, week, day) {
    return week >= 1 && week <= 53 && day >= 0 && day <= 6;
  }
  function validateTime(hours, minutes, seconds) {
    if (hours === 24) {
      return minutes === 0 && seconds === 0;
    }
    return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
  }
  function validateTimezone(_hours, minutes) {
    return minutes >= 0 && minutes <= 59;
  }

  // packages/editor/build-module/components/post-schedule/index.mjs
  var import_date17 = __toESM(require_date(), 1);
  var import_i18n232 = __toESM(require_i18n(), 1);
  var import_data145 = __toESM(require_data(), 1);
  var import_block_editor56 = __toESM(require_block_editor(), 1);
  var import_element218 = __toESM(require_element(), 1);
  var import_core_data88 = __toESM(require_core_data(), 1);
  var import_jsx_runtime400 = __toESM(require_jsx_runtime(), 1);
  var { PrivatePublishDateTimePicker } = unlock(import_block_editor56.privateApis);
  function PostSchedule(props) {
    return /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(
      PrivatePostSchedule,
      {
        ...props,
        showPopoverHeaderActions: true,
        isCompact: false
      }
    );
  }
  function PrivatePostSchedule({
    onClose,
    showPopoverHeaderActions,
    isCompact
  }) {
    const { postDate, postType: postType2 } = (0, import_data145.useSelect)(
      (select7) => ({
        postDate: select7(store3).getEditedPostAttribute("date"),
        postType: select7(store3).getCurrentPostType()
      }),
      []
    );
    const { editPost: editPost2 } = (0, import_data145.useDispatch)(store3);
    const onUpdateDate = (date) => editPost2({ date });
    const [previewedMonth, setPreviewedMonth] = (0, import_element218.useState)(
      startOfMonth2(new Date(postDate))
    );
    const eventsByPostType = (0, import_data145.useSelect)(
      (select7) => select7(import_core_data88.store).getEntityRecords("postType", postType2, {
        status: "publish,future",
        after: startOfMonth2(previewedMonth).toISOString(),
        before: endOfMonth(previewedMonth).toISOString(),
        exclude: [select7(store3).getCurrentPostId()],
        per_page: 100,
        _fields: "id,date"
      }),
      [previewedMonth, postType2]
    );
    const events = (0, import_element218.useMemo)(
      () => (eventsByPostType || []).map(({ date: eventDate }) => ({
        date: new Date(eventDate)
      })),
      [eventsByPostType]
    );
    const settings = (0, import_date17.getSettings)();
    const is12HourTime = /a(?!\\)/i.test(
      settings.formats.time.toLowerCase().replace(/\\\\/g, "").split("").reverse().join("")
      // Reverse the string and test for "a" not followed by a slash.
    );
    return /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(
      PrivatePublishDateTimePicker,
      {
        currentDate: postDate,
        onChange: onUpdateDate,
        is12Hour: is12HourTime,
        dateOrder: (
          /* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */
          (0, import_i18n232._x)("dmy", "date order")
        ),
        events,
        onMonthPreviewed: (date) => setPreviewedMonth(parseISO(date)),
        onClose,
        isCompact,
        showPopoverHeaderActions
      }
    );
  }

  // packages/editor/build-module/components/post-schedule/label.mjs
  var import_i18n233 = __toESM(require_i18n(), 1);
  var import_date18 = __toESM(require_date(), 1);
  var import_data146 = __toESM(require_data(), 1);
  function PostScheduleLabel(props) {
    return usePostScheduleLabel(props);
  }
  function usePostScheduleLabel({ full = false } = {}) {
    const { date, isFloating } = (0, import_data146.useSelect)(
      (select7) => ({
        date: select7(store3).getEditedPostAttribute("date"),
        isFloating: select7(store3).isEditedPostDateFloating()
      }),
      []
    );
    return full ? getFullPostScheduleLabel(date) : getPostScheduleLabel(date, { isFloating });
  }
  function getFullPostScheduleLabel(dateAttribute) {
    const date = (0, import_date18.getDate)(dateAttribute);
    const timezoneAbbreviation = getTimezoneAbbreviation();
    const formattedDate = (0, import_date18.dateI18n)(
      // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
      (0, import_i18n233._x)("F j, Y g:i\xA0a", "post schedule full date format"),
      date
    );
    return (0, import_i18n233.isRTL)() ? `${timezoneAbbreviation} ${formattedDate}` : `${formattedDate} ${timezoneAbbreviation}`;
  }
  function getPostScheduleLabel(dateAttribute, { isFloating = false, now = /* @__PURE__ */ new Date() } = {}) {
    if (!dateAttribute || isFloating) {
      return (0, import_i18n233.__)("Immediately");
    }
    if (!isTimezoneSameAsSiteTimezone(now)) {
      return getFullPostScheduleLabel(dateAttribute);
    }
    const date = (0, import_date18.getDate)(dateAttribute);
    if (isSameDay(date, now)) {
      return (0, import_i18n233.sprintf)(
        // translators: %s: Time of day the post is scheduled for.
        (0, import_i18n233.__)("Today at %s"),
        // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
        (0, import_date18.dateI18n)((0, import_i18n233._x)("g:i\xA0a", "post schedule time format"), date)
      );
    }
    const tomorrow = new Date(now);
    tomorrow.setDate(tomorrow.getDate() + 1);
    if (isSameDay(date, tomorrow)) {
      return (0, import_i18n233.sprintf)(
        // translators: %s: Time of day the post is scheduled for.
        (0, import_i18n233.__)("Tomorrow at %s"),
        // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
        (0, import_date18.dateI18n)((0, import_i18n233._x)("g:i\xA0a", "post schedule time format"), date)
      );
    }
    if (date.getFullYear() === now.getFullYear()) {
      return (0, import_date18.dateI18n)(
        // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
        (0, import_i18n233._x)("F j g:i\xA0a", "post schedule date format without year"),
        date
      );
    }
    return (0, import_date18.dateI18n)(
      // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
      (0, import_i18n233._x)("F j, Y g:i\xA0a", "post schedule full date format"),
      date
    );
  }
  function getTimezoneAbbreviation() {
    const { timezone } = (0, import_date18.getSettings)();
    if (timezone.abbr && isNaN(Number(timezone.abbr))) {
      return timezone.abbr;
    }
    const symbol3 = timezone.offset < 0 ? "" : "+";
    return `UTC${symbol3}${timezone.offsetFormatted}`;
  }
  function isTimezoneSameAsSiteTimezone(date) {
    const { timezone } = (0, import_date18.getSettings)();
    const siteOffset = Number(timezone.offset);
    const dateOffset = -1 * (date.getTimezoneOffset() / 60);
    return siteOffset === dateOffset;
  }
  function isSameDay(left, right) {
    return left.getDate() === right.getDate() && left.getMonth() === right.getMonth() && left.getFullYear() === right.getFullYear();
  }

  // packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.mjs
  var import_i18n235 = __toESM(require_i18n(), 1);
  var import_element220 = __toESM(require_element(), 1);
  var import_data149 = __toESM(require_data(), 1);
  var import_components209 = __toESM(require_components(), 1);
  var import_core_data91 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/post-taxonomies/flat-term-selector.mjs
  var import_i18n234 = __toESM(require_i18n(), 1);
  var import_element219 = __toESM(require_element(), 1);
  var import_components208 = __toESM(require_components(), 1);
  var import_data148 = __toESM(require_data(), 1);
  var import_core_data90 = __toESM(require_core_data(), 1);
  var import_compose47 = __toESM(require_compose(), 1);
  var import_a11y4 = __toESM(require_a11y(), 1);
  var import_notices24 = __toESM(require_notices(), 1);

  // packages/editor/build-module/components/post-taxonomies/most-used-terms.mjs
  var import_components207 = __toESM(require_components(), 1);
  var import_data147 = __toESM(require_data(), 1);
  var import_core_data89 = __toESM(require_core_data(), 1);
  var import_jsx_runtime401 = __toESM(require_jsx_runtime(), 1);
  var MIN_MOST_USED_TERMS = 3;
  var DEFAULT_QUERY2 = {
    per_page: 10,
    orderby: "count",
    order: "desc",
    hide_empty: true,
    _fields: "id,name,count",
    context: "view"
  };
  function MostUsedTerms({ onSelect, taxonomy }) {
    const { _terms, showTerms } = (0, import_data147.useSelect)(
      (select7) => {
        const mostUsedTerms = select7(import_core_data89.store).getEntityRecords(
          "taxonomy",
          taxonomy.slug,
          DEFAULT_QUERY2
        );
        return {
          _terms: mostUsedTerms,
          showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS
        };
      },
      [taxonomy.slug]
    );
    if (!showTerms) {
      return null;
    }
    const terms = unescapeTerms(_terms);
    return /* @__PURE__ */ (0, import_jsx_runtime401.jsxs)("div", { className: "editor-post-taxonomies__flat-term-most-used", children: [
      /* @__PURE__ */ (0, import_jsx_runtime401.jsx)(
        import_components207.BaseControl.VisualLabel,
        {
          as: "h3",
          className: "editor-post-taxonomies__flat-term-most-used-label",
          children: taxonomy.labels.most_used
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime401.jsx)(
        "ul",
        {
          role: "list",
          className: "editor-post-taxonomies__flat-term-most-used-list",
          children: terms.map((term) => /* @__PURE__ */ (0, import_jsx_runtime401.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime401.jsx)(
            import_components207.Button,
            {
              __next40pxDefaultSize: true,
              variant: "link",
              onClick: () => onSelect(term),
              children: term.name
            }
          ) }, term.id))
        }
      )
    ] });
  }

  // packages/editor/build-module/components/post-taxonomies/flat-term-selector.mjs
  var import_jsx_runtime402 = __toESM(require_jsx_runtime(), 1);
  var EMPTY_ARRAY12 = [];
  var MAX_TERMS_SUGGESTIONS = 100;
  var DEFAULT_QUERY3 = {
    per_page: MAX_TERMS_SUGGESTIONS,
    _fields: "id,name",
    context: "view"
  };
  var isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
  var termNamesToIds = (names, terms) => {
    return names.map(
      (termName) => terms.find((term) => isSameTermName(term.name, termName))?.id
    ).filter((id) => id !== void 0);
  };
  function FlatTermSelector({ slug }) {
    const [values, setValues] = (0, import_element219.useState)([]);
    const [search, setSearch] = (0, import_element219.useState)("");
    const debouncedSearch = (0, import_compose47.useDebounce)(setSearch, 500);
    const {
      terms,
      termIds,
      taxonomy,
      hasAssignAction,
      hasCreateAction,
      hasResolvedTerms
    } = (0, import_data148.useSelect)(
      (select7) => {
        const { getCurrentPost: getCurrentPost2, getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
        const { getEntityRecords, getEntityRecord, hasFinishedResolution } = select7(import_core_data90.store);
        const post2 = getCurrentPost2();
        const _taxonomy = getEntityRecord("root", "taxonomy", slug);
        const _termIds = _taxonomy ? getEditedPostAttribute2(_taxonomy.rest_base) : EMPTY_ARRAY12;
        const query = {
          ...DEFAULT_QUERY3,
          include: _termIds?.join(","),
          per_page: -1
        };
        return {
          hasCreateAction: _taxonomy ? post2._links?.["wp:action-create-" + _taxonomy.rest_base] ?? false : false,
          hasAssignAction: _taxonomy ? post2._links?.["wp:action-assign-" + _taxonomy.rest_base] ?? false : false,
          taxonomy: _taxonomy,
          termIds: _termIds,
          terms: _termIds?.length ? getEntityRecords("taxonomy", slug, query) : EMPTY_ARRAY12,
          hasResolvedTerms: hasFinishedResolution("getEntityRecords", [
            "taxonomy",
            slug,
            query
          ])
        };
      },
      [slug]
    );
    const { searchResults } = (0, import_data148.useSelect)(
      (select7) => {
        const { getEntityRecords } = select7(import_core_data90.store);
        return {
          searchResults: !!search ? getEntityRecords("taxonomy", slug, {
            ...DEFAULT_QUERY3,
            search
          }) : EMPTY_ARRAY12
        };
      },
      [search, slug]
    );
    (0, import_element219.useEffect)(() => {
      if (hasResolvedTerms) {
        const newValues = (terms ?? []).map(
          (term) => unescapeString(term.name)
        );
        setValues(newValues);
      }
    }, [terms, hasResolvedTerms]);
    const suggestions = (0, import_element219.useMemo)(() => {
      return (searchResults ?? []).map(
        (term) => unescapeString(term.name)
      );
    }, [searchResults]);
    const { editPost: editPost2 } = (0, import_data148.useDispatch)(store3);
    const { saveEntityRecord } = (0, import_data148.useDispatch)(import_core_data90.store);
    const { createErrorNotice } = (0, import_data148.useDispatch)(import_notices24.store);
    if (!hasAssignAction) {
      return null;
    }
    async function findOrCreateTerm(term) {
      try {
        const newTerm = await saveEntityRecord("taxonomy", slug, term, {
          throwOnError: true
        });
        return unescapeTerm(newTerm);
      } catch (error2) {
        if (error2.code !== "term_exists") {
          throw error2;
        }
        return {
          id: error2.data.term_id,
          name: term.name
        };
      }
    }
    function onUpdateTerms(newTermIds) {
      editPost2({ [taxonomy.rest_base]: newTermIds });
    }
    function onChange(termNames) {
      const availableTerms = [
        ...terms ?? [],
        ...searchResults ?? []
      ];
      const uniqueTerms = termNames.reduce((acc, name2) => {
        if (!acc.some((n3) => n3.toLowerCase() === name2.toLowerCase())) {
          acc.push(name2);
        }
        return acc;
      }, []);
      const newTermNames = uniqueTerms.filter(
        (termName) => !availableTerms.find(
          (term) => isSameTermName(term.name, termName)
        )
      );
      setValues(uniqueTerms);
      if (newTermNames.length === 0) {
        onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
        return;
      }
      if (!hasCreateAction) {
        return;
      }
      Promise.all(
        newTermNames.map(
          (termName) => findOrCreateTerm({ name: termName })
        )
      ).then((newTerms) => {
        const newAvailableTerms = availableTerms.concat(newTerms);
        onUpdateTerms(
          termNamesToIds(uniqueTerms, newAvailableTerms)
        );
      }).catch((error2) => {
        createErrorNotice(error2.message, {
          type: "snackbar"
        });
        onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
      });
    }
    function appendTerm(newTerm) {
      if (termIds.includes(newTerm.id)) {
        return;
      }
      const newTermIds = [...termIds, newTerm.id];
      const defaultName = slug === "post_tag" ? (0, import_i18n234.__)("Tag") : (0, import_i18n234.__)("Term");
      const termAddedMessage = (0, import_i18n234.sprintf)(
        /* translators: %s: term name. */
        (0, import_i18n234._x)("%s added", "term"),
        taxonomy?.labels?.singular_name ?? defaultName
      );
      (0, import_a11y4.speak)(termAddedMessage, "assertive");
      onUpdateTerms(newTermIds);
    }
    const newTermLabel = taxonomy?.labels?.add_new_item ?? (slug === "post_tag" ? (0, import_i18n234.__)("Add Tag") : (0, import_i18n234.__)("Add Term"));
    const singularName = taxonomy?.labels?.singular_name ?? (slug === "post_tag" ? (0, import_i18n234.__)("Tag") : (0, import_i18n234.__)("Term"));
    const termAddedLabel = (0, import_i18n234.sprintf)(
      /* translators: %s: term name. */
      (0, import_i18n234._x)("%s added", "term"),
      singularName
    );
    const termRemovedLabel = (0, import_i18n234.sprintf)(
      /* translators: %s: term name. */
      (0, import_i18n234._x)("%s removed", "term"),
      singularName
    );
    const removeTermLabel = (0, import_i18n234.sprintf)(
      /* translators: %s: term name. */
      (0, import_i18n234._x)("Remove %s", "term"),
      singularName
    );
    return /* @__PURE__ */ (0, import_jsx_runtime402.jsxs)(import_components208.__experimentalVStack, { spacing: 4, children: [
      /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(
        import_components208.FormTokenField,
        {
          __next40pxDefaultSize: true,
          value: values,
          suggestions,
          onChange,
          onInputChange: debouncedSearch,
          maxSuggestions: MAX_TERMS_SUGGESTIONS,
          label: newTermLabel,
          messages: {
            added: termAddedLabel,
            removed: termRemovedLabel,
            remove: removeTermLabel
          }
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(MostUsedTerms, { taxonomy, onSelect: appendTerm })
    ] });
  }
  var flat_term_selector_default = (0, import_components208.withFilters)("editor.PostTaxonomyType")(FlatTermSelector);

  // packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.mjs
  var import_jsx_runtime403 = __toESM(require_jsx_runtime(), 1);
  var TagsPanel = () => {
    const tagLabels = (0, import_data149.useSelect)((select7) => {
      const taxonomy = select7(import_core_data91.store).getTaxonomy("post_tag");
      return taxonomy?.labels;
    }, []);
    const addNewItem = tagLabels?.add_new_item ?? (0, import_i18n235.__)("Add tag");
    const tagLabel = tagLabels?.name ?? (0, import_i18n235.__)("Tags");
    const panelBodyTitle = [
      (0, import_i18n235.__)("Suggestion:"),
      /* @__PURE__ */ (0, import_jsx_runtime403.jsx)("span", { className: "editor-post-publish-panel__link", children: addNewItem }, "label")
    ];
    return /* @__PURE__ */ (0, import_jsx_runtime403.jsxs)(import_components209.PanelBody, { initialOpen: false, title: panelBodyTitle, children: [
      /* @__PURE__ */ (0, import_jsx_runtime403.jsx)("p", { children: (0, import_i18n235.sprintf)(
        // translators: %s is the taxonomy name (e.g., "Tags").
        (0, import_i18n235.__)(
          "%s help users and search engines navigate your site and find your content. Add a few keywords to describe your post."
        ),
        tagLabel
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime403.jsx)(flat_term_selector_default, { slug: "post_tag" })
    ] });
  };
  var MaybeTagsPanel = () => {
    const { postHasTags, siteHasTags, isPostTypeSupported } = (0, import_data149.useSelect)(
      (select7) => {
        const postType2 = select7(store3).getCurrentPostType();
        const tagsTaxonomy = select7(import_core_data91.store).getEntityRecord(
          "root",
          "taxonomy",
          "post_tag"
        );
        const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType2);
        const areTagsFetched = tagsTaxonomy !== void 0;
        const tags = tagsTaxonomy && select7(store3).getEditedPostAttribute(
          tagsTaxonomy.rest_base
        );
        const siteTags = _isPostTypeSupported ? !!select7(import_core_data91.store).getEntityRecords(
          "taxonomy",
          "post_tag",
          { per_page: 1 }
        )?.length : false;
        return {
          postHasTags: !!tags?.length,
          siteHasTags: siteTags,
          isPostTypeSupported: areTagsFetched && _isPostTypeSupported
        };
      },
      []
    );
    const [hadTagsWhenOpeningThePanel] = (0, import_element220.useState)(postHasTags);
    if (!isPostTypeSupported || !siteHasTags) {
      return null;
    }
    if (!hadTagsWhenOpeningThePanel) {
      return /* @__PURE__ */ (0, import_jsx_runtime403.jsx)(TagsPanel, {});
    }
    return null;
  };
  var maybe_tags_panel_default = MaybeTagsPanel;

  // packages/editor/build-module/components/post-publish-panel/maybe-post-format-panel.mjs
  var import_components210 = __toESM(require_components(), 1);
  var import_data150 = __toESM(require_data(), 1);
  var import_i18n236 = __toESM(require_i18n(), 1);
  var import_core_data92 = __toESM(require_core_data(), 1);
  var import_jsx_runtime404 = __toESM(require_jsx_runtime(), 1);
  var getSuggestion = (supportedFormats, suggestedPostFormat) => {
    const formats = POST_FORMATS2.filter(
      (format6) => supportedFormats?.includes(format6.id)
    );
    return formats.find((format6) => format6.id === suggestedPostFormat);
  };
  var PostFormatSuggestion = ({
    suggestedPostFormat,
    suggestionText,
    onUpdatePostFormat
  }) => /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(
    import_components210.Button,
    {
      __next40pxDefaultSize: true,
      variant: "link",
      onClick: () => onUpdatePostFormat(suggestedPostFormat),
      children: suggestionText
    }
  );
  function PostFormatPanel() {
    const { currentPostFormat, suggestion } = (0, import_data150.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2, getSuggestedPostFormat: getSuggestedPostFormat2 } = select7(store3);
      const supportedFormats = select7(import_core_data92.store).getThemeSupports().formats ?? [];
      return {
        currentPostFormat: getEditedPostAttribute2("format"),
        suggestion: getSuggestion(
          supportedFormats,
          getSuggestedPostFormat2()
        )
      };
    }, []);
    const { editPost: editPost2 } = (0, import_data150.useDispatch)(store3);
    const onUpdatePostFormat = (format6) => editPost2({ format: format6 });
    const panelBodyTitle = [
      (0, import_i18n236.__)("Suggestion:"),
      /* @__PURE__ */ (0, import_jsx_runtime404.jsx)("span", { className: "editor-post-publish-panel__link", children: (0, import_i18n236.__)("Use a post format") }, "label")
    ];
    if (!suggestion || suggestion.id === currentPostFormat) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime404.jsxs)(import_components210.PanelBody, { initialOpen: false, title: panelBodyTitle, children: [
      /* @__PURE__ */ (0, import_jsx_runtime404.jsx)("p", { children: (0, import_i18n236.__)(
        "Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling."
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime404.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(
        PostFormatSuggestion,
        {
          onUpdatePostFormat,
          suggestedPostFormat: suggestion.id,
          suggestionText: (0, import_i18n236.sprintf)(
            /* translators: %1s: post format */
            (0, import_i18n236.__)('Apply the "%1$s" format.'),
            suggestion.caption
          )
        }
      ) })
    ] });
  }

  // packages/editor/build-module/components/post-publish-panel/maybe-category-panel.mjs
  var import_i18n238 = __toESM(require_i18n(), 1);
  var import_data152 = __toESM(require_data(), 1);
  var import_components212 = __toESM(require_components(), 1);
  var import_core_data94 = __toESM(require_core_data(), 1);
  var import_element222 = __toESM(require_element(), 1);

  // packages/editor/build-module/components/post-taxonomies/hierarchical-term-selector.mjs
  var import_i18n237 = __toESM(require_i18n(), 1);
  var import_element221 = __toESM(require_element(), 1);
  var import_notices25 = __toESM(require_notices(), 1);
  var import_components211 = __toESM(require_components(), 1);
  var import_data151 = __toESM(require_data(), 1);
  var import_compose48 = __toESM(require_compose(), 1);
  var import_core_data93 = __toESM(require_core_data(), 1);
  var import_a11y5 = __toESM(require_a11y(), 1);
  var import_html_entities23 = __toESM(require_html_entities(), 1);
  var import_jsx_runtime405 = __toESM(require_jsx_runtime(), 1);
  var { normalizeTextString } = unlock(import_components211.privateApis);
  var { RECEIVE_INTERMEDIATE_RESULTS } = unlock(import_core_data93.privateApis);
  var DEFAULT_QUERY4 = {
    per_page: -1,
    orderby: "name",
    order: "asc",
    _fields: "id,name,parent",
    context: "view",
    [RECEIVE_INTERMEDIATE_RESULTS]: true
  };
  var MIN_TERMS_COUNT_FOR_FILTER = 8;
  var EMPTY_ARRAY13 = [];
  function sortBySelected(termsTree, terms) {
    const treeHasSelection = (termTree) => {
      if (terms.indexOf(termTree.id) !== -1) {
        return true;
      }
      if (void 0 === termTree.children) {
        return false;
      }
      return termTree.children.map(treeHasSelection).filter((child) => child).length > 0;
    };
    const termOrChildIsSelected = (termA, termB) => {
      const termASelected = treeHasSelection(termA);
      const termBSelected = treeHasSelection(termB);
      if (termASelected === termBSelected) {
        return 0;
      }
      if (termASelected && !termBSelected) {
        return -1;
      }
      if (!termASelected && termBSelected) {
        return 1;
      }
      return 0;
    };
    const newTermTree = [...termsTree];
    newTermTree.sort(termOrChildIsSelected);
    return newTermTree;
  }
  function findTerm(terms, parent, name2) {
    return terms.find((term) => {
      return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name2.toLowerCase();
    });
  }
  function getFilterMatcher(filterValue) {
    const matchTermsForFilter = (originalTerm) => {
      if ("" === filterValue) {
        return originalTerm;
      }
      const term = { ...originalTerm };
      if (term.children.length > 0) {
        term.children = term.children.map(matchTermsForFilter).filter((child) => child);
      }
      if (-1 !== normalizeTextString(term.name).indexOf(
        normalizeTextString(filterValue)
      ) || term.children.length > 0) {
        return term;
      }
      return false;
    };
    return matchTermsForFilter;
  }
  function HierarchicalTermSelector({ slug }) {
    const [adding, setAdding] = (0, import_element221.useState)(false);
    const [formName, setFormName] = (0, import_element221.useState)("");
    const [formParent, setFormParent] = (0, import_element221.useState)("");
    const [showForm, setShowForm] = (0, import_element221.useState)(false);
    const [filterValue, setFilterValue] = (0, import_element221.useState)("");
    const [filteredTermsTree, setFilteredTermsTree] = (0, import_element221.useState)([]);
    const debouncedSpeak = (0, import_compose48.useDebounce)(import_a11y5.speak, 500);
    const {
      hasCreateAction,
      hasAssignAction,
      terms,
      loading,
      availableTerms,
      taxonomy
    } = (0, import_data151.useSelect)(
      (select7) => {
        const { getCurrentPost: getCurrentPost2, getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
        const { getEntityRecord, getEntityRecords, isResolving } = select7(import_core_data93.store);
        const _taxonomy = getEntityRecord("root", "taxonomy", slug);
        const post2 = getCurrentPost2();
        return {
          hasCreateAction: _taxonomy ? !!post2._links?.["wp:action-create-" + _taxonomy.rest_base] : false,
          hasAssignAction: _taxonomy ? !!post2._links?.["wp:action-assign-" + _taxonomy.rest_base] : false,
          terms: _taxonomy ? getEditedPostAttribute2(_taxonomy.rest_base) : EMPTY_ARRAY13,
          loading: isResolving("getEntityRecords", [
            "taxonomy",
            slug,
            DEFAULT_QUERY4
          ]),
          availableTerms: getEntityRecords("taxonomy", slug, DEFAULT_QUERY4) || EMPTY_ARRAY13,
          taxonomy: _taxonomy
        };
      },
      [slug]
    );
    const { editPost: editPost2 } = (0, import_data151.useDispatch)(store3);
    const { saveEntityRecord } = (0, import_data151.useDispatch)(import_core_data93.store);
    const availableTermsTree = (0, import_element221.useMemo)(
      () => sortBySelected(buildTermsTree2(availableTerms), terms),
      // Remove `terms` from the dependency list to avoid reordering every time
      // checking or unchecking a term.
      [availableTerms]
    );
    const { createErrorNotice } = (0, import_data151.useDispatch)(import_notices25.store);
    if (!hasAssignAction) {
      return null;
    }
    const addTerm = (term) => {
      return saveEntityRecord("taxonomy", slug, term, {
        throwOnError: true
      });
    };
    const onUpdateTerms = (termIds) => {
      editPost2({ [taxonomy.rest_base]: termIds });
    };
    const onChange = (termId) => {
      const hasTerm = terms.includes(termId);
      const newTerms = hasTerm ? terms.filter((id) => id !== termId) : [...terms, termId];
      onUpdateTerms(newTerms);
    };
    const onChangeFormName = (value) => {
      setFormName(value);
    };
    const onChangeFormParent = (parentId) => {
      setFormParent(parentId);
    };
    const onToggleForm = () => {
      setShowForm(!showForm);
    };
    const onAddTerm = async (event) => {
      event.preventDefault();
      if (formName === "" || adding) {
        return;
      }
      const existingTerm = findTerm(availableTerms, formParent, formName);
      if (existingTerm) {
        if (!terms.some((term) => term === existingTerm.id)) {
          onUpdateTerms([...terms, existingTerm.id]);
        }
        setFormName("");
        setFormParent("");
        return;
      }
      setAdding(true);
      let newTerm;
      try {
        newTerm = await addTerm({
          name: formName,
          parent: formParent ? formParent : void 0
        });
      } catch (error2) {
        createErrorNotice(error2.message, {
          type: "snackbar"
        });
        return;
      }
      const defaultName = slug === "category" ? (0, import_i18n237.__)("Category") : (0, import_i18n237.__)("Term");
      const termAddedMessage = (0, import_i18n237.sprintf)(
        /* translators: %s: term name. */
        (0, import_i18n237._x)("%s added", "term"),
        taxonomy?.labels?.singular_name ?? defaultName
      );
      (0, import_a11y5.speak)(termAddedMessage, "assertive");
      setAdding(false);
      setFormName("");
      setFormParent("");
      onUpdateTerms([...terms, newTerm.id]);
    };
    const setFilter = (value) => {
      const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter((term) => term);
      const getResultCount = (termsTree) => {
        let count = 0;
        for (let i3 = 0; i3 < termsTree.length; i3++) {
          count++;
          if (void 0 !== termsTree[i3].children) {
            count += getResultCount(termsTree[i3].children);
          }
        }
        return count;
      };
      setFilterValue(value);
      setFilteredTermsTree(newFilteredTermsTree);
      const resultCount = getResultCount(newFilteredTermsTree);
      const resultsFoundMessage = (0, import_i18n237.sprintf)(
        /* translators: %d: number of results. */
        (0, import_i18n237._n)("%d result found.", "%d results found.", resultCount),
        resultCount
      );
      debouncedSpeak(resultsFoundMessage, "assertive");
    };
    const renderTerms = (renderedTerms) => {
      return renderedTerms.map((term) => {
        return /* @__PURE__ */ (0, import_jsx_runtime405.jsxs)(
          "div",
          {
            className: "editor-post-taxonomies__hierarchical-terms-choice",
            children: [
              /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(
                import_components211.CheckboxControl,
                {
                  checked: terms.indexOf(term.id) !== -1,
                  onChange: () => {
                    const termId = parseInt(term.id, 10);
                    onChange(termId);
                  },
                  label: (0, import_html_entities23.decodeEntities)(term.name)
                }
              ),
              !!term.children.length && /* @__PURE__ */ (0, import_jsx_runtime405.jsx)("div", { className: "editor-post-taxonomies__hierarchical-terms-subchoices", children: renderTerms(term.children) })
            ]
          },
          term.id
        );
      });
    };
    const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => taxonomy?.labels?.[labelProperty] ?? (slug === "category" ? fallbackIsCategory : fallbackIsNotCategory);
    const newTermButtonLabel = labelWithFallback(
      "add_new_item",
      (0, import_i18n237.__)("Add Category"),
      (0, import_i18n237.__)("Add Term")
    );
    const newTermLabel = labelWithFallback(
      "new_item_name",
      (0, import_i18n237.__)("Add Category"),
      (0, import_i18n237.__)("Add Term")
    );
    const parentSelectLabel = labelWithFallback(
      "parent_item",
      (0, import_i18n237.__)("Parent Category"),
      (0, import_i18n237.__)("Parent Term")
    );
    const noParentOption = `\u2014 ${parentSelectLabel} \u2014`;
    const newTermSubmitLabel = newTermButtonLabel;
    const filterLabel = taxonomy?.labels?.search_items ?? (0, import_i18n237.__)("Search Terms");
    const groupLabel = taxonomy?.name ?? (0, import_i18n237.__)("Terms");
    const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
    return /* @__PURE__ */ (0, import_jsx_runtime405.jsxs)(import_components211.Flex, { direction: "column", gap: "4", children: [
      showFilter && !loading && /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(
        import_components211.SearchControl,
        {
          __next40pxDefaultSize: true,
          label: filterLabel,
          placeholder: filterLabel,
          value: filterValue,
          onChange: setFilter
        }
      ),
      loading && /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(
        import_components211.Flex,
        {
          justify: "center",
          style: {
            // Match SearchControl height to prevent layout shift.
            height: "40px"
          },
          children: /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(import_components211.Spinner, {})
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(
        "div",
        {
          className: "editor-post-taxonomies__hierarchical-terms-list",
          tabIndex: "0",
          role: "group",
          "aria-label": groupLabel,
          children: renderTerms(
            "" !== filterValue ? filteredTermsTree : availableTermsTree
          )
        }
      ),
      !loading && hasCreateAction && /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(import_components211.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(
        import_components211.Button,
        {
          __next40pxDefaultSize: true,
          onClick: onToggleForm,
          className: "editor-post-taxonomies__hierarchical-terms-add",
          "aria-expanded": showForm,
          variant: "link",
          children: newTermButtonLabel
        }
      ) }),
      showForm && /* @__PURE__ */ (0, import_jsx_runtime405.jsx)("form", { onSubmit: onAddTerm, children: /* @__PURE__ */ (0, import_jsx_runtime405.jsxs)(import_components211.Flex, { direction: "column", gap: "4", children: [
        /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(
          import_components211.TextControl,
          {
            __next40pxDefaultSize: true,
            className: "editor-post-taxonomies__hierarchical-terms-input",
            label: newTermLabel,
            value: formName,
            onChange: onChangeFormName,
            required: true
          }
        ),
        !!availableTerms.length && /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(
          import_components211.TreeSelect,
          {
            __next40pxDefaultSize: true,
            label: parentSelectLabel,
            noOptionLabel: noParentOption,
            onChange: onChangeFormParent,
            selectedId: formParent,
            tree: availableTermsTree
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(import_components211.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(
          import_components211.Button,
          {
            __next40pxDefaultSize: true,
            variant: "secondary",
            type: "submit",
            className: "editor-post-taxonomies__hierarchical-terms-submit",
            children: newTermSubmitLabel
          }
        ) })
      ] }) })
    ] });
  }
  var hierarchical_term_selector_default = (0, import_components211.withFilters)("editor.PostTaxonomyType")(
    HierarchicalTermSelector
  );

  // packages/editor/build-module/components/post-publish-panel/maybe-category-panel.mjs
  var import_jsx_runtime406 = __toESM(require_jsx_runtime(), 1);
  function MaybeCategoryPanel() {
    const { hasNoCategory, hasSiteCategories } = (0, import_data152.useSelect)((select7) => {
      const postType2 = select7(store3).getCurrentPostType();
      const { canUser, getEntityRecord } = select7(import_core_data94.store);
      const categoriesTaxonomy = getEntityRecord(
        "root",
        "taxonomy",
        "category"
      );
      const defaultCategoryId = canUser("read", {
        kind: "root",
        name: "site"
      }) ? getEntityRecord("root", "site")?.default_category : void 0;
      const defaultCategory = defaultCategoryId ? getEntityRecord("taxonomy", "category", defaultCategoryId) : void 0;
      const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some((type) => type === postType2);
      const categories = categoriesTaxonomy && select7(store3).getEditedPostAttribute(
        categoriesTaxonomy.rest_base
      );
      const siteCategories = postTypeSupportsCategories ? !!select7(import_core_data94.store).getEntityRecords("taxonomy", "category", {
        exclude: [defaultCategoryId],
        per_page: 1
      })?.length : false;
      const noCategory = !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]);
      return {
        hasNoCategory: noCategory,
        hasSiteCategories: siteCategories
      };
    }, []);
    const [shouldShowPanel, setShouldShowPanel] = (0, import_element222.useState)(false);
    (0, import_element222.useEffect)(() => {
      if (hasNoCategory) {
        setShouldShowPanel(true);
      }
    }, [hasNoCategory]);
    if (!shouldShowPanel || !hasSiteCategories) {
      return null;
    }
    const panelBodyTitle = [
      (0, import_i18n238.__)("Suggestion:"),
      /* @__PURE__ */ (0, import_jsx_runtime406.jsx)("span", { className: "editor-post-publish-panel__link", children: (0, import_i18n238.__)("Assign a category") }, "label")
    ];
    return /* @__PURE__ */ (0, import_jsx_runtime406.jsxs)(import_components212.PanelBody, { initialOpen: false, title: panelBodyTitle, children: [
      /* @__PURE__ */ (0, import_jsx_runtime406.jsx)("p", { children: (0, import_i18n238.__)(
        "Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about."
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime406.jsx)(hierarchical_term_selector_default, { slug: "category" })
    ] });
  }
  var maybe_category_panel_default = MaybeCategoryPanel;

  // packages/editor/build-module/components/post-publish-panel/maybe-upload-media.mjs
  var import_components213 = __toESM(require_components(), 1);
  var import_data153 = __toESM(require_data(), 1);
  var import_i18n239 = __toESM(require_i18n(), 1);
  var import_block_editor57 = __toESM(require_block_editor(), 1);
  var import_element223 = __toESM(require_element(), 1);
  var import_blob4 = __toESM(require_blob(), 1);

  // packages/editor/build-module/components/post-publish-panel/media-util.mjs
  var import_url17 = __toESM(require_url(), 1);
  function generateUniqueBasenames(urls) {
    const basenames = /* @__PURE__ */ new Set();
    return Object.fromEntries(
      urls.map((url) => {
        const filename = (0, import_url17.getFilename)(url);
        let basename = "";
        if (filename) {
          const parts = filename.split(".");
          if (parts.length > 1) {
            parts.pop();
          }
          basename = parts.join(".");
        }
        if (!basename) {
          basename = v4_default();
        }
        if (basenames.has(basename)) {
          basename = `${basename}-${v4_default()}`;
        }
        basenames.add(basename);
        return [url, basename];
      })
    );
  }
  function fetchMedia(urls) {
    return Object.fromEntries(
      Object.entries(generateUniqueBasenames(urls)).map(
        ([url, basename]) => {
          const filePromise = window.fetch(url.includes("?") ? url : url + "?").then((response) => response.blob()).then((blob) => {
            return new File([blob], `${basename}.png`, {
              type: blob.type
            });
          });
          return [url, filePromise];
        }
      )
    );
  }

  // packages/editor/build-module/components/post-publish-panel/maybe-upload-media.mjs
  var import_jsx_runtime407 = __toESM(require_jsx_runtime(), 1);
  function flattenBlocks(blocks) {
    const result = [];
    blocks.forEach((block) => {
      result.push(block);
      result.push(...flattenBlocks(block.innerBlocks));
    });
    return result;
  }
  function hasExternalMedia(block) {
    if (block.name === "core/image" || block.name === "core/cover") {
      return block.attributes.url && !block.attributes.id;
    }
    if (block.name === "core/media-text") {
      return block.attributes.mediaUrl && !block.attributes.mediaId;
    }
    return void 0;
  }
  function getMediaInfo(block) {
    if (block.name === "core/image" || block.name === "core/cover") {
      const { url, alt, id } = block.attributes;
      return { url, alt, id };
    }
    if (block.name === "core/media-text") {
      const { mediaUrl: url, mediaAlt: alt, mediaId: id } = block.attributes;
      return { url, alt, id };
    }
    return {};
  }
  function Image2({ clientId, alt, url }) {
    const { selectBlock: selectBlock2 } = (0, import_data153.useDispatch)(import_block_editor57.store);
    return /* @__PURE__ */ (0, import_jsx_runtime407.jsx)(
      import_components213.__unstableMotion.img,
      {
        tabIndex: 0,
        role: "button",
        "aria-label": (0, import_i18n239.__)("Select image block."),
        onClick: () => {
          selectBlock2(clientId);
        },
        onKeyDown: (event) => {
          if (event.key === "Enter" || event.key === " ") {
            selectBlock2(clientId);
            event.preventDefault();
          }
        },
        alt,
        src: url,
        animate: { opacity: 1 },
        exit: { opacity: 0, scale: 0 },
        style: {
          width: "32px",
          height: "32px",
          objectFit: "cover",
          borderRadius: "2px",
          cursor: "var(--wpds-cursor-control, pointer)"
        },
        whileHover: { scale: 1.08 }
      },
      clientId
    );
  }
  function MaybeUploadMediaPanel() {
    const [isUploading, setIsUploading] = (0, import_element223.useState)(false);
    const [isAnimating2, setIsAnimating] = (0, import_element223.useState)(false);
    const [hadUploadError, setHadUploadError] = (0, import_element223.useState)(false);
    const { editorBlocks, mediaUpload: mediaUpload2 } = (0, import_data153.useSelect)(
      (select7) => ({
        editorBlocks: select7(import_block_editor57.store).getBlocks(),
        mediaUpload: select7(import_block_editor57.store).getSettings().mediaUpload
      }),
      []
    );
    const blocksWithExternalMedia = flattenBlocks(editorBlocks).filter(
      (block) => hasExternalMedia(block)
    );
    const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data153.useDispatch)(import_block_editor57.store);
    if (!mediaUpload2 || !blocksWithExternalMedia.length) {
      return null;
    }
    const panelBodyTitle = [
      (0, import_i18n239.__)("Suggestion:"),
      /* @__PURE__ */ (0, import_jsx_runtime407.jsx)("span", { className: "editor-post-publish-panel__link", children: (0, import_i18n239.__)("External media") }, "label")
    ];
    function updateBlockWithUploadedMedia(block, media) {
      if (block.name === "core/image" || block.name === "core/cover") {
        updateBlockAttributes2(block.clientId, {
          id: media.id,
          url: media.url
        });
      }
      if (block.name === "core/media-text") {
        updateBlockAttributes2(block.clientId, {
          mediaId: media.id,
          mediaUrl: media.url
        });
      }
    }
    function uploadImages() {
      setIsUploading(true);
      setHadUploadError(false);
      const mediaUrls = new Set(
        blocksWithExternalMedia.map((block) => {
          const { url } = getMediaInfo(block);
          return url;
        })
      );
      const uploadPromises = Object.fromEntries(
        Object.entries(fetchMedia([...mediaUrls])).map(
          ([url, filePromise]) => {
            const uploadPromise = filePromise.then(
              (blob) => new Promise((resolve, reject) => {
                mediaUpload2({
                  filesList: [blob],
                  onFileChange: ([media]) => {
                    if ((0, import_blob4.isBlobURL)(media.url)) {
                      return;
                    }
                    resolve(media);
                  },
                  onError() {
                    reject();
                  }
                });
              })
            );
            return [url, uploadPromise];
          }
        )
      );
      Promise.allSettled(
        blocksWithExternalMedia.map((block) => {
          const { url } = getMediaInfo(block);
          return uploadPromises[url].then(
            (media) => updateBlockWithUploadedMedia(block, media)
          ).then(() => setIsAnimating(true)).catch(() => setHadUploadError(true));
        })
      ).finally(() => {
        setIsUploading(false);
      });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime407.jsxs)(import_components213.PanelBody, { initialOpen: true, title: panelBodyTitle, children: [
      /* @__PURE__ */ (0, import_jsx_runtime407.jsx)("p", { children: (0, import_i18n239.__)(
        "Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly."
      ) }),
      /* @__PURE__ */ (0, import_jsx_runtime407.jsxs)(
        "div",
        {
          style: {
            display: "inline-flex",
            flexWrap: "wrap",
            gap: "8px"
          },
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime407.jsx)(
              import_components213.__unstableAnimatePresence,
              {
                onExitComplete: () => setIsAnimating(false),
                children: blocksWithExternalMedia.map((block) => {
                  const { url, alt } = getMediaInfo(block);
                  return /* @__PURE__ */ (0, import_jsx_runtime407.jsx)(
                    Image2,
                    {
                      clientId: block.clientId,
                      url,
                      alt
                    },
                    block.clientId
                  );
                })
              }
            ),
            isUploading || isAnimating2 ? /* @__PURE__ */ (0, import_jsx_runtime407.jsx)(import_components213.Spinner, {}) : /* @__PURE__ */ (0, import_jsx_runtime407.jsx)(
              import_components213.Button,
              {
                size: "compact",
                variant: "primary",
                onClick: uploadImages,
                children: (0, import_i18n239._x)("Upload", "verb")
              }
            )
          ]
        }
      ),
      hadUploadError && /* @__PURE__ */ (0, import_jsx_runtime407.jsx)("p", { children: (0, import_i18n239.__)("Upload failed, try again.") })
    ] });
  }

  // packages/editor/build-module/components/post-publish-panel/prepublish.mjs
  var import_jsx_runtime408 = __toESM(require_jsx_runtime(), 1);
  function PostPublishPanelPrepublish({ children }) {
    const {
      isBeingScheduled,
      isRequestingSiteIcon,
      hasPublishAction,
      siteIconUrl,
      siteTitle,
      siteHome
    } = (0, import_data154.useSelect)((select7) => {
      const { getCurrentPost: getCurrentPost2, isEditedPostBeingScheduled: isEditedPostBeingScheduled2 } = select7(store3);
      const { getEntityRecord, isResolving } = select7(import_core_data95.store);
      const siteData = getEntityRecord("root", "__unstableBase", void 0) || {};
      return {
        hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false,
        isBeingScheduled: isEditedPostBeingScheduled2(),
        isRequestingSiteIcon: isResolving("getEntityRecord", [
          "root",
          "__unstableBase",
          void 0
        ]),
        siteIconUrl: siteData.site_icon_url,
        siteTitle: siteData.name,
        siteHome: siteData.home && (0, import_url18.filterURLForDisplay)(siteData.home)
      };
    }, []);
    let siteIcon = /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(import_components214.Icon, { className: "components-site-icon", size: "36px", icon: wordpress_default });
    if (siteIconUrl) {
      siteIcon = /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(
        "img",
        {
          alt: (0, import_i18n240.__)("Site Icon"),
          className: "components-site-icon",
          src: siteIconUrl
        }
      );
    }
    if (isRequestingSiteIcon) {
      siteIcon = null;
    }
    let prePublishTitle, prePublishBodyText;
    if (!hasPublishAction) {
      prePublishTitle = (0, import_i18n240.__)("Are you ready to submit for review?");
      prePublishBodyText = (0, import_i18n240.__)(
        "Your work will be reviewed and then approved."
      );
    } else if (isBeingScheduled) {
      prePublishTitle = (0, import_i18n240.__)("Are you ready to schedule?");
      prePublishBodyText = (0, import_i18n240.__)(
        "Your work will be published at the specified date and time."
      );
    } else {
      prePublishTitle = (0, import_i18n240.__)("Are you ready to publish?");
      prePublishBodyText = (0, import_i18n240.__)(
        "Double-check your settings before publishing."
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime408.jsxs)("div", { className: "editor-post-publish-panel__prepublish", children: [
      /* @__PURE__ */ (0, import_jsx_runtime408.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime408.jsx)("strong", { children: prePublishTitle }) }),
      /* @__PURE__ */ (0, import_jsx_runtime408.jsx)("p", { children: prePublishBodyText }),
      /* @__PURE__ */ (0, import_jsx_runtime408.jsxs)("div", { className: "components-site-card", children: [
        siteIcon,
        /* @__PURE__ */ (0, import_jsx_runtime408.jsxs)("div", { className: "components-site-info", children: [
          /* @__PURE__ */ (0, import_jsx_runtime408.jsx)("span", { className: "components-site-name", children: (0, import_html_entities24.decodeEntities)(siteTitle) || (0, import_i18n240.__)("(Untitled)") }),
          /* @__PURE__ */ (0, import_jsx_runtime408.jsx)("span", { className: "components-site-home", children: siteHome })
        ] })
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(MaybeUploadMediaPanel, {}),
      hasPublishAction && /* @__PURE__ */ (0, import_jsx_runtime408.jsxs)(import_jsx_runtime408.Fragment, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(
          import_components214.PanelBody,
          {
            initialOpen: false,
            title: [
              (0, import_i18n240.__)("Visibility:"),
              /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(
                "span",
                {
                  className: "editor-post-publish-panel__link",
                  children: /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(PostVisibilityLabel, {})
                },
                "label"
              )
            ],
            children: /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(PostVisibility, {})
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(
          import_components214.PanelBody,
          {
            initialOpen: false,
            title: [
              (0, import_i18n240.__)("Publish:"),
              /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(
                "span",
                {
                  className: "editor-post-publish-panel__link",
                  children: /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(PostScheduleLabel, {})
                },
                "label"
              )
            ],
            children: /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(PostSchedule, {})
          }
        )
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(PostFormatPanel, {}),
      /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(maybe_tags_panel_default, {}),
      /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(maybe_category_panel_default, {}),
      children
    ] });
  }
  var prepublish_default = PostPublishPanelPrepublish;

  // packages/editor/build-module/components/post-publish-panel/postpublish.mjs
  var import_components215 = __toESM(require_components(), 1);
  var import_i18n241 = __toESM(require_i18n(), 1);
  var import_element224 = __toESM(require_element(), 1);
  var import_data155 = __toESM(require_data(), 1);
  var import_url19 = __toESM(require_url(), 1);
  var import_html_entities25 = __toESM(require_html_entities(), 1);
  var import_compose49 = __toESM(require_compose(), 1);
  var import_core_data96 = __toESM(require_core_data(), 1);
  var import_jsx_runtime409 = __toESM(require_jsx_runtime(), 1);
  var POSTNAME = "%postname%";
  var PAGENAME = "%pagename%";
  var getFuturePostUrl = (post2) => {
    const { slug } = post2;
    if (post2.permalink_template.includes(POSTNAME)) {
      return post2.permalink_template.replace(POSTNAME, slug);
    }
    if (post2.permalink_template.includes(PAGENAME)) {
      return post2.permalink_template.replace(PAGENAME, slug);
    }
    return post2.permalink_template;
  };
  function CopyButton2({ text }) {
    const [showCopyConfirmation, setShowCopyConfirmation] = (0, import_element224.useState)(false);
    const timeoutIdRef = (0, import_element224.useRef)();
    const ref = (0, import_compose49.useCopyToClipboard)(text, () => {
      setShowCopyConfirmation(true);
      if (timeoutIdRef.current) {
        clearTimeout(timeoutIdRef.current);
      }
      timeoutIdRef.current = setTimeout(() => {
        setShowCopyConfirmation(false);
      }, 4e3);
    });
    (0, import_element224.useEffect)(() => {
      return () => {
        if (timeoutIdRef.current) {
          clearTimeout(timeoutIdRef.current);
        }
      };
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(import_components215.Button, { __next40pxDefaultSize: true, variant: "secondary", ref, children: showCopyConfirmation ? (0, import_i18n241.__)("Copied!") : (0, import_i18n241.__)("Copy") });
  }
  function PostPublishPanelPostpublish({
    focusOnMount,
    children
  }) {
    const { post: post2, postType: postType2, isScheduled } = (0, import_data155.useSelect)((select7) => {
      const {
        getEditedPostAttribute: getEditedPostAttribute2,
        getCurrentPost: getCurrentPost2,
        isCurrentPostScheduled: isCurrentPostScheduled2
      } = select7(store3);
      const { getPostType } = select7(import_core_data96.store);
      return {
        post: getCurrentPost2(),
        postType: getPostType(getEditedPostAttribute2("type")),
        isScheduled: isCurrentPostScheduled2()
      };
    }, []);
    const postLabel = postType2?.labels?.singular_name;
    const viewPostLabel = postType2?.labels?.view_item;
    const addNewPostLabel = postType2?.labels?.add_new_item;
    const link = post2.status === "future" ? getFuturePostUrl(post2) : post2.link;
    const addLink = (0, import_url19.addQueryArgs)("post-new.php", {
      post_type: post2.type
    });
    const postLinkRef = (0, import_element224.useCallback)(
      (node) => {
        if (focusOnMount && node) {
          node.focus();
        }
      },
      [focusOnMount]
    );
    const postPublishNonLinkHeader = isScheduled ? /* @__PURE__ */ (0, import_jsx_runtime409.jsxs)(import_jsx_runtime409.Fragment, { children: [
      (0, import_i18n241.__)("is now scheduled. It will go live on"),
      " ",
      /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(PostScheduleLabel, {}),
      "."
    ] }) : (0, import_i18n241.__)("is now live.");
    return /* @__PURE__ */ (0, import_jsx_runtime409.jsxs)("div", { className: "post-publish-panel__postpublish", children: [
      /* @__PURE__ */ (0, import_jsx_runtime409.jsxs)(import_components215.PanelBody, { className: "post-publish-panel__postpublish-header", children: [
        /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(import_components215.ExternalLink, { ref: postLinkRef, href: link, children: (0, import_html_entities25.decodeEntities)(post2.title) || (0, import_i18n241.__)("(no title)") }),
        " ",
        postPublishNonLinkHeader
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime409.jsxs)(import_components215.PanelBody, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime409.jsx)("p", { className: "post-publish-panel__postpublish-subheader", children: /* @__PURE__ */ (0, import_jsx_runtime409.jsx)("strong", { children: (0, import_i18n241.__)("What\u2019s next?") }) }),
        /* @__PURE__ */ (0, import_jsx_runtime409.jsxs)("div", { className: "post-publish-panel__postpublish-post-address-container", children: [
          /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(
            import_components215.TextControl,
            {
              __next40pxDefaultSize: true,
              className: "post-publish-panel__postpublish-post-address",
              readOnly: true,
              label: (0, import_i18n241.sprintf)(
                /* translators: %s: post type singular name */
                (0, import_i18n241.__)("%s address"),
                postLabel
              ),
              value: (0, import_url19.safeDecodeURIComponent)(link),
              onFocus: (event) => event.target.select()
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime409.jsx)("div", { className: "post-publish-panel__postpublish-post-address__copy-button-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(CopyButton2, { text: link }) })
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime409.jsxs)("div", { className: "post-publish-panel__postpublish-buttons", children: [
          !isScheduled && /* @__PURE__ */ (0, import_jsx_runtime409.jsxs)(
            import_components215.Button,
            {
              variant: "primary",
              href: link,
              __next40pxDefaultSize: true,
              icon: external_default,
              iconPosition: "right",
              target: "_blank",
              children: [
                viewPostLabel,
                /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(VisuallyHidden, {
                  render: /* @__PURE__ */ (0, import_jsx_runtime409.jsx)("span", {}),
                  /* translators: accessibility text */
                  children: (0, import_i18n241.__)("(opens in a new tab)")
                })
              ]
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(
            import_components215.Button,
            {
              variant: isScheduled ? "primary" : "secondary",
              __next40pxDefaultSize: true,
              href: addLink,
              children: addNewPostLabel
            }
          )
        ] })
      ] }),
      children
    ] });
  }

  // packages/editor/build-module/components/post-publish-panel/index.mjs
  var import_jsx_runtime410 = __toESM(require_jsx_runtime(), 1);
  var PostPublishPanel = class extends import_element225.Component {
    constructor() {
      super(...arguments);
      this.onSubmit = this.onSubmit.bind(this);
      this.cancelButtonNode = (0, import_element225.createRef)();
    }
    componentDidMount() {
      this.timeoutID = setTimeout(() => {
        this.cancelButtonNode.current.focus();
      }, 0);
    }
    componentWillUnmount() {
      clearTimeout(this.timeoutID);
    }
    componentDidUpdate(prevProps) {
      if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty || this.props.currentPostId !== prevProps.currentPostId) {
        this.props.onClose();
      }
    }
    onSubmit() {
      const { onClose, hasPublishAction, isPostTypeViewable } = this.props;
      if (!hasPublishAction || !isPostTypeViewable) {
        onClose();
      }
    }
    render() {
      const {
        forceIsDirty,
        isBeingScheduled,
        isPublished,
        isPublishSidebarEnabled: isPublishSidebarEnabled2,
        isScheduled,
        isSaving,
        isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2,
        onClose,
        onTogglePublishSidebar,
        PostPublishExtension,
        PrePublishExtension,
        currentPostId,
        ...additionalProps
      } = this.props;
      const {
        hasPublishAction,
        isDirty,
        isPostTypeViewable,
        ...propsForPanel
      } = additionalProps;
      const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled;
      const isPrePublish = !isPublishedOrScheduled && !isSaving;
      const isPostPublish = isPublishedOrScheduled && !isSaving;
      return /* @__PURE__ */ (0, import_jsx_runtime410.jsxs)("div", { className: "editor-post-publish-panel", ...propsForPanel, children: [
        /* @__PURE__ */ (0, import_jsx_runtime410.jsx)("div", { className: "editor-post-publish-panel__header", children: isPostPublish ? /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(
          import_components216.Button,
          {
            size: "compact",
            onClick: onClose,
            icon: close_small_default,
            label: (0, import_i18n242.__)("Close panel")
          }
        ) : /* @__PURE__ */ (0, import_jsx_runtime410.jsxs)(import_jsx_runtime410.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime410.jsx)("div", { className: "editor-post-publish-panel__header-cancel-button", children: /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(
            import_components216.Button,
            {
              ref: this.cancelButtonNode,
              accessibleWhenDisabled: true,
              disabled: isSavingNonPostEntityChanges2,
              onClick: onClose,
              variant: "secondary",
              size: "compact",
              children: (0, import_i18n242.__)("Cancel")
            }
          ) }),
          /* @__PURE__ */ (0, import_jsx_runtime410.jsx)("div", { className: "editor-post-publish-panel__header-publish-button", children: /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(
            post_publish_button_default,
            {
              onSubmit: this.onSubmit,
              forceIsDirty
            }
          ) })
        ] }) }),
        /* @__PURE__ */ (0, import_jsx_runtime410.jsxs)("div", { className: "editor-post-publish-panel__content", children: [
          isPrePublish && /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(prepublish_default, { children: PrePublishExtension && /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(PrePublishExtension, {}) }),
          isPostPublish && /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(PostPublishPanelPostpublish, { focusOnMount: true, children: PostPublishExtension && /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(PostPublishExtension, {}) }),
          isSaving && /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(import_components216.Spinner, {})
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime410.jsx)("div", { className: "editor-post-publish-panel__footer", children: /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(
          import_components216.CheckboxControl,
          {
            label: (0, import_i18n242.__)("Always show pre-publish checks."),
            checked: isPublishSidebarEnabled2,
            onChange: onTogglePublishSidebar
          }
        ) })
      ] });
    }
  };
  var post_publish_panel_default = (0, import_compose50.compose)([
    (0, import_data156.withSelect)((select7) => {
      const { getPostType } = select7(import_core_data97.store);
      const {
        getCurrentPost: getCurrentPost2,
        getCurrentPostId: getCurrentPostId2,
        getEditedPostAttribute: getEditedPostAttribute2,
        isCurrentPostPublished: isCurrentPostPublished2,
        isCurrentPostScheduled: isCurrentPostScheduled2,
        isEditedPostBeingScheduled: isEditedPostBeingScheduled2,
        isEditedPostDirty: isEditedPostDirty2,
        isAutosavingPost: isAutosavingPost2,
        isSavingPost: isSavingPost2,
        isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2
      } = select7(store3);
      const { isPublishSidebarEnabled: isPublishSidebarEnabled2 } = select7(store3);
      const postType2 = getPostType(getEditedPostAttribute2("type"));
      return {
        hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false,
        isPostTypeViewable: postType2?.viewable,
        isBeingScheduled: isEditedPostBeingScheduled2(),
        isDirty: isEditedPostDirty2(),
        isPublished: isCurrentPostPublished2(),
        isPublishSidebarEnabled: isPublishSidebarEnabled2(),
        isSaving: isSavingPost2() && !isAutosavingPost2(),
        isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2(),
        isScheduled: isCurrentPostScheduled2(),
        currentPostId: getCurrentPostId2()
      };
    }),
    (0, import_data156.withDispatch)((dispatch7, { isPublishSidebarEnabled: isPublishSidebarEnabled2 }) => {
      const { disablePublishSidebar: disablePublishSidebar2, enablePublishSidebar: enablePublishSidebar2 } = dispatch7(store3);
      return {
        onTogglePublishSidebar: () => {
          if (isPublishSidebarEnabled2) {
            disablePublishSidebar2();
          } else {
            enablePublishSidebar2();
          }
        }
      };
    }),
    import_components216.withFocusReturn,
    import_components216.withConstrainedTabbing
  ])(PostPublishPanel);

  // packages/editor/build-module/components/post-saved-state/index.mjs
  var import_components219 = __toESM(require_components(), 1);
  var import_compose52 = __toESM(require_compose(), 1);
  var import_data160 = __toESM(require_data(), 1);
  var import_element227 = __toESM(require_element(), 1);
  var import_i18n245 = __toESM(require_i18n(), 1);
  var import_keycodes13 = __toESM(require_keycodes(), 1);
  var import_preferences14 = __toESM(require_preferences(), 1);

  // packages/editor/build-module/components/post-status/index.mjs
  var import_components218 = __toESM(require_components(), 1);
  var import_i18n244 = __toESM(require_i18n(), 1);
  var import_data159 = __toESM(require_data(), 1);
  var import_element226 = __toESM(require_element(), 1);
  var import_core_data98 = __toESM(require_core_data(), 1);
  var import_block_editor58 = __toESM(require_block_editor(), 1);
  var import_compose51 = __toESM(require_compose(), 1);

  // packages/editor/build-module/components/post-sticky/index.mjs
  var import_i18n243 = __toESM(require_i18n(), 1);
  var import_components217 = __toESM(require_components(), 1);
  var import_data158 = __toESM(require_data(), 1);

  // packages/editor/build-module/components/post-sticky/check.mjs
  var import_data157 = __toESM(require_data(), 1);
  function PostStickyCheck({ children }) {
    const { hasStickyAction, postType: postType2 } = (0, import_data157.useSelect)((select7) => {
      const post2 = select7(store3).getCurrentPost();
      return {
        hasStickyAction: post2._links?.["wp:action-sticky"] ?? false,
        postType: select7(store3).getCurrentPostType()
      };
    }, []);
    if (postType2 !== "post" || !hasStickyAction) {
      return null;
    }
    return children;
  }

  // packages/editor/build-module/components/post-sticky/index.mjs
  var import_jsx_runtime411 = __toESM(require_jsx_runtime(), 1);
  function PostSticky() {
    const postSticky = (0, import_data158.useSelect)((select7) => {
      return select7(store3).getEditedPostAttribute("sticky") ?? false;
    }, []);
    const { editPost: editPost2 } = (0, import_data158.useDispatch)(store3);
    return /* @__PURE__ */ (0, import_jsx_runtime411.jsx)(PostStickyCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime411.jsx)(
      import_components217.CheckboxControl,
      {
        className: "editor-post-sticky__checkbox-control",
        label: (0, import_i18n243.__)("Sticky"),
        help: (0, import_i18n243.__)("Pin this post to the top of the blog."),
        checked: postSticky,
        onChange: () => editPost2({ sticky: !postSticky })
      }
    ) });
  }

  // packages/editor/build-module/components/post-status/index.mjs
  var import_jsx_runtime412 = __toESM(require_jsx_runtime(), 1);
  var postStatusesInfo = {
    "auto-draft": { label: (0, import_i18n244.__)("Draft"), icon: drafts_default },
    draft: { label: (0, import_i18n244.__)("Draft"), icon: drafts_default },
    pending: { label: (0, import_i18n244.__)("Pending"), icon: pending_default },
    private: { label: (0, import_i18n244.__)("Private"), icon: not_allowed_default },
    future: { label: (0, import_i18n244.__)("Scheduled"), icon: scheduled_default },
    publish: { label: (0, import_i18n244.__)("Published"), icon: published_default }
  };
  var STATUS_OPTIONS = [
    {
      label: (0, import_i18n244.__)("Draft"),
      value: "draft",
      description: (0, import_i18n244.__)("Not ready to publish.")
    },
    {
      label: (0, import_i18n244.__)("Pending"),
      value: "pending",
      description: (0, import_i18n244.__)("Waiting for review before publishing.")
    },
    {
      label: (0, import_i18n244.__)("Private"),
      value: "private",
      description: (0, import_i18n244.__)("Only visible to site admins and editors.")
    },
    {
      label: (0, import_i18n244.__)("Scheduled"),
      value: "future",
      description: (0, import_i18n244.__)("Publish automatically on a chosen date.")
    },
    {
      label: (0, import_i18n244.__)("Published"),
      value: "publish",
      description: (0, import_i18n244.__)("Visible to everyone.")
    }
  ];
  function PostStatus() {
    const { status, date, password, postId: postId2, postType: postType2, canEdit } = (0, import_data159.useSelect)(
      (select7) => {
        const {
          getEditedPostAttribute: getEditedPostAttribute2,
          getCurrentPostId: getCurrentPostId2,
          getCurrentPostType: getCurrentPostType2,
          getCurrentPost: getCurrentPost2
        } = select7(store3);
        return {
          status: getEditedPostAttribute2("status"),
          date: getEditedPostAttribute2("date"),
          password: getEditedPostAttribute2("password"),
          postId: getCurrentPostId2(),
          postType: getCurrentPostType2(),
          canEdit: getCurrentPost2()._links?.["wp:action-publish"] ?? false
        };
      },
      []
    );
    const [showPassword, setShowPassword] = (0, import_element226.useState)(!!password);
    const passwordInputId = (0, import_compose51.useInstanceId)(
      PostStatus,
      "editor-change-status__password-input"
    );
    const { editEntityRecord } = (0, import_data159.useDispatch)(import_core_data98.store);
    const [popoverAnchor, setPopoverAnchor] = (0, import_element226.useState)(null);
    const popoverProps = (0, import_element226.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        "aria-label": (0, import_i18n244.__)("Status & visibility"),
        headerTitle: (0, import_i18n244.__)("Status & visibility"),
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    if (DESIGN_POST_TYPES.includes(postType2)) {
      return null;
    }
    const updatePost2 = ({
      status: newStatus = status,
      password: newPassword = password,
      date: newDate = date
    }) => {
      editEntityRecord("postType", postType2, postId2, {
        status: newStatus,
        date: newDate,
        password: newPassword
      });
    };
    const handleTogglePassword = (value) => {
      setShowPassword(value);
      if (!value) {
        updatePost2({ password: "" });
      }
    };
    const handleStatus = (value) => {
      let newDate = date;
      let newPassword = password;
      if (status === "future" && new Date(date) > /* @__PURE__ */ new Date()) {
        newDate = null;
      }
      if (value === "private" && password) {
        newPassword = "";
      }
      updatePost2({
        status: value,
        date: newDate,
        password: newPassword
      });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(post_panel_row_default, { label: (0, import_i18n244.__)("Status"), ref: setPopoverAnchor, children: canEdit ? /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
      import_components218.Dropdown,
      {
        className: "editor-post-status",
        contentClassName: "editor-change-status__content",
        popoverProps,
        focusOnMount: true,
        renderToggle: ({ onToggle, isOpen: isOpen2 }) => /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
          import_components218.Button,
          {
            className: "editor-post-status__toggle",
            variant: "tertiary",
            size: "compact",
            onClick: onToggle,
            icon: postStatusesInfo[status]?.icon,
            "aria-label": (0, import_i18n244.sprintf)(
              // translators: %s: Current post status.
              (0, import_i18n244.__)("Change status: %s"),
              postStatusesInfo[status]?.label
            ),
            "aria-expanded": isOpen2,
            children: postStatusesInfo[status]?.label
          }
        ),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime412.jsxs)(import_jsx_runtime412.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
            import_block_editor58.__experimentalInspectorPopoverHeader,
            {
              title: (0, import_i18n244.__)("Status & visibility"),
              onClose
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
            "form",
            {
              onSubmit: (event) => {
                event.preventDefault();
                onClose();
              },
              children: /* @__PURE__ */ (0, import_jsx_runtime412.jsxs)(import_components218.__experimentalVStack, { spacing: 4, children: [
                /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
                  import_components218.RadioControl,
                  {
                    className: "editor-change-status__options",
                    hideLabelFromVision: true,
                    label: (0, import_i18n244.__)("Status"),
                    options: STATUS_OPTIONS,
                    onChange: handleStatus,
                    selected: status === "auto-draft" ? "draft" : status
                  }
                ),
                status === "future" && /* @__PURE__ */ (0, import_jsx_runtime412.jsx)("div", { className: "editor-change-status__publish-date-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
                  PrivatePostSchedule,
                  {
                    showPopoverHeaderActions: false,
                    isCompact: true
                  }
                ) }),
                status !== "private" && /* @__PURE__ */ (0, import_jsx_runtime412.jsxs)(
                  import_components218.__experimentalVStack,
                  {
                    as: "fieldset",
                    spacing: 4,
                    className: "editor-change-status__password-fieldset",
                    children: [
                      /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
                        import_components218.CheckboxControl,
                        {
                          label: (0, import_i18n244.__)(
                            "Password protected"
                          ),
                          help: (0, import_i18n244.__)(
                            "Only visible to those who know the password."
                          ),
                          checked: showPassword,
                          onChange: handleTogglePassword
                        }
                      ),
                      showPassword && /* @__PURE__ */ (0, import_jsx_runtime412.jsx)("div", { className: "editor-change-status__password-input", children: /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
                        import_components218.TextControl,
                        {
                          label: (0, import_i18n244.__)(
                            "Password"
                          ),
                          onChange: (value) => updatePost2({
                            password: value
                          }),
                          value: password,
                          placeholder: (0, import_i18n244.__)(
                            "Use a secure password"
                          ),
                          type: "text",
                          id: passwordInputId,
                          __next40pxDefaultSize: true,
                          maxLength: 255
                        }
                      ) })
                    ]
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(PostSticky, {})
              ] })
            }
          )
        ] })
      }
    ) : /* @__PURE__ */ (0, import_jsx_runtime412.jsx)("div", { className: "editor-post-status is-read-only", children: postStatusesInfo[status]?.label }) });
  }

  // packages/editor/build-module/components/post-saved-state/index.mjs
  var import_jsx_runtime413 = __toESM(require_jsx_runtime(), 1);
  function PostSavedState({ forceIsDirty }) {
    const [forceSavedMessage, setForceSavedMessage] = (0, import_element227.useState)(false);
    const isLargeViewport = (0, import_compose52.useViewportMatch)("small");
    const {
      isAutosaving,
      isDirty,
      isNew,
      isPublished,
      isSaveable,
      isSaving,
      isSavingLocked,
      isScheduled,
      hasPublishAction,
      showIconLabels,
      postStatus,
      postStatusHasChanged,
      postType: postType2
    } = (0, import_data160.useSelect)(
      (select7) => {
        const {
          isEditedPostNew: isEditedPostNew2,
          isCurrentPostPublished: isCurrentPostPublished2,
          isCurrentPostScheduled: isCurrentPostScheduled2,
          isEditedPostDirty: isEditedPostDirty2,
          isSavingPost: isSavingPost2,
          isEditedPostSaveable: isEditedPostSaveable2,
          isPostSavingLocked: isPostSavingLocked2,
          getCurrentPost: getCurrentPost2,
          isAutosavingPost: isAutosavingPost2,
          getEditedPostAttribute: getEditedPostAttribute2,
          getPostEdits: getPostEdits2
        } = select7(store3);
        const { get } = select7(import_preferences14.store);
        return {
          isAutosaving: isAutosavingPost2(),
          isDirty: forceIsDirty || isEditedPostDirty2(),
          isNew: isEditedPostNew2(),
          isPublished: isCurrentPostPublished2(),
          isSaving: isSavingPost2(),
          isSaveable: isEditedPostSaveable2(),
          isSavingLocked: isPostSavingLocked2(),
          isScheduled: isCurrentPostScheduled2(),
          hasPublishAction: getCurrentPost2()?._links?.["wp:action-publish"] ?? false,
          showIconLabels: get("core", "showIconLabels"),
          postStatus: getEditedPostAttribute2("status"),
          postStatusHasChanged: !!getPostEdits2()?.status,
          postType: select7(store3).getCurrentPostType()
        };
      },
      [forceIsDirty]
    );
    const isPending = postStatus === "pending";
    const { savePost: savePost2 } = (0, import_data160.useDispatch)(store3);
    const wasSaving = (0, import_compose52.usePrevious)(isSaving);
    (0, import_element227.useEffect)(() => {
      let timeoutId;
      if (wasSaving && !isSaving) {
        setForceSavedMessage(true);
        timeoutId = setTimeout(() => {
          setForceSavedMessage(false);
        }, 1e3);
      }
      return () => clearTimeout(timeoutId);
    }, [isSaving]);
    if (postType2 === ATTACHMENT_POST_TYPE) {
      return null;
    }
    if (!hasPublishAction && isPending) {
      return null;
    }
    const isIneligibleStatus = !["pending", "draft", "auto-draft"].includes(postStatus) && STATUS_OPTIONS.map(({ value }) => value).includes(postStatus);
    if (isPublished || isScheduled || isIneligibleStatus || postStatusHasChanged && ["pending", "draft"].includes(postStatus)) {
      return null;
    }
    const label = isPending ? (0, import_i18n245.__)("Save as pending") : (0, import_i18n245.__)("Save draft");
    const shortLabel = (0, import_i18n245.__)("Save");
    const isSaved = forceSavedMessage || !isNew && !isDirty;
    const isSavedState = isSaving || isSaved;
    const isDisabled = isSaving || isSaved || !isSaveable || isSavingLocked;
    let text;
    if (isSaving) {
      text = isAutosaving ? (0, import_i18n245.__)("Autosaving") : (0, import_i18n245.__)("Saving");
    } else if (isSaved) {
      text = (0, import_i18n245.__)("Saved");
    } else if (isLargeViewport) {
      text = label;
    } else if (showIconLabels) {
      text = shortLabel;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime413.jsxs)(
      import_components219.Button,
      {
        className: isSaveable || isSaving ? clsx_default({
          "editor-post-save-draft": !isSavedState,
          "editor-post-saved-state": isSavedState,
          "is-saving": isSaving,
          "is-autosaving": isAutosaving,
          "is-saved": isSaved,
          [(0, import_components219.__unstableGetAnimateClassName)({
            type: "loading"
          })]: isSaving
        }) : void 0,
        onClick: isDisabled ? void 0 : () => savePost2(),
        shortcut: isDisabled ? void 0 : import_keycodes13.displayShortcut.primary("s"),
        variant: "tertiary",
        size: "compact",
        icon: isLargeViewport ? void 0 : cloud_upload_default,
        label: text || label,
        "aria-disabled": isDisabled,
        children: [
          isSavedState && /* @__PURE__ */ (0, import_jsx_runtime413.jsx)(icon_default, { icon: isSaved ? check_default : cloud_default }),
          text
        ]
      }
    );
  }

  // packages/editor/build-module/components/post-schedule/check.mjs
  var import_data161 = __toESM(require_data(), 1);
  function PostScheduleCheck({ children }) {
    const hasPublishAction = (0, import_data161.useSelect)((select7) => {
      return select7(store3).getCurrentPost()._links?.["wp:action-publish"] ?? false;
    }, []);
    if (!hasPublishAction) {
      return null;
    }
    return children;
  }

  // packages/editor/build-module/components/post-schedule/panel.mjs
  var import_components220 = __toESM(require_components(), 1);
  var import_i18n246 = __toESM(require_i18n(), 1);
  var import_element228 = __toESM(require_element(), 1);
  var import_data162 = __toESM(require_data(), 1);
  var import_jsx_runtime414 = __toESM(require_jsx_runtime(), 1);
  function PostSchedulePanel() {
    const [popoverAnchor, setPopoverAnchor] = (0, import_element228.useState)(null);
    const postType2 = (0, import_data162.useSelect)(
      (select7) => select7(store3).getCurrentPostType(),
      []
    );
    const popoverProps = (0, import_element228.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        "aria-label": (0, import_i18n246.__)("Change publish date"),
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    const label = usePostScheduleLabel();
    const fullLabel = usePostScheduleLabel({ full: true });
    if (DESIGN_POST_TYPES.includes(postType2)) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(PostScheduleCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(post_panel_row_default, { label: (0, import_i18n246.__)("Publish"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(
      import_components220.Dropdown,
      {
        popoverProps,
        focusOnMount: true,
        className: "editor-post-schedule__panel-dropdown",
        contentClassName: "editor-post-schedule__dialog",
        renderToggle: ({ onToggle, isOpen: isOpen2 }) => /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(
          import_components220.Button,
          {
            size: "compact",
            className: "editor-post-schedule__dialog-toggle",
            variant: "tertiary",
            tooltipPosition: "middle left",
            onClick: onToggle,
            "aria-label": (0, import_i18n246.sprintf)(
              // translators: %s: Current post date.
              (0, import_i18n246.__)("Change date: %s"),
              label
            ),
            label: fullLabel,
            showTooltip: label !== fullLabel,
            "aria-expanded": isOpen2,
            children: label
          }
        ),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(PostSchedule, { onClose })
      }
    ) }) });
  }

  // packages/editor/build-module/components/post-switch-to-draft-button/index.mjs
  var import_components221 = __toESM(require_components(), 1);
  var import_i18n247 = __toESM(require_i18n(), 1);
  var import_data163 = __toESM(require_data(), 1);
  var import_element229 = __toESM(require_element(), 1);
  var import_deprecated11 = __toESM(require_deprecated(), 1);
  var import_jsx_runtime415 = __toESM(require_jsx_runtime(), 1);
  function PostSwitchToDraftButton() {
    (0, import_deprecated11.default)("wp.editor.PostSwitchToDraftButton", {
      since: "6.7",
      version: "6.9"
    });
    const [showConfirmDialog, setShowConfirmDialog] = (0, import_element229.useState)(false);
    const { editPost: editPost2, savePost: savePost2 } = (0, import_data163.useDispatch)(store3);
    const { isSaving, isPublished, isScheduled } = (0, import_data163.useSelect)((select7) => {
      const { isSavingPost: isSavingPost2, isCurrentPostPublished: isCurrentPostPublished2, isCurrentPostScheduled: isCurrentPostScheduled2 } = select7(store3);
      return {
        isSaving: isSavingPost2(),
        isPublished: isCurrentPostPublished2(),
        isScheduled: isCurrentPostScheduled2()
      };
    }, []);
    const isDisabled = isSaving || !isPublished && !isScheduled;
    let alertMessage;
    let confirmButtonText;
    if (isPublished) {
      alertMessage = (0, import_i18n247.__)("Are you sure you want to unpublish this post?");
      confirmButtonText = (0, import_i18n247.__)("Unpublish");
    } else if (isScheduled) {
      alertMessage = (0, import_i18n247.__)("Are you sure you want to unschedule this post?");
      confirmButtonText = (0, import_i18n247.__)("Unschedule");
    }
    const handleConfirm = () => {
      setShowConfirmDialog(false);
      editPost2({ status: "draft" });
      savePost2();
    };
    return /* @__PURE__ */ (0, import_jsx_runtime415.jsxs)(import_jsx_runtime415.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(
        import_components221.Button,
        {
          __next40pxDefaultSize: true,
          className: "editor-post-switch-to-draft",
          onClick: () => {
            if (!isDisabled) {
              setShowConfirmDialog(true);
            }
          },
          "aria-disabled": isDisabled,
          variant: "secondary",
          style: { flexGrow: "1", justifyContent: "center" },
          children: (0, import_i18n247.__)("Switch to draft")
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(
        import_components221.__experimentalConfirmDialog,
        {
          isOpen: showConfirmDialog,
          onConfirm: handleConfirm,
          onCancel: () => setShowConfirmDialog(false),
          confirmButtonText,
          children: alertMessage
        }
      )
    ] });
  }

  // packages/editor/build-module/components/post-sync-status/index.mjs
  var import_data164 = __toESM(require_data(), 1);
  var import_i18n248 = __toESM(require_i18n(), 1);
  var import_jsx_runtime416 = __toESM(require_jsx_runtime(), 1);
  function PostSyncStatus() {
    const { syncStatus, postType: postType2 } = (0, import_data164.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
      const meta2 = getEditedPostAttribute2("meta");
      const currentSyncStatus = meta2?.wp_pattern_sync_status === "unsynced" ? "unsynced" : getEditedPostAttribute2("wp_pattern_sync_status");
      return {
        syncStatus: currentSyncStatus,
        postType: getEditedPostAttribute2("type")
      };
    });
    if (postType2 !== "wp_block") {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(post_panel_row_default, { label: (0, import_i18n248.__)("Sync status"), children: /* @__PURE__ */ (0, import_jsx_runtime416.jsx)("div", { className: "editor-post-sync-status__value", children: syncStatus === "unsynced" ? (0, import_i18n248._x)("Not synced", "pattern (singular)") : (0, import_i18n248._x)("Synced", "pattern (singular)") }) });
  }

  // packages/editor/build-module/components/post-taxonomies/index.mjs
  var import_element230 = __toESM(require_element(), 1);
  var import_data165 = __toESM(require_data(), 1);
  var import_core_data99 = __toESM(require_core_data(), 1);
  var import_jsx_runtime417 = __toESM(require_jsx_runtime(), 1);
  var identity4 = (x2) => x2;
  function PostTaxonomies({ taxonomyWrapper = identity4 }) {
    const { postType: postType2, taxonomies } = (0, import_data165.useSelect)((select7) => {
      return {
        postType: select7(store3).getCurrentPostType(),
        taxonomies: select7(import_core_data99.store).getEntityRecords(
          "root",
          "taxonomy",
          { per_page: -1 }
        )
      };
    }, []);
    const visibleTaxonomies = (taxonomies ?? []).filter(
      (taxonomy) => (
        // In some circumstances .visibility can end up as undefined so optional chaining operator required.
        // https://github.com/WordPress/gutenberg/issues/40326
        taxonomy.types.includes(postType2) && taxonomy.visibility?.show_ui
      )
    );
    return visibleTaxonomies.map((taxonomy) => {
      const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector_default : flat_term_selector_default;
      return /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(import_element230.Fragment, { children: taxonomyWrapper(
        /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(TaxonomyComponent, { slug: taxonomy.slug }),
        taxonomy
      ) }, `taxonomy-${taxonomy.slug}`);
    });
  }
  var post_taxonomies_default = PostTaxonomies;

  // packages/editor/build-module/components/post-taxonomies/check.mjs
  var import_data166 = __toESM(require_data(), 1);
  var import_core_data100 = __toESM(require_core_data(), 1);
  function PostTaxonomiesCheck({ children }) {
    const hasTaxonomies = (0, import_data166.useSelect)((select7) => {
      const postType2 = select7(store3).getCurrentPostType();
      const taxonomies = select7(import_core_data100.store).getEntityRecords(
        "root",
        "taxonomy",
        { per_page: -1 }
      );
      return taxonomies?.some(
        (taxonomy) => taxonomy.types.includes(postType2)
      );
    }, []);
    if (!hasTaxonomies) {
      return null;
    }
    return children;
  }

  // packages/editor/build-module/components/post-taxonomies/panel.mjs
  var import_components222 = __toESM(require_components(), 1);
  var import_data167 = __toESM(require_data(), 1);
  var import_jsx_runtime418 = __toESM(require_jsx_runtime(), 1);
  function TaxonomyPanel({ taxonomy, children }) {
    const slug = taxonomy?.slug;
    const panelName = slug ? `taxonomy-panel-${slug}` : "";
    const { isEnabled, isOpened } = (0, import_data167.useSelect)(
      (select7) => {
        const { isEditorPanelEnabled: isEditorPanelEnabled2, isEditorPanelOpened: isEditorPanelOpened2 } = select7(store3);
        return {
          isEnabled: slug ? isEditorPanelEnabled2(panelName) : false,
          isOpened: slug ? isEditorPanelOpened2(panelName) : false
        };
      },
      [panelName, slug]
    );
    const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data167.useDispatch)(store3);
    if (!isEnabled) {
      return null;
    }
    const taxonomyMenuName = taxonomy?.labels?.menu_name;
    if (!taxonomyMenuName) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(
      import_components222.PanelBody,
      {
        title: taxonomyMenuName,
        opened: isOpened,
        onToggle: () => toggleEditorPanelOpened2(panelName),
        children
      }
    );
  }
  function PostTaxonomies2() {
    return /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(PostTaxonomiesCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(
      post_taxonomies_default,
      {
        taxonomyWrapper: (content, taxonomy) => {
          return /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(TaxonomyPanel, { taxonomy, children: content });
        }
      }
    ) });
  }

  // packages/editor/build-module/components/post-text-editor/index.mjs
  var import_react_autosize_textarea = __toESM(require_lib(), 1);
  var import_i18n249 = __toESM(require_i18n(), 1);
  var import_core_data101 = __toESM(require_core_data(), 1);
  var import_data168 = __toESM(require_data(), 1);
  var import_compose53 = __toESM(require_compose(), 1);
  var import_jsx_runtime419 = __toESM(require_jsx_runtime(), 1);
  function PostTextEditor() {
    const instanceId = (0, import_compose53.useInstanceId)(PostTextEditor);
    const { value, type, id } = (0, import_data168.useSelect)((select7) => {
      const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2, getEditedPostContent: getEditedPostContent2 } = select7(store3);
      return {
        value: getEditedPostContent2(),
        type: getCurrentPostType2(),
        id: getCurrentPostId2()
      };
    }, []);
    const { editEntityRecord } = (0, import_data168.useDispatch)(import_core_data101.store);
    return /* @__PURE__ */ (0, import_jsx_runtime419.jsxs)(import_jsx_runtime419.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(
        VisuallyHidden,
        {
          render: /* @__PURE__ */ (0, import_jsx_runtime419.jsx)("label", { htmlFor: `post-content-${instanceId}` }),
          children: (0, import_i18n249.__)("Type text or HTML")
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(
        import_react_autosize_textarea.default,
        {
          autoComplete: "off",
          dir: "auto",
          value,
          onChange: (event) => {
            editEntityRecord("postType", type, id, {
              content: event.target.value,
              blocks: void 0,
              selection: void 0
            });
          },
          className: "editor-post-text-editor",
          id: `post-content-${instanceId}`,
          placeholder: (0, import_i18n249.__)("Start writing with text or HTML")
        }
      )
    ] });
  }

  // packages/editor/build-module/components/post-title/index.mjs
  var import_i18n250 = __toESM(require_i18n(), 1);
  var import_element232 = __toESM(require_element(), 1);
  var import_html_entities26 = __toESM(require_html_entities(), 1);
  var import_data171 = __toESM(require_data(), 1);
  var import_block_editor59 = __toESM(require_block_editor(), 1);
  var import_keycodes14 = __toESM(require_keycodes(), 1);
  var import_blocks27 = __toESM(require_blocks(), 1);
  var import_rich_text3 = __toESM(require_rich_text(), 1);
  var import_compose54 = __toESM(require_compose(), 1);
  var import_dom12 = __toESM(require_dom(), 1);

  // packages/editor/build-module/components/post-title/constants.mjs
  var DEFAULT_CLASSNAMES = "wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text";
  var REGEXP_NEWLINES = /[\r\n]+/g;

  // packages/editor/build-module/components/post-title/use-post-title-focus.mjs
  var import_element231 = __toESM(require_element(), 1);
  var import_data169 = __toESM(require_data(), 1);
  function usePostTitleFocus(forwardedRef) {
    const ref = (0, import_element231.useRef)();
    const { isCleanNewPost: isCleanNewPost2 } = (0, import_data169.useSelect)((select7) => {
      const { isCleanNewPost: _isCleanNewPost } = select7(store3);
      return {
        isCleanNewPost: _isCleanNewPost()
      };
    }, []);
    (0, import_element231.useImperativeHandle)(forwardedRef, () => ({
      focus: () => {
        ref?.current?.focus();
      }
    }));
    (0, import_element231.useEffect)(() => {
      if (!ref.current) {
        return;
      }
      const { defaultView } = ref.current.ownerDocument;
      const { name: name2, parent } = defaultView;
      const ownerDocument = name2 === "editor-canvas" ? parent.document : defaultView.document;
      const { activeElement, body } = ownerDocument;
      if (isCleanNewPost2 && (!activeElement || body === activeElement)) {
        ref.current.focus();
      }
    }, [isCleanNewPost2]);
    return { ref };
  }

  // packages/editor/build-module/components/post-title/use-post-title.mjs
  var import_data170 = __toESM(require_data(), 1);
  function usePostTitle() {
    const { editPost: editPost2 } = (0, import_data170.useDispatch)(store3);
    const { title } = (0, import_data170.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
      return {
        title: getEditedPostAttribute2("title")
      };
    }, []);
    function updateTitle(newTitle) {
      editPost2({ title: newTitle });
    }
    return { title, setTitle: updateTitle };
  }

  // packages/editor/build-module/components/post-title/index.mjs
  var import_jsx_runtime420 = __toESM(require_jsx_runtime(), 1);
  var { useRichText } = unlock(import_rich_text3.privateApis);
  var PostTitle = (0, import_element232.forwardRef)((_, forwardedRef) => {
    const { placeholder, isEditingContentOnlySection, isPreview } = (0, import_data171.useSelect)(
      (select7) => {
        const { getSettings: getSettings11, getEditedContentOnlySection } = unlock(
          select7(import_block_editor59.store)
        );
        const { titlePlaceholder, isPreviewMode } = getSettings11();
        return {
          placeholder: titlePlaceholder,
          isEditingContentOnlySection: !!getEditedContentOnlySection(),
          isPreview: isPreviewMode
        };
      },
      []
    );
    const [isSelected2, setIsSelected] = (0, import_element232.useState)(false);
    const { ref: focusRef } = usePostTitleFocus(forwardedRef);
    const { title, setTitle: onUpdate } = usePostTitle();
    const [selection, setSelection] = (0, import_element232.useState)({});
    const { clearSelectedBlock: clearSelectedBlock2, insertBlocks: insertBlocks2, insertDefaultBlock: insertDefaultBlock2 } = (0, import_data171.useDispatch)(import_block_editor59.store);
    const decodedPlaceholder = (0, import_html_entities26.decodeEntities)(placeholder) || (0, import_i18n250.__)("Add title");
    const {
      value,
      onChange,
      ref: richTextRef
    } = useRichText({
      value: title,
      onChange(newValue) {
        onUpdate(newValue.replace(REGEXP_NEWLINES, " "));
      },
      placeholder: decodedPlaceholder,
      selectionStart: selection.start,
      selectionEnd: selection.end,
      onSelectionChange(newStart, newEnd) {
        setSelection((sel) => {
          const { start: start2, end } = sel;
          if (start2 === newStart && end === newEnd) {
            return sel;
          }
          return {
            start: newStart,
            end: newEnd
          };
        });
      },
      __unstableDisableFormats: false
    });
    function onInsertBlockAfter(blocks) {
      insertBlocks2(blocks, 0);
    }
    function onSelect() {
      setIsSelected(true);
      clearSelectedBlock2();
    }
    function onUnselect() {
      setIsSelected(false);
      setSelection({});
    }
    function onEnterPress() {
      insertDefaultBlock2(void 0, void 0, 0);
    }
    function onKeyDown(event) {
      if (event.keyCode === import_keycodes14.ENTER) {
        event.preventDefault();
        onEnterPress();
      }
    }
    function onPaste(event) {
      const clipboardData = event.clipboardData;
      let plainText = "";
      let html = "";
      try {
        plainText = clipboardData.getData("text/plain");
        html = clipboardData.getData("text/html");
      } catch {
        return;
      }
      const content = (0, import_blocks27.pasteHandler)({
        HTML: html,
        plainText
      });
      event.preventDefault();
      if (!content.length) {
        return;
      }
      if (typeof content !== "string") {
        const [firstBlock] = content;
        if (!title && (firstBlock.name === "core/heading" || firstBlock.name === "core/paragraph")) {
          const contentNoHTML = (0, import_dom12.__unstableStripHTML)(
            firstBlock.attributes.content
          );
          onUpdate(contentNoHTML);
          onInsertBlockAfter(content.slice(1));
        } else {
          onInsertBlockAfter(content);
        }
      } else {
        const contentNoHTML = (0, import_dom12.__unstableStripHTML)(content);
        onChange((0, import_rich_text3.insert)(value, (0, import_rich_text3.create)({ html: contentNoHTML })));
      }
    }
    const className = clsx_default(DEFAULT_CLASSNAMES, {
      "is-selected": isSelected2
    });
    const style = isEditingContentOnlySection ? { opacity: 0.2 } : void 0;
    return (
      /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */
      /* @__PURE__ */ (0, import_jsx_runtime420.jsx)(
        "h1",
        {
          ref: (0, import_compose54.useMergeRefs)([richTextRef, focusRef]),
          contentEditable: !isEditingContentOnlySection && !isPreview,
          className,
          "aria-label": decodedPlaceholder,
          role: "textbox",
          "aria-multiline": "true",
          onFocus: onSelect,
          onBlur: onUnselect,
          onKeyDown,
          onPaste,
          style
        }
      )
    );
  });
  var post_title_default = (0, import_element232.forwardRef)((_, forwardedRef) => /* @__PURE__ */ (0, import_jsx_runtime420.jsx)(post_type_support_check_default, { supportKeys: "title", children: /* @__PURE__ */ (0, import_jsx_runtime420.jsx)(PostTitle, { ref: forwardedRef }) }));

  // packages/editor/build-module/components/post-title/post-title-raw.mjs
  var import_components223 = __toESM(require_components(), 1);
  var import_i18n251 = __toESM(require_i18n(), 1);
  var import_html_entities27 = __toESM(require_html_entities(), 1);
  var import_data172 = __toESM(require_data(), 1);
  var import_block_editor60 = __toESM(require_block_editor(), 1);
  var import_element233 = __toESM(require_element(), 1);
  var import_jsx_runtime421 = __toESM(require_jsx_runtime(), 1);
  function PostTitleRaw(_, forwardedRef) {
    const { placeholder } = (0, import_data172.useSelect)((select7) => {
      const { getSettings: getSettings11 } = select7(import_block_editor60.store);
      const { titlePlaceholder } = getSettings11();
      return {
        placeholder: titlePlaceholder
      };
    }, []);
    const [isSelected2, setIsSelected] = (0, import_element233.useState)(false);
    const { title, setTitle: onUpdate } = usePostTitle();
    const { ref: focusRef } = usePostTitleFocus(forwardedRef);
    function onChange(value) {
      onUpdate(value.replace(REGEXP_NEWLINES, " "));
    }
    function onSelect() {
      setIsSelected(true);
    }
    function onUnselect() {
      setIsSelected(false);
    }
    const className = clsx_default(DEFAULT_CLASSNAMES, {
      "is-selected": isSelected2,
      "is-raw-text": true
    });
    const decodedPlaceholder = (0, import_html_entities27.decodeEntities)(placeholder) || (0, import_i18n251.__)("Add title");
    return /* @__PURE__ */ (0, import_jsx_runtime421.jsx)(
      import_components223.TextareaControl,
      {
        ref: focusRef,
        value: title,
        onChange,
        onFocus: onSelect,
        onBlur: onUnselect,
        label: placeholder,
        className,
        placeholder: decodedPlaceholder,
        hideLabelFromVision: true,
        autoComplete: "off",
        dir: "auto",
        rows: 1
      }
    );
  }
  var post_title_raw_default = (0, import_element233.forwardRef)(PostTitleRaw);

  // packages/editor/build-module/components/post-trash/index.mjs
  var import_i18n252 = __toESM(require_i18n(), 1);
  var import_components224 = __toESM(require_components(), 1);
  var import_data174 = __toESM(require_data(), 1);
  var import_element234 = __toESM(require_element(), 1);

  // packages/editor/build-module/components/post-trash/check.mjs
  var import_data173 = __toESM(require_data(), 1);
  var import_core_data102 = __toESM(require_core_data(), 1);
  function PostTrashCheck({ children }) {
    const { canTrashPost } = (0, import_data173.useSelect)((select7) => {
      const { isEditedPostNew: isEditedPostNew2, getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
      const { canUser } = select7(import_core_data102.store);
      const postType2 = getCurrentPostType2();
      const postId2 = getCurrentPostId2();
      const isNew = isEditedPostNew2();
      const canUserDelete = !!postId2 ? canUser("delete", {
        kind: "postType",
        name: postType2,
        id: postId2
      }) : false;
      return {
        canTrashPost: (!isNew || postId2) && canUserDelete && !GLOBAL_POST_TYPES.includes(postType2)
      };
    }, []);
    if (!canTrashPost) {
      return null;
    }
    return children;
  }

  // packages/editor/build-module/components/post-trash/index.mjs
  var import_jsx_runtime422 = __toESM(require_jsx_runtime(), 1);
  function PostTrash({ onActionPerformed }) {
    const registry = (0, import_data174.useRegistry)();
    const { isNew, isDeleting, postId: postId2, title } = (0, import_data174.useSelect)((select7) => {
      const store4 = select7(store3);
      return {
        isNew: store4.isEditedPostNew(),
        isDeleting: store4.isDeletingPost(),
        postId: store4.getCurrentPostId(),
        title: store4.getCurrentPostAttribute("title")
      };
    }, []);
    const { trashPost: trashPost3 } = (0, import_data174.useDispatch)(store3);
    const [showConfirmDialog, setShowConfirmDialog] = (0, import_element234.useState)(false);
    if (isNew || !postId2) {
      return null;
    }
    const handleConfirm = async () => {
      setShowConfirmDialog(false);
      await trashPost3();
      const item = await registry.resolveSelect(store3).getCurrentPost();
      onActionPerformed?.("move-to-trash", [item]);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime422.jsxs)(PostTrashCheck, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime422.jsx)(
        import_components224.Button,
        {
          __next40pxDefaultSize: true,
          className: "editor-post-trash",
          isDestructive: true,
          variant: "secondary",
          isBusy: isDeleting,
          "aria-disabled": isDeleting,
          onClick: isDeleting ? void 0 : () => setShowConfirmDialog(true),
          children: (0, import_i18n252.__)("Move to trash")
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime422.jsx)(
        import_components224.__experimentalConfirmDialog,
        {
          isOpen: showConfirmDialog,
          onConfirm: handleConfirm,
          onCancel: () => setShowConfirmDialog(false),
          confirmButtonText: (0, import_i18n252.__)("Move to trash"),
          size: "small",
          children: (0, import_i18n252.sprintf)(
            // translators: %s: The item's title.
            (0, import_i18n252.__)('Are you sure you want to move "%s" to the trash?'),
            title
          )
        }
      )
    ] });
  }

  // packages/editor/build-module/components/post-url/index.mjs
  var import_data175 = __toESM(require_data(), 1);
  var import_url20 = __toESM(require_url(), 1);
  var import_element235 = __toESM(require_element(), 1);
  var import_block_editor61 = __toESM(require_block_editor(), 1);
  var import_i18n253 = __toESM(require_i18n(), 1);
  var import_components225 = __toESM(require_components(), 1);
  var import_notices26 = __toESM(require_notices(), 1);
  var import_core_data103 = __toESM(require_core_data(), 1);
  var import_compose55 = __toESM(require_compose(), 1);
  var import_jsx_runtime423 = __toESM(require_jsx_runtime(), 1);
  function PostURL({ onClose }) {
    const {
      isEditable,
      postSlug,
      postLink,
      permalinkPrefix,
      permalinkSuffix,
      permalink
    } = (0, import_data175.useSelect)((select7) => {
      const post2 = select7(store3).getCurrentPost();
      const postTypeSlug = select7(store3).getCurrentPostType();
      const postType2 = select7(import_core_data103.store).getPostType(postTypeSlug);
      const permalinkParts = select7(store3).getPermalinkParts();
      const hasPublishAction = post2?._links?.["wp:action-publish"] ?? false;
      return {
        isEditable: select7(store3).isPermalinkEditable() && hasPublishAction,
        postSlug: (0, import_url20.safeDecodeURIComponent)(
          select7(store3).getEditedPostSlug()
        ),
        viewPostLabel: postType2?.labels.view_item,
        postLink: post2.link,
        permalinkPrefix: permalinkParts?.prefix,
        permalinkSuffix: permalinkParts?.suffix,
        permalink: (0, import_url20.safeDecodeURIComponent)(
          select7(store3).getPermalink()
        )
      };
    }, []);
    const { editPost: editPost2 } = (0, import_data175.useDispatch)(store3);
    const { createNotice } = (0, import_data175.useDispatch)(import_notices26.store);
    const [forceEmptyField, setForceEmptyField] = (0, import_element235.useState)(false);
    const copyButtonRef = (0, import_compose55.useCopyToClipboard)(permalink, () => {
      createNotice("info", (0, import_i18n253.__)("Copied Permalink to clipboard."), {
        isDismissible: true,
        type: "snackbar"
      });
    });
    const postUrlSlugDescriptionId = "editor-post-url__slug-description-" + (0, import_compose55.useInstanceId)(PostURL);
    return /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)("div", { className: "editor-post-url", children: [
      /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
        import_block_editor61.__experimentalInspectorPopoverHeader,
        {
          title: (0, import_i18n253.__)("Slug"),
          onClose
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)(import_components225.__experimentalVStack, { spacing: 3, children: [
        isEditable && /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("p", { className: "editor-post-url__intro", children: (0, import_element235.createInterpolateElement)(
          (0, import_i18n253.__)(
            "<span>Customize the last part of the Permalink.</span> <a>Learn more.</a>"
          ),
          {
            span: /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("span", { id: postUrlSlugDescriptionId }),
            a: /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
              import_components225.ExternalLink,
              {
                href: (0, import_i18n253.__)(
                  "https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink"
                )
              }
            )
          }
        ) }),
        /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)("div", { children: [
          isEditable && /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)(import_jsx_runtime423.Fragment, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
              import_components225.__experimentalInputControl,
              {
                __next40pxDefaultSize: true,
                prefix: /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(import_components225.__experimentalInputControlPrefixWrapper, { children: "/" }),
                suffix: /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(import_components225.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
                  import_components225.Button,
                  {
                    icon: copy_small_default,
                    ref: copyButtonRef,
                    size: "small",
                    label: "Copy"
                  }
                ) }),
                label: (0, import_i18n253.__)("Slug"),
                hideLabelFromVision: true,
                value: forceEmptyField ? "" : postSlug,
                autoComplete: "off",
                spellCheck: "false",
                type: "text",
                className: "editor-post-url__input",
                onChange: (newValue) => {
                  editPost2({ slug: newValue });
                  if (!newValue) {
                    if (!forceEmptyField) {
                      setForceEmptyField(true);
                    }
                    return;
                  }
                  if (forceEmptyField) {
                    setForceEmptyField(false);
                  }
                },
                onBlur: (event) => {
                  editPost2({
                    slug: (0, import_url20.cleanForSlug)(
                      event.target.value
                    )
                  });
                  if (forceEmptyField) {
                    setForceEmptyField(false);
                  }
                },
                "aria-describedby": postUrlSlugDescriptionId
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)("p", { className: "editor-post-url__permalink", children: [
              /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("span", { className: "editor-post-url__permalink-visual-label", children: (0, import_i18n253.__)("Permalink:") }),
              /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)(
                import_components225.ExternalLink,
                {
                  className: "editor-post-url__link",
                  href: postLink,
                  target: "_blank",
                  children: [
                    /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("span", { className: "editor-post-url__link-prefix", children: permalinkPrefix }),
                    /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("span", { className: "editor-post-url__link-slug", children: postSlug }),
                    /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("span", { className: "editor-post-url__link-suffix", children: permalinkSuffix })
                  ]
                }
              )
            ] })
          ] }),
          !isEditable && /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
            import_components225.ExternalLink,
            {
              className: "editor-post-url__link",
              href: postLink,
              target: "_blank",
              children: postLink
            }
          )
        ] })
      ] })
    ] });
  }

  // packages/editor/build-module/components/post-url/check.mjs
  var import_data176 = __toESM(require_data(), 1);
  var import_core_data104 = __toESM(require_core_data(), 1);
  function PostURLCheck({ children }) {
    const isVisible2 = (0, import_data176.useSelect)((select7) => {
      const postTypeSlug = select7(store3).getCurrentPostType();
      const postType2 = select7(import_core_data104.store).getPostType(postTypeSlug);
      if (!postType2?.viewable) {
        return false;
      }
      const post2 = select7(store3).getCurrentPost();
      if (!post2.link) {
        return false;
      }
      const permalinkParts = select7(store3).getPermalinkParts();
      if (!permalinkParts) {
        return false;
      }
      return true;
    }, []);
    if (!isVisible2) {
      return null;
    }
    return children;
  }

  // packages/editor/build-module/components/post-url/label.mjs
  var import_data177 = __toESM(require_data(), 1);
  var import_url21 = __toESM(require_url(), 1);
  function PostURLLabel() {
    return usePostURLLabel();
  }
  function usePostURLLabel() {
    const postLink = (0, import_data177.useSelect)(
      (select7) => select7(store3).getPermalink(),
      []
    );
    return (0, import_url21.filterURLForDisplay)((0, import_url21.safeDecodeURIComponent)(postLink));
  }

  // packages/editor/build-module/components/post-url/panel.mjs
  var import_element236 = __toESM(require_element(), 1);
  var import_data178 = __toESM(require_data(), 1);
  var import_components226 = __toESM(require_components(), 1);
  var import_i18n254 = __toESM(require_i18n(), 1);
  var import_url22 = __toESM(require_url(), 1);
  var import_core_data105 = __toESM(require_core_data(), 1);
  var import_jsx_runtime424 = __toESM(require_jsx_runtime(), 1);
  function PostURLPanel() {
    const { isFrontPage } = (0, import_data178.useSelect)((select7) => {
      const { getCurrentPostId: getCurrentPostId2 } = select7(store3);
      const { getEditedEntityRecord, canUser } = select7(import_core_data105.store);
      const siteSettings = canUser("read", {
        kind: "root",
        name: "site"
      }) ? getEditedEntityRecord("root", "site") : void 0;
      const _id = getCurrentPostId2();
      return {
        isFrontPage: siteSettings?.page_on_front === _id
      };
    }, []);
    const [popoverAnchor, setPopoverAnchor] = (0, import_element236.useState)(null);
    const popoverProps = (0, import_element236.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    const label = isFrontPage ? (0, import_i18n254.__)("Link") : (0, import_i18n254.__)("Slug");
    return /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(PostURLCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime424.jsxs)(post_panel_row_default, { label, ref: setPopoverAnchor, children: [
      !isFrontPage && /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(
        import_components226.Dropdown,
        {
          popoverProps,
          className: "editor-post-url__panel-dropdown",
          contentClassName: "editor-post-url__panel-dialog",
          focusOnMount: true,
          renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(
            PostURLToggle,
            {
              isOpen: isOpen2,
              onClick: onToggle
            }
          ),
          renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(PostURL, { onClose })
        }
      ),
      isFrontPage && /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(FrontPageLink, {})
    ] }) });
  }
  function PostURLToggle({ isOpen: isOpen2, onClick }) {
    const { slug } = (0, import_data178.useSelect)((select7) => {
      return {
        slug: select7(store3).getEditedPostSlug()
      };
    }, []);
    const decodedSlug = (0, import_url22.safeDecodeURIComponent)(slug);
    return /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(
      import_components226.Button,
      {
        size: "compact",
        className: "editor-post-url__panel-toggle",
        variant: "tertiary",
        "aria-expanded": isOpen2,
        "aria-label": (
          // translators: %s: Current post link.
          (0, import_i18n254.sprintf)((0, import_i18n254.__)("Change link: %s"), decodedSlug)
        ),
        onClick,
        children: /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(import_jsx_runtime424.Fragment, { children: decodedSlug })
      }
    );
  }
  function FrontPageLink() {
    const { postLink } = (0, import_data178.useSelect)((select7) => {
      const { getCurrentPost: getCurrentPost2 } = select7(store3);
      return {
        postLink: getCurrentPost2()?.link
      };
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(
      import_components226.ExternalLink,
      {
        className: "editor-post-url__front-page-link",
        href: postLink,
        target: "_blank",
        children: postLink
      }
    );
  }

  // packages/editor/build-module/components/post-visibility/check.mjs
  var import_data179 = __toESM(require_data(), 1);
  function PostVisibilityCheck({ render: render4 }) {
    const canEdit = (0, import_data179.useSelect)((select7) => {
      return select7(store3).getCurrentPost()._links?.["wp:action-publish"] ?? false;
    });
    return render4({ canEdit });
  }

  // packages/editor/build-module/components/table-of-contents/index.mjs
  var import_i18n258 = __toESM(require_i18n(), 1);
  var import_components227 = __toESM(require_components(), 1);
  var import_data184 = __toESM(require_data(), 1);
  var import_element238 = __toESM(require_element(), 1);
  var import_block_editor63 = __toESM(require_block_editor(), 1);

  // packages/editor/build-module/components/table-of-contents/panel.mjs
  var import_i18n257 = __toESM(require_i18n(), 1);
  var import_data183 = __toESM(require_data(), 1);
  var import_block_editor62 = __toESM(require_block_editor(), 1);

  // packages/editor/build-module/components/word-count/index.mjs
  var import_data180 = __toESM(require_data(), 1);
  var import_i18n255 = __toESM(require_i18n(), 1);
  var import_wordcount2 = __toESM(require_wordcount(), 1);
  var import_jsx_runtime425 = __toESM(require_jsx_runtime(), 1);
  function WordCount() {
    const content = (0, import_data180.useSelect)(
      (select7) => select7(store3).getEditedPostAttribute("content"),
      []
    );
    const wordCountType = (0, import_i18n255._x)("words", "Word count type. Do not translate!");
    return /* @__PURE__ */ (0, import_jsx_runtime425.jsx)("span", { className: "word-count", children: (0, import_wordcount2.count)(content, wordCountType) });
  }

  // packages/editor/build-module/components/time-to-read/index.mjs
  var import_data181 = __toESM(require_data(), 1);
  var import_i18n256 = __toESM(require_i18n(), 1);
  var import_wordcount3 = __toESM(require_wordcount(), 1);
  var import_element237 = __toESM(require_element(), 1);
  var import_jsx_runtime426 = __toESM(require_jsx_runtime(), 1);
  var AVERAGE_READING_RATE2 = 189;
  function TimeToRead() {
    const content = (0, import_data181.useSelect)(
      (select7) => select7(store3).getEditedPostAttribute("content"),
      []
    );
    const wordCountType = (0, import_i18n256._x)("words", "Word count type. Do not translate!");
    const minutesToRead = Math.round(
      (0, import_wordcount3.count)(content, wordCountType) / AVERAGE_READING_RATE2
    );
    const minutesToReadString = minutesToRead === 0 ? (0, import_element237.createInterpolateElement)((0, import_i18n256.__)("<span>< 1</span> minute"), {
      span: /* @__PURE__ */ (0, import_jsx_runtime426.jsx)("span", {})
    }) : (0, import_element237.createInterpolateElement)(
      (0, import_i18n256.sprintf)(
        /* translators: %s: the number of minutes to read the post. */
        (0, import_i18n256._n)(
          "<span>%s</span> minute",
          "<span>%s</span> minutes",
          minutesToRead
        ),
        minutesToRead
      ),
      {
        span: /* @__PURE__ */ (0, import_jsx_runtime426.jsx)("span", {})
      }
    );
    return /* @__PURE__ */ (0, import_jsx_runtime426.jsx)("span", { className: "time-to-read", children: minutesToReadString });
  }

  // packages/editor/build-module/components/character-count/index.mjs
  var import_data182 = __toESM(require_data(), 1);
  var import_wordcount4 = __toESM(require_wordcount(), 1);
  function CharacterCount() {
    const content = (0, import_data182.useSelect)(
      (select7) => select7(store3).getEditedPostAttribute("content"),
      []
    );
    return (0, import_wordcount4.count)(content, "characters_including_spaces");
  }

  // packages/editor/build-module/components/table-of-contents/panel.mjs
  var import_jsx_runtime427 = __toESM(require_jsx_runtime(), 1);
  function TableOfContentsPanel({ hasOutlineItemsDisabled, onRequestClose }) {
    const { headingCount, paragraphCount, numberOfBlocks } = (0, import_data183.useSelect)(
      (select7) => {
        const { getGlobalBlockCount: getGlobalBlockCount2 } = select7(import_block_editor62.store);
        return {
          headingCount: getGlobalBlockCount2("core/heading"),
          paragraphCount: getGlobalBlockCount2("core/paragraph"),
          numberOfBlocks: getGlobalBlockCount2()
        };
      },
      []
    );
    return (
      /*
       * Disable reason: The `list` ARIA role is redundant but
       * Safari+VoiceOver won't announce the list otherwise.
       */
      /* eslint-disable jsx-a11y/no-redundant-roles */
      /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)(import_jsx_runtime427.Fragment, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime427.jsx)(
          "div",
          {
            className: "table-of-contents__wrapper",
            role: "note",
            "aria-label": (0, import_i18n257.__)("Document Statistics"),
            tabIndex: "0",
            children: /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)("ul", { role: "list", className: "table-of-contents__counts", children: [
              /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)("li", { className: "table-of-contents__count", children: [
                (0, import_i18n257.__)("Words"),
                /* @__PURE__ */ (0, import_jsx_runtime427.jsx)(WordCount, {})
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)("li", { className: "table-of-contents__count", children: [
                (0, import_i18n257.__)("Characters"),
                /* @__PURE__ */ (0, import_jsx_runtime427.jsx)("span", { className: "table-of-contents__number", children: /* @__PURE__ */ (0, import_jsx_runtime427.jsx)(CharacterCount, {}) })
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)("li", { className: "table-of-contents__count", children: [
                (0, import_i18n257.__)("Time to read"),
                /* @__PURE__ */ (0, import_jsx_runtime427.jsx)(TimeToRead, {})
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)("li", { className: "table-of-contents__count", children: [
                (0, import_i18n257.__)("Headings"),
                /* @__PURE__ */ (0, import_jsx_runtime427.jsx)("span", { className: "table-of-contents__number", children: headingCount })
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)("li", { className: "table-of-contents__count", children: [
                (0, import_i18n257.__)("Paragraphs"),
                /* @__PURE__ */ (0, import_jsx_runtime427.jsx)("span", { className: "table-of-contents__number", children: paragraphCount })
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)("li", { className: "table-of-contents__count", children: [
                (0, import_i18n257.__)("Blocks"),
                /* @__PURE__ */ (0, import_jsx_runtime427.jsx)("span", { className: "table-of-contents__number", children: numberOfBlocks })
              ] })
            ] })
          }
        ),
        headingCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)(import_jsx_runtime427.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime427.jsx)("hr", {}),
          /* @__PURE__ */ (0, import_jsx_runtime427.jsx)("h2", { className: "table-of-contents__title", children: (0, import_i18n257.__)("Document Outline") }),
          /* @__PURE__ */ (0, import_jsx_runtime427.jsx)(
            DocumentOutline,
            {
              onSelect: onRequestClose,
              hasOutlineItemsDisabled
            }
          )
        ] })
      ] })
    );
  }
  var panel_default3 = TableOfContentsPanel;

  // packages/editor/build-module/components/table-of-contents/index.mjs
  var import_jsx_runtime428 = __toESM(require_jsx_runtime(), 1);
  function TableOfContents({ hasOutlineItemsDisabled, repositionDropdown, ...props }, ref) {
    const hasBlocks = (0, import_data184.useSelect)(
      (select7) => !!select7(import_block_editor63.store).getBlockCount(),
      []
    );
    return /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
      import_components227.Dropdown,
      {
        popoverProps: {
          placement: repositionDropdown ? "right" : "bottom"
        },
        className: "table-of-contents",
        contentClassName: "table-of-contents__popover",
        renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
          import_components227.Button,
          {
            __next40pxDefaultSize: true,
            ...props,
            ref,
            onClick: hasBlocks ? onToggle : void 0,
            icon: info_default,
            "aria-expanded": isOpen2,
            "aria-haspopup": "true",
            label: (0, import_i18n258.__)("Details"),
            tooltipPosition: "bottom",
            "aria-disabled": !hasBlocks
          }
        ),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
          panel_default3,
          {
            onRequestClose: onClose,
            hasOutlineItemsDisabled
          }
        )
      }
    );
  }
  var table_of_contents_default = (0, import_element238.forwardRef)(TableOfContents);

  // packages/editor/build-module/components/unsaved-changes-warning/index.mjs
  var import_i18n259 = __toESM(require_i18n(), 1);
  var import_element239 = __toESM(require_element(), 1);
  var import_data185 = __toESM(require_data(), 1);
  var import_core_data106 = __toESM(require_core_data(), 1);
  function UnsavedChangesWarning() {
    const { __experimentalGetDirtyEntityRecords } = (0, import_data185.useSelect)(import_core_data106.store);
    (0, import_element239.useEffect)(() => {
      const warnIfUnsavedChanges = (event) => {
        const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
        if (dirtyEntityRecords.length > 0) {
          event.returnValue = (0, import_i18n259.__)(
            "You have unsaved changes. If you proceed, they will be lost."
          );
          return event.returnValue;
        }
      };
      window.addEventListener("beforeunload", warnIfUnsavedChanges);
      return () => {
        window.removeEventListener("beforeunload", warnIfUnsavedChanges);
      };
    }, [__experimentalGetDirtyEntityRecords]);
    return null;
  }

  // packages/editor/build-module/components/deprecated.mjs
  var import_deprecated12 = __toESM(require_deprecated(), 1);
  var import_element240 = __toESM(require_element(), 1);
  var import_block_editor64 = __toESM(require_block_editor(), 1);
  var import_server_side_render = __toESM(require_server_side_render(), 1);
  var import_jsx_runtime429 = __toESM(require_jsx_runtime(), 1);
  function deprecateComponent(name2, Wrapped, staticsToHoist = []) {
    const Component6 = (0, import_element240.forwardRef)((props, ref) => {
      (0, import_deprecated12.default)("wp.editor." + name2, {
        since: "5.3",
        alternative: "wp.blockEditor." + name2,
        version: "6.2"
      });
      return /* @__PURE__ */ (0, import_jsx_runtime429.jsx)(Wrapped, { ref, ...props });
    });
    staticsToHoist.forEach((staticName) => {
      Component6[staticName] = deprecateComponent(
        name2 + "." + staticName,
        Wrapped[staticName]
      );
    });
    return Component6;
  }
  function deprecateFunction(name2, func) {
    return (...args) => {
      (0, import_deprecated12.default)("wp.editor." + name2, {
        since: "5.3",
        alternative: "wp.blockEditor." + name2,
        version: "6.2"
      });
      return func(...args);
    };
  }
  var RichText = deprecateComponent("RichText", import_block_editor64.RichText, ["Content"]);
  RichText.isEmpty = deprecateFunction(
    "RichText.isEmpty",
    import_block_editor64.RichText.isEmpty
  );
  var Autocomplete = deprecateComponent(
    "Autocomplete",
    import_block_editor64.Autocomplete
  );
  var AlignmentToolbar = deprecateComponent(
    "AlignmentToolbar",
    import_block_editor64.AlignmentToolbar
  );
  var BlockAlignmentToolbar = deprecateComponent(
    "BlockAlignmentToolbar",
    import_block_editor64.BlockAlignmentToolbar
  );
  var BlockControls = deprecateComponent(
    "BlockControls",
    import_block_editor64.BlockControls,
    ["Slot"]
  );
  var BlockEdit = deprecateComponent("BlockEdit", import_block_editor64.BlockEdit);
  var BlockEditorKeyboardShortcuts2 = deprecateComponent(
    "BlockEditorKeyboardShortcuts",
    import_block_editor64.BlockEditorKeyboardShortcuts
  );
  var BlockFormatControls = deprecateComponent(
    "BlockFormatControls",
    import_block_editor64.BlockFormatControls,
    ["Slot"]
  );
  var BlockIcon3 = deprecateComponent("BlockIcon", import_block_editor64.BlockIcon);
  var BlockInspector = deprecateComponent(
    "BlockInspector",
    import_block_editor64.BlockInspector
  );
  var BlockList4 = deprecateComponent("BlockList", import_block_editor64.BlockList);
  var BlockMover = deprecateComponent("BlockMover", import_block_editor64.BlockMover);
  var BlockNavigationDropdown = deprecateComponent(
    "BlockNavigationDropdown",
    import_block_editor64.BlockNavigationDropdown
  );
  var BlockSelectionClearer = deprecateComponent(
    "BlockSelectionClearer",
    import_block_editor64.BlockSelectionClearer
  );
  var BlockSettingsMenu = deprecateComponent(
    "BlockSettingsMenu",
    import_block_editor64.BlockSettingsMenu
  );
  var BlockTitle = deprecateComponent("BlockTitle", import_block_editor64.BlockTitle);
  var BlockToolbar = deprecateComponent(
    "BlockToolbar",
    import_block_editor64.BlockToolbar
  );
  var ColorPalette2 = deprecateComponent(
    "ColorPalette",
    import_block_editor64.ColorPalette
  );
  var ContrastChecker = deprecateComponent(
    "ContrastChecker",
    import_block_editor64.ContrastChecker
  );
  var CopyHandler = deprecateComponent("CopyHandler", import_block_editor64.CopyHandler);
  var DefaultBlockAppender = deprecateComponent(
    "DefaultBlockAppender",
    import_block_editor64.DefaultBlockAppender
  );
  var FontSizePicker = deprecateComponent(
    "FontSizePicker",
    import_block_editor64.FontSizePicker
  );
  var Inserter = deprecateComponent("Inserter", import_block_editor64.Inserter);
  var InnerBlocks = deprecateComponent("InnerBlocks", import_block_editor64.InnerBlocks, [
    "ButtonBlockAppender",
    "DefaultBlockAppender",
    "Content"
  ]);
  var InspectorAdvancedControls = deprecateComponent(
    "InspectorAdvancedControls",
    import_block_editor64.InspectorAdvancedControls,
    ["Slot"]
  );
  var InspectorControls = deprecateComponent(
    "InspectorControls",
    import_block_editor64.InspectorControls,
    ["Slot"]
  );
  var PanelColorSettings = deprecateComponent(
    "PanelColorSettings",
    import_block_editor64.PanelColorSettings
  );
  var PlainText = deprecateComponent("PlainText", import_block_editor64.PlainText);
  var RichTextShortcut = deprecateComponent(
    "RichTextShortcut",
    import_block_editor64.RichTextShortcut
  );
  var RichTextToolbarButton = deprecateComponent(
    "RichTextToolbarButton",
    import_block_editor64.RichTextToolbarButton
  );
  var __unstableRichTextInputEvent = deprecateComponent(
    "__unstableRichTextInputEvent",
    import_block_editor64.__unstableRichTextInputEvent
  );
  var MediaPlaceholder = deprecateComponent(
    "MediaPlaceholder",
    import_block_editor64.MediaPlaceholder
  );
  var MediaUpload3 = deprecateComponent("MediaUpload", import_block_editor64.MediaUpload);
  var MediaUploadCheck2 = deprecateComponent(
    "MediaUploadCheck",
    import_block_editor64.MediaUploadCheck
  );
  var MultiSelectScrollIntoView = deprecateComponent(
    "MultiSelectScrollIntoView",
    import_block_editor64.MultiSelectScrollIntoView
  );
  var NavigableToolbar = deprecateComponent(
    "NavigableToolbar",
    import_block_editor64.NavigableToolbar
  );
  var ObserveTyping = deprecateComponent(
    "ObserveTyping",
    import_block_editor64.ObserveTyping
  );
  var SkipToSelectedBlock = deprecateComponent(
    "SkipToSelectedBlock",
    import_block_editor64.SkipToSelectedBlock
  );
  var URLInput = deprecateComponent("URLInput", import_block_editor64.URLInput);
  var URLInputButton = deprecateComponent(
    "URLInputButton",
    import_block_editor64.URLInputButton
  );
  var URLPopover = deprecateComponent("URLPopover", import_block_editor64.URLPopover);
  var Warning = deprecateComponent("Warning", import_block_editor64.Warning);
  var WritingFlow = deprecateComponent("WritingFlow", import_block_editor64.WritingFlow);
  var createCustomColorsHOC = deprecateFunction(
    "createCustomColorsHOC",
    import_block_editor64.createCustomColorsHOC
  );
  var getColorClassName2 = deprecateFunction(
    "getColorClassName",
    import_block_editor64.getColorClassName
  );
  var getColorObjectByAttributeValues = deprecateFunction(
    "getColorObjectByAttributeValues",
    import_block_editor64.getColorObjectByAttributeValues
  );
  var getColorObjectByColorValue = deprecateFunction(
    "getColorObjectByColorValue",
    import_block_editor64.getColorObjectByColorValue
  );
  var getFontSize = deprecateFunction("getFontSize", import_block_editor64.getFontSize);
  var getFontSizeClass = deprecateFunction(
    "getFontSizeClass",
    import_block_editor64.getFontSizeClass
  );
  var withColorContext = deprecateFunction(
    "withColorContext",
    import_block_editor64.withColorContext
  );
  var withColors = deprecateFunction("withColors", import_block_editor64.withColors);
  var withFontSizes = deprecateFunction(
    "withFontSizes",
    import_block_editor64.withFontSizes
  );

  // packages/editor/build-module/components/index.mjs
  var VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
  var TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;

  // packages/editor/build-module/hooks/default-autocompleters.mjs
  function setDefaultCompleters(completers = []) {
    completers.push({ ...link_default2 }, { ...user_default });
    return completers;
  }
  (0, import_hooks50.addFilter)(
    "editor.Autocomplete.completers",
    "editor/autocompleters/set-default-completers",
    setDefaultCompleters
  );

  // packages/editor/build-module/hooks/media-upload.mjs
  var import_element241 = __toESM(require_element(), 1);
  var import_hooks51 = __toESM(require_hooks(), 1);
  var import_deprecated13 = __toESM(require_deprecated(), 1);
  var import_media_utils6 = __toESM(require_media_utils(), 1);
  var import_jsx_runtime430 = __toESM(require_jsx_runtime(), 1);
  var { MediaUploadModal: MediaUploadModalComponent } = unlock(
    import_media_utils6.privateApis
  );
  var MediaUploadModalWrapper = class extends import_element241.Component {
    constructor(props) {
      super(props);
      this.state = {
        isOpen: false
      };
      this.openModal = this.openModal.bind(this);
      this.closeModal = this.closeModal.bind(this);
    }
    openModal() {
      this.setState({ isOpen: true });
    }
    closeModal() {
      this.setState({ isOpen: false });
      this.props.onClose?.();
    }
    render() {
      const {
        allowedTypes,
        multiple,
        value,
        onSelect,
        title,
        modalClass,
        render: render4
      } = this.props;
      const { isOpen: isOpen2 } = this.state;
      return /* @__PURE__ */ (0, import_jsx_runtime430.jsxs)(import_jsx_runtime430.Fragment, { children: [
        render4({ open: this.openModal }),
        /* @__PURE__ */ (0, import_jsx_runtime430.jsx)(
          MediaUploadModalComponent,
          {
            allowedTypes,
            multiple,
            value,
            onSelect: (media) => {
              onSelect(media);
              this.closeModal();
            },
            onClose: this.closeModal,
            title,
            isOpen: isOpen2,
            modalClass
          }
        )
      ] });
    }
  };
  if (window.__experimentalDataViewsMediaModal) {
    (0, import_hooks51.addFilter)(
      "editor.MediaUpload",
      "core/editor/components/media-upload",
      () => {
        (0, import_deprecated13.default)("Extending MediaUpload as a class component", {
          since: "7.0",
          version: "7.2",
          hint: "MediaUpload will become a function component in WordPress 7.2 Please update any custom implementations to use function components instead."
        });
        return MediaUploadModalWrapper;
      }
    );
  } else {
    (0, import_hooks51.addFilter)(
      "editor.MediaUpload",
      "core/editor/components/media-upload",
      () => {
        return import_media_utils6.MediaUpload;
      }
    );
  }

  // packages/editor/build-module/hooks/pattern-overrides.mjs
  var import_hooks52 = __toESM(require_hooks(), 1);
  var import_patterns8 = __toESM(require_patterns(), 1);
  var import_compose56 = __toESM(require_compose(), 1);
  var import_block_editor65 = __toESM(require_block_editor(), 1);
  var import_data186 = __toESM(require_data(), 1);
  var import_blocks28 = __toESM(require_blocks(), 1);
  var import_jsx_runtime431 = __toESM(require_jsx_runtime(), 1);
  var {
    PatternOverridesControls,
    ResetOverridesControl,
    PATTERN_TYPES: PATTERN_TYPES4,
    PATTERN_SYNC_TYPES
  } = unlock(import_patterns8.privateApis);
  var withPatternOverrideControls = (0, import_compose56.createHigherOrderComponent)(
    (BlockEdit2) => (props) => {
      const isSupportedBlock = (0, import_data186.useSelect)(
        (select7) => {
          const { __experimentalBlockBindingsSupportedAttributes } = select7(import_block_editor65.store).getSettings();
          return !!__experimentalBlockBindingsSupportedAttributes?.[props.name];
        },
        [props.name]
      );
      return /* @__PURE__ */ (0, import_jsx_runtime431.jsxs)(import_jsx_runtime431.Fragment, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime431.jsx)(BlockEdit2, { ...props }, "edit"),
        props.isSelected && isSupportedBlock && /* @__PURE__ */ (0, import_jsx_runtime431.jsx)(ControlsWithStoreSubscription, { ...props })
      ] });
    },
    "withPatternOverrideControls"
  );
  function ControlsWithStoreSubscription(props) {
    const blockEditingMode = (0, import_block_editor65.useBlockEditingMode)();
    const { hasPatternOverridesSource, isEditingSyncedPattern } = (0, import_data186.useSelect)(
      (select7) => {
        const { getCurrentPostType: getCurrentPostType2, getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
        return {
          // For editing link to the site editor if the theme and user permissions support it.
          hasPatternOverridesSource: !!(0, import_blocks28.getBlockBindingsSource)(
            "core/pattern-overrides"
          ),
          isEditingSyncedPattern: getCurrentPostType2() === PATTERN_TYPES4.user && getEditedPostAttribute2("meta")?.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced && getEditedPostAttribute2("wp_pattern_sync_status") !== PATTERN_SYNC_TYPES.unsynced
        };
      },
      []
    );
    const bindings = props.attributes.metadata?.bindings;
    const hasPatternBindings = !!bindings && Object.values(bindings).some(
      (binding) => binding.source === "core/pattern-overrides"
    );
    const shouldShowPatternOverridesControls = isEditingSyncedPattern && blockEditingMode === "default";
    const shouldShowResetOverridesControl = !isEditingSyncedPattern && !!props.attributes.metadata?.name && blockEditingMode !== "disabled" && hasPatternBindings;
    if (!hasPatternOverridesSource) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime431.jsxs)(import_jsx_runtime431.Fragment, { children: [
      shouldShowPatternOverridesControls && /* @__PURE__ */ (0, import_jsx_runtime431.jsx)(PatternOverridesControls, { ...props }),
      shouldShowResetOverridesControl && /* @__PURE__ */ (0, import_jsx_runtime431.jsx)(ResetOverridesControl, { ...props })
    ] });
  }
  (0, import_hooks52.addFilter)(
    "editor.BlockEdit",
    "core/editor/with-pattern-override-controls",
    withPatternOverrideControls
  );

  // packages/editor/build-module/hooks/navigation-link-view-button.mjs
  var import_hooks53 = __toESM(require_hooks(), 1);
  var import_compose57 = __toESM(require_compose(), 1);
  var import_element242 = __toESM(require_element(), 1);
  var import_i18n260 = __toESM(require_i18n(), 1);
  var import_block_editor66 = __toESM(require_block_editor(), 1);
  var import_components229 = __toESM(require_components(), 1);
  var import_data187 = __toESM(require_data(), 1);
  var import_jsx_runtime432 = __toESM(require_jsx_runtime(), 1);
  var SUPPORTED_BLOCKS = ["core/navigation-link", "core/navigation-submenu"];
  function NavigationViewButton({ attributes }) {
    const { kind, id, type } = attributes;
    const blockEditingMode = (0, import_block_editor66.useBlockEditingMode)();
    const onNavigateToEntityRecord = (0, import_data187.useSelect)(
      (select7) => select7(import_block_editor66.store).getSettings().onNavigateToEntityRecord,
      []
    );
    const onViewPage = (0, import_element242.useCallback)(() => {
      if (kind === "post-type" && type === "page" && id && onNavigateToEntityRecord) {
        onNavigateToEntityRecord({
          postId: id,
          postType: type
        });
      }
    }, [kind, id, type, onNavigateToEntityRecord]);
    if (kind !== "post-type" || type !== "page" || !id || !onNavigateToEntityRecord || blockEditingMode !== "contentOnly") {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime432.jsx)(import_block_editor66.__unstableBlockToolbarLastItem, { children: /* @__PURE__ */ (0, import_jsx_runtime432.jsx)(import_components229.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime432.jsx)(
      import_components229.ToolbarButton,
      {
        name: "view",
        title: (0, import_i18n260.__)("View"),
        onClick: onViewPage,
        children: (0, import_i18n260.__)("View")
      }
    ) }) });
  }
  var withNavigationViewButton = (0, import_compose57.createHigherOrderComponent)(
    (BlockEdit2) => (props) => {
      const isSupportedBlock = SUPPORTED_BLOCKS.includes(props.name);
      return /* @__PURE__ */ (0, import_jsx_runtime432.jsxs)(import_jsx_runtime432.Fragment, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime432.jsx)(BlockEdit2, { ...props }, "edit"),
        props.isSelected && isSupportedBlock && /* @__PURE__ */ (0, import_jsx_runtime432.jsx)(NavigationViewButton, { ...props })
      ] });
    },
    "withNavigationViewButton"
  );
  (0, import_hooks53.addFilter)(
    "editor.BlockEdit",
    "core/editor/with-navigation-view-button",
    withNavigationViewButton
  );

  // packages/editor/build-module/hooks/template-part-navigation-edit-button.mjs
  var import_hooks54 = __toESM(require_hooks(), 1);
  var import_compose58 = __toESM(require_compose(), 1);
  var import_element243 = __toESM(require_element(), 1);
  var import_i18n261 = __toESM(require_i18n(), 1);
  var import_block_editor67 = __toESM(require_block_editor(), 1);
  var import_components230 = __toESM(require_components(), 1);
  var import_data188 = __toESM(require_data(), 1);
  var import_jsx_runtime433 = __toESM(require_jsx_runtime(), 1);
  var NAVIGATION_BLOCK_NAME = "core/navigation";
  var TEMPLATE_PART_BLOCK_NAME = "core/template-part";
  var BLOCK_INSPECTOR_AREA = "edit-post/block";
  function TemplatePartNavigationEditButton({ clientId }) {
    const registry = (0, import_data188.useRegistry)();
    const { selectBlock: selectBlock2, flashBlock } = (0, import_data188.useDispatch)(import_block_editor67.store);
    const { requestInspectorTab } = unlock((0, import_data188.useDispatch)(import_block_editor67.store));
    const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data188.useDispatch)(store2);
    const {
      hasNavigationBlocks,
      firstNavigationBlockId,
      isNavigationEditable
    } = (0, import_data188.useSelect)(
      (select7) => {
        const {
          getClientIdsOfDescendants: getClientIdsOfDescendants2,
          getBlockName: getBlockName2,
          getBlockEditingMode
        } = select7(import_block_editor67.store);
        const descendants = getClientIdsOfDescendants2(clientId);
        const navigationBlocksInTemplatePart = descendants.filter(
          (blockId) => getBlockName2(blockId) === NAVIGATION_BLOCK_NAME
        );
        const _hasNavigationBlocks = navigationBlocksInTemplatePart.length > 0;
        const _firstNavigationBlockId = _hasNavigationBlocks ? navigationBlocksInTemplatePart[0] : null;
        return {
          hasNavigationBlocks: _hasNavigationBlocks,
          firstNavigationBlockId: _firstNavigationBlockId,
          // We can't use the useBlockEditingMode hook here because the current
          // context is the template part, not the navigation block.
          isNavigationEditable: getBlockEditingMode(_firstNavigationBlockId) !== "disabled"
        };
      },
      [clientId]
    );
    const onEditNavigation = (0, import_element243.useCallback)(() => {
      if (firstNavigationBlockId) {
        registry.batch(() => {
          selectBlock2(firstNavigationBlockId);
          flashBlock(firstNavigationBlockId, 500);
          enableComplementaryArea2("core", BLOCK_INSPECTOR_AREA);
          requestInspectorTab("list", {
            openPanel: firstNavigationBlockId
          });
        });
      }
    }, [
      firstNavigationBlockId,
      registry,
      selectBlock2,
      flashBlock,
      enableComplementaryArea2,
      requestInspectorTab
    ]);
    if (!hasNavigationBlocks || !isNavigationEditable) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime433.jsx)(import_block_editor67.__unstableBlockToolbarLastItem, { children: /* @__PURE__ */ (0, import_jsx_runtime433.jsx)(import_components230.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime433.jsx)(
      import_components230.ToolbarButton,
      {
        label: (0, import_i18n261.__)("Edit navigation"),
        onClick: onEditNavigation,
        children: (0, import_i18n261.__)("Edit navigation")
      }
    ) }) });
  }
  var withTemplatePartNavigationEditButton = (0, import_compose58.createHigherOrderComponent)(
    (BlockEdit2) => (props) => {
      const isTemplatePart2 = props.name === TEMPLATE_PART_BLOCK_NAME;
      return /* @__PURE__ */ (0, import_jsx_runtime433.jsxs)(import_jsx_runtime433.Fragment, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime433.jsx)(BlockEdit2, { ...props }, "edit"),
        props.isSelected && isTemplatePart2 && /* @__PURE__ */ (0, import_jsx_runtime433.jsx)(
          TemplatePartNavigationEditButton,
          {
            clientId: props.clientId
          }
        )
      ] });
    },
    "withTemplatePartNavigationEditButton"
  );
  (0, import_hooks54.addFilter)(
    "editor.BlockEdit",
    "core/editor/with-template-part-navigation-edit-button",
    withTemplatePartNavigationEditButton
  );

  // packages/editor/build-module/hooks/push-changes-to-global-styles/index.mjs
  var import_hooks55 = __toESM(require_hooks(), 1);
  var import_compose59 = __toESM(require_compose(), 1);
  var import_block_editor68 = __toESM(require_block_editor(), 1);
  var import_components231 = __toESM(require_components(), 1);
  var import_i18n262 = __toESM(require_i18n(), 1);
  var import_blocks29 = __toESM(require_blocks(), 1);
  var import_element244 = __toESM(require_element(), 1);
  var import_data189 = __toESM(require_data(), 1);
  var import_notices27 = __toESM(require_notices(), 1);
  var import_core_data107 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/utils/set-nested-value.mjs
  function setNestedValue(object, path, value) {
    if (!object || typeof object !== "object") {
      return object;
    }
    path.reduce((acc, key, idx) => {
      if (acc[key] === void 0) {
        if (Number.isInteger(path[idx + 1])) {
          acc[key] = [];
        } else {
          acc[key] = {};
        }
      }
      if (idx === path.length - 1) {
        acc[key] = value;
      }
      return acc[key];
    }, object);
    return object;
  }

  // packages/editor/build-module/hooks/push-changes-to-global-styles/index.mjs
  var import_jsx_runtime434 = __toESM(require_jsx_runtime(), 1);
  var { cleanEmptyObject: cleanEmptyObject3 } = unlock(import_block_editor68.privateApis);
  var STYLE_PROPERTY2 = {
    ...import_blocks29.__EXPERIMENTAL_STYLE_PROPERTY,
    blockGap: { value: ["spacing", "blockGap"] }
  };
  var STYLE_PATH_TO_CSS_VAR_INFIX = {
    "border.color": "color",
    "color.background": "color",
    "color.text": "color",
    "elements.link.color.text": "color",
    "elements.link.:hover.color.text": "color",
    "elements.link.typography.fontFamily": "font-family",
    "elements.link.typography.fontSize": "font-size",
    "elements.button.color.text": "color",
    "elements.button.color.background": "color",
    "elements.button.typography.fontFamily": "font-family",
    "elements.button.typography.fontSize": "font-size",
    "elements.caption.color.text": "color",
    "elements.heading.color": "color",
    "elements.heading.color.background": "color",
    "elements.heading.typography.fontFamily": "font-family",
    "elements.heading.gradient": "gradient",
    "elements.heading.color.gradient": "gradient",
    "elements.h1.color": "color",
    "elements.h1.color.background": "color",
    "elements.h1.typography.fontFamily": "font-family",
    "elements.h1.color.gradient": "gradient",
    "elements.h2.color": "color",
    "elements.h2.color.background": "color",
    "elements.h2.typography.fontFamily": "font-family",
    "elements.h2.color.gradient": "gradient",
    "elements.h3.color": "color",
    "elements.h3.color.background": "color",
    "elements.h3.typography.fontFamily": "font-family",
    "elements.h3.color.gradient": "gradient",
    "elements.h4.color": "color",
    "elements.h4.color.background": "color",
    "elements.h4.typography.fontFamily": "font-family",
    "elements.h4.color.gradient": "gradient",
    "elements.h5.color": "color",
    "elements.h5.color.background": "color",
    "elements.h5.typography.fontFamily": "font-family",
    "elements.h5.color.gradient": "gradient",
    "elements.h6.color": "color",
    "elements.h6.color.background": "color",
    "elements.h6.typography.fontFamily": "font-family",
    "elements.h6.color.gradient": "gradient",
    "color.gradient": "gradient",
    blockGap: "spacing",
    "typography.fontSize": "font-size",
    "typography.fontFamily": "font-family"
  };
  var STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
    "border.color": "borderColor",
    "color.background": "backgroundColor",
    "color.text": "textColor",
    "color.gradient": "gradient",
    "typography.fontSize": "fontSize",
    "typography.fontFamily": "fontFamily"
  };
  var SUPPORTED_STYLES = ["border", "color", "spacing", "typography"];
  var getValueFromObjectPath2 = (object, path) => {
    let value = object;
    path.forEach((fieldName) => {
      value = value?.[fieldName];
    });
    return value;
  };
  var flatBorderProperties = ["borderColor", "borderWidth", "borderStyle"];
  var sides = ["top", "right", "bottom", "left"];
  function getBorderStyleChanges(border, presetColor, userStyle) {
    if (!border && !presetColor) {
      return [];
    }
    const changes = [
      ...getFallbackBorderStyleChange("top", border, userStyle),
      ...getFallbackBorderStyleChange("right", border, userStyle),
      ...getFallbackBorderStyleChange("bottom", border, userStyle),
      ...getFallbackBorderStyleChange("left", border, userStyle)
    ];
    const { color: customColor, style, width } = border || {};
    const hasColorOrWidth = presetColor || customColor || width;
    if (hasColorOrWidth && !style) {
      sides.forEach((side) => {
        if (!userStyle?.[side]?.style) {
          changes.push({
            path: ["border", side, "style"],
            value: "solid"
          });
        }
      });
    }
    return changes;
  }
  function getFallbackBorderStyleChange(side, border, globalBorderStyle) {
    if (!border?.[side] || globalBorderStyle?.[side]?.style) {
      return [];
    }
    const { color, style, width } = border[side];
    const hasColorOrWidth = color || width;
    if (!hasColorOrWidth || style) {
      return [];
    }
    return [{ path: ["border", side, "style"], value: "solid" }];
  }
  function useChangesToPush(name2, attributes, userConfig) {
    const supports = (0, import_data189.useSelect)(
      (select7) => {
        return unlock(select7(import_blocks29.store)).getSupportedStyles(name2);
      },
      [name2]
    );
    const blockUserConfig = userConfig?.styles?.blocks?.[name2];
    return (0, import_element244.useMemo)(() => {
      const changes = supports.flatMap((key) => {
        if (!STYLE_PROPERTY2[key]) {
          return [];
        }
        const { value: path } = STYLE_PROPERTY2[key];
        const presetAttributeKey = path.join(".");
        const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]];
        const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : getValueFromObjectPath2(attributes.style, path);
        if (key === "linkColor") {
          const linkChanges = value ? [{ path, value }] : [];
          const hoverPath = [
            "elements",
            "link",
            ":hover",
            "color",
            "text"
          ];
          const hoverValue = getValueFromObjectPath2(
            attributes.style,
            hoverPath
          );
          if (hoverValue) {
            linkChanges.push({ path: hoverPath, value: hoverValue });
          }
          return linkChanges;
        }
        if (flatBorderProperties.includes(key) && value) {
          const borderChanges = [{ path, value }];
          sides.forEach((side) => {
            const currentPath = [...path];
            currentPath.splice(-1, 0, side);
            borderChanges.push({ path: currentPath, value });
          });
          return borderChanges;
        }
        return value ? [{ path, value }] : [];
      });
      getBorderStyleChanges(
        attributes.style?.border,
        attributes.borderColor,
        blockUserConfig?.border
      ).forEach((change) => changes.push(change));
      return changes;
    }, [supports, attributes, blockUserConfig]);
  }
  function PushChangesToGlobalStylesControl({
    name: name2,
    attributes,
    setAttributes
  }) {
    const { user: userConfig, setUser: setUserConfig } = useGlobalStyles();
    const changes = useChangesToPush(name2, attributes, userConfig);
    const { __unstableMarkNextChangeAsNotPersistent } = (0, import_data189.useDispatch)(import_block_editor68.store);
    const { createSuccessNotice } = (0, import_data189.useDispatch)(import_notices27.store);
    const pushChanges = (0, import_element244.useCallback)(() => {
      if (changes.length === 0) {
        return;
      }
      if (changes.length > 0) {
        const { style: blockStyles } = attributes;
        const newBlockStyles = structuredClone(blockStyles);
        const newUserConfig = structuredClone(userConfig);
        for (const { path, value } of changes) {
          setNestedValue(newBlockStyles, path, void 0);
          setNestedValue(
            newUserConfig,
            ["styles", "blocks", name2, ...path],
            value
          );
        }
        const newBlockAttributes = {
          borderColor: void 0,
          backgroundColor: void 0,
          textColor: void 0,
          gradient: void 0,
          fontSize: void 0,
          fontFamily: void 0,
          style: cleanEmptyObject3(newBlockStyles)
        };
        __unstableMarkNextChangeAsNotPersistent();
        setAttributes(newBlockAttributes);
        setUserConfig(newUserConfig, { undoIgnore: true });
        createSuccessNotice(
          (0, import_i18n262.sprintf)(
            // translators: %s: Title of the block e.g. 'Heading'.
            (0, import_i18n262.__)("%s styles applied."),
            (0, import_blocks29.getBlockType)(name2).title
          ),
          {
            type: "snackbar",
            actions: [
              {
                label: (0, import_i18n262.__)("Undo"),
                onClick() {
                  __unstableMarkNextChangeAsNotPersistent();
                  setAttributes(attributes);
                  setUserConfig(userConfig, {
                    undoIgnore: true
                  });
                }
              }
            ]
          }
        );
      }
    }, [
      __unstableMarkNextChangeAsNotPersistent,
      attributes,
      changes,
      createSuccessNotice,
      name2,
      setAttributes,
      setUserConfig,
      userConfig
    ]);
    return /* @__PURE__ */ (0, import_jsx_runtime434.jsxs)(
      import_components231.BaseControl,
      {
        className: "editor-push-changes-to-global-styles-control",
        help: (0, import_i18n262.sprintf)(
          // translators: %s: Title of the block e.g. 'Heading'.
          (0, import_i18n262.__)(
            "Apply this block\u2019s typography, spacing, dimensions, and color styles to all %s blocks."
          ),
          (0, import_blocks29.getBlockType)(name2).title
        ),
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime434.jsx)(import_components231.BaseControl.VisualLabel, { children: (0, import_i18n262.__)("Styles") }),
          /* @__PURE__ */ (0, import_jsx_runtime434.jsx)(
            import_components231.Button,
            {
              __next40pxDefaultSize: true,
              variant: "secondary",
              accessibleWhenDisabled: true,
              disabled: changes.length === 0,
              onClick: pushChanges,
              children: (0, import_i18n262.__)("Apply globally")
            }
          )
        ]
      }
    );
  }
  function PushChangesToGlobalStyles(props) {
    const blockEditingMode = (0, import_block_editor68.useBlockEditingMode)();
    const isBlockBasedTheme = (0, import_data189.useSelect)(
      (select7) => select7(import_core_data107.store).getCurrentTheme()?.is_block_theme,
      []
    );
    const supportsStyles = SUPPORTED_STYLES.some(
      (feature) => (0, import_blocks29.hasBlockSupport)(props.name, feature)
    );
    const isDisplayed = blockEditingMode === "default" && supportsStyles && isBlockBasedTheme;
    if (!isDisplayed) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime434.jsx)(import_block_editor68.InspectorAdvancedControls, { children: /* @__PURE__ */ (0, import_jsx_runtime434.jsx)(PushChangesToGlobalStylesControl, { ...props }) });
  }
  var withPushChangesToGlobalStyles = (0, import_compose59.createHigherOrderComponent)(
    (BlockEdit2) => (props) => /* @__PURE__ */ (0, import_jsx_runtime434.jsxs)(import_jsx_runtime434.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime434.jsx)(BlockEdit2, { ...props }, "edit"),
      props.isSelected && /* @__PURE__ */ (0, import_jsx_runtime434.jsx)(PushChangesToGlobalStyles, { ...props })
    ] })
  );
  (0, import_hooks55.addFilter)(
    "editor.BlockEdit",
    "core/editor/push-changes-to-global-styles",
    withPushChangesToGlobalStyles
  );

  // packages/editor/build-module/components/header/back-button.mjs
  var import_components232 = __toESM(require_components(), 1);
  var import_jsx_runtime435 = __toESM(require_jsx_runtime(), 1);
  var slotName = "__experimentalMainDashboardButton";
  var useHasBackButton = () => {
    const fills = (0, import_components232.__experimentalUseSlotFills)(slotName);
    return Boolean(fills && fills.length);
  };
  var { Fill: Fill10, Slot: Slot10 } = (0, import_components232.createSlotFill)(slotName);
  var BackButton = Fill10;
  var BackButtonSlot = () => {
    const fills = (0, import_components232.__experimentalUseSlotFills)(slotName);
    return /* @__PURE__ */ (0, import_jsx_runtime435.jsx)(
      Slot10,
      {
        bubblesVirtually: true,
        fillProps: { length: !fills ? 0 : fills.length }
      }
    );
  };
  BackButton.Slot = BackButtonSlot;
  var back_button_default = BackButton;

  // packages/editor/build-module/components/editor/index.mjs
  var import_data263 = __toESM(require_data(), 1);
  var import_core_data141 = __toESM(require_core_data(), 1);
  var import_components289 = __toESM(require_components(), 1);
  var import_i18n325 = __toESM(require_i18n(), 1);

  // packages/editor/build-module/components/editor-interface/index.mjs
  var import_data224 = __toESM(require_data(), 1);
  var import_i18n291 = __toESM(require_i18n(), 1);
  var import_preferences24 = __toESM(require_preferences(), 1);
  var import_block_editor85 = __toESM(require_block_editor(), 1);
  var import_compose75 = __toESM(require_compose(), 1);
  var import_element275 = __toESM(require_element(), 1);
  var import_html_entities29 = __toESM(require_html_entities(), 1);
  var import_notices32 = __toESM(require_notices(), 1);

  // packages/editor/build-module/components/header/index.mjs
  var import_block_editor74 = __toESM(require_block_editor(), 1);
  var import_data200 = __toESM(require_data(), 1);
  var import_compose65 = __toESM(require_compose(), 1);
  var import_preferences21 = __toESM(require_preferences(), 1);
  var import_element257 = __toESM(require_element(), 1);

  // packages/editor/build-module/components/collapsible-block-toolbar/index.mjs
  var import_block_editor69 = __toESM(require_block_editor(), 1);
  var import_element245 = __toESM(require_element(), 1);
  var import_components233 = __toESM(require_components(), 1);
  var import_i18n263 = __toESM(require_i18n(), 1);
  var import_data190 = __toESM(require_data(), 1);
  var import_jsx_runtime436 = __toESM(require_jsx_runtime(), 1);
  var { useHasBlockToolbar } = unlock(import_block_editor69.privateApis);
  function CollapsibleBlockToolbar({ isCollapsed, onToggle }) {
    const { blockSelectionStart } = (0, import_data190.useSelect)((select7) => {
      return {
        blockSelectionStart: select7(import_block_editor69.store).getBlockSelectionStart()
      };
    }, []);
    const hasBlockToolbar = useHasBlockToolbar();
    const hasBlockSelection = !!blockSelectionStart;
    (0, import_element245.useEffect)(() => {
      if (blockSelectionStart) {
        onToggle(false);
      }
    }, [blockSelectionStart, onToggle]);
    if (!hasBlockToolbar) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime436.jsxs)(import_jsx_runtime436.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime436.jsx)(
        "div",
        {
          className: clsx_default("editor-collapsible-block-toolbar", {
            "is-collapsed": isCollapsed || !hasBlockSelection
          }),
          children: /* @__PURE__ */ (0, import_jsx_runtime436.jsx)(import_block_editor69.BlockToolbar, { hideDragHandle: true })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime436.jsx)(import_components233.Popover.Slot, { name: "block-toolbar" }),
      /* @__PURE__ */ (0, import_jsx_runtime436.jsx)(
        import_components233.Button,
        {
          className: "editor-collapsible-block-toolbar__toggle",
          icon: isCollapsed ? next_default : previous_default,
          onClick: () => {
            onToggle(!isCollapsed);
          },
          label: isCollapsed ? (0, import_i18n263.__)("Show block tools") : (0, import_i18n263.__)("Hide block tools"),
          size: "compact"
        }
      )
    ] });
  }

  // packages/editor/build-module/components/document-tools/index.mjs
  var import_compose60 = __toESM(require_compose(), 1);
  var import_data191 = __toESM(require_data(), 1);
  var import_i18n264 = __toESM(require_i18n(), 1);
  var import_block_editor70 = __toESM(require_block_editor(), 1);
  var import_components234 = __toESM(require_components(), 1);
  var import_element246 = __toESM(require_element(), 1);
  var import_keyboard_shortcuts5 = __toESM(require_keyboard_shortcuts(), 1);
  var import_preferences15 = __toESM(require_preferences(), 1);
  var import_jsx_runtime437 = __toESM(require_jsx_runtime(), 1);
  function DocumentTools({ className, disableBlockTools = false }) {
    const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2 } = (0, import_data191.useDispatch)(store3);
    const {
      isDistractionFree,
      isInserterOpened: isInserterOpened2,
      isListViewOpen,
      listViewShortcut,
      inserterSidebarToggleRef: inserterSidebarToggleRef2,
      listViewToggleRef: listViewToggleRef2,
      showIconLabels
    } = (0, import_data191.useSelect)((select7) => {
      const { get } = select7(import_preferences15.store);
      const {
        isListViewOpened: isListViewOpened2,
        getEditorMode: getEditorMode2,
        getInserterSidebarToggleRef: getInserterSidebarToggleRef2,
        getListViewToggleRef: getListViewToggleRef2
      } = unlock(select7(store3));
      const { getShortcutRepresentation } = select7(import_keyboard_shortcuts5.store);
      return {
        isInserterOpened: select7(store3).isInserterOpened(),
        isListViewOpen: isListViewOpened2(),
        listViewShortcut: getShortcutRepresentation(
          "core/editor/toggle-list-view"
        ),
        inserterSidebarToggleRef: getInserterSidebarToggleRef2(),
        listViewToggleRef: getListViewToggleRef2(),
        showIconLabels: get("core", "showIconLabels"),
        isDistractionFree: get("core", "distractionFree"),
        isVisualMode: getEditorMode2() === "visual"
      };
    }, []);
    const preventDefault = (event) => {
      if (isInserterOpened2) {
        event.preventDefault();
      }
    };
    const isWideViewport = (0, import_compose60.useViewportMatch)("wide");
    const toolbarAriaLabel = (0, import_i18n264.__)("Document tools");
    const toggleListView = (0, import_element246.useCallback)(
      () => setIsListViewOpened2(!isListViewOpen),
      [setIsListViewOpened2, isListViewOpen]
    );
    const toggleInserter = (0, import_element246.useCallback)(
      () => setIsInserterOpened2(!isInserterOpened2),
      [isInserterOpened2, setIsInserterOpened2]
    );
    const longLabel = (0, import_i18n264._x)(
      "Block Inserter",
      "Generic label for block inserter button"
    );
    const shortLabel = !isInserterOpened2 ? (0, import_i18n264.__)("Add") : (0, import_i18n264.__)("Close");
    return (
      // Some plugins expect and use the `edit-post-header-toolbar` CSS class to
      // find the toolbar and inject UI elements into it. This is not officially
      // supported, but we're keeping it in the list of class names for backwards
      // compatibility.
      /* @__PURE__ */ (0, import_jsx_runtime437.jsx)(
        import_block_editor70.NavigableToolbar,
        {
          className: clsx_default(
            "editor-document-tools",
            "edit-post-header-toolbar",
            className
          ),
          "aria-label": toolbarAriaLabel,
          variant: "unstyled",
          children: /* @__PURE__ */ (0, import_jsx_runtime437.jsxs)("div", { className: "editor-document-tools__left", children: [
            !isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime437.jsx)(
              import_components234.ToolbarButton,
              {
                ref: inserterSidebarToggleRef2,
                className: "editor-document-tools__inserter-toggle",
                variant: "primary",
                isPressed: isInserterOpened2,
                onMouseDown: preventDefault,
                onClick: toggleInserter,
                disabled: disableBlockTools,
                icon: plus_default,
                label: showIconLabels ? shortLabel : longLabel,
                showTooltip: !showIconLabels,
                "aria-expanded": isInserterOpened2
              }
            ),
            (isWideViewport || !showIconLabels) && /* @__PURE__ */ (0, import_jsx_runtime437.jsxs)(import_jsx_runtime437.Fragment, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime437.jsx)(
                import_components234.ToolbarItem,
                {
                  as: undo_default2,
                  showTooltip: !showIconLabels,
                  variant: showIconLabels ? "tertiary" : void 0,
                  size: "compact"
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime437.jsx)(
                import_components234.ToolbarItem,
                {
                  as: redo_default2,
                  showTooltip: !showIconLabels,
                  variant: showIconLabels ? "tertiary" : void 0,
                  size: "compact"
                }
              ),
              !isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime437.jsx)(
                import_components234.ToolbarButton,
                {
                  className: "editor-document-tools__document-overview-toggle",
                  icon: list_view_default,
                  disabled: disableBlockTools,
                  isPressed: isListViewOpen,
                  label: (0, import_i18n264.__)("Document Overview"),
                  onClick: toggleListView,
                  shortcut: listViewShortcut,
                  showTooltip: !showIconLabels,
                  variant: showIconLabels ? "tertiary" : void 0,
                  "aria-expanded": isListViewOpen,
                  ref: listViewToggleRef2
                }
              )
            ] })
          ] })
        }
      )
    );
  }
  var document_tools_default = DocumentTools;

  // packages/editor/build-module/components/header/header-skeleton.mjs
  var import_components235 = __toESM(require_components(), 1);
  var import_jsx_runtime438 = __toESM(require_jsx_runtime(), 1);
  var toolbarVariations = {
    distractionFreeDisabled: { y: "-50px" },
    distractionFreeHover: { y: 0 },
    distractionFreeHidden: { y: "-50px" },
    visible: { y: 0 },
    hidden: { y: 0 }
  };
  var backButtonVariations = {
    distractionFreeDisabled: { x: "-100%" },
    distractionFreeHover: { x: 0 },
    distractionFreeHidden: { x: "-100%" },
    visible: { x: 0 },
    hidden: { x: 0 }
  };
  function HeaderSkeleton({
    className,
    toolbar,
    center,
    settings
  }) {
    const hasBackButton = useHasBackButton();
    return /* @__PURE__ */ (0, import_jsx_runtime438.jsxs)("div", { className: clsx_default("editor-header edit-post-header", className), children: [
      hasBackButton && /* @__PURE__ */ (0, import_jsx_runtime438.jsx)(
        import_components235.__unstableMotion.div,
        {
          className: "editor-header__back-button",
          variants: backButtonVariations,
          transition: { type: "tween" },
          children: /* @__PURE__ */ (0, import_jsx_runtime438.jsx)(back_button_default.Slot, {})
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime438.jsx)(
        import_components235.__unstableMotion.div,
        {
          variants: toolbarVariations,
          className: "editor-header__toolbar",
          transition: { type: "tween" },
          children: toolbar
        }
      ),
      center && /* @__PURE__ */ (0, import_jsx_runtime438.jsx)(
        import_components235.__unstableMotion.div,
        {
          variants: toolbarVariations,
          className: "editor-header__center",
          transition: { type: "tween" },
          children: center
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime438.jsx)(
        import_components235.__unstableMotion.div,
        {
          variants: toolbarVariations,
          transition: { type: "tween" },
          className: "editor-header__settings",
          children: settings
        }
      )
    ] });
  }

  // packages/editor/build-module/components/more-menu/index.mjs
  var import_i18n267 = __toESM(require_i18n(), 1);
  var import_data194 = __toESM(require_data(), 1);
  var import_keycodes15 = __toESM(require_keycodes(), 1);
  var import_components240 = __toESM(require_components(), 1);
  var import_preferences16 = __toESM(require_preferences(), 1);

  // packages/editor/build-module/components/more-menu/copy-content-menu-item.mjs
  var import_components236 = __toESM(require_components(), 1);
  var import_data192 = __toESM(require_data(), 1);
  var import_i18n265 = __toESM(require_i18n(), 1);
  var import_compose61 = __toESM(require_compose(), 1);
  var import_notices28 = __toESM(require_notices(), 1);
  var import_jsx_runtime439 = __toESM(require_jsx_runtime(), 1);
  function CopyContentMenuItem() {
    const { createNotice } = (0, import_data192.useDispatch)(import_notices28.store);
    const { getEditedPostContent: getEditedPostContent2 } = (0, import_data192.useSelect)(store3);
    function getText() {
      return getEditedPostContent2();
    }
    function onSuccess() {
      createNotice("info", (0, import_i18n265.__)("All content copied."), {
        isDismissible: true,
        type: "snackbar"
      });
    }
    const ref = (0, import_compose61.useCopyToClipboard)(getText, onSuccess);
    return /* @__PURE__ */ (0, import_jsx_runtime439.jsx)(import_components236.MenuItem, { ref, children: (0, import_i18n265.__)("Copy all blocks") });
  }

  // packages/editor/build-module/components/mode-switcher/index.mjs
  var import_i18n266 = __toESM(require_i18n(), 1);
  var import_components237 = __toESM(require_components(), 1);
  var import_data193 = __toESM(require_data(), 1);
  var import_keyboard_shortcuts6 = __toESM(require_keyboard_shortcuts(), 1);
  var import_jsx_runtime440 = __toESM(require_jsx_runtime(), 1);
  var MODES = [
    {
      value: "visual",
      label: (0, import_i18n266.__)("Visual editor")
    },
    {
      value: "text",
      label: (0, import_i18n266.__)("Code editor")
    }
  ];
  function ModeSwitcher() {
    const { shortcut, isRichEditingEnabled, isCodeEditingEnabled, mode } = (0, import_data193.useSelect)(
      (select7) => ({
        shortcut: select7(
          import_keyboard_shortcuts6.store
        ).getShortcutRepresentation("core/editor/toggle-mode"),
        isRichEditingEnabled: select7(store3).getEditorSettings().richEditingEnabled,
        isCodeEditingEnabled: select7(store3).getEditorSettings().codeEditingEnabled,
        mode: select7(store3).getEditorMode()
      }),
      []
    );
    const { switchEditorMode: switchEditorMode2 } = (0, import_data193.useDispatch)(store3);
    let selectedMode = mode;
    if (!isRichEditingEnabled && mode === "visual") {
      selectedMode = "text";
    }
    if (!isCodeEditingEnabled && mode === "text") {
      selectedMode = "visual";
    }
    const choices = MODES.map((choice) => {
      if (!isCodeEditingEnabled && choice.value === "text") {
        choice = {
          ...choice,
          disabled: true
        };
      }
      if (!isRichEditingEnabled && choice.value === "visual") {
        choice = {
          ...choice,
          disabled: true,
          info: (0, import_i18n266.__)(
            "You can enable the visual editor in your profile settings."
          )
        };
      }
      if (choice.value !== selectedMode && !choice.disabled) {
        return { ...choice, shortcut };
      }
      return choice;
    });
    return /* @__PURE__ */ (0, import_jsx_runtime440.jsx)(import_components237.MenuGroup, { label: (0, import_i18n266.__)("Editor"), children: /* @__PURE__ */ (0, import_jsx_runtime440.jsx)(
      import_components237.MenuItemsChoice,
      {
        choices,
        value: selectedMode,
        onSelect: switchEditorMode2
      }
    ) });
  }
  var mode_switcher_default = ModeSwitcher;

  // packages/editor/build-module/components/more-menu/tools-more-menu-group.mjs
  var import_components238 = __toESM(require_components(), 1);
  var import_jsx_runtime441 = __toESM(require_jsx_runtime(), 1);
  var { Fill: ToolsMoreMenuGroup, Slot: Slot11 } = (0, import_components238.createSlotFill)("ToolsMoreMenuGroup");
  ToolsMoreMenuGroup.Slot = ({ fillProps }) => /* @__PURE__ */ (0, import_jsx_runtime441.jsx)(Slot11, { fillProps });
  var tools_more_menu_group_default = ToolsMoreMenuGroup;

  // packages/editor/build-module/components/more-menu/view-more-menu-group.mjs
  var import_components239 = __toESM(require_components(), 1);
  var import_element247 = __toESM(require_element(), 1);
  var import_jsx_runtime442 = __toESM(require_jsx_runtime(), 1);
  var { Fill: ViewMoreMenuGroup, Slot: Slot12 } = (0, import_components239.createSlotFill)(
    import_element247.Platform.OS === "web" ? /* @__PURE__ */ Symbol("ViewMoreMenuGroup") : "ViewMoreMenuGroup"
  );
  ViewMoreMenuGroup.Slot = ({ fillProps }) => /* @__PURE__ */ (0, import_jsx_runtime442.jsx)(Slot12, { fillProps });
  var view_more_menu_group_default = ViewMoreMenuGroup;

  // packages/editor/build-module/components/more-menu/index.mjs
  var import_jsx_runtime443 = __toESM(require_jsx_runtime(), 1);
  function MoreMenu({ disabled: disabled2 = false }) {
    const { openModal: openModal2 } = (0, import_data194.useDispatch)(store2);
    const { set: setPreference } = (0, import_data194.useDispatch)(import_preferences16.store);
    const { toggleDistractionFree: toggleDistractionFree2 } = (0, import_data194.useDispatch)(store3);
    const showIconLabels = (0, import_data194.useSelect)(
      (select7) => select7(import_preferences16.store).get("core", "showIconLabels"),
      []
    );
    const turnOffDistractionFree = () => {
      setPreference("core", "distractionFree", false);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(import_jsx_runtime443.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(
      import_components240.DropdownMenu,
      {
        icon: more_vertical_default,
        label: (0, import_i18n267.__)("Options"),
        popoverProps: {
          placement: "bottom-end",
          className: "more-menu-dropdown__content"
        },
        toggleProps: {
          showTooltip: !showIconLabels,
          ...showIconLabels && { variant: "tertiary" },
          tooltipPosition: "bottom",
          size: "compact",
          disabled: disabled2
        },
        children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime443.jsxs)(import_jsx_runtime443.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime443.jsxs)(import_components240.MenuGroup, { label: (0, import_i18n267._x)("View", "noun"), children: [
            /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(
              import_preferences16.PreferenceToggleMenuItem,
              {
                scope: "core",
                name: "fixedToolbar",
                onToggle: turnOffDistractionFree,
                label: (0, import_i18n267.__)("Top toolbar"),
                info: (0, import_i18n267.__)(
                  "Access all block and document tools in a single place"
                ),
                messageActivated: (0, import_i18n267.__)(
                  "Top toolbar activated."
                ),
                messageDeactivated: (0, import_i18n267.__)(
                  "Top toolbar deactivated."
                )
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(
              import_preferences16.PreferenceToggleMenuItem,
              {
                scope: "core",
                name: "distractionFree",
                label: (0, import_i18n267.__)("Distraction free"),
                info: (0, import_i18n267.__)("Write with calmness"),
                handleToggling: false,
                onToggle: () => toggleDistractionFree2({
                  createNotice: false
                }),
                messageActivated: (0, import_i18n267.__)(
                  "Distraction free mode activated."
                ),
                messageDeactivated: (0, import_i18n267.__)(
                  "Distraction free mode deactivated."
                ),
                shortcut: import_keycodes15.displayShortcut.primaryShift(
                  "\\"
                )
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(
              import_preferences16.PreferenceToggleMenuItem,
              {
                scope: "core",
                name: "focusMode",
                label: (0, import_i18n267.__)("Spotlight mode"),
                info: (0, import_i18n267.__)("Focus on one block at a time"),
                messageActivated: (0, import_i18n267.__)(
                  "Spotlight mode activated."
                ),
                messageDeactivated: (0, import_i18n267.__)(
                  "Spotlight mode deactivated."
                )
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(view_more_menu_group_default.Slot, { fillProps: { onClose } })
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(mode_switcher_default, {}),
          /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(
            action_item_default.Slot,
            {
              name: "core/plugin-more-menu",
              label: (0, import_i18n267.__)("Panels"),
              fillProps: { onClick: onClose }
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime443.jsxs)(import_components240.MenuGroup, { label: (0, import_i18n267.__)("Tools"), children: [
            /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(
              import_components240.MenuItem,
              {
                onClick: () => openModal2("editor/keyboard-shortcut-help"),
                shortcut: import_keycodes15.displayShortcut.access("h"),
                children: (0, import_i18n267.__)("Keyboard shortcuts")
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(CopyContentMenuItem, {}),
            /* @__PURE__ */ (0, import_jsx_runtime443.jsxs)(
              import_components240.MenuItem,
              {
                icon: external_default,
                href: (0, import_i18n267.__)(
                  "https://wordpress.org/documentation/article/wordpress-block-editor/"
                ),
                target: "_blank",
                rel: "noopener",
                children: [
                  (0, import_i18n267.__)("Help"),
                  /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(VisuallyHidden, {
                    render: /* @__PURE__ */ (0, import_jsx_runtime443.jsx)("span", {}),
                    /* translators: accessibility text */
                    children: (0, import_i18n267.__)("(opens in a new tab)")
                  })
                ]
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(
              tools_more_menu_group_default.Slot,
              {
                fillProps: { onClose }
              }
            )
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(import_components240.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(
            import_components240.MenuItem,
            {
              onClick: () => openModal2("editor/preferences"),
              children: (0, import_i18n267.__)("Preferences")
            }
          ) })
        ] })
      }
    ) });
  }

  // packages/editor/build-module/components/post-publish-button/post-publish-button-or-toggle.mjs
  var import_compose62 = __toESM(require_compose(), 1);
  var import_data195 = __toESM(require_data(), 1);
  var import_jsx_runtime444 = __toESM(require_jsx_runtime(), 1);
  var IS_TOGGLE = "toggle";
  var IS_BUTTON = "button";
  function PostPublishButtonOrToggle({
    forceIsDirty,
    setEntitiesSavedStatesCallback
  }) {
    let component;
    const isSmallerThanMediumViewport = (0, import_compose62.useViewportMatch)("medium", "<");
    const { togglePublishSidebar: togglePublishSidebar2 } = (0, import_data195.useDispatch)(store3);
    const {
      hasPublishAction,
      isBeingScheduled,
      isPending,
      isPublished,
      isPublishSidebarEnabled: isPublishSidebarEnabled2,
      isPublishSidebarOpened: isPublishSidebarOpened2,
      isScheduled,
      postStatus,
      postStatusHasChanged,
      postType: postType2
    } = (0, import_data195.useSelect)((select7) => {
      return {
        hasPublishAction: !!select7(store3).getCurrentPost()?._links?.["wp:action-publish"],
        isBeingScheduled: select7(store3).isEditedPostBeingScheduled(),
        isPending: select7(store3).isCurrentPostPending(),
        isPublished: select7(store3).isCurrentPostPublished(),
        isPublishSidebarEnabled: select7(store3).isPublishSidebarEnabled(),
        isPublishSidebarOpened: select7(store3).isPublishSidebarOpened(),
        isScheduled: select7(store3).isCurrentPostScheduled(),
        postStatus: select7(store3).getEditedPostAttribute("status"),
        postStatusHasChanged: select7(store3).getPostEdits()?.status,
        postType: select7(store3).getCurrentPostType()
      };
    }, []);
    if (postType2 === ATTACHMENT_POST_TYPE) {
      component = IS_BUTTON;
    } else if (isPublished || postStatusHasChanged && !["future", "publish"].includes(postStatus) || isScheduled && isBeingScheduled || isPending && !hasPublishAction && !isSmallerThanMediumViewport) {
      component = IS_BUTTON;
    } else if (isSmallerThanMediumViewport || isPublishSidebarEnabled2) {
      component = IS_TOGGLE;
    } else {
      component = IS_BUTTON;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime444.jsx)(
      post_publish_button_default,
      {
        forceIsDirty,
        isOpen: isPublishSidebarOpened2,
        isToggle: component === IS_TOGGLE,
        onToggle: togglePublishSidebar2,
        setEntitiesSavedStatesCallback
      }
    );
  }

  // packages/editor/build-module/components/post-view-link/index.mjs
  var import_i18n268 = __toESM(require_i18n(), 1);
  var import_components241 = __toESM(require_components(), 1);
  var import_core_data108 = __toESM(require_core_data(), 1);
  var import_data196 = __toESM(require_data(), 1);
  var import_preferences17 = __toESM(require_preferences(), 1);
  var import_jsx_runtime445 = __toESM(require_jsx_runtime(), 1);
  function PostViewLink() {
    const { hasLoaded, permalink, isPublished, label, showIconLabels } = (0, import_data196.useSelect)((select7) => {
      const postTypeSlug = select7(store3).getCurrentPostType();
      const postType2 = select7(import_core_data108.store).getPostType(postTypeSlug);
      const { get } = select7(import_preferences17.store);
      return {
        permalink: select7(store3).getPermalink(),
        isPublished: select7(store3).isCurrentPostPublished(),
        label: postType2?.labels.view_item,
        hasLoaded: !!postType2,
        showIconLabels: get("core", "showIconLabels")
      };
    }, []);
    if (!isPublished || !permalink || !hasLoaded) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime445.jsx)(
      import_components241.Button,
      {
        icon: external_default,
        label: label || (0, import_i18n268.__)("View post"),
        href: permalink,
        target: "_blank",
        showTooltip: !showIconLabels,
        size: "compact"
      }
    );
  }

  // packages/editor/build-module/components/preview-dropdown/index.mjs
  var import_compose63 = __toESM(require_compose(), 1);
  var import_components242 = __toESM(require_components(), 1);
  var import_i18n269 = __toESM(require_i18n(), 1);
  var import_data197 = __toESM(require_data(), 1);
  var import_core_data109 = __toESM(require_core_data(), 1);
  var import_preferences18 = __toESM(require_preferences(), 1);
  var import_block_editor71 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime446 = __toESM(require_jsx_runtime(), 1);
  function PreviewDropdown({ forceIsAutosaveable, disabled: disabled2 }) {
    const {
      deviceType: deviceType2,
      homeUrl,
      isTemplate: isTemplate2,
      isViewable,
      showIconLabels,
      isTemplateHidden,
      templateId: templateId2
    } = (0, import_data197.useSelect)((select7) => {
      const {
        getDeviceType: getDeviceType2,
        getCurrentPostType: getCurrentPostType2,
        getCurrentTemplateId: getCurrentTemplateId2,
        getRenderingMode: getRenderingMode2
      } = select7(store3);
      const { getEntityRecord, getPostType } = select7(import_core_data109.store);
      const { get } = select7(import_preferences18.store);
      const _currentPostType = getCurrentPostType2();
      return {
        deviceType: getDeviceType2(),
        homeUrl: getEntityRecord("root", "__unstableBase")?.home,
        isTemplate: _currentPostType === "wp_template",
        isViewable: getPostType(_currentPostType)?.viewable ?? false,
        showIconLabels: get("core", "showIconLabels"),
        isTemplateHidden: getRenderingMode2() === "post-only",
        templateId: getCurrentTemplateId2()
      };
    }, []);
    const { setDeviceType: setDeviceType2, setRenderingMode: setRenderingMode2, setDefaultRenderingMode: setDefaultRenderingMode2 } = unlock(
      (0, import_data197.useDispatch)(store3)
    );
    const { resetZoomLevel } = unlock((0, import_data197.useDispatch)(import_block_editor71.store));
    const handleDevicePreviewChange = (newDeviceType) => {
      setDeviceType2(newDeviceType);
      resetZoomLevel();
    };
    const isMobile = (0, import_compose63.useViewportMatch)("medium", "<");
    if (isMobile) {
      return null;
    }
    const popoverProps = {
      placement: "bottom-end"
    };
    const toggleProps = {
      className: "editor-preview-dropdown__toggle",
      iconPosition: "right",
      size: "compact",
      showTooltip: !showIconLabels,
      disabled: disabled2,
      accessibleWhenDisabled: disabled2
    };
    const menuProps = {
      "aria-label": (0, import_i18n269.__)("View options")
    };
    const deviceIcons = {
      desktop: desktop_default,
      mobile: mobile_default,
      tablet: tablet_default
    };
    const choices = [
      {
        value: "Desktop",
        label: (0, import_i18n269.__)("Desktop"),
        icon: desktop_default
      },
      {
        value: "Tablet",
        label: (0, import_i18n269.__)("Tablet"),
        icon: tablet_default
      },
      {
        value: "Mobile",
        label: (0, import_i18n269.__)("Mobile"),
        icon: mobile_default
      }
    ];
    return /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(
      import_components242.DropdownMenu,
      {
        className: clsx_default(
          "editor-preview-dropdown",
          `editor-preview-dropdown--${deviceType2.toLowerCase()}`
        ),
        popoverProps,
        toggleProps,
        menuProps,
        icon: deviceIcons[deviceType2.toLowerCase()],
        label: (0, import_i18n269.__)("View"),
        disableOpenOnArrowDown: disabled2,
        children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime446.jsxs)(import_jsx_runtime446.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(import_components242.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(
            import_components242.MenuItemsChoice,
            {
              choices,
              value: deviceType2,
              onSelect: handleDevicePreviewChange
            }
          ) }),
          isTemplate2 && /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(import_components242.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime446.jsxs)(
            import_components242.MenuItem,
            {
              href: homeUrl,
              target: "_blank",
              icon: external_default,
              onClick: onClose,
              children: [
                (0, import_i18n269.__)("View site"),
                /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(VisuallyHidden, {
                  render: /* @__PURE__ */ (0, import_jsx_runtime446.jsx)("span", {}),
                  /* translators: accessibility text */
                  children: (0, import_i18n269.__)("(opens in a new tab)")
                })
              ]
            }
          ) }),
          !isTemplate2 && !!templateId2 && /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(import_components242.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(
            import_components242.MenuItem,
            {
              icon: !isTemplateHidden ? check_default : void 0,
              isSelected: !isTemplateHidden,
              role: "menuitemcheckbox",
              onClick: () => {
                const newRenderingMode = isTemplateHidden ? "template-locked" : "post-only";
                setRenderingMode2(newRenderingMode);
                setDefaultRenderingMode2(newRenderingMode);
                resetZoomLevel();
              },
              children: (0, import_i18n269.__)("Show template")
            }
          ) }),
          isViewable && /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(import_components242.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(
            PostPreviewButton,
            {
              className: "editor-preview-dropdown__button-external",
              role: "menuitem",
              forceIsAutosaveable,
              "aria-label": (0, import_i18n269.__)("Preview in new tab"),
              textContent: /* @__PURE__ */ (0, import_jsx_runtime446.jsxs)(import_jsx_runtime446.Fragment, { children: [
                (0, import_i18n269.__)("Preview in new tab"),
                /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(import_components242.Icon, { icon: external_default })
              ] }),
              onPreview: onClose
            }
          ) }),
          /* @__PURE__ */ (0, import_jsx_runtime446.jsx)(
            action_item_default.Slot,
            {
              name: "core/plugin-preview-menu",
              fillProps: { onClick: onClose }
            }
          )
        ] })
      }
    );
  }

  // packages/editor/build-module/components/zoom-out-toggle/index.mjs
  var import_components243 = __toESM(require_components(), 1);
  var import_i18n270 = __toESM(require_i18n(), 1);
  var import_element248 = __toESM(require_element(), 1);
  var import_data198 = __toESM(require_data(), 1);
  var import_block_editor72 = __toESM(require_block_editor(), 1);
  var import_preferences19 = __toESM(require_preferences(), 1);
  var import_keyboard_shortcuts7 = __toESM(require_keyboard_shortcuts(), 1);
  var import_keycodes16 = __toESM(require_keycodes(), 1);
  var import_jsx_runtime447 = __toESM(require_jsx_runtime(), 1);
  var ZoomOutToggle = ({ disabled: disabled2 }) => {
    const { isZoomOut, showIconLabels, isDistractionFree } = (0, import_data198.useSelect)(
      (select7) => ({
        isZoomOut: unlock(select7(import_block_editor72.store)).isZoomOut(),
        showIconLabels: select7(import_preferences19.store).get(
          "core",
          "showIconLabels"
        ),
        isDistractionFree: select7(import_preferences19.store).get(
          "core",
          "distractionFree"
        )
      })
    );
    const { resetZoomLevel, setZoomLevel } = unlock(
      (0, import_data198.useDispatch)(import_block_editor72.store)
    );
    const { registerShortcut, unregisterShortcut } = (0, import_data198.useDispatch)(
      import_keyboard_shortcuts7.store
    );
    (0, import_element248.useEffect)(() => {
      registerShortcut({
        name: "core/editor/zoom",
        category: "global",
        description: (0, import_i18n270.__)("Enter or exit zoom out."),
        keyCombination: {
          // `primaryShift+0` (`ctrl+shift+0`) is the shortcut for switching
          // to input mode in Windows, so apply a different key combination.
          modifier: (0, import_keycodes16.isAppleOS)() ? "primaryShift" : "secondary",
          character: "0"
        }
      });
      return () => {
        unregisterShortcut("core/editor/zoom");
      };
    }, [registerShortcut, unregisterShortcut]);
    (0, import_keyboard_shortcuts7.useShortcut)(
      "core/editor/zoom",
      () => {
        if (isZoomOut) {
          resetZoomLevel();
        } else {
          setZoomLevel("auto-scaled");
        }
      },
      {
        isDisabled: isDistractionFree
      }
    );
    const handleZoomOut = () => {
      if (isZoomOut) {
        resetZoomLevel();
      } else {
        setZoomLevel("auto-scaled");
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime447.jsx)(
      import_components243.Button,
      {
        accessibleWhenDisabled: true,
        disabled: disabled2,
        onClick: handleZoomOut,
        icon: square_default,
        label: (0, import_i18n270.__)("Zoom Out"),
        isPressed: isZoomOut,
        size: "compact",
        showTooltip: !showIconLabels,
        className: "editor-zoom-out-toggle"
      }
    );
  };
  var zoom_out_toggle_default = ZoomOutToggle;

  // packages/editor/build-module/components/collaborators-presence/index.mjs
  var import_components246 = __toESM(require_components(), 1);
  var import_element256 = __toESM(require_element(), 1);
  var import_core_data113 = __toESM(require_core_data(), 1);
  var import_i18n275 = __toESM(require_i18n(), 1);

  // packages/editor/build-module/components/collaborators-presence/avatar/component.mjs
  var import_components244 = __toESM(require_components(), 1);
  var import_element250 = __toESM(require_element(), 1);

  // packages/editor/build-module/components/collaborators-presence/avatar/use-image-loading-status.mjs
  var import_element249 = __toESM(require_element(), 1);
  function useImageLoadingStatus(src) {
    const [prevSrc, setPrevSrc] = (0, import_element249.useState)(src);
    const [status, setStatus] = (0, import_element249.useState)(
      src ? "loading" : "idle"
    );
    if (prevSrc !== src) {
      setPrevSrc(src);
      setStatus(src ? "loading" : "idle");
    }
    const handleLoad = (0, import_element249.useCallback)(() => setStatus("loaded"), []);
    const handleError = (0, import_element249.useCallback)(() => setStatus("error"), []);
    return { status, handleLoad, handleError };
  }

  // packages/editor/build-module/components/collaborators-presence/avatar/component.mjs
  var import_jsx_runtime448 = __toESM(require_jsx_runtime(), 1);
  k([a11y_default]);
  var GRAY_900 = "#1e1e1e";
  var WHITE = "#fff";
  function Avatar({
    className,
    src,
    name: name2,
    label,
    variant,
    size = "default",
    borderColor,
    dimmed = false,
    statusIndicator,
    style,
    ...props
  }) {
    const {
      status: imageStatus,
      handleLoad,
      handleError
    } = useImageLoadingStatus(src);
    const imageLoaded = imageStatus === "loaded";
    const showBadge = variant === "badge" && !!name2;
    const initials = name2 ? name2.split(/\s+/).slice(0, 2).map((word) => word[0]).join("").toUpperCase() : void 0;
    const nameColor = (0, import_element250.useMemo)(
      () => borderColor && w2(borderColor).isReadable(GRAY_900, {
        level: "AA",
        size: "normal"
      }) ? GRAY_900 : WHITE,
      [borderColor]
    );
    const customProperties = {
      ...style,
      ...borderColor ? {
        "--editor-avatar-outline-color": borderColor,
        "--editor-avatar-name-color": nameColor
      } : {}
    };
    const avatar = /* @__PURE__ */ (0, import_jsx_runtime448.jsxs)(
      "div",
      {
        className: clsx_default("editor-avatar", className, {
          "has-avatar-border-color": !!borderColor,
          "has-src": imageLoaded,
          "is-badge": showBadge,
          "is-small": size === "small",
          "is-dimmed": dimmed
        }),
        style: customProperties,
        role: name2 ? "img" : void 0,
        "aria-label": name2 || void 0,
        ...props,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime448.jsxs)("span", { className: "editor-avatar__image", children: [
            src && /* @__PURE__ */ (0, import_jsx_runtime448.jsx)(
              "img",
              {
                src,
                alt: "",
                crossOrigin: "anonymous",
                className: "editor-avatar__img",
                onLoad: handleLoad,
                onError: handleError
              }
            ),
            !imageLoaded && initials
          ] }),
          dimmed && !!statusIndicator && /* @__PURE__ */ (0, import_jsx_runtime448.jsx)("span", { className: "editor-avatar__status-indicator", children: /* @__PURE__ */ (0, import_jsx_runtime448.jsx)(import_components244.Icon, { icon: statusIndicator }) }),
          showBadge && /* @__PURE__ */ (0, import_jsx_runtime448.jsx)("span", { className: "editor-avatar__name", children: label || name2 })
        ]
      }
    );
    if (name2 && (!showBadge || label)) {
      return /* @__PURE__ */ (0, import_jsx_runtime448.jsx)(import_components244.Tooltip, { text: name2, children: avatar });
    }
    return avatar;
  }
  var component_default = Avatar;

  // packages/editor/build-module/components/collaborators-presence/avatar-group/component.mjs
  var import_element251 = __toESM(require_element(), 1);
  var import_i18n271 = __toESM(require_i18n(), 1);
  var import_jsx_runtime449 = __toESM(require_jsx_runtime(), 1);
  function AvatarGroup({
    className,
    max: max2 = 3,
    children,
    ...props
  }) {
    const childArray = import_element251.Children.toArray(children);
    const visible = childArray.slice(0, max2);
    const overflowCount = childArray.length - max2;
    return /* @__PURE__ */ (0, import_jsx_runtime449.jsxs)(
      "div",
      {
        role: "group",
        className: clsx_default("editor-avatar-group", className),
        ...props,
        children: [
          visible,
          overflowCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime449.jsx)(
            "span",
            {
              className: "editor-avatar-group__overflow",
              "aria-label": (0, import_i18n271.sprintf)(
                /* translators: %d: number of additional collaborators not shown */
                (0, import_i18n271._n)(
                  "%d more collaborator",
                  "%d more collaborators",
                  overflowCount
                ),
                overflowCount
              ),
              children: `+${overflowCount}`
            }
          )
        ]
      }
    );
  }
  var component_default2 = AvatarGroup;

  // packages/editor/build-module/components/collaborators-presence/list.mjs
  var import_i18n273 = __toESM(require_i18n(), 1);
  var import_components245 = __toESM(require_components(), 1);
  var import_a11y7 = __toESM(require_a11y(), 1);

  // packages/editor/build-module/components/collaborators-overlay/get-avatar-url.mjs
  function getAvatarUrl(avatarUrls) {
    return avatarUrls?.["48"] || avatarUrls?.["96"] || avatarUrls?.["24"];
  }

  // packages/editor/build-module/components/collab-sidebar/utils.mjs
  var import_i18n272 = __toESM(require_i18n(), 1);
  function sanitizeNoteContent(str3) {
    return str3.trim();
  }
  var THREAD_ALIGN_OFFSET = -16;
  var THREAD_GAP = 16;
  var OVERLAP_MARGIN = 20;
  var AVATAR_BORDER_COLORS = [
    "#C36EFF",
    // Purple
    "#FF51A8",
    // Pink
    "#E4780A",
    // Orange
    "#FF35EE",
    // Magenta
    "#879F11",
    // Olive
    "#46A494",
    // Teal
    "#00A2C3"
    // Cyan
  ];
  function getAvatarBorderColor(userId) {
    return AVATAR_BORDER_COLORS[userId % AVATAR_BORDER_COLORS.length];
  }
  function getNoteExcerpt(text, excerptLength = 10) {
    if (!text) {
      return "";
    }
    const wordCountType = (0, import_i18n272._x)("words", "Word count type. Do not translate!");
    const rawText = text.trim();
    let trimmedExcerpt = "";
    if (wordCountType === "words") {
      trimmedExcerpt = rawText.split(" ", excerptLength).join(" ");
    } else if (wordCountType === "characters_excluding_spaces") {
      const textWithSpaces = rawText.split("", excerptLength).join("");
      const numberOfSpaces = textWithSpaces.length - textWithSpaces.replaceAll(" ", "").length;
      trimmedExcerpt = rawText.split("", excerptLength + numberOfSpaces).join("");
    } else if (wordCountType === "characters_including_spaces") {
      trimmedExcerpt = rawText.split("", excerptLength).join("");
    }
    const isTrimmed = trimmedExcerpt !== rawText;
    return isTrimmed ? trimmedExcerpt + "\u2026" : trimmedExcerpt;
  }
  function calculateNotePositions({
    threads,
    selectedNoteId,
    blockRects,
    heights,
    scrollTop = 0
  }) {
    const offsets = {};
    const anchorIndex = Math.max(
      0,
      threads.findIndex((thread) => thread.id === selectedNoteId)
    );
    const anchorThread = threads[anchorIndex];
    if (!anchorThread || !blockRects[anchorThread.id]) {
      return { positions: {} };
    }
    const anchorRect = blockRects[anchorThread.id];
    const anchorTop = anchorRect.top || 0;
    const anchorHeight = heights[anchorThread.id] || 0;
    offsets[anchorThread.id] = THREAD_ALIGN_OFFSET;
    let prevAdjustedTop = anchorTop + THREAD_ALIGN_OFFSET;
    let prevHeight = anchorHeight;
    for (let i3 = anchorIndex + 1; i3 < threads.length; i3++) {
      const thread = threads[i3];
      const threadRect = blockRects[thread.id];
      if (!threadRect) {
        continue;
      }
      const threadTop = threadRect.top || 0;
      const threadHeight = heights[thread.id] || 0;
      let offset = THREAD_ALIGN_OFFSET;
      const prevBottom = prevAdjustedTop + prevHeight;
      if (threadTop < prevBottom + THREAD_GAP) {
        offset = prevBottom - threadTop + OVERLAP_MARGIN;
      }
      offsets[thread.id] = offset;
      prevAdjustedTop = threadTop + offset;
      prevHeight = threadHeight;
    }
    let belowAdjustedTop = anchorTop + THREAD_ALIGN_OFFSET;
    for (let i3 = anchorIndex - 1; i3 >= 0; i3--) {
      const thread = threads[i3];
      const threadRect = blockRects[thread.id];
      if (!threadRect) {
        continue;
      }
      const threadTop = threadRect.top || 0;
      const threadHeight = heights[thread.id] || 0;
      let offset = THREAD_ALIGN_OFFSET;
      const threadBottom = threadTop + threadHeight;
      if (threadBottom > belowAdjustedTop) {
        offset = belowAdjustedTop - threadTop - threadHeight - OVERLAP_MARGIN;
      }
      offsets[thread.id] = offset;
      belowAdjustedTop = threadTop + offset;
    }
    const positions = {};
    for (const thread of threads) {
      const blockRect = blockRects[thread.id];
      if (blockRect && offsets[thread.id] !== void 0) {
        positions[thread.id] = blockRect.top + scrollTop + offsets[thread.id];
      }
    }
    return { positions };
  }
  function focusNoteThread(noteId, container, additionalSelector) {
    if (!container) {
      return;
    }
    const threadSelector = noteId && noteId !== "new" ? `[role=treeitem][id="note-thread-${noteId}"]` : "[role=treeitem]:not([id])";
    const selector2 = additionalSelector ? `${threadSelector} ${additionalSelector}` : threadSelector;
    return new Promise((resolve) => {
      if (container.querySelector(selector2)) {
        return resolve(container.querySelector(selector2));
      }
      let timer = null;
      const observer = new window.MutationObserver(() => {
        if (container.querySelector(selector2)) {
          clearTimeout(timer);
          observer.disconnect();
          resolve(container.querySelector(selector2));
        }
      });
      observer.observe(container, {
        childList: true,
        subtree: true
      });
      timer = setTimeout(() => {
        observer.disconnect();
        resolve(null);
      }, 3e3);
    }).then((element) => element?.focus());
  }

  // packages/editor/build-module/components/collaborators-presence/list.mjs
  var import_jsx_runtime450 = __toESM(require_jsx_runtime(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='b52a84ee9f']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "b52a84ee9f");
    style.appendChild(document.createTextNode(".editor-collaborators-presence__list.components-popover .components-popover__content{background:#fff;border:1px solid #ddd;border-radius:8px;border-width:1px 0 0 1px;box-shadow:0 1px 2px #0000000d,0 2px 3px #0000000a,0 6px 6px #00000008,0 8px 8px #00000005}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-content{min-width:280px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header{align-items:center;display:flex;justify-content:space-between;padding:8px 16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title{display:flex;font-size:13px;font-weight:499;gap:4px;line-height:20px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title span{color:#757575}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action{padding:0}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action button{color:#1e1e1e;height:32px;padding:0;width:32px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-items{display:flex;flex-direction:column;padding-bottom:16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item{all:unset;align-items:center;box-sizing:border-box;cursor:var(--wpds-cursor-control,pointer);display:flex;gap:8px;padding:12px 16px;transition:background-color .2s ease;width:100%}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:hover:not(:disabled){background-color:rgba(var(--wp-admin-theme-color--rgb),.04)}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:active:not(:disabled){background-color:rgba(var(--wp-admin-theme-color--rgb),.08)}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:focus-visible{outline:2px solid var(--wp-admin-theme-color,#3858e9);outline-offset:-2px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:disabled{cursor:default}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item-info{display:flex;flex:1;flex-direction:column;min-width:0}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item-name{color:#1e1e1e;font-size:13px;font-weight:499;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"));
    document.head.appendChild(style);
  }
  function CollaboratorsList({
    activeCollaborators,
    popoverAnchor,
    setIsPopoverVisible,
    cursorRegistry
  }) {
    const handleCollaboratorClick = (clientId) => {
      const success = cursorRegistry.scrollToCursor(clientId, {
        behavior: "smooth",
        block: "center",
        highlightDuration: 2e3
      });
      if (success) {
        (0, import_a11y7.speak)((0, import_i18n273.__)("Scrolled to cursor"), "polite");
        setIsPopoverVisible(false);
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime450.jsx)(
      import_components245.Popover,
      {
        anchor: popoverAnchor,
        placement: "bottom",
        offset: 8,
        className: "editor-collaborators-presence__list",
        onClose: () => setIsPopoverVisible(false),
        children: /* @__PURE__ */ (0, import_jsx_runtime450.jsxs)("div", { className: "editor-collaborators-presence__list-content", children: [
          /* @__PURE__ */ (0, import_jsx_runtime450.jsxs)("div", { className: "editor-collaborators-presence__list-header", children: [
            /* @__PURE__ */ (0, import_jsx_runtime450.jsxs)("div", { className: "editor-collaborators-presence__list-header-title", children: [
              (0, import_i18n273.__)("Collaborators"),
              /* @__PURE__ */ (0, import_jsx_runtime450.jsx)("span", { children: activeCollaborators.length })
            ] }),
            /* @__PURE__ */ (0, import_jsx_runtime450.jsx)("div", { className: "editor-collaborators-presence__list-header-action", children: /* @__PURE__ */ (0, import_jsx_runtime450.jsx)(
              import_components245.Button,
              {
                __next40pxDefaultSize: true,
                icon: close_small_default,
                iconSize: 24,
                label: (0, import_i18n273.__)("Close Collaborators List"),
                onClick: () => setIsPopoverVisible(false)
              }
            ) })
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime450.jsx)("div", { className: "editor-collaborators-presence__list-items", children: activeCollaborators.map((collaboratorState) => {
            const isCurrentUser = collaboratorState.isMe;
            return /* @__PURE__ */ (0, import_jsx_runtime450.jsxs)(
              "button",
              {
                className: "editor-collaborators-presence__list-item",
                disabled: isCurrentUser,
                onClick: () => handleCollaboratorClick(
                  collaboratorState.clientId
                ),
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime450.jsx)(
                    component_default,
                    {
                      src: getAvatarUrl(
                        collaboratorState.collaboratorInfo.avatar_urls
                      ),
                      name: collaboratorState.collaboratorInfo.name,
                      borderColor: isCurrentUser ? "var(--wp-admin-theme-color)" : getAvatarBorderColor(
                        collaboratorState.collaboratorInfo.id
                      ),
                      dimmed: !collaboratorState.isConnected
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime450.jsx)("div", { className: "editor-collaborators-presence__list-item-info", children: /* @__PURE__ */ (0, import_jsx_runtime450.jsx)("div", { className: "editor-collaborators-presence__list-item-name", children: isCurrentUser ? (0, import_i18n273.__)("You") : collaboratorState.collaboratorInfo.name }) })
                ]
              },
              collaboratorState.clientId
            );
          }) })
        ] })
      }
    );
  }

  // packages/editor/build-module/components/collaborators-overlay/cursor-registry.mjs
  function highlightCursor(element, duration) {
    element.classList.add("collaborators-overlay-cursor-highlighted");
    setTimeout(() => {
      element.classList.remove("collaborators-overlay-cursor-highlighted");
    }, duration);
  }
  function createCursorRegistry() {
    const cursorMap = /* @__PURE__ */ new Map();
    return {
      /**
       * Register a cursor element when it's created.
       *
       * @param clientId - The clientId of the cursor to register.
       * @param element  - The cursor element to register.
       */
      registerCursor(clientId, element) {
        cursorMap.set(clientId, element);
      },
      /**
       * Unregister a cursor element when it's removed.
       *
       * @param clientId - The clientId of the cursor to unregister.
       */
      unregisterCursor(clientId) {
        cursorMap.delete(clientId);
      },
      /**
       * Scroll to a cursor by clientId.
       *
       * @param clientId - The clientId of the cursor to scroll to.
       * @param options  - The options for the scroll.
       * @return true if cursor was found and scrolled to, false otherwise.
       */
      scrollToCursor(clientId, options) {
        const cursorElement = cursorMap.get(clientId);
        if (!cursorElement) {
          return false;
        }
        cursorElement.scrollIntoView({
          behavior: options?.behavior ?? "smooth",
          block: options?.block ?? "center",
          inline: options?.inline ?? "nearest"
        });
        if (options?.highlightDuration) {
          highlightCursor(cursorElement, options.highlightDuration);
        }
        return true;
      },
      /**
       * Clear the registry.
       */
      removeAll() {
        cursorMap.clear();
      }
    };
  }

  // packages/editor/build-module/components/collaborators-overlay/index.mjs
  var import_block_editor73 = __toESM(require_block_editor(), 1);

  // packages/editor/build-module/components/collaborators-overlay/overlay.mjs
  var import_compose64 = __toESM(require_compose(), 1);
  var import_element255 = __toESM(require_element(), 1);
  var import_i18n274 = __toESM(require_i18n(), 1);

  // packages/editor/build-module/components/collaborators-overlay/collaborator-styles.mjs
  var ELEVATION_X_SMALL = "0 1px 1px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.02), 0 3px 3px rgba(0, 0, 0, 0.02), 0 4px 4px rgba(0, 0, 0, 0.01)";
  var RADIUS_FULL = "9999px";
  var BUTTON_SIZE_COMPACT = "32px";
  var BUTTON_SIZE_SMALL = "24px";
  var GRID_UNIT_05 = "4px";
  var GRID_UNIT_10 = "8px";
  var BORDER_WIDTH = "1px";
  var BORDER_WIDTH_FOCUS_FALLBACK = "2px";
  var WHITE2 = "#fff";
  var FONT_SIZE_X_SMALL = "11px";
  var FONT_SIZE_MEDIUM = "13px";
  var FONT_WEIGHT_MEDIUM = "499";
  var FONT_LINE_HEIGHT_SMALL = "20px";

  // packages/editor/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs
  var AVATAR_IFRAME_STYLES = `
.editor-avatar {
	position: relative;
	display: inline-flex;
	align-items: center;
	border-radius: ${RADIUS_FULL};
	flex-shrink: 0;
	box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 2px) ${WHITE2}, ${ELEVATION_X_SMALL};
}
.editor-avatar__image {
	box-sizing: border-box;
	position: relative;
	width: ${BUTTON_SIZE_COMPACT};
	height: ${BUTTON_SIZE_COMPACT};
	border-radius: ${RADIUS_FULL};
	border: 0;
	background-color: var(--wp-admin-theme-color, #3858e9);
	overflow: hidden;
	overflow: clip;
	flex-shrink: 0;
	font-size: 0;
	color: ${WHITE2};
}
.is-small > .editor-avatar__image {
	width: ${BUTTON_SIZE_SMALL};
	height: ${BUTTON_SIZE_SMALL};
}
.has-avatar-border-color > .editor-avatar__image {
	border: var(--wp-admin-border-width-focus, 2px) solid var(--editor-avatar-outline-color);
	background-clip: padding-box;
}
.has-avatar-border-color > .editor-avatar__image::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus, 2px) ${WHITE2};
	pointer-events: none;
	z-index: 1;
}
.editor-avatar__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: inherit;
	opacity: 0;
}
.has-src > .editor-avatar__image > .editor-avatar__img {
	opacity: 1;
}
.editor-avatar:not(.has-src) > .editor-avatar__image {
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: ${FONT_SIZE_X_SMALL};
	font-weight: ${FONT_WEIGHT_MEDIUM};
	border: 0;
	background-clip: border-box;
}
.editor-avatar:not(.has-src) > .editor-avatar__image::after {
	content: none;
}
.editor-avatar:not(.has-src).has-avatar-border-color > .editor-avatar__image {
	background-color: var(--editor-avatar-outline-color);
}
.editor-avatar__name {
	font-size: ${FONT_SIZE_MEDIUM};
	font-weight: ${FONT_WEIGHT_MEDIUM};
	line-height: ${FONT_LINE_HEIGHT_SMALL};
	color: var(--editor-avatar-name-color, ${WHITE2});
	min-width: 0;
	padding-bottom: 2px; /* $grid-unit-05 / 2 */
	overflow: hidden;
	opacity: 0;
	white-space: nowrap;
	transition: opacity 0.15s cubic-bezier(0.15, 0, 0.15, 1);
}
.editor-avatar.is-badge {
	display: inline-grid;
	grid-template-columns: min-content 0fr;
	column-gap: 0;
	padding-inline-end: 0;
	background-color: var(--wp-admin-theme-color, #3858e9);
	transition:
		grid-template-columns 0.3s cubic-bezier(0.15, 0, 0.15, 1),
		column-gap 0.3s cubic-bezier(0.15, 0, 0.15, 1),
		padding-inline-end 0.3s cubic-bezier(0.15, 0, 0.15, 1);
}
.editor-avatar.is-badge:hover {
	grid-template-columns: min-content 1fr;
	column-gap: ${GRID_UNIT_05};
	padding-inline-end: ${GRID_UNIT_10};
	transition-timing-function: cubic-bezier(0.85, 0, 0.85, 1);
}
.editor-avatar.is-badge:hover .editor-avatar__name {
	opacity: 1;
	transition-timing-function: cubic-bezier(0.85, 0, 0.85, 1);
}
.editor-avatar.is-badge.has-avatar-border-color {
	background-color: var(--editor-avatar-outline-color);
}
@media (prefers-reduced-motion: reduce) {
	.editor-avatar.is-badge,
	.editor-avatar__name {
		transition: none;
	}
}
`;

  // packages/editor/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs
  var OVERLAY_IFRAME_STYLES = `
.block-canvas-cover {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 20000;
}
.block-canvas-cover .collaborators-overlay-full {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}
.block-canvas-cover .collaborators-overlay-fixed {
	position: fixed;
	width: 100%;
	height: 100%;
}
.collaborators-overlay-user {
	position: absolute;
}
/* Cursor lines render below avatar labels across all users. The parent
   .collaborators-overlay-user has no z-index so it does not create a
   stacking context \u2014 children participate in the shared overlay context. */
.collaborators-overlay-user-cursor {
	position: absolute;
	z-index: 0;
	width: ${BORDER_WIDTH_FOCUS_FALLBACK};
	border-radius: ${BORDER_WIDTH};
	outline: ${BORDER_WIDTH} solid ${WHITE2};
	box-shadow: ${ELEVATION_X_SMALL};
	animation: collaborators-overlay-cursor-blink 1s infinite;
}
.collaborators-overlay-selection-rect {
	position: absolute;
	opacity: 0.15;
	pointer-events: none;
	border-radius: 2px;
}

/* Overlay-specific positioning applied to the Avatar cursor label. */
.collaborators-overlay-user-label.editor-avatar {
	position: absolute;
	z-index: 1;
	transform: translate(-11px, -100%);
	margin-top: -${GRID_UNIT_05};
	pointer-events: auto;
	overflow: visible;
	width: max-content;
}
/* Avatar positioned above a highlighted block as a label. */
.collaborators-overlay-block-label.editor-avatar {
	position: absolute;
	z-index: 1;
	transform: translateY(calc(-100% - ${GRID_UNIT_10}));
	pointer-events: auto;
	overflow: visible;
	width: max-content;
}

@keyframes collaborators-overlay-cursor-blink {
	0%, 45% { opacity: 1; }
	55%, 95% { opacity: 0; }
	100% { opacity: 1; }
}
.collaborators-overlay-cursor-highlighted .collaborators-overlay-user-cursor {
	animation: collaborators-overlay-cursor-highlight 0.6s ease-in-out 3;
}
.collaborators-overlay-cursor-highlighted .collaborators-overlay-user-label {
	animation: collaborators-overlay-label-highlight 0.6s ease-in-out 3;
}
@keyframes collaborators-overlay-cursor-highlight {
	0%, 100% {
		transform: scale(1);
		filter: drop-shadow(0 0 0 transparent);
	}
	50% {
		transform: scale(1.2);
		filter: drop-shadow(0 0 8px currentColor);
	}
}
@keyframes collaborators-overlay-label-highlight {
	0%, 100% {
		transform: translate(-11px, -100%) scale(1);
		filter: drop-shadow(0 0 0 transparent);
	}
	50% {
		transform: translate(-11px, -100%) scale(1.1);
		filter: drop-shadow(0 0 6px currentColor);
	}
}
.block-editor-block-list__block.is-collaborator-selected:not(:focus)::after {
	content: "";
	position: absolute;
	pointer-events: none;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	outline-color: var(--collaborator-outline-color);
	outline-style: solid;
	outline-width: calc(var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1));
	outline-offset: calc(-1 * var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1));
	box-shadow: inset 0 0 0 calc((var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1)) + 0.5px) rgba(${WHITE2}, 0.7);
	z-index: 1;
}
@media (prefers-reduced-motion: reduce) {
	.collaborators-overlay-user-label,
	.collaborators-overlay-user-cursor {
		animation: none;
	}
}
`;

  // packages/editor/build-module/components/collaborators-overlay/timing-utils.mjs
  function setDelayedInterval(callback, delayMs) {
    let timerHandle = null;
    const runner = () => {
      try {
        callback();
      } catch {
      }
      timerHandle = setTimeout(runner, delayMs);
    };
    timerHandle = setTimeout(runner, delayMs);
    return () => {
      if (timerHandle) {
        clearTimeout(timerHandle);
      }
    };
  }

  // packages/editor/build-module/components/collaborators-overlay/use-block-highlighting.mjs
  var import_core_data110 = __toESM(require_core_data(), 1);
  var import_element253 = __toESM(require_element(), 1);

  // packages/editor/build-module/components/collaborators-overlay/use-debounced-recompute.mjs
  var import_element252 = __toESM(require_element(), 1);
  function useDebouncedRecompute(delayMs) {
    const [recomputeToken, setRecomputeToken] = (0, import_element252.useState)(0);
    const timeoutRef = (0, import_element252.useRef)(null);
    const rerenderAfterDelay = (0, import_element252.useCallback)(() => {
      if (timeoutRef.current) {
        clearTimeout(timeoutRef.current);
      }
      timeoutRef.current = setTimeout(() => {
        setRecomputeToken((t4) => t4 + 1);
      }, delayMs);
      return () => {
        if (timeoutRef.current) {
          clearTimeout(timeoutRef.current);
        }
      };
    }, [delayMs]);
    return [recomputeToken, rerenderAfterDelay];
  }

  // packages/editor/build-module/components/collaborators-overlay/use-block-highlighting.mjs
  var { useActiveCollaborators, useResolvedSelection } = unlock(import_core_data110.privateApis);
  function useBlockHighlighting(overlayElement, blockEditorDocument, postId2, postType2, delayMs) {
    const highlightedBlockIds = (0, import_element253.useRef)(/* @__PURE__ */ new Set());
    const userStates = useActiveCollaborators(
      postId2 ?? null,
      postType2 ?? null
    );
    const resolveSelection = useResolvedSelection(
      postId2 ?? null,
      postType2 ?? null
    );
    const [highlights, setHighlights] = (0, import_element253.useState)(
      []
    );
    const [recomputeToken, rerenderHighlightsAfterDelay] = useDebouncedRecompute(delayMs);
    (0, import_element253.useEffect)(() => {
      if (!blockEditorDocument) {
        setHighlights([]);
        return;
      }
      const currentHighlightedIds = highlightedBlockIds.current;
      const seen = /* @__PURE__ */ new Set();
      const blocksToHighlight = userStates.filter((userState) => {
        const isWholeBlockSelected = userState.editorState?.selection?.type === import_core_data110.SelectionType.WholeBlock;
        return !userState.isMe && isWholeBlockSelected;
      }).map((userState) => {
        let localClientId;
        try {
          ({ localClientId } = resolveSelection(
            userState.editorState?.selection
          ));
        } catch {
          return null;
        }
        if (!localClientId) {
          return null;
        }
        return {
          blockId: localClientId,
          color: userState.isMe ? "var(--wp-admin-theme-color)" : getAvatarBorderColor(userState.collaboratorInfo.id),
          userName: userState.collaboratorInfo.name,
          avatarUrl: getAvatarUrl(
            userState.collaboratorInfo.avatar_urls
          )
        };
      }).filter((block) => {
        if (!block) {
          return false;
        }
        if (seen.has(block.blockId)) {
          return false;
        }
        seen.add(block.blockId);
        return true;
      });
      const selectedBlockIds = new Set(
        blocksToHighlight.map((block) => block.blockId)
      );
      for (const blockId of currentHighlightedIds) {
        if (!selectedBlockIds.has(blockId)) {
          const blockElement = getBlockElementById(
            blockEditorDocument,
            blockId
          );
          if (blockElement) {
            blockElement.classList.remove("is-collaborator-selected");
            blockElement.style.removeProperty(
              "--collaborator-outline-color"
            );
          }
          currentHighlightedIds.delete(blockId);
        }
      }
      const results = [];
      const overlayRect = overlayElement?.getBoundingClientRect() ?? null;
      blocksToHighlight.forEach((block) => {
        const { color, blockId, userName, avatarUrl } = block;
        const blockElement = getBlockElementById(
          blockEditorDocument,
          blockId
        );
        if (!blockElement) {
          return;
        }
        blockElement.classList.add("is-collaborator-selected");
        blockElement.style.setProperty(
          "--collaborator-outline-color",
          color
        );
        currentHighlightedIds.add(blockId);
        if (overlayRect) {
          const blockRect = blockElement.getBoundingClientRect();
          results.push({
            blockId,
            userName,
            avatarUrl,
            color,
            x: blockRect.left - overlayRect.left,
            y: blockRect.top - overlayRect.top
          });
        }
      });
      setHighlights(results);
      return () => {
        for (const blockId of currentHighlightedIds) {
          const el = getBlockElementById(blockEditorDocument, blockId);
          if (el) {
            el.classList.remove("is-collaborator-selected");
            el.style.removeProperty("--collaborator-outline-color");
          }
        }
        currentHighlightedIds.clear();
      };
    }, [
      userStates,
      blockEditorDocument,
      overlayElement,
      recomputeToken,
      resolveSelection
    ]);
    return { highlights, rerenderHighlightsAfterDelay };
  }
  var getBlockElementById = (blockEditorDocument, blockId) => {
    return blockEditorDocument.querySelector(`[data-block="${blockId}"]`);
  };

  // packages/editor/build-module/components/collaborators-overlay/use-render-cursors.mjs
  var import_core_data112 = __toESM(require_core_data(), 1);
  var import_data199 = __toESM(require_data(), 1);
  var import_element254 = __toESM(require_element(), 1);
  var import_preferences20 = __toESM(require_preferences(), 1);

  // packages/editor/build-module/components/collaborators-overlay/compute-selection.mjs
  var import_core_data111 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/collaborators-overlay/cursor-dom-utils.mjs
  var MAX_NODE_OFFSET_COUNT = 500;
  var getCursorPosition = (absolutePositionIndex, blockElement, editorDocument, overlayRect) => {
    if (absolutePositionIndex === null || !blockElement) {
      return null;
    }
    return getOffsetPositionInBlock(
      blockElement,
      absolutePositionIndex,
      editorDocument,
      overlayRect
    ) ?? null;
  };
  var getOffsetPositionInBlock = (blockElement, charOffset, editorDocument, overlayRect) => {
    const { node, offset } = findInnerBlockOffset(
      blockElement,
      charOffset,
      editorDocument
    );
    const cursorRange = editorDocument.createRange();
    try {
      cursorRange.setStart(node, offset);
    } catch {
      return null;
    }
    cursorRange.collapse(true);
    const cursorRect = cursorRange.getBoundingClientRect();
    const blockRect = blockElement.getBoundingClientRect();
    let cursorX = 0;
    let cursorY = 0;
    if (cursorRect.x === 0 && cursorRect.y === 0 && cursorRect.width === 0 && cursorRect.height === 0) {
      cursorX = blockRect.left - overlayRect.left;
      cursorY = blockRect.top - overlayRect.top;
    } else {
      cursorX = cursorRect.left - overlayRect.left;
      cursorY = cursorRect.top - overlayRect.top;
    }
    let cursorHeight = cursorRect.height;
    if (cursorHeight === 0) {
      const view2 = editorDocument.defaultView ?? window;
      cursorHeight = parseInt(view2.getComputedStyle(blockElement).lineHeight, 10) || blockRect.height;
    }
    return {
      x: cursorX,
      y: cursorY,
      height: cursorHeight
    };
  };
  var getSelectionRects = (blockElement, startOffset, endOffset, editorDocument, overlayRect) => {
    let normalizedStart = startOffset;
    let normalizedEnd = endOffset;
    if (normalizedStart > normalizedEnd) {
      [normalizedStart, normalizedEnd] = [normalizedEnd, normalizedStart];
    }
    const startPos = findInnerBlockOffset(
      blockElement,
      normalizedStart,
      editorDocument
    );
    const endPos = findInnerBlockOffset(
      blockElement,
      normalizedEnd,
      editorDocument
    );
    const range = editorDocument.createRange();
    try {
      range.setStart(startPos.node, startPos.offset);
      range.setEnd(endPos.node, endPos.offset);
    } catch {
      return null;
    }
    const clientRects = range.getClientRects();
    const rects = [];
    for (const rect of clientRects) {
      if (rect.width === 0 && rect.height === 0) {
        continue;
      }
      const x2 = rect.left - overlayRect.left;
      const y3 = rect.top - overlayRect.top;
      const isDuplicate = rects.some(
        (r4) => r4.x === x2 && r4.y === y3 && r4.width === rect.width && r4.height === rect.height
      );
      if (isDuplicate) {
        continue;
      }
      rects.push({
        x: x2,
        y: y3,
        width: rect.width,
        height: rect.height
      });
    }
    return rects.length > 0 ? rects : null;
  };
  var getFullBlockSelectionRects = (blockElement, editorDocument, overlayRect) => {
    const range = editorDocument.createRange();
    range.selectNodeContents(blockElement);
    const clientRects = range.getClientRects();
    const rects = [];
    for (const rect of clientRects) {
      if (rect.width === 0 && rect.height === 0) {
        continue;
      }
      rects.push({
        x: rect.left - overlayRect.left,
        y: rect.top - overlayRect.top,
        width: rect.width,
        height: rect.height
      });
    }
    if (rects.length === 0) {
      const blockRect = blockElement.getBoundingClientRect();
      if (blockRect.width > 0 && blockRect.height > 0) {
        rects.push({
          x: blockRect.left - overlayRect.left,
          y: blockRect.top - overlayRect.top,
          width: blockRect.width,
          height: blockRect.height
        });
      }
    }
    return rects;
  };
  var getBlocksBetween = (startBlockId, endBlockId, editorDocument) => {
    const allBlocks = editorDocument.querySelectorAll("[data-block]");
    let startIndex = -1;
    let endIndex = -1;
    for (let i3 = 0; i3 < allBlocks.length; i3++) {
      const blockId = allBlocks[i3].getAttribute("data-block");
      if (blockId === startBlockId) {
        startIndex = i3;
      }
      if (blockId === endBlockId) {
        endIndex = i3;
      }
    }
    if (startIndex === -1 || endIndex === -1) {
      return [];
    }
    if (startIndex > endIndex) {
      [startIndex, endIndex] = [endIndex, startIndex];
    }
    const result = [];
    for (let i3 = startIndex + 1; i3 < endIndex; i3++) {
      result.push(allBlocks[i3]);
    }
    return result;
  };
  var findInnerBlockOffset = (blockElement, offset, editorDocument) => {
    const treeWalker = editorDocument.createTreeWalker(
      blockElement,
      NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT
      // eslint-disable-line no-bitwise
    );
    let currentOffset = 0;
    let lastTextNode = null;
    let node = null;
    let nodeCount = 1;
    while (node = treeWalker.nextNode()) {
      nodeCount++;
      if (nodeCount > MAX_NODE_OFFSET_COUNT) {
        if (lastTextNode) {
          return { node: lastTextNode, offset: 0 };
        }
        return { node: blockElement, offset: 0 };
      }
      const nodeLength = node.nodeValue?.length ?? 0;
      if (node.nodeType === Node.ELEMENT_NODE) {
        if (node.nodeName === "BR") {
          if (currentOffset + 1 >= offset) {
            const nodeAfterBr = treeWalker.nextNode();
            if (nodeAfterBr?.nodeType === Node.TEXT_NODE) {
              return { node: nodeAfterBr, offset: 0 };
            } else if (lastTextNode) {
              return {
                node: lastTextNode,
                offset: lastTextNode.nodeValue?.length ?? 0
              };
            }
            return { node: blockElement, offset: 0 };
          }
          currentOffset += 1;
          continue;
        } else {
          continue;
        }
      }
      if (nodeLength === 0) {
        continue;
      }
      if (currentOffset + nodeLength >= offset) {
        return { node, offset: offset - currentOffset };
      }
      currentOffset += nodeLength;
      if (node.nodeType === Node.TEXT_NODE) {
        lastTextNode = node;
      }
    }
    if (lastTextNode && lastTextNode.nodeValue?.length) {
      return { node: lastTextNode, offset: lastTextNode.nodeValue.length };
    }
    return { node: blockElement, offset: 0 };
  };
  var isNodeBefore = (a3, b3) => a3.compareDocumentPosition(b3) === Node.DOCUMENT_POSITION_FOLLOWING;

  // packages/editor/build-module/components/collaborators-overlay/compute-selection.mjs
  function computeSelectionVisual(selection, start2, end, overlayContext) {
    if (selection.type === import_core_data111.SelectionType.None || selection.type === import_core_data111.SelectionType.WholeBlock) {
      return {};
    }
    if (selection.type === import_core_data111.SelectionType.Cursor) {
      return computeCursorOnly(start2, overlayContext);
    }
    if (!end) {
      return {};
    }
    return computeTextSelection(selection, start2, end, overlayContext);
  }
  function computeCursorOnly(start2, overlayContext) {
    if (!start2.localClientId) {
      return {};
    }
    const blockElement = overlayContext.editorDocument.querySelector(
      `[data-block="${start2.localClientId}"]`
    );
    return {
      coords: getCursorPosition(
        start2.richTextOffset,
        blockElement,
        overlayContext.editorDocument,
        overlayContext.overlayRect
      )
    };
  }
  function computeTextSelection(selection, start2, end, overlayContext) {
    if (!start2.localClientId || !end.localClientId || start2.richTextOffset === null || end.richTextOffset === null) {
      return {};
    }
    const isReverse = selection.selectionDirection === import_core_data111.SelectionDirection.Backward;
    const activeEnd = isReverse ? start2 : end;
    let allRects;
    let activeEndBlock = null;
    if (selection.type === import_core_data111.SelectionType.SelectionInOneBlock) {
      const result = computeSingleBlockRects(start2, end, overlayContext);
      allRects = result.rects;
      activeEndBlock = result.blockElement;
    } else {
      const result = computeMultiBlockRects(start2, end, overlayContext);
      allRects = result.rects;
      activeEndBlock = activeEnd.localClientId === result.firstBlockClientId ? result.firstBlock : result.lastBlock;
    }
    if (allRects.length > 0) {
      return {
        coords: getCursorPosition(
          activeEnd.richTextOffset,
          activeEndBlock,
          overlayContext.editorDocument,
          overlayContext.overlayRect
        ),
        selectionRects: allRects
      };
    }
    const startBlock = overlayContext.editorDocument.querySelector(
      `[data-block="${start2.localClientId}"]`
    );
    return {
      coords: getCursorPosition(
        start2.richTextOffset,
        startBlock,
        overlayContext.editorDocument,
        overlayContext.overlayRect
      )
    };
  }
  function computeSingleBlockRects(start2, end, overlayContext) {
    const blockElement = overlayContext.editorDocument.querySelector(
      `[data-block="${start2.localClientId}"]`
    );
    if (!blockElement || start2.richTextOffset === null || end.richTextOffset === null) {
      return { rects: [], blockElement: null };
    }
    return {
      rects: getSelectionRects(
        blockElement,
        start2.richTextOffset,
        end.richTextOffset,
        overlayContext.editorDocument,
        overlayContext.overlayRect
      ) ?? [],
      blockElement
    };
  }
  function computeMultiBlockRects(start2, end, overlayContext) {
    let docFirst = start2;
    let docLast = end;
    let firstBlock = overlayContext.editorDocument.querySelector(
      `[data-block="${docFirst.localClientId}"]`
    );
    let lastBlock = overlayContext.editorDocument.querySelector(
      `[data-block="${docLast.localClientId}"]`
    );
    if (firstBlock && lastBlock && isNodeBefore(lastBlock, firstBlock)) {
      docFirst = end;
      docLast = start2;
      [firstBlock, lastBlock] = [lastBlock, firstBlock];
    }
    if (!firstBlock || !lastBlock || docFirst.richTextOffset === null || docLast.richTextOffset === null || !docFirst.localClientId || !docLast.localClientId) {
      return {
        rects: [],
        firstBlock: null,
        lastBlock: null,
        firstBlockClientId: null
      };
    }
    const allRects = [];
    const startRects = getSelectionRects(
      firstBlock,
      docFirst.richTextOffset,
      Number.MAX_SAFE_INTEGER,
      overlayContext.editorDocument,
      overlayContext.overlayRect
    );
    if (startRects) {
      allRects.push(...startRects);
    }
    const intermediateBlocks = getBlocksBetween(
      docFirst.localClientId,
      docLast.localClientId,
      overlayContext.editorDocument
    );
    for (const intermediateBlock of intermediateBlocks) {
      const rects = getFullBlockSelectionRects(
        intermediateBlock,
        overlayContext.editorDocument,
        overlayContext.overlayRect
      );
      allRects.push(...rects);
    }
    const endRects = getSelectionRects(
      lastBlock,
      0,
      docLast.richTextOffset,
      overlayContext.editorDocument,
      overlayContext.overlayRect
    );
    if (endRects) {
      allRects.push(...endRects);
    }
    return {
      rects: allRects,
      firstBlock,
      lastBlock,
      firstBlockClientId: docFirst.localClientId
    };
  }

  // packages/editor/build-module/components/collaborators-overlay/use-render-cursors.mjs
  var { useActiveCollaborators: useActiveCollaborators2, useResolvedSelection: useResolvedSelection2 } = unlock(import_core_data112.privateApis);
  function useRenderCursors(overlayElement, blockEditorDocument, postId2, postType2, delayMs) {
    const sortedUsers = useActiveCollaborators2(
      postId2 ?? null,
      postType2 ?? null
    );
    const resolveSelection = useResolvedSelection2(
      postId2 ?? null,
      postType2 ?? null
    );
    const showOwnCursor = (0, import_data199.useSelect)(
      (select7) => select7(import_preferences20.store).get("core", "showCollaborationCursor"),
      []
    );
    const [cursorPositions, setCursorPositions] = (0, import_element254.useState)(
      []
    );
    const [recomputeToken, rerenderCursorsAfterDelay] = useDebouncedRecompute(delayMs);
    (0, import_element254.useEffect)(() => {
      if (!overlayElement || !blockEditorDocument) {
        setCursorPositions([]);
        return;
      }
      const overlayRect = overlayElement.getBoundingClientRect();
      const overlayContext = {
        editorDocument: blockEditorDocument,
        overlayRect
      };
      const results = [];
      const hasOtherCollaborators = sortedUsers.some(
        (u3) => !u3.isMe
      );
      sortedUsers.forEach((user) => {
        if (user.isMe && (!showOwnCursor || !hasOtherCollaborators)) {
          return;
        }
        const selection = user.editorState?.selection ?? {
          type: import_core_data112.SelectionType.None
        };
        let start2 = {
          richTextOffset: null,
          localClientId: null
        };
        let end;
        if (selection.type === import_core_data112.SelectionType.Cursor) {
          try {
            start2 = resolveSelection(selection);
          } catch {
            return;
          }
        } else if (selection.type === import_core_data112.SelectionType.SelectionInOneBlock || selection.type === import_core_data112.SelectionType.SelectionInMultipleBlocks) {
          try {
            start2 = resolveSelection({
              type: import_core_data112.SelectionType.Cursor,
              cursorPosition: selection.cursorStartPosition
            });
            end = resolveSelection({
              type: import_core_data112.SelectionType.Cursor,
              cursorPosition: selection.cursorEndPosition
            });
          } catch {
            return;
          }
        }
        const userName = user.collaboratorInfo.name;
        const clientId = user.clientId;
        const color = user.isMe ? "var(--wp-admin-theme-color)" : getAvatarBorderColor(user.collaboratorInfo.id);
        const avatarUrl = getAvatarUrl(user.collaboratorInfo.avatar_urls);
        const selectionVisual = computeSelectionVisual(
          selection,
          start2,
          end,
          overlayContext
        );
        if (selectionVisual.coords) {
          const cursorData = {
            userName,
            clientId,
            color,
            avatarUrl,
            isMe: user.isMe,
            ...selectionVisual.coords
          };
          if (selectionVisual.selectionRects) {
            cursorData.selectionRects = selectionVisual.selectionRects;
          }
          results.push(cursorData);
        }
      });
      setCursorPositions(results);
    }, [
      blockEditorDocument,
      resolveSelection,
      overlayElement,
      sortedUsers,
      showOwnCursor,
      recomputeToken
    ]);
    return { cursors: cursorPositions, rerenderCursorsAfterDelay };
  }

  // packages/editor/build-module/components/collaborators-overlay/overlay.mjs
  var import_jsx_runtime451 = __toESM(require_jsx_runtime(), 1);
  var RERENDER_DELAY_MS = 500;
  var CURSOR_REDRAW_INTERVAL_MS = 1e4;
  function Overlay({
    blockEditorDocument,
    postId: postId2,
    postType: postType2,
    cursorRegistry
  }) {
    const [overlayElement, setOverlayElement] = (0, import_element255.useState)(null);
    const { cursors, rerenderCursorsAfterDelay } = useRenderCursors(
      overlayElement,
      blockEditorDocument ?? null,
      postId2 ?? null,
      postType2 ?? null,
      RERENDER_DELAY_MS
    );
    const { highlights, rerenderHighlightsAfterDelay } = useBlockHighlighting(
      overlayElement,
      blockEditorDocument ?? null,
      postId2 ?? null,
      postType2 ?? null,
      RERENDER_DELAY_MS
    );
    const onResize = (0, import_element255.useCallback)(() => {
      rerenderCursorsAfterDelay();
      rerenderHighlightsAfterDelay();
    }, [rerenderCursorsAfterDelay, rerenderHighlightsAfterDelay]);
    const resizeObserverRef = (0, import_compose64.useResizeObserver)(onResize);
    (0, import_element255.useEffect)(() => {
      const cleanupCursors = rerenderCursorsAfterDelay();
      const cleanupHighlights = rerenderHighlightsAfterDelay();
      return () => {
        cleanupCursors();
        cleanupHighlights();
      };
    }, [rerenderCursorsAfterDelay, rerenderHighlightsAfterDelay]);
    (0, import_element255.useEffect)(() => {
      if (cursors.length === 0) {
        return;
      }
      return setDelayedInterval(
        rerenderCursorsAfterDelay,
        CURSOR_REDRAW_INTERVAL_MS
      );
    }, [cursors.length, rerenderCursorsAfterDelay]);
    const mergedRef = (0, import_compose64.useMergeRefs)([
      setOverlayElement,
      resizeObserverRef
    ]);
    const cursorRefsMap = (0, import_element255.useRef)(/* @__PURE__ */ new Map());
    (0, import_element255.useEffect)(() => {
      if (!cursorRegistry) {
        return;
      }
      const refs = cursorRefsMap.current;
      const currentIds = new Set(cursors.map((c6) => c6.clientId));
      for (const id of refs.keys()) {
        if (!currentIds.has(id)) {
          cursorRegistry.unregisterCursor(id);
          refs.delete(id);
        }
      }
      for (const [id, el] of refs.entries()) {
        cursorRegistry.registerCursor(id, el);
      }
      return () => cursorRegistry.removeAll();
    }, [cursors, cursorRegistry]);
    const setCursorRef = (0, import_element255.useCallback)(
      (clientId) => (el) => {
        if (el) {
          cursorRefsMap.current.set(clientId, el);
        } else {
          cursorRefsMap.current.delete(clientId);
        }
      },
      []
    );
    return /* @__PURE__ */ (0, import_jsx_runtime451.jsxs)("div", { className: "collaborators-overlay-full", ref: mergedRef, children: [
      /* @__PURE__ */ (0, import_jsx_runtime451.jsx)("style", { children: AVATAR_IFRAME_STYLES + OVERLAY_IFRAME_STYLES }),
      cursors.map((cursor) => /* @__PURE__ */ (0, import_jsx_runtime451.jsxs)("div", { children: [
        !cursor.isMe && cursor.selectionRects?.map((rect, index) => /* @__PURE__ */ (0, import_jsx_runtime451.jsx)(
          "div",
          {
            className: "collaborators-overlay-selection-rect",
            style: {
              left: `${rect.x}px`,
              top: `${rect.y}px`,
              width: `${rect.width}px`,
              height: `${rect.height}px`,
              backgroundColor: cursor.color
            }
          },
          `${cursor.clientId}-sel-${index}`
        )),
        /* @__PURE__ */ (0, import_jsx_runtime451.jsxs)(
          "div",
          {
            ref: setCursorRef(cursor.clientId),
            className: "collaborators-overlay-user",
            style: {
              left: `${cursor.x}px`,
              top: `${cursor.y}px`
            },
            children: [
              !cursor.isMe && /* @__PURE__ */ (0, import_jsx_runtime451.jsx)(
                "div",
                {
                  className: "collaborators-overlay-user-cursor",
                  style: {
                    backgroundColor: cursor.color,
                    height: `${cursor.height}px`
                  }
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime451.jsx)(
                component_default,
                {
                  className: "collaborators-overlay-user-label",
                  variant: "badge",
                  size: "small",
                  src: cursor.avatarUrl,
                  name: cursor.userName,
                  label: cursor.isMe ? (0, import_i18n274.__)("You") : void 0,
                  borderColor: cursor.color
                }
              )
            ]
          }
        )
      ] }, cursor.clientId)),
      highlights.map((highlight) => /* @__PURE__ */ (0, import_jsx_runtime451.jsx)(
        component_default,
        {
          className: "collaborators-overlay-block-label",
          variant: "badge",
          size: "small",
          src: highlight.avatarUrl,
          name: highlight.userName,
          borderColor: highlight.color,
          style: {
            left: `${highlight.x}px`,
            top: `${highlight.y}px`
          }
        },
        highlight.blockId
      ))
    ] });
  }

  // packages/editor/build-module/components/collaborators-overlay/index.mjs
  var import_jsx_runtime452 = __toESM(require_jsx_runtime(), 1);
  var { BlockCanvasCover } = unlock(import_block_editor73.privateApis);
  function CollaboratorsOverlay({
    postId: postId2,
    postType: postType2,
    cursorRegistry
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime452.jsx)(BlockCanvasCover.Fill, { children: ({
      containerRef
    }) => /* @__PURE__ */ (0, import_jsx_runtime452.jsx)(
      Overlay,
      {
        blockEditorDocument: containerRef.current?.ownerDocument,
        postId: postId2,
        postType: postType2,
        cursorRegistry
      }
    ) });
  }

  // packages/editor/build-module/components/collaborators-presence/index.mjs
  var import_jsx_runtime453 = __toESM(require_jsx_runtime(), 1);
  if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='9907eeab15']")) {
    const style = document.createElement("style");
    style.setAttribute("data-wp-hash", "9907eeab15");
    style.appendChild(document.createTextNode(".editor-collaborators-presence{align-items:center;background:#f0f0f0;border-radius:4px;display:flex;flex-shrink:0;height:32px;margin-right:8px}.editor-collaborators-presence:has(.is-pressed),.editor-collaborators-presence:hover{background-color:#e0e0e0}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button{align-items:center;background:#0000;border-radius:4px;box-sizing:border-box;color:#2f2f2f;cursor:var(--wpds-cursor-control,pointer);display:flex;height:100%;padding:4px;position:relative}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed:hover,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:hover{background:#0000;color:#2f2f2f}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:focus:not(:active){box-shadow:inset 0 0 0 var(--wp-admin-border-width-focus,2px) var(--wp-admin-theme-color,#007cba);outline:none}"));
    document.head.appendChild(style);
  }
  var { useActiveCollaborators: useActiveCollaborators3 } = unlock(import_core_data113.privateApis);
  function CollaboratorsPresence({
    postId: postId2,
    postType: postType2
  }) {
    const activeCollaborators = useActiveCollaborators3(
      postId2,
      postType2
    );
    const otherActiveCollaborators = activeCollaborators.filter(
      (c6) => !c6.isMe
    );
    const collaboratorsForList = (0, import_element256.useMemo)(() => {
      return [...activeCollaborators].sort((a3, b3) => {
        if (a3.isMe && !b3.isMe) {
          return -1;
        }
        if (!a3.isMe && b3.isMe) {
          return 1;
        }
        return 0;
      });
    }, [activeCollaborators]);
    const [cursorRegistry] = (0, import_element256.useState)(createCursorRegistry);
    const [isPopoverVisible, setIsPopoverVisible] = (0, import_element256.useState)(false);
    const [popoverAnchor, setPopoverAnchor] = (0, import_element256.useState)(
      null
    );
    if (otherActiveCollaborators.length === 0) {
      return null;
    }
    const me = activeCollaborators.find((c6) => c6.isMe);
    return /* @__PURE__ */ (0, import_jsx_runtime453.jsxs)(import_jsx_runtime453.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime453.jsxs)("div", { className: "editor-collaborators-presence", children: [
        /* @__PURE__ */ (0, import_jsx_runtime453.jsx)(
          import_components246.Button,
          {
            __next40pxDefaultSize: true,
            className: "editor-collaborators-presence__button",
            onClick: () => setIsPopoverVisible(!isPopoverVisible),
            isPressed: isPopoverVisible,
            ref: setPopoverAnchor,
            "aria-label": (0, import_i18n275.sprintf)(
              // translators: %d: number of online collaborators.
              (0, import_i18n275.__)("Collaborators list, %d online"),
              collaboratorsForList.length
            ),
            children: /* @__PURE__ */ (0, import_jsx_runtime453.jsxs)(component_default2, { max: 4, children: [
              me && /* @__PURE__ */ (0, import_jsx_runtime453.jsx)(
                component_default,
                {
                  src: getAvatarUrl(
                    me.collaboratorInfo.avatar_urls
                  ),
                  name: me.collaboratorInfo.name,
                  borderColor: "var(--wp-admin-theme-color)",
                  size: "small"
                },
                me.clientId
              ),
              otherActiveCollaborators.map(
                (collaboratorState) => /* @__PURE__ */ (0, import_jsx_runtime453.jsx)(
                  component_default,
                  {
                    src: getAvatarUrl(
                      collaboratorState.collaboratorInfo.avatar_urls
                    ),
                    name: collaboratorState.collaboratorInfo.name,
                    borderColor: getAvatarBorderColor(
                      collaboratorState.collaboratorInfo.id
                    ),
                    size: "small"
                  },
                  collaboratorState.clientId
                )
              )
            ] })
          }
        ),
        isPopoverVisible && /* @__PURE__ */ (0, import_jsx_runtime453.jsx)(
          CollaboratorsList,
          {
            activeCollaborators: collaboratorsForList,
            popoverAnchor,
            setIsPopoverVisible,
            cursorRegistry
          }
        )
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime453.jsx)(
        CollaboratorsOverlay,
        {
          postId: postId2,
          postType: postType2,
          cursorRegistry
        }
      )
    ] });
  }

  // packages/editor/build-module/components/header/index.mjs
  var import_jsx_runtime454 = __toESM(require_jsx_runtime(), 1);
  function Header5({
    customSaveButton,
    forceIsDirty,
    setEntitiesSavedStatesCallback
  }) {
    const isWideViewport = (0, import_compose65.useViewportMatch)("large");
    const isLargeViewport = (0, import_compose65.useViewportMatch)("medium");
    const isTooNarrowForDocumentBar = (0, import_compose65.useMediaQuery)("(max-width: 403px)");
    const {
      postId: postId2,
      postType: postType2,
      isTextEditor,
      isPublishSidebarOpened: isPublishSidebarOpened2,
      showIconLabels,
      hasFixedToolbar,
      hasBlockSelection,
      hasSectionRootClientId,
      isStylesCanvasActive,
      isAttachment
    } = (0, import_data200.useSelect)((select7) => {
      const { get: getPreference } = select7(import_preferences21.store);
      const {
        getEditorMode: getEditorMode2,
        getCurrentPostType: getCurrentPostType2,
        getCurrentPostId: getCurrentPostId2,
        isPublishSidebarOpened: _isPublishSidebarOpened
      } = select7(store3);
      const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock(
        select7(store3)
      );
      const { getBlockSelectionStart: getBlockSelectionStart2, getSectionRootClientId } = unlock(
        select7(import_block_editor74.store)
      );
      return {
        postId: getCurrentPostId2(),
        postType: getCurrentPostType2(),
        isTextEditor: getEditorMode2() === "text",
        isPublishSidebarOpened: _isPublishSidebarOpened(),
        showIconLabels: getPreference("core", "showIconLabels"),
        hasFixedToolbar: getPreference("core", "fixedToolbar"),
        hasBlockSelection: !!getBlockSelectionStart2(),
        hasSectionRootClientId: !!getSectionRootClientId(),
        isStylesCanvasActive: !!getStylesPath2()?.startsWith("/revisions") || getShowStylebook2(),
        isAttachment: getCurrentPostType2() === ATTACHMENT_POST_TYPE && window?.__experimentalMediaEditor
      };
    }, []);
    const canBeZoomedOut = ["post", "page", "wp_template"].includes(postType2) && hasSectionRootClientId;
    const disablePreviewOption = [
      ATTACHMENT_POST_TYPE,
      NAVIGATION_POST_TYPE,
      TEMPLATE_PART_POST_TYPE,
      PATTERN_POST_TYPE
    ].includes(postType2) || isStylesCanvasActive;
    const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0, import_element257.useState)(true);
    const hasCenter = !isTooNarrowForDocumentBar && (!hasFixedToolbar || hasFixedToolbar && (!hasBlockSelection || isBlockToolsCollapsed));
    return /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(
      HeaderSkeleton,
      {
        toolbar: /* @__PURE__ */ (0, import_jsx_runtime454.jsxs)(import_jsx_runtime454.Fragment, { children: [
          !isAttachment && /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(
            document_tools_default,
            {
              disableBlockTools: isStylesCanvasActive || isTextEditor
            }
          ),
          hasFixedToolbar && isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(
            CollapsibleBlockToolbar,
            {
              isCollapsed: isBlockToolsCollapsed,
              onToggle: setIsBlockToolsCollapsed
            }
          )
        ] }),
        center: hasCenter ? /* @__PURE__ */ (0, import_jsx_runtime454.jsxs)(import_jsx_runtime454.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(
            CollaboratorsPresence,
            {
              postType: postType2,
              postId: postId2
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(DocumentBar, {})
        ] }) : void 0,
        settings: /* @__PURE__ */ (0, import_jsx_runtime454.jsxs)(import_jsx_runtime454.Fragment, { children: [
          !customSaveButton && !isPublishSidebarOpened2 && /*
          * This button isn't completely hidden by the publish sidebar.
          * We can't hide the whole toolbar when the publish sidebar is open because
          * we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
          * We track that DOM node to return focus to the PostPublishButtonOrToggle
          * when the publish sidebar has been closed.
          */
          /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(PostSavedState, { forceIsDirty }),
          /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(PostViewLink, {}),
          /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(
            PreviewDropdown,
            {
              forceIsAutosaveable: forceIsDirty,
              disabled: disablePreviewOption
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(
            PostPreviewButton,
            {
              className: "editor-header__post-preview-button",
              forceIsAutosaveable: forceIsDirty
            }
          ),
          isWideViewport && canBeZoomedOut && /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(zoom_out_toggle_default, { disabled: isStylesCanvasActive }),
          (isWideViewport || !showIconLabels) && /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(pinned_items_default.Slot, { scope: "core" }),
          !customSaveButton && /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(
            PostPublishButtonOrToggle,
            {
              forceIsDirty,
              setEntitiesSavedStatesCallback
            }
          ),
          customSaveButton,
          !isAttachment && /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(MoreMenu, {})
        ] })
      }
    );
  }
  var header_default2 = Header5;

  // packages/editor/build-module/components/inserter-sidebar/index.mjs
  var import_data201 = __toESM(require_data(), 1);
  var import_block_editor75 = __toESM(require_block_editor(), 1);
  var import_compose66 = __toESM(require_compose(), 1);
  var import_element258 = __toESM(require_element(), 1);
  var import_preferences22 = __toESM(require_preferences(), 1);
  var import_keycodes17 = __toESM(require_keycodes(), 1);
  var import_jsx_runtime455 = __toESM(require_jsx_runtime(), 1);
  var { PrivateInserterLibrary } = unlock(import_block_editor75.privateApis);
  function InserterSidebar() {
    const {
      blockSectionRootClientId,
      inserterSidebarToggleRef: inserterSidebarToggleRef2,
      inserter,
      showMostUsedBlocks,
      sidebarIsOpened
    } = (0, import_data201.useSelect)((select7) => {
      const {
        getInserterSidebarToggleRef: getInserterSidebarToggleRef2,
        getInserter: getInserter2,
        isPublishSidebarOpened: isPublishSidebarOpened2
      } = unlock(select7(store3));
      const { getBlockRootClientId: getBlockRootClientId2, isZoomOut, getSectionRootClientId } = unlock(select7(import_block_editor75.store));
      const { get } = select7(import_preferences22.store);
      const { getActiveComplementaryArea: getActiveComplementaryArea2 } = select7(store2);
      const getBlockSectionRootClientId = () => {
        if (isZoomOut()) {
          const sectionRootClientId = getSectionRootClientId();
          if (sectionRootClientId) {
            return sectionRootClientId;
          }
        }
        return getBlockRootClientId2();
      };
      return {
        inserterSidebarToggleRef: getInserterSidebarToggleRef2(),
        inserter: getInserter2(),
        showMostUsedBlocks: get("core", "mostUsedBlocks"),
        blockSectionRootClientId: getBlockSectionRootClientId(),
        sidebarIsOpened: !!(getActiveComplementaryArea2("core") || isPublishSidebarOpened2())
      };
    }, []);
    const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data201.useDispatch)(store3);
    const { disableComplementaryArea: disableComplementaryArea2 } = (0, import_data201.useDispatch)(store2);
    const isMobileViewport = (0, import_compose66.useViewportMatch)("medium", "<");
    const libraryRef = (0, import_element258.useRef)();
    const closeInserterSidebar = (0, import_element258.useCallback)(() => {
      setIsInserterOpened2(false);
      inserterSidebarToggleRef2.current?.focus();
    }, [inserterSidebarToggleRef2, setIsInserterOpened2]);
    const closeOnEscape = (0, import_element258.useCallback)(
      (event) => {
        if (event.keyCode === import_keycodes17.ESCAPE && !event.defaultPrevented) {
          event.preventDefault();
          closeInserterSidebar();
        }
      },
      [closeInserterSidebar]
    );
    const inserterContents = /* @__PURE__ */ (0, import_jsx_runtime455.jsx)("div", { className: "editor-inserter-sidebar__content", children: /* @__PURE__ */ (0, import_jsx_runtime455.jsx)(
      PrivateInserterLibrary,
      {
        showMostUsedBlocks,
        showInserterHelpPanel: true,
        shouldFocusBlock: isMobileViewport,
        rootClientId: blockSectionRootClientId ?? inserter.rootClientId,
        __experimentalInsertionIndex: inserter.insertionIndex,
        onSelect: inserter.onSelect,
        __experimentalInitialTab: inserter.tab,
        __experimentalInitialCategory: inserter.category,
        __experimentalFilterValue: inserter.filterValue,
        onPatternCategorySelection: sidebarIsOpened ? () => disableComplementaryArea2("core") : void 0,
        ref: libraryRef,
        onClose: closeInserterSidebar
      }
    ) });
    return (
      // eslint-disable-next-line jsx-a11y/no-static-element-interactions
      /* @__PURE__ */ (0, import_jsx_runtime455.jsx)("div", { onKeyDown: closeOnEscape, className: "editor-inserter-sidebar", children: inserterContents })
    );
  }

  // packages/editor/build-module/components/list-view-sidebar/index.mjs
  var import_block_editor76 = __toESM(require_block_editor(), 1);
  var import_compose67 = __toESM(require_compose(), 1);
  var import_data202 = __toESM(require_data(), 1);
  var import_dom13 = __toESM(require_dom(), 1);
  var import_element259 = __toESM(require_element(), 1);
  var import_i18n277 = __toESM(require_i18n(), 1);
  var import_keyboard_shortcuts8 = __toESM(require_keyboard_shortcuts(), 1);
  var import_keycodes18 = __toESM(require_keycodes(), 1);

  // packages/editor/build-module/components/list-view-sidebar/list-view-outline.mjs
  var import_components247 = __toESM(require_components(), 1);
  var import_i18n276 = __toESM(require_i18n(), 1);
  var import_jsx_runtime456 = __toESM(require_jsx_runtime(), 1);
  function ListViewOutline() {
    return /* @__PURE__ */ (0, import_jsx_runtime456.jsxs)(import_jsx_runtime456.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime456.jsxs)("div", { className: "editor-list-view-sidebar__outline", children: [
        /* @__PURE__ */ (0, import_jsx_runtime456.jsxs)("div", { children: [
          /* @__PURE__ */ (0, import_jsx_runtime456.jsx)(import_components247.__experimentalText, { children: (0, import_i18n276.__)("Characters:") }),
          /* @__PURE__ */ (0, import_jsx_runtime456.jsx)(import_components247.__experimentalText, { children: /* @__PURE__ */ (0, import_jsx_runtime456.jsx)(CharacterCount, {}) })
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime456.jsxs)("div", { children: [
          /* @__PURE__ */ (0, import_jsx_runtime456.jsx)(import_components247.__experimentalText, { children: (0, import_i18n276.__)("Words:") }),
          /* @__PURE__ */ (0, import_jsx_runtime456.jsx)(WordCount, {})
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime456.jsxs)("div", { children: [
          /* @__PURE__ */ (0, import_jsx_runtime456.jsx)(import_components247.__experimentalText, { children: (0, import_i18n276.__)("Time to read:") }),
          /* @__PURE__ */ (0, import_jsx_runtime456.jsx)(TimeToRead, {})
        ] })
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime456.jsx)(DocumentOutline, {})
    ] });
  }

  // packages/editor/build-module/components/list-view-sidebar/index.mjs
  var import_jsx_runtime457 = __toESM(require_jsx_runtime(), 1);
  var { TabbedSidebar } = unlock(import_block_editor76.privateApis);
  function ListViewSidebar() {
    const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data202.useDispatch)(store3);
    const { getListViewToggleRef: getListViewToggleRef2 } = unlock((0, import_data202.useSelect)(store3));
    const focusOnMountRef = (0, import_compose67.useFocusOnMount)("firstElement");
    const closeListView = (0, import_element259.useCallback)(() => {
      setIsListViewOpened2(false);
      getListViewToggleRef2().current?.focus();
    }, [getListViewToggleRef2, setIsListViewOpened2]);
    const closeOnEscape = (0, import_element259.useCallback)(
      (event) => {
        if (event.keyCode === import_keycodes18.ESCAPE && !event.defaultPrevented) {
          event.preventDefault();
          closeListView();
        }
      },
      [closeListView]
    );
    const [dropZoneElement, setDropZoneElement] = (0, import_element259.useState)(null);
    const [tab, setTab] = (0, import_element259.useState)("list-view");
    const sidebarRef = (0, import_element259.useRef)();
    const tabsRef = (0, import_element259.useRef)();
    const listViewRef = (0, import_element259.useRef)();
    const listViewContainerRef = (0, import_compose67.useMergeRefs)([
      focusOnMountRef,
      listViewRef,
      setDropZoneElement
    ]);
    function handleSidebarFocus(currentTab) {
      const tabPanelFocus = import_dom13.focus.tabbable.find(tabsRef.current)[0];
      if (currentTab === "list-view") {
        const listViewApplicationFocus = import_dom13.focus.tabbable.find(
          listViewRef.current
        )[0];
        const listViewFocusArea = sidebarRef.current.contains(
          listViewApplicationFocus
        ) ? listViewApplicationFocus : tabPanelFocus;
        listViewFocusArea.focus();
      } else {
        tabPanelFocus.focus();
      }
    }
    const handleToggleListViewShortcut = (0, import_element259.useCallback)(() => {
      if (sidebarRef.current.contains(
        sidebarRef.current.ownerDocument.activeElement
      )) {
        closeListView();
      } else {
        handleSidebarFocus(tab);
      }
    }, [closeListView, tab]);
    (0, import_keyboard_shortcuts8.useShortcut)("core/editor/toggle-list-view", handleToggleListViewShortcut);
    return (
      // eslint-disable-next-line jsx-a11y/no-static-element-interactions
      /* @__PURE__ */ (0, import_jsx_runtime457.jsx)(
        "div",
        {
          className: "editor-list-view-sidebar",
          onKeyDown: closeOnEscape,
          ref: sidebarRef,
          children: /* @__PURE__ */ (0, import_jsx_runtime457.jsx)(
            TabbedSidebar,
            {
              tabs: [
                {
                  name: "list-view",
                  title: (0, import_i18n277._x)("List View", "Post overview"),
                  panel: /* @__PURE__ */ (0, import_jsx_runtime457.jsx)("div", { className: "editor-list-view-sidebar__list-view-container", children: /* @__PURE__ */ (0, import_jsx_runtime457.jsx)("div", { className: "editor-list-view-sidebar__list-view-panel-content", children: /* @__PURE__ */ (0, import_jsx_runtime457.jsx)(
                    import_block_editor76.__experimentalListView,
                    {
                      dropZoneElement
                    }
                  ) }) }),
                  panelRef: listViewContainerRef
                },
                {
                  name: "outline",
                  title: (0, import_i18n277._x)("Outline", "Post overview"),
                  panel: /* @__PURE__ */ (0, import_jsx_runtime457.jsx)("div", { className: "editor-list-view-sidebar__list-view-container", children: /* @__PURE__ */ (0, import_jsx_runtime457.jsx)(ListViewOutline, {}) })
                }
              ],
              onClose: closeListView,
              onSelect: (tabName) => setTab(tabName),
              defaultTabId: "list-view",
              ref: tabsRef,
              closeButtonLabel: (0, import_i18n277.__)("Close")
            }
          )
        }
      )
    );
  }

  // packages/editor/build-module/components/post-revisions-preview/revisions-header.mjs
  var import_data204 = __toESM(require_data(), 1);
  var import_components249 = __toESM(require_components(), 1);
  var import_i18n279 = __toESM(require_i18n(), 1);

  // packages/editor/build-module/components/post-revisions-preview/revisions-slider.mjs
  var import_data203 = __toESM(require_data(), 1);
  var import_components248 = __toESM(require_components(), 1);
  var import_core_data114 = __toESM(require_core_data(), 1);
  var import_i18n278 = __toESM(require_i18n(), 1);
  var import_date19 = __toESM(require_date(), 1);
  var import_jsx_runtime458 = __toESM(require_jsx_runtime(), 1);
  function RevisionsSlider() {
    const { revisions, isLoading, currentRevisionId, revisionKey } = (0, import_data203.useSelect)(
      (select7) => {
        const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
        const { getRevisions, isResolving, getEntityConfig } = select7(import_core_data114.store);
        const postId2 = getCurrentPostId2();
        const postType2 = getCurrentPostType2();
        if (!postId2 || !postType2) {
          return {};
        }
        const entityConfig = getEntityConfig("postType", postType2);
        const _revisionKey = entityConfig?.revisionKey || "id";
        const query = {
          per_page: -1,
          context: "edit",
          orderby: "date",
          order: "asc",
          _fields: [
            .../* @__PURE__ */ new Set([
              "id",
              "date",
              "modified",
              "author",
              "meta",
              "title.raw",
              "excerpt.raw",
              "content.raw",
              _revisionKey
            ])
          ].join()
        };
        return {
          revisions: getRevisions("postType", postType2, postId2, query),
          isLoading: isResolving("getRevisions", [
            "postType",
            postType2,
            postId2,
            query
          ]),
          currentRevisionId: unlock(
            select7(store3)
          ).getCurrentRevisionId(),
          revisionKey: _revisionKey
        };
      },
      []
    );
    const { setCurrentRevisionId: setCurrentRevisionId2 } = unlock((0, import_data203.useDispatch)(store3));
    const selectedIndex = revisions?.findIndex(
      (r4) => r4[revisionKey] === currentRevisionId
    );
    const handleSliderChange = (index) => {
      const revision = revisions?.[index];
      if (revision) {
        setCurrentRevisionId2(revision[revisionKey]);
      }
    };
    const dateSettings = (0, import_date19.getSettings)();
    const renderTooltipContent = (index) => {
      const revision = revisions?.[index];
      if (!revision) {
        return index;
      }
      return (0, import_date19.dateI18n)(dateSettings.formats.datetime, revision.date);
    };
    if (isLoading) {
      return /* @__PURE__ */ (0, import_jsx_runtime458.jsx)(import_components248.Spinner, {});
    }
    if (!revisions?.length) {
      return /* @__PURE__ */ (0, import_jsx_runtime458.jsx)("span", { className: "editor-revisions-header__no-revisions", children: (0, import_i18n278.__)("No revisions found.") });
    }
    if (revisions?.length === 1) {
      return /* @__PURE__ */ (0, import_jsx_runtime458.jsx)("span", { className: "editor-revisions-header__no-revisions", children: (0, import_i18n278.__)("Only one revision found.") });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime458.jsx)(
      import_components248.RangeControl,
      {
        __next40pxDefaultSize: true,
        "aria-valuetext": renderTooltipContent(selectedIndex),
        className: "editor-revisions-header__slider",
        hideLabelFromVision: true,
        label: (0, import_i18n278.__)("Revision"),
        max: revisions?.length - 1,
        min: 0,
        marks: true,
        onChange: handleSliderChange,
        renderTooltipContent,
        value: selectedIndex,
        withInputField: false
      }
    );
  }
  var revisions_slider_default = RevisionsSlider;

  // packages/editor/build-module/components/sidebar/constants.mjs
  var sidebars = {
    document: "edit-post/document",
    block: "edit-post/block"
  };

  // packages/editor/build-module/components/post-revisions-preview/revisions-header.mjs
  var import_jsx_runtime459 = __toESM(require_jsx_runtime(), 1);
  function RevisionsHeader({ showDiff, onToggleDiff }) {
    const { currentRevisionId, sidebarIsOpened } = (0, import_data204.useSelect)((select7) => {
      return {
        currentRevisionId: unlock(
          select7(store3)
        ).getCurrentRevisionId(),
        sidebarIsOpened: !!select7(store2).getActiveComplementaryArea(
          "core"
        )
      };
    }, []);
    const { setCurrentRevisionId: setCurrentRevisionId2, restoreRevision: restoreRevision2 } = unlock(
      (0, import_data204.useDispatch)(store3)
    );
    const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data204.useDispatch)(store2);
    const canRestore = !!currentRevisionId;
    const handleRestore = () => {
      if (currentRevisionId) {
        restoreRevision2(currentRevisionId);
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime459.jsx)(
      HeaderSkeleton,
      {
        className: "editor-revisions-header",
        toolbar: /* @__PURE__ */ (0, import_jsx_runtime459.jsx)(
          import_components249.Button,
          {
            __next40pxDefaultSize: true,
            size: "compact",
            icon: seen_default,
            label: (0, import_i18n279._x)("Show changes", "revisions"),
            isPressed: showDiff,
            onClick: onToggleDiff
          }
        ),
        center: /* @__PURE__ */ (0, import_jsx_runtime459.jsx)(revisions_slider_default, {}),
        settings: /* @__PURE__ */ (0, import_jsx_runtime459.jsxs)(import_jsx_runtime459.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime459.jsx)(PostPreviewButton, { className: "editor-header__post-preview-button" }),
          /* @__PURE__ */ (0, import_jsx_runtime459.jsx)(
            import_components249.Button,
            {
              __next40pxDefaultSize: true,
              icon: (0, import_i18n279.isRTL)() ? drawer_left_default : drawer_right_default,
              label: (0, import_i18n279._x)("Settings", "panel button label"),
              isPressed: sidebarIsOpened,
              "aria-expanded": sidebarIsOpened,
              onClick: () => {
                if (sidebarIsOpened) {
                  disableComplementaryArea2("core");
                } else {
                  enableComplementaryArea2(
                    "core",
                    sidebars.document
                  );
                }
              },
              size: "compact"
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime459.jsx)(
            import_components249.Button,
            {
              __next40pxDefaultSize: true,
              variant: "secondary",
              size: "compact",
              onClick: () => setCurrentRevisionId2(null),
              children: (0, import_i18n279.__)("Exit")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime459.jsx)(
            import_components249.Button,
            {
              __next40pxDefaultSize: true,
              accessibleWhenDisabled: true,
              variant: "primary",
              size: "compact",
              className: "editor-revisions-header__restore-button",
              disabled: !canRestore,
              onClick: handleRestore,
              children: (0, import_i18n279.__)("Restore")
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime459.jsx)(MoreMenu, { disabled: true })
        ] })
      }
    );
  }
  var revisions_header_default = RevisionsHeader;

  // packages/editor/build-module/components/post-revisions-preview/revisions-canvas.mjs
  var import_components252 = __toESM(require_components(), 1);
  var import_block_editor84 = __toESM(require_block_editor(), 1);
  var import_data213 = __toESM(require_data(), 1);
  var import_element265 = __toESM(require_element(), 1);
  var import_hooks58 = __toESM(require_hooks(), 1);

  // packages/editor/build-module/components/visual-editor/index.mjs
  var import_block_editor82 = __toESM(require_block_editor(), 1);
  var import_element263 = __toESM(require_element(), 1);
  var import_data211 = __toESM(require_data(), 1);
  var import_blocks32 = __toESM(require_blocks(), 1);
  var import_core_data117 = __toESM(require_core_data(), 1);
  var import_compose73 = __toESM(require_compose(), 1);

  // packages/editor/build-module/components/visual-editor/edit-template-blocks-notification.mjs
  var import_data205 = __toESM(require_data(), 1);
  var import_core_data115 = __toESM(require_core_data(), 1);
  var import_element260 = __toESM(require_element(), 1);
  var import_i18n280 = __toESM(require_i18n(), 1);
  var import_components250 = __toESM(require_components(), 1);
  var import_jsx_runtime460 = __toESM(require_jsx_runtime(), 1);
  function EditTemplateBlocksNotification({ contentRef }) {
    const { onNavigateToEntityRecord, templateId: templateId2 } = (0, import_data205.useSelect)((select7) => {
      const { getEditorSettings: getEditorSettings2, getCurrentTemplateId: getCurrentTemplateId2 } = select7(store3);
      return {
        onNavigateToEntityRecord: getEditorSettings2().onNavigateToEntityRecord,
        templateId: getCurrentTemplateId2()
      };
    }, []);
    const canEditTemplate = (0, import_data205.useSelect)(
      (select7) => !!select7(import_core_data115.store).canUser("create", {
        kind: "postType",
        name: "wp_template"
      }),
      []
    );
    const [isDialogOpen, setIsDialogOpen] = (0, import_element260.useState)(false);
    (0, import_element260.useEffect)(() => {
      const handleDblClick = (event) => {
        if (!canEditTemplate) {
          return;
        }
        if (!event.target.classList.contains("is-root-container") || event.target.dataset?.type === "core/template-part") {
          return;
        }
        if (!event.defaultPrevented) {
          event.preventDefault();
          setIsDialogOpen(true);
        }
      };
      const canvas = contentRef.current;
      canvas?.addEventListener("dblclick", handleDblClick);
      return () => {
        canvas?.removeEventListener("dblclick", handleDblClick);
      };
    }, [contentRef, canEditTemplate]);
    if (!canEditTemplate) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime460.jsx)(
      import_components250.__experimentalConfirmDialog,
      {
        isOpen: isDialogOpen,
        confirmButtonText: (0, import_i18n280.__)("Edit template"),
        onConfirm: () => {
          setIsDialogOpen(false);
          onNavigateToEntityRecord({
            postId: templateId2,
            postType: "wp_template"
          });
        },
        onCancel: () => setIsDialogOpen(false),
        size: "medium",
        children: (0, import_i18n280.__)(
          "You\u2019ve tried to select a block that is part of a template that may be used elsewhere on your site. Would you like to edit the template?"
        )
      }
    );
  }

  // packages/editor/build-module/components/visual-editor/use-select-nearest-editable-block.mjs
  var import_compose68 = __toESM(require_compose(), 1);
  var import_data206 = __toESM(require_data(), 1);
  var import_block_editor77 = __toESM(require_block_editor(), 1);
  var DISTANCE_THRESHOLD = 500;
  function clamp(value, min2, max2) {
    return Math.min(Math.max(value, min2), max2);
  }
  function distanceFromRect(x2, y3, rect) {
    const dx = x2 - clamp(x2, rect.left, rect.right);
    const dy = y3 - clamp(y3, rect.top, rect.bottom);
    return Math.sqrt(dx * dx + dy * dy);
  }
  function useSelectNearestEditableBlock({
    isEnabled = true
  } = {}) {
    const { getEnabledClientIdsTree, getBlockName: getBlockName2, getBlockOrder: getBlockOrder2 } = unlock(
      (0, import_data206.useSelect)(import_block_editor77.store)
    );
    const { selectBlock: selectBlock2 } = (0, import_data206.useDispatch)(import_block_editor77.store);
    return (0, import_compose68.useRefEffect)(
      (element) => {
        if (!isEnabled) {
          return;
        }
        const selectNearestEditableBlock = (x2, y3) => {
          const editableBlockClientIds = getEnabledClientIdsTree().flatMap(({ clientId }) => {
            const blockName = getBlockName2(clientId);
            if (blockName === "core/template-part") {
              return [];
            }
            if (blockName === "core/post-content") {
              const innerBlocks = getBlockOrder2(clientId);
              if (innerBlocks.length) {
                return innerBlocks;
              }
            }
            return [clientId];
          });
          let nearestDistance = Infinity, nearestClientId = null;
          for (const clientId of editableBlockClientIds) {
            const block = element.querySelector(
              `[data-block="${clientId}"]`
            );
            if (!block) {
              continue;
            }
            const rect = block.getBoundingClientRect();
            const distance2 = distanceFromRect(x2, y3, rect);
            if (distance2 < nearestDistance && distance2 < DISTANCE_THRESHOLD) {
              nearestDistance = distance2;
              nearestClientId = clientId;
            }
          }
          if (nearestClientId) {
            selectBlock2(nearestClientId);
          }
        };
        const handleClick = (event) => {
          const shouldSelect = event.target === element || event.target.classList.contains("is-root-container");
          if (shouldSelect) {
            selectNearestEditableBlock(event.clientX, event.clientY);
          }
        };
        element.addEventListener("click", handleClick);
        return () => element.removeEventListener("click", handleClick);
      },
      [isEnabled]
    );
  }

  // packages/editor/build-module/components/visual-editor/use-zoom-out-mode-exit.mjs
  var import_data207 = __toESM(require_data(), 1);
  var import_compose69 = __toESM(require_compose(), 1);
  var import_block_editor78 = __toESM(require_block_editor(), 1);
  function useZoomOutModeExit() {
    const { getSettings: getSettings11, isZoomOut } = unlock((0, import_data207.useSelect)(import_block_editor78.store));
    const { resetZoomLevel } = unlock((0, import_data207.useDispatch)(import_block_editor78.store));
    return (0, import_compose69.useRefEffect)(
      (node) => {
        function onDoubleClick(event) {
          if (!isZoomOut()) {
            return;
          }
          if (!event.defaultPrevented) {
            event.preventDefault();
            const { __experimentalSetIsInserterOpened } = getSettings11();
            if (typeof __experimentalSetIsInserterOpened === "function") {
              __experimentalSetIsInserterOpened(false);
            }
            resetZoomLevel();
          }
        }
        node.addEventListener("dblclick", onDoubleClick);
        return () => {
          node.removeEventListener("dblclick", onDoubleClick);
        };
      },
      [getSettings11, isZoomOut, resetZoomLevel]
    );
  }

  // packages/editor/build-module/components/visual-editor/use-padding-appender.mjs
  var import_data208 = __toESM(require_data(), 1);
  var import_compose70 = __toESM(require_compose(), 1);
  var import_block_editor79 = __toESM(require_block_editor(), 1);
  var import_blocks30 = __toESM(require_blocks(), 1);
  var CSS2 = ':root :where(.editor-styles-wrapper)::after {content: ""; display: block; height: 40vh;}';
  function usePaddingAppender(enabled) {
    const registry = (0, import_data208.useRegistry)();
    const effect = (0, import_compose70.useRefEffect)(
      (node) => {
        function onMouseDown(event) {
          if (event.target !== node && // Tests for the parent element because in the iframed editor if the click is
          // below the padding the target will be the parent element (html) and should
          // still be treated as intent to append.
          event.target !== node.parentElement) {
            return;
          }
          const lastChild = node.lastElementChild;
          if (!lastChild) {
            return;
          }
          const lastChildRect = lastChild.getBoundingClientRect();
          if (event.clientY < lastChildRect.bottom) {
            return;
          }
          event.preventDefault();
          const blockOrder = registry.select(import_block_editor79.store).getBlockOrder("");
          const lastBlockClientId = blockOrder[blockOrder.length - 1];
          const lastBlock = registry.select(import_block_editor79.store).getBlock(lastBlockClientId);
          const { selectBlock: selectBlock2, insertDefaultBlock: insertDefaultBlock2 } = registry.dispatch(import_block_editor79.store);
          if (lastBlock && (0, import_blocks30.isUnmodifiedDefaultBlock)(lastBlock)) {
            selectBlock2(lastBlockClientId);
          } else {
            insertDefaultBlock2();
          }
        }
        const { ownerDocument } = node;
        ownerDocument.addEventListener("pointerdown", onMouseDown);
        return () => {
          ownerDocument.removeEventListener("pointerdown", onMouseDown);
        };
      },
      [registry]
    );
    return enabled ? [effect, CSS2] : [];
  }

  // packages/editor/build-module/components/visual-editor/use-edit-content-only-section-exit.mjs
  var import_data209 = __toESM(require_data(), 1);
  var import_compose71 = __toESM(require_compose(), 1);
  var import_block_editor80 = __toESM(require_block_editor(), 1);
  function useEditContentOnlySectionExit() {
    const { getEditedContentOnlySection } = unlock(
      (0, import_data209.useSelect)(import_block_editor80.store)
    );
    const { stopEditingContentOnlySection } = unlock(
      (0, import_data209.useDispatch)(import_block_editor80.store)
    );
    return (0, import_compose71.useRefEffect)(
      (node) => {
        function onClick(event) {
          const editedContentOnlySection = getEditedContentOnlySection();
          if (!editedContentOnlySection) {
            return;
          }
          const isClickOutside = !event.target.closest(
            `[data-block="${editedContentOnlySection}"]`
          );
          if (isClickOutside && !event.defaultPrevented) {
            event.preventDefault();
            stopEditingContentOnlySection();
          }
        }
        node.addEventListener("click", onClick);
        return () => {
          node.removeEventListener("click", onClick);
        };
      },
      [getEditedContentOnlySection, stopEditingContentOnlySection]
    );
  }

  // packages/editor/build-module/components/sync-connection-error-modal/index.mjs
  var import_data210 = __toESM(require_data(), 1);
  var import_compose72 = __toESM(require_compose(), 1);
  var import_blocks31 = __toESM(require_blocks(), 1);
  var import_core_data116 = __toESM(require_core_data(), 1);
  var import_block_editor81 = __toESM(require_block_editor(), 1);
  var import_components251 = __toESM(require_components(), 1);
  var import_hooks57 = __toESM(require_hooks(), 1);
  var import_element262 = __toESM(require_element(), 1);
  var import_i18n281 = __toESM(require_i18n(), 1);

  // packages/editor/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs
  var import_element261 = __toESM(require_element(), 1);
  function useRetryCountdown(connectionStatus) {
    const [secondsRemaining, setSecondsRemaining] = (0, import_element261.useState)();
    const hasRetriedRef = (0, import_element261.useRef)(false);
    (0, import_element261.useEffect)(() => {
      if (!connectionStatus) {
        return;
      }
      if ("connected" === connectionStatus.status) {
        setSecondsRemaining(void 0);
        hasRetriedRef.current = false;
        return;
      }
      if ("disconnected" !== connectionStatus.status || !connectionStatus.willAutoRetryInMs) {
        return;
      }
      const { willAutoRetryInMs: retryInMs } = connectionStatus;
      const retryAt = Date.now() + retryInMs;
      const hasRetried = hasRetriedRef.current;
      hasRetriedRef.current = true;
      if (hasRetried) {
        setSecondsRemaining(0);
      }
      let countdownIntervalId = null;
      const startCountdown = () => {
        setSecondsRemaining(Math.ceil((retryAt - Date.now()) / 1e3));
        countdownIntervalId = setInterval(() => {
          const remaining = Math.ceil((retryAt - Date.now()) / 1e3);
          setSecondsRemaining(Math.max(0, remaining));
          if (remaining <= 0 && countdownIntervalId) {
            clearInterval(countdownIntervalId);
          }
        }, 1e3);
      };
      const retryingDelayId = hasRetried ? setTimeout(startCountdown, 500) : null;
      if (!retryingDelayId) {
        startCountdown();
      }
      return () => {
        if (retryingDelayId) {
          clearTimeout(retryingDelayId);
        }
        if (countdownIntervalId) {
          clearInterval(countdownIntervalId);
        }
      };
    }, [connectionStatus]);
    return {
      onManualRetry: () => {
        setSecondsRemaining(0);
      },
      secondsRemaining
    };
  }

  // packages/editor/build-module/components/sync-connection-error-modal/index.mjs
  var import_jsx_runtime461 = __toESM(require_jsx_runtime(), 1);
  var { BlockCanvasCover: BlockCanvasCover2 } = unlock(import_block_editor81.privateApis);
  var { retrySyncConnection } = unlock(import_core_data116.privateApis);
  var INITIAL_DISCONNECTED_DEBOUNCE_MS = 2e4;
  function SyncConnectionErrorModal() {
    const [hasInitialized, setHasInitialized] = (0, import_element262.useState)(false);
    const [showModal, setShowModal] = (0, import_element262.useState)(false);
    const [isManualRetryAvailable, setIsManualRetryAvailable] = (0, import_element262.useState)(false);
    const { connectionStatus, isCollaborationEnabled, postType: postType2 } = (0, import_data210.useSelect)(
      (selectFn) => {
        const currentPostType = selectFn(store3).getCurrentPostType();
        return {
          connectionStatus: selectFn(import_core_data116.store).getSyncConnectionStatus() || null,
          isCollaborationEnabled: selectFn(
            store3
          ).isCollaborationEnabledForCurrentPost(),
          postType: currentPostType ? selectFn(import_core_data116.store).getPostType(currentPostType) : null
        };
      },
      []
    );
    const { onManualRetry, secondsRemaining } = useRetryCountdown(connectionStatus);
    const copyButtonRef = (0, import_compose72.useCopyToClipboard)(() => {
      const blocks = (0, import_data210.select)(import_block_editor81.store).getBlocks();
      return (0, import_blocks31.serialize)(blocks);
    });
    (0, import_element262.useEffect)(() => {
      const timeout = setTimeout(() => {
        setHasInitialized(true);
      }, INITIAL_DISCONNECTED_DEBOUNCE_MS);
      return () => clearTimeout(timeout);
    }, []);
    (0, import_element262.useEffect)(() => {
      if ("connecting" === connectionStatus?.status) {
        return;
      }
      setIsManualRetryAvailable(
        connectionStatus !== null && "canManuallyRetry" in connectionStatus && connectionStatus.canManuallyRetry === true
      );
    }, [connectionStatus]);
    const canRetry = connectionStatus && "disconnected" === connectionStatus.status && (connectionStatus.canManuallyRetry || connectionStatus.willAutoRetryInMs);
    (0, import_element262.useEffect)(() => {
      if ("connected" === connectionStatus?.status) {
        setShowModal(false);
        return;
      }
      if (connectionStatus?.status && "connecting" !== connectionStatus.status && (!canRetry || connectionStatus.backgroundRetriesFailed)) {
        setShowModal(true);
      }
    }, [connectionStatus, canRetry]);
    if (!isCollaborationEnabled || !hasInitialized || !showModal) {
      return null;
    }
    const error2 = connectionStatus && "error" in connectionStatus ? connectionStatus?.error : void 0;
    if (!canRetry && (0, import_hooks57.applyFilters)(
      "editor.isSyncConnectionErrorHandled",
      false,
      error2?.code
    ) !== false) {
      return null;
    }
    const manualRetry = isManualRetryAvailable ? () => {
      onManualRetry();
      retrySyncConnection();
    } : void 0;
    const messages = getSyncErrorMessages(error2);
    let retryCountdownText = "";
    let isRetrying = false;
    if (secondsRemaining && secondsRemaining > 0) {
      retryCountdownText = (0, import_i18n281.sprintf)(
        /* translators: %d: number of seconds until retry */
        (0, import_i18n281._n)(
          "Retrying connection in %d second\u2026",
          "Retrying connection in %d seconds\u2026",
          secondsRemaining
        ),
        secondsRemaining
      );
    } else if (0 === secondsRemaining) {
      isRetrying = true;
      retryCountdownText = (0, import_i18n281.__)("Retrying\u2026");
    }
    let editPostHref = "edit.php";
    if (postType2?.slug) {
      editPostHref = `edit.php?post_type=${postType2.slug}`;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime461.jsx)(BlockCanvasCover2.Fill, { children: /* @__PURE__ */ (0, import_jsx_runtime461.jsx)(
      import_components251.Modal,
      {
        overlayClassName: "editor-sync-connection-error-modal",
        isDismissible: false,
        onRequestClose: () => {
        },
        shouldCloseOnClickOutside: false,
        shouldCloseOnEsc: false,
        size: "medium",
        title: messages.title,
        children: /* @__PURE__ */ (0, import_jsx_runtime461.jsxs)(import_components251.__experimentalVStack, { spacing: 6, children: [
          /* @__PURE__ */ (0, import_jsx_runtime461.jsx)("p", { children: messages.description }),
          retryCountdownText && /* @__PURE__ */ (0, import_jsx_runtime461.jsx)("p", { className: "editor-sync-connection-error-modal__retry-countdown", children: retryCountdownText }),
          /* @__PURE__ */ (0, import_jsx_runtime461.jsxs)(import_components251.__experimentalHStack, { justify: "right", children: [
            /* @__PURE__ */ (0, import_jsx_runtime461.jsx)(
              import_components251.Button,
              {
                __next40pxDefaultSize: true,
                href: editPostHref,
                isDestructive: true,
                variant: "tertiary",
                children: (0, import_i18n281.sprintf)(
                  /* translators: %s: Post type name (e.g., "Posts", "Pages"). */
                  (0, import_i18n281.__)("Back to %s"),
                  postType2?.labels?.name ?? (0, import_i18n281.__)("Posts")
                )
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime461.jsx)(
              import_components251.Button,
              {
                __next40pxDefaultSize: true,
                ref: copyButtonRef,
                variant: manualRetry ? "secondary" : "primary",
                children: (0, import_i18n281.__)("Copy Post Content")
              }
            ),
            manualRetry && /* @__PURE__ */ (0, import_jsx_runtime461.jsx)(
              import_components251.Button,
              {
                __next40pxDefaultSize: true,
                accessibleWhenDisabled: true,
                "aria-disabled": isRetrying,
                disabled: isRetrying,
                isBusy: isRetrying,
                variant: "primary",
                onClick: manualRetry,
                children: (0, import_i18n281.__)("Retry")
              }
            )
          ] })
        ] })
      }
    ) });
  }

  // packages/editor/build-module/components/visual-editor/index.mjs
  var import_jsx_runtime462 = __toESM(require_jsx_runtime(), 1);
  var {
    LayoutStyle,
    useLayoutClasses,
    useLayoutStyles,
    ExperimentalBlockCanvas: BlockCanvas,
    useFlashEditableBlocks
  } = unlock(import_block_editor82.privateApis);
  function getPostContentAttributes(blocks) {
    for (let i3 = 0; i3 < blocks.length; i3++) {
      if (blocks[i3].name === "core/post-content") {
        return blocks[i3].attributes;
      }
      if (blocks[i3].innerBlocks.length) {
        const nestedPostContent = getPostContentAttributes(
          blocks[i3].innerBlocks
        );
        if (nestedPostContent) {
          return nestedPostContent;
        }
      }
    }
  }
  function checkForPostContentAtRootLevel(blocks) {
    for (let i3 = 0; i3 < blocks.length; i3++) {
      if (blocks[i3].name === "core/post-content") {
        return true;
      }
    }
    return false;
  }
  function VisualEditor({
    // Ideally as we unify post and site editors, we won't need these props.
    autoFocus,
    disableIframe = false,
    iframeProps,
    contentRef,
    className
  }) {
    const isMobileViewport = (0, import_compose73.useViewportMatch)("small", "<");
    const {
      renderingMode: renderingMode2,
      postContentAttributes,
      editedPostTemplate = {},
      wrapperBlockName,
      wrapperUniqueId,
      deviceType: deviceType2,
      isFocusedEntity,
      isDesignPostType,
      postType: postType2,
      isPreview,
      styles
    } = (0, import_data211.useSelect)((select7) => {
      const {
        getCurrentPostId: getCurrentPostId2,
        getCurrentPostType: getCurrentPostType2,
        getCurrentTemplateId: getCurrentTemplateId2,
        getEditorSettings: getEditorSettings2,
        getRenderingMode: getRenderingMode2,
        getDeviceType: getDeviceType2
      } = unlock(select7(store3));
      const { getPostType, getEditedEntityRecord } = select7(import_core_data117.store);
      const postTypeSlug = getCurrentPostType2();
      const _renderingMode = getRenderingMode2();
      let _wrapperBlockName;
      if (postTypeSlug === PATTERN_POST_TYPE) {
        _wrapperBlockName = "core/block";
      } else if (_renderingMode === "post-only") {
        _wrapperBlockName = "core/post-content";
      }
      const editorSettings2 = getEditorSettings2();
      const supportsTemplateMode = editorSettings2.supportsTemplateMode;
      const postTypeObject = getPostType(postTypeSlug);
      const currentTemplateId = getCurrentTemplateId2();
      const template2 = currentTemplateId ? getEditedEntityRecord(
        "postType",
        TEMPLATE_POST_TYPE,
        currentTemplateId
      ) : void 0;
      return {
        renderingMode: _renderingMode,
        postContentAttributes: editorSettings2.postContentAttributes,
        isDesignPostType: DESIGN_POST_TYPES.includes(postTypeSlug),
        // Post template fetch returns a 404 on classic themes, which
        // messes with e2e tests, so check it's a block theme first.
        editedPostTemplate: postTypeObject?.viewable && supportsTemplateMode ? template2 : void 0,
        wrapperBlockName: _wrapperBlockName,
        wrapperUniqueId: getCurrentPostId2(),
        deviceType: getDeviceType2(),
        isFocusedEntity: !!editorSettings2.onNavigateToPreviousEntityRecord,
        postType: postTypeSlug,
        isPreview: editorSettings2.isPreviewMode,
        styles: editorSettings2.styles
      };
    }, []);
    const { isCleanNewPost: isCleanNewPost2 } = (0, import_data211.useSelect)(store3);
    const {
      hasRootPaddingAwareAlignments,
      themeHasDisabledLayoutStyles,
      themeSupportsLayout,
      isZoomedOut
    } = (0, import_data211.useSelect)((select7) => {
      const { getSettings: getSettings11, isZoomOut: _isZoomOut } = unlock(
        select7(import_block_editor82.store)
      );
      const _settings = getSettings11();
      return {
        themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
        themeSupportsLayout: _settings.supportsLayout,
        hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
        isZoomedOut: _isZoomOut()
      };
    }, []);
    const localRef = (0, import_element263.useRef)();
    const deviceStyles = (0, import_block_editor82.__experimentalUseResizeCanvas)(deviceType2);
    const [globalLayoutSettings] = (0, import_block_editor82.useSettings)("layout");
    const fallbackLayout = (0, import_element263.useMemo)(() => {
      if (renderingMode2 !== "post-only" || isDesignPostType) {
        return { type: "default" };
      }
      if (themeSupportsLayout) {
        return { ...globalLayoutSettings, type: "constrained" };
      }
      return { type: "default" };
    }, [
      renderingMode2,
      themeSupportsLayout,
      globalLayoutSettings,
      isDesignPostType
    ]);
    const newestPostContentAttributes = (0, import_element263.useMemo)(() => {
      if (!editedPostTemplate?.content && !editedPostTemplate?.blocks && postContentAttributes) {
        return postContentAttributes;
      }
      if (editedPostTemplate?.blocks) {
        return getPostContentAttributes(editedPostTemplate?.blocks);
      }
      const parseableContent = typeof editedPostTemplate?.content === "string" ? editedPostTemplate?.content : "";
      return getPostContentAttributes((0, import_blocks32.parse)(parseableContent)) || {};
    }, [
      editedPostTemplate?.content,
      editedPostTemplate?.blocks,
      postContentAttributes
    ]);
    const hasPostContentAtRootLevel = (0, import_element263.useMemo)(() => {
      if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
        return false;
      }
      if (editedPostTemplate?.blocks) {
        return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
      }
      const parseableContent = typeof editedPostTemplate?.content === "string" ? editedPostTemplate?.content : "";
      return checkForPostContentAtRootLevel((0, import_blocks32.parse)(parseableContent)) || false;
    }, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
    const { layout = {}, align = "" } = newestPostContentAttributes || {};
    const postContentLayoutClasses = useLayoutClasses(
      newestPostContentAttributes,
      "core/post-content"
    );
    const blockListLayoutClass = clsx_default(
      {
        "is-layout-flow": !themeSupportsLayout
      },
      themeSupportsLayout && postContentLayoutClasses,
      align && `align${align}`
    );
    const postContentLayoutStyles = useLayoutStyles(
      newestPostContentAttributes,
      "core/post-content",
      ".block-editor-block-list__layout.is-root-container"
    );
    const postContentLayout = (0, import_element263.useMemo)(() => {
      return layout && (layout?.type === "constrained" || layout?.inherit || layout?.contentSize || layout?.wideSize) ? { ...globalLayoutSettings, ...layout, type: "constrained" } : { ...globalLayoutSettings, ...layout, type: "default" };
    }, [
      layout?.type,
      layout?.inherit,
      layout?.contentSize,
      layout?.wideSize,
      globalLayoutSettings
    ]);
    const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
    const postEditorLayout = blockListLayout?.type === "default" && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
    const observeTypingRef = (0, import_block_editor82.__unstableUseTypingObserver)();
    const titleRef = (0, import_element263.useRef)();
    (0, import_element263.useEffect)(() => {
      if (!autoFocus || !isCleanNewPost2()) {
        return;
      }
      titleRef?.current?.focus();
    }, [autoFocus, isCleanNewPost2]);
    const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
		.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
		.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
		.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
    const enableResizing = [
      NAVIGATION_POST_TYPE,
      TEMPLATE_PART_POST_TYPE,
      PATTERN_POST_TYPE
    ].includes(postType2) && // Disable in previews / view mode.
    !isPreview && // Disable resizing in mobile viewport.
    !isMobileViewport && // Disable resizing in zoomed-out mode.
    !isZoomedOut;
    const isNavigationPreview = postType2 === NAVIGATION_POST_TYPE && isPreview;
    const [paddingAppenderRef, paddingStyle] = usePaddingAppender(
      !isPreview && renderingMode2 === "post-only" && !isDesignPostType
    );
    const centerContentCSS = `display:flex;align-items:center;justify-content:center;`;
    const iframeStyles = (0, import_element263.useMemo)(() => {
      return [
        ...styles ?? [],
        {
          // Ensures margins of children are contained so that the body background paints behind them.
          // Otherwise, the background of html (when zoomed out) would show there and appear broken. It's
          // important mostly for post-only views yet conceivably an issue in templated views too.
          css: `:where(.block-editor-iframe__body){display:flow-root;}.is-root-container{display:flow-root;${// Some themes will have `min-height: 100vh` for the root container,
          // which isn't a requirement in auto resize mode.
          enableResizing || isNavigationPreview ? "min-height:0!important;" : ""}}
				${paddingStyle ? paddingStyle : ""}
				${enableResizing ? `.block-editor-iframe__html{background:var(--wp-editor-canvas-background);min-height:100vh;${centerContentCSS}}.block-editor-iframe__body{width:100%;}` : ""}${isNavigationPreview ? `.block-editor-iframe__body{${centerContentCSS}padding:var(--wp--style--block-gap,2em);}` : ""}`
          // The CSS for enableResizing centers the body content vertically when resizing is enabled and applies a background
          // color to the iframe HTML element to match the background color of the editor canvas.
          // The CSS for isNavigationPreview centers the body content vertically and horizontally when the navigation is in preview mode.
        }
      ];
    }, [styles, enableResizing, isNavigationPreview, paddingStyle]);
    const typewriterRef = (0, import_block_editor82.__unstableUseTypewriter)();
    contentRef = (0, import_compose73.useMergeRefs)([
      localRef,
      contentRef,
      renderingMode2 === "post-only" ? typewriterRef : null,
      useFlashEditableBlocks({
        isEnabled: renderingMode2 === "template-locked"
      }),
      useSelectNearestEditableBlock({
        isEnabled: renderingMode2 === "template-locked"
      }),
      useZoomOutModeExit(),
      paddingAppenderRef,
      useEditContentOnlySectionExit()
    ]);
    return /* @__PURE__ */ (0, import_jsx_runtime462.jsxs)(
      "div",
      {
        className: clsx_default(
          "editor-visual-editor",
          // this class is here for backward compatibility reasons.
          "edit-post-visual-editor",
          className,
          {
            "has-padding": isFocusedEntity || enableResizing,
            "is-resizable": enableResizing,
            "is-iframed": !disableIframe
          }
        ),
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(SyncConnectionErrorModal, {}),
          /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(resizable_editor_default, { enableResizing, height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime462.jsxs)(
            BlockCanvas,
            {
              shouldIframe: !disableIframe,
              contentRef,
              styles: iframeStyles,
              height: "100%",
              iframeProps: {
                ...iframeProps,
                style: {
                  ...iframeProps?.style,
                  ...deviceStyles
                }
              },
              children: [
                themeSupportsLayout && !themeHasDisabledLayoutStyles && renderingMode2 === "post-only" && !isDesignPostType && /* @__PURE__ */ (0, import_jsx_runtime462.jsxs)(import_jsx_runtime462.Fragment, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(
                    LayoutStyle,
                    {
                      selector: ".editor-visual-editor__post-title-wrapper",
                      layout: fallbackLayout
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(
                    LayoutStyle,
                    {
                      selector: ".block-editor-block-list__layout.is-root-container",
                      layout: postEditorLayout
                    }
                  ),
                  align && /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(LayoutStyle, { css: alignCSS }),
                  postContentLayoutStyles && /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(
                    LayoutStyle,
                    {
                      layout: postContentLayout,
                      css: postContentLayoutStyles
                    }
                  )
                ] }),
                renderingMode2 === "post-only" && !isDesignPostType && /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(
                  "div",
                  {
                    className: clsx_default(
                      "editor-visual-editor__post-title-wrapper",
                      // The following class is only here for backward compatibility
                      // some themes might be using it to style the post title.
                      "edit-post-visual-editor__post-title-wrapper",
                      {
                        "has-global-padding": hasRootPaddingAwareAlignments
                      }
                    ),
                    contentEditable: false,
                    ref: observeTypingRef,
                    style: {
                      // This is using inline styles
                      // so it's applied for both iframed and non iframed editors.
                      marginTop: "4rem"
                    },
                    children: /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(post_title_default, { ref: titleRef })
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime462.jsxs)(
                  import_block_editor82.RecursionProvider,
                  {
                    blockName: wrapperBlockName,
                    uniqueId: wrapperUniqueId,
                    children: [
                      /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(
                        import_block_editor82.BlockList,
                        {
                          className: clsx_default(
                            "is-" + deviceType2.toLowerCase() + "-preview",
                            renderingMode2 !== "post-only" || isDesignPostType ? "wp-site-blocks" : `${blockListLayoutClass} wp-block-post-content`,
                            // Ensure root level blocks receive default/flow blockGap styling rules.
                            {
                              "has-global-padding": renderingMode2 === "post-only" && !isDesignPostType && hasRootPaddingAwareAlignments
                            }
                          ),
                          layout: blockListLayout,
                          dropZoneElement: (
                            // When iframed, pass in the html element of the iframe to
                            // ensure the drop zone extends to the edges of the iframe.
                            disableIframe ? localRef.current : localRef.current?.parentNode
                          ),
                          __unstableDisableDropZone: (
                            // In template preview mode, disable drop zones at the root of the template.
                            renderingMode2 === "template-locked" ? true : false
                          )
                        }
                      ),
                      renderingMode2 === "template-locked" && /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(
                        EditTemplateBlocksNotification,
                        {
                          contentRef: localRef
                        }
                      )
                    ]
                  }
                )
              ]
            }
          ) })
        ]
      }
    );
  }
  var visual_editor_default = VisualEditor;

  // packages/editor/build-module/components/post-revisions-preview/diff-format-types.mjs
  var import_i18n282 = __toESM(require_i18n(), 1);
  var import_rich_text4 = __toESM(require_rich_text(), 1);
  var DIFF_FORMAT_TYPES = [
    {
      name: "revision/diff-removed",
      title: (0, import_i18n282.__)("Removed"),
      tagName: "del",
      className: "revision-diff-removed"
    },
    {
      name: "revision/diff-added",
      title: (0, import_i18n282.__)("Added"),
      tagName: "ins",
      className: "revision-diff-added"
    },
    {
      name: "revision/diff-format-added",
      title: (0, import_i18n282.__)("Format added"),
      tagName: "span",
      className: "revision-diff-format-added"
    },
    {
      name: "revision/diff-format-removed",
      title: (0, import_i18n282.__)("Format removed"),
      tagName: "span",
      className: "revision-diff-format-removed"
    },
    {
      name: "revision/diff-format-changed",
      title: (0, import_i18n282.__)("Format changed"),
      tagName: "span",
      className: "revision-diff-format-changed"
    }
  ];
  function registerDiffFormatTypes() {
    for (const formatType of DIFF_FORMAT_TYPES) {
      (0, import_rich_text4.registerFormatType)(formatType.name, {
        ...formatType,
        attributes: { title: "title" },
        edit: () => null
      });
    }
  }
  function unregisterDiffFormatTypes() {
    for (const formatType of DIFF_FORMAT_TYPES) {
      (0, import_rich_text4.unregisterFormatType)(formatType.name);
    }
  }

  // packages/editor/build-module/components/post-revisions-preview/diff-markers.mjs
  var import_element264 = __toESM(require_element(), 1);
  var import_compose74 = __toESM(require_compose(), 1);
  var import_data212 = __toESM(require_data(), 1);
  var import_block_editor83 = __toESM(require_block_editor(), 1);
  var import_i18n283 = __toESM(require_i18n(), 1);
  var import_jsx_runtime463 = __toESM(require_jsx_runtime(), 1);
  var { useBlockElementRef } = unlock(import_block_editor83.privateApis);
  function collectDiffBlocks(blocks) {
    const result = [];
    for (const block of blocks) {
      if (block.__revisionDiffStatus?.status) {
        result.push({
          clientId: block.clientId,
          status: block.__revisionDiffStatus.status
        });
      }
      if (block.innerBlocks?.length) {
        result.push(...collectDiffBlocks(block.innerBlocks));
      }
    }
    return result;
  }
  var STATUS_LABELS = {
    added: (0, import_i18n283.__)("Go to added block"),
    removed: (0, import_i18n283.__)("Go to removed block"),
    modified: (0, import_i18n283.__)("Go to modified block")
  };
  function calculatePosition(el) {
    if (!el) {
      return null;
    }
    const doc = el.ownerDocument;
    const scrollHeight = doc.documentElement.scrollHeight;
    const rect = el.getBoundingClientRect();
    const scrollTop = doc.documentElement.scrollTop;
    const top = rect.top + scrollTop;
    return {
      top: top / scrollHeight * 100,
      height: rect.height / scrollHeight * 100
    };
  }
  function DiffMarkerButton({ clientId, status, subscribe: subscribe2 }) {
    const blockRef = (0, import_element264.useRef)();
    useBlockElementRef(clientId, blockRef);
    const [position, setPosition] = (0, import_element264.useState)(
      () => calculatePosition(blockRef.current)
    );
    (0, import_element264.useEffect)(() => {
      return subscribe2(() => {
        setPosition(calculatePosition(blockRef.current));
      });
    }, [subscribe2]);
    (0, import_element264.useEffect)(() => {
      setPosition(calculatePosition(blockRef.current));
    }, [status]);
    if (!position) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime463.jsx)(
      "button",
      {
        className: `revision-diff-marker is-${status}`,
        style: {
          top: `${position.top}%`,
          height: `${Math.max(position.height, 0.5)}%`
        },
        onClick: () => blockRef.current?.focus(),
        "aria-label": STATUS_LABELS[status]
      }
    );
  }
  function useDiffMarkers() {
    const [isMounted, setIsMounted] = (0, import_element264.useState)(false);
    const subscribersRef = (0, import_element264.useRef)(/* @__PURE__ */ new Set());
    const blocks = (0, import_data212.useSelect)(
      (select7) => select7(import_block_editor83.store).getBlocks(),
      []
    );
    const diffBlocks = (0, import_element264.useMemo)(() => collectDiffBlocks(blocks), [blocks]);
    const subscribe2 = (0, import_element264.useCallback)((callback) => {
      subscribersRef.current.add(callback);
      return () => subscribersRef.current.delete(callback);
    }, []);
    const contentRef = (0, import_compose74.useRefEffect)((element) => {
      const { ownerDocument } = element;
      const { defaultView } = ownerDocument;
      const resizeObserver = new defaultView.ResizeObserver(() => {
        subscribersRef.current.forEach((cb) => cb());
      });
      resizeObserver.observe(ownerDocument.body);
      return () => {
        resizeObserver.disconnect();
      };
    }, []);
    return [
      (0, import_compose74.useMergeRefs)([contentRef, setIsMounted]),
      /* @__PURE__ */ (0, import_jsx_runtime463.jsx)(
        "div",
        {
          className: "revision-diff-markers",
          role: "navigation",
          "aria-label": (0, import_i18n283.__)("Document changes"),
          children: isMounted && diffBlocks.map(({ clientId, status }) => /* @__PURE__ */ (0, import_jsx_runtime463.jsx)(
            DiffMarkerButton,
            {
              clientId,
              status,
              subscribe: subscribe2
            },
            clientId
          ))
        },
        "diff-markers"
      )
    ];
  }

  // packages/editor/build-module/components/post-revisions-preview/revisions-canvas.mjs
  var import_jsx_runtime464 = __toESM(require_jsx_runtime(), 1);
  var { usePrivateStyleOverride } = unlock(import_block_editor84.privateApis);
  var REVISION_REMOVED_FILTER_SVG = `
<svg
	xmlns="http://www.w3.org/2000/svg"
	viewBox="0 0 0 0"
	width="0"
	height="0"
	focusable="false"
	role="none"
	aria-hidden="true"
	style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
>
	<defs>
		<filter id="revision-removed-filter" x="0" y="0" width="100%" height="100%">
			<!-- Desaturate and add red tint -->
			<feColorMatrix type="matrix"
				values="0.5 0.3 0.2 0 0.15
				        0.2 0.2 0.1 0 0
				        0.2 0.2 0.1 0 0
				        0   0   0   0.8 0"/>
		</filter>
	</defs>
</svg>
`;
  var REVISION_DIFF_STYLES = `
	.is-revision-added {
		box-shadow: inset 0 0 0 9999px color-mix(in srgb, currentColor 5%, #00a32a 15%), 0 0 0 4px color-mix(in srgb, currentColor 5%, #00a32a 15%);
	}
	.is-revision-removed,
	.revision-diff-removed {
		text-decoration: line-through;
		filter: url(#revision-removed-filter);
	}
	.is-revision-modified {
		outline: 2px solid color-mix(in srgb, currentColor 30%, #dba617 70%) !important;
		outline-offset: 2px;
	}
	.revision-diff-added {
		background-color: color-mix(in srgb, currentColor 5%, #00a32a 15%);
		text-decoration: none;
	}
	.revision-diff-format-added {
		text-decoration: underline wavy color-mix(in srgb, currentColor 30%, #00a32a 70%);
		text-decoration-thickness: 2px;
	}
	.revision-diff-format-removed {
		text-decoration: underline wavy color-mix(in srgb, currentColor 20%, #d63638 80%);
		text-decoration-thickness: 2px;
	}
	.revision-diff-format-changed {
		text-decoration: underline wavy color-mix(in srgb, currentColor 30%, #dba617 70%);
		text-decoration-thickness: 2px;
	}
`;
  function withRevisionDiffClasses(BlockListBlock) {
    return (props) => {
      const { block, className } = props;
      const diffStatus = block?.__revisionDiffStatus?.status;
      const enhancedClassName = clsx_default(className, {
        "is-revision-added": diffStatus === "added",
        "is-revision-removed": diffStatus === "removed",
        "is-revision-modified": diffStatus === "modified"
      });
      return /* @__PURE__ */ (0, import_jsx_runtime464.jsx)(BlockListBlock, { ...props, className: enhancedClassName });
    };
  }
  var FILTER_NAME = "editor/revisions-canvas/withRevisionDiffClasses";
  (0, import_hooks58.addFilter)("editor.BlockListBlock", FILTER_NAME, withRevisionDiffClasses);
  function DiffStyleOverrides({ showDiff }) {
    usePrivateStyleOverride({
      css: showDiff ? REVISION_DIFF_STYLES : ""
    });
    usePrivateStyleOverride({
      assets: showDiff ? REVISION_REMOVED_FILTER_SVG : "",
      __unstableType: "svgs"
    });
    return null;
  }
  function CanvasContent({ showDiff }) {
    const [contentRef, diffMarkers] = useDiffMarkers();
    return /* @__PURE__ */ (0, import_jsx_runtime464.jsxs)(import_jsx_runtime464.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime464.jsx)(visual_editor_default, { contentRef }),
      showDiff && diffMarkers
    ] });
  }
  function RevisionsCanvas() {
    (0, import_element265.useEffect)(() => {
      registerDiffFormatTypes();
      return () => {
        unregisterDiffFormatTypes();
      };
    }, []);
    const { revision, showDiff } = (0, import_data213.useSelect)((select7) => {
      const { getCurrentRevision: getCurrentRevision2, isShowingRevisionDiff: isShowingRevisionDiff2 } = unlock(
        select7(store3)
      );
      return {
        revision: getCurrentRevision2(),
        showDiff: isShowingRevisionDiff2()
      };
    }, []);
    return revision ? /* @__PURE__ */ (0, import_jsx_runtime464.jsxs)(import_jsx_runtime464.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime464.jsx)(DiffStyleOverrides, { showDiff }),
      /* @__PURE__ */ (0, import_jsx_runtime464.jsx)("div", { className: "editor-revisions-canvas__content", children: /* @__PURE__ */ (0, import_jsx_runtime464.jsx)(CanvasContent, { showDiff }) })
    ] }) : /* @__PURE__ */ (0, import_jsx_runtime464.jsx)("div", { className: "editor-revisions-canvas__loading", children: /* @__PURE__ */ (0, import_jsx_runtime464.jsx)(import_components252.Spinner, {}) });
  }

  // packages/editor/build-module/components/collaborators-presence/use-collaborator-notifications.mjs
  var import_data214 = __toESM(require_data(), 1);
  var import_element266 = __toESM(require_element(), 1);
  var import_i18n284 = __toESM(require_i18n(), 1);
  var import_notices29 = __toESM(require_notices(), 1);
  var import_core_data118 = __toESM(require_core_data(), 1);
  var import_preferences23 = __toESM(require_preferences(), 1);
  var { useOnCollaboratorJoin, useOnCollaboratorLeave, useOnPostSave } = unlock(import_core_data118.privateApis);
  var NOTIFICATION_TYPE = {
    COLLAB_POST_UPDATED: "collab-post-updated",
    COLLAB_USER_ENTERED: "collab-user-entered",
    COLLAB_USER_EXITED: "collab-user-exited"
  };
  var PUBLISHED_STATUSES = ["publish", "private", "future"];
  function getPostUpdatedMessage(name2, status, isFirstPublish) {
    if (isFirstPublish) {
      return (0, import_i18n284.sprintf)((0, import_i18n284.__)("Post published by %s."), name2);
    }
    if (PUBLISHED_STATUSES.includes(status)) {
      return (0, import_i18n284.sprintf)((0, import_i18n284.__)("Post updated by %s."), name2);
    }
    return (0, import_i18n284.sprintf)((0, import_i18n284.__)("Draft saved by %s."), name2);
  }
  function useCollaboratorNotifications(postId2, postType2) {
    const { postStatus, isCollaborationEnabled, showNotifications } = (0, import_data214.useSelect)(
      (select7) => {
        const editorSel = select7(store3);
        return {
          postStatus: editorSel.getCurrentPostAttribute("status"),
          isCollaborationEnabled: editorSel.isCollaborationEnabledForCurrentPost(),
          showNotifications: select7(import_preferences23.store).get(
            "core",
            "showCollaborationNotifications"
          ) ?? true
        };
      },
      []
    );
    const { createNotice } = (0, import_data214.useDispatch)(import_notices29.store);
    const shouldSubscribe = isCollaborationEnabled && showNotifications;
    const effectivePostId = shouldSubscribe ? postId2 : null;
    const effectivePostType = shouldSubscribe ? postType2 : null;
    useOnCollaboratorJoin(
      effectivePostId,
      effectivePostType,
      (0, import_element266.useCallback)(
        (collaborator, me) => {
          if (me && collaborator.collaboratorInfo.enteredAt < me.collaboratorInfo.enteredAt) {
            return;
          }
          void createNotice(
            "info",
            (0, import_i18n284.sprintf)(
              /* translators: %s: collaborator display name */
              (0, import_i18n284.__)("%s has joined the post."),
              collaborator.collaboratorInfo.name
            ),
            {
              id: `${NOTIFICATION_TYPE.COLLAB_USER_ENTERED}-${collaborator.collaboratorInfo.id}`,
              type: "snackbar",
              isDismissible: false
            }
          );
        },
        [createNotice]
      )
    );
    useOnCollaboratorLeave(
      effectivePostId,
      effectivePostType,
      (0, import_element266.useCallback)(
        (collaborator) => {
          void createNotice(
            "info",
            (0, import_i18n284.sprintf)(
              /* translators: %s: collaborator display name */
              (0, import_i18n284.__)("%s has left the post."),
              collaborator.collaboratorInfo.name
            ),
            {
              id: `${NOTIFICATION_TYPE.COLLAB_USER_EXITED}-${collaborator.collaboratorInfo.id}`,
              type: "snackbar",
              isDismissible: false
            }
          );
        },
        [createNotice]
      )
    );
    useOnPostSave(
      effectivePostId,
      effectivePostType,
      (0, import_element266.useCallback)(
        (saveEvent, saver, prevEvent) => {
          if (!postStatus) {
            return;
          }
          const effectiveStatus = saveEvent.postStatus ?? postStatus ?? "draft";
          const prevStatus = prevEvent?.postStatus ?? postStatus;
          const isFirstPublish = !(prevStatus && PUBLISHED_STATUSES.includes(prevStatus)) && PUBLISHED_STATUSES.includes(effectiveStatus);
          const message2 = getPostUpdatedMessage(
            saver.collaboratorInfo.name,
            effectiveStatus,
            isFirstPublish
          );
          void createNotice("info", message2, {
            id: `${NOTIFICATION_TYPE.COLLAB_POST_UPDATED}-${saver.collaboratorInfo.id}`,
            type: "snackbar",
            isDismissible: false
          });
        },
        [createNotice, postStatus]
      )
    );
  }

  // packages/editor/build-module/components/save-publish-panels/index.mjs
  var import_data215 = __toESM(require_data(), 1);
  var import_components253 = __toESM(require_components(), 1);
  var import_i18n285 = __toESM(require_i18n(), 1);
  var import_element267 = __toESM(require_element(), 1);
  var import_jsx_runtime465 = __toESM(require_jsx_runtime(), 1);
  var { Fill: Fill11, Slot: Slot13 } = (0, import_components253.createSlotFill)("ActionsPanel");
  function SavePublishPanels({
    setEntitiesSavedStatesCallback,
    closeEntitiesSavedStates,
    isEntitiesSavedStatesOpen,
    forceIsDirtyPublishPanel
  }) {
    const { closePublishSidebar: closePublishSidebar2, togglePublishSidebar: togglePublishSidebar2 } = (0, import_data215.useDispatch)(store3);
    const {
      publishSidebarOpened,
      isPublishable,
      isDirty,
      hasOtherEntitiesChanges
    } = (0, import_data215.useSelect)((select7) => {
      const {
        isPublishSidebarOpened: isPublishSidebarOpened2,
        isEditedPostPublishable: isEditedPostPublishable2,
        isCurrentPostPublished: isCurrentPostPublished2,
        isEditedPostDirty: isEditedPostDirty2,
        hasNonPostEntityChanges: hasNonPostEntityChanges2
      } = select7(store3);
      const _hasOtherEntitiesChanges = hasNonPostEntityChanges2();
      return {
        publishSidebarOpened: isPublishSidebarOpened2(),
        isPublishable: !isCurrentPostPublished2() && isEditedPostPublishable2(),
        isDirty: _hasOtherEntitiesChanges || isEditedPostDirty2(),
        hasOtherEntitiesChanges: _hasOtherEntitiesChanges
      };
    }, []);
    const openEntitiesSavedStates = (0, import_element267.useCallback)(
      () => setEntitiesSavedStatesCallback(true),
      []
    );
    let unmountableContent;
    if (publishSidebarOpened) {
      unmountableContent = /* @__PURE__ */ (0, import_jsx_runtime465.jsx)(
        post_publish_panel_default,
        {
          onClose: closePublishSidebar2,
          forceIsDirty: forceIsDirtyPublishPanel,
          PrePublishExtension: plugin_pre_publish_panel_default.Slot,
          PostPublishExtension: plugin_post_publish_panel_default.Slot
        }
      );
    } else if (isPublishable && !hasOtherEntitiesChanges) {
      unmountableContent = /* @__PURE__ */ (0, import_jsx_runtime465.jsx)("div", { className: "editor-layout__toggle-publish-panel", children: /* @__PURE__ */ (0, import_jsx_runtime465.jsx)(
        import_components253.Button,
        {
          __next40pxDefaultSize: true,
          variant: "secondary",
          onClick: togglePublishSidebar2,
          "aria-expanded": false,
          children: (0, import_i18n285.__)("Open publish panel")
        }
      ) });
    } else {
      unmountableContent = /* @__PURE__ */ (0, import_jsx_runtime465.jsx)("div", { className: "editor-layout__toggle-entities-saved-states-panel", children: /* @__PURE__ */ (0, import_jsx_runtime465.jsx)(
        import_components253.Button,
        {
          __next40pxDefaultSize: true,
          variant: "secondary",
          onClick: openEntitiesSavedStates,
          "aria-expanded": false,
          "aria-haspopup": "dialog",
          disabled: !isDirty,
          accessibleWhenDisabled: true,
          children: (0, import_i18n285.__)("Open save panel")
        }
      ) });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime465.jsxs)(import_jsx_runtime465.Fragment, { children: [
      isEntitiesSavedStatesOpen && /* @__PURE__ */ (0, import_jsx_runtime465.jsx)(
        EntitiesSavedStates,
        {
          close: closeEntitiesSavedStates,
          renderDialog: true
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime465.jsx)(Slot13, { bubblesVirtually: true }),
      !isEntitiesSavedStatesOpen && unmountableContent
    ] });
  }

  // packages/editor/build-module/components/text-editor/index.mjs
  var import_components254 = __toESM(require_components(), 1);
  var import_data216 = __toESM(require_data(), 1);
  var import_i18n286 = __toESM(require_i18n(), 1);
  var import_keyboard_shortcuts9 = __toESM(require_keyboard_shortcuts(), 1);
  var import_element268 = __toESM(require_element(), 1);
  var import_jsx_runtime466 = __toESM(require_jsx_runtime(), 1);
  function TextEditor({ autoFocus = false }) {
    const { switchEditorMode: switchEditorMode2 } = (0, import_data216.useDispatch)(store3);
    const { shortcut, isRichEditingEnabled } = (0, import_data216.useSelect)((select7) => {
      const { getEditorSettings: getEditorSettings2 } = select7(store3);
      const { getShortcutRepresentation } = select7(import_keyboard_shortcuts9.store);
      return {
        shortcut: getShortcutRepresentation("core/editor/toggle-mode"),
        isRichEditingEnabled: getEditorSettings2().richEditingEnabled
      };
    }, []);
    const titleRef = (0, import_element268.useRef)();
    (0, import_element268.useEffect)(() => {
      if (autoFocus) {
        return;
      }
      titleRef?.current?.focus();
    }, [autoFocus]);
    return /* @__PURE__ */ (0, import_jsx_runtime466.jsxs)("div", { className: "editor-text-editor", children: [
      isRichEditingEnabled && /* @__PURE__ */ (0, import_jsx_runtime466.jsxs)("div", { className: "editor-text-editor__toolbar", children: [
        /* @__PURE__ */ (0, import_jsx_runtime466.jsx)("h2", { children: (0, import_i18n286.__)("Editing code") }),
        /* @__PURE__ */ (0, import_jsx_runtime466.jsx)(
          import_components254.Button,
          {
            __next40pxDefaultSize: true,
            variant: "tertiary",
            onClick: () => switchEditorMode2("visual"),
            shortcut,
            children: (0, import_i18n286.__)("Exit code editor")
          }
        )
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime466.jsxs)("div", { className: "editor-text-editor__body", children: [
        /* @__PURE__ */ (0, import_jsx_runtime466.jsx)(post_title_raw_default, { ref: titleRef }),
        /* @__PURE__ */ (0, import_jsx_runtime466.jsx)(PostTextEditor, {})
      ] })
    ] });
  }

  // packages/editor/build-module/components/media/preview.mjs
  var import_data217 = __toESM(require_data(), 1);
  var import_jsx_runtime467 = __toESM(require_jsx_runtime(), 1);
  function MediaPreview3(props) {
    const { media } = (0, import_data217.useSelect)((select7) => {
      const currentPost = select7(store3).getCurrentPost();
      return {
        media: currentPost
      };
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime467.jsx)(MediaEditorProvider, { value: media, children: /* @__PURE__ */ (0, import_jsx_runtime467.jsx)(MediaPreview2, { ...props }) });
  }

  // packages/editor/build-module/components/media/metadata-panel.mjs
  var import_data223 = __toESM(require_data(), 1);
  var import_element274 = __toESM(require_element(), 1);
  var import_core_data124 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/post-card-panel/index.mjs
  var import_components258 = __toESM(require_components(), 1);
  var import_core_data123 = __toESM(require_core_data(), 1);
  var import_data222 = __toESM(require_data(), 1);
  var import_element273 = __toESM(require_element(), 1);
  var import_i18n290 = __toESM(require_i18n(), 1);
  var import_dom14 = __toESM(require_dom(), 1);

  // packages/editor/build-module/components/post-actions/index.mjs
  var import_data221 = __toESM(require_data(), 1);
  var import_element272 = __toESM(require_element(), 1);
  var import_i18n289 = __toESM(require_i18n(), 1);
  var import_components257 = __toESM(require_components(), 1);
  var import_core_data122 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/post-actions/actions.mjs
  var import_data220 = __toESM(require_data(), 1);
  var import_element271 = __toESM(require_element(), 1);
  var import_core_data121 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/post-actions/set-as-homepage.mjs
  var import_i18n287 = __toESM(require_i18n(), 1);
  var import_element269 = __toESM(require_element(), 1);
  var import_components255 = __toESM(require_components(), 1);
  var import_data218 = __toESM(require_data(), 1);
  var import_core_data119 = __toESM(require_core_data(), 1);
  var import_notices30 = __toESM(require_notices(), 1);

  // packages/editor/build-module/utils/get-item-title.mjs
  var import_html_entities28 = __toESM(require_html_entities(), 1);
  function getItemTitle2(item) {
    if (typeof item.title === "string") {
      return (0, import_html_entities28.decodeEntities)(item.title);
    }
    if (item.title && "rendered" in item.title) {
      return (0, import_html_entities28.decodeEntities)(item.title.rendered);
    }
    if (item.title && "raw" in item.title) {
      return (0, import_html_entities28.decodeEntities)(item.title.raw);
    }
    return "";
  }

  // packages/editor/build-module/components/post-actions/set-as-homepage.mjs
  var import_jsx_runtime468 = __toESM(require_jsx_runtime(), 1);
  var SetAsHomepageModal = ({ items, closeModal: closeModal2 }) => {
    const [item] = items;
    const pageTitle = getItemTitle2(item);
    const { showOnFront, currentHomePage, isSaving } = (0, import_data218.useSelect)(
      (select7) => {
        const { getEntityRecord, isSavingEntityRecord } = select7(import_core_data119.store);
        const siteSettings = getEntityRecord("root", "site");
        const currentHomePageItem = getEntityRecord(
          "postType",
          "page",
          siteSettings?.page_on_front
        );
        return {
          showOnFront: siteSettings?.show_on_front,
          currentHomePage: currentHomePageItem,
          isSaving: isSavingEntityRecord("root", "site")
        };
      }
    );
    const { saveEntityRecord } = (0, import_data218.useDispatch)(import_core_data119.store);
    const { createSuccessNotice, createErrorNotice } = (0, import_data218.useDispatch)(import_notices30.store);
    async function onSetPageAsHomepage(event) {
      event.preventDefault();
      try {
        await saveEntityRecord("root", "site", {
          page_on_front: item.id,
          show_on_front: "page"
        });
        createSuccessNotice((0, import_i18n287.__)("Homepage updated."), {
          type: "snackbar"
        });
      } catch (error2) {
        const errorMessage = error2.message && error2.code !== "unknown_error" ? error2.message : (0, import_i18n287.__)("An error occurred while setting the homepage.");
        createErrorNotice(errorMessage, { type: "snackbar" });
      } finally {
        closeModal2?.();
      }
    }
    let modalWarning = "";
    if ("posts" === showOnFront) {
      modalWarning = (0, import_i18n287.__)(
        "This will replace the current homepage which is set to display latest posts."
      );
    } else if (currentHomePage) {
      modalWarning = (0, import_i18n287.sprintf)(
        // translators: %s: title of the current home page.
        (0, import_i18n287.__)('This will replace the current homepage: "%s"'),
        getItemTitle2(currentHomePage)
      );
    }
    const modalText = (0, import_i18n287.sprintf)(
      // translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message.
      (0, import_i18n287.__)('Set "%1$s" as the site homepage? %2$s'),
      pageTitle,
      modalWarning
    ).trim();
    const modalButtonLabel = (0, import_i18n287.__)("Set homepage");
    return /* @__PURE__ */ (0, import_jsx_runtime468.jsx)("form", { onSubmit: onSetPageAsHomepage, children: /* @__PURE__ */ (0, import_jsx_runtime468.jsxs)(import_components255.__experimentalVStack, { spacing: "5", children: [
      /* @__PURE__ */ (0, import_jsx_runtime468.jsx)(import_components255.__experimentalText, { children: modalText }),
      /* @__PURE__ */ (0, import_jsx_runtime468.jsxs)(import_components255.__experimentalHStack, { justify: "right", children: [
        /* @__PURE__ */ (0, import_jsx_runtime468.jsx)(
          import_components255.Button,
          {
            __next40pxDefaultSize: true,
            variant: "tertiary",
            onClick: () => {
              closeModal2?.();
            },
            disabled: isSaving,
            accessibleWhenDisabled: true,
            children: (0, import_i18n287.__)("Cancel")
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime468.jsx)(
          import_components255.Button,
          {
            __next40pxDefaultSize: true,
            variant: "primary",
            type: "submit",
            disabled: isSaving,
            accessibleWhenDisabled: true,
            children: modalButtonLabel
          }
        )
      ] })
    ] }) });
  };
  var useSetAsHomepageAction = () => {
    const { pageOnFront, pageForPosts } = (0, import_data218.useSelect)((select7) => {
      const { getEntityRecord, canUser } = select7(import_core_data119.store);
      const siteSettings = canUser("read", {
        kind: "root",
        name: "site"
      }) ? getEntityRecord("root", "site") : void 0;
      return {
        pageOnFront: siteSettings?.page_on_front,
        pageForPosts: siteSettings?.page_for_posts
      };
    });
    return (0, import_element269.useMemo)(
      () => ({
        id: "set-as-homepage",
        label: (0, import_i18n287.__)("Set as homepage"),
        isEligible(post2) {
          if (post2.status !== "publish") {
            return false;
          }
          if (post2.type !== "page") {
            return false;
          }
          if (pageOnFront === post2.id) {
            return false;
          }
          if (pageForPosts === post2.id) {
            return false;
          }
          return true;
        },
        modalFocusOnMount: "firstContentElement",
        RenderModal: SetAsHomepageModal
      }),
      [pageForPosts, pageOnFront]
    );
  };

  // packages/editor/build-module/components/post-actions/set-as-posts-page.mjs
  var import_i18n288 = __toESM(require_i18n(), 1);
  var import_element270 = __toESM(require_element(), 1);
  var import_components256 = __toESM(require_components(), 1);
  var import_data219 = __toESM(require_data(), 1);
  var import_core_data120 = __toESM(require_core_data(), 1);
  var import_notices31 = __toESM(require_notices(), 1);
  var import_jsx_runtime469 = __toESM(require_jsx_runtime(), 1);
  var SetAsPostsPageModal = ({ items, closeModal: closeModal2 }) => {
    const [item] = items;
    const pageTitle = getItemTitle2(item);
    const { currentPostsPage, isPageForPostsSet, isSaving } = (0, import_data219.useSelect)(
      (select7) => {
        const { getEntityRecord, isSavingEntityRecord } = select7(import_core_data120.store);
        const siteSettings = getEntityRecord("root", "site");
        const currentPostsPageItem = getEntityRecord(
          "postType",
          "page",
          siteSettings?.page_for_posts
        );
        return {
          currentPostsPage: currentPostsPageItem,
          isPageForPostsSet: siteSettings?.page_for_posts !== 0,
          isSaving: isSavingEntityRecord("root", "site")
        };
      }
    );
    const { saveEntityRecord } = (0, import_data219.useDispatch)(import_core_data120.store);
    const { createSuccessNotice, createErrorNotice } = (0, import_data219.useDispatch)(import_notices31.store);
    async function onSetPageAsPostsPage(event) {
      event.preventDefault();
      try {
        await saveEntityRecord("root", "site", {
          page_for_posts: item.id,
          show_on_front: "page"
        });
        createSuccessNotice((0, import_i18n288.__)("Posts page updated."), {
          type: "snackbar"
        });
      } catch (error2) {
        const errorMessage = error2.message && error2.code !== "unknown_error" ? error2.message : (0, import_i18n288.__)("An error occurred while setting the posts page.");
        createErrorNotice(errorMessage, { type: "snackbar" });
      } finally {
        closeModal2?.();
      }
    }
    const modalWarning = isPageForPostsSet && currentPostsPage ? (0, import_i18n288.sprintf)(
      // translators: %s: title of the current posts page.
      (0, import_i18n288.__)('This will replace the current posts page: "%s"'),
      getItemTitle2(currentPostsPage)
    ) : (0, import_i18n288.__)("This page will show the latest posts.");
    const modalText = (0, import_i18n288.sprintf)(
      // translators: %1$s: title of the page to be set as the posts page, %2$s: posts page replacement warning message.
      (0, import_i18n288.__)('Set "%1$s" as the posts page? %2$s'),
      pageTitle,
      modalWarning
    );
    const modalButtonLabel = (0, import_i18n288.__)("Set posts page");
    return /* @__PURE__ */ (0, import_jsx_runtime469.jsx)("form", { onSubmit: onSetPageAsPostsPage, children: /* @__PURE__ */ (0, import_jsx_runtime469.jsxs)(import_components256.__experimentalVStack, { spacing: "5", children: [
      /* @__PURE__ */ (0, import_jsx_runtime469.jsx)(import_components256.__experimentalText, { children: modalText }),
      /* @__PURE__ */ (0, import_jsx_runtime469.jsxs)(import_components256.__experimentalHStack, { justify: "right", children: [
        /* @__PURE__ */ (0, import_jsx_runtime469.jsx)(
          import_components256.Button,
          {
            __next40pxDefaultSize: true,
            variant: "tertiary",
            onClick: () => {
              closeModal2?.();
            },
            disabled: isSaving,
            accessibleWhenDisabled: true,
            children: (0, import_i18n288.__)("Cancel")
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime469.jsx)(
          import_components256.Button,
          {
            __next40pxDefaultSize: true,
            variant: "primary",
            type: "submit",
            disabled: isSaving,
            accessibleWhenDisabled: true,
            children: modalButtonLabel
          }
        )
      ] })
    ] }) });
  };
  var useSetAsPostsPageAction = () => {
    const { pageOnFront, pageForPosts } = (0, import_data219.useSelect)((select7) => {
      const { getEntityRecord, canUser } = select7(import_core_data120.store);
      const siteSettings = canUser("read", {
        kind: "root",
        name: "site"
      }) ? getEntityRecord("root", "site") : void 0;
      return {
        pageOnFront: siteSettings?.page_on_front,
        pageForPosts: siteSettings?.page_for_posts
      };
    });
    return (0, import_element270.useMemo)(
      () => ({
        id: "set-as-posts-page",
        label: (0, import_i18n288.__)("Set as posts page"),
        isEligible(post2) {
          if (post2.status !== "publish") {
            return false;
          }
          if (post2.type !== "page") {
            return false;
          }
          if (pageOnFront === post2.id) {
            return false;
          }
          if (pageForPosts === post2.id) {
            return false;
          }
          return true;
        },
        modalFocusOnMount: "firstContentElement",
        RenderModal: SetAsPostsPageModal
      }),
      [pageForPosts, pageOnFront]
    );
  };

  // packages/editor/build-module/components/post-actions/actions.mjs
  var import_jsx_runtime470 = __toESM(require_jsx_runtime(), 1);
  function usePostActions({ postType: postType2, onActionPerformed, context }) {
    const { defaultActions } = (0, import_data220.useSelect)(
      (select7) => {
        const { getEntityActions: getEntityActions3 } = unlock(select7(store3));
        return {
          defaultActions: getEntityActions3("postType", postType2)
        };
      },
      [postType2]
    );
    const shouldShowHomepageActions = (0, import_data220.useSelect)(
      (select7) => {
        if (postType2 !== "page") {
          return false;
        }
        const { getDefaultTemplateId, getEntityRecord, canUser } = select7(import_core_data121.store);
        const canUpdateSettings = canUser("update", {
          kind: "root",
          name: "site"
        });
        if (!canUpdateSettings) {
          return false;
        }
        const frontPageTemplateId = getDefaultTemplateId({
          slug: "front-page"
        });
        if (!frontPageTemplateId) {
          return true;
        }
        const frontPageTemplate = getEntityRecord(
          "postType",
          "wp_template",
          frontPageTemplateId
        );
        if (!frontPageTemplate) {
          return true;
        }
        return frontPageTemplate.slug !== "front-page";
      },
      [postType2]
    );
    const setAsHomepageAction = useSetAsHomepageAction();
    const setAsPostsPageAction = useSetAsPostsPageAction();
    const { registerPostTypeSchema: registerPostTypeSchema2 } = unlock((0, import_data220.useDispatch)(store3));
    (0, import_element271.useEffect)(() => {
      registerPostTypeSchema2(postType2);
    }, [registerPostTypeSchema2, postType2]);
    return (0, import_element271.useMemo)(() => {
      let actions2 = [...defaultActions];
      if (shouldShowHomepageActions) {
        actions2.push(setAsHomepageAction, setAsPostsPageAction);
      }
      actions2 = actions2.sort(
        (a3, b3) => b3.id === "move-to-trash" ? -1 : 0
      );
      actions2 = actions2.filter((action) => {
        if (!action.context) {
          return true;
        }
        return action.context === context;
      });
      if (onActionPerformed) {
        for (let i3 = 0; i3 < actions2.length; ++i3) {
          if (actions2[i3].callback) {
            const existingCallback = actions2[i3].callback;
            actions2[i3] = {
              ...actions2[i3],
              callback: (items, argsObject) => {
                existingCallback(items, {
                  ...argsObject,
                  onActionPerformed: (_items) => {
                    if (argsObject?.onActionPerformed) {
                      argsObject.onActionPerformed(_items);
                    }
                    onActionPerformed(
                      actions2[i3].id,
                      _items
                    );
                  }
                });
              }
            };
          }
          if (actions2[i3].RenderModal) {
            const ExistingRenderModal = actions2[i3].RenderModal;
            actions2[i3] = {
              ...actions2[i3],
              RenderModal: (props) => {
                return /* @__PURE__ */ (0, import_jsx_runtime470.jsx)(
                  ExistingRenderModal,
                  {
                    ...props,
                    onActionPerformed: (_items) => {
                      if (props.onActionPerformed) {
                        props.onActionPerformed(_items);
                      }
                      onActionPerformed(
                        actions2[i3].id,
                        _items
                      );
                    }
                  }
                );
              }
            };
          }
        }
      }
      return actions2;
    }, [
      context,
      defaultActions,
      onActionPerformed,
      setAsHomepageAction,
      setAsPostsPageAction,
      shouldShowHomepageActions
    ]);
  }

  // packages/editor/build-module/components/post-actions/index.mjs
  var import_jsx_runtime471 = __toESM(require_jsx_runtime(), 1);
  var { Menu: Menu10, kebabCase: kebabCase5 } = unlock(import_components257.privateApis);
  function PostActions({ postType: postType2, postId: postId2, onActionPerformed }) {
    const [activeModalAction, setActiveModalAction] = (0, import_element272.useState)(null);
    const { item, permissions } = (0, import_data221.useSelect)(
      (select7) => {
        const { getEditedEntityRecord, getEntityRecordPermissions } = unlock(select7(import_core_data122.store));
        return {
          item: getEditedEntityRecord("postType", postType2, postId2),
          permissions: getEntityRecordPermissions(
            "postType",
            postType2,
            postId2
          )
        };
      },
      [postId2, postType2]
    );
    const itemWithPermissions = (0, import_element272.useMemo)(() => {
      return {
        ...item,
        permissions
      };
    }, [item, permissions]);
    const allActions = usePostActions({ postType: postType2, onActionPerformed });
    const actions2 = (0, import_element272.useMemo)(() => {
      return allActions.filter((action) => {
        return !action.isEligible || action.isEligible(itemWithPermissions);
      });
    }, [allActions, itemWithPermissions]);
    return /* @__PURE__ */ (0, import_jsx_runtime471.jsxs)(import_jsx_runtime471.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime471.jsxs)(Menu10, { placement: "bottom-end", children: [
        /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(
          Menu10.TriggerButton,
          {
            render: /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(
              import_components257.Button,
              {
                size: "small",
                icon: more_vertical_default,
                label: (0, import_i18n289.__)("Actions"),
                disabled: !actions2.length,
                accessibleWhenDisabled: true,
                className: "editor-all-actions-button"
              }
            )
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(Menu10.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(
          ActionsDropdownMenuGroup,
          {
            actions: actions2,
            items: [itemWithPermissions],
            setActiveModalAction
          }
        ) })
      ] }),
      !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(
        ActionModal2,
        {
          action: activeModalAction,
          items: [itemWithPermissions],
          closeModal: () => setActiveModalAction(null)
        }
      )
    ] });
  }
  function DropdownMenuItemTrigger({ action, onClick, items }) {
    const label = typeof action.label === "string" ? action.label : action.label(items);
    return /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(Menu10.Item, { onClick, children: /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(Menu10.ItemLabel, { children: label }) });
  }
  function ActionModal2({ action, items, closeModal: closeModal2 }) {
    const label = typeof action.label === "string" ? action.label : action.label(items);
    return /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(
      import_components257.Modal,
      {
        title: action.modalHeader || label,
        __experimentalHideHeader: !!action.hideModalHeader,
        onRequestClose: closeModal2 ?? (() => {
        }),
        focusOnMount: "firstContentElement",
        size: "medium",
        overlayClassName: `editor-action-modal editor-action-modal__${kebabCase5(
          action.id
        )}`,
        children: /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(action.RenderModal, { items, closeModal: closeModal2 })
      }
    );
  }
  function ActionsDropdownMenuGroup({ actions: actions2, items, setActiveModalAction }) {
    const registry = (0, import_data221.useRegistry)();
    return /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(Menu10.Group, { children: actions2.map((action) => {
      return /* @__PURE__ */ (0, import_jsx_runtime471.jsx)(
        DropdownMenuItemTrigger,
        {
          action,
          onClick: () => {
            if ("RenderModal" in action) {
              setActiveModalAction(action);
              return;
            }
            action.callback(items, { registry });
          },
          items
        },
        action.id
      );
    }) });
  }

  // packages/editor/build-module/components/post-card-panel/index.mjs
  var import_jsx_runtime472 = __toESM(require_jsx_runtime(), 1);
  var { Badge: WCBadge4 } = unlock(import_components258.privateApis);
  function PostCardPanel({
    postType: postType2,
    postId: postId2,
    hideActions = false,
    onActionPerformed,
    onClose
  }) {
    const postIds = (0, import_element273.useMemo)(
      () => Array.isArray(postId2) ? postId2 : [postId2],
      [postId2]
    );
    const { postTitle, icon, labels } = (0, import_data222.useSelect)(
      (select7) => {
        const { getEditedEntityRecord, getCurrentTheme, getPostType } = select7(import_core_data123.store);
        const {
          getPostIcon: getPostIcon2,
          getCurrentPostType: getCurrentPostType2,
          isRevisionsMode: isRevisionsMode2,
          getCurrentRevision: getCurrentRevision2
        } = unlock(select7(store3));
        let _title = "";
        if (isRevisionsMode2()) {
          const parentPostType = getCurrentPostType2();
          const _record2 = getCurrentRevision2();
          _title = _record2?.title?.rendered || _record2?.title?.raw || "";
          return {
            postTitle: _title,
            icon: getPostIcon2(parentPostType, {
              area: _record2?.area
            }),
            labels: getPostType(parentPostType)?.labels
          };
        }
        const _record = getEditedEntityRecord(
          "postType",
          postType2,
          postIds[0]
        );
        if (postIds.length === 1) {
          const { default_template_types: templateTypes = [] } = getCurrentTheme() ?? {};
          const _templateInfo = [
            TEMPLATE_POST_TYPE,
            TEMPLATE_PART_POST_TYPE
          ].includes(postType2) ? getTemplateInfo({
            template: _record,
            templateTypes
          }) : {};
          _title = _templateInfo?.title || _record?.title;
        }
        return {
          postTitle: _title,
          icon: getPostIcon2(postType2, {
            area: _record?.area
          }),
          labels: getPostType(postType2)?.labels
        };
      },
      [postIds, postType2]
    );
    const pageTypeBadge = usePageTypeBadge(postId2);
    let title = (0, import_i18n290.__)("No title");
    if (labels?.name && postIds.length > 1) {
      title = (0, import_i18n290.sprintf)(
        // translators: %1$d number of selected items %2$s: Name of the plural post type e.g: "Posts".
        (0, import_i18n290.__)("%1$d %2$s"),
        postIds.length,
        labels?.name
      );
    } else if (postTitle) {
      title = (0, import_dom14.__unstableStripHTML)(postTitle);
    }
    return /* @__PURE__ */ (0, import_jsx_runtime472.jsxs)(import_components258.__experimentalVStack, { spacing: 1, className: "editor-post-card-panel", children: [
      /* @__PURE__ */ (0, import_jsx_runtime472.jsxs)(
        import_components258.__experimentalHStack,
        {
          spacing: 2,
          className: "editor-post-card-panel__header",
          alignment: "flex-start",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime472.jsx)(import_components258.Icon, { className: "editor-post-card-panel__icon", icon }),
            /* @__PURE__ */ (0, import_jsx_runtime472.jsxs)(
              import_components258.__experimentalText,
              {
                numberOfLines: 2,
                truncate: true,
                className: "editor-post-card-panel__title",
                as: "h2",
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime472.jsx)("span", { className: "editor-post-card-panel__title-name", children: title }),
                  pageTypeBadge && postIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime472.jsx)(WCBadge4, { children: pageTypeBadge })
                ]
              }
            ),
            !hideActions && postIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime472.jsx)(
              PostActions,
              {
                postType: postType2,
                postId: postIds[0],
                onActionPerformed
              }
            ),
            onClose && /* @__PURE__ */ (0, import_jsx_runtime472.jsx)(
              import_components258.Button,
              {
                size: "small",
                icon: close_default,
                label: (0, import_i18n290.__)("Close"),
                onClick: onClose
              }
            )
          ]
        }
      ),
      postIds.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime472.jsx)(import_components258.__experimentalText, { className: "editor-post-card-panel__description", children: (0, import_i18n290.sprintf)(
        // translators: %s: Name of the plural post type e.g: "Posts".
        (0, import_i18n290.__)("Changes will be applied to all selected %s."),
        labels?.name.toLowerCase()
      ) })
    ] });
  }

  // packages/editor/build-module/components/post-panel-section/index.mjs
  var import_components259 = __toESM(require_components(), 1);
  var import_jsx_runtime473 = __toESM(require_jsx_runtime(), 1);
  function PostPanelSection({ className, children }) {
    return /* @__PURE__ */ (0, import_jsx_runtime473.jsx)(import_components259.__experimentalVStack, { className: clsx_default("editor-post-panel__section", className), children });
  }
  var post_panel_section_default = PostPanelSection;

  // packages/editor/build-module/components/media/metadata-panel.mjs
  var import_jsx_runtime474 = __toESM(require_jsx_runtime(), 1);
  function MediaMetadataPanel({ onActionPerformed }) {
    const { media, postType: postType2, postId: postId2 } = (0, import_data223.useSelect)((select7) => {
      const _postType = select7(store3).getCurrentPostType();
      const _postId = select7(store3).getCurrentPostId();
      const currentPost = select7(import_core_data124.store).getEditedEntityRecord(
        "postType",
        _postType,
        _postId,
        {
          _embed: "author,wp:attached-to"
        }
      );
      return {
        media: currentPost,
        postType: _postType,
        postId: _postId
      };
    }, []);
    const { editPost: editPost2 } = (0, import_data223.useDispatch)(store3);
    const fields3 = post_fields_default({ postType: "attachment" });
    const settings = (0, import_element274.useMemo)(
      () => ({
        fields: fields3
      }),
      [fields3]
    );
    const handleUpdate = (updates) => {
      editPost2(updates);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime474.jsx)(post_panel_section_default, { className: "editor-media-metadata-panel", children: /* @__PURE__ */ (0, import_jsx_runtime474.jsx)(
      MediaEditorProvider,
      {
        value: media,
        settings,
        onChange: handleUpdate,
        children: /* @__PURE__ */ (0, import_jsx_runtime474.jsx)(
          MediaForm,
          {
            header: /* @__PURE__ */ (0, import_jsx_runtime474.jsx)(
              PostCardPanel,
              {
                postType: postType2,
                postId: postId2,
                onActionPerformed
              }
            )
          }
        )
      }
    ) });
  }

  // packages/editor/build-module/components/editor-interface/index.mjs
  var import_jsx_runtime475 = __toESM(require_jsx_runtime(), 1);
  var interfaceLabels = {
    /* translators: accessibility text for the editor top bar landmark region. */
    header: (0, import_i18n291.__)("Editor top bar"),
    /* translators: accessibility text for the editor content landmark region. */
    body: (0, import_i18n291.__)("Editor content"),
    /* translators: accessibility text for the editor settings landmark region. */
    sidebar: (0, import_i18n291.__)("Editor settings"),
    /* translators: accessibility text for the editor publish landmark region. */
    actions: (0, import_i18n291.__)("Editor publish"),
    /* translators: accessibility text for the editor footer landmark region. */
    footer: (0, import_i18n291.__)("Editor footer")
  };
  var Notices = () => /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(
    import_notices32.InlineNotices,
    {
      pinnedNoticesClassName: "editor-notices__pinned",
      dismissibleNoticesClassName: "editor-notices__dismissible",
      children: /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(TemplateValidationNotice, {})
    }
  );
  function EditorInterface({
    className,
    children,
    forceIsDirty,
    contentRef,
    disableIframe,
    autoFocus,
    customSaveButton,
    customSavePanel,
    forceDisableBlockTools,
    iframeProps
  }) {
    const {
      mode,
      postId: postId2,
      postType: postType2,
      isAttachment,
      isInserterOpened: isInserterOpened2,
      isListViewOpened: isListViewOpened2,
      isDistractionFree,
      isPreviewMode,
      showBlockBreadcrumbs,
      postTypeLabel,
      stylesPath: stylesPath2,
      showStylebook: showStylebook2,
      isRevisionsMode: isRevisionsMode2,
      showDiff
    } = (0, import_data224.useSelect)((select7) => {
      const { get } = select7(import_preferences24.store);
      const {
        getEditorSettings: getEditorSettings2,
        getPostTypeLabel: getPostTypeLabel2,
        getCurrentPostType: getCurrentPostType2,
        getCurrentPostId: getCurrentPostId2
      } = select7(store3);
      const {
        getStylesPath: getStylesPath2,
        getShowStylebook: getShowStylebook2,
        isRevisionsMode: _isRevisionsMode,
        isShowingRevisionDiff: isShowingRevisionDiff2
      } = unlock(select7(store3));
      const editorSettings2 = getEditorSettings2();
      let _mode = select7(store3).getEditorMode();
      if (!editorSettings2.richEditingEnabled && _mode === "visual") {
        _mode = "text";
      }
      if (!editorSettings2.codeEditingEnabled && _mode === "text") {
        _mode = "visual";
      }
      return {
        mode: _mode,
        postId: getCurrentPostId2(),
        postType: getCurrentPostType2(),
        isInserterOpened: select7(store3).isInserterOpened(),
        isListViewOpened: select7(store3).isListViewOpened(),
        isDistractionFree: get("core", "distractionFree"),
        isPreviewMode: editorSettings2.isPreviewMode,
        showBlockBreadcrumbs: get("core", "showBlockBreadcrumbs"),
        postTypeLabel: getPostTypeLabel2(),
        stylesPath: getStylesPath2(),
        showStylebook: getShowStylebook2(),
        isAttachment: getCurrentPostType2() === "attachment" && window?.__experimentalMediaEditor,
        isRevisionsMode: _isRevisionsMode(),
        showDiff: isShowingRevisionDiff2()
      };
    }, []);
    const { setShowRevisionDiff: setShowRevisionDiff2 } = unlock((0, import_data224.useDispatch)(store3));
    useCollaboratorNotifications(postId2, postType2);
    const isLargeViewport = (0, import_compose75.useViewportMatch)("medium");
    const secondarySidebarLabel = isListViewOpened2 ? (0, import_i18n291.__)("Document Overview") : (0, import_i18n291.__)("Block Library");
    const shouldShowMediaEditor = !!isAttachment;
    const shouldShowStylesCanvas = !isAttachment && (showStylebook2 || stylesPath2?.startsWith("/revisions"));
    const shouldShowBlockEditor = !shouldShowMediaEditor && !shouldShowStylesCanvas;
    const [entitiesSavedStatesCallback, setEntitiesSavedStatesCallback] = (0, import_element275.useState)(false);
    const closeEntitiesSavedStates = (0, import_element275.useCallback)(
      (arg) => {
        if (typeof entitiesSavedStatesCallback === "function") {
          entitiesSavedStatesCallback(arg);
        }
        setEntitiesSavedStatesCallback(false);
      },
      [entitiesSavedStatesCallback]
    );
    if (isRevisionsMode2) {
      return /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(
        interface_skeleton_default,
        {
          className: clsx_default("editor-editor-interface", className),
          labels: interfaceLabels,
          header: /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(
            revisions_header_default,
            {
              showDiff,
              onToggleDiff: () => setShowRevisionDiff2(!showDiff)
            }
          ),
          content: /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(RevisionsCanvas, {}),
          sidebar: /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(complementary_area_default.Slot, { scope: "core" })
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(
      interface_skeleton_default,
      {
        isDistractionFree,
        className: clsx_default("editor-editor-interface", className, {
          "is-entity-save-view-open": !!entitiesSavedStatesCallback,
          "is-distraction-free": isDistractionFree && !isPreviewMode
        }),
        labels: {
          ...interfaceLabels,
          secondarySidebar: secondarySidebarLabel
        },
        header: !isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(
          header_default2,
          {
            forceIsDirty,
            setEntitiesSavedStatesCallback,
            customSaveButton,
            forceDisableBlockTools
          }
        ),
        editorNotices: /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(Notices, {}),
        secondarySidebar: !isAttachment && !isPreviewMode && mode === "visual" && (isInserterOpened2 && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(InserterSidebar, {}) || isListViewOpened2 && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(ListViewSidebar, {})),
        sidebar: !isPreviewMode && !isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(complementary_area_default.Slot, { scope: "core" }),
        content: /* @__PURE__ */ (0, import_jsx_runtime475.jsxs)(import_jsx_runtime475.Fragment, { children: [
          !isDistractionFree && !isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(Notices, {}),
          shouldShowMediaEditor && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(MediaPreview3, { ...iframeProps }),
          shouldShowStylesCanvas && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(StylesCanvas, {}),
          shouldShowBlockEditor && /* @__PURE__ */ (0, import_jsx_runtime475.jsxs)(import_jsx_runtime475.Fragment, { children: [
            !isPreviewMode && mode === "text" && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(
              TextEditor,
              {
                autoFocus
              }
            ),
            !isPreviewMode && !isLargeViewport && mode === "visual" && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(import_block_editor85.BlockToolbar, { hideDragHandle: true }),
            (isPreviewMode || mode === "visual") && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(
              visual_editor_default,
              {
                contentRef,
                disableIframe,
                autoFocus,
                iframeProps
              }
            ),
            children,
            /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(
              CollaboratorsOverlay,
              {
                postId: postId2,
                postType: postType2
              }
            )
          ] })
        ] }),
        footer: !isPreviewMode && !isDistractionFree && isLargeViewport && showBlockBreadcrumbs && mode === "visual" && /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(
          import_block_editor85.BlockBreadcrumb,
          {
            rootLabelText: postTypeLabel ? (0, import_html_entities29.decodeEntities)(postTypeLabel) : void 0
          }
        ),
        actions: !isPreviewMode ? customSavePanel || /* @__PURE__ */ (0, import_jsx_runtime475.jsx)(
          SavePublishPanels,
          {
            closeEntitiesSavedStates,
            isEntitiesSavedStatesOpen: entitiesSavedStatesCallback,
            setEntitiesSavedStatesCallback,
            forceIsDirtyPublishPanel: forceIsDirty
          }
        ) : void 0
      }
    );
  }

  // packages/editor/build-module/components/sidebar/index.mjs
  var import_block_editor97 = __toESM(require_block_editor(), 1);
  var import_data252 = __toESM(require_data(), 1);
  var import_element290 = __toESM(require_element(), 1);
  var import_i18n311 = __toESM(require_i18n(), 1);
  var import_keyboard_shortcuts10 = __toESM(require_keyboard_shortcuts(), 1);
  var import_components278 = __toESM(require_components(), 1);

  // packages/editor/build-module/components/pattern-overrides-panel/index.mjs
  var import_data225 = __toESM(require_data(), 1);
  var import_patterns9 = __toESM(require_patterns(), 1);
  var import_jsx_runtime476 = __toESM(require_jsx_runtime(), 1);
  var { OverridesPanel } = unlock(import_patterns9.privateApis);
  function PatternOverridesPanel() {
    const supportsPatternOverridesPanel = (0, import_data225.useSelect)(
      (select7) => select7(store3).getCurrentPostType() === "wp_block",
      []
    );
    if (!supportsPatternOverridesPanel) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime476.jsx)(OverridesPanel, {});
  }

  // packages/editor/build-module/components/sidebar/post-summary.mjs
  var import_components267 = __toESM(require_components(), 1);
  var import_data236 = __toESM(require_data(), 1);

  // packages/editor/build-module/components/sidebar/dataform-post-summary.mjs
  var import_i18n292 = __toESM(require_i18n(), 1);
  var import_data229 = __toESM(require_data(), 1);
  var import_core_data126 = __toESM(require_core_data(), 1);
  var import_components260 = __toESM(require_components(), 1);
  var import_element277 = __toESM(require_element(), 1);

  // packages/views/build-module/use-view.mjs
  var import_element276 = __toESM(require_element(), 1);
  var import_data226 = __toESM(require_data(), 1);
  var import_preferences25 = __toESM(require_preferences(), 1);

  // packages/views/build-module/load-view.mjs
  var import_data227 = __toESM(require_data(), 1);
  var import_preferences26 = __toESM(require_preferences(), 1);

  // packages/views/build-module/use-view-config.mjs
  var import_data228 = __toESM(require_data(), 1);
  var import_core_data125 = __toESM(require_core_data(), 1);

  // packages/views/build-module/lock-unlock.mjs
  var import_private_apis7 = __toESM(require_private_apis(), 1);
  var { lock: lock6, unlock: unlock6 } = (0, import_private_apis7.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
    "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
    "@wordpress/views"
  );

  // packages/views/build-module/use-view-config.mjs
  function useViewConfig({
    kind,
    name: name2
  }) {
    return (0, import_data228.useSelect)(
      (select7) => {
        return unlock6(select7(import_core_data125.store)).getViewConfig(kind, name2);
      },
      [kind, name2]
    );
  }

  // packages/editor/build-module/components/sidebar/dataform-post-summary.mjs
  var import_jsx_runtime477 = __toESM(require_jsx_runtime(), 1);
  var EMPTY_FORM = { layout: { type: "panel" }, fields: [] };
  function DataFormPostSummary({ onActionPerformed }) {
    const { postType: postType2, postId: postId2 } = (0, import_data229.useSelect)((select7) => {
      const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select7(store3);
      return {
        postType: getCurrentPostType2(),
        postId: getCurrentPostId2()
      };
    }, []);
    const { form: formConfig } = useViewConfig({
      kind: "postType",
      name: postType2
    });
    const form = formConfig ?? EMPTY_FORM;
    const record = (0, import_data229.useSelect)(
      (select7) => {
        if (!postType2 || !postId2) {
          return null;
        }
        return select7(import_core_data126.store).getEditedEntityRecord(
          "postType",
          postType2,
          postId2
        );
      },
      [postType2, postId2]
    );
    const templatePanelMode = usePostTemplatePanelMode();
    const availableTemplates = (0, import_data229.useSelect)((select7) => {
      if (select7(import_core_data126.store).getCurrentTheme()?.is_block_theme) {
        return null;
      }
      return select7(store3).getEditorSettings().availableTemplates ?? {};
    }, []);
    const augmentedRecord = (0, import_element277.useMemo)(() => {
      if (!record || !availableTemplates) {
        return record;
      }
      return {
        ...record,
        available_templates: availableTemplates
      };
    }, [record, availableTemplates]);
    const { editEntityRecord } = (0, import_data229.useDispatch)(import_core_data126.store);
    const _fields = post_fields_default({ postType: postType2 });
    const fields3 = (0, import_element277.useMemo)(
      () => _fields?.map((field) => {
        if (field.id === "status") {
          return {
            ...field,
            elements: field.elements.filter(
              (element) => element.value !== "trash"
            )
          };
        }
        if (field.id === "template") {
          if (!templatePanelMode) {
            return null;
          }
          if (templatePanelMode === "classic" && Object.keys(availableTemplates ?? {}).length === 0) {
            return {
              ...field,
              readOnly: true,
              render: () => (0, import_i18n292.__)("Default template")
            };
          }
          return field;
        }
        return field;
      }).filter(Boolean),
      [_fields, templatePanelMode, availableTemplates]
    );
    const onChange = (edits) => {
      if (edits.status && edits.status !== "future" && record?.status === "future" && new Date(record.date) > /* @__PURE__ */ new Date()) {
        edits.date = null;
      }
      if (edits.status && edits.status === "private" && record?.password) {
        edits.password = "";
      }
      editEntityRecord("postType", postType2, postId2, edits);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime477.jsx)(post_panel_section_default, { className: "editor-post-summary", children: /* @__PURE__ */ (0, import_jsx_runtime477.jsxs)(import_components260.__experimentalVStack, { spacing: 4, children: [
      /* @__PURE__ */ (0, import_jsx_runtime477.jsx)(
        PostCardPanel,
        {
          postType: postType2,
          postId: postId2,
          onActionPerformed
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime477.jsx)(
        DataForm,
        {
          data: augmentedRecord,
          fields: fields3,
          form,
          onChange
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime477.jsx)(PostTrash, { onActionPerformed })
    ] }) });
  }

  // packages/editor/build-module/components/post-content-information/index.mjs
  var import_components261 = __toESM(require_components(), 1);
  var import_data230 = __toESM(require_data(), 1);
  var import_i18n293 = __toESM(require_i18n(), 1);
  var import_wordcount5 = __toESM(require_wordcount(), 1);
  var import_element278 = __toESM(require_element(), 1);
  var import_core_data127 = __toESM(require_core_data(), 1);
  var import_jsx_runtime478 = __toESM(require_jsx_runtime(), 1);
  var AVERAGE_READING_RATE3 = 189;
  function PostContentInformation() {
    const postContent = (0, import_data230.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select7(store3);
      const { canUser } = select7(import_core_data127.store);
      const { getEntityRecord } = select7(import_core_data127.store);
      const siteSettings = canUser("read", {
        kind: "root",
        name: "site"
      }) ? getEntityRecord("root", "site") : void 0;
      const postType2 = getCurrentPostType2();
      const _id = getCurrentPostId2();
      const isPostsPage = +_id === siteSettings?.page_for_posts;
      const showPostContentInfo = !isPostsPage && ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(
        postType2
      );
      return showPostContentInfo && getEditedPostAttribute2("content");
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime478.jsx)(PostContentInformationUI, { postContent });
  }
  function PostContentInformationUI({ postContent }) {
    const wordCountType = (0, import_i18n293._x)("words", "Word count type. Do not translate!");
    const wordsCounted = (0, import_element278.useMemo)(
      () => postContent ? (0, import_wordcount5.count)(postContent, wordCountType) : 0,
      [postContent, wordCountType]
    );
    if (!wordsCounted) {
      return null;
    }
    const readingTime = Math.round(wordsCounted / AVERAGE_READING_RATE3);
    const wordsCountText = (0, import_i18n293.sprintf)(
      // translators: %s: the number of words in the post.
      (0, import_i18n293._n)("%s word", "%s words", wordsCounted),
      wordsCounted.toLocaleString()
    );
    const minutesText = readingTime <= 1 ? (0, import_i18n293.__)("1 minute") : (0, import_i18n293.sprintf)(
      /* translators: %s: the number of minutes to read the post. */
      (0, import_i18n293._n)("%s minute", "%s minutes", readingTime),
      readingTime.toLocaleString()
    );
    return /* @__PURE__ */ (0, import_jsx_runtime478.jsx)("div", { className: "editor-post-content-information", children: /* @__PURE__ */ (0, import_jsx_runtime478.jsx)(import_components261.__experimentalText, { children: (0, import_i18n293.sprintf)(
      /* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */
      (0, import_i18n293.__)("%1$s, %2$s read time."),
      wordsCountText,
      minutesText
    ) }) });
  }

  // packages/editor/build-module/components/post-format/panel.mjs
  var import_components262 = __toESM(require_components(), 1);
  var import_i18n294 = __toESM(require_i18n(), 1);
  var import_data231 = __toESM(require_data(), 1);
  var import_element279 = __toESM(require_element(), 1);
  var import_block_editor86 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime479 = __toESM(require_jsx_runtime(), 1);
  function PostFormat2() {
    const { postFormat } = (0, import_data231.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2 } = select7(store3);
      const _postFormat = getEditedPostAttribute2("format");
      return {
        postFormat: _postFormat ?? "standard"
      };
    }, []);
    const activeFormat = POST_FORMATS2.find(
      (format6) => format6.id === postFormat
    );
    const [popoverAnchor, setPopoverAnchor] = (0, import_element279.useState)(null);
    const popoverProps = (0, import_element279.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime479.jsx)(PostFormatCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime479.jsx)(post_panel_row_default, { label: (0, import_i18n294.__)("Format"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime479.jsx)(
      import_components262.Dropdown,
      {
        popoverProps,
        contentClassName: "editor-post-format__dialog",
        focusOnMount: true,
        renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime479.jsx)(
          import_components262.Button,
          {
            size: "compact",
            variant: "tertiary",
            "aria-expanded": isOpen2,
            "aria-label": (0, import_i18n294.sprintf)(
              // translators: %s: Current post format.
              (0, import_i18n294.__)("Change format: %s"),
              activeFormat?.caption
            ),
            onClick: onToggle,
            children: activeFormat?.caption
          }
        ),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime479.jsxs)("div", { className: "editor-post-format__dialog-content", children: [
          /* @__PURE__ */ (0, import_jsx_runtime479.jsx)(
            import_block_editor86.__experimentalInspectorPopoverHeader,
            {
              title: (0, import_i18n294.__)("Format"),
              onClose
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime479.jsx)(PostFormat, {})
        ] })
      }
    ) }) });
  }
  var panel_default4 = PostFormat2;

  // packages/editor/build-module/components/post-last-edited-panel/index.mjs
  var import_components263 = __toESM(require_components(), 1);
  var import_data232 = __toESM(require_data(), 1);
  var import_i18n295 = __toESM(require_i18n(), 1);
  var import_date20 = __toESM(require_date(), 1);
  var import_jsx_runtime480 = __toESM(require_jsx_runtime(), 1);
  function PostLastEditedPanel() {
    const modified = (0, import_data232.useSelect)(
      (select7) => select7(store3).getEditedPostAttribute("modified"),
      []
    );
    if (!modified) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime480.jsx)("div", { className: "editor-post-last-edited-panel", children: /* @__PURE__ */ (0, import_jsx_runtime480.jsx)(import_components263.__experimentalText, { children: (0, import_i18n295.sprintf)(
      // translators: %s: Human-readable time difference, e.g. "2 days ago".
      (0, import_i18n295.__)("Last edited %s."),
      (0, import_date20.humanTimeDiff)(modified)
    ) }) });
  }

  // packages/editor/build-module/components/blog-title/index.mjs
  var import_i18n296 = __toESM(require_i18n(), 1);
  var import_compose76 = __toESM(require_compose(), 1);
  var import_data233 = __toESM(require_data(), 1);
  var import_core_data128 = __toESM(require_core_data(), 1);
  var import_html_entities30 = __toESM(require_html_entities(), 1);
  var import_components264 = __toESM(require_components(), 1);
  var import_element280 = __toESM(require_element(), 1);
  var import_block_editor87 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime481 = __toESM(require_jsx_runtime(), 1);
  var EMPTY_OBJECT5 = {};
  function BlogTitle() {
    const { editEntityRecord } = (0, import_data233.useDispatch)(import_core_data128.store);
    const { postsPageTitle, postsPageId, isTemplate: isTemplate2, postSlug } = (0, import_data233.useSelect)(
      (select7) => {
        const { getEntityRecord, getEditedEntityRecord, canUser } = select7(import_core_data128.store);
        const siteSettings = canUser("read", {
          kind: "root",
          name: "site"
        }) ? getEntityRecord("root", "site") : void 0;
        const _postsPageRecord = siteSettings?.page_for_posts ? getEditedEntityRecord(
          "postType",
          "page",
          siteSettings?.page_for_posts
        ) : EMPTY_OBJECT5;
        const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
        return {
          postsPageId: _postsPageRecord?.id,
          postsPageTitle: _postsPageRecord?.title,
          isTemplate: getCurrentPostType2() === TEMPLATE_POST_TYPE,
          postSlug: getEditedPostAttribute2("slug")
        };
      },
      []
    );
    const [popoverAnchor, setPopoverAnchor] = (0, import_element280.useState)(null);
    const popoverProps = (0, import_element280.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    if (!isTemplate2 || !["home", "index"].includes(postSlug) || !postsPageId) {
      return null;
    }
    const setPostsPageTitle = (newValue) => {
      editEntityRecord("postType", "page", postsPageId, {
        title: newValue
      });
    };
    const decodedTitle = (0, import_html_entities30.decodeEntities)(postsPageTitle);
    return /* @__PURE__ */ (0, import_jsx_runtime481.jsx)(post_panel_row_default, { label: (0, import_i18n296.__)("Blog title"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime481.jsx)(
      import_components264.Dropdown,
      {
        popoverProps,
        contentClassName: "editor-blog-title-dropdown__content",
        focusOnMount: true,
        renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime481.jsx)(
          import_components264.Button,
          {
            size: "compact",
            variant: "tertiary",
            "aria-expanded": isOpen2,
            "aria-label": (0, import_i18n296.sprintf)(
              // translators: %s: Current post link.
              (0, import_i18n296.__)("Change blog title: %s"),
              decodedTitle
            ),
            onClick: onToggle,
            children: decodedTitle
          }
        ),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime481.jsxs)(import_jsx_runtime481.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime481.jsx)(
            import_block_editor87.__experimentalInspectorPopoverHeader,
            {
              title: (0, import_i18n296.__)("Blog title"),
              onClose
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime481.jsx)(
            import_components264.__experimentalInputControl,
            {
              placeholder: (0, import_i18n296.__)("No title"),
              size: "__unstable-large",
              value: postsPageTitle,
              onChange: (0, import_compose76.debounce)(setPostsPageTitle, 300),
              label: (0, import_i18n296.__)("Blog title"),
              help: (0, import_i18n296.__)(
                "Set the Posts Page title. Appears in search results, and when the page is shared on social media."
              ),
              hideLabelFromVision: true
            }
          )
        ] })
      }
    ) });
  }

  // packages/editor/build-module/components/posts-per-page/index.mjs
  var import_i18n297 = __toESM(require_i18n(), 1);
  var import_data234 = __toESM(require_data(), 1);
  var import_core_data129 = __toESM(require_core_data(), 1);
  var import_components265 = __toESM(require_components(), 1);
  var import_element281 = __toESM(require_element(), 1);
  var import_block_editor88 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime482 = __toESM(require_jsx_runtime(), 1);
  function PostsPerPage() {
    const { editEntityRecord } = (0, import_data234.useDispatch)(import_core_data129.store);
    const { postsPerPage, isTemplate: isTemplate2, postSlug } = (0, import_data234.useSelect)((select7) => {
      const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
      const { getEditedEntityRecord, canUser } = select7(import_core_data129.store);
      const siteSettings = canUser("read", {
        kind: "root",
        name: "site"
      }) ? getEditedEntityRecord("root", "site") : void 0;
      return {
        isTemplate: getCurrentPostType2() === TEMPLATE_POST_TYPE,
        postSlug: getEditedPostAttribute2("slug"),
        postsPerPage: siteSettings?.posts_per_page || 1
      };
    }, []);
    const [popoverAnchor, setPopoverAnchor] = (0, import_element281.useState)(null);
    const popoverProps = (0, import_element281.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    if (!isTemplate2 || !["home", "index"].includes(postSlug)) {
      return null;
    }
    const setPostsPerPage = (newValue) => {
      editEntityRecord("root", "site", void 0, {
        posts_per_page: newValue
      });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime482.jsx)(post_panel_row_default, { label: (0, import_i18n297.__)("Posts per page"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime482.jsx)(
      import_components265.Dropdown,
      {
        popoverProps,
        contentClassName: "editor-posts-per-page-dropdown__content",
        focusOnMount: true,
        renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime482.jsx)(
          import_components265.Button,
          {
            size: "compact",
            variant: "tertiary",
            "aria-expanded": isOpen2,
            "aria-label": (0, import_i18n297.__)("Change posts per page"),
            onClick: onToggle,
            children: postsPerPage
          }
        ),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime482.jsxs)(import_jsx_runtime482.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime482.jsx)(
            import_block_editor88.__experimentalInspectorPopoverHeader,
            {
              title: (0, import_i18n297.__)("Posts per page"),
              onClose
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime482.jsx)(
            import_components265.__experimentalNumberControl,
            {
              placeholder: 0,
              value: postsPerPage,
              size: "__unstable-large",
              spinControls: "custom",
              step: "1",
              min: "1",
              onChange: setPostsPerPage,
              label: (0, import_i18n297.__)("Posts per page"),
              help: (0, import_i18n297.__)(
                "Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting."
              ),
              hideLabelFromVision: true
            }
          )
        ] })
      }
    ) });
  }

  // packages/editor/build-module/components/site-discussion/index.mjs
  var import_i18n298 = __toESM(require_i18n(), 1);
  var import_data235 = __toESM(require_data(), 1);
  var import_core_data130 = __toESM(require_core_data(), 1);
  var import_components266 = __toESM(require_components(), 1);
  var import_element282 = __toESM(require_element(), 1);
  var import_block_editor89 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime483 = __toESM(require_jsx_runtime(), 1);
  var COMMENT_OPTIONS2 = [
    {
      label: (0, import_i18n298._x)("Open", 'Adjective: e.g. "Comments are open"'),
      value: "open",
      description: (0, import_i18n298.__)("Visitors can add new comments and replies.")
    },
    {
      label: (0, import_i18n298.__)("Closed"),
      value: "",
      description: [
        (0, import_i18n298.__)("Visitors cannot add new comments or replies."),
        (0, import_i18n298.__)("Existing comments remain visible.")
      ].join(" ")
    }
  ];
  function SiteDiscussion() {
    const { editEntityRecord } = (0, import_data235.useDispatch)(import_core_data130.store);
    const { allowCommentsOnNewPosts, isTemplate: isTemplate2, postSlug } = (0, import_data235.useSelect)(
      (select7) => {
        const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
        const { getEditedEntityRecord, canUser } = select7(import_core_data130.store);
        const siteSettings = canUser("read", {
          kind: "root",
          name: "site"
        }) ? getEditedEntityRecord("root", "site") : void 0;
        return {
          isTemplate: getCurrentPostType2() === TEMPLATE_POST_TYPE,
          postSlug: getEditedPostAttribute2("slug"),
          allowCommentsOnNewPosts: siteSettings?.default_comment_status || ""
        };
      },
      []
    );
    const [popoverAnchor, setPopoverAnchor] = (0, import_element282.useState)(null);
    const popoverProps = (0, import_element282.useMemo)(
      () => ({
        // Anchor the popover to the middle of the entire row so that it doesn't
        // move around when the label changes.
        anchor: popoverAnchor,
        placement: "left-start",
        offset: 36,
        shift: true
      }),
      [popoverAnchor]
    );
    if (!isTemplate2 || !["home", "index"].includes(postSlug)) {
      return null;
    }
    const setAllowCommentsOnNewPosts = (newValue) => {
      editEntityRecord("root", "site", void 0, {
        default_comment_status: newValue ? "open" : null
      });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime483.jsx)(post_panel_row_default, { label: (0, import_i18n298.__)("Discussion"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime483.jsx)(
      import_components266.Dropdown,
      {
        popoverProps,
        contentClassName: "editor-site-discussion-dropdown__content",
        focusOnMount: true,
        renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime483.jsx)(
          import_components266.Button,
          {
            size: "compact",
            variant: "tertiary",
            "aria-expanded": isOpen2,
            "aria-label": (0, import_i18n298.__)("Change discussion settings"),
            onClick: onToggle,
            children: allowCommentsOnNewPosts ? (0, import_i18n298.__)("Comments open") : (0, import_i18n298.__)("Comments closed")
          }
        ),
        renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime483.jsxs)(import_jsx_runtime483.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime483.jsx)(
            import_block_editor89.__experimentalInspectorPopoverHeader,
            {
              title: (0, import_i18n298.__)("Discussion"),
              onClose
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime483.jsxs)(import_components266.__experimentalVStack, { spacing: 3, children: [
            /* @__PURE__ */ (0, import_jsx_runtime483.jsx)(import_components266.__experimentalText, { children: (0, import_i18n298.__)(
              "Changes will apply to new posts only. Individual posts may override these settings."
            ) }),
            /* @__PURE__ */ (0, import_jsx_runtime483.jsx)(
              import_components266.RadioControl,
              {
                className: "editor-site-discussion__options",
                hideLabelFromVision: true,
                label: (0, import_i18n298.__)("Comment status"),
                options: COMMENT_OPTIONS2,
                onChange: setAllowCommentsOnNewPosts,
                selected: allowCommentsOnNewPosts
              }
            )
          ] })
        ] })
      }
    ) });
  }

  // packages/editor/build-module/components/sidebar/post-summary.mjs
  var import_jsx_runtime484 = __toESM(require_jsx_runtime(), 1);
  var PANEL_NAME5 = "post-status";
  function PostSummary({ onActionPerformed }) {
    const postType2 = (0, import_data236.useSelect)(
      (select7) => select7(store3).getCurrentPostType(),
      []
    );
    if (window?.__experimentalDataFormInspector && ["page", "post"].includes(postType2)) {
      return /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(DataFormPostSummary, { onActionPerformed });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(ClassicPostSummary, { onActionPerformed });
  }
  function ClassicPostSummary({ onActionPerformed }) {
    const { isRemovedPostStatusPanel, postType: postType2, postId: postId2 } = (0, import_data236.useSelect)(
      (select7) => {
        const {
          isEditorPanelRemoved: isEditorPanelRemoved2,
          getCurrentPostType: getCurrentPostType2,
          getCurrentPostId: getCurrentPostId2
        } = select7(store3);
        return {
          isRemovedPostStatusPanel: isEditorPanelRemoved2(PANEL_NAME5),
          postType: getCurrentPostType2(),
          postId: getCurrentPostId2()
        };
      },
      []
    );
    return /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(post_panel_section_default, { className: "editor-post-summary", children: /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(plugin_post_status_info_default.Slot, { children: (fills) => /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(import_jsx_runtime484.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime484.jsxs)(import_components267.__experimentalVStack, { spacing: 4, children: [
      /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(
        PostCardPanel,
        {
          postType: postType2,
          postId: postId2,
          onActionPerformed
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PostFeaturedImagePanel, { withPanelBody: false }),
      /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PrivatePostExcerptPanel, {}),
      /* @__PURE__ */ (0, import_jsx_runtime484.jsxs)(import_components267.__experimentalVStack, { spacing: 1, children: [
        /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PostContentInformation, {}),
        /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PostLastEditedPanel, {})
      ] }),
      !isRemovedPostStatusPanel && /* @__PURE__ */ (0, import_jsx_runtime484.jsxs)(import_components267.__experimentalVStack, { spacing: 4, children: [
        /* @__PURE__ */ (0, import_jsx_runtime484.jsxs)(import_components267.__experimentalVStack, { spacing: 1, children: [
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PostStatus, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PostSchedulePanel, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PostURLPanel, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(panel_default, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PostTemplatePanel, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PostDiscussionPanel, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PrivatePostLastRevision, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PageAttributesPanel, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PostSyncStatus, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(BlogTitle, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(PostsPerPage, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(SiteDiscussion, {}),
          /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(panel_default4, {}),
          fills
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime484.jsx)(
          PostTrash,
          {
            onActionPerformed
          }
        )
      ] })
    ] }) }) }) });
  }

  // packages/editor/build-module/components/sidebar/post-revision-summary.mjs
  var import_data240 = __toESM(require_data(), 1);
  var import_components270 = __toESM(require_components(), 1);
  var import_i18n302 = __toESM(require_i18n(), 1);
  var import_url23 = __toESM(require_url(), 1);

  // packages/editor/build-module/components/revision-author-panel/index.mjs
  var import_data237 = __toESM(require_data(), 1);
  var import_core_data131 = __toESM(require_core_data(), 1);
  var import_html_entities31 = __toESM(require_html_entities(), 1);
  var import_i18n299 = __toESM(require_i18n(), 1);
  var import_jsx_runtime485 = __toESM(require_jsx_runtime(), 1);
  function RevisionAuthorPanel() {
    const authorName = (0, import_data237.useSelect)((select7) => {
      const { getCurrentRevision: getCurrentRevision2 } = unlock(select7(store3));
      const revision = getCurrentRevision2();
      if (!revision?.author) {
        return null;
      }
      const author = select7(import_core_data131.store).getUser(revision.author);
      return author?.name;
    }, []);
    if (!authorName) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime485.jsx)(post_panel_row_default, { label: (0, import_i18n299.__)("Author"), children: (0, import_html_entities31.decodeEntities)(authorName) });
  }

  // packages/editor/build-module/components/revision-created-panel/index.mjs
  var import_components268 = __toESM(require_components(), 1);
  var import_data238 = __toESM(require_data(), 1);
  var import_i18n300 = __toESM(require_i18n(), 1);
  var import_date21 = __toESM(require_date(), 1);
  var import_jsx_runtime486 = __toESM(require_jsx_runtime(), 1);
  function RevisionCreatedPanel() {
    const date = (0, import_data238.useSelect)((select7) => {
      const { getCurrentRevision: getCurrentRevision2 } = unlock(select7(store3));
      return getCurrentRevision2()?.date;
    }, []);
    if (!date) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime486.jsx)("div", { className: "editor-post-last-edited-panel", children: /* @__PURE__ */ (0, import_jsx_runtime486.jsx)(import_components268.__experimentalText, { children: (0, import_i18n300.sprintf)(
      // translators: %s: Human-readable time difference, e.g. "2 days ago".
      (0, import_i18n300.__)("Created %s."),
      (0, import_date21.humanTimeDiff)(date)
    ) }) });
  }

  // packages/editor/build-module/components/revision-fields-diff/index.mjs
  var import_word2 = __toESM(require_word(), 1);
  var import_data239 = __toESM(require_data(), 1);
  var import_element283 = __toESM(require_element(), 1);
  var import_i18n301 = __toESM(require_i18n(), 1);

  // packages/editor/build-module/components/revision-diff-panel/index.mjs
  var import_components269 = __toESM(require_components(), 1);
  var import_jsx_runtime487 = __toESM(require_jsx_runtime(), 1);
  function RevisionDiffPanel({ title, entries, initialOpen }) {
    if (!entries) {
      return null;
    }
    const fields3 = Object.entries(entries).map(([key, parts]) => /* @__PURE__ */ (0, import_jsx_runtime487.jsx)(post_panel_row_default, { label: key, children: /* @__PURE__ */ (0, import_jsx_runtime487.jsx)("span", { className: "editor-revision-fields-diff__value", children: parts.map((part, index) => {
      if (part.added) {
        return /* @__PURE__ */ (0, import_jsx_runtime487.jsx)(
          "ins",
          {
            className: "editor-revision-fields-diff__added",
            children: part.value
          },
          index
        );
      }
      if (part.removed) {
        return /* @__PURE__ */ (0, import_jsx_runtime487.jsx)(
          "del",
          {
            className: "editor-revision-fields-diff__removed",
            children: part.value
          },
          index
        );
      }
      return /* @__PURE__ */ (0, import_jsx_runtime487.jsx)("span", { children: part.value }, index);
    }) }) }, key));
    return /* @__PURE__ */ (0, import_jsx_runtime487.jsx)(import_components269.PanelBody, { title, initialOpen, children: fields3 });
  }

  // packages/editor/build-module/components/revision-fields-diff/index.mjs
  var import_jsx_runtime488 = __toESM(require_jsx_runtime(), 1);
  function stringifyValue2(value) {
    if (value === null || value === void 0) {
      return "";
    }
    if (typeof value === "object") {
      return JSON.stringify(value, null, 2);
    }
    return String(value);
  }
  function RevisionFieldsDiffPanel() {
    const { revision, previousRevision } = (0, import_data239.useSelect)((select7) => {
      const { getCurrentRevision: getCurrentRevision2, getPreviousRevision: getPreviousRevision2 } = unlock(
        select7(store3)
      );
      return {
        revision: getCurrentRevision2(),
        previousRevision: getPreviousRevision2()
      };
    }, []);
    const entries = (0, import_element283.useMemo)(() => {
      if (!revision) {
        return null;
      }
      const revisionMeta = revision.meta ?? {};
      const previousMeta = previousRevision?.meta ?? {};
      const allMetaKeys = /* @__PURE__ */ new Set([
        ...Object.keys(revisionMeta),
        ...Object.keys(previousMeta)
      ]);
      const result = {};
      for (const key of allMetaKeys) {
        const revStr = stringifyValue2(revisionMeta[key]);
        const prevStr = stringifyValue2(previousMeta[key]);
        if (!revStr && !prevStr) {
          continue;
        }
        result[key] = (0, import_word2.diffWords)(prevStr, revStr);
      }
      if (Object.keys(result).length === 0) {
        return null;
      }
      return result;
    }, [revision, previousRevision]);
    return /* @__PURE__ */ (0, import_jsx_runtime488.jsx)(
      RevisionDiffPanel,
      {
        title: (0, import_i18n301.__)("Meta"),
        entries,
        initialOpen: false
      }
    );
  }

  // packages/editor/build-module/components/sidebar/post-revision-summary.mjs
  var import_jsx_runtime489 = __toESM(require_jsx_runtime(), 1);
  function PostRevisionSummary() {
    const { revisionId: revisionId2, postId: postId2, postContent } = (0, import_data240.useSelect)((select7) => {
      const { getCurrentRevisionId: getCurrentRevisionId2, getCurrentRevision: getCurrentRevision2, getCurrentPostId: getCurrentPostId2 } = unlock(select7(store3));
      const _revisionId = getCurrentRevisionId2();
      return {
        revisionId: _revisionId,
        postId: getCurrentPostId2(),
        postContent: _revisionId && getCurrentRevision2()?.content?.raw
      };
    }, []);
    if (!revisionId2) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime489.jsxs)(import_jsx_runtime489.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime489.jsx)(post_panel_section_default, { className: "editor-post-summary", children: /* @__PURE__ */ (0, import_jsx_runtime489.jsxs)(import_components270.__experimentalVStack, { spacing: 4, children: [
        /* @__PURE__ */ (0, import_jsx_runtime489.jsx)(PostCardPanel, { postId: postId2, hideActions: true }),
        /* @__PURE__ */ (0, import_jsx_runtime489.jsxs)(import_components270.__experimentalVStack, { spacing: 1, children: [
          /* @__PURE__ */ (0, import_jsx_runtime489.jsx)(PostContentInformationUI, { postContent }),
          /* @__PURE__ */ (0, import_jsx_runtime489.jsx)(RevisionCreatedPanel, {})
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime489.jsx)(
          import_components270.ExternalLink,
          {
            href: (0, import_url23.addQueryArgs)("revision.php", {
              revision: revisionId2
            }),
            children: (0, import_i18n302.__)("Open classic revisions screen")
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime489.jsx)(RevisionAuthorPanel, {})
      ] }) }),
      /* @__PURE__ */ (0, import_jsx_runtime489.jsx)(RevisionFieldsDiffPanel, {})
    ] });
  }

  // packages/editor/build-module/components/post-transform-panel/index.mjs
  var import_data242 = __toESM(require_data(), 1);
  var import_core_data133 = __toESM(require_core_data(), 1);
  var import_components271 = __toESM(require_components(), 1);
  var import_i18n303 = __toESM(require_i18n(), 1);
  var import_block_editor90 = __toESM(require_block_editor(), 1);
  var import_blocks34 = __toESM(require_blocks(), 1);

  // packages/editor/build-module/components/post-transform-panel/hooks.mjs
  var import_data241 = __toESM(require_data(), 1);
  var import_element284 = __toESM(require_element(), 1);
  var import_core_data132 = __toESM(require_core_data(), 1);
  var import_blocks33 = __toESM(require_blocks(), 1);
  var import_patterns10 = __toESM(require_patterns(), 1);
  var { EXCLUDED_PATTERN_SOURCES, PATTERN_TYPES: PATTERN_TYPES5 } = unlock(import_patterns10.privateApis);
  function injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet) {
    block.innerBlocks = block.innerBlocks.map((innerBlock) => {
      return injectThemeAttributeInBlockTemplateContent(
        innerBlock,
        currentThemeStylesheet
      );
    });
    if (block.name === "core/template-part" && block.attributes.theme === void 0) {
      block.attributes.theme = currentThemeStylesheet;
    }
    return block;
  }
  function filterPatterns(patterns2, template2) {
    const filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex((item) => currentItem.name === item.name);
    const filterOutExcludedPatternSources = (pattern) => {
      if (template2.area === "navigation-overlay" && pattern.blockTypes?.includes(
        "core/template-part/navigation-overlay"
      )) {
        return true;
      }
      return !EXCLUDED_PATTERN_SOURCES.includes(pattern.source);
    };
    const filterCompatiblePatterns = (pattern) => pattern.templateTypes?.includes(template2.slug) || pattern.blockTypes?.includes("core/template-part/" + template2.area);
    return patterns2.filter((pattern, index, items) => {
      return filterOutDuplicatesByName(pattern, index, items) && filterOutExcludedPatternSources(pattern) && filterCompatiblePatterns(pattern);
    });
  }
  function preparePatterns(patterns2, currentThemeStylesheet) {
    return patterns2.map((pattern) => ({
      ...pattern,
      keywords: pattern.keywords || [],
      type: PATTERN_TYPES5.theme,
      blocks: (0, import_blocks33.parse)(pattern.content, {
        __unstableSkipMigrationLogs: true
      }).map(
        (block) => injectThemeAttributeInBlockTemplateContent(
          block,
          currentThemeStylesheet
        )
      )
    }));
  }
  function useAvailablePatterns({ area, name: name2, slug }) {
    const { blockPatterns, restBlockPatterns, currentThemeStylesheet } = (0, import_data241.useSelect)((select7) => {
      const { getEditorSettings: getEditorSettings2 } = select7(store3);
      const settings = getEditorSettings2();
      return {
        blockPatterns: settings.__experimentalAdditionalBlockPatterns ?? settings.__experimentalBlockPatterns,
        restBlockPatterns: select7(import_core_data132.store).getBlockPatterns(),
        currentThemeStylesheet: select7(import_core_data132.store).getCurrentTheme().stylesheet
      };
    }, []);
    return (0, import_element284.useMemo)(() => {
      const mergedPatterns = [
        ...blockPatterns || [],
        ...restBlockPatterns || []
      ];
      const filteredPatterns = filterPatterns(mergedPatterns, {
        area,
        name: name2,
        slug
      });
      return preparePatterns(filteredPatterns, currentThemeStylesheet);
    }, [
      area,
      name2,
      slug,
      blockPatterns,
      restBlockPatterns,
      currentThemeStylesheet
    ]);
  }

  // packages/editor/build-module/components/post-transform-panel/index.mjs
  var import_jsx_runtime490 = __toESM(require_jsx_runtime(), 1);
  function TemplatesList2({ availableTemplates, onSelect }) {
    if (!availableTemplates || availableTemplates?.length === 0) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime490.jsx)(
      import_block_editor90.__experimentalBlockPatternsList,
      {
        label: (0, import_i18n303.__)("Templates"),
        blockPatterns: availableTemplates,
        onClickPattern: onSelect,
        showTitlesAsTooltip: true
      }
    );
  }
  function PostTransform() {
    const { area, name: name2, slug, postType: postType2, postId: postId2 } = (0, import_data242.useSelect)((select7) => {
      const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select7(store3);
      const { getEditedEntityRecord } = select7(import_core_data133.store);
      const type = getCurrentPostType2();
      const id = getCurrentPostId2();
      const record = getEditedEntityRecord("postType", type, id);
      return {
        area: record?.area,
        name: record?.name,
        slug: record?.slug,
        postType: type,
        postId: id
      };
    }, []);
    const { editEntityRecord } = (0, import_data242.useDispatch)(import_core_data133.store);
    const availablePatterns = useAvailablePatterns({ area, name: name2, slug });
    const onTemplateSelect = async (selectedTemplate) => {
      await editEntityRecord("postType", postType2, postId2, {
        blocks: selectedTemplate.blocks,
        content: (0, import_blocks34.serialize)(selectedTemplate.blocks)
      });
    };
    if (!availablePatterns?.length) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime490.jsx)(
      import_components271.PanelBody,
      {
        title: (0, import_i18n303.__)("Design"),
        initialOpen: postType2 === TEMPLATE_PART_POST_TYPE,
        children: /* @__PURE__ */ (0, import_jsx_runtime490.jsx)(
          TemplatesList2,
          {
            availableTemplates: availablePatterns,
            onSelect: onTemplateSelect
          }
        )
      }
    );
  }
  function PostTransformPanel() {
    const { postType: postType2 } = (0, import_data242.useSelect)((select7) => {
      const { getCurrentPostType: getCurrentPostType2 } = select7(store3);
      return {
        postType: getCurrentPostType2()
      };
    }, []);
    if (![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(postType2)) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime490.jsx)(PostTransform, {});
  }

  // packages/editor/build-module/components/sidebar/header.mjs
  var import_components272 = __toESM(require_components(), 1);
  var import_i18n304 = __toESM(require_i18n(), 1);
  var import_data243 = __toESM(require_data(), 1);
  var import_element285 = __toESM(require_element(), 1);
  var import_html_entities32 = __toESM(require_html_entities(), 1);
  var import_jsx_runtime491 = __toESM(require_jsx_runtime(), 1);
  var { Tabs: Tabs5 } = unlock(import_components272.privateApis);
  var SidebarHeader = (_, ref) => {
    const { postTypeLabel, isAttachment, isRevisionsMode: isRevisionsMode2 } = (0, import_data243.useSelect)(
      (select7) => {
        const { getPostTypeLabel: getPostTypeLabel2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
        const { isRevisionsMode: _isRevisionsMode } = unlock(
          select7(store3)
        );
        return {
          postTypeLabel: getPostTypeLabel2(),
          isAttachment: getCurrentPostType2() === ATTACHMENT_POST_TYPE && window?.__experimentalMediaEditor,
          isRevisionsMode: _isRevisionsMode()
        };
      },
      []
    );
    let documentLabel;
    if (isRevisionsMode2) {
      documentLabel = (0, import_i18n304.__)("Revision");
    } else if (postTypeLabel) {
      documentLabel = (0, import_html_entities32.decodeEntities)(postTypeLabel);
    } else {
      documentLabel = (0, import_i18n304._x)("Document", "noun, panel");
    }
    return /* @__PURE__ */ (0, import_jsx_runtime491.jsxs)(Tabs5.TabList, { ref, children: [
      /* @__PURE__ */ (0, import_jsx_runtime491.jsx)(
        Tabs5.Tab,
        {
          tabId: sidebars.document,
          "data-tab-id": sidebars.document,
          children: documentLabel
        }
      ),
      !isAttachment && /* @__PURE__ */ (0, import_jsx_runtime491.jsx)(
        Tabs5.Tab,
        {
          tabId: sidebars.block,
          "data-tab-id": sidebars.block,
          children: (0, import_i18n304.__)("Block")
        }
      )
    ] });
  };
  var header_default3 = (0, import_element285.forwardRef)(SidebarHeader);

  // packages/editor/build-module/components/template-actions-panel/index.mjs
  var import_data246 = __toESM(require_data(), 1);

  // packages/editor/build-module/components/template-actions-panel/block-theme-content.mjs
  var import_data244 = __toESM(require_data(), 1);
  var import_core_data134 = __toESM(require_core_data(), 1);
  var import_block_editor91 = __toESM(require_block_editor(), 1);
  var import_components273 = __toESM(require_components(), 1);
  var import_element286 = __toESM(require_element(), 1);
  var import_i18n305 = __toESM(require_i18n(), 1);
  var import_html_entities33 = __toESM(require_html_entities(), 1);
  var import_notices33 = __toESM(require_notices(), 1);
  var import_preferences27 = __toESM(require_preferences(), 1);
  var import_jsx_runtime492 = __toESM(require_jsx_runtime(), 1);
  function TemplateActionsPanelContent() {
    const templateId2 = (0, import_data244.useSelect)(
      (select7) => select7(store3).getCurrentTemplateId(),
      []
    );
    const [isCreateModalOpen, setIsCreateModalOpen] = (0, import_element286.useState)(false);
    const [isSwapModalOpen, setIsSwapModalOpen] = (0, import_element286.useState)(false);
    const availableTemplates = useAvailableTemplates();
    const hasSwapTargets = !!availableTemplates?.length;
    const {
      onNavigateToEntityRecord,
      canCreateTemplate,
      hasGoBack,
      getEditorSettings: getEditorSettings2
    } = (0, import_data244.useSelect)((select7) => {
      const { getEditorSettings: _getEditorSettings } = select7(store3);
      const editorSettings2 = _getEditorSettings();
      return {
        onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord,
        canCreateTemplate: !!select7(import_core_data134.store).canUser("create", {
          kind: "postType",
          name: "wp_template"
        }),
        hasGoBack: editorSettings2.hasOwnProperty(
          "onNavigateToPreviousEntityRecord"
        ),
        getEditorSettings: _getEditorSettings
      };
    }, []);
    const { get: getPreference } = (0, import_data244.useSelect)(import_preferences27.store);
    const { createSuccessNotice } = (0, import_data244.useDispatch)(import_notices33.store);
    const { editedRecord: template2, hasResolved } = (0, import_core_data134.useEntityRecord)(
      "postType",
      "wp_template",
      templateId2
    );
    const [blocks] = (0, import_core_data134.useEntityBlockEditor)("postType", "wp_template", {
      id: templateId2
    });
    if (!hasResolved) {
      return null;
    }
    const notificationAction = hasGoBack ? [
      {
        label: (0, import_i18n305.__)("Go back"),
        onClick: () => getEditorSettings2().onNavigateToPreviousEntityRecord()
      }
    ] : void 0;
    const mayShowTemplateEditNotice = () => {
      if (!getPreference("core/edit-site", "welcomeGuideTemplate")) {
        createSuccessNotice(
          (0, import_i18n305.__)(
            "Editing template. Changes made here affect all posts and pages that use the template."
          ),
          { type: "snackbar", actions: notificationAction }
        );
      }
    };
    const templateName = (0, import_html_entities33.decodeEntities)(template2.title);
    const previewContent = !!blocks?.length && /* @__PURE__ */ (0, import_jsx_runtime492.jsx)(import_block_editor91.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime492.jsx)(import_block_editor91.BlockPreview, { blocks }) });
    const renderPreview = () => {
      if (!previewContent) {
        return null;
      }
      if (hasSwapTargets) {
        const tooltipText = (0, import_i18n305.__)("Change template");
        return /* @__PURE__ */ (0, import_jsx_runtime492.jsx)(import_components273.Tooltip, { text: tooltipText, children: /* @__PURE__ */ (0, import_jsx_runtime492.jsx)(
          "div",
          {
            className: "editor-template-actions-panel__preview",
            role: "button",
            tabIndex: 0,
            "aria-label": tooltipText,
            onClick: () => setIsSwapModalOpen(true),
            onKeyPress: () => setIsSwapModalOpen(true),
            children: previewContent
          }
        ) });
      }
      return /* @__PURE__ */ (0, import_jsx_runtime492.jsx)("div", { className: "editor-template-actions-panel__preview", children: previewContent });
    };
    return /* @__PURE__ */ (0, import_jsx_runtime492.jsxs)(import_jsx_runtime492.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime492.jsx)(
        import_components273.PanelBody,
        {
          title: (0, import_i18n305.sprintf)(
            /* translators: %s: template name */
            (0, import_i18n305.__)("Template: %s"),
            templateName
          ),
          initialOpen: false,
          children: /* @__PURE__ */ (0, import_jsx_runtime492.jsxs)(import_components273.__experimentalVStack, { children: [
            renderPreview(),
            /* @__PURE__ */ (0, import_jsx_runtime492.jsxs)(import_components273.__experimentalHStack, { children: [
              onNavigateToEntityRecord && /* @__PURE__ */ (0, import_jsx_runtime492.jsx)(
                import_components273.Button,
                {
                  className: "editor-template-actions-panel__action",
                  __next40pxDefaultSize: true,
                  variant: "secondary",
                  onClick: () => {
                    onNavigateToEntityRecord({
                      postId: template2.id,
                      postType: "wp_template"
                    });
                    mayShowTemplateEditNotice();
                  },
                  children: (0, import_i18n305.__)("Edit")
                }
              ),
              canCreateTemplate && /* @__PURE__ */ (0, import_jsx_runtime492.jsx)(
                import_components273.Button,
                {
                  className: "editor-template-actions-panel__action",
                  __next40pxDefaultSize: true,
                  variant: "secondary",
                  onClick: () => setIsCreateModalOpen(true),
                  children: (0, import_i18n305.__)("Create new")
                }
              )
            ] })
          ] })
        }
      ),
      isCreateModalOpen && /* @__PURE__ */ (0, import_jsx_runtime492.jsx)(
        CreateNewTemplateModal,
        {
          onClose: () => setIsCreateModalOpen(false)
        }
      ),
      isSwapModalOpen && /* @__PURE__ */ (0, import_jsx_runtime492.jsx)(
        SwapTemplateModal,
        {
          onRequestClose: () => setIsSwapModalOpen(false)
        }
      )
    ] });
  }

  // packages/editor/build-module/components/template-actions-panel/classic-theme-content.mjs
  var import_data245 = __toESM(require_data(), 1);
  var import_core_data135 = __toESM(require_core_data(), 1);
  var import_block_editor92 = __toESM(require_block_editor(), 1);
  var import_components274 = __toESM(require_components(), 1);
  var import_element287 = __toESM(require_element(), 1);
  var import_i18n306 = __toESM(require_i18n(), 1);
  var import_html_entities34 = __toESM(require_html_entities(), 1);
  var import_notices34 = __toESM(require_notices(), 1);
  var import_preferences28 = __toESM(require_preferences(), 1);
  var import_jsx_runtime493 = __toESM(require_jsx_runtime(), 1);
  function ClassicThemeContent() {
    const templateId2 = (0, import_data245.useSelect)(
      (select7) => select7(store3).getCurrentTemplateId(),
      []
    );
    const [isCreateModalOpen, setIsCreateModalOpen] = (0, import_element287.useState)(false);
    const {
      onNavigateToEntityRecord,
      canCreateTemplate,
      hasGoBack,
      getEditorSettings: getEditorSettings2
    } = (0, import_data245.useSelect)((select7) => {
      const { getEditorSettings: _getEditorSettings } = select7(store3);
      const editorSettings2 = _getEditorSettings();
      return {
        onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord,
        canCreateTemplate: !!select7(import_core_data135.store).canUser("create", {
          kind: "postType",
          name: "wp_template"
        }) && editorSettings2.supportsTemplateMode,
        hasGoBack: editorSettings2.hasOwnProperty(
          "onNavigateToPreviousEntityRecord"
        ),
        getEditorSettings: _getEditorSettings
      };
    }, []);
    const { get: getPreference } = (0, import_data245.useSelect)(import_preferences28.store);
    const { createSuccessNotice } = (0, import_data245.useDispatch)(import_notices34.store);
    const { editedRecord: template2 } = (0, import_core_data135.useEntityRecord)(
      "postType",
      "wp_template",
      templateId2
    );
    const [blocks] = (0, import_core_data135.useEntityBlockEditor)("postType", "wp_template", {
      id: templateId2
    });
    if (!templateId2 && !canCreateTemplate) {
      return null;
    }
    const notificationAction = hasGoBack ? [
      {
        label: (0, import_i18n306.__)("Go back"),
        onClick: () => getEditorSettings2().onNavigateToPreviousEntityRecord()
      }
    ] : void 0;
    const mayShowTemplateEditNotice = () => {
      if (!getPreference("core/edit-site", "welcomeGuideTemplate")) {
        createSuccessNotice(
          (0, import_i18n306.__)(
            "Editing template. Changes made here affect all posts and pages that use the template."
          ),
          { type: "snackbar", actions: notificationAction }
        );
      }
    };
    const templateName = template2 ? (0, import_html_entities34.decodeEntities)(template2.title) : void 0;
    const previewContent = !!blocks?.length && /* @__PURE__ */ (0, import_jsx_runtime493.jsx)(import_block_editor92.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime493.jsx)(import_block_editor92.BlockPreview, { blocks }) });
    return /* @__PURE__ */ (0, import_jsx_runtime493.jsxs)(import_jsx_runtime493.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime493.jsx)(
        import_components274.PanelBody,
        {
          title: template2 ? (0, import_i18n306.sprintf)(
            /* translators: %s: template name */
            (0, import_i18n306.__)("Template: %s"),
            templateName
          ) : (0, import_i18n306.__)("Template"),
          initialOpen: false,
          children: /* @__PURE__ */ (0, import_jsx_runtime493.jsxs)(import_components274.__experimentalVStack, { children: [
            !templateId2 && /* @__PURE__ */ (0, import_jsx_runtime493.jsx)(import_components274.__experimentalText, { children: (0, import_i18n306.__)(
              "This page uses a classic template. To edit this template with blocks, create a block template."
            ) }),
            template2 && previewContent && /* @__PURE__ */ (0, import_jsx_runtime493.jsx)("div", { className: "editor-template-actions-panel__preview", children: previewContent }),
            /* @__PURE__ */ (0, import_jsx_runtime493.jsxs)(import_components274.__experimentalHStack, { children: [
              template2 && onNavigateToEntityRecord && /* @__PURE__ */ (0, import_jsx_runtime493.jsx)(
                import_components274.Button,
                {
                  className: "editor-template-actions-panel__action",
                  __next40pxDefaultSize: true,
                  variant: "secondary",
                  onClick: () => {
                    onNavigateToEntityRecord({
                      postId: template2.id,
                      postType: "wp_template"
                    });
                    mayShowTemplateEditNotice();
                  },
                  children: (0, import_i18n306.__)("Edit")
                }
              ),
              canCreateTemplate && /* @__PURE__ */ (0, import_jsx_runtime493.jsx)(
                import_components274.Button,
                {
                  className: "editor-template-actions-panel__action",
                  __next40pxDefaultSize: true,
                  variant: "secondary",
                  onClick: () => setIsCreateModalOpen(true),
                  children: !templateId2 ? (0, import_i18n306.__)("Create block template") : (0, import_i18n306.__)("Create new")
                }
              )
            ] })
          ] })
        }
      ),
      isCreateModalOpen && /* @__PURE__ */ (0, import_jsx_runtime493.jsx)(
        CreateNewTemplateModal,
        {
          onClose: () => setIsCreateModalOpen(false)
        }
      )
    ] });
  }

  // packages/editor/build-module/components/template-actions-panel/index.mjs
  var import_jsx_runtime494 = __toESM(require_jsx_runtime(), 1);
  function TemplateActionsPanel() {
    const postType2 = (0, import_data246.useSelect)(
      (select7) => select7(store3).getCurrentPostType(),
      []
    );
    const mode = usePostTemplatePanelMode();
    if (!["page", "post"].includes(postType2)) {
      return null;
    }
    if (mode === "classic") {
      return /* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ClassicThemeContent, {});
    }
    if (mode === "block-theme") {
      return /* @__PURE__ */ (0, import_jsx_runtime494.jsx)(TemplateActionsPanelContent, {});
    }
    return null;
  }

  // packages/editor/build-module/components/template-content-panel/index.mjs
  var import_data247 = __toESM(require_data(), 1);
  var import_block_editor93 = __toESM(require_block_editor(), 1);
  var import_components275 = __toESM(require_components(), 1);
  var import_i18n307 = __toESM(require_i18n(), 1);
  var import_jsx_runtime495 = __toESM(require_jsx_runtime(), 1);
  var { BlockQuickNavigation } = unlock(import_block_editor93.privateApis);
  var TEMPLATE_PART_BLOCK = "core/template-part";
  function TemplateContentPanelInner({ postType: postType2 }) {
    const postContentBlockTypes = usePostContentBlockTypes();
    const clientIds = (0, import_data247.useSelect)(
      (select7) => {
        const { getPostBlocksByName: getPostBlocksByName2 } = unlock(select7(store3));
        return getPostBlocksByName2(
          TEMPLATE_POST_TYPE === postType2 ? TEMPLATE_PART_BLOCK : postContentBlockTypes
        );
      },
      [postType2, postContentBlockTypes]
    );
    const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data247.useDispatch)(store2);
    if (clientIds.length === 0) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime495.jsx)(import_components275.PanelBody, { title: (0, import_i18n307.__)("Content"), children: /* @__PURE__ */ (0, import_jsx_runtime495.jsx)(
      BlockQuickNavigation,
      {
        clientIds,
        onSelect: () => {
          enableComplementaryArea2("core", "edit-post/document");
        }
      }
    ) });
  }
  function TemplateContentPanel() {
    const { postType: postType2, renderingMode: renderingMode2 } = (0, import_data247.useSelect)((select7) => {
      const { getCurrentPostType: getCurrentPostType2, getRenderingMode: getRenderingMode2 } = unlock(
        select7(store3)
      );
      return {
        postType: getCurrentPostType2(),
        renderingMode: getRenderingMode2()
      };
    }, []);
    if (renderingMode2 === "post-only" && postType2 !== TEMPLATE_POST_TYPE) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime495.jsx)(TemplateContentPanelInner, { postType: postType2 });
  }

  // packages/editor/build-module/components/template-part-content-panel/index.mjs
  var import_data248 = __toESM(require_data(), 1);
  var import_element288 = __toESM(require_element(), 1);
  var import_blocks35 = __toESM(require_blocks(), 1);
  var import_block_editor94 = __toESM(require_block_editor(), 1);
  var import_components276 = __toESM(require_components(), 1);
  var import_i18n308 = __toESM(require_i18n(), 1);
  var import_jsx_runtime496 = __toESM(require_jsx_runtime(), 1);
  var { BlockQuickNavigation: BlockQuickNavigation2 } = unlock(import_block_editor94.privateApis);
  function TemplatePartContentPanelInner() {
    const blockTypes = (0, import_data248.useSelect)((select7) => {
      const { getBlockTypes: getBlockTypes6 } = select7(import_blocks35.store);
      return getBlockTypes6();
    }, []);
    const themeBlockNames = (0, import_element288.useMemo)(() => {
      return blockTypes.filter((blockType) => {
        return blockType.category === "theme";
      }).map(({ name: name2 }) => name2);
    }, [blockTypes]);
    const themeBlocks = (0, import_data248.useSelect)(
      (select7) => {
        const { getBlocksByName } = select7(import_block_editor94.store);
        return getBlocksByName(themeBlockNames);
      },
      [themeBlockNames]
    );
    if (themeBlocks.length === 0) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime496.jsx)(import_components276.PanelBody, { title: (0, import_i18n308.__)("Content"), children: /* @__PURE__ */ (0, import_jsx_runtime496.jsx)(BlockQuickNavigation2, { clientIds: themeBlocks }) });
  }
  function TemplatePartContentPanel() {
    const postType2 = (0, import_data248.useSelect)((select7) => {
      const { getCurrentPostType: getCurrentPostType2 } = select7(store3);
      return getCurrentPostType2();
    }, []);
    if (postType2 !== TEMPLATE_PART_POST_TYPE) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime496.jsx)(TemplatePartContentPanelInner, {});
  }

  // packages/editor/build-module/components/post-revisions-panel/index.mjs
  var import_components277 = __toESM(require_components(), 1);
  var import_core_data136 = __toESM(require_core_data(), 1);
  var import_date22 = __toESM(require_date(), 1);
  var import_data249 = __toESM(require_data(), 1);
  var import_i18n309 = __toESM(require_i18n(), 1);
  var import_jsx_runtime497 = __toESM(require_jsx_runtime(), 1);
  var { Badge: WCBadge5 } = unlock(import_components277.privateApis);
  var DAY_IN_MILLISECONDS2 = 864e5;
  var EMPTY_ARRAY14 = [];
  var defaultLayouts = { activity: true };
  var noop9 = () => {
  };
  var paginationInfo = {};
  var view = {
    type: "activity",
    titleField: "date",
    fields: ["author"],
    layout: { density: "compact" }
  };
  var fields2 = [
    {
      id: "date",
      label: (0, import_i18n309.__)("Date"),
      render: ({ item, field }) => {
        const dateNowInMs = (0, import_date22.getDate)(null).getTime();
        const _value = field.getValue({ item });
        const date = (0, import_date22.getDate)(_value ?? null);
        const displayDate = dateNowInMs - date.getTime() > DAY_IN_MILLISECONDS2 ? (0, import_date22.dateI18n)(
          (0, import_date22.getSettings)().formats.datetimeAbbreviated,
          date
        ) : (0, import_date22.humanTimeDiff)(date);
        return /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(
          "time",
          {
            className: "editor-post-revisions-panel__revision-date",
            dateTime: _value,
            children: displayDate
          }
        );
      },
      enableSorting: false,
      enableHiding: false
    },
    author_default
  ];
  function PostRevisionsPanelContent() {
    const { setCurrentRevisionId: setCurrentRevisionId2 } = unlock((0, import_data249.useDispatch)(store3));
    const {
      revisionsCount,
      revisions,
      revisionKey,
      isLoading,
      lastRevisionId
    } = (0, import_data249.useSelect)((select7) => {
      const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
      const { getCurrentPostRevisionsCount: getCurrentPostRevisionsCount2, getCurrentPostLastRevisionId: getCurrentPostLastRevisionId2 } = select7(store3);
      const { getRevisions, getEntityConfig, isResolving } = select7(import_core_data136.store);
      const _postType = getCurrentPostType2();
      const entityConfig = getEntityConfig("postType", _postType);
      const _revisionKey = entityConfig?.revisionKey || "id";
      const revisionsQuery = {
        per_page: 3,
        orderby: "date",
        order: "desc",
        _fields: `${_revisionKey},date,author`
      };
      const query = [
        "postType",
        _postType,
        getCurrentPostId2(),
        revisionsQuery
      ];
      const _revisions = getRevisions(...query);
      return {
        revisionsCount: getCurrentPostRevisionsCount2(),
        lastRevisionId: getCurrentPostLastRevisionId2(),
        revisions: _revisions,
        revisionKey: _revisionKey,
        isLoading: isResolving("getRevisions", query)
      };
    }, []);
    return /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(
      import_components277.PanelBody,
      {
        title: /* @__PURE__ */ (0, import_jsx_runtime497.jsxs)(import_components277.__experimentalHStack, { justify: "space-between", align: "center", as: "span", children: [
          /* @__PURE__ */ (0, import_jsx_runtime497.jsx)("span", { children: (0, import_i18n309.__)("Revisions") }),
          /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(WCBadge5, { className: "editor-post-revisions-panel__revisions-count", children: revisionsCount })
        ] }),
        initialOpen: false,
        children: /* @__PURE__ */ (0, import_jsx_runtime497.jsxs)(import_components277.__experimentalVStack, { className: "editor-post-revisions-panel", children: [
          /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(
            dataviews_default,
            {
              view,
              onChangeView: noop9,
              fields: fields2,
              data: revisions || EMPTY_ARRAY14,
              isLoading,
              paginationInfo,
              defaultLayouts,
              getItemId: (item) => item[revisionKey],
              isItemClickable: () => true,
              onClickItem: (item) => {
                setCurrentRevisionId2(item[revisionKey]);
              },
              children: /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(dataviews_default.Layout, {})
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(
            import_components277.Button,
            {
              className: "editor-post-revisions-panel__view-all",
              __next40pxDefaultSize: true,
              variant: "secondary",
              onClick: () => setCurrentRevisionId2(lastRevisionId),
              children: (0, import_i18n309.__)("View all revisions")
            }
          )
        ] })
      }
    );
  }
  function PostRevisionsPanel() {
    return /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(check_default5, { children: /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(PostRevisionsPanelContent, {}) });
  }

  // packages/editor/build-module/components/revision-block-diff/index.mjs
  var import_block_editor95 = __toESM(require_block_editor(), 1);
  var import_data250 = __toESM(require_data(), 1);
  var import_i18n310 = __toESM(require_i18n(), 1);
  var import_jsx_runtime498 = __toESM(require_jsx_runtime(), 1);
  function RevisionBlockDiffPanel() {
    const { block } = (0, import_data250.useSelect)((select7) => {
      const { getSelectedBlock: getSelectedBlock2 } = select7(import_block_editor95.store);
      return {
        block: getSelectedBlock2()
      };
    }, []);
    if (!block) {
      return null;
    }
    const changedAttributes = block.attributes?.__revisionDiffStatus?.changedAttributes;
    return /* @__PURE__ */ (0, import_jsx_runtime498.jsx)(
      RevisionDiffPanel,
      {
        title: (0, import_i18n310.__)("Changed attributes"),
        entries: changedAttributes,
        initialOpen: true
      }
    );
  }

  // packages/editor/build-module/components/provider/use-auto-switch-editor-sidebars.mjs
  var import_data251 = __toESM(require_data(), 1);
  var import_element289 = __toESM(require_element(), 1);
  var import_block_editor96 = __toESM(require_block_editor(), 1);
  var import_preferences29 = __toESM(require_preferences(), 1);
  function useAutoSwitchEditorSidebars() {
    const { hasBlockSelection } = (0, import_data251.useSelect)((select7) => {
      return {
        hasBlockSelection: !!select7(import_block_editor96.store).getBlockSelectionStart()
      };
    }, []);
    const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data251.useSelect)(store2);
    const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data251.useDispatch)(store2);
    const { get: getPreference } = (0, import_data251.useSelect)(import_preferences29.store);
    (0, import_element289.useEffect)(() => {
      const activeGeneralSidebar = getActiveComplementaryArea2("core");
      const isEditorSidebarOpened = [
        "edit-post/document",
        "edit-post/block"
      ].includes(activeGeneralSidebar);
      const isDistractionFree = getPreference("core", "distractionFree");
      if (!isEditorSidebarOpened || isDistractionFree) {
        return;
      }
      if (hasBlockSelection) {
        enableComplementaryArea2("core", "edit-post/block");
      } else {
        enableComplementaryArea2("core", "edit-post/document");
      }
    }, [
      hasBlockSelection,
      getActiveComplementaryArea2,
      enableComplementaryArea2,
      getPreference
    ]);
  }
  var use_auto_switch_editor_sidebars_default = useAutoSwitchEditorSidebars;

  // packages/editor/build-module/components/sidebar/index.mjs
  var import_jsx_runtime499 = __toESM(require_jsx_runtime(), 1);
  var { Tabs: Tabs6 } = unlock(import_components278.privateApis);
  var SIDEBAR_ACTIVE_BY_DEFAULT = import_element290.Platform.select({
    web: true,
    native: false
  });
  var SidebarContent = ({
    tabName,
    keyboardShortcut,
    onActionPerformed,
    extraPanels,
    postType: postType2
  }) => {
    const tabListRef = (0, import_element290.useRef)(null);
    const tabsContextValue = (0, import_element290.useContext)(Tabs6.Context);
    const isAttachment = postType2 === ATTACHMENT_POST_TYPE;
    const isRevisionsMode2 = (0, import_data252.useSelect)((select7) => {
      return unlock(select7(store3)).isRevisionsMode();
    });
    (0, import_element290.useEffect)(() => {
      const tabsElements = Array.from(
        tabListRef.current?.querySelectorAll('[role="tab"]') || []
      );
      const selectedTabElement = tabsElements.find(
        // We are purposefully using a custom `data-tab-id` attribute here
        // because we don't want rely on any assumptions about `Tabs`
        // component internals.
        (element) => element.getAttribute("data-tab-id") === tabName
      );
      const activeElement = selectedTabElement?.ownerDocument.activeElement;
      const tabsHasFocus = tabsElements.some((element) => {
        return activeElement && activeElement.id === element.id;
      });
      if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) {
        selectedTabElement?.focus();
      }
    }, [tabName]);
    let tabContent;
    if (isAttachment) {
      tabContent = /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(MediaMetadataPanel, { onActionPerformed });
    } else if (isRevisionsMode2) {
      tabContent = /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(PostRevisionSummary, {});
    } else {
      tabContent = /* @__PURE__ */ (0, import_jsx_runtime499.jsxs)(import_jsx_runtime499.Fragment, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(PostSummary, { onActionPerformed }),
        /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(plugin_document_setting_panel_default.Slot, {}),
        /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(TemplateContentPanel, {}),
        window?.__experimentalDataFormInspector && [
          "post",
          "page",
          "wp_template",
          "wp_template_part",
          "wp_block"
        ].includes(postType2) && /* @__PURE__ */ (0, import_jsx_runtime499.jsxs)(import_jsx_runtime499.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(TemplateActionsPanel, {}),
          /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(PostRevisionsPanel, {})
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(TemplatePartContentPanel, {}),
        /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(PostTransformPanel, {}),
        /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(PostTaxonomies2, {}),
        /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(PatternOverridesPanel, {}),
        extraPanels
      ] });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(
      PluginSidebar,
      {
        identifier: tabName,
        header: /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(Tabs6.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(header_default3, { ref: tabListRef }) }),
        closeLabel: (0, import_i18n311.__)("Close Settings"),
        className: "editor-sidebar__panel",
        headerClassName: "editor-sidebar__panel-tabs",
        title: (
          /* translators: button label text should, if possible, be under 16 characters. */
          (0, import_i18n311._x)("Settings", "panel button label")
        ),
        toggleShortcut: keyboardShortcut,
        icon: (0, import_i18n311.isRTL)() ? drawer_left_default : drawer_right_default,
        isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
        children: /* @__PURE__ */ (0, import_jsx_runtime499.jsxs)(Tabs6.Context.Provider, { value: tabsContextValue, children: [
          /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(Tabs6.TabPanel, { tabId: sidebars.document, focusable: false, children: tabContent }),
          !isAttachment && /* @__PURE__ */ (0, import_jsx_runtime499.jsxs)(Tabs6.TabPanel, { tabId: sidebars.block, focusable: false, children: [
            /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(import_block_editor97.BlockInspector, {}),
            isRevisionsMode2 && /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(RevisionBlockDiffPanel, {})
          ] })
        ] })
      }
    );
  };
  var Sidebar = ({ extraPanels, onActionPerformed }) => {
    use_auto_switch_editor_sidebars_default();
    const { tabName, keyboardShortcut, showSummary, postType: postType2 } = (0, import_data252.useSelect)(
      (select7) => {
        const shortcut = select7(
          import_keyboard_shortcuts10.store
        ).getShortcutRepresentation("core/editor/toggle-sidebar");
        const sidebar = select7(store2).getActiveComplementaryArea("core");
        const _isEditorSidebarOpened = [
          sidebars.block,
          sidebars.document
        ].includes(sidebar);
        let _tabName = sidebar;
        if (!_isEditorSidebarOpened) {
          _tabName = !!select7(
            import_block_editor97.store
          ).getBlockSelectionStart() ? sidebars.block : sidebars.document;
        }
        const _postType = select7(store3).getCurrentPostType();
        return {
          tabName: _tabName,
          keyboardShortcut: shortcut,
          showSummary: ![
            TEMPLATE_POST_TYPE,
            TEMPLATE_PART_POST_TYPE,
            NAVIGATION_POST_TYPE
          ].includes(_postType),
          postType: _postType
        };
      },
      []
    );
    const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data252.useDispatch)(store2);
    const onTabSelect = (0, import_element290.useCallback)(
      (newSelectedTabId) => {
        if (!!newSelectedTabId) {
          enableComplementaryArea2("core", newSelectedTabId);
        }
      },
      [enableComplementaryArea2]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(
      Tabs6,
      {
        selectedTabId: tabName,
        onSelect: onTabSelect,
        selectOnMove: false,
        children: /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(
          SidebarContent,
          {
            tabName,
            keyboardShortcut,
            showSummary,
            onActionPerformed,
            extraPanels,
            postType: postType2
          }
        )
      }
    );
  };
  var sidebar_default2 = Sidebar;

  // packages/editor/build-module/components/collab-sidebar/index.mjs
  var import_i18n321 = __toESM(require_i18n(), 1);
  var import_data259 = __toESM(require_data(), 1);
  var import_element297 = __toESM(require_element(), 1);
  var import_compose79 = __toESM(require_compose(), 1);
  var import_keyboard_shortcuts12 = __toESM(require_keyboard_shortcuts(), 1);
  var import_block_editor105 = __toESM(require_block_editor(), 1);
  var import_preferences30 = __toESM(require_preferences(), 1);

  // packages/editor/build-module/components/collab-sidebar/constants.mjs
  var ALL_NOTES_SIDEBAR = "edit-post/collab-history-sidebar";
  var FLOATING_NOTES_SIDEBAR = "edit-post/collab-sidebar";
  var SIDEBARS = [ALL_NOTES_SIDEBAR, FLOATING_NOTES_SIDEBAR];

  // packages/editor/build-module/components/collab-sidebar/notes.mjs
  var import_element295 = __toESM(require_element(), 1);
  var import_i18n318 = __toESM(require_i18n(), 1);
  var import_data257 = __toESM(require_data(), 1);
  var import_block_editor102 = __toESM(require_block_editor(), 1);

  // packages/editor/build-module/components/collab-sidebar/note-thread.mjs
  var import_element293 = __toESM(require_element(), 1);
  var import_components283 = __toESM(require_components(), 1);
  var import_compose78 = __toESM(require_compose(), 1);
  var import_i18n316 = __toESM(require_i18n(), 1);
  var import_data255 = __toESM(require_data(), 1);
  var import_dom15 = __toESM(require_dom(), 1);
  var import_block_editor100 = __toESM(require_block_editor(), 1);

  // packages/editor/build-module/components/collab-sidebar/add-note.mjs
  var import_i18n314 = __toESM(require_i18n(), 1);
  var import_data254 = __toESM(require_data(), 1);
  var import_block_editor99 = __toESM(require_block_editor(), 1);

  // packages/editor/build-module/components/collab-sidebar/note-card.mjs
  var import_components280 = __toESM(require_components(), 1);

  // packages/editor/build-module/components/collab-sidebar/note-byline.mjs
  var import_components279 = __toESM(require_components(), 1);
  var import_i18n312 = __toESM(require_i18n(), 1);
  var import_date23 = __toESM(require_date(), 1);
  var import_core_data137 = __toESM(require_core_data(), 1);
  var import_data253 = __toESM(require_data(), 1);
  var import_block_editor98 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime500 = __toESM(require_jsx_runtime(), 1);
  function NoteByline({ avatar, name: name2, date, userId }) {
    const hasAvatar = !!avatar;
    const dateSettings = (0, import_date23.getSettings)();
    const {
      currentUserAvatar,
      currentUserName,
      currentUserId,
      dateFormat = dateSettings.formats.date
    } = (0, import_data253.useSelect)(
      (select7) => {
        const { canUser, getCurrentUser, getEntityRecord } = select7(import_core_data137.store);
        const siteSettings = canUser("read", {
          kind: "root",
          name: "site"
        }) ? getEntityRecord("root", "site") : void 0;
        if (hasAvatar) {
          return {
            dateFormat: siteSettings?.date_format
          };
        }
        const { getSettings: getSettings11 } = select7(import_block_editor98.store);
        const { __experimentalDiscussionSettings } = getSettings11();
        const defaultAvatar = __experimentalDiscussionSettings?.avatarURL;
        const userData = getCurrentUser();
        return {
          currentUserAvatar: userData?.avatar_urls?.[48] ?? defaultAvatar,
          currentUserName: userData?.name,
          currentUserId: userData?.id,
          dateFormat: siteSettings?.date_format
        };
      },
      [hasAvatar]
    );
    const commentDate = (0, import_date23.getDate)(date);
    const commentDateTime = (0, import_date23.dateI18n)("c", commentDate);
    const shouldShowHumanTimeDiff = Math.floor((/* @__PURE__ */ new Date() - commentDate) / (1e3 * 60 * 60 * 24)) < 30;
    const commentDateText = shouldShowHumanTimeDiff ? (0, import_date23.humanTimeDiff)(commentDate) : (0, import_date23.dateI18n)(dateFormat, commentDate);
    const tooltipText = (0, import_date23.dateI18n)(
      // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
      (0, import_i18n312._x)("F j, Y g:i\xA0a", "Note date full date format"),
      date
    );
    return /* @__PURE__ */ (0, import_jsx_runtime500.jsxs)(import_jsx_runtime500.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime500.jsx)(
        "img",
        {
          src: avatar || currentUserAvatar,
          className: "editor-collab-sidebar-panel__user-avatar",
          alt: (0, import_i18n312.__)("User avatar"),
          width: 32,
          height: 32,
          style: {
            borderColor: getAvatarBorderColor(
              userId ?? currentUserId
            )
          }
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime500.jsxs)(Stack, { direction: "column", children: [
        /* @__PURE__ */ (0, import_jsx_runtime500.jsx)("span", { className: "editor-collab-sidebar-panel__user-name", children: name2 ?? currentUserName }),
        date && /* @__PURE__ */ (0, import_jsx_runtime500.jsx)(import_components279.Tooltip, { text: tooltipText, children: /* @__PURE__ */ (0, import_jsx_runtime500.jsx)(
          "time",
          {
            dateTime: commentDateTime,
            className: "editor-collab-sidebar-panel__user-time",
            children: commentDateText
          }
        ) })
      ] })
    ] });
  }

  // packages/editor/build-module/components/collab-sidebar/note-card.mjs
  var import_jsx_runtime501 = __toESM(require_jsx_runtime(), 1);
  function NoteCard({ note, actions: actions2, className, children, ...props }) {
    return /* @__PURE__ */ (0, import_jsx_runtime501.jsxs)(Stack, { direction: "column", gap: "sm", className, ...props, children: [
      /* @__PURE__ */ (0, import_jsx_runtime501.jsxs)(Stack, { direction: "row", align: "center", justify: "flex-start", gap: "md", children: [
        /* @__PURE__ */ (0, import_jsx_runtime501.jsx)(
          NoteByline,
          {
            avatar: note?.author_avatar_urls?.[48],
            name: note?.author_name,
            date: note?.date,
            userId: note?.author
          }
        ),
        actions2 && /* @__PURE__ */ (0, import_jsx_runtime501.jsx)(
          import_components280.FlexItem,
          {
            className: "editor-collab-sidebar-panel__note-actions",
            onClick: (event) => event.stopPropagation(),
            children: /* @__PURE__ */ (0, import_jsx_runtime501.jsx)(Stack, { direction: "row", align: "center", children: actions2 })
          }
        )
      ] }),
      children
    ] });
  }

  // packages/editor/build-module/components/collab-sidebar/note-form.mjs
  var import_react_autosize_textarea2 = __toESM(require_lib(), 1);
  var import_element291 = __toESM(require_element(), 1);
  var import_components281 = __toESM(require_components(), 1);
  var import_i18n313 = __toESM(require_i18n(), 1);
  var import_compose77 = __toESM(require_compose(), 1);
  var import_keycodes19 = __toESM(require_keycodes(), 1);
  var import_jsx_runtime502 = __toESM(require_jsx_runtime(), 1);
  function NoteForm({ onSubmit, onCancel, note, labels }) {
    const [inputComment, setInputComment] = (0, import_element291.useState)(
      note?.content?.raw ?? ""
    );
    const inputId = (0, import_compose77.useInstanceId)(NoteForm, "comment-input");
    const isDisabled = inputComment === note?.content?.raw || !sanitizeNoteContent(inputComment).length;
    return /* @__PURE__ */ (0, import_jsx_runtime502.jsxs)(
      Stack,
      {
        className: "editor-collab-sidebar-panel__note-form",
        direction: "column",
        gap: "lg",
        render: /* @__PURE__ */ (0, import_jsx_runtime502.jsx)("form", {}),
        onSubmit: (event) => {
          event.preventDefault();
          onSubmit(inputComment);
          setInputComment("");
        },
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime502.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime502.jsx)("label", { htmlFor: inputId }), children: labels?.input ?? (0, import_i18n313.__)("Note") }),
          /* @__PURE__ */ (0, import_jsx_runtime502.jsx)(
            import_react_autosize_textarea2.default,
            {
              id: inputId,
              value: inputComment ?? "",
              onChange: (comment) => setInputComment(comment.target.value),
              rows: 1,
              maxRows: 20,
              onKeyDown: (event) => {
                if (import_keycodes19.isKeyboardEvent.primary(event, "Enter") && !isDisabled) {
                  event.target.parentNode.requestSubmit();
                }
                if (event.key === "Escape") {
                  event.preventDefault();
                  onCancel(event);
                }
              }
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime502.jsxs)(
            Stack,
            {
              direction: "row",
              align: "center",
              justify: "flex-end",
              gap: "sm",
              wrap: "wrap",
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime502.jsx)(import_components281.Button, { size: "compact", variant: "tertiary", onClick: onCancel, children: /* @__PURE__ */ (0, import_jsx_runtime502.jsx)(import_components281.__experimentalTruncate, { children: (0, import_i18n313.__)("Cancel") }) }),
                /* @__PURE__ */ (0, import_jsx_runtime502.jsx)(
                  import_components281.Button,
                  {
                    size: "compact",
                    accessibleWhenDisabled: true,
                    variant: "primary",
                    type: "submit",
                    disabled: isDisabled,
                    children: /* @__PURE__ */ (0, import_jsx_runtime502.jsx)(import_components281.__experimentalTruncate, { children: labels?.submit ?? (0, import_i18n313.__)("Add note") })
                  }
                )
              ]
            }
          )
        ]
      }
    );
  }

  // packages/editor/build-module/components/collab-sidebar/floating-container.mjs
  var import_jsx_runtime503 = __toESM(require_jsx_runtime(), 1);
  function FloatingContainer({
    floating,
    className,
    style,
    children,
    ...props
  }) {
    const isFloating = !!floating;
    return /* @__PURE__ */ (0, import_jsx_runtime503.jsx)(
      Stack,
      {
        direction: "column",
        className: clsx_default(className, { "is-floating": isFloating }),
        ref: isFloating ? floating.ref : void 0,
        style: isFloating ? { top: floating.y, ...style } : style,
        ...props,
        children
      }
    );
  }

  // packages/editor/build-module/components/collab-sidebar/add-note.mjs
  var import_jsx_runtime504 = __toESM(require_jsx_runtime(), 1);
  var { useBlockElement } = unlock(import_block_editor99.privateApis);
  function AddNote({ onSubmit, sidebarRef, floating }) {
    const { clientId } = (0, import_data254.useSelect)((select7) => {
      const { getSelectedBlockClientId: getSelectedBlockClientId2 } = select7(import_block_editor99.store);
      return {
        clientId: getSelectedBlockClientId2()
      };
    }, []);
    const selectedNote2 = (0, import_data254.useSelect)(
      (select7) => unlock(select7(store3)).getSelectedNote(),
      []
    );
    const blockElement = useBlockElement(clientId);
    const { toggleBlockSpotlight } = unlock((0, import_data254.useDispatch)(import_block_editor99.store));
    const { selectNote: selectNote2 } = unlock((0, import_data254.useDispatch)(store3));
    const unselectNote = () => {
      selectNote2(void 0);
      blockElement?.focus();
      toggleBlockSpotlight(clientId, false);
    };
    if (selectedNote2 !== "new" || !clientId) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime504.jsx)(
      FloatingContainer,
      {
        floating,
        className: "editor-collab-sidebar-panel__thread is-selected",
        gap: "md",
        tabIndex: 0,
        "aria-label": (0, import_i18n314.__)("New note"),
        role: "treeitem",
        style: floating ? { opacity: !floating.y ? 0 : void 0 } : void 0,
        onBlur: (event) => {
          if (!document.hasFocus()) {
            return;
          }
          if (event.currentTarget.contains(event.relatedTarget)) {
            return;
          }
          toggleBlockSpotlight(clientId, false);
          selectNote2(void 0);
        },
        children: /* @__PURE__ */ (0, import_jsx_runtime504.jsx)(NoteCard, { children: /* @__PURE__ */ (0, import_jsx_runtime504.jsx)(
          NoteForm,
          {
            onSubmit: async (inputComment) => {
              const { id } = await onSubmit({
                content: inputComment
              });
              selectNote2(id);
              focusNoteThread(id, sidebarRef.current);
            },
            onCancel: unselectNote,
            labels: { input: (0, import_i18n314.__)("New note") }
          }
        ) })
      }
    );
  }

  // packages/editor/build-module/components/collab-sidebar/note.mjs
  var import_element292 = __toESM(require_element(), 1);
  var import_components282 = __toESM(require_components(), 1);
  var import_i18n315 = __toESM(require_i18n(), 1);
  var import_jsx_runtime505 = __toESM(require_jsx_runtime(), 1);
  var { Menu: Menu11 } = unlock(import_components282.privateApis);
  function NoteActionsMenu({ items, buttonRef }) {
    return /* @__PURE__ */ (0, import_jsx_runtime505.jsxs)(Menu11, { placement: "bottom-end", children: [
      /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(
        Menu11.TriggerButton,
        {
          render: /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(
            import_components282.Button,
            {
              ref: buttonRef,
              size: "small",
              icon: more_vertical_default,
              label: (0, import_i18n315.__)("Actions"),
              disabled: !items.length,
              accessibleWhenDisabled: true
            }
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(
        Menu11.Popover,
        {
          modal: false,
          children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(Menu11.Item, { onClick: item.onClick, children: /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(Menu11.ItemLabel, { children: item.title }) }, item.id))
        }
      )
    ] });
  }
  function Note({
    note,
    parentNote,
    isSelected: isSelected2,
    onEditNote,
    onDeleteNote,
    onResolve
  }) {
    const [actionState, setActionState] = (0, import_element292.useState)(null);
    const actionButtonRef = (0, import_element292.useRef)(null);
    const canResolve = note.parent === 0;
    const isResolutionNote = note.type === "note" && note.meta && (note.meta._wp_note_status === "resolved" || note.meta._wp_note_status === "reopen");
    const menuItems = [
      {
        id: "edit",
        title: (0, import_i18n315.__)("Edit"),
        isEligible: ({ status }) => status !== "approved",
        onClick: () => setActionState("edit")
      },
      {
        id: "reopen",
        title: (0, import_i18n315._x)("Reopen", "Reopen note"),
        isEligible: ({ status }) => status === "approved",
        onClick: () => onEditNote({ id: note.id, status: "hold" })
      },
      {
        id: "delete",
        title: (0, import_i18n315.__)("Delete"),
        isEligible: () => true,
        onClick: () => setActionState("delete")
      }
    ];
    const availableItems = parentNote?.status !== "approved" ? menuItems.filter((item) => item.isEligible(note)) : [];
    const deleteConfirmMessage = note.parent === 0 ? (0, import_i18n315.__)(
      "Are you sure you want to delete this note? This will also delete all of this note's replies."
    ) : (0, import_i18n315.__)("Are you sure you want to delete this reply?");
    const handleCancel = () => {
      setActionState(null);
      actionButtonRef.current?.focus();
    };
    let body;
    if (actionState === "edit") {
      body = /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(
        NoteForm,
        {
          onSubmit: (value) => {
            onEditNote({ id: note.id, content: value });
            setActionState(null);
            actionButtonRef.current?.focus();
          },
          onCancel: handleCancel,
          note,
          labels: {
            submit: (0, import_i18n315._x)("Update", "verb"),
            input: (0, import_i18n315.sprintf)(
              // translators: %1$s: note identifier, %2$s: author name.
              (0, import_i18n315.__)("Edit note %1$s by %2$s"),
              note.id,
              note.author_name
            )
          }
        }
      );
    } else if (isResolutionNote) {
      const actionText = note.meta._wp_note_status === "resolved" ? (0, import_i18n315.__)("Marked as resolved") : (0, import_i18n315.__)("Reopened");
      const raw = note?.content?.raw;
      const text = raw && typeof raw === "string" && raw.trim() !== "" ? (0, import_i18n315.sprintf)(
        // translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text.
        (0, import_i18n315.__)("%1$s: %2$s"),
        actionText,
        raw
      ) : actionText;
      body = /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(
        import_element292.RawHTML,
        {
          className: clsx_default(
            "editor-collab-sidebar-panel__note-content",
            "editor-collab-sidebar-panel__resolution-text"
          ),
          children: text
        }
      );
    } else {
      body = /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(import_element292.RawHTML, { className: "editor-collab-sidebar-panel__note-content", children: note?.content?.rendered });
    }
    const actions2 = isSelected2 ? /* @__PURE__ */ (0, import_jsx_runtime505.jsxs)(import_jsx_runtime505.Fragment, { children: [
      canResolve && onResolve && /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(
        import_components282.Button,
        {
          label: (0, import_i18n315._x)("Resolve", "Mark note as resolved"),
          size: "small",
          icon: published_default,
          disabled: note.status === "approved",
          accessibleWhenDisabled: note.status === "approved",
          onClick: onResolve
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(
        NoteActionsMenu,
        {
          items: availableItems,
          buttonRef: actionButtonRef
        }
      )
    ] }) : null;
    return /* @__PURE__ */ (0, import_jsx_runtime505.jsxs)(
      NoteCard,
      {
        note,
        actions: actions2,
        role: note.parent !== 0 ? "treeitem" : void 0,
        children: [
          body,
          actionState === "delete" && /* @__PURE__ */ (0, import_jsx_runtime505.jsx)(
            import_components282.__experimentalConfirmDialog,
            {
              isOpen: true,
              onConfirm: () => {
                onDeleteNote(note);
                setActionState(null);
              },
              onCancel: handleCancel,
              confirmButtonText: (0, import_i18n315.__)("Delete"),
              children: deleteConfirmMessage
            }
          )
        ]
      }
    );
  }

  // packages/editor/build-module/components/collab-sidebar/note-thread.mjs
  var import_jsx_runtime506 = __toESM(require_jsx_runtime(), 1);
  var { useBlockElement: useBlockElement2 } = unlock(import_block_editor100.privateApis);
  function NoteThread({
    note,
    onEditNote,
    onAddReply,
    onDeleteNote,
    isSelected: isSelected2,
    sidebarRef,
    floating,
    onKeyDown
  }) {
    const isFloating = !!floating;
    const { toggleBlockHighlight, selectBlock: selectBlock2, toggleBlockSpotlight } = unlock(
      (0, import_data255.useDispatch)(import_block_editor100.store)
    );
    const { selectNote: selectNote2 } = unlock((0, import_data255.useDispatch)(store3));
    const relatedBlockElement = useBlockElement2(note.blockClientId);
    const debouncedToggleBlockHighlight = (0, import_compose78.useDebounce)(
      toggleBlockHighlight,
      50
    );
    const floatingRef = (0, import_element293.useRef)(null);
    const isKeyboardTabbingRef = (0, import_element293.useRef)(false);
    const registerThread = floating?.registerThread;
    const unregisterThread = floating?.unregisterThread;
    (0, import_element293.useEffect)(() => {
      const floatingEl = floatingRef.current;
      if (floatingEl && registerThread) {
        registerThread(note.id, relatedBlockElement, floatingEl);
      }
      return () => unregisterThread?.(note.id);
    }, [relatedBlockElement, note.id, registerThread, unregisterThread]);
    const onMouseEnter = () => {
      debouncedToggleBlockHighlight(note.blockClientId, true);
    };
    const onMouseLeave = () => {
      debouncedToggleBlockHighlight(note.blockClientId, false);
    };
    const onFocus = () => {
      toggleBlockHighlight(note.blockClientId, true);
    };
    const onBlur = (event) => {
      if (!document.hasFocus()) {
        return;
      }
      const isNoteFocused2 = event.relatedTarget?.closest(
        ".editor-collab-sidebar-panel__thread"
      );
      const isDialogFocused = event.relatedTarget?.closest('[role="dialog"]');
      const isTabbing = isKeyboardTabbingRef.current;
      if (isNoteFocused2 && !isTabbing) {
        return;
      }
      if (isDialogFocused) {
        return;
      }
      if (isTabbing && event.currentTarget.contains(event.relatedTarget)) {
        return;
      }
      toggleBlockHighlight(note.blockClientId, false);
      unselectNote();
    };
    const handleNoteSelect = () => {
      selectNote2(note.id);
      toggleBlockSpotlight(note.blockClientId, true);
      if (!!note.blockClientId) {
        selectBlock2(note.blockClientId, null);
      }
    };
    const unselectNote = () => {
      selectNote2(void 0);
      toggleBlockSpotlight(note.blockClientId, false);
    };
    const handleResolve = () => {
      onEditNote({ id: note.id, status: "approved" });
      unselectNote();
      if (isFloating) {
        relatedBlockElement?.focus();
      } else {
        focusNoteThread(note.id, sidebarRef.current);
      }
    };
    const allReplies = note?.reply || [];
    const lastReply = allReplies.length > 0 ? allReplies[allReplies.length - 1] : void 0;
    const restReplies = allReplies.length > 0 ? allReplies.slice(0, -1) : [];
    const noteExcerpt = getNoteExcerpt(
      (0, import_dom15.__unstableStripHTML)(note.content?.rendered),
      10
    );
    const ariaLabel = !!note.blockClientId ? (0, import_i18n316.sprintf)(
      // translators: %s: note excerpt
      (0, import_i18n316.__)("Note: %s"),
      noteExcerpt
    ) : (0, import_i18n316.sprintf)(
      // translators: %s: note excerpt
      (0, import_i18n316.__)("Original block deleted. Note: %s"),
      noteExcerpt
    );
    if (isFloating && note.id === "new") {
      return /* @__PURE__ */ (0, import_jsx_runtime506.jsx)(
        AddNote,
        {
          onSubmit: onAddReply,
          sidebarRef,
          floating: { y: floating.y, ref: floatingRef }
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime506.jsxs)(
      FloatingContainer,
      {
        floating: isFloating ? { y: floating.y, ref: floatingRef } : void 0,
        className: clsx_default("editor-collab-sidebar-panel__thread", {
          "is-selected": isSelected2
        }),
        id: `note-thread-${note.id}`,
        gap: "md",
        onClick: handleNoteSelect,
        onMouseEnter,
        onMouseLeave,
        onFocus,
        onBlur,
        onKeyUp: (event) => {
          if (event.key === "Tab") {
            isKeyboardTabbingRef.current = false;
          }
        },
        onKeyDown: (event) => {
          if (event.key === "Tab") {
            isKeyboardTabbingRef.current = true;
          } else {
            onKeyDown(event);
          }
        },
        tabIndex: 0,
        role: "treeitem",
        "aria-label": ariaLabel,
        "aria-expanded": isSelected2,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime506.jsx)(
            import_components283.Button,
            {
              className: "editor-collab-sidebar-panel__skip-to-note",
              variant: "secondary",
              size: "compact",
              onClick: () => {
                focusNoteThread(note.id, sidebarRef.current, "textarea");
              },
              children: (0, import_i18n316.__)("Add new reply")
            }
          ),
          !note.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime506.jsx)("p", { className: "editor-collab-sidebar-panel__deleted-block-notice", children: (0, import_i18n316.__)("Original block deleted.") }),
          /* @__PURE__ */ (0, import_jsx_runtime506.jsx)(
            Note,
            {
              note,
              isSelected: isSelected2,
              onEditNote,
              onDeleteNote,
              onResolve: handleResolve
            }
          ),
          isSelected2 && allReplies.map((reply) => /* @__PURE__ */ (0, import_jsx_runtime506.jsx)(
            Note,
            {
              note: reply,
              parentNote: note,
              isSelected: isSelected2,
              onEditNote,
              onDeleteNote
            },
            reply.id
          )),
          !isSelected2 && restReplies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime506.jsx)(
            Stack,
            {
              direction: "row",
              align: "center",
              justify: "space-between",
              className: "editor-collab-sidebar-panel__more-reply-separator",
              children: /* @__PURE__ */ (0, import_jsx_runtime506.jsx)(
                import_components283.Button,
                {
                  size: "compact",
                  variant: "tertiary",
                  className: "editor-collab-sidebar-panel__more-reply-button",
                  onClick: () => {
                    selectNote2(note.id);
                    focusNoteThread(note.id, sidebarRef.current);
                  },
                  children: (0, import_i18n316.sprintf)(
                    // translators: %s: number of replies.
                    (0, import_i18n316._n)(
                      "%s more reply",
                      "%s more replies",
                      restReplies.length
                    ),
                    restReplies.length
                  )
                }
              )
            }
          ),
          !isSelected2 && lastReply && /* @__PURE__ */ (0, import_jsx_runtime506.jsx)(
            Note,
            {
              note: lastReply,
              parentNote: note,
              isSelected: false,
              onEditNote,
              onDeleteNote
            }
          ),
          isSelected2 && /* @__PURE__ */ (0, import_jsx_runtime506.jsx)(NoteCard, { role: "treeitem", children: /* @__PURE__ */ (0, import_jsx_runtime506.jsx)(
            NoteForm,
            {
              onSubmit: (inputComment) => {
                if ("approved" === note.status) {
                  onEditNote({
                    id: note.id,
                    status: "hold",
                    content: inputComment
                  });
                } else {
                  onAddReply({
                    content: inputComment,
                    parent: note.id
                  });
                }
              },
              onCancel: (event) => {
                event.stopPropagation();
                unselectNote();
                focusNoteThread(note.id, sidebarRef.current);
              },
              labels: {
                submit: "approved" === note.status ? (0, import_i18n316.__)("Reopen & Reply") : (0, import_i18n316.__)("Reply"),
                input: (0, import_i18n316.sprintf)(
                  // translators: %1$s: note identifier, %2$s: author name
                  (0, import_i18n316.__)("Reply to note %1$s by %2$s"),
                  note.id,
                  note.author_name
                )
              }
            }
          ) }),
          !!note.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime506.jsx)(
            import_components283.Button,
            {
              className: "editor-collab-sidebar-panel__skip-to-block",
              variant: "secondary",
              size: "compact",
              onClick: (event) => {
                event.stopPropagation();
                relatedBlockElement?.focus();
              },
              children: (0, import_i18n316.__)("Back to block")
            }
          )
        ]
      }
    );
  }

  // packages/editor/build-module/components/collab-sidebar/hooks.mjs
  var import_i18n317 = __toESM(require_i18n(), 1);
  var import_element294 = __toESM(require_element(), 1);
  var import_core_data138 = __toESM(require_core_data(), 1);
  var import_data256 = __toESM(require_data(), 1);
  var import_block_editor101 = __toESM(require_block_editor(), 1);
  var import_notices35 = __toESM(require_notices(), 1);
  var import_dom16 = __toESM(require_dom(), 1);
  var import_html_entities35 = __toESM(require_html_entities(), 1);

  // packages/editor/build-module/components/collab-sidebar/board-store.mjs
  function createBoardStore() {
    const listeners = /* @__PURE__ */ new Set();
    const blockRefs = /* @__PURE__ */ new Map();
    const floatingRefs = /* @__PURE__ */ new Map();
    const idByElement = /* @__PURE__ */ new WeakMap();
    const heights = {};
    let snapshot = {};
    function emit() {
      snapshot = { ...heights };
      for (const listener of listeners) {
        listener();
      }
    }
    const observer = new window.ResizeObserver((entries) => {
      let changed = false;
      for (const entry of entries) {
        const id = idByElement.get(entry.target);
        const newHeight = entry.borderBoxSize[0].blockSize;
        if (heights[id] !== newHeight) {
          heights[id] = newHeight;
          changed = true;
        }
      }
      if (changed) {
        emit();
      }
    });
    return {
      subscribe(listener) {
        listeners.add(listener);
        return () => {
          listeners.delete(listener);
          if (listeners.size === 0) {
            observer.disconnect();
          }
        };
      },
      getSnapshot() {
        return snapshot;
      },
      registerThread(id, blockEl, floatingEl) {
        blockRefs.set(id, blockEl);
        const prev = floatingRefs.get(id);
        if (prev && prev !== floatingEl) {
          observer.unobserve(prev);
          idByElement.delete(prev);
        }
        if (floatingEl) {
          floatingRefs.set(id, floatingEl);
          idByElement.set(floatingEl, id);
          observer.observe(floatingEl);
        }
        emit();
      },
      unregisterThread(id) {
        blockRefs.delete(id);
        const prev = floatingRefs.get(id);
        if (prev) {
          observer.unobserve(prev);
          idByElement.delete(prev);
          floatingRefs.delete(id);
        }
        delete heights[id];
      },
      getBlockRects() {
        return Object.fromEntries(
          Array.from(blockRefs).flatMap(
            ([id, el]) => el ? [[id, el.getBoundingClientRect()]] : []
          )
        );
      },
      getFirstBlockElement() {
        return blockRefs.values().next().value ?? null;
      }
    };
  }

  // packages/editor/build-module/components/collab-sidebar/hooks.mjs
  var { cleanEmptyObject: cleanEmptyObject4 } = unlock(import_block_editor101.privateApis);
  function useNoteThreads(postId2) {
    const queryArgs = {
      post: postId2,
      type: "note",
      status: "all",
      per_page: -1
    };
    const { records: threads } = (0, import_core_data138.useEntityRecords)(
      "root",
      "comment",
      queryArgs,
      { enabled: !!postId2 && typeof postId2 === "number" }
    );
    const { getBlockAttributes: getBlockAttributes2 } = (0, import_data256.useSelect)(import_block_editor101.store);
    const { clientIds } = (0, import_data256.useSelect)((select7) => {
      const { getClientIdsWithDescendants: getClientIdsWithDescendants2 } = select7(import_block_editor101.store);
      return {
        clientIds: getClientIdsWithDescendants2()
      };
    }, []);
    const { notes, unresolvedNotes } = (0, import_element294.useMemo)(() => {
      if (!threads || threads.length === 0) {
        return { notes: [], unresolvedNotes: [] };
      }
      const blocksWithNotes = {};
      const clientIdByNoteId = /* @__PURE__ */ new Map();
      for (const clientId of clientIds) {
        const noteId = getBlockAttributes2(clientId)?.metadata?.noteId;
        if (noteId) {
          const key = String(noteId);
          blocksWithNotes[clientId] = key;
          clientIdByNoteId.set(key, clientId);
        }
      }
      const threadsById = /* @__PURE__ */ new Map();
      const rootThreads = [];
      for (const item of threads) {
        const thread = {
          ...item,
          reply: [],
          blockClientId: item.parent === 0 ? clientIdByNoteId.get(String(item.id)) ?? null : null
        };
        threadsById.set(item.id, thread);
        if (item.parent === 0) {
          rootThreads.push(thread);
        }
      }
      for (const item of threads) {
        if (item.parent !== 0) {
          threadsById.get(item.parent)?.reply.unshift(threadsById.get(item.id));
        }
      }
      if (rootThreads.length === 0) {
        return { notes: [], unresolvedNotes: [] };
      }
      const unresolved = [];
      const resolved = [];
      for (const noteId of Object.values(blocksWithNotes)) {
        const thread = threadsById.get(Number(noteId)) ?? threadsById.get(noteId);
        if (!thread) {
          continue;
        }
        if (thread.status === "hold") {
          unresolved.push(thread);
        } else if (thread.status === "approved") {
          resolved.push(thread);
        }
      }
      const orphans = rootThreads.filter(
        (thread) => !thread.blockClientId
      );
      return {
        notes: [...unresolved, ...resolved, ...orphans],
        unresolvedNotes: unresolved
      };
    }, [clientIds, threads, getBlockAttributes2]);
    return {
      notes,
      unresolvedNotes
    };
  }
  function useNoteActions() {
    const { createNotice } = (0, import_data256.useDispatch)(import_notices35.store);
    const { saveEntityRecord, deleteEntityRecord } = (0, import_data256.useDispatch)(import_core_data138.store);
    const { getCurrentPostId: getCurrentPostId2 } = (0, import_data256.useSelect)(store3);
    const { getBlockAttributes: getBlockAttributes2, getSelectedBlockClientId: getSelectedBlockClientId2 } = (0, import_data256.useSelect)(import_block_editor101.store);
    const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data256.useDispatch)(import_block_editor101.store);
    const onError = (error2) => {
      const errorMessage = error2.message && error2.code !== "unknown_error" ? (0, import_html_entities35.decodeEntities)(error2.message) : (0, import_i18n317.__)("An error occurred while performing an update.");
      createNotice("error", errorMessage, {
        type: "snackbar",
        isDismissible: true
      });
    };
    const onCreate = async ({ content, parent }) => {
      try {
        const savedRecord = await saveEntityRecord(
          "root",
          "comment",
          {
            post: getCurrentPostId2(),
            content,
            status: "hold",
            type: "note",
            parent: parent || 0
          },
          { throwOnError: true }
        );
        if (!parent && savedRecord?.id) {
          const clientId = getSelectedBlockClientId2();
          const metadata = getBlockAttributes2(clientId)?.metadata;
          updateBlockAttributes2(clientId, {
            metadata: {
              ...metadata,
              noteId: savedRecord.id
            }
          });
        }
        createNotice(
          "snackbar",
          parent ? (0, import_i18n317.__)("Reply added.") : (0, import_i18n317.__)("Note added."),
          {
            type: "snackbar",
            isDismissible: true
          }
        );
        return savedRecord;
      } catch (error2) {
        onError(error2);
      }
    };
    const onEdit = async ({ id, content, status }) => {
      const messageType = status ? status : "updated";
      const messages = {
        approved: (0, import_i18n317.__)("Note marked as resolved."),
        hold: (0, import_i18n317.__)("Note reopened."),
        updated: (0, import_i18n317.__)("Note updated.")
      };
      try {
        if (status === "approved" || status === "hold") {
          await saveEntityRecord(
            "root",
            "comment",
            {
              id,
              status
            },
            {
              throwOnError: true
            }
          );
          const newNoteData = {
            post: getCurrentPostId2(),
            content: content || "",
            // Empty content for resolve, content for reopen.
            type: "note",
            status,
            parent: id,
            meta: {
              _wp_note_status: status === "approved" ? "resolved" : "reopen"
            }
          };
          await saveEntityRecord("root", "comment", newNoteData, {
            throwOnError: true
          });
        } else {
          const updateData = {
            id,
            content,
            status
          };
          await saveEntityRecord("root", "comment", updateData, {
            throwOnError: true
          });
        }
        createNotice(
          "snackbar",
          messages[messageType] ?? (0, import_i18n317.__)("Note updated."),
          {
            type: "snackbar",
            isDismissible: true
          }
        );
      } catch (error2) {
        onError(error2);
      }
    };
    const onDelete = async (note) => {
      try {
        await deleteEntityRecord("root", "comment", note.id, void 0, {
          throwOnError: true
        });
        if (!note.parent) {
          const clientId = getSelectedBlockClientId2();
          const metadata = getBlockAttributes2(clientId)?.metadata;
          updateBlockAttributes2(clientId, {
            metadata: cleanEmptyObject4({
              ...metadata,
              noteId: void 0
            })
          });
        }
        createNotice("snackbar", (0, import_i18n317.__)("Note deleted."), {
          type: "snackbar",
          isDismissible: true
        });
      } catch (error2) {
        onError(error2);
      }
    };
    return { onCreate, onEdit, onDelete };
  }
  function useEnableFloatingSidebar(enabled = false) {
    const registry = (0, import_data256.useRegistry)();
    (0, import_element294.useEffect)(() => {
      if (!enabled) {
        return;
      }
      const { getActiveComplementaryArea: getActiveComplementaryArea2 } = registry.select(store2);
      const { disableComplementaryArea: disableComplementaryArea2, enableComplementaryArea: enableComplementaryArea2 } = registry.dispatch(store2);
      const unsubscribe = registry.subscribe(() => {
        if (getActiveComplementaryArea2("core") === null) {
          enableComplementaryArea2("core", FLOATING_NOTES_SIDEBAR);
        }
      });
      return () => {
        unsubscribe();
        if (getActiveComplementaryArea2("core") === FLOATING_NOTES_SIDEBAR) {
          disableComplementaryArea2("core", FLOATING_NOTES_SIDEBAR);
        }
      };
    }, [enabled, registry]);
  }
  function useFloatingBoard({
    threads,
    selectedNoteId,
    isFloating,
    sidebarRef
  }) {
    const [notePositions, setNotePositions] = (0, import_element294.useState)({});
    const [store4] = (0, import_element294.useState)(createBoardStore);
    const heights = (0, import_element294.useSyncExternalStore)(store4.subscribe, store4.getSnapshot);
    (0, import_element294.useEffect)(() => {
      if (!isFloating || !sidebarRef?.current) {
        return;
      }
      const panel = sidebarRef.current;
      const blockEl = store4.getFirstBlockElement();
      const rootEl = blockEl?.closest(".is-root-container") ?? blockEl;
      const canvas = rootEl ? (0, import_dom16.getScrollContainer)(rootEl) : null;
      const applyScroll = () => {
        panel.style.setProperty(
          "--canvas-scroll",
          `${-(canvas?.scrollTop ?? 0)}px`
        );
      };
      const rafId = window.requestAnimationFrame(() => {
        const result = calculateNotePositions({
          threads,
          selectedNoteId,
          blockRects: store4.getBlockRects(),
          heights,
          scrollTop: canvas?.scrollTop ?? 0
        });
        setNotePositions(result.positions);
        applyScroll();
      });
      const view2 = canvas?.ownerDocument?.defaultView;
      const listenerOptions = { passive: true, capture: true };
      view2?.addEventListener("scroll", applyScroll, listenerOptions);
      return () => {
        window.cancelAnimationFrame(rafId);
        view2?.removeEventListener("scroll", applyScroll, listenerOptions);
      };
    }, [sidebarRef, heights, isFloating, selectedNoteId, store4, threads]);
    return {
      notePositions,
      registerThread: store4.registerThread,
      unregisterThread: store4.unregisterThread
    };
  }

  // packages/editor/build-module/components/collab-sidebar/notes.mjs
  var import_jsx_runtime507 = __toESM(require_jsx_runtime(), 1);
  var { useBlockElement: useBlockElement3 } = unlock(import_block_editor102.privateApis);
  function Notes({ notes, sidebarRef, isFloating = false, styles }) {
    const {
      onCreate: onAddReply,
      onEdit: onEditNote,
      onDelete
    } = useNoteActions();
    const { selectNote: selectNote2 } = unlock((0, import_data257.useDispatch)(store3));
    const { selectBlock: selectBlock2, toggleBlockSpotlight } = unlock(
      (0, import_data257.useDispatch)(import_block_editor102.store)
    );
    const { blockNoteId, selectedBlockClientId, orderedBlockIds } = (0, import_data257.useSelect)(
      (select7) => {
        const {
          getBlockAttributes: getBlockAttributes2,
          getSelectedBlockClientId: getSelectedBlockClientId2,
          getClientIdsWithDescendants: getClientIdsWithDescendants2
        } = select7(import_block_editor102.store);
        const clientId = getSelectedBlockClientId2();
        return {
          blockNoteId: clientId ? getBlockAttributes2(clientId)?.metadata?.noteId : null,
          selectedBlockClientId: clientId,
          orderedBlockIds: getClientIdsWithDescendants2()
        };
      },
      []
    );
    const { selectedNote: selectedNote2, noteFocused } = (0, import_data257.useSelect)((select7) => {
      const { getSelectedNote: getSelectedNote2, isNoteFocused: isNoteFocused2 } = unlock(
        select7(store3)
      );
      return {
        selectedNote: getSelectedNote2(),
        noteFocused: isNoteFocused2()
      };
    }, []);
    const relatedBlockElement = useBlockElement3(selectedBlockClientId);
    const threads = (0, import_element295.useMemo)(() => {
      if (!isFloating || selectedNote2 !== "new") {
        return notes;
      }
      const newNoteThread = {
        id: "new",
        blockClientId: selectedBlockClientId,
        content: { rendered: "" }
      };
      const out = [];
      orderedBlockIds.forEach((blockId) => {
        if (blockId === selectedBlockClientId) {
          out.push(newNoteThread);
        } else {
          const threadForBlock = notes.find(
            (t4) => t4.blockClientId === blockId
          );
          if (threadForBlock) {
            out.push(threadForBlock);
          }
        }
      });
      return out;
    }, [
      notes,
      isFloating,
      selectedNote2,
      selectedBlockClientId,
      orderedBlockIds
    ]);
    const handleDelete = async (note) => {
      const currentIndex = threads.findIndex((t4) => t4.id === note.id);
      const nextThread = threads[currentIndex + 1];
      const prevThread = threads[currentIndex - 1];
      await onDelete(note);
      if (note.parent !== 0) {
        selectNote2(note.parent);
        focusNoteThread(note.parent, sidebarRef.current);
        return;
      }
      if (nextThread) {
        selectNote2(nextThread.id);
        focusNoteThread(nextThread.id, sidebarRef.current);
      } else if (prevThread) {
        selectNote2(prevThread.id);
        focusNoteThread(prevThread.id, sidebarRef.current);
      } else {
        selectNote2(void 0);
        toggleBlockSpotlight(note.blockClientId, false);
        relatedBlockElement?.focus();
      }
    };
    (0, import_element295.useEffect)(() => {
      selectNote2(blockNoteId ?? void 0);
    }, [blockNoteId, selectNote2]);
    (0, import_element295.useEffect)(() => {
      if (noteFocused && selectedNote2) {
        focusNoteThread(
          selectedNote2,
          sidebarRef.current,
          selectedNote2 === "new" ? "textarea" : void 0
        );
        selectNote2(selectedNote2);
      }
    }, [noteFocused, selectedNote2, selectNote2, sidebarRef]);
    const { notePositions, registerThread, unregisterThread } = useFloatingBoard({
      threads,
      selectedNoteId: selectedNote2,
      isFloating,
      sidebarRef
    });
    const hasThreads = Array.isArray(threads) && threads.length > 0;
    const navigate = (event, thread, isSelected2) => {
      if (event.defaultPrevented) {
        return;
      }
      const currentIndex = threads.findIndex((t4) => t4.id === thread.id);
      const isSelfTarget2 = event.currentTarget === event.target;
      if ((event.key === "Enter" || event.key === "ArrowRight") && isSelfTarget2 && !isSelected2) {
        selectNote2(thread.id);
        if (!!thread.blockClientId) {
          selectBlock2(thread.blockClientId, null);
          toggleBlockSpotlight(thread.blockClientId, true);
        }
      } else if ((event.key === "Enter" || event.key === "ArrowLeft") && isSelfTarget2 && isSelected2 || event.key === "Escape") {
        selectNote2(void 0);
        if (thread.blockClientId) {
          toggleBlockSpotlight(thread.blockClientId, false);
        }
        focusNoteThread(thread.id, sidebarRef.current);
      } else if (event.key === "ArrowDown" && currentIndex < threads.length - 1 && isSelfTarget2) {
        focusNoteThread(
          threads[currentIndex + 1].id,
          sidebarRef.current
        );
      } else if (event.key === "ArrowUp" && currentIndex > 0 && isSelfTarget2) {
        focusNoteThread(
          threads[currentIndex - 1].id,
          sidebarRef.current
        );
      } else if (event.key === "Home" && isSelfTarget2) {
        focusNoteThread(threads[0].id, sidebarRef.current);
      } else if (event.key === "End" && isSelfTarget2) {
        focusNoteThread(
          threads[threads.length - 1].id,
          sidebarRef.current
        );
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime507.jsx)(
      Stack,
      {
        className: "editor-collab-sidebar-panel",
        style: styles,
        role: "tree",
        direction: "column",
        gap: "md",
        justify: "flex-start",
        ref: (node) => {
          if (node) {
            sidebarRef.current = node;
          }
        },
        "aria-label": isFloating ? (0, import_i18n318.__)("Unresolved notes") : (0, import_i18n318.__)("All notes"),
        children: !hasThreads && !isFloating ? /* @__PURE__ */ (0, import_jsx_runtime507.jsx)(AddNote, { onSubmit: onAddReply, sidebarRef }) : /* @__PURE__ */ (0, import_jsx_runtime507.jsxs)(import_jsx_runtime507.Fragment, { children: [
          !isFloating && selectedNote2 === "new" && /* @__PURE__ */ (0, import_jsx_runtime507.jsx)(
            AddNote,
            {
              onSubmit: onAddReply,
              sidebarRef
            }
          ),
          threads.map((thread) => /* @__PURE__ */ (0, import_jsx_runtime507.jsx)(
            NoteThread,
            {
              note: thread,
              onAddReply,
              onDeleteNote: handleDelete,
              onEditNote,
              isSelected: selectedNote2 === thread.id,
              sidebarRef,
              floating: isFloating ? {
                y: notePositions[thread.id],
                registerThread,
                unregisterThread
              } : void 0,
              onKeyDown: (event) => navigate(
                event,
                thread,
                selectedNote2 === thread.id
              )
            },
            thread.id
          ))
        ] })
      }
    );
  }

  // packages/editor/build-module/components/collab-sidebar/add-note-menu-item.mjs
  var import_components284 = __toESM(require_components(), 1);
  var import_i18n319 = __toESM(require_i18n(), 1);
  var import_block_editor103 = __toESM(require_block_editor(), 1);
  var import_data258 = __toESM(require_data(), 1);
  var import_blocks36 = __toESM(require_blocks(), 1);
  var import_keyboard_shortcuts11 = __toESM(require_keyboard_shortcuts(), 1);
  var import_jsx_runtime508 = __toESM(require_jsx_runtime(), 1);
  var { NoteIconSlotFill } = unlock(import_block_editor103.privateApis);
  function NoteMenuItem({ clientId, onClick, isDistractionFree }) {
    const block = (0, import_data258.useSelect)(
      (select7) => {
        return select7(import_block_editor103.store).getBlock(clientId);
      },
      [clientId]
    );
    const shortcut = (0, import_data258.useSelect)(
      (select7) => select7(import_keyboard_shortcuts11.store).getShortcutRepresentation(
        "core/editor/new-note"
      ),
      []
    );
    if (!block?.isValid || block?.name === (0, import_blocks36.getUnregisteredTypeHandlerName)()) {
      return null;
    }
    const isDisabled = isDistractionFree || block?.name === "core/freeform";
    let infoText;
    if (isDistractionFree) {
      infoText = (0, import_i18n319.__)("Notes are disabled in distraction free mode.");
    } else if (block?.name === "core/freeform") {
      infoText = (0, import_i18n319.__)("Convert to blocks to add notes.");
    }
    return /* @__PURE__ */ (0, import_jsx_runtime508.jsx)(
      import_components284.MenuItem,
      {
        onClick,
        "aria-haspopup": "dialog",
        disabled: isDisabled,
        info: infoText,
        shortcut,
        children: (0, import_i18n319.__)("Add note")
      }
    );
  }
  function AddNoteMenuItem({ onClick, isDistractionFree }) {
    return /* @__PURE__ */ (0, import_jsx_runtime508.jsx)(NoteIconSlotFill.Fill, { children: ({ clientId, onClose }) => /* @__PURE__ */ (0, import_jsx_runtime508.jsx)(
      NoteMenuItem,
      {
        clientId,
        isDistractionFree,
        onClick: () => {
          onClick(clientId);
          onClose();
        }
      }
    ) });
  }

  // packages/editor/build-module/components/collab-sidebar/note-indicator-toolbar.mjs
  var import_components285 = __toESM(require_components(), 1);
  var import_i18n320 = __toESM(require_i18n(), 1);
  var import_element296 = __toESM(require_element(), 1);
  var import_block_editor104 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime509 = __toESM(require_jsx_runtime(), 1);
  var { NoteIconToolbarSlotFill } = unlock(import_block_editor104.privateApis);
  function NoteAvatarIndicator({ onClick, note }) {
    const threadParticipants = (0, import_element296.useMemo)(() => {
      if (!note) {
        return [];
      }
      const participantsMap = /* @__PURE__ */ new Map();
      const allNotes = [note, ...note.reply];
      allNotes.sort((a3, b3) => new Date(a3.date) - new Date(b3.date));
      allNotes.forEach((entry) => {
        if (entry.author_name && entry.author_avatar_urls) {
          if (!participantsMap.has(entry.author)) {
            participantsMap.set(entry.author, {
              name: entry.author_name,
              avatar: entry.author_avatar_urls?.["48"] || entry.author_avatar_urls?.["96"],
              id: entry.author,
              date: entry.date
            });
          }
        }
      });
      return Array.from(participantsMap.values());
    }, [note]);
    if (!threadParticipants.length) {
      return null;
    }
    const maxAvatars = 3;
    const isOverflow = threadParticipants.length > maxAvatars;
    const visibleParticipants = isOverflow ? threadParticipants.slice(0, maxAvatars - 1) : threadParticipants;
    const overflowCount = Math.max(
      0,
      threadParticipants.length - visibleParticipants.length
    );
    const threadHasMoreParticipants = threadParticipants.length > 100;
    const overflowText = threadHasMoreParticipants && overflowCount > 0 ? (0, import_i18n320.__)("100+") : (0, import_i18n320.sprintf)(
      // translators: %s: Number of participants.
      (0, import_i18n320.__)("+%s"),
      overflowCount
    );
    return /* @__PURE__ */ (0, import_jsx_runtime509.jsx)(NoteIconToolbarSlotFill.Fill, { children: /* @__PURE__ */ (0, import_jsx_runtime509.jsx)(
      import_components285.ToolbarButton,
      {
        className: "editor-note-indicator",
        label: (0, import_i18n320.__)("View notes"),
        onClick: () => onClick(),
        showTooltip: true,
        children: /* @__PURE__ */ (0, import_jsx_runtime509.jsxs)(Stack, { direction: "row", align: "center", gap: "xs", children: [
          visibleParticipants.map((participant) => /* @__PURE__ */ (0, import_jsx_runtime509.jsx)(
            "img",
            {
              src: participant.avatar,
              alt: participant.name,
              className: "editor-note-indicator__avatar",
              style: {
                borderColor: getAvatarBorderColor(
                  participant.id
                )
              }
            },
            participant.id
          )),
          overflowCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime509.jsx)("span", { className: "editor-note-indicator__overflow", children: overflowText })
        ] })
      }
    ) });
  }

  // packages/editor/build-module/components/collab-sidebar/index.mjs
  var import_jsx_runtime510 = __toESM(require_jsx_runtime(), 1);
  function NotesSidebar({ postId: postId2 }) {
    const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data259.useSelect)(store2);
    const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data259.useDispatch)(store2);
    const { toggleBlockSpotlight, selectBlock: selectBlock2 } = unlock(
      (0, import_data259.useDispatch)(import_block_editor105.store)
    );
    const { selectNote: selectNote2 } = unlock((0, import_data259.useDispatch)(store3));
    const isLargeViewport = (0, import_compose79.useViewportMatch)("medium");
    const sidebarRef = (0, import_element297.useRef)(null);
    const { clientId, noteId, isClassicBlock } = (0, import_data259.useSelect)((select7) => {
      const { getBlockAttributes: getBlockAttributes2, getSelectedBlockClientId: getSelectedBlockClientId2, getBlockName: getBlockName2 } = select7(import_block_editor105.store);
      const _clientId = getSelectedBlockClientId2();
      return {
        clientId: _clientId,
        noteId: _clientId ? getBlockAttributes2(_clientId)?.metadata?.noteId : null,
        isClassicBlock: _clientId ? getBlockName2(_clientId) === "core/freeform" : false
      };
    }, []);
    const { isDistractionFree } = (0, import_data259.useSelect)((select7) => {
      const { get } = select7(import_preferences30.store);
      return {
        isDistractionFree: get("core", "distractionFree")
      };
    }, []);
    const selectedNote2 = (0, import_data259.useSelect)(
      (select7) => unlock(select7(store3)).getSelectedNote(),
      []
    );
    const { notes, unresolvedNotes } = useNoteThreads(postId2);
    const showFloatingSidebar = isLargeViewport;
    const showAllNotesSidebar = notes.length > 0 || !showFloatingSidebar;
    useEnableFloatingSidebar(
      showFloatingSidebar && (unresolvedNotes.length > 0 || selectedNote2 !== void 0)
    );
    (0, import_keyboard_shortcuts12.useShortcut)(
      "core/editor/new-note",
      (event) => {
        event.preventDefault();
        openTheSidebar();
      },
      {
        // When multiple notes per block are supported. Remove note ID check.
        // See: https://github.com/WordPress/gutenberg/pull/75147.
        isDisabled: isDistractionFree || isClassicBlock || !clientId || !!noteId
      }
    );
    const { merged: GlobalStyles } = useGlobalStylesContext();
    const backgroundColor = GlobalStyles?.styles?.color?.background;
    const currentThread = noteId ? notes.find((thread) => thread.id === noteId) : null;
    async function openTheSidebar(selectedClientId) {
      const prevArea = await getActiveComplementaryArea2("core");
      const activeNotesArea = SIDEBARS.find((name2) => name2 === prevArea);
      const targetClientId = selectedClientId && selectedClientId !== clientId ? selectedClientId : clientId;
      const targetNote = notes.find(
        (note) => note.blockClientId === targetClientId
      );
      if (targetNote?.status === "approved") {
        enableComplementaryArea2("core", ALL_NOTES_SIDEBAR);
      } else if (!activeNotesArea || !showAllNotesSidebar) {
        enableComplementaryArea2(
          "core",
          showFloatingSidebar ? FLOATING_NOTES_SIDEBAR : ALL_NOTES_SIDEBAR
        );
      }
      const currentArea = await getActiveComplementaryArea2("core");
      if (!SIDEBARS.includes(currentArea)) {
        return;
      }
      selectBlock2(targetClientId, null);
      toggleBlockSpotlight(targetClientId, true);
      selectNote2(targetNote ? targetNote.id : "new", { focus: true });
    }
    if (isDistractionFree) {
      return /* @__PURE__ */ (0, import_jsx_runtime510.jsx)(AddNoteMenuItem, { isDistractionFree: true });
    }
    return /* @__PURE__ */ (0, import_jsx_runtime510.jsxs)(import_jsx_runtime510.Fragment, { children: [
      !!currentThread && /* @__PURE__ */ (0, import_jsx_runtime510.jsx)(
        NoteAvatarIndicator,
        {
          note: currentThread,
          onClick: openTheSidebar
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime510.jsx)(AddNoteMenuItem, { onClick: openTheSidebar }),
      showAllNotesSidebar && /* @__PURE__ */ (0, import_jsx_runtime510.jsx)(
        PluginSidebar,
        {
          identifier: ALL_NOTES_SIDEBAR,
          name: ALL_NOTES_SIDEBAR,
          title: (0, import_i18n321.__)("All notes"),
          header: /* @__PURE__ */ (0, import_jsx_runtime510.jsx)("h2", { className: "interface-complementary-area-header__title", children: (0, import_i18n321.__)("All notes") }),
          icon: comment_default,
          closeLabel: (0, import_i18n321.__)("Close Notes"),
          children: /* @__PURE__ */ (0, import_jsx_runtime510.jsx)(Notes, { notes, sidebarRef })
        }
      ),
      isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime510.jsx)(
        PluginSidebar,
        {
          isPinnable: false,
          header: false,
          identifier: FLOATING_NOTES_SIDEBAR,
          className: "editor-collab-sidebar",
          headerClassName: "editor-collab-sidebar__header",
          backgroundColor,
          children: /* @__PURE__ */ (0, import_jsx_runtime510.jsx)(
            Notes,
            {
              notes: unresolvedNotes,
              sidebarRef,
              styles: { backgroundColor },
              isFloating: true
            }
          )
        }
      )
    ] });
  }
  function NotesSidebarContainer() {
    const { postId: postId2, editorMode, revisionsMode } = (0, import_data259.useSelect)((select7) => {
      const { getCurrentPostId: getCurrentPostId2, getEditorMode: getEditorMode2, isRevisionsMode: isRevisionsMode2 } = unlock(
        select7(store3)
      );
      return {
        postId: getCurrentPostId2(),
        editorMode: getEditorMode2(),
        revisionsMode: isRevisionsMode2()
      };
    }, []);
    if (!postId2 || typeof postId2 !== "number") {
      return null;
    }
    if (editorMode === "text" || revisionsMode) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime510.jsx)(post_type_support_check_default, { supportKeys: "editor.notes", children: /* @__PURE__ */ (0, import_jsx_runtime510.jsx)(NotesSidebar, { postId: postId2 }) });
  }

  // packages/editor/build-module/components/global-styles-sidebar/index.mjs
  var import_components288 = __toESM(require_components(), 1);
  var import_i18n324 = __toESM(require_i18n(), 1);
  var import_data262 = __toESM(require_data(), 1);
  var import_element298 = __toESM(require_element(), 1);
  var import_preferences33 = __toESM(require_preferences(), 1);
  var import_compose80 = __toESM(require_compose(), 1);
  var import_core_data140 = __toESM(require_core_data(), 1);

  // packages/editor/build-module/components/global-styles/menu.mjs
  var import_components286 = __toESM(require_components(), 1);
  var import_data260 = __toESM(require_data(), 1);
  var import_i18n322 = __toESM(require_i18n(), 1);
  var import_preferences31 = __toESM(require_preferences(), 1);
  var import_core_data139 = __toESM(require_core_data(), 1);
  var import_jsx_runtime511 = __toESM(require_jsx_runtime(), 1);
  function GlobalStylesActionMenu({
    hideWelcomeGuide = false,
    onChangePath
  }) {
    const { user, setUser } = useGlobalStyles();
    const canReset = !!user && (Object.keys(user?.styles ?? {}).length > 0 || Object.keys(user?.settings ?? {}).length > 0);
    const onReset = () => {
      setUser({ styles: {}, settings: {} });
    };
    const { toggle } = (0, import_data260.useDispatch)(import_preferences31.store);
    const { canEditCSS } = (0, import_data260.useSelect)((select7) => {
      const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select7(import_core_data139.store);
      const globalStylesId = __experimentalGetCurrentGlobalStylesId();
      const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0;
      return {
        canEditCSS: !!globalStyles?._links?.["wp:action-edit-css"]
      };
    }, []);
    const loadCustomCSS = () => {
      onChangePath("/css");
    };
    return /* @__PURE__ */ (0, import_jsx_runtime511.jsx)(
      import_components286.DropdownMenu,
      {
        icon: more_vertical_default,
        label: (0, import_i18n322.__)("More"),
        toggleProps: { size: "compact" },
        children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime511.jsxs)(import_jsx_runtime511.Fragment, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime511.jsxs)(import_components286.MenuGroup, { children: [
            canEditCSS && /* @__PURE__ */ (0, import_jsx_runtime511.jsx)(import_components286.MenuItem, { onClick: loadCustomCSS, children: (0, import_i18n322.__)("Additional CSS") }),
            !hideWelcomeGuide && /* @__PURE__ */ (0, import_jsx_runtime511.jsx)(
              import_components286.MenuItem,
              {
                onClick: () => {
                  toggle(
                    "core/edit-site",
                    "welcomeGuideStyles"
                  );
                  onClose();
                },
                children: (0, import_i18n322.__)("Welcome Guide")
              }
            )
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime511.jsx)(import_components286.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime511.jsx)(
            import_components286.MenuItem,
            {
              onClick: () => {
                onReset();
                onClose();
              },
              disabled: !canReset,
              children: (0, import_i18n322.__)("Reset styles")
            }
          ) })
        ] })
      }
    );
  }

  // packages/editor/build-module/components/global-styles-sidebar/default-sidebar.mjs
  var import_jsx_runtime512 = __toESM(require_jsx_runtime(), 1);
  function DefaultSidebar({
    className,
    identifier,
    title,
    icon,
    children,
    closeLabel,
    header,
    headerClassName,
    panelClassName,
    isActiveByDefault
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime512.jsxs)(import_jsx_runtime512.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime512.jsx)(
        complementary_area_default,
        {
          className,
          scope: "core",
          identifier,
          title,
          icon,
          closeLabel,
          header,
          headerClassName,
          panelClassName,
          isActiveByDefault,
          children
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime512.jsx)(
        ComplementaryAreaMoreMenuItem,
        {
          scope: "core",
          identifier,
          icon,
          children: title
        }
      )
    ] });
  }

  // packages/editor/build-module/components/global-styles-sidebar/welcome-guide.mjs
  var import_data261 = __toESM(require_data(), 1);
  var import_components287 = __toESM(require_components(), 1);
  var import_i18n323 = __toESM(require_i18n(), 1);
  var import_preferences32 = __toESM(require_preferences(), 1);

  // packages/editor/build-module/components/global-styles-sidebar/welcome-guide-image.mjs
  var import_jsx_runtime513 = __toESM(require_jsx_runtime(), 1);
  function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) {
    return /* @__PURE__ */ (0, import_jsx_runtime513.jsxs)("picture", { className: "editor-welcome-guide__image", children: [
      /* @__PURE__ */ (0, import_jsx_runtime513.jsx)(
        "source",
        {
          srcSet: nonAnimatedSrc,
          media: "(prefers-reduced-motion: reduce)"
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime513.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" })
    ] });
  }

  // packages/editor/build-module/components/global-styles-sidebar/welcome-guide.mjs
  var import_jsx_runtime514 = __toESM(require_jsx_runtime(), 1);
  function WelcomeGuideStyles() {
    const { toggle } = (0, import_data261.useDispatch)(import_preferences32.store);
    const { isActive, isStylesOpen } = (0, import_data261.useSelect)((select7) => {
      const sidebar = select7(store2).getActiveComplementaryArea("core");
      return {
        isActive: !!select7(import_preferences32.store).get(
          "core/edit-site",
          "welcomeGuideStyles"
        ),
        isStylesOpen: sidebar === "edit-site/global-styles"
      };
    }, []);
    if (!isActive || !isStylesOpen) {
      return null;
    }
    const welcomeLabel = (0, import_i18n323.__)("Welcome to Styles");
    return /* @__PURE__ */ (0, import_jsx_runtime514.jsx)(
      import_components287.Guide,
      {
        className: "editor-welcome-guide guide-styles",
        contentLabel: welcomeLabel,
        finishButtonText: (0, import_i18n323.__)("Get started"),
        onFinish: () => toggle("core/edit-site", "welcomeGuideStyles"),
        pages: [
          {
            image: /* @__PURE__ */ (0, import_jsx_runtime514.jsx)(
              WelcomeGuideImage,
              {
                nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.svg?1",
                animatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.gif?1"
              }
            ),
            content: /* @__PURE__ */ (0, import_jsx_runtime514.jsxs)(import_jsx_runtime514.Fragment, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime514.jsx)("h1", { className: "editor-welcome-guide__heading", children: welcomeLabel }),
              /* @__PURE__ */ (0, import_jsx_runtime514.jsx)("p", { className: "editor-welcome-guide__text", children: (0, import_i18n323.__)(
                "Tweak your site, or give it a whole new look! Get creative \u2014 how about a new color palette for your buttons, or choosing a new font? Take a look at what you can do here."
              ) })
            ] })
          },
          {
            image: /* @__PURE__ */ (0, import_jsx_runtime514.jsx)(
              WelcomeGuideImage,
              {
                nonAnimatedSrc: "https://s.w.org/images/block-editor/set-the-design.svg?1",
                animatedSrc: "https://s.w.org/images/block-editor/set-the-design.gif?1"
              }
            ),
            content: /* @__PURE__ */ (0, import_jsx_runtime514.jsxs)(import_jsx_runtime514.Fragment, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime514.jsx)("h1", { className: "editor-welcome-guide__heading", children: (0, import_i18n323.__)("Set the design") }),
              /* @__PURE__ */ (0, import_jsx_runtime514.jsx)("p", { className: "editor-welcome-guide__text", children: (0, import_i18n323.__)(
                "You can customize your site as much as you like with different colors, typography, and layouts. Or if you prefer, just leave it up to your theme to handle!"
              ) })
            ] })
          },
          {
            image: /* @__PURE__ */ (0, import_jsx_runtime514.jsx)(
              WelcomeGuideImage,
              {
                nonAnimatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.svg?1",
                animatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.gif?1"
              }
            ),
            content: /* @__PURE__ */ (0, import_jsx_runtime514.jsxs)(import_jsx_runtime514.Fragment, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime514.jsx)("h1", { className: "editor-welcome-guide__heading", children: (0, import_i18n323.__)("Personalize blocks") }),
              /* @__PURE__ */ (0, import_jsx_runtime514.jsx)("p", { className: "editor-welcome-guide__text", children: (0, import_i18n323.__)(
                "You can adjust your blocks to ensure a cohesive experience across your site \u2014 add your unique colors to a branded Button block, or adjust the Heading block to your preferred size."
              ) })
            ] })
          },
          {
            image: /* @__PURE__ */ (0, import_jsx_runtime514.jsx)(
              WelcomeGuideImage,
              {
                nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
                animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
              }
            ),
            content: /* @__PURE__ */ (0, import_jsx_runtime514.jsxs)(import_jsx_runtime514.Fragment, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime514.jsx)("h1", { className: "editor-welcome-guide__heading", children: (0, import_i18n323.__)("Learn more") }),
              /* @__PURE__ */ (0, import_jsx_runtime514.jsxs)("p", { className: "editor-welcome-guide__text", children: [
                (0, import_i18n323.__)(
                  "New to block themes and styling your site?"
                ),
                " ",
                /* @__PURE__ */ (0, import_jsx_runtime514.jsx)(
                  import_components287.ExternalLink,
                  {
                    href: (0, import_i18n323.__)(
                      "https://wordpress.org/documentation/article/styles-overview/"
                    ),
                    children: (0, import_i18n323.__)(
                      "Here\u2019s a detailed guide to learn how to make the most of it."
                    )
                  }
                )
              ] })
            ] })
          }
        ]
      }
    );
  }

  // packages/editor/build-module/components/global-styles-sidebar/index.mjs
  var import_jsx_runtime515 = __toESM(require_jsx_runtime(), 1);
  function GlobalStylesSidebar() {
    const {
      shouldResetNavigation,
      stylesPath: stylesPath2,
      showStylebook: showStylebook2,
      showListViewByDefault,
      hasRevisions,
      activeComplementaryArea,
      editorSettings: editorSettings2
    } = (0, import_data262.useSelect)((select7) => {
      const { getActiveComplementaryArea: getActiveComplementaryArea2 } = select7(store2);
      const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock(
        select7(store3)
      );
      const _isVisualEditorMode = "visual" === select7(store3).getEditorMode();
      const _showListViewByDefault = select7(import_preferences33.store).get(
        "core",
        "showListViewByDefault"
      );
      const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select7(import_core_data140.store);
      const globalStylesId = __experimentalGetCurrentGlobalStylesId();
      const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0;
      return {
        stylesPath: getStylesPath2(),
        showStylebook: getShowStylebook2(),
        shouldResetNavigation: "edit-site/global-styles" !== getActiveComplementaryArea2("core") || !_isVisualEditorMode,
        showListViewByDefault: _showListViewByDefault,
        hasRevisions: !!globalStyles?._links?.["version-history"]?.[0]?.count,
        activeComplementaryArea: select7(store2).getActiveComplementaryArea("core"),
        editorSettings: select7(store3).getEditorSettings()
      };
    }, []);
    const { setStylesPath: setStylesPath2, setShowStylebook: setShowStylebook2, resetStylesNavigation: resetStylesNavigation2 } = unlock(
      (0, import_data262.useDispatch)(store3)
    );
    const isMobileViewport = (0, import_compose80.useViewportMatch)("medium", "<");
    const isRevisionsOpened = stylesPath2.startsWith("/revisions") && !showStylebook2;
    const isRevisionsStyleBookOpened = stylesPath2.startsWith("/revisions") && showStylebook2;
    const previousActiveArea = (0, import_compose80.usePrevious)(activeComplementaryArea);
    (0, import_element298.useEffect)(() => {
      if (activeComplementaryArea === "edit-site/global-styles" && previousActiveArea !== "edit-site/global-styles") {
        resetStylesNavigation2();
      }
    }, [activeComplementaryArea, previousActiveArea, resetStylesNavigation2]);
    (0, import_element298.useEffect)(() => {
      if (shouldResetNavigation) {
        resetStylesNavigation2();
      }
    }, [shouldResetNavigation, resetStylesNavigation2]);
    const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data262.useDispatch)(store3);
    const toggleRevisions = () => {
      setIsListViewOpened2(false);
      if (isRevisionsOpened || isRevisionsStyleBookOpened) {
        setStylesPath2("/");
      } else {
        setStylesPath2("/revisions");
      }
    };
    const toggleStyleBook = () => {
      setIsListViewOpened2(showStylebook2 && showListViewByDefault);
      setShowStylebook2(!showStylebook2);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime515.jsxs)(import_jsx_runtime515.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime515.jsx)(
        DefaultSidebar,
        {
          className: "editor-global-styles-sidebar",
          identifier: "edit-site/global-styles",
          title: (0, import_i18n324.__)("Styles"),
          icon: styles_default,
          closeLabel: (0, import_i18n324.__)("Close Styles"),
          panelClassName: "editor-global-styles-sidebar__panel",
          header: /* @__PURE__ */ (0, import_jsx_runtime515.jsxs)(
            import_components288.Flex,
            {
              className: "editor-global-styles-sidebar__header",
              gap: 1,
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime515.jsx)(import_components288.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime515.jsx)("h2", { className: "editor-global-styles-sidebar__header-title", children: (0, import_i18n324.__)("Styles") }) }),
                /* @__PURE__ */ (0, import_jsx_runtime515.jsxs)(
                  import_components288.Flex,
                  {
                    justify: "flex-end",
                    gap: 1,
                    className: "editor-global-styles-sidebar__header-actions",
                    children: [
                      !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime515.jsx)(import_components288.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime515.jsx)(
                        import_components288.Button,
                        {
                          icon: seen_default,
                          label: (0, import_i18n324.__)("Style Book"),
                          isPressed: showStylebook2,
                          accessibleWhenDisabled: true,
                          disabled: shouldResetNavigation,
                          onClick: toggleStyleBook,
                          size: "compact"
                        }
                      ) }),
                      /* @__PURE__ */ (0, import_jsx_runtime515.jsx)(import_components288.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime515.jsx)(
                        import_components288.Button,
                        {
                          label: (0, import_i18n324.__)("Revisions"),
                          icon: backup_default,
                          onClick: toggleRevisions,
                          accessibleWhenDisabled: true,
                          disabled: !hasRevisions,
                          isPressed: isRevisionsOpened || isRevisionsStyleBookOpened,
                          size: "compact"
                        }
                      ) }),
                      /* @__PURE__ */ (0, import_jsx_runtime515.jsx)(
                        GlobalStylesActionMenu,
                        {
                          onChangePath: setStylesPath2
                        }
                      )
                    ]
                  }
                )
              ]
            }
          ),
          children: /* @__PURE__ */ (0, import_jsx_runtime515.jsx)(
            GlobalStylesUIWrapper,
            {
              path: stylesPath2,
              onPathChange: setStylesPath2,
              settings: editorSettings2
            }
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime515.jsx)(WelcomeGuideStyles, {})
    ] });
  }

  // packages/editor/build-module/components/editor/index.mjs
  var import_jsx_runtime516 = __toESM(require_jsx_runtime(), 1);
  function Editor({
    postType: postType2,
    postId: postId2,
    templateId: templateId2,
    settings,
    children,
    initialEdits,
    // This could be part of the settings.
    onActionPerformed,
    // The following abstractions are not ideal but necessary
    // to account for site editor and post editor differences for now.
    extraContent,
    extraSidebarPanels,
    ...props
  }) {
    const {
      post: post2,
      template: template2,
      hasLoadedPost,
      error: error2,
      isBlockTheme,
      showGlobalStyles
    } = (0, import_data263.useSelect)(
      (select7) => {
        const {
          getEntityRecord,
          getResolutionError,
          hasFinishedResolution,
          getCurrentTheme,
          __experimentalGetCurrentGlobalStylesId,
          canUser
        } = select7(import_core_data141.store);
        const { getRenderingMode: getRenderingMode2, getCurrentPostType: getCurrentPostType2 } = select7(store3);
        const postArgs = ["postType", postType2, postId2];
        const renderingMode2 = getRenderingMode2();
        const currentPostType = getCurrentPostType2();
        const _isBlockTheme = getCurrentTheme()?.is_block_theme;
        const globalStylesId = __experimentalGetCurrentGlobalStylesId();
        const userCanEditGlobalStyles = globalStylesId ? canUser("update", {
          kind: "root",
          name: "globalStyles",
          id: globalStylesId
        }) : false;
        return {
          post: getEntityRecord(...postArgs),
          template: templateId2 ? getEntityRecord(
            "postType",
            TEMPLATE_POST_TYPE,
            templateId2
          ) : void 0,
          hasLoadedPost: hasFinishedResolution(
            "getEntityRecord",
            postArgs
          ),
          error: getResolutionError("getEntityRecord", postArgs)?.message,
          isBlockTheme: _isBlockTheme,
          showGlobalStyles: _isBlockTheme && userCanEditGlobalStyles && (currentPostType === "wp_template" || renderingMode2 === "template-locked")
        };
      },
      [postType2, postId2, templateId2]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime516.jsxs)(import_jsx_runtime516.Fragment, { children: [
      hasLoadedPost && !post2 && /* @__PURE__ */ (0, import_jsx_runtime516.jsx)(
        import_components289.Notice,
        {
          status: !!error2 ? "error" : "warning",
          isDismissible: false,
          children: !error2 ? (0, import_i18n325.__)(
            "You attempted to edit an item that doesn't exist. Perhaps it was deleted?"
          ) : error2
        }
      ),
      !!post2 && /* @__PURE__ */ (0, import_jsx_runtime516.jsxs)(
        ExperimentalEditorProvider,
        {
          post: post2,
          __unstableTemplate: template2,
          settings,
          initialEdits,
          useSubRegistry: false,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime516.jsx)(EditorInterface, { ...props, children: extraContent }),
            children,
            /* @__PURE__ */ (0, import_jsx_runtime516.jsx)(
              sidebar_default2,
              {
                onActionPerformed,
                extraPanels: extraSidebarPanels
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime516.jsx)(NotesSidebarContainer, {}),
            isBlockTheme && /* @__PURE__ */ (0, import_jsx_runtime516.jsx)(GlobalStylesRenderer, {}),
            showGlobalStyles && /* @__PURE__ */ (0, import_jsx_runtime516.jsx)(GlobalStylesSidebar, {})
          ]
        }
      )
    ] });
  }
  var editor_default = Editor;

  // packages/editor/build-module/components/preferences-modal/index.mjs
  var import_i18n327 = __toESM(require_i18n(), 1);
  var import_compose81 = __toESM(require_compose(), 1);
  var import_data266 = __toESM(require_data(), 1);
  var import_element300 = __toESM(require_element(), 1);
  var import_preferences36 = __toESM(require_preferences(), 1);

  // packages/editor/build-module/components/preferences-modal/enable-publish-sidebar.mjs
  var import_data264 = __toESM(require_data(), 1);
  var import_preferences34 = __toESM(require_preferences(), 1);
  var import_jsx_runtime517 = __toESM(require_jsx_runtime(), 1);
  var { PreferenceBaseOption: PreferenceBaseOption2 } = unlock(import_preferences34.privateApis);
  function EnablePublishSidebarOption(props) {
    const isChecked = (0, import_data264.useSelect)((select7) => {
      return select7(store3).isPublishSidebarEnabled();
    }, []);
    const { enablePublishSidebar: enablePublishSidebar2, disablePublishSidebar: disablePublishSidebar2 } = (0, import_data264.useDispatch)(store3);
    return /* @__PURE__ */ (0, import_jsx_runtime517.jsx)(
      PreferenceBaseOption2,
      {
        isChecked,
        onChange: (isEnabled) => isEnabled ? enablePublishSidebar2() : disablePublishSidebar2(),
        ...props
      }
    );
  }

  // packages/editor/build-module/components/block-visibility/index.mjs
  var import_data265 = __toESM(require_data(), 1);
  var import_preferences35 = __toESM(require_preferences(), 1);
  var import_blocks37 = __toESM(require_blocks(), 1);
  var import_element299 = __toESM(require_element(), 1);
  var import_components290 = __toESM(require_components(), 1);
  var import_i18n326 = __toESM(require_i18n(), 1);
  var import_block_editor106 = __toESM(require_block_editor(), 1);
  var import_jsx_runtime518 = __toESM(require_jsx_runtime(), 1);
  var { BlockManager } = unlock(import_block_editor106.privateApis);
  var EMPTY_ARRAY15 = [];
  function BlockVisibility() {
    const { showBlockTypes: showBlockTypes2, hideBlockTypes: hideBlockTypes2 } = unlock(
      (0, import_data265.useDispatch)(store3)
    );
    const {
      blockTypes,
      allowedBlockTypes: _allowedBlockTypes,
      hiddenBlockTypes: _hiddenBlockTypes
    } = (0, import_data265.useSelect)((select7) => {
      return {
        blockTypes: select7(import_blocks37.store).getBlockTypes(),
        allowedBlockTypes: select7(store3).getEditorSettings().allowedBlockTypes,
        hiddenBlockTypes: select7(import_preferences35.store).get("core", "hiddenBlockTypes") ?? EMPTY_ARRAY15
      };
    }, []);
    const allowedBlockTypes = (0, import_element299.useMemo)(() => {
      if (_allowedBlockTypes === true) {
        return blockTypes;
      }
      return blockTypes.filter(({ name: name2 }) => {
        return _allowedBlockTypes?.includes(name2);
      });
    }, [_allowedBlockTypes, blockTypes]);
    const filteredBlockTypes = allowedBlockTypes.filter(
      (blockType) => (0, import_blocks37.hasBlockSupport)(blockType, "inserter", true) && (!blockType.parent || blockType.parent.includes("core/post-content"))
    );
    const hiddenBlockTypes = _hiddenBlockTypes.filter((hiddenBlock) => {
      return filteredBlockTypes.some(
        (registeredBlock) => registeredBlock.name === hiddenBlock
      );
    });
    const selectedBlockTypes = filteredBlockTypes.filter(
      (blockType) => !hiddenBlockTypes.includes(blockType.name)
    );
    const numberOfHiddenBlocks = filteredBlockTypes.length - selectedBlockTypes.length;
    function enableAllBlockTypes() {
      onChangeSelectedBlockTypes(filteredBlockTypes);
    }
    const onChangeSelectedBlockTypes = (newSelectedBlockTypes) => {
      if (selectedBlockTypes.length > newSelectedBlockTypes.length) {
        const blockTypesToHide = selectedBlockTypes.filter(
          (blockType) => !newSelectedBlockTypes.find(
            ({ name: name2 }) => name2 === blockType.name
          )
        );
        hideBlockTypes2(blockTypesToHide.map(({ name: name2 }) => name2));
      } else if (selectedBlockTypes.length < newSelectedBlockTypes.length) {
        const blockTypesToShow = newSelectedBlockTypes.filter(
          (blockType) => !selectedBlockTypes.find(
            ({ name: name2 }) => name2 === blockType.name
          )
        );
        showBlockTypes2(blockTypesToShow.map(({ name: name2 }) => name2));
      }
    };
    return /* @__PURE__ */ (0, import_jsx_runtime518.jsxs)("div", { className: "editor-block-visibility", children: [
      !!numberOfHiddenBlocks && /* @__PURE__ */ (0, import_jsx_runtime518.jsxs)("div", { className: "editor-block-visibility__disabled-blocks-count", children: [
        (0, import_i18n326.sprintf)(
          /* translators: %d: number of blocks. */
          (0, import_i18n326._n)(
            "%d block is hidden.",
            "%d blocks are hidden.",
            numberOfHiddenBlocks
          ),
          numberOfHiddenBlocks
        ),
        /* @__PURE__ */ (0, import_jsx_runtime518.jsx)(
          import_components290.Button,
          {
            __next40pxDefaultSize: true,
            variant: "link",
            onClick: enableAllBlockTypes,
            children: (0, import_i18n326.__)("Reset")
          }
        )
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime518.jsx)(
        BlockManager,
        {
          blockTypes: filteredBlockTypes,
          selectedBlockTypes,
          onChange: onChangeSelectedBlockTypes,
          showSelectAll: false
        }
      )
    ] });
  }

  // packages/editor/build-module/components/preferences-modal/index.mjs
  var import_jsx_runtime519 = __toESM(require_jsx_runtime(), 1);
  var {
    PreferencesModal,
    PreferencesModalTabs,
    PreferencesModalSection,
    PreferenceToggleControl
  } = unlock(import_preferences36.privateApis);
  function EditorPreferencesModal({ extraSections = {} }) {
    const isActive = (0, import_data266.useSelect)((select7) => {
      return select7(store2).isModalActive("editor/preferences");
    }, []);
    const { closeModal: closeModal2 } = (0, import_data266.useDispatch)(store2);
    if (!isActive) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(PreferencesModal, { closeModal: closeModal2, children: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(PreferencesModalContents, { extraSections }) });
  }
  function PreferencesModalContents({ extraSections = {} }) {
    const isLargeViewport = (0, import_compose81.useViewportMatch)("medium");
    const { showBlockBreadcrumbsOption, showCollaborationOptions } = (0, import_data266.useSelect)(
      (select7) => {
        const { getEditorSettings: getEditorSettings2, isCollaborationEnabledForCurrentPost: isCollaborationEnabledForCurrentPost2 } = select7(store3);
        const { get } = select7(import_preferences36.store);
        const isRichEditingEnabled = getEditorSettings2().richEditingEnabled;
        const isDistractionFreeEnabled = get("core", "distractionFree");
        return {
          showBlockBreadcrumbsOption: !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled,
          showCollaborationOptions: isCollaborationEnabledForCurrentPost2()
        };
      },
      [isLargeViewport]
    );
    const { setIsListViewOpened: setIsListViewOpened2, setIsInserterOpened: setIsInserterOpened2 } = (0, import_data266.useDispatch)(store3);
    const { set: setPreference } = (0, import_data266.useDispatch)(import_preferences36.store);
    const sections = (0, import_element300.useMemo)(
      () => [
        {
          name: "general",
          tabLabel: (0, import_i18n327.__)("General"),
          content: /* @__PURE__ */ (0, import_jsx_runtime519.jsxs)(import_jsx_runtime519.Fragment, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime519.jsxs)(
              PreferencesModalSection,
              {
                title: (0, import_i18n327.__)("Interface"),
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                    PreferenceToggleControl,
                    {
                      scope: "core",
                      featureName: "showListViewByDefault",
                      help: (0, import_i18n327.__)(
                        "Opens the List View panel by default."
                      ),
                      label: (0, import_i18n327.__)("Always open List View")
                    }
                  ),
                  showBlockBreadcrumbsOption && /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                    PreferenceToggleControl,
                    {
                      scope: "core",
                      featureName: "showBlockBreadcrumbs",
                      help: (0, import_i18n327.__)(
                        "Display the block hierarchy trail at the bottom of the editor."
                      ),
                      label: (0, import_i18n327.__)("Show block breadcrumbs")
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                    PreferenceToggleControl,
                    {
                      scope: "core",
                      featureName: "allowRightClickOverrides",
                      help: (0, import_i18n327.__)(
                        "Allows contextual List View menus via right-click, overriding browser defaults."
                      ),
                      label: (0, import_i18n327.__)(
                        "Allow right-click contextual menus"
                      )
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                    PreferenceToggleControl,
                    {
                      scope: "core",
                      featureName: "enableChoosePatternModal",
                      help: (0, import_i18n327.__)(
                        "Pick from starter content when creating a new page."
                      ),
                      label: (0, import_i18n327.__)("Show starter patterns")
                    }
                  ),
                  showCollaborationOptions && /* @__PURE__ */ (0, import_jsx_runtime519.jsxs)(import_jsx_runtime519.Fragment, { children: [
                    /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                      PreferenceToggleControl,
                      {
                        scope: "core",
                        featureName: "showCollaborationCursor",
                        help: (0, import_i18n327.__)(
                          "Show your own avatar inside blocks during collaborative editing sessions."
                        ),
                        label: (0, import_i18n327.__)(
                          "Show avatar in blocks"
                        )
                      }
                    ),
                    /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                      PreferenceToggleControl,
                      {
                        scope: "core",
                        featureName: "showCollaborationNotifications",
                        help: (0, import_i18n327.__)(
                          "Show notifications when collaborators join, leave, or save the post."
                        ),
                        label: (0, import_i18n327.__)(
                          "Show collaboration notifications"
                        )
                      }
                    )
                  ] })
                ]
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime519.jsxs)(
              PreferencesModalSection,
              {
                title: (0, import_i18n327.__)("Document settings"),
                description: (0, import_i18n327.__)(
                  "Select what settings are shown in the document panel."
                ),
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(enable_plugin_document_setting_panel_default.Slot, {}),
                  /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                    post_taxonomies_default,
                    {
                      taxonomyWrapper: (content, taxonomy) => /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                        EnablePanelOption,
                        {
                          label: taxonomy.labels.menu_name,
                          panelName: `taxonomy-panel-${taxonomy.slug}`
                        }
                      )
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(check_default4, { children: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                    EnablePanelOption,
                    {
                      label: (0, import_i18n327.__)("Featured image"),
                      panelName: "featured-image"
                    }
                  ) }),
                  /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(check_default3, { children: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                    EnablePanelOption,
                    {
                      label: (0, import_i18n327.__)("Excerpt"),
                      panelName: "post-excerpt"
                    }
                  ) }),
                  /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                    post_type_support_check_default,
                    {
                      supportKeys: ["comments", "trackbacks"],
                      children: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                        EnablePanelOption,
                        {
                          label: (0, import_i18n327.__)("Discussion"),
                          panelName: "discussion-panel"
                        }
                      )
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(check_default2, { children: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                    EnablePanelOption,
                    {
                      label: (0, import_i18n327.__)("Page attributes"),
                      panelName: "page-attributes"
                    }
                  ) })
                ]
              }
            ),
            isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
              PreferencesModalSection,
              {
                title: (0, import_i18n327.__)("Publishing"),
                children: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                  EnablePublishSidebarOption,
                  {
                    help: (0, import_i18n327.__)(
                      "Review settings, such as visibility and tags."
                    ),
                    label: (0, import_i18n327.__)(
                      "Enable pre-publish checks"
                    )
                  }
                )
              }
            ),
            extraSections?.general
          ] })
        },
        {
          name: "appearance",
          tabLabel: (0, import_i18n327.__)("Appearance"),
          content: /* @__PURE__ */ (0, import_jsx_runtime519.jsxs)(
            PreferencesModalSection,
            {
              title: (0, import_i18n327.__)("Appearance"),
              description: (0, import_i18n327.__)(
                "Customize the editor interface to suit your needs."
              ),
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                  PreferenceToggleControl,
                  {
                    scope: "core",
                    featureName: "fixedToolbar",
                    onToggle: () => setPreference(
                      "core",
                      "distractionFree",
                      false
                    ),
                    help: (0, import_i18n327.__)(
                      "Access all block and document tools in a single place."
                    ),
                    label: (0, import_i18n327.__)("Top toolbar")
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                  PreferenceToggleControl,
                  {
                    scope: "core",
                    featureName: "distractionFree",
                    onToggle: () => {
                      setPreference(
                        "core",
                        "fixedToolbar",
                        true
                      );
                      setIsInserterOpened2(false);
                      setIsListViewOpened2(false);
                    },
                    help: (0, import_i18n327.__)(
                      "Reduce visual distractions by hiding the toolbar and other elements to focus on writing."
                    ),
                    label: (0, import_i18n327.__)("Distraction free")
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                  PreferenceToggleControl,
                  {
                    scope: "core",
                    featureName: "focusMode",
                    help: (0, import_i18n327.__)(
                      "Highlights the current block and fades other content."
                    ),
                    label: (0, import_i18n327.__)("Spotlight mode")
                  }
                ),
                extraSections?.appearance
              ]
            }
          )
        },
        {
          name: "accessibility",
          tabLabel: (0, import_i18n327.__)("Accessibility"),
          content: /* @__PURE__ */ (0, import_jsx_runtime519.jsxs)(import_jsx_runtime519.Fragment, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
              PreferencesModalSection,
              {
                title: (0, import_i18n327.__)("Navigation"),
                description: (0, import_i18n327.__)(
                  "Optimize the editing experience for enhanced control."
                ),
                children: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                  PreferenceToggleControl,
                  {
                    scope: "core",
                    featureName: "keepCaretInsideBlock",
                    help: (0, import_i18n327.__)(
                      "Keeps the text cursor within blocks while navigating with arrow keys, preventing it from moving to other blocks and enhancing accessibility for keyboard users."
                    ),
                    label: (0, import_i18n327.__)(
                      "Contain text cursor inside block"
                    )
                  }
                )
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
              PreferencesModalSection,
              {
                title: (0, import_i18n327.__)("Interface"),
                children: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                  PreferenceToggleControl,
                  {
                    scope: "core",
                    featureName: "showIconLabels",
                    label: (0, import_i18n327.__)("Show button text labels"),
                    help: (0, import_i18n327.__)(
                      "Show text instead of icons on buttons across the interface."
                    )
                  }
                )
              }
            )
          ] })
        },
        {
          name: "blocks",
          tabLabel: (0, import_i18n327.__)("Blocks"),
          content: /* @__PURE__ */ (0, import_jsx_runtime519.jsxs)(import_jsx_runtime519.Fragment, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(PreferencesModalSection, { title: (0, import_i18n327.__)("Inserter"), children: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
              PreferenceToggleControl,
              {
                scope: "core",
                featureName: "mostUsedBlocks",
                help: (0, import_i18n327.__)(
                  "Adds a category with the most frequently used blocks in the inserter."
                ),
                label: (0, import_i18n327.__)("Show most used blocks")
              }
            ) }),
            /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
              PreferencesModalSection,
              {
                title: (0, import_i18n327.__)("Manage block visibility"),
                description: (0, import_i18n327.__)(
                  "Disable blocks that you don't want to appear in the inserter. They can always be toggled back on later."
                ),
                children: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(BlockVisibility, {})
              }
            )
          ] })
        },
        window.__clientSideMediaProcessing && {
          name: "media",
          tabLabel: (0, import_i18n327.__)("Media"),
          content: /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(import_jsx_runtime519.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime519.jsxs)(
            PreferencesModalSection,
            {
              title: (0, import_i18n327.__)("General"),
              description: (0, import_i18n327.__)(
                "Customize options related to the media upload flow."
              ),
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                  PreferenceToggleControl,
                  {
                    scope: "core/media",
                    featureName: "optimizeOnUpload",
                    help: (0, import_i18n327.__)(
                      "Compress media items before uploading to the server."
                    ),
                    label: (0, import_i18n327.__)("Pre-upload compression")
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(
                  PreferenceToggleControl,
                  {
                    scope: "core/media",
                    featureName: "requireApproval",
                    help: (0, import_i18n327.__)(
                      "Require approval step when optimizing existing media."
                    ),
                    label: (0, import_i18n327.__)("Approval step")
                  }
                )
              ]
            }
          ) })
        }
      ].filter(Boolean),
      [
        showBlockBreadcrumbsOption,
        showCollaborationOptions,
        extraSections,
        setIsInserterOpened2,
        setIsListViewOpened2,
        setPreference,
        isLargeViewport
      ]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime519.jsx)(PreferencesModalTabs, { sections });
  }

  // packages/editor/build-module/bindings/api.mjs
  var import_blocks38 = __toESM(require_blocks(), 1);

  // packages/editor/build-module/bindings/pattern-overrides.mjs
  var import_block_editor107 = __toESM(require_block_editor(), 1);
  var CONTENT = "content";
  var pattern_overrides_default = {
    name: "core/pattern-overrides",
    getValues({ select: select7, clientId, context, bindings }) {
      const patternOverridesContent = context["pattern/overrides"];
      const { getBlockAttributes: getBlockAttributes2 } = select7(import_block_editor107.store);
      const currentBlockAttributes = getBlockAttributes2(clientId);
      const overridesValues = {};
      for (const attributeName of Object.keys(bindings)) {
        const overridableValue = patternOverridesContent?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
        if (overridableValue === void 0) {
          overridesValues[attributeName] = currentBlockAttributes[attributeName];
          continue;
        } else {
          overridesValues[attributeName] = overridableValue === "" ? void 0 : overridableValue;
        }
      }
      return overridesValues;
    },
    setValues({ select: select7, dispatch: dispatch7, clientId, bindings }) {
      const { getBlockAttributes: getBlockAttributes2, getBlockParentsByBlockName, getBlocks: getBlocks2 } = select7(import_block_editor107.store);
      const currentBlockAttributes = getBlockAttributes2(clientId);
      const blockName = currentBlockAttributes?.metadata?.name;
      if (!blockName) {
        return;
      }
      const [patternClientId] = getBlockParentsByBlockName(
        clientId,
        "core/block",
        true
      );
      const attributes = Object.entries(bindings).reduce(
        (attrs, [key, { newValue }]) => {
          attrs[key] = newValue;
          return attrs;
        },
        {}
      );
      if (!patternClientId) {
        const syncBlocksWithSameName = (blocks) => {
          for (const block of blocks) {
            if (block.attributes?.metadata?.name === blockName) {
              dispatch7(import_block_editor107.store).updateBlockAttributes(
                block.clientId,
                attributes
              );
            }
            syncBlocksWithSameName(block.innerBlocks);
          }
        };
        syncBlocksWithSameName(getBlocks2());
        return;
      }
      const currentBindingValue = getBlockAttributes2(patternClientId)?.[CONTENT];
      dispatch7(import_block_editor107.store).updateBlockAttributes(patternClientId, {
        [CONTENT]: {
          ...currentBindingValue,
          [blockName]: {
            ...currentBindingValue?.[blockName],
            ...Object.entries(attributes).reduce(
              (acc, [key, value]) => {
                acc[key] = value === void 0 ? "" : value;
                return acc;
              },
              {}
            )
          }
        }
      });
    },
    canUserEditValue: () => true
  };

  // packages/editor/build-module/bindings/post-data.mjs
  var import_i18n328 = __toESM(require_i18n(), 1);
  var import_core_data142 = __toESM(require_core_data(), 1);
  var import_block_editor108 = __toESM(require_block_editor(), 1);
  var NAVIGATION_BLOCK_TYPES = [
    "core/navigation-link",
    "core/navigation-submenu"
  ];
  var postDataFields = [
    {
      label: (0, import_i18n328.__)("Post Date"),
      args: { field: "date" },
      type: "string"
    },
    {
      label: (0, import_i18n328.__)("Post Modified Date"),
      args: { field: "modified" },
      type: "string"
    },
    {
      label: (0, import_i18n328.__)("Post Link"),
      args: { field: "link" },
      type: "string"
    }
  ];
  var post_data_default = {
    name: "core/post-data",
    getValues({ select: select7, context, bindings, clientId }) {
      const { getBlockAttributes: getBlockAttributes2, getBlockName: getBlockName2 } = select7(import_block_editor108.store);
      const blockName = getBlockName2(clientId);
      const isNavigationBlock = NAVIGATION_BLOCK_TYPES.includes(blockName);
      let postId2, postType2;
      if (isNavigationBlock) {
        const blockAttributes = getBlockAttributes2(clientId);
        postId2 = blockAttributes?.id;
        postType2 = blockAttributes?.type;
      } else {
        postId2 = context?.postId;
        postType2 = context?.postType;
      }
      const { getEditedEntityRecord } = select7(import_core_data142.store);
      const entityDataValues = getEditedEntityRecord(
        "postType",
        postType2,
        postId2
      );
      const newValues = {};
      for (const [attributeName, binding] of Object.entries(bindings)) {
        const postDataField = postDataFields.find(
          (field) => field.args.field === binding.args.field
        );
        if (!postDataField) {
          newValues[attributeName] = binding.args.field;
        } else if (!entityDataValues) {
          newValues[attributeName] = postDataField.label;
        } else {
          newValues[attributeName] = entityDataValues[binding.args.field];
        }
      }
      return newValues;
    },
    setValues({ dispatch: dispatch7, context, bindings, clientId, select: select7 }) {
      const { getBlockName: getBlockName2 } = select7(import_block_editor108.store);
      const blockName = getBlockName2(clientId);
      if (NAVIGATION_BLOCK_TYPES.includes(blockName)) {
        return false;
      }
      const newData = {};
      Object.values(bindings).forEach(({ args, newValue }) => {
        newData[args.field] = newValue;
      });
      dispatch7(import_core_data142.store).editEntityRecord(
        "postType",
        context?.postType,
        context?.postId,
        newData
      );
    },
    canUserEditValue({ select: select7, context }) {
      const { getBlockName: getBlockName2, getSelectedBlockClientId: getSelectedBlockClientId2 } = select7(import_block_editor108.store);
      const clientId = getSelectedBlockClientId2();
      const blockName = getBlockName2(clientId);
      if (NAVIGATION_BLOCK_TYPES.includes(blockName)) {
        return false;
      }
      if (context?.query || context?.queryId) {
        return false;
      }
      if (!context?.postType) {
        return false;
      }
      const canUserEdit = select7(import_core_data142.store).canUser("update", {
        kind: "postType",
        name: context?.postType,
        id: context?.postId
      });
      if (!canUserEdit) {
        return false;
      }
      return true;
    },
    getFieldsList({ context, select: select7 }) {
      const selectedBlock = select7(import_block_editor108.store).getSelectedBlock();
      if (selectedBlock?.name !== "core/post-date") {
        return [];
      }
      if (!context || !context.postId || !context.postType) {
        return [];
      }
      return postDataFields;
    }
  };

  // packages/editor/build-module/bindings/post-meta.mjs
  var import_core_data143 = __toESM(require_core_data(), 1);
  function getPostMetaFields(select7, context) {
    const { getRegisteredPostMeta } = unlock(select7(import_core_data143.store));
    const registeredFields = getRegisteredPostMeta(context?.postType);
    const metaFields = [];
    Object.entries(registeredFields).forEach(([key, props]) => {
      if (key === "footnotes" || key.charAt(0) === "_") {
        return;
      }
      metaFields.push({
        label: props.title || key,
        args: { key },
        default: props.default,
        type: props.type
      });
    });
    return metaFields;
  }
  function getValue({ select: select7, context, args }) {
    const metaFields = getPostMetaFields(select7, context);
    const metaField = metaFields.find(
      (field) => field.args.key === args.key
    );
    if (!metaField) {
      return args.key;
    }
    if (!context?.postId) {
      return metaField.default || metaField.label || args.key;
    }
    const { getEditedEntityRecord } = select7(import_core_data143.store);
    const entityMetaValues = getEditedEntityRecord(
      "postType",
      context?.postType,
      context?.postId
    ).meta;
    return entityMetaValues?.[args.key] ?? metaField?.label ?? args.key;
  }
  var post_meta_default = {
    name: "core/post-meta",
    getValues({ select: select7, context, bindings }) {
      const newValues = {};
      for (const [attributeName, binding] of Object.entries(bindings)) {
        newValues[attributeName] = getValue({
          select: select7,
          context,
          args: binding.args
        });
      }
      return newValues;
    },
    setValues({ dispatch: dispatch7, context, bindings }) {
      const newMeta = {};
      Object.values(bindings).forEach(({ args, newValue }) => {
        newMeta[args.key] = newValue;
      });
      dispatch7(import_core_data143.store).editEntityRecord(
        "postType",
        context?.postType,
        context?.postId,
        {
          meta: newMeta
        }
      );
    },
    canUserEditValue({ select: select7, context, args }) {
      if (context?.query || context?.queryId) {
        return false;
      }
      if (!context?.postType) {
        return false;
      }
      const metaFields = getPostMetaFields(select7, context);
      const hasMatchingMetaField = metaFields.some(
        (field) => field.args.key === args.key
      );
      if (!hasMatchingMetaField) {
        return false;
      }
      const areCustomFieldsEnabled = select7(store3).getEditorSettings().enableCustomFields;
      if (areCustomFieldsEnabled) {
        return false;
      }
      const canUserEdit = select7(import_core_data143.store).canUser("update", {
        kind: "postType",
        name: context?.postType,
        id: context?.postId
      });
      if (!canUserEdit) {
        return false;
      }
      return true;
    },
    getFieldsList({ select: select7, context }) {
      const metaFields = getPostMetaFields(select7, context);
      return metaFields.map(
        ({ default: defaultProp, ...otherProps }) => ({
          ...otherProps
        })
      );
    }
  };

  // packages/editor/build-module/bindings/term-data.mjs
  var import_i18n329 = __toESM(require_i18n(), 1);
  var import_core_data144 = __toESM(require_core_data(), 1);
  var import_block_editor109 = __toESM(require_block_editor(), 1);
  var NAVIGATION_BLOCK_TYPES2 = [
    "core/navigation-link",
    "core/navigation-submenu"
  ];
  var termDataFields = [
    {
      label: (0, import_i18n329.__)("Term ID"),
      args: { field: "id" },
      type: "string"
    },
    {
      label: (0, import_i18n329.__)("Name"),
      args: { field: "name" },
      type: "string"
    },
    {
      label: (0, import_i18n329.__)("Slug"),
      args: { field: "slug" },
      type: "string"
    },
    {
      label: (0, import_i18n329.__)("Link"),
      args: { field: "link" },
      type: "string"
    },
    {
      label: (0, import_i18n329.__)("Description"),
      args: { field: "description" },
      type: "string"
    },
    {
      label: (0, import_i18n329.__)("Parent ID"),
      args: { field: "parent" },
      type: "string"
    },
    {
      label: (0, import_i18n329.__)("Count"),
      args: { field: "count" },
      type: "string"
    }
  ];
  var term_data_default = {
    name: "core/term-data",
    usesContext: ["taxonomy", "termId", "termData"],
    getValues({ select: select7, context, bindings, clientId }) {
      const { getEntityRecord } = select7(import_core_data144.store);
      const { getBlockAttributes: getBlockAttributes2, getBlockName: getBlockName2 } = select7(import_block_editor109.store);
      const blockName = getBlockName2(clientId);
      const isNavigationBlock = NAVIGATION_BLOCK_TYPES2.includes(blockName);
      let termDataValues;
      if (isNavigationBlock) {
        const blockAttributes = getBlockAttributes2(clientId);
        const typeFromAttributes = blockAttributes?.type;
        const taxonomy = typeFromAttributes === "tag" ? "post_tag" : typeFromAttributes;
        termDataValues = getEntityRecord(
          "taxonomy",
          taxonomy,
          blockAttributes?.id
        );
      } else if (context.termId && context.taxonomy) {
        termDataValues = getEntityRecord(
          "taxonomy",
          context.taxonomy,
          context.termId
        );
      }
      if (!termDataValues && context?.termData && !isNavigationBlock) {
        termDataValues = context.termData;
      }
      const newValues = {};
      for (const [attributeName, binding] of Object.entries(bindings)) {
        const termDataField = termDataFields.find(
          (field) => field.args.field === binding.args.field
        );
        if (!termDataField) {
          newValues[attributeName] = binding.args.field;
        } else if (!termDataValues || termDataValues[binding.args.field] === void 0) {
          newValues[attributeName] = termDataField.label;
        } else if (binding.args.field === "count") {
          newValues[attributeName] = "(" + termDataValues[binding.args.field] + ")";
        } else {
          newValues[attributeName] = termDataValues[binding.args.field];
        }
      }
      return newValues;
    },
    // eslint-disable-next-line no-unused-vars
    setValues({ dispatch: dispatch7, context, bindings }) {
      return false;
    },
    canUserEditValue({ select: select7, context }) {
      const { getBlockName: getBlockName2, getSelectedBlockClientId: getSelectedBlockClientId2 } = select7(import_block_editor109.store);
      const clientId = getSelectedBlockClientId2();
      const blockName = getBlockName2(clientId);
      if (NAVIGATION_BLOCK_TYPES2.includes(blockName)) {
        return false;
      }
      if (context?.termQuery) {
        return false;
      }
      if (!context?.taxonomy || !context?.termId) {
        return false;
      }
      return false;
    },
    getFieldsList({ context, select: select7 }) {
      const { getBlockAttributes: getBlockAttributes2, getBlockName: getBlockName2, getSelectedBlockClientId: getSelectedBlockClientId2 } = select7(import_block_editor109.store);
      const clientId = getSelectedBlockClientId2();
      const blockName = getBlockName2(clientId);
      if (NAVIGATION_BLOCK_TYPES2.includes(blockName)) {
        const blockAttributes = getBlockAttributes2(clientId);
        if (!blockAttributes || !blockAttributes.id || !blockAttributes.type) {
          return [];
        }
        return termDataFields;
      }
      if (!context) {
        return [];
      }
      if (context.taxonomy && context.termId || context.termData) {
        return termDataFields;
      }
      return [];
    }
  };

  // packages/editor/build-module/bindings/api.mjs
  function registerCoreBlockBindingsSources() {
    (0, import_blocks38.registerBlockBindingsSource)(pattern_overrides_default);
    (0, import_blocks38.registerBlockBindingsSource)(post_data_default);
    (0, import_blocks38.registerBlockBindingsSource)(post_meta_default);
    (0, import_blocks38.registerBlockBindingsSource)(term_data_default);
  }

  // packages/editor/build-module/private-apis.mjs
  var { store: interfaceStore, ...remainingInterfaceApis } = build_module_exports;
  var privateApis19 = {};
  lock(privateApis19, {
    CreateTemplatePartModal,
    patternTitleField: pattern_title_default,
    templateTitleField: template_title_default,
    BackButton: back_button_default,
    EntitiesSavedStatesExtensible,
    Editor: editor_default,
    PluginPostExcerpt: plugin_default,
    PostCardPanel,
    PreferencesModal: EditorPreferencesModal,
    usePostActions,
    usePostFields: post_fields_default,
    ToolsMoreMenuGroup: tools_more_menu_group_default,
    ViewMoreMenuGroup: view_more_menu_group_default,
    ResizableEditor: resizable_editor_default,
    registerCoreBlockBindingsSources,
    getTemplateInfo,
    // Global Styles
    GlobalStylesUIWrapper,
    GlobalStylesActionMenu,
    StyleBookPreview,
    useGlobalStyles,
    useStyle: useStyle2,
    // This is a temporary private API while we're updating the site editor to use EditorProvider.
    interfaceStore,
    ...remainingInterfaceApis
  });

  // packages/editor/build-module/dataviews/api.mjs
  var import_data267 = __toESM(require_data(), 1);
  function registerEntityAction2(kind, name2, config2) {
    const { registerEntityAction: _registerEntityAction } = unlock(
      (0, import_data267.dispatch)(store3)
    );
    if (true) {
      _registerEntityAction(kind, name2, config2);
    }
  }
  function unregisterEntityAction2(kind, name2, actionId) {
    const { unregisterEntityAction: _unregisterEntityAction } = unlock(
      (0, import_data267.dispatch)(store3)
    );
    if (true) {
      _unregisterEntityAction(kind, name2, actionId);
    }
  }
  function registerEntityField2(kind, name2, config2) {
    const { registerEntityField: _registerEntityField } = unlock(
      (0, import_data267.dispatch)(store3)
    );
    if (true) {
      _registerEntityField(kind, name2, config2);
    }
  }
  function unregisterEntityField2(kind, name2, fieldId) {
    const { unregisterEntityField: _unregisterEntityField } = unlock(
      (0, import_data267.dispatch)(store3)
    );
    if (true) {
      _unregisterEntityField(kind, name2, fieldId);
    }
  }

  // packages/editor/build-module/index.mjs
  var import_block_editor110 = __toESM(require_block_editor(), 1);
  return __toCommonJS(index_exports);
})();
/*! Bundled license information:

use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
  (**
   * @license React
   * use-sync-external-store-shim.development.js
   *
   * Copyright (c) Meta Platforms, Inc. and affiliates.
   *
   * This source code is licensed under the MIT license found in the
   * LICENSE file in the root directory of this source tree.
   *)

react-is/cjs/react-is.development.js:
  (** @license React v16.13.1
   * react-is.development.js
   *
   * Copyright (c) Facebook, Inc. and its affiliates.
   *
   * This source code is licensed under the MIT license found in the
   * LICENSE file in the root directory of this source tree.
   *)

object-assign/index.js:
  (*
  object-assign
  (c) Sindre Sorhus
  @license MIT
  *)

autosize/dist/autosize.js:
  (*!
  	autosize 4.0.2
  	license: MIT
  	http://www.jacklmoore.com/autosize
  *)

is-plain-object/dist/is-plain-object.mjs:
  (*!
   * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
   *
   * Copyright (c) 2014-2017, Jon Schlinkert.
   * Released under the MIT License.
   *)
*/
//# sourceMappingURL=index.js.map
