| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 var __create = Object.create; 2 var __defProp = Object.defineProperty; 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 4 var __getOwnPropNames = Object.getOwnPropertyNames; 5 var __getProtoOf = Object.getPrototypeOf; 6 var __hasOwnProp = Object.prototype.hasOwnProperty; 7 var __commonJS = (cb, mod) => function __require() { 8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 9 }; 10 var __export = (target, all) => { 11 for (var name in all) 12 __defProp(target, name, { get: all[name], enumerable: true }); 13 }; 14 var __copyProps = (to, from, except, desc) => { 15 if (from && typeof from === "object" || typeof from === "function") { 16 for (let key of __getOwnPropNames(from)) 17 if (!__hasOwnProp.call(to, key) && key !== except) 18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 19 } 20 return to; 21 }; 22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 23 // If the importer is in node compatibility mode or this is not an ESM 24 // file that has been converted to a CommonJS file using a Babel- 25 // compatible transform (i.e. "__esModule" has not been set), then set 26 // "default" to the CommonJS "module.exports" for node compatibility. 27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 28 mod 29 )); 30 31 // package-external:@wordpress/i18n 32 var require_i18n = __commonJS({ 33 "package-external:@wordpress/i18n"(exports, module) { 34 module.exports = window.wp.i18n; 35 } 36 }); 37 38 // package-external:@wordpress/element 39 var require_element = __commonJS({ 40 "package-external:@wordpress/element"(exports, module) { 41 module.exports = window.wp.element; 42 } 43 }); 44 45 // vendor-external:react 46 var require_react = __commonJS({ 47 "vendor-external:react"(exports, module) { 48 module.exports = window.React; 49 } 50 }); 51 52 // vendor-external:react/jsx-runtime 53 var require_jsx_runtime = __commonJS({ 54 "vendor-external:react/jsx-runtime"(exports, module) { 55 module.exports = window.ReactJSXRuntime; 56 } 57 }); 58 59 // vendor-external:react-dom 60 var require_react_dom = __commonJS({ 61 "vendor-external:react-dom"(exports, module) { 62 module.exports = window.ReactDOM; 63 } 64 }); 65 66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js 67 var require_use_sync_external_store_shim_development = __commonJS({ 68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) { 69 "use strict"; 70 (function() { 71 function is(x2, y2) { 72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 73 } 74 function useSyncExternalStore$2(subscribe, getSnapshot) { 75 didWarnOld18Alpha || void 0 === React59.startTransition || (didWarnOld18Alpha = true, console.error( 76 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release." 77 )); 78 var value = getSnapshot(); 79 if (!didWarnUncachedGetSnapshot) { 80 var cachedValue = getSnapshot(); 81 objectIs(value, cachedValue) || (console.error( 82 "The result of getSnapshot should be cached to avoid an infinite loop" 83 ), didWarnUncachedGetSnapshot = true); 84 } 85 cachedValue = useState33({ 86 inst: { value, getSnapshot } 87 }); 88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1]; 89 useLayoutEffect7( 90 function() { 91 inst.value = value; 92 inst.getSnapshot = getSnapshot; 93 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 94 }, 95 [subscribe, value, getSnapshot] 96 ); 97 useEffect32( 98 function() { 99 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 100 return subscribe(function() { 101 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 102 }); 103 }, 104 [subscribe] 105 ); 106 useDebugValue2(value); 107 return value; 108 } 109 function checkIfSnapshotChanged(inst) { 110 var latestGetSnapshot = inst.getSnapshot; 111 inst = inst.value; 112 try { 113 var nextValue = latestGetSnapshot(); 114 return !objectIs(inst, nextValue); 115 } catch (error2) { 116 return true; 117 } 118 } 119 function useSyncExternalStore$1(subscribe, getSnapshot) { 120 return getSnapshot(); 121 } 122 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 123 var React59 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState33 = React59.useState, useEffect32 = React59.useEffect, useLayoutEffect7 = React59.useLayoutEffect, useDebugValue2 = React59.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2; 124 exports.useSyncExternalStore = void 0 !== React59.useSyncExternalStore ? React59.useSyncExternalStore : shim; 125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 126 })(); 127 } 128 }); 129 130 // node_modules/use-sync-external-store/shim/index.js 131 var require_shim = __commonJS({ 132 "node_modules/use-sync-external-store/shim/index.js"(exports, module) { 133 "use strict"; 134 if (false) { 135 module.exports = null; 136 } else { 137 module.exports = require_use_sync_external_store_shim_development(); 138 } 139 } 140 }); 141 142 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js 143 var require_with_selector_development = __commonJS({ 144 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) { 145 "use strict"; 146 (function() { 147 function is(x2, y2) { 148 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 149 } 150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 151 var React59 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef41 = React59.useRef, useEffect32 = React59.useEffect, useMemo43 = React59.useMemo, useDebugValue2 = React59.useDebugValue; 152 exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) { 153 var instRef = useRef41(null); 154 if (null === instRef.current) { 155 var inst = { hasValue: false, value: null }; 156 instRef.current = inst; 157 } else inst = instRef.current; 158 instRef = useMemo43( 159 function() { 160 function memoizedSelector(nextSnapshot) { 161 if (!hasMemo) { 162 hasMemo = true; 163 memoizedSnapshot = nextSnapshot; 164 nextSnapshot = selector(nextSnapshot); 165 if (void 0 !== isEqual && inst.hasValue) { 166 var currentSelection = inst.value; 167 if (isEqual(currentSelection, nextSnapshot)) 168 return memoizedSelection = currentSelection; 169 } 170 return memoizedSelection = nextSnapshot; 171 } 172 currentSelection = memoizedSelection; 173 if (objectIs(memoizedSnapshot, nextSnapshot)) 174 return currentSelection; 175 var nextSelection = selector(nextSnapshot); 176 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) 177 return memoizedSnapshot = nextSnapshot, currentSelection; 178 memoizedSnapshot = nextSnapshot; 179 return memoizedSelection = nextSelection; 180 } 181 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot; 182 return [ 183 function() { 184 return memoizedSelector(getSnapshot()); 185 }, 186 null === maybeGetServerSnapshot ? void 0 : function() { 187 return memoizedSelector(maybeGetServerSnapshot()); 188 } 189 ]; 190 }, 191 [getSnapshot, getServerSnapshot, selector, isEqual] 192 ); 193 var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]); 194 useEffect32( 195 function() { 196 inst.hasValue = true; 197 inst.value = value; 198 }, 199 [value] 200 ); 201 useDebugValue2(value); 202 return value; 203 }; 204 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 205 })(); 206 } 207 }); 208 209 // node_modules/use-sync-external-store/shim/with-selector.js 210 var require_with_selector = __commonJS({ 211 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) { 212 "use strict"; 213 if (false) { 214 module.exports = null; 215 } else { 216 module.exports = require_with_selector_development(); 217 } 218 } 219 }); 220 221 // package-external:@wordpress/primitives 222 var require_primitives = __commonJS({ 223 "package-external:@wordpress/primitives"(exports, module) { 224 module.exports = window.wp.primitives; 225 } 226 }); 227 228 // package-external:@wordpress/compose 229 var require_compose = __commonJS({ 230 "package-external:@wordpress/compose"(exports, module) { 231 module.exports = window.wp.compose; 232 } 233 }); 234 235 // package-external:@wordpress/theme 236 var require_theme = __commonJS({ 237 "package-external:@wordpress/theme"(exports, module) { 238 module.exports = window.wp.theme; 239 } 240 }); 241 242 // package-external:@wordpress/private-apis 243 var require_private_apis = __commonJS({ 244 "package-external:@wordpress/private-apis"(exports, module) { 245 module.exports = window.wp.privateApis; 246 } 247 }); 248 249 // package-external:@wordpress/components 250 var require_components = __commonJS({ 251 "package-external:@wordpress/components"(exports, module) { 252 module.exports = window.wp.components; 253 } 254 }); 255 256 // package-external:@wordpress/core-data 257 var require_core_data = __commonJS({ 258 "package-external:@wordpress/core-data"(exports, module) { 259 module.exports = window.wp.coreData; 260 } 261 }); 262 263 // package-external:@wordpress/data 264 var require_data = __commonJS({ 265 "package-external:@wordpress/data"(exports, module) { 266 module.exports = window.wp.data; 267 } 268 }); 269 270 // package-external:@wordpress/editor 271 var require_editor = __commonJS({ 272 "package-external:@wordpress/editor"(exports, module) { 273 module.exports = window.wp.editor; 274 } 275 }); 276 277 // package-external:@wordpress/html-entities 278 var require_html_entities = __commonJS({ 279 "package-external:@wordpress/html-entities"(exports, module) { 280 module.exports = window.wp.htmlEntities; 281 } 282 }); 283 284 // package-external:@wordpress/keycodes 285 var require_keycodes = __commonJS({ 286 "package-external:@wordpress/keycodes"(exports, module) { 287 module.exports = window.wp.keycodes; 288 } 289 }); 290 291 // node_modules/fast-deep-equal/es6/index.js 292 var require_es6 = __commonJS({ 293 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 294 "use strict"; 295 module.exports = function equal(a2, b2) { 296 if (a2 === b2) return true; 297 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { 298 if (a2.constructor !== b2.constructor) return false; 299 var length2, i2, keys; 300 if (Array.isArray(a2)) { 301 length2 = a2.length; 302 if (length2 != b2.length) return false; 303 for (i2 = length2; i2-- !== 0; ) 304 if (!equal(a2[i2], b2[i2])) return false; 305 return true; 306 } 307 if (a2 instanceof Map && b2 instanceof Map) { 308 if (a2.size !== b2.size) return false; 309 for (i2 of a2.entries()) 310 if (!b2.has(i2[0])) return false; 311 for (i2 of a2.entries()) 312 if (!equal(i2[1], b2.get(i2[0]))) return false; 313 return true; 314 } 315 if (a2 instanceof Set && b2 instanceof Set) { 316 if (a2.size !== b2.size) return false; 317 for (i2 of a2.entries()) 318 if (!b2.has(i2[0])) return false; 319 return true; 320 } 321 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) { 322 length2 = a2.length; 323 if (length2 != b2.length) return false; 324 for (i2 = length2; i2-- !== 0; ) 325 if (a2[i2] !== b2[i2]) return false; 326 return true; 327 } 328 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags; 329 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf(); 330 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); 331 keys = Object.keys(a2); 332 length2 = keys.length; 333 if (length2 !== Object.keys(b2).length) return false; 334 for (i2 = length2; i2-- !== 0; ) 335 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false; 336 for (i2 = length2; i2-- !== 0; ) { 337 var key = keys[i2]; 338 if (!equal(a2[key], b2[key])) return false; 339 } 340 return true; 341 } 342 return a2 !== a2 && b2 !== b2; 343 }; 344 } 345 }); 346 347 // package-external:@wordpress/date 348 var require_date = __commonJS({ 349 "package-external:@wordpress/date"(exports, module) { 350 module.exports = window.wp.date; 351 } 352 }); 353 354 // node_modules/deepmerge/dist/cjs.js 355 var require_cjs = __commonJS({ 356 "node_modules/deepmerge/dist/cjs.js"(exports, module) { 357 "use strict"; 358 var isMergeableObject = function isMergeableObject2(value) { 359 return isNonNullObject(value) && !isSpecial(value); 360 }; 361 function isNonNullObject(value) { 362 return !!value && typeof value === "object"; 363 } 364 function isSpecial(value) { 365 var stringValue = Object.prototype.toString.call(value); 366 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value); 367 } 368 var canUseSymbol = typeof Symbol === "function" && Symbol.for; 369 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103; 370 function isReactElement(value) { 371 return value.$$typeof === REACT_ELEMENT_TYPE; 372 } 373 function emptyTarget(val) { 374 return Array.isArray(val) ? [] : {}; 375 } 376 function cloneUnlessOtherwiseSpecified(value, options) { 377 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value; 378 } 379 function defaultArrayMerge(target, source, options) { 380 return target.concat(source).map(function(element) { 381 return cloneUnlessOtherwiseSpecified(element, options); 382 }); 383 } 384 function getMergeFunction(key, options) { 385 if (!options.customMerge) { 386 return deepmerge; 387 } 388 var customMerge = options.customMerge(key); 389 return typeof customMerge === "function" ? customMerge : deepmerge; 390 } 391 function getEnumerableOwnPropertySymbols(target) { 392 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) { 393 return Object.propertyIsEnumerable.call(target, symbol); 394 }) : []; 395 } 396 function getKeys(target) { 397 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)); 398 } 399 function propertyIsOnObject(object, property) { 400 try { 401 return property in object; 402 } catch (_) { 403 return false; 404 } 405 } 406 function propertyIsUnsafe(target, key) { 407 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key)); 408 } 409 function mergeObject(target, source, options) { 410 var destination = {}; 411 if (options.isMergeableObject(target)) { 412 getKeys(target).forEach(function(key) { 413 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); 414 }); 415 } 416 getKeys(source).forEach(function(key) { 417 if (propertyIsUnsafe(target, key)) { 418 return; 419 } 420 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { 421 destination[key] = getMergeFunction(key, options)(target[key], source[key], options); 422 } else { 423 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); 424 } 425 }); 426 return destination; 427 } 428 function deepmerge(target, source, options) { 429 options = options || {}; 430 options.arrayMerge = options.arrayMerge || defaultArrayMerge; 431 options.isMergeableObject = options.isMergeableObject || isMergeableObject; 432 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; 433 var sourceIsArray = Array.isArray(source); 434 var targetIsArray = Array.isArray(target); 435 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; 436 if (!sourceAndTargetTypesMatch) { 437 return cloneUnlessOtherwiseSpecified(source, options); 438 } else if (sourceIsArray) { 439 return options.arrayMerge(target, source, options); 440 } else { 441 return mergeObject(target, source, options); 442 } 443 } 444 deepmerge.all = function deepmergeAll(array, options) { 445 if (!Array.isArray(array)) { 446 throw new Error("first argument should be an array"); 447 } 448 return array.reduce(function(prev, next) { 449 return deepmerge(prev, next, options); 450 }, {}); 451 }; 452 var deepmerge_1 = deepmerge; 453 module.exports = deepmerge_1; 454 } 455 }); 456 457 // package-external:@wordpress/deprecated 458 var require_deprecated = __commonJS({ 459 "package-external:@wordpress/deprecated"(exports, module) { 460 module.exports = window.wp.deprecated; 461 } 462 }); 463 464 // package-external:@wordpress/keyboard-shortcuts 465 var require_keyboard_shortcuts = __commonJS({ 466 "package-external:@wordpress/keyboard-shortcuts"(exports, module) { 467 module.exports = window.wp.keyboardShortcuts; 468 } 469 }); 470 471 // package-external:@wordpress/notices 472 var require_notices = __commonJS({ 473 "package-external:@wordpress/notices"(exports, module) { 474 module.exports = window.wp.notices; 475 } 476 }); 477 478 // package-external:@wordpress/viewport 479 var require_viewport = __commonJS({ 480 "package-external:@wordpress/viewport"(exports, module) { 481 module.exports = window.wp.viewport; 482 } 483 }); 484 485 // package-external:@wordpress/preferences 486 var require_preferences = __commonJS({ 487 "package-external:@wordpress/preferences"(exports, module) { 488 module.exports = window.wp.preferences; 489 } 490 }); 491 492 // package-external:@wordpress/plugins 493 var require_plugins = __commonJS({ 494 "package-external:@wordpress/plugins"(exports, module) { 495 module.exports = window.wp.plugins; 496 } 497 }); 498 499 // package-external:@wordpress/api-fetch 500 var require_api_fetch = __commonJS({ 501 "package-external:@wordpress/api-fetch"(exports, module) { 502 module.exports = window.wp.apiFetch; 503 } 504 }); 505 506 // packages/admin-ui/build-module/breadcrumbs/index.mjs 507 var import_i18n2 = __toESM(require_i18n(), 1); 508 import { Link as RouterLink } from "@wordpress/route"; 509 510 // node_modules/clsx/dist/clsx.mjs 511 function r(e2) { 512 var t2, f2, n2 = ""; 513 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2; 514 else if ("object" == typeof e2) if (Array.isArray(e2)) { 515 var o2 = e2.length; 516 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2); 517 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2); 518 return n2; 519 } 520 function clsx() { 521 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2); 522 return n2; 523 } 524 var clsx_default = clsx; 525 526 // packages/ui/build-module/badge/badge.mjs 527 var import_element9 = __toESM(require_element(), 1); 528 529 // node_modules/@base-ui/utils/esm/useControlled.js 530 var React2 = __toESM(require_react(), 1); 531 532 // node_modules/@base-ui/utils/esm/error.js 533 var set; 534 if (true) { 535 set = /* @__PURE__ */ new Set(); 536 } 537 function error(...messages) { 538 if (true) { 539 const messageKey = messages.join(" "); 540 if (!set.has(messageKey)) { 541 set.add(messageKey); 542 console.error(`Base UI: $messageKey}`); 543 } 544 } 545 } 546 547 // node_modules/@base-ui/utils/esm/useControlled.js 548 function useControlled({ 549 controlled, 550 default: defaultProp, 551 name, 552 state = "value" 553 }) { 554 const { 555 current: isControlled 556 } = React2.useRef(controlled !== void 0); 557 const [valueState, setValue] = React2.useState(defaultProp); 558 const value = isControlled ? controlled : valueState; 559 if (true) { 560 React2.useEffect(() => { 561 if (isControlled !== (controlled !== void 0)) { 562 error([`A component is changing the $isControlled ? "" : "un"}controlled $state} state of $name} to be $isControlled ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled $name} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join("\n")); 563 } 564 }, [state, name, controlled]); 565 const { 566 current: defaultValue 567 } = React2.useRef(defaultProp); 568 React2.useEffect(() => { 569 if (!isControlled && serializeToDevModeString(defaultValue) !== serializeToDevModeString(defaultProp)) { 570 error([`A component is changing the default $state} state of an uncontrolled $name} after being initialized. To suppress this warning opt to use a controlled $name}.`].join("\n")); 571 } 572 }, [defaultProp]); 573 } 574 const setValueIfUncontrolled = React2.useCallback((newValue) => { 575 if (!isControlled) { 576 setValue(newValue); 577 } 578 }, []); 579 return [value, setValueIfUncontrolled]; 580 } 581 function serializeToDevModeString(input) { 582 let nextId = 0; 583 const seen = /* @__PURE__ */ new WeakMap(); 584 try { 585 const result = JSON.stringify(input, function replacer(key, value) { 586 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) { 587 return void 0; 588 } 589 if (typeof value === "bigint") { 590 return `__bigint__:$value}`; 591 } 592 if (value !== null && typeof value === "object") { 593 const id = seen.get(value); 594 if (id !== void 0) { 595 return `__object__:$id}`; 596 } 597 seen.set(value, nextId); 598 nextId += 1; 599 } 600 return value; 601 }); 602 return result ?? `__top__:$typeof input}`; 603 } catch { 604 return "__unserializable__"; 605 } 606 } 607 608 // node_modules/@base-ui/utils/esm/useStableCallback.js 609 var React4 = __toESM(require_react(), 1); 610 611 // node_modules/@base-ui/utils/esm/useRefWithInit.js 612 var React3 = __toESM(require_react(), 1); 613 var UNINITIALIZED = {}; 614 function useRefWithInit(init, initArg) { 615 const ref = React3.useRef(UNINITIALIZED); 616 if (ref.current === UNINITIALIZED) { 617 ref.current = init(initArg); 618 } 619 return ref; 620 } 621 622 // node_modules/@base-ui/utils/esm/useStableCallback.js 623 var useInsertionEffect = React4[`useInsertionEffect$Math.random().toFixed(1)}`.slice(0, -3)]; 624 var useSafeInsertionEffect = ( 625 // React 17 doesn't have useInsertionEffect. 626 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late. 627 useInsertionEffect !== React4.useLayoutEffect ? useInsertionEffect : (fn) => fn() 628 ); 629 function useStableCallback(callback) { 630 const stable = useRefWithInit(createStableCallback).current; 631 stable.next = callback; 632 useSafeInsertionEffect(stable.effect); 633 return stable.trampoline; 634 } 635 function createStableCallback() { 636 const stable = { 637 next: void 0, 638 callback: assertNotCalled, 639 trampoline: (...args) => stable.callback?.(...args), 640 effect: () => { 641 stable.callback = stable.next; 642 } 643 }; 644 return stable; 645 } 646 function assertNotCalled() { 647 if (true) { 648 throw ( 649 /* minify-error-disabled */ 650 new Error("Base UI: Cannot call an event handler while rendering.") 651 ); 652 } 653 } 654 655 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js 656 var React5 = __toESM(require_react(), 1); 657 var noop = () => { 658 }; 659 var useIsoLayoutEffect = typeof document !== "undefined" ? React5.useLayoutEffect : noop; 660 661 // node_modules/@base-ui/utils/esm/warn.js 662 var set2; 663 if (true) { 664 set2 = /* @__PURE__ */ new Set(); 665 } 666 function warn(...messages) { 667 if (true) { 668 const messageKey = messages.join(" "); 669 if (!set2.has(messageKey)) { 670 set2.add(messageKey); 671 console.warn(`Base UI: $messageKey}`); 672 } 673 } 674 } 675 676 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js 677 var React6 = __toESM(require_react(), 1); 678 var DirectionContext = /* @__PURE__ */ React6.createContext(void 0); 679 if (true) DirectionContext.displayName = "DirectionContext"; 680 function useDirection() { 681 const context = React6.useContext(DirectionContext); 682 return context?.direction ?? "ltr"; 683 } 684 685 // node_modules/@base-ui/react/esm/internals/useRenderElement.js 686 var React9 = __toESM(require_react(), 1); 687 688 // node_modules/@base-ui/utils/esm/useMergedRefs.js 689 function useMergedRefs(a2, b2, c2, d2) { 690 const forkRef = useRefWithInit(createForkRef).current; 691 if (didChange(forkRef, a2, b2, c2, d2)) { 692 update(forkRef, [a2, b2, c2, d2]); 693 } 694 return forkRef.callback; 695 } 696 function useMergedRefsN(refs) { 697 const forkRef = useRefWithInit(createForkRef).current; 698 if (didChangeN(forkRef, refs)) { 699 update(forkRef, refs); 700 } 701 return forkRef.callback; 702 } 703 function createForkRef() { 704 return { 705 callback: null, 706 cleanup: null, 707 refs: [] 708 }; 709 } 710 function didChange(forkRef, a2, b2, c2, d2) { 711 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2; 712 } 713 function didChangeN(forkRef, newRefs) { 714 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]); 715 } 716 function update(forkRef, refs) { 717 forkRef.refs = refs; 718 if (refs.every((ref) => ref == null)) { 719 forkRef.callback = null; 720 return; 721 } 722 forkRef.callback = (instance) => { 723 if (forkRef.cleanup) { 724 forkRef.cleanup(); 725 forkRef.cleanup = null; 726 } 727 if (instance != null) { 728 const cleanupCallbacks = Array(refs.length).fill(null); 729 for (let i2 = 0; i2 < refs.length; i2 += 1) { 730 const ref = refs[i2]; 731 if (ref == null) { 732 continue; 733 } 734 switch (typeof ref) { 735 case "function": { 736 const refCleanup = ref(instance); 737 if (typeof refCleanup === "function") { 738 cleanupCallbacks[i2] = refCleanup; 739 } 740 break; 741 } 742 case "object": { 743 ref.current = instance; 744 break; 745 } 746 default: 747 } 748 } 749 forkRef.cleanup = () => { 750 for (let i2 = 0; i2 < refs.length; i2 += 1) { 751 const ref = refs[i2]; 752 if (ref == null) { 753 continue; 754 } 755 switch (typeof ref) { 756 case "function": { 757 const cleanupCallback = cleanupCallbacks[i2]; 758 if (typeof cleanupCallback === "function") { 759 cleanupCallback(); 760 } else { 761 ref(null); 762 } 763 break; 764 } 765 case "object": { 766 ref.current = null; 767 break; 768 } 769 default: 770 } 771 } 772 }; 773 } 774 }; 775 } 776 777 // node_modules/@base-ui/utils/esm/getReactElementRef.js 778 var React8 = __toESM(require_react(), 1); 779 780 // node_modules/@base-ui/utils/esm/reactVersion.js 781 var React7 = __toESM(require_react(), 1); 782 var majorVersion = parseInt(React7.version, 10); 783 function isReactVersionAtLeast(reactVersionToCheck) { 784 return majorVersion >= reactVersionToCheck; 785 } 786 787 // node_modules/@base-ui/utils/esm/getReactElementRef.js 788 function getReactElementRef(element) { 789 if (!/* @__PURE__ */ React8.isValidElement(element)) { 790 return null; 791 } 792 const reactElement = element; 793 const propsWithRef = reactElement.props; 794 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null; 795 } 796 797 // node_modules/@base-ui/utils/esm/mergeObjects.js 798 function mergeObjects(a2, b2) { 799 if (a2 && !b2) { 800 return a2; 801 } 802 if (!a2 && b2) { 803 return b2; 804 } 805 if (a2 || b2) { 806 return { 807 ...a2, 808 ...b2 809 }; 810 } 811 return void 0; 812 } 813 814 // node_modules/@base-ui/utils/esm/empty.js 815 function NOOP() { 816 } 817 var EMPTY_ARRAY = Object.freeze([]); 818 var EMPTY_OBJECT = Object.freeze({}); 819 820 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js 821 function getStateAttributesProps(state, customMapping) { 822 const props = {}; 823 for (const key in state) { 824 const value = state[key]; 825 if (customMapping?.hasOwnProperty(key)) { 826 const customProps = customMapping[key](value); 827 if (customProps != null) { 828 Object.assign(props, customProps); 829 } 830 continue; 831 } 832 if (value === true) { 833 props[`data-$key.toLowerCase()}`] = ""; 834 } else if (value) { 835 props[`data-$key.toLowerCase()}`] = value.toString(); 836 } 837 } 838 return props; 839 } 840 841 // node_modules/@base-ui/react/esm/utils/resolveClassName.js 842 function resolveClassName(className, state) { 843 return typeof className === "function" ? className(state) : className; 844 } 845 846 // node_modules/@base-ui/react/esm/utils/resolveStyle.js 847 function resolveStyle(style, state) { 848 return typeof style === "function" ? style(state) : style; 849 } 850 851 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js 852 var EMPTY_PROPS = {}; 853 function mergeProps(a2, b2, c2, d2, e2) { 854 if (!c2 && !d2 && !e2 && !a2) { 855 return createInitialMergedProps(b2); 856 } 857 let merged = createInitialMergedProps(a2); 858 if (b2) { 859 merged = mergeInto(merged, b2); 860 } 861 if (c2) { 862 merged = mergeInto(merged, c2); 863 } 864 if (d2) { 865 merged = mergeInto(merged, d2); 866 } 867 if (e2) { 868 merged = mergeInto(merged, e2); 869 } 870 return merged; 871 } 872 function mergePropsN(props) { 873 if (props.length === 0) { 874 return EMPTY_PROPS; 875 } 876 if (props.length === 1) { 877 return createInitialMergedProps(props[0]); 878 } 879 let merged = createInitialMergedProps(props[0]); 880 for (let i2 = 1; i2 < props.length; i2 += 1) { 881 merged = mergeInto(merged, props[i2]); 882 } 883 return merged; 884 } 885 function createInitialMergedProps(inputProps) { 886 if (isPropsGetter(inputProps)) { 887 return { 888 ...resolvePropsGetter(inputProps, EMPTY_PROPS) 889 }; 890 } 891 return copyInitialProps(inputProps); 892 } 893 function mergeInto(merged, inputProps) { 894 if (isPropsGetter(inputProps)) { 895 return resolvePropsGetter(inputProps, merged); 896 } 897 return mutablyMergeInto(merged, inputProps); 898 } 899 function copyInitialProps(inputProps) { 900 const copiedProps = { 901 ...inputProps 902 }; 903 for (const propName in copiedProps) { 904 const propValue = copiedProps[propName]; 905 if (isEventHandler(propName, propValue)) { 906 copiedProps[propName] = wrapEventHandler(propValue); 907 } 908 } 909 return copiedProps; 910 } 911 function mutablyMergeInto(mergedProps, externalProps) { 912 if (!externalProps) { 913 return mergedProps; 914 } 915 for (const propName in externalProps) { 916 const externalPropValue = externalProps[propName]; 917 switch (propName) { 918 case "style": { 919 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue); 920 break; 921 } 922 case "className": { 923 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue); 924 break; 925 } 926 default: { 927 if (isEventHandler(propName, externalPropValue)) { 928 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue); 929 } else { 930 mergedProps[propName] = externalPropValue; 931 } 932 } 933 } 934 } 935 return mergedProps; 936 } 937 function isEventHandler(key, value) { 938 const code0 = key.charCodeAt(0); 939 const code1 = key.charCodeAt(1); 940 const code2 = key.charCodeAt(2); 941 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined"); 942 } 943 function isPropsGetter(inputProps) { 944 return typeof inputProps === "function"; 945 } 946 function resolvePropsGetter(inputProps, previousProps) { 947 if (isPropsGetter(inputProps)) { 948 return inputProps(previousProps); 949 } 950 return inputProps ?? EMPTY_PROPS; 951 } 952 function mergeEventHandlers(ourHandler, theirHandler) { 953 if (!theirHandler) { 954 return ourHandler; 955 } 956 if (!ourHandler) { 957 return wrapEventHandler(theirHandler); 958 } 959 return (...args) => { 960 const event = args[0]; 961 if (isSyntheticEvent(event)) { 962 const baseUIEvent = event; 963 makeEventPreventable(baseUIEvent); 964 const result2 = theirHandler(...args); 965 if (!baseUIEvent.baseUIHandlerPrevented) { 966 ourHandler?.(...args); 967 } 968 return result2; 969 } 970 const result = theirHandler(...args); 971 ourHandler?.(...args); 972 return result; 973 }; 974 } 975 function wrapEventHandler(handler) { 976 if (!handler) { 977 return handler; 978 } 979 return (...args) => { 980 const event = args[0]; 981 if (isSyntheticEvent(event)) { 982 makeEventPreventable(event); 983 } 984 return handler(...args); 985 }; 986 } 987 function makeEventPreventable(event) { 988 event.preventBaseUIHandler = () => { 989 event.baseUIHandlerPrevented = true; 990 }; 991 return event; 992 } 993 function mergeClassNames(ourClassName, theirClassName) { 994 if (theirClassName) { 995 if (ourClassName) { 996 return theirClassName + " " + ourClassName; 997 } 998 return theirClassName; 999 } 1000 return ourClassName; 1001 } 1002 function isSyntheticEvent(event) { 1003 return event != null && typeof event === "object" && "nativeEvent" in event; 1004 } 1005 1006 // node_modules/@base-ui/react/esm/internals/useRenderElement.js 1007 var import_react = __toESM(require_react(), 1); 1008 function useRenderElement(element, componentProps, params = {}) { 1009 const renderProp = componentProps.render; 1010 const outProps = useRenderElementProps(componentProps, params); 1011 if (params.enabled === false) { 1012 return null; 1013 } 1014 const state = params.state ?? EMPTY_OBJECT; 1015 return evaluateRenderProp(element, renderProp, outProps, state); 1016 } 1017 function useRenderElementProps(componentProps, params = {}) { 1018 const { 1019 className: classNameProp, 1020 style: styleProp, 1021 render: renderProp 1022 } = componentProps; 1023 const { 1024 state = EMPTY_OBJECT, 1025 ref, 1026 props, 1027 stateAttributesMapping: stateAttributesMapping4, 1028 enabled = true 1029 } = params; 1030 const className = enabled ? resolveClassName(classNameProp, state) : void 0; 1031 const style = enabled ? resolveStyle(styleProp, state) : void 0; 1032 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping4) : EMPTY_OBJECT; 1033 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0; 1034 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT; 1035 if (typeof document !== "undefined") { 1036 if (!enabled) { 1037 useMergedRefs(null, null); 1038 } else if (Array.isArray(ref)) { 1039 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]); 1040 } else { 1041 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref); 1042 } 1043 } 1044 if (!enabled) { 1045 return EMPTY_OBJECT; 1046 } 1047 if (className !== void 0) { 1048 outProps.className = mergeClassNames(outProps.className, className); 1049 } 1050 if (style !== void 0) { 1051 outProps.style = mergeObjects(outProps.style, style); 1052 } 1053 return outProps; 1054 } 1055 function resolveRenderFunctionProps(props) { 1056 if (Array.isArray(props)) { 1057 return mergePropsN(props); 1058 } 1059 return mergeProps(void 0, props); 1060 } 1061 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); 1062 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/; 1063 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/; 1064 function evaluateRenderProp(element, render4, props, state) { 1065 if (render4) { 1066 if (typeof render4 === "function") { 1067 if (true) { 1068 warnIfRenderPropLooksLikeComponent(render4); 1069 } 1070 return render4(props, state); 1071 } 1072 const mergedProps = mergeProps(props, render4.props); 1073 mergedProps.ref = props.ref; 1074 let newElement = render4; 1075 if (newElement?.$$typeof === REACT_LAZY_TYPE) { 1076 const children = React9.Children.toArray(render4); 1077 newElement = children[0]; 1078 } 1079 if (true) { 1080 if (!/* @__PURE__ */ React9.isValidElement(newElement)) { 1081 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")); 1082 } 1083 } 1084 return /* @__PURE__ */ React9.cloneElement(newElement, mergedProps); 1085 } 1086 if (element) { 1087 if (typeof element === "string") { 1088 return renderTag(element, props); 1089 } 1090 } 1091 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8)); 1092 } 1093 function warnIfRenderPropLooksLikeComponent(renderFn) { 1094 const functionName = renderFn.name; 1095 if (functionName.length === 0) { 1096 return; 1097 } 1098 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) { 1099 return; 1100 } 1101 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) { 1102 return; 1103 } 1104 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"); 1105 } 1106 function renderTag(Tag, props) { 1107 if (Tag === "button") { 1108 return /* @__PURE__ */ (0, import_react.createElement)("button", { 1109 type: "button", 1110 ...props, 1111 key: props.key 1112 }); 1113 } 1114 if (Tag === "img") { 1115 return /* @__PURE__ */ (0, import_react.createElement)("img", { 1116 alt: "", 1117 ...props, 1118 key: props.key 1119 }); 1120 } 1121 return /* @__PURE__ */ React9.createElement(Tag, props); 1122 } 1123 1124 // node_modules/@base-ui/react/esm/internals/reason-parts.js 1125 var reason_parts_exports = {}; 1126 __export(reason_parts_exports, { 1127 cancelOpen: () => cancelOpen, 1128 chipRemovePress: () => chipRemovePress, 1129 clearPress: () => clearPress, 1130 closePress: () => closePress, 1131 closeWatcher: () => closeWatcher, 1132 decrementPress: () => decrementPress, 1133 disabled: () => disabled, 1134 drag: () => drag, 1135 escapeKey: () => escapeKey, 1136 focusOut: () => focusOut, 1137 imperativeAction: () => imperativeAction, 1138 incrementPress: () => incrementPress, 1139 inputBlur: () => inputBlur, 1140 inputChange: () => inputChange, 1141 inputClear: () => inputClear, 1142 inputPaste: () => inputPaste, 1143 inputPress: () => inputPress, 1144 itemPress: () => itemPress, 1145 keyboard: () => keyboard, 1146 linkPress: () => linkPress, 1147 listNavigation: () => listNavigation, 1148 none: () => none, 1149 outsidePress: () => outsidePress, 1150 pointer: () => pointer, 1151 scrub: () => scrub, 1152 siblingOpen: () => siblingOpen, 1153 swipe: () => swipe, 1154 trackPress: () => trackPress, 1155 triggerFocus: () => triggerFocus, 1156 triggerHover: () => triggerHover, 1157 triggerPress: () => triggerPress, 1158 wheel: () => wheel, 1159 windowResize: () => windowResize 1160 }); 1161 var none = "none"; 1162 var triggerPress = "trigger-press"; 1163 var triggerHover = "trigger-hover"; 1164 var triggerFocus = "trigger-focus"; 1165 var outsidePress = "outside-press"; 1166 var itemPress = "item-press"; 1167 var closePress = "close-press"; 1168 var linkPress = "link-press"; 1169 var clearPress = "clear-press"; 1170 var chipRemovePress = "chip-remove-press"; 1171 var trackPress = "track-press"; 1172 var incrementPress = "increment-press"; 1173 var decrementPress = "decrement-press"; 1174 var inputChange = "input-change"; 1175 var inputClear = "input-clear"; 1176 var inputBlur = "input-blur"; 1177 var inputPaste = "input-paste"; 1178 var inputPress = "input-press"; 1179 var focusOut = "focus-out"; 1180 var escapeKey = "escape-key"; 1181 var closeWatcher = "close-watcher"; 1182 var listNavigation = "list-navigation"; 1183 var keyboard = "keyboard"; 1184 var pointer = "pointer"; 1185 var drag = "drag"; 1186 var wheel = "wheel"; 1187 var scrub = "scrub"; 1188 var cancelOpen = "cancel-open"; 1189 var siblingOpen = "sibling-open"; 1190 var disabled = "disabled"; 1191 var imperativeAction = "imperative-action"; 1192 var swipe = "swipe"; 1193 var windowResize = "window-resize"; 1194 1195 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js 1196 function createChangeEventDetails(reason, event, trigger, customProperties) { 1197 let canceled = false; 1198 let allowPropagation = false; 1199 const custom = customProperties ?? EMPTY_OBJECT; 1200 const details = { 1201 reason, 1202 event: event ?? new Event("base-ui"), 1203 cancel() { 1204 canceled = true; 1205 }, 1206 allowPropagation() { 1207 allowPropagation = true; 1208 }, 1209 get isCanceled() { 1210 return canceled; 1211 }, 1212 get isPropagationAllowed() { 1213 return allowPropagation; 1214 }, 1215 trigger, 1216 ...custom 1217 }; 1218 return details; 1219 } 1220 1221 // node_modules/@base-ui/utils/esm/useId.js 1222 var React11 = __toESM(require_react(), 1); 1223 1224 // node_modules/@base-ui/utils/esm/safeReact.js 1225 var React10 = __toESM(require_react(), 1); 1226 var SafeReact = { 1227 ...React10 1228 }; 1229 1230 // node_modules/@base-ui/utils/esm/useId.js 1231 var globalId = 0; 1232 function useGlobalId(idOverride, prefix = "mui") { 1233 const [defaultId, setDefaultId] = React11.useState(idOverride); 1234 const id = idOverride || defaultId; 1235 React11.useEffect(() => { 1236 if (defaultId == null) { 1237 globalId += 1; 1238 setDefaultId(`$prefix}-$globalId}`); 1239 } 1240 }, [defaultId, prefix]); 1241 return id; 1242 } 1243 var maybeReactUseId = SafeReact.useId; 1244 function useId(idOverride, prefix) { 1245 if (maybeReactUseId !== void 0) { 1246 const reactId = maybeReactUseId(); 1247 return idOverride ?? (prefix ? `$prefix}-$reactId}` : reactId); 1248 } 1249 return useGlobalId(idOverride, prefix); 1250 } 1251 1252 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js 1253 function useBaseUiId(idOverride) { 1254 return useId(idOverride, "base-ui"); 1255 } 1256 1257 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js 1258 var React14 = __toESM(require_react(), 1); 1259 1260 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js 1261 var ReactDOM = __toESM(require_react_dom(), 1); 1262 1263 // node_modules/@base-ui/utils/esm/useOnMount.js 1264 var React12 = __toESM(require_react(), 1); 1265 var EMPTY = []; 1266 function useOnMount(fn) { 1267 React12.useEffect(fn, EMPTY); 1268 } 1269 1270 // node_modules/@base-ui/utils/esm/useAnimationFrame.js 1271 var EMPTY2 = null; 1272 var LAST_RAF = globalThis.requestAnimationFrame; 1273 var Scheduler = class { 1274 /* This implementation uses an array as a backing data-structure for frame callbacks. 1275 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it 1276 * never calls the native `cancelAnimationFrame` if there are no frames left. This can 1277 * be much more efficient if there is a call pattern that alterns as 1278 * "request-cancel-request-cancel-…". 1279 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation 1280 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */ 1281 callbacks = []; 1282 callbacksCount = 0; 1283 nextId = 1; 1284 startId = 1; 1285 isScheduled = false; 1286 tick = (timestamp) => { 1287 this.isScheduled = false; 1288 const currentCallbacks = this.callbacks; 1289 const currentCallbacksCount = this.callbacksCount; 1290 this.callbacks = []; 1291 this.callbacksCount = 0; 1292 this.startId = this.nextId; 1293 if (currentCallbacksCount > 0) { 1294 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) { 1295 currentCallbacks[i2]?.(timestamp); 1296 } 1297 } 1298 }; 1299 request(fn) { 1300 const id = this.nextId; 1301 this.nextId += 1; 1302 this.callbacks.push(fn); 1303 this.callbacksCount += 1; 1304 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true); 1305 if (!this.isScheduled || didRAFChange) { 1306 requestAnimationFrame(this.tick); 1307 this.isScheduled = true; 1308 } 1309 return id; 1310 } 1311 cancel(id) { 1312 const index2 = id - this.startId; 1313 if (index2 < 0 || index2 >= this.callbacks.length) { 1314 return; 1315 } 1316 this.callbacks[index2] = null; 1317 this.callbacksCount -= 1; 1318 } 1319 }; 1320 var scheduler = new Scheduler(); 1321 var AnimationFrame = class _AnimationFrame { 1322 static create() { 1323 return new _AnimationFrame(); 1324 } 1325 static request(fn) { 1326 return scheduler.request(fn); 1327 } 1328 static cancel(id) { 1329 return scheduler.cancel(id); 1330 } 1331 currentId = EMPTY2; 1332 /** 1333 * Executes `fn` after `delay`, clearing any previously scheduled call. 1334 */ 1335 request(fn) { 1336 this.cancel(); 1337 this.currentId = scheduler.request(() => { 1338 this.currentId = EMPTY2; 1339 fn(); 1340 }); 1341 } 1342 cancel = () => { 1343 if (this.currentId !== EMPTY2) { 1344 scheduler.cancel(this.currentId); 1345 this.currentId = EMPTY2; 1346 } 1347 }; 1348 disposeEffect = () => { 1349 return this.cancel; 1350 }; 1351 }; 1352 function useAnimationFrame() { 1353 const timeout = useRefWithInit(AnimationFrame.create).current; 1354 useOnMount(timeout.disposeEffect); 1355 return timeout; 1356 } 1357 1358 // node_modules/@base-ui/react/esm/utils/resolveRef.js 1359 function resolveRef(maybeRef) { 1360 if (maybeRef == null) { 1361 return maybeRef; 1362 } 1363 return "current" in maybeRef ? maybeRef.current : maybeRef; 1364 } 1365 1366 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js 1367 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) { 1368 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style"; 1369 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style"; 1370 return TransitionStatusDataAttributes2; 1371 })({}); 1372 var STARTING_HOOK = { 1373 [TransitionStatusDataAttributes.startingStyle]: "" 1374 }; 1375 var ENDING_HOOK = { 1376 [TransitionStatusDataAttributes.endingStyle]: "" 1377 }; 1378 var transitionStatusMapping = { 1379 transitionStatus(value) { 1380 if (value === "starting") { 1381 return STARTING_HOOK; 1382 } 1383 if (value === "ending") { 1384 return ENDING_HOOK; 1385 } 1386 return null; 1387 } 1388 }; 1389 1390 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js 1391 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) { 1392 const frame = useAnimationFrame(); 1393 return useStableCallback((fnToExecute, signal = null) => { 1394 frame.cancel(); 1395 const element = resolveRef(elementOrRef); 1396 if (element == null) { 1397 return; 1398 } 1399 const resolvedElement = element; 1400 const done = () => { 1401 ReactDOM.flushSync(fnToExecute); 1402 }; 1403 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) { 1404 fnToExecute(); 1405 return; 1406 } 1407 function exec() { 1408 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => { 1409 if (!signal?.aborted) { 1410 done(); 1411 } 1412 }).catch(() => { 1413 if (treatAbortedAsFinished) { 1414 if (!signal?.aborted) { 1415 done(); 1416 } 1417 return; 1418 } 1419 const currentAnimations = resolvedElement.getAnimations(); 1420 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) { 1421 exec(); 1422 } 1423 }); 1424 } 1425 if (waitForStartingStyleRemoved) { 1426 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle; 1427 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 1428 frame.request(exec); 1429 return; 1430 } 1431 const attributeObserver = new MutationObserver(() => { 1432 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 1433 attributeObserver.disconnect(); 1434 exec(); 1435 } 1436 }); 1437 attributeObserver.observe(resolvedElement, { 1438 attributes: true, 1439 attributeFilter: [startingStyleAttribute] 1440 }); 1441 signal?.addEventListener("abort", () => attributeObserver.disconnect(), { 1442 once: true 1443 }); 1444 return; 1445 } 1446 frame.request(exec); 1447 }); 1448 } 1449 1450 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js 1451 var React13 = __toESM(require_react(), 1); 1452 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) { 1453 const [transitionStatus, setTransitionStatus] = React13.useState(open && enableIdleState ? "idle" : void 0); 1454 const [mounted, setMounted] = React13.useState(open); 1455 if (open && !mounted) { 1456 setMounted(true); 1457 setTransitionStatus("starting"); 1458 } 1459 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) { 1460 setTransitionStatus("ending"); 1461 } 1462 if (!open && !mounted && transitionStatus === "ending") { 1463 setTransitionStatus(void 0); 1464 } 1465 useIsoLayoutEffect(() => { 1466 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) { 1467 const frame = AnimationFrame.request(() => { 1468 setTransitionStatus("ending"); 1469 }); 1470 return () => { 1471 AnimationFrame.cancel(frame); 1472 }; 1473 } 1474 return void 0; 1475 }, [open, mounted, transitionStatus, deferEndingState]); 1476 useIsoLayoutEffect(() => { 1477 if (!open || enableIdleState) { 1478 return void 0; 1479 } 1480 const frame = AnimationFrame.request(() => { 1481 setTransitionStatus(void 0); 1482 }); 1483 return () => { 1484 AnimationFrame.cancel(frame); 1485 }; 1486 }, [enableIdleState, open]); 1487 useIsoLayoutEffect(() => { 1488 if (!open || !enableIdleState) { 1489 return void 0; 1490 } 1491 if (open && mounted && transitionStatus !== "idle") { 1492 setTransitionStatus("starting"); 1493 } 1494 const frame = AnimationFrame.request(() => { 1495 setTransitionStatus("idle"); 1496 }); 1497 return () => { 1498 AnimationFrame.cancel(frame); 1499 }; 1500 }, [enableIdleState, open, mounted, transitionStatus]); 1501 return { 1502 mounted, 1503 setMounted, 1504 transitionStatus 1505 }; 1506 } 1507 1508 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js 1509 function useCollapsibleRoot(parameters) { 1510 const { 1511 open: openParam, 1512 defaultOpen, 1513 onOpenChange, 1514 disabled: disabled2 1515 } = parameters; 1516 const isControlled = openParam !== void 0; 1517 const [open, setOpen] = useControlled({ 1518 controlled: openParam, 1519 default: defaultOpen, 1520 name: "Collapsible", 1521 state: "open" 1522 }); 1523 const { 1524 mounted, 1525 setMounted, 1526 transitionStatus 1527 } = useTransitionStatus(open, true, true); 1528 const [visible, setVisible] = React14.useState(open); 1529 const [{ 1530 height, 1531 width 1532 }, setDimensions] = React14.useState({ 1533 height: void 0, 1534 width: void 0 1535 }); 1536 const defaultPanelId = useBaseUiId(); 1537 const [panelIdState, setPanelIdState] = React14.useState(); 1538 const panelId = panelIdState ?? defaultPanelId; 1539 const [hiddenUntilFound, setHiddenUntilFound] = React14.useState(false); 1540 const [keepMounted, setKeepMounted] = React14.useState(false); 1541 const abortControllerRef = React14.useRef(null); 1542 const animationTypeRef = React14.useRef(null); 1543 const transitionDimensionRef = React14.useRef(null); 1544 const panelRef = React14.useRef(null); 1545 const runOnceAnimationsFinish = useAnimationsFinished(panelRef, false); 1546 const handleTrigger = useStableCallback((event) => { 1547 const nextOpen = !open; 1548 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent); 1549 onOpenChange(nextOpen, eventDetails); 1550 if (eventDetails.isCanceled) { 1551 return; 1552 } 1553 const panel = panelRef.current; 1554 if (animationTypeRef.current === "css-animation" && panel != null) { 1555 panel.style.removeProperty("animation-name"); 1556 } 1557 if (!hiddenUntilFound && !keepMounted) { 1558 if (animationTypeRef.current != null && animationTypeRef.current !== "css-animation") { 1559 if (!mounted && nextOpen) { 1560 setMounted(true); 1561 } 1562 } 1563 if (animationTypeRef.current === "css-animation") { 1564 if (!visible && nextOpen) { 1565 setVisible(true); 1566 } 1567 if (!mounted && nextOpen) { 1568 setMounted(true); 1569 } 1570 } 1571 } 1572 setOpen(nextOpen); 1573 if (animationTypeRef.current === "none" && mounted && !nextOpen) { 1574 setMounted(false); 1575 } 1576 }); 1577 useIsoLayoutEffect(() => { 1578 if (isControlled && animationTypeRef.current === "none" && !open) { 1579 setMounted(false); 1580 } 1581 }, [isControlled, open, openParam, setMounted]); 1582 return React14.useMemo(() => ({ 1583 abortControllerRef, 1584 animationTypeRef, 1585 disabled: disabled2, 1586 handleTrigger, 1587 height, 1588 mounted, 1589 open, 1590 panelId, 1591 panelRef, 1592 runOnceAnimationsFinish, 1593 setDimensions, 1594 setHiddenUntilFound, 1595 setKeepMounted, 1596 setMounted, 1597 setOpen, 1598 setPanelIdState, 1599 setVisible, 1600 transitionDimensionRef, 1601 transitionStatus, 1602 visible, 1603 width 1604 }), [abortControllerRef, animationTypeRef, disabled2, handleTrigger, height, mounted, open, panelId, panelRef, runOnceAnimationsFinish, setDimensions, setHiddenUntilFound, setKeepMounted, setMounted, setOpen, setVisible, transitionDimensionRef, transitionStatus, visible, width]); 1605 } 1606 1607 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRootContext.js 1608 var React15 = __toESM(require_react(), 1); 1609 var CollapsibleRootContext = /* @__PURE__ */ React15.createContext(void 0); 1610 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext"; 1611 function useCollapsibleRootContext() { 1612 const context = React15.useContext(CollapsibleRootContext); 1613 if (context === void 0) { 1614 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15)); 1615 } 1616 return context; 1617 } 1618 1619 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelDataAttributes.js 1620 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) { 1621 CollapsiblePanelDataAttributes2["open"] = "data-open"; 1622 CollapsiblePanelDataAttributes2["closed"] = "data-closed"; 1623 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; 1624 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; 1625 return CollapsiblePanelDataAttributes2; 1626 })({}); 1627 1628 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTriggerDataAttributes.js 1629 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) { 1630 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open"; 1631 return CollapsibleTriggerDataAttributes2; 1632 })({}); 1633 1634 // node_modules/@base-ui/react/esm/utils/collapsibleOpenStateMapping.js 1635 var PANEL_OPEN_HOOK = { 1636 [CollapsiblePanelDataAttributes.open]: "" 1637 }; 1638 var PANEL_CLOSED_HOOK = { 1639 [CollapsiblePanelDataAttributes.closed]: "" 1640 }; 1641 var triggerOpenStateMapping = { 1642 open(value) { 1643 if (value) { 1644 return { 1645 [CollapsibleTriggerDataAttributes.panelOpen]: "" 1646 }; 1647 } 1648 return null; 1649 } 1650 }; 1651 var collapsibleOpenStateMapping = { 1652 open(value) { 1653 if (value) { 1654 return PANEL_OPEN_HOOK; 1655 } 1656 return PANEL_CLOSED_HOOK; 1657 } 1658 }; 1659 1660 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js 1661 var React18 = __toESM(require_react(), 1); 1662 1663 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs 1664 function hasWindow() { 1665 return typeof window !== "undefined"; 1666 } 1667 function getNodeName(node) { 1668 if (isNode(node)) { 1669 return (node.nodeName || "").toLowerCase(); 1670 } 1671 return "#document"; 1672 } 1673 function getWindow(node) { 1674 var _node$ownerDocument; 1675 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; 1676 } 1677 function getDocumentElement(node) { 1678 var _ref; 1679 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; 1680 } 1681 function isNode(value) { 1682 if (!hasWindow()) { 1683 return false; 1684 } 1685 return value instanceof Node || value instanceof getWindow(value).Node; 1686 } 1687 function isElement(value) { 1688 if (!hasWindow()) { 1689 return false; 1690 } 1691 return value instanceof Element || value instanceof getWindow(value).Element; 1692 } 1693 function isHTMLElement(value) { 1694 if (!hasWindow()) { 1695 return false; 1696 } 1697 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; 1698 } 1699 function isShadowRoot(value) { 1700 if (!hasWindow() || typeof ShadowRoot === "undefined") { 1701 return false; 1702 } 1703 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; 1704 } 1705 function isOverflowElement(element) { 1706 const { 1707 overflow, 1708 overflowX, 1709 overflowY, 1710 display 1711 } = getComputedStyle2(element); 1712 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents"; 1713 } 1714 function isTableElement(element) { 1715 return /^(table|td|th)$/.test(getNodeName(element)); 1716 } 1717 function isTopLayer(element) { 1718 try { 1719 if (element.matches(":popover-open")) { 1720 return true; 1721 } 1722 } catch (_e) { 1723 } 1724 try { 1725 return element.matches(":modal"); 1726 } catch (_e) { 1727 return false; 1728 } 1729 } 1730 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/; 1731 var containRe = /paint|layout|strict|content/; 1732 var isNotNone = (value) => !!value && value !== "none"; 1733 var isWebKitValue; 1734 function isContainingBlock(elementOrCss) { 1735 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss; 1736 return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || ""); 1737 } 1738 function getContainingBlock(element) { 1739 let currentNode = getParentNode(element); 1740 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { 1741 if (isContainingBlock(currentNode)) { 1742 return currentNode; 1743 } else if (isTopLayer(currentNode)) { 1744 return null; 1745 } 1746 currentNode = getParentNode(currentNode); 1747 } 1748 return null; 1749 } 1750 function isWebKit() { 1751 if (isWebKitValue == null) { 1752 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none"); 1753 } 1754 return isWebKitValue; 1755 } 1756 function isLastTraversableNode(node) { 1757 return /^(html|body|#document)$/.test(getNodeName(node)); 1758 } 1759 function getComputedStyle2(element) { 1760 return getWindow(element).getComputedStyle(element); 1761 } 1762 function getNodeScroll(element) { 1763 if (isElement(element)) { 1764 return { 1765 scrollLeft: element.scrollLeft, 1766 scrollTop: element.scrollTop 1767 }; 1768 } 1769 return { 1770 scrollLeft: element.scrollX, 1771 scrollTop: element.scrollY 1772 }; 1773 } 1774 function getParentNode(node) { 1775 if (getNodeName(node) === "html") { 1776 return node; 1777 } 1778 const result = ( 1779 // Step into the shadow DOM of the parent of a slotted node. 1780 node.assignedSlot || // DOM Element detected. 1781 node.parentNode || // ShadowRoot detected. 1782 isShadowRoot(node) && node.host || // Fallback. 1783 getDocumentElement(node) 1784 ); 1785 return isShadowRoot(result) ? result.host : result; 1786 } 1787 function getNearestOverflowAncestor(node) { 1788 const parentNode = getParentNode(node); 1789 if (isLastTraversableNode(parentNode)) { 1790 return node.ownerDocument ? node.ownerDocument.body : node.body; 1791 } 1792 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { 1793 return parentNode; 1794 } 1795 return getNearestOverflowAncestor(parentNode); 1796 } 1797 function getOverflowAncestors(node, list, traverseIframes) { 1798 var _node$ownerDocument2; 1799 if (list === void 0) { 1800 list = []; 1801 } 1802 if (traverseIframes === void 0) { 1803 traverseIframes = true; 1804 } 1805 const scrollableAncestor = getNearestOverflowAncestor(node); 1806 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); 1807 const win = getWindow(scrollableAncestor); 1808 if (isBody) { 1809 const frameElement = getFrameElement(win); 1810 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []); 1811 } else { 1812 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); 1813 } 1814 } 1815 function getFrameElement(win) { 1816 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null; 1817 } 1818 1819 // node_modules/@base-ui/react/esm/internals/composite/root/CompositeRootContext.js 1820 var React16 = __toESM(require_react(), 1); 1821 var CompositeRootContext = /* @__PURE__ */ React16.createContext(void 0); 1822 if (true) CompositeRootContext.displayName = "CompositeRootContext"; 1823 function useCompositeRootContext(optional = false) { 1824 const context = React16.useContext(CompositeRootContext); 1825 if (context === void 0 && !optional) { 1826 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16)); 1827 } 1828 return context; 1829 } 1830 1831 // node_modules/@base-ui/react/esm/utils/useFocusableWhenDisabled.js 1832 var React17 = __toESM(require_react(), 1); 1833 function useFocusableWhenDisabled(parameters) { 1834 const { 1835 focusableWhenDisabled, 1836 disabled: disabled2, 1837 composite = false, 1838 tabIndex: tabIndexProp = 0, 1839 isNativeButton 1840 } = parameters; 1841 const isFocusableComposite = composite && focusableWhenDisabled !== false; 1842 const isNonFocusableComposite = composite && focusableWhenDisabled === false; 1843 const props = React17.useMemo(() => { 1844 const additionalProps = { 1845 // allow Tabbing away from focusableWhenDisabled elements 1846 onKeyDown(event) { 1847 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") { 1848 event.preventDefault(); 1849 } 1850 } 1851 }; 1852 if (!composite) { 1853 additionalProps.tabIndex = tabIndexProp; 1854 if (!isNativeButton && disabled2) { 1855 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1; 1856 } 1857 } 1858 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) { 1859 additionalProps["aria-disabled"] = disabled2; 1860 } 1861 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) { 1862 additionalProps.disabled = disabled2; 1863 } 1864 return additionalProps; 1865 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]); 1866 return { 1867 props 1868 }; 1869 } 1870 1871 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js 1872 function useButton(parameters = {}) { 1873 const { 1874 disabled: disabled2 = false, 1875 focusableWhenDisabled, 1876 tabIndex = 0, 1877 native: isNativeButton = true, 1878 composite: compositeProp 1879 } = parameters; 1880 const elementRef = React18.useRef(null); 1881 const compositeRootContext = useCompositeRootContext(true); 1882 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0; 1883 const { 1884 props: focusableWhenDisabledProps 1885 } = useFocusableWhenDisabled({ 1886 focusableWhenDisabled, 1887 disabled: disabled2, 1888 composite: isCompositeItem, 1889 tabIndex, 1890 isNativeButton 1891 }); 1892 if (true) { 1893 React18.useEffect(() => { 1894 if (!elementRef.current) { 1895 return; 1896 } 1897 const isButtonTag = isButtonElement(elementRef.current); 1898 if (isNativeButton) { 1899 if (!isButtonTag) { 1900 const ownerStackMessage = SafeReact.captureOwnerStack?.() || ""; 1901 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`."; 1902 error(`$message2}$ownerStackMessage}`); 1903 } 1904 } else if (isButtonTag) { 1905 const ownerStackMessage = SafeReact.captureOwnerStack?.() || ""; 1906 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`."; 1907 error(`$message2}$ownerStackMessage}`); 1908 } 1909 }, [isNativeButton]); 1910 } 1911 const updateDisabled = React18.useCallback(() => { 1912 const element = elementRef.current; 1913 if (!isButtonElement(element)) { 1914 return; 1915 } 1916 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) { 1917 element.disabled = false; 1918 } 1919 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]); 1920 useIsoLayoutEffect(updateDisabled, [updateDisabled]); 1921 const getButtonProps = React18.useCallback((externalProps = {}) => { 1922 const { 1923 onClick: externalOnClick, 1924 onMouseDown: externalOnMouseDown, 1925 onKeyUp: externalOnKeyUp, 1926 onKeyDown: externalOnKeyDown, 1927 onPointerDown: externalOnPointerDown, 1928 ...otherExternalProps 1929 } = externalProps; 1930 const type = isNativeButton ? "button" : void 0; 1931 return mergeProps({ 1932 type, 1933 onClick(event) { 1934 if (disabled2) { 1935 event.preventDefault(); 1936 return; 1937 } 1938 externalOnClick?.(event); 1939 }, 1940 onMouseDown(event) { 1941 if (!disabled2) { 1942 externalOnMouseDown?.(event); 1943 } 1944 }, 1945 onKeyDown(event) { 1946 if (disabled2) { 1947 return; 1948 } 1949 makeEventPreventable(event); 1950 externalOnKeyDown?.(event); 1951 if (event.baseUIHandlerPrevented) { 1952 return; 1953 } 1954 const isCurrentTarget = event.target === event.currentTarget; 1955 const currentTarget = event.currentTarget; 1956 const isButton = isButtonElement(currentTarget); 1957 const isLink = !isNativeButton && isValidLinkElement(currentTarget); 1958 const shouldClick = isCurrentTarget && (isNativeButton ? isButton : !isLink); 1959 const isEnterKey = event.key === "Enter"; 1960 const isSpaceKey = event.key === " "; 1961 const role = currentTarget.getAttribute("role"); 1962 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell"; 1963 if (isCurrentTarget && isCompositeItem && isSpaceKey) { 1964 if (event.defaultPrevented && isTextNavigationRole) { 1965 return; 1966 } 1967 event.preventDefault(); 1968 if (isLink || isNativeButton && isButton) { 1969 currentTarget.click(); 1970 event.preventBaseUIHandler(); 1971 } else if (shouldClick) { 1972 externalOnClick?.(event); 1973 event.preventBaseUIHandler(); 1974 } 1975 return; 1976 } 1977 if (shouldClick) { 1978 if (!isNativeButton && (isSpaceKey || isEnterKey)) { 1979 event.preventDefault(); 1980 } 1981 if (!isNativeButton && isEnterKey) { 1982 externalOnClick?.(event); 1983 } 1984 } 1985 }, 1986 onKeyUp(event) { 1987 if (disabled2) { 1988 return; 1989 } 1990 makeEventPreventable(event); 1991 externalOnKeyUp?.(event); 1992 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") { 1993 event.preventDefault(); 1994 return; 1995 } 1996 if (event.baseUIHandlerPrevented) { 1997 return; 1998 } 1999 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") { 2000 externalOnClick?.(event); 2001 } 2002 }, 2003 onPointerDown(event) { 2004 if (disabled2) { 2005 event.preventDefault(); 2006 return; 2007 } 2008 externalOnPointerDown?.(event); 2009 } 2010 }, !isNativeButton ? { 2011 role: "button" 2012 } : void 0, focusableWhenDisabledProps, otherExternalProps); 2013 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]); 2014 const buttonRef = useStableCallback((element) => { 2015 elementRef.current = element; 2016 updateDisabled(); 2017 }); 2018 return { 2019 getButtonProps, 2020 buttonRef 2021 }; 2022 } 2023 function isButtonElement(elem) { 2024 return isHTMLElement(elem) && elem.tagName === "BUTTON"; 2025 } 2026 function isValidLinkElement(elem) { 2027 return Boolean(elem?.tagName === "A" && elem?.href); 2028 } 2029 2030 // node_modules/@base-ui/utils/esm/detectBrowser.js 2031 var hasNavigator = typeof navigator !== "undefined"; 2032 var nav = getNavigatorData(); 2033 var platform = getPlatform(); 2034 var userAgent = getUserAgent(); 2035 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none"); 2036 var isIOS = ( 2037 // iPads can claim to be MacIntel 2038 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform) 2039 ); 2040 var isFirefox = hasNavigator && /firefox/i.test(userAgent); 2041 var isSafari = hasNavigator && /apple/i.test(navigator.vendor); 2042 var isEdge = hasNavigator && /Edg/i.test(userAgent); 2043 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent); 2044 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints; 2045 var isJSDOM = userAgent.includes("jsdom/"); 2046 function getNavigatorData() { 2047 if (!hasNavigator) { 2048 return { 2049 platform: "", 2050 maxTouchPoints: -1 2051 }; 2052 } 2053 const uaData = navigator.userAgentData; 2054 if (uaData?.platform) { 2055 return { 2056 platform: uaData.platform, 2057 maxTouchPoints: navigator.maxTouchPoints 2058 }; 2059 } 2060 return { 2061 platform: navigator.platform ?? "", 2062 maxTouchPoints: navigator.maxTouchPoints ?? -1 2063 }; 2064 } 2065 function getUserAgent() { 2066 if (!hasNavigator) { 2067 return ""; 2068 } 2069 const uaData = navigator.userAgentData; 2070 if (uaData && Array.isArray(uaData.brands)) { 2071 return uaData.brands.map(({ 2072 brand, 2073 version: version2 2074 }) => `$brand}/$version2}`).join(" "); 2075 } 2076 return navigator.userAgent; 2077 } 2078 function getPlatform() { 2079 if (!hasNavigator) { 2080 return ""; 2081 } 2082 const uaData = navigator.userAgentData; 2083 if (uaData?.platform) { 2084 return uaData.platform; 2085 } 2086 return navigator.platform ?? ""; 2087 } 2088 2089 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js 2090 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable"; 2091 var ACTIVE_KEY = "active"; 2092 var SELECTED_KEY = "selected"; 2093 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"; 2094 2095 // node_modules/@base-ui/react/esm/internals/shadowDom.js 2096 function activeElement(doc) { 2097 let element = doc.activeElement; 2098 while (element?.shadowRoot?.activeElement != null) { 2099 element = element.shadowRoot.activeElement; 2100 } 2101 return element; 2102 } 2103 function contains(parent, child) { 2104 if (!parent || !child) { 2105 return false; 2106 } 2107 const rootNode = child.getRootNode?.(); 2108 if (parent.contains(child)) { 2109 return true; 2110 } 2111 if (rootNode && isShadowRoot(rootNode)) { 2112 let next = child; 2113 while (next) { 2114 if (parent === next) { 2115 return true; 2116 } 2117 next = next.parentNode || next.host; 2118 } 2119 } 2120 return false; 2121 } 2122 function getTarget(event) { 2123 if ("composedPath" in event) { 2124 return event.composedPath()[0]; 2125 } 2126 return event.target; 2127 } 2128 2129 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js 2130 function isTargetInsideEnabledTrigger(target, triggerElements) { 2131 if (!isElement(target)) { 2132 return false; 2133 } 2134 const targetElement = target; 2135 if (triggerElements.hasElement(targetElement)) { 2136 return !targetElement.hasAttribute("data-trigger-disabled"); 2137 } 2138 for (const [, trigger] of triggerElements.entries()) { 2139 if (contains(trigger, targetElement)) { 2140 return !trigger.hasAttribute("data-trigger-disabled"); 2141 } 2142 } 2143 return false; 2144 } 2145 function isEventTargetWithin(event, node) { 2146 if (node == null) { 2147 return false; 2148 } 2149 if ("composedPath" in event) { 2150 return event.composedPath().includes(node); 2151 } 2152 const eventAgain = event; 2153 return eventAgain.target != null && node.contains(eventAgain.target); 2154 } 2155 function isRootElement(element) { 2156 return element.matches("html,body"); 2157 } 2158 function isTypeableElement(element) { 2159 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR); 2160 } 2161 function isInteractiveElement(element) { 2162 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),$TYPEABLE_SELECTOR}`) != null; 2163 } 2164 function matchesFocusVisible(element) { 2165 if (!element || isJSDOM) { 2166 return true; 2167 } 2168 try { 2169 return element.matches(":focus-visible"); 2170 } catch (_e) { 2171 return true; 2172 } 2173 } 2174 2175 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js 2176 function getNodeChildren(nodes, id, onlyOpenChildren = true) { 2177 const directChildren = nodes.filter((node) => node.parentId === id); 2178 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]); 2179 } 2180 2181 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js 2182 function isReactEvent(event) { 2183 return "nativeEvent" in event; 2184 } 2185 function isMouseLikePointerType(pointerType, strict) { 2186 const values = ["mouse", "pen"]; 2187 if (!strict) { 2188 values.push("", void 0); 2189 } 2190 return values.includes(pointerType); 2191 } 2192 function isClickLikeEvent(event) { 2193 const type = event.type; 2194 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup"; 2195 } 2196 2197 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs 2198 var sides = ["top", "right", "bottom", "left"]; 2199 var min = Math.min; 2200 var max = Math.max; 2201 var round = Math.round; 2202 var floor = Math.floor; 2203 var createCoords = (v2) => ({ 2204 x: v2, 2205 y: v2 2206 }); 2207 var oppositeSideMap = { 2208 left: "right", 2209 right: "left", 2210 bottom: "top", 2211 top: "bottom" 2212 }; 2213 function clamp(start, value, end) { 2214 return max(start, min(value, end)); 2215 } 2216 function evaluate(value, param) { 2217 return typeof value === "function" ? value(param) : value; 2218 } 2219 function getSide(placement) { 2220 return placement.split("-")[0]; 2221 } 2222 function getAlignment(placement) { 2223 return placement.split("-")[1]; 2224 } 2225 function getOppositeAxis(axis) { 2226 return axis === "x" ? "y" : "x"; 2227 } 2228 function getAxisLength(axis) { 2229 return axis === "y" ? "height" : "width"; 2230 } 2231 function getSideAxis(placement) { 2232 const firstChar = placement[0]; 2233 return firstChar === "t" || firstChar === "b" ? "y" : "x"; 2234 } 2235 function getAlignmentAxis(placement) { 2236 return getOppositeAxis(getSideAxis(placement)); 2237 } 2238 function getAlignmentSides(placement, rects, rtl) { 2239 if (rtl === void 0) { 2240 rtl = false; 2241 } 2242 const alignment = getAlignment(placement); 2243 const alignmentAxis = getAlignmentAxis(placement); 2244 const length2 = getAxisLength(alignmentAxis); 2245 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; 2246 if (rects.reference[length2] > rects.floating[length2]) { 2247 mainAlignmentSide = getOppositePlacement(mainAlignmentSide); 2248 } 2249 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; 2250 } 2251 function getExpandedPlacements(placement) { 2252 const oppositePlacement = getOppositePlacement(placement); 2253 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; 2254 } 2255 function getOppositeAlignmentPlacement(placement) { 2256 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start"); 2257 } 2258 var lrPlacement = ["left", "right"]; 2259 var rlPlacement = ["right", "left"]; 2260 var tbPlacement = ["top", "bottom"]; 2261 var btPlacement = ["bottom", "top"]; 2262 function getSideList(side, isStart, rtl) { 2263 switch (side) { 2264 case "top": 2265 case "bottom": 2266 if (rtl) return isStart ? rlPlacement : lrPlacement; 2267 return isStart ? lrPlacement : rlPlacement; 2268 case "left": 2269 case "right": 2270 return isStart ? tbPlacement : btPlacement; 2271 default: 2272 return []; 2273 } 2274 } 2275 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { 2276 const alignment = getAlignment(placement); 2277 let list = getSideList(getSide(placement), direction === "start", rtl); 2278 if (alignment) { 2279 list = list.map((side) => side + "-" + alignment); 2280 if (flipAlignment) { 2281 list = list.concat(list.map(getOppositeAlignmentPlacement)); 2282 } 2283 } 2284 return list; 2285 } 2286 function getOppositePlacement(placement) { 2287 const side = getSide(placement); 2288 return oppositeSideMap[side] + placement.slice(side.length); 2289 } 2290 function expandPaddingObject(padding) { 2291 return { 2292 top: 0, 2293 right: 0, 2294 bottom: 0, 2295 left: 0, 2296 ...padding 2297 }; 2298 } 2299 function getPaddingObject(padding) { 2300 return typeof padding !== "number" ? expandPaddingObject(padding) : { 2301 top: padding, 2302 right: padding, 2303 bottom: padding, 2304 left: padding 2305 }; 2306 } 2307 function rectToClientRect(rect) { 2308 const { 2309 x: x2, 2310 y: y2, 2311 width, 2312 height 2313 } = rect; 2314 return { 2315 width, 2316 height, 2317 top: y2, 2318 left: x2, 2319 right: x2 + width, 2320 bottom: y2 + height, 2321 x: x2, 2322 y: y2 2323 }; 2324 } 2325 2326 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js 2327 function isHiddenByStyles(styles) { 2328 return styles.visibility === "hidden" || styles.visibility === "collapse"; 2329 } 2330 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) { 2331 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) { 2332 return false; 2333 } 2334 if (typeof element.checkVisibility === "function") { 2335 return element.checkVisibility(); 2336 } 2337 return styles.display !== "none" && styles.display !== "contents"; 2338 } 2339 2340 // node_modules/@base-ui/utils/esm/owner.js 2341 function ownerDocument(node) { 2342 return node?.ownerDocument || document; 2343 } 2344 2345 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js 2346 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]'; 2347 function getParentElement(element) { 2348 const assignedSlot = element.assignedSlot; 2349 if (assignedSlot) { 2350 return assignedSlot; 2351 } 2352 if (element.parentElement) { 2353 return element.parentElement; 2354 } 2355 const rootNode = element.getRootNode(); 2356 return isShadowRoot(rootNode) ? rootNode.host : null; 2357 } 2358 function getDetailsSummary(details) { 2359 for (const child of Array.from(details.children)) { 2360 if (getNodeName(child) === "summary") { 2361 return child; 2362 } 2363 } 2364 return null; 2365 } 2366 function isWithinOpenDetailsSummary(element, details) { 2367 const summary = getDetailsSummary(details); 2368 return !!summary && (element === summary || contains(summary, element)); 2369 } 2370 function isFocusableCandidate(element) { 2371 const nodeName = element ? getNodeName(element) : ""; 2372 return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && getNodeName(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden"); 2373 } 2374 function isFocusableElement(element) { 2375 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) { 2376 return false; 2377 } 2378 for (let current = element; current; current = getParentElement(current)) { 2379 const isAncestor = current !== element; 2380 const isSlot = getNodeName(current) === "slot"; 2381 if (current.hasAttribute("inert")) { 2382 return false; 2383 } 2384 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) { 2385 return false; 2386 } 2387 } 2388 return true; 2389 } 2390 function isVisibleInTabbableTree(element, isAncestor) { 2391 const styles = getComputedStyle2(element); 2392 if (!isAncestor) { 2393 return isElementVisible(element, styles); 2394 } 2395 return styles.display !== "none"; 2396 } 2397 function getTabIndex(element) { 2398 const tabIndex = element.tabIndex; 2399 if (tabIndex < 0) { 2400 const nodeName = getNodeName(element); 2401 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) { 2402 return 0; 2403 } 2404 } 2405 return tabIndex; 2406 } 2407 function getNamedRadioInput(element) { 2408 if (getNodeName(element) !== "input") { 2409 return null; 2410 } 2411 const input = element; 2412 return input.type === "radio" && input.name !== "" ? input : null; 2413 } 2414 function isTabbableRadio(element, candidates) { 2415 const input = getNamedRadioInput(element); 2416 if (!input) { 2417 return true; 2418 } 2419 const checkedRadio = candidates.find((candidate) => { 2420 const radio = getNamedRadioInput(candidate); 2421 return radio?.name === input.name && radio.form === input.form && radio.checked; 2422 }); 2423 if (checkedRadio) { 2424 return checkedRadio === input; 2425 } 2426 return candidates.find((candidate) => { 2427 const radio = getNamedRadioInput(candidate); 2428 return radio?.name === input.name && radio.form === input.form; 2429 }) === input; 2430 } 2431 function getComposedChildren(container) { 2432 if (isHTMLElement(container) && getNodeName(container) === "slot") { 2433 const assignedElements = container.assignedElements({ 2434 flatten: true 2435 }); 2436 if (assignedElements.length > 0) { 2437 return assignedElements; 2438 } 2439 } 2440 if (isHTMLElement(container) && container.shadowRoot) { 2441 return Array.from(container.shadowRoot.children); 2442 } 2443 return Array.from(container.children); 2444 } 2445 function appendCandidates(container, list) { 2446 getComposedChildren(container).forEach((child) => { 2447 if (isFocusableCandidate(child)) { 2448 list.push(child); 2449 } 2450 appendCandidates(child, list); 2451 }); 2452 } 2453 function appendMatchingElements(container, selector, list) { 2454 getComposedChildren(container).forEach((child) => { 2455 if (isHTMLElement(child) && child.matches(selector)) { 2456 list.push(child); 2457 } 2458 appendMatchingElements(child, selector, list); 2459 }); 2460 } 2461 function focusable(container) { 2462 const candidates = []; 2463 appendCandidates(container, candidates); 2464 return candidates.filter(isFocusableElement); 2465 } 2466 function tabbable(container) { 2467 const candidates = focusable(container); 2468 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates)); 2469 } 2470 function getTabbableIn(container, dir) { 2471 const list = tabbable(container); 2472 const len2 = list.length; 2473 if (len2 === 0) { 2474 return void 0; 2475 } 2476 const active = activeElement(ownerDocument(container)); 2477 const index2 = list.indexOf(active); 2478 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len2 - 1 : index2 + dir; 2479 return list[nextIndex]; 2480 } 2481 function getNextTabbable(referenceElement) { 2482 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement; 2483 } 2484 function getPreviousTabbable(referenceElement) { 2485 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement; 2486 } 2487 function isOutsideEvent(event, container) { 2488 const containerElement = container || event.currentTarget; 2489 const relatedTarget = event.relatedTarget; 2490 return !relatedTarget || !contains(containerElement, relatedTarget); 2491 } 2492 function disableFocusInside(container) { 2493 const tabbableElements = tabbable(container); 2494 tabbableElements.forEach((element) => { 2495 element.dataset.tabindex = element.getAttribute("tabindex") || ""; 2496 element.setAttribute("tabindex", "-1"); 2497 }); 2498 } 2499 function enableFocusInside(container) { 2500 const elements = []; 2501 appendMatchingElements(container, "[data-tabindex]", elements); 2502 elements.forEach((element) => { 2503 const tabindex = element.dataset.tabindex; 2504 delete element.dataset.tabindex; 2505 if (tabindex) { 2506 element.setAttribute("tabindex", tabindex); 2507 } else { 2508 element.removeAttribute("tabindex"); 2509 } 2510 }); 2511 } 2512 2513 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js 2514 var React19 = __toESM(require_react(), 1); 2515 2516 // node_modules/@base-ui/utils/esm/addEventListener.js 2517 function addEventListener(target, type, listener, options) { 2518 target.addEventListener(type, listener, options); 2519 return () => { 2520 target.removeEventListener(type, listener, options); 2521 }; 2522 } 2523 2524 // node_modules/@base-ui/react/esm/accordion/root/AccordionRootDataAttributes.js 2525 var AccordionRootDataAttributes = /* @__PURE__ */ (function(AccordionRootDataAttributes2) { 2526 AccordionRootDataAttributes2["disabled"] = "data-disabled"; 2527 AccordionRootDataAttributes2["orientation"] = "data-orientation"; 2528 return AccordionRootDataAttributes2; 2529 })({}); 2530 2531 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js 2532 function useCollapsiblePanel(parameters) { 2533 const { 2534 abortControllerRef, 2535 animationTypeRef, 2536 externalRef, 2537 height, 2538 hiddenUntilFound, 2539 keepMounted, 2540 id: idParam, 2541 mounted, 2542 onOpenChange, 2543 open, 2544 panelRef, 2545 runOnceAnimationsFinish, 2546 setDimensions, 2547 setMounted, 2548 setOpen, 2549 setVisible, 2550 transitionDimensionRef, 2551 visible, 2552 width 2553 } = parameters; 2554 const isBeforeMatchRef = React19.useRef(false); 2555 const latestAnimationNameRef = React19.useRef(null); 2556 const shouldCancelInitialOpenAnimationRef = React19.useRef(open); 2557 const shouldCancelInitialOpenTransitionRef = React19.useRef(open); 2558 const endingStyleFrame = useAnimationFrame(); 2559 const hidden = React19.useMemo(() => { 2560 if (animationTypeRef.current === "css-animation") { 2561 return !visible; 2562 } 2563 return !open && !mounted; 2564 }, [open, mounted, visible, animationTypeRef]); 2565 const handlePanelRef = useStableCallback((element) => { 2566 if (!element) { 2567 return void 0; 2568 } 2569 if (animationTypeRef.current == null || transitionDimensionRef.current == null) { 2570 const panelStyles = getComputedStyle(element); 2571 const hasAnimation = panelStyles.animationName !== "none" && panelStyles.animationName !== ""; 2572 const hasTransition = panelStyles.transitionDuration !== "0s" && panelStyles.transitionDuration !== ""; 2573 if (hasAnimation && hasTransition) { 2574 if (true) { 2575 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used."); 2576 } 2577 } else if (panelStyles.animationName === "none" && panelStyles.transitionDuration !== "0s") { 2578 animationTypeRef.current = "css-transition"; 2579 } else if (panelStyles.animationName !== "none" && panelStyles.transitionDuration === "0s") { 2580 animationTypeRef.current = "css-animation"; 2581 } else { 2582 animationTypeRef.current = "none"; 2583 } 2584 if (element.getAttribute(AccordionRootDataAttributes.orientation) === "horizontal" || panelStyles.transitionProperty.indexOf("width") > -1) { 2585 transitionDimensionRef.current = "width"; 2586 } else { 2587 transitionDimensionRef.current = "height"; 2588 } 2589 } 2590 if (animationTypeRef.current !== "css-transition") { 2591 return void 0; 2592 } 2593 if (height === void 0 || width === void 0) { 2594 setDimensions({ 2595 height: element.scrollHeight, 2596 width: element.scrollWidth 2597 }); 2598 if (shouldCancelInitialOpenTransitionRef.current) { 2599 element.style.setProperty("transition-duration", "0s"); 2600 } 2601 } 2602 let frame = -1; 2603 let nextFrame = -1; 2604 frame = AnimationFrame.request(() => { 2605 shouldCancelInitialOpenTransitionRef.current = false; 2606 nextFrame = AnimationFrame.request(() => { 2607 setTimeout(() => { 2608 element.style.removeProperty("transition-duration"); 2609 }); 2610 }); 2611 }); 2612 return () => { 2613 AnimationFrame.cancel(frame); 2614 AnimationFrame.cancel(nextFrame); 2615 }; 2616 }); 2617 const mergedPanelRef = useMergedRefs(externalRef, panelRef, handlePanelRef); 2618 useIsoLayoutEffect(() => { 2619 if (animationTypeRef.current !== "css-transition") { 2620 return void 0; 2621 } 2622 const panel = panelRef.current; 2623 if (!panel) { 2624 return void 0; 2625 } 2626 let resizeFrame = -1; 2627 if (abortControllerRef.current != null) { 2628 abortControllerRef.current.abort(); 2629 abortControllerRef.current = null; 2630 } 2631 if (open) { 2632 const originalLayoutStyles = { 2633 "justify-content": panel.style.justifyContent, 2634 "align-items": panel.style.alignItems, 2635 "align-content": panel.style.alignContent, 2636 "justify-items": panel.style.justifyItems 2637 }; 2638 Object.keys(originalLayoutStyles).forEach((key) => { 2639 panel.style.setProperty(key, "initial", "important"); 2640 }); 2641 if (!shouldCancelInitialOpenTransitionRef.current && !keepMounted) { 2642 panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, ""); 2643 } 2644 setDimensions({ 2645 height: panel.scrollHeight, 2646 width: panel.scrollWidth 2647 }); 2648 resizeFrame = AnimationFrame.request(() => { 2649 Object.entries(originalLayoutStyles).forEach(([key, value]) => { 2650 if (value === "") { 2651 panel.style.removeProperty(key); 2652 } else { 2653 panel.style.setProperty(key, value); 2654 } 2655 }); 2656 }); 2657 } else { 2658 if (panel.scrollHeight === 0 && panel.scrollWidth === 0) { 2659 return void 0; 2660 } 2661 setDimensions({ 2662 height: panel.scrollHeight, 2663 width: panel.scrollWidth 2664 }); 2665 const abortController = new AbortController(); 2666 abortControllerRef.current = abortController; 2667 const signal = abortController.signal; 2668 let attributeObserver = null; 2669 const endingStyleAttribute = CollapsiblePanelDataAttributes.endingStyle; 2670 attributeObserver = new MutationObserver((mutationList) => { 2671 const hasEndingStyle = mutationList.some((mutation) => mutation.type === "attributes" && mutation.attributeName === endingStyleAttribute); 2672 if (hasEndingStyle) { 2673 attributeObserver?.disconnect(); 2674 attributeObserver = null; 2675 runOnceAnimationsFinish(() => { 2676 setDimensions({ 2677 height: 0, 2678 width: 0 2679 }); 2680 panel.style.removeProperty("content-visibility"); 2681 setMounted(false); 2682 if (abortControllerRef.current === abortController) { 2683 abortControllerRef.current = null; 2684 } 2685 }, signal); 2686 } 2687 }); 2688 attributeObserver.observe(panel, { 2689 attributes: true, 2690 attributeFilter: [endingStyleAttribute] 2691 }); 2692 return () => { 2693 attributeObserver?.disconnect(); 2694 endingStyleFrame.cancel(); 2695 if (abortControllerRef.current === abortController) { 2696 abortController.abort(); 2697 abortControllerRef.current = null; 2698 } 2699 }; 2700 } 2701 return () => { 2702 AnimationFrame.cancel(resizeFrame); 2703 }; 2704 }, [abortControllerRef, animationTypeRef, endingStyleFrame, hiddenUntilFound, keepMounted, mounted, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted]); 2705 useIsoLayoutEffect(() => { 2706 if (animationTypeRef.current !== "css-animation") { 2707 return; 2708 } 2709 const panel = panelRef.current; 2710 if (!panel) { 2711 return; 2712 } 2713 latestAnimationNameRef.current = panel.style.animationName || latestAnimationNameRef.current; 2714 panel.style.setProperty("animation-name", "none"); 2715 setDimensions({ 2716 height: panel.scrollHeight, 2717 width: panel.scrollWidth 2718 }); 2719 if (!shouldCancelInitialOpenAnimationRef.current && !isBeforeMatchRef.current) { 2720 panel.style.removeProperty("animation-name"); 2721 } 2722 if (open) { 2723 if (abortControllerRef.current != null) { 2724 abortControllerRef.current.abort(); 2725 abortControllerRef.current = null; 2726 } 2727 setMounted(true); 2728 setVisible(true); 2729 } else { 2730 abortControllerRef.current = new AbortController(); 2731 runOnceAnimationsFinish(() => { 2732 setMounted(false); 2733 setVisible(false); 2734 abortControllerRef.current = null; 2735 }, abortControllerRef.current.signal); 2736 } 2737 }, [abortControllerRef, animationTypeRef, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted, setVisible, visible]); 2738 useOnMount(() => { 2739 const frame = AnimationFrame.request(() => { 2740 shouldCancelInitialOpenAnimationRef.current = false; 2741 }); 2742 return () => AnimationFrame.cancel(frame); 2743 }); 2744 useIsoLayoutEffect(() => { 2745 if (!hiddenUntilFound) { 2746 return void 0; 2747 } 2748 const panel = panelRef.current; 2749 if (!panel) { 2750 return void 0; 2751 } 2752 let frame = -1; 2753 let nextFrame = -1; 2754 if (open && isBeforeMatchRef.current) { 2755 panel.style.transitionDuration = "0s"; 2756 setDimensions({ 2757 height: panel.scrollHeight, 2758 width: panel.scrollWidth 2759 }); 2760 frame = AnimationFrame.request(() => { 2761 isBeforeMatchRef.current = false; 2762 nextFrame = AnimationFrame.request(() => { 2763 setTimeout(() => { 2764 panel.style.removeProperty("transition-duration"); 2765 }); 2766 }); 2767 }); 2768 } 2769 return () => { 2770 AnimationFrame.cancel(frame); 2771 AnimationFrame.cancel(nextFrame); 2772 }; 2773 }, [hiddenUntilFound, open, panelRef, setDimensions]); 2774 useIsoLayoutEffect(() => { 2775 const panel = panelRef.current; 2776 if (panel && hiddenUntilFound && hidden) { 2777 panel.setAttribute("hidden", "until-found"); 2778 if (animationTypeRef.current === "css-transition") { 2779 panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, ""); 2780 } 2781 } 2782 }, [hiddenUntilFound, hidden, animationTypeRef, panelRef]); 2783 React19.useEffect(function registerBeforeMatchListener() { 2784 const panel = panelRef.current; 2785 if (!panel) { 2786 return void 0; 2787 } 2788 function handleBeforeMatch(event) { 2789 isBeforeMatchRef.current = true; 2790 setOpen(true); 2791 onOpenChange(true, createChangeEventDetails(reason_parts_exports.none, event)); 2792 } 2793 return addEventListener(panel, "beforematch", handleBeforeMatch); 2794 }, [onOpenChange, panelRef, setOpen]); 2795 return React19.useMemo(() => ({ 2796 props: { 2797 hidden, 2798 id: idParam, 2799 ref: mergedPanelRef 2800 } 2801 }), [hidden, idParam, mergedPanelRef]); 2802 } 2803 2804 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js 2805 var React20 = __toESM(require_react(), 1); 2806 function useOpenChangeComplete(parameters) { 2807 const { 2808 enabled = true, 2809 open, 2810 ref, 2811 onComplete: onCompleteParam 2812 } = parameters; 2813 const onComplete = useStableCallback(onCompleteParam); 2814 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false); 2815 React20.useEffect(() => { 2816 if (!enabled) { 2817 return void 0; 2818 } 2819 const abortController = new AbortController(); 2820 runOnceAnimationsFinish(onComplete, abortController.signal); 2821 return () => { 2822 abortController.abort(); 2823 }; 2824 }, [enabled, open, onComplete, runOnceAnimationsFinish]); 2825 } 2826 2827 // node_modules/@base-ui/utils/esm/useOnFirstRender.js 2828 var React21 = __toESM(require_react(), 1); 2829 function useOnFirstRender(fn) { 2830 const ref = React21.useRef(true); 2831 if (ref.current) { 2832 ref.current = false; 2833 fn(); 2834 } 2835 } 2836 2837 // node_modules/@base-ui/utils/esm/useTimeout.js 2838 var EMPTY3 = 0; 2839 var Timeout = class _Timeout { 2840 static create() { 2841 return new _Timeout(); 2842 } 2843 currentId = EMPTY3; 2844 /** 2845 * Executes `fn` after `delay`, clearing any previously scheduled call. 2846 */ 2847 start(delay, fn) { 2848 this.clear(); 2849 this.currentId = setTimeout(() => { 2850 this.currentId = EMPTY3; 2851 fn(); 2852 }, delay); 2853 } 2854 isStarted() { 2855 return this.currentId !== EMPTY3; 2856 } 2857 clear = () => { 2858 if (this.currentId !== EMPTY3) { 2859 clearTimeout(this.currentId); 2860 this.currentId = EMPTY3; 2861 } 2862 }; 2863 disposeEffect = () => { 2864 return this.clear; 2865 }; 2866 }; 2867 function useTimeout() { 2868 const timeout = useRefWithInit(Timeout.create).current; 2869 useOnMount(timeout.disposeEffect); 2870 return timeout; 2871 } 2872 2873 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js 2874 var React22 = __toESM(require_react(), 1); 2875 2876 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js 2877 function resolveValue(value, pointerType) { 2878 if (pointerType != null && !isMouseLikePointerType(pointerType)) { 2879 return 0; 2880 } 2881 if (typeof value === "function") { 2882 return value(); 2883 } 2884 return value; 2885 } 2886 function getDelay(value, prop, pointerType) { 2887 const result = resolveValue(value, pointerType); 2888 if (typeof result === "number") { 2889 return result; 2890 } 2891 return result?.[prop]; 2892 } 2893 function getRestMs(value) { 2894 if (typeof value === "function") { 2895 return value(); 2896 } 2897 return value; 2898 } 2899 function isClickLikeOpenEvent(openEventType, interactedInside) { 2900 return interactedInside || openEventType === "click" || openEventType === "mousedown"; 2901 } 2902 2903 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js 2904 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 2905 var FloatingDelayGroupContext = /* @__PURE__ */ React22.createContext({ 2906 hasProvider: false, 2907 timeoutMs: 0, 2908 delayRef: { 2909 current: 0 2910 }, 2911 initialDelayRef: { 2912 current: 0 2913 }, 2914 timeout: new Timeout(), 2915 currentIdRef: { 2916 current: null 2917 }, 2918 currentContextRef: { 2919 current: null 2920 } 2921 }); 2922 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext"; 2923 function FloatingDelayGroup(props) { 2924 const { 2925 children, 2926 delay, 2927 timeoutMs = 0 2928 } = props; 2929 const delayRef = React22.useRef(delay); 2930 const initialDelayRef = React22.useRef(delay); 2931 const currentIdRef = React22.useRef(null); 2932 const currentContextRef = React22.useRef(null); 2933 const timeout = useTimeout(); 2934 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, { 2935 value: React22.useMemo(() => ({ 2936 hasProvider: true, 2937 delayRef, 2938 initialDelayRef, 2939 currentIdRef, 2940 timeoutMs, 2941 currentContextRef, 2942 timeout 2943 }), [timeoutMs, timeout]), 2944 children 2945 }); 2946 } 2947 function useDelayGroup(context, options = { 2948 open: false 2949 }) { 2950 const store3 = "rootStore" in context ? context.rootStore : context; 2951 const floatingId = store3.useState("floatingId"); 2952 const { 2953 open 2954 } = options; 2955 const groupContext = React22.useContext(FloatingDelayGroupContext); 2956 const { 2957 currentIdRef, 2958 delayRef, 2959 timeoutMs, 2960 initialDelayRef, 2961 currentContextRef, 2962 hasProvider, 2963 timeout 2964 } = groupContext; 2965 const [isInstantPhase, setIsInstantPhase] = React22.useState(false); 2966 useIsoLayoutEffect(() => { 2967 function unset() { 2968 setIsInstantPhase(false); 2969 currentContextRef.current?.setIsInstantPhase(false); 2970 currentIdRef.current = null; 2971 currentContextRef.current = null; 2972 delayRef.current = initialDelayRef.current; 2973 } 2974 if (!currentIdRef.current) { 2975 return void 0; 2976 } 2977 if (!open && currentIdRef.current === floatingId) { 2978 setIsInstantPhase(false); 2979 if (timeoutMs) { 2980 const closingId = floatingId; 2981 timeout.start(timeoutMs, () => { 2982 if (store3.select("open") || currentIdRef.current && currentIdRef.current !== closingId) { 2983 return; 2984 } 2985 unset(); 2986 }); 2987 return () => { 2988 timeout.clear(); 2989 }; 2990 } 2991 unset(); 2992 } 2993 return void 0; 2994 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store3]); 2995 useIsoLayoutEffect(() => { 2996 if (!open) { 2997 return; 2998 } 2999 const prevContext = currentContextRef.current; 3000 const prevId = currentIdRef.current; 3001 timeout.clear(); 3002 currentContextRef.current = { 3003 onOpenChange: store3.setOpen, 3004 setIsInstantPhase 3005 }; 3006 currentIdRef.current = floatingId; 3007 delayRef.current = { 3008 open: 0, 3009 close: getDelay(initialDelayRef.current, "close") 3010 }; 3011 if (prevId !== null && prevId !== floatingId) { 3012 setIsInstantPhase(true); 3013 prevContext?.setIsInstantPhase(true); 3014 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none)); 3015 } else { 3016 setIsInstantPhase(false); 3017 prevContext?.setIsInstantPhase(false); 3018 } 3019 }, [open, floatingId, store3, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]); 3020 useIsoLayoutEffect(() => { 3021 return () => { 3022 currentContextRef.current = null; 3023 }; 3024 }, [currentContextRef]); 3025 return React22.useMemo(() => ({ 3026 hasProvider, 3027 delayRef, 3028 isInstantPhase 3029 }), [hasProvider, delayRef, isInstantPhase]); 3030 } 3031 3032 // node_modules/@base-ui/utils/esm/mergeCleanups.js 3033 function mergeCleanups(...cleanups) { 3034 return () => { 3035 for (let i2 = 0; i2 < cleanups.length; i2 += 1) { 3036 const cleanup = cleanups[i2]; 3037 if (cleanup) { 3038 cleanup(); 3039 } 3040 } 3041 }; 3042 } 3043 3044 // node_modules/@base-ui/utils/esm/useValueAsRef.js 3045 function useValueAsRef(value) { 3046 const latest = useRefWithInit(createLatestRef, value).current; 3047 latest.next = value; 3048 useIsoLayoutEffect(latest.effect); 3049 return latest; 3050 } 3051 function createLatestRef(value) { 3052 const latest = { 3053 current: value, 3054 next: value, 3055 effect: () => { 3056 latest.current = latest.next; 3057 } 3058 }; 3059 return latest; 3060 } 3061 3062 // node_modules/@base-ui/react/esm/utils/FocusGuard.js 3063 var React23 = __toESM(require_react(), 1); 3064 3065 // node_modules/@base-ui/utils/esm/visuallyHidden.js 3066 var visuallyHiddenBase = { 3067 clipPath: "inset(50%)", 3068 overflow: "hidden", 3069 whiteSpace: "nowrap", 3070 border: 0, 3071 padding: 0, 3072 width: 1, 3073 height: 1, 3074 margin: -1 3075 }; 3076 var visuallyHidden = { 3077 ...visuallyHiddenBase, 3078 position: "fixed", 3079 top: 0, 3080 left: 0 3081 }; 3082 var visuallyHiddenInput = { 3083 ...visuallyHiddenBase, 3084 position: "absolute" 3085 }; 3086 3087 // node_modules/@base-ui/react/esm/utils/FocusGuard.js 3088 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 3089 var FocusGuard = /* @__PURE__ */ React23.forwardRef(function FocusGuard2(props, ref) { 3090 const [role, setRole] = React23.useState(); 3091 useIsoLayoutEffect(() => { 3092 if (isSafari) { 3093 setRole("button"); 3094 } 3095 }, []); 3096 const restProps = { 3097 tabIndex: 0, 3098 // Role is only for VoiceOver 3099 role 3100 }; 3101 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { 3102 ...props, 3103 ref, 3104 style: visuallyHidden, 3105 "aria-hidden": role ? void 0 : true, 3106 ...restProps, 3107 "data-base-ui-focus-guard": "" 3108 }); 3109 }); 3110 if (true) FocusGuard.displayName = "FocusGuard"; 3111 3112 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js 3113 function createAttribute(name) { 3114 return `data-base-ui-$name}`; 3115 } 3116 3117 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js 3118 var React24 = __toESM(require_react(), 1); 3119 var ReactDOM2 = __toESM(require_react_dom(), 1); 3120 3121 // node_modules/@base-ui/react/esm/internals/constants.js 3122 var DISABLED_TRANSITIONS_STYLE = { 3123 style: { 3124 transition: "none" 3125 } 3126 }; 3127 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore"; 3128 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore"; 3129 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[$BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`; 3130 var LEGACY_SWIPE_IGNORE_SELECTOR = `[$LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`; 3131 var POPUP_COLLISION_AVOIDANCE = { 3132 fallbackAxisSide: "end" 3133 }; 3134 var ownerVisuallyHidden = { 3135 clipPath: "inset(50%)", 3136 position: "fixed", 3137 top: 0, 3138 left: 0 3139 }; 3140 3141 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js 3142 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 3143 var PortalContext = /* @__PURE__ */ React24.createContext(null); 3144 if (true) PortalContext.displayName = "PortalContext"; 3145 var usePortalContext = () => React24.useContext(PortalContext); 3146 var attr = createAttribute("portal"); 3147 function useFloatingPortalNode(props = {}) { 3148 const { 3149 ref, 3150 container: containerProp, 3151 componentProps = EMPTY_OBJECT, 3152 elementProps 3153 } = props; 3154 const uniqueId = useId(); 3155 const portalContext = usePortalContext(); 3156 const parentPortalNode = portalContext?.portalNode; 3157 const [containerElement, setContainerElement] = React24.useState(null); 3158 const [portalNode, setPortalNode] = React24.useState(null); 3159 const setPortalNodeRef = useStableCallback((node) => { 3160 if (node !== null) { 3161 setPortalNode(node); 3162 } 3163 }); 3164 const containerRef = React24.useRef(null); 3165 useIsoLayoutEffect(() => { 3166 if (containerProp === null) { 3167 if (containerRef.current) { 3168 containerRef.current = null; 3169 setPortalNode(null); 3170 setContainerElement(null); 3171 } 3172 return; 3173 } 3174 if (uniqueId == null) { 3175 return; 3176 } 3177 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body; 3178 if (resolvedContainer == null) { 3179 if (containerRef.current) { 3180 containerRef.current = null; 3181 setPortalNode(null); 3182 setContainerElement(null); 3183 } 3184 return; 3185 } 3186 if (containerRef.current !== resolvedContainer) { 3187 containerRef.current = resolvedContainer; 3188 setPortalNode(null); 3189 setContainerElement(resolvedContainer); 3190 } 3191 }, [containerProp, parentPortalNode, uniqueId]); 3192 const portalElement = useRenderElement("div", componentProps, { 3193 ref: [ref, setPortalNodeRef], 3194 props: [{ 3195 id: uniqueId, 3196 [attr]: "" 3197 }, elementProps] 3198 }); 3199 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null; 3200 return { 3201 portalNode, 3202 portalSubtree 3203 }; 3204 } 3205 var FloatingPortal = /* @__PURE__ */ React24.forwardRef(function FloatingPortal2(componentProps, forwardedRef) { 3206 const { 3207 children, 3208 container, 3209 className, 3210 render: render4, 3211 renderGuards, 3212 style, 3213 ...elementProps 3214 } = componentProps; 3215 const { 3216 portalNode, 3217 portalSubtree 3218 } = useFloatingPortalNode({ 3219 container, 3220 ref: forwardedRef, 3221 componentProps, 3222 elementProps 3223 }); 3224 const beforeOutsideRef = React24.useRef(null); 3225 const afterOutsideRef = React24.useRef(null); 3226 const beforeInsideRef = React24.useRef(null); 3227 const afterInsideRef = React24.useRef(null); 3228 const [focusManagerState, setFocusManagerState] = React24.useState(null); 3229 const focusInsideDisabledRef = React24.useRef(false); 3230 const modal = focusManagerState?.modal; 3231 const open = focusManagerState?.open; 3232 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode; 3233 React24.useEffect(() => { 3234 if (!portalNode || modal) { 3235 return void 0; 3236 } 3237 function onFocus(event) { 3238 if (portalNode && event.relatedTarget && isOutsideEvent(event)) { 3239 if (event.type === "focusin") { 3240 if (focusInsideDisabledRef.current) { 3241 enableFocusInside(portalNode); 3242 focusInsideDisabledRef.current = false; 3243 } 3244 } else { 3245 disableFocusInside(portalNode); 3246 focusInsideDisabledRef.current = true; 3247 } 3248 } 3249 } 3250 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true)); 3251 }, [portalNode, modal]); 3252 React24.useEffect(() => { 3253 if (!portalNode || open !== false) { 3254 return; 3255 } 3256 enableFocusInside(portalNode); 3257 focusInsideDisabledRef.current = false; 3258 }, [open, portalNode]); 3259 const portalContextValue = React24.useMemo(() => ({ 3260 beforeOutsideRef, 3261 afterOutsideRef, 3262 beforeInsideRef, 3263 afterInsideRef, 3264 portalNode, 3265 setFocusManagerState 3266 }), [portalNode]); 3267 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React24.Fragment, { 3268 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, { 3269 value: portalContextValue, 3270 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { 3271 "data-type": "outside", 3272 ref: beforeOutsideRef, 3273 onFocus: (event) => { 3274 if (isOutsideEvent(event, portalNode)) { 3275 beforeInsideRef.current?.focus(); 3276 } else { 3277 const domReference = focusManagerState ? focusManagerState.domReference : null; 3278 const prevTabbable = getPreviousTabbable(domReference); 3279 prevTabbable?.focus(); 3280 } 3281 } 3282 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { 3283 "aria-owns": portalNode.id, 3284 style: ownerVisuallyHidden 3285 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { 3286 "data-type": "outside", 3287 ref: afterOutsideRef, 3288 onFocus: (event) => { 3289 if (isOutsideEvent(event, portalNode)) { 3290 afterInsideRef.current?.focus(); 3291 } else { 3292 const domReference = focusManagerState ? focusManagerState.domReference : null; 3293 const nextTabbable = getNextTabbable(domReference); 3294 nextTabbable?.focus(); 3295 if (focusManagerState?.closeOnFocusOut) { 3296 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent)); 3297 } 3298 } 3299 } 3300 })] 3301 })] 3302 }); 3303 }); 3304 if (true) FloatingPortal.displayName = "FloatingPortal"; 3305 3306 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js 3307 var React25 = __toESM(require_react(), 1); 3308 3309 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js 3310 function createEventEmitter() { 3311 const map = /* @__PURE__ */ new Map(); 3312 return { 3313 emit(event, data) { 3314 map.get(event)?.forEach((listener) => listener(data)); 3315 }, 3316 on(event, listener) { 3317 if (!map.has(event)) { 3318 map.set(event, /* @__PURE__ */ new Set()); 3319 } 3320 map.get(event).add(listener); 3321 }, 3322 off(event, listener) { 3323 map.get(event)?.delete(listener); 3324 } 3325 }; 3326 } 3327 3328 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js 3329 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); 3330 var FloatingNodeContext = /* @__PURE__ */ React25.createContext(null); 3331 if (true) FloatingNodeContext.displayName = "FloatingNodeContext"; 3332 var FloatingTreeContext = /* @__PURE__ */ React25.createContext(null); 3333 if (true) FloatingTreeContext.displayName = "FloatingTreeContext"; 3334 var useFloatingParentNodeId = () => React25.useContext(FloatingNodeContext)?.id || null; 3335 var useFloatingTree = (externalTree) => { 3336 const contextTree = React25.useContext(FloatingTreeContext); 3337 return externalTree ?? contextTree; 3338 }; 3339 3340 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js 3341 var React26 = __toESM(require_react(), 1); 3342 function createVirtualElement(domElement, data) { 3343 let offsetX = null; 3344 let offsetY = null; 3345 let isAutoUpdateEvent = false; 3346 return { 3347 contextElement: domElement || void 0, 3348 getBoundingClientRect() { 3349 const domRect = domElement?.getBoundingClientRect() || { 3350 width: 0, 3351 height: 0, 3352 x: 0, 3353 y: 0 3354 }; 3355 const isXAxis = data.axis === "x" || data.axis === "both"; 3356 const isYAxis = data.axis === "y" || data.axis === "both"; 3357 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch"; 3358 let width = domRect.width; 3359 let height = domRect.height; 3360 let x2 = domRect.x; 3361 let y2 = domRect.y; 3362 if (offsetX == null && data.x && isXAxis) { 3363 offsetX = domRect.x - data.x; 3364 } 3365 if (offsetY == null && data.y && isYAxis) { 3366 offsetY = domRect.y - data.y; 3367 } 3368 x2 -= offsetX || 0; 3369 y2 -= offsetY || 0; 3370 width = 0; 3371 height = 0; 3372 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) { 3373 width = data.axis === "y" ? domRect.width : 0; 3374 height = data.axis === "x" ? domRect.height : 0; 3375 x2 = isXAxis && data.x != null ? data.x : x2; 3376 y2 = isYAxis && data.y != null ? data.y : y2; 3377 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) { 3378 height = data.axis === "x" ? domRect.height : height; 3379 width = data.axis === "y" ? domRect.width : width; 3380 } 3381 isAutoUpdateEvent = true; 3382 return { 3383 width, 3384 height, 3385 x: x2, 3386 y: y2, 3387 top: y2, 3388 right: x2 + width, 3389 bottom: y2 + height, 3390 left: x2 3391 }; 3392 } 3393 }; 3394 } 3395 function isMouseBasedEvent(event) { 3396 return event != null && event.clientX != null; 3397 } 3398 function useClientPoint(context, props = {}) { 3399 const store3 = "rootStore" in context ? context.rootStore : context; 3400 const open = store3.useState("open"); 3401 const floating = store3.useState("floatingElement"); 3402 const domReference = store3.useState("domReferenceElement"); 3403 const dataRef = store3.context.dataRef; 3404 const { 3405 enabled = true, 3406 axis = "both" 3407 } = props; 3408 const initialRef = React26.useRef(false); 3409 const cleanupListenerRef = React26.useRef(null); 3410 const [pointerType, setPointerType] = React26.useState(); 3411 const [reactive, setReactive] = React26.useState([]); 3412 const setReference = useStableCallback((newX, newY, referenceElement) => { 3413 if (initialRef.current) { 3414 return; 3415 } 3416 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) { 3417 return; 3418 } 3419 store3.set("positionReference", createVirtualElement(referenceElement ?? domReference, { 3420 x: newX, 3421 y: newY, 3422 axis, 3423 dataRef, 3424 pointerType 3425 })); 3426 }); 3427 const handleReferenceEnterOrMove = useStableCallback((event) => { 3428 if (!open) { 3429 setReference(event.clientX, event.clientY, event.currentTarget); 3430 } else if (!cleanupListenerRef.current) { 3431 setReactive([]); 3432 } 3433 }); 3434 const openCheck = isMouseLikePointerType(pointerType) ? floating : open; 3435 const addListener = React26.useCallback(() => { 3436 if (!openCheck || !enabled) { 3437 return void 0; 3438 } 3439 const win = getWindow(floating); 3440 function handleMouseMove(event) { 3441 const target = getTarget(event); 3442 if (!contains(floating, target)) { 3443 setReference(event.clientX, event.clientY); 3444 } else { 3445 cleanupListenerRef.current?.(); 3446 cleanupListenerRef.current = null; 3447 } 3448 } 3449 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) { 3450 const cleanup = () => { 3451 cleanupListenerRef.current?.(); 3452 cleanupListenerRef.current = null; 3453 }; 3454 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove); 3455 return cleanup; 3456 } 3457 store3.set("positionReference", domReference); 3458 return void 0; 3459 }, [openCheck, enabled, floating, dataRef, domReference, store3, setReference]); 3460 React26.useEffect(() => { 3461 return addListener(); 3462 }, [addListener, reactive]); 3463 React26.useEffect(() => { 3464 if (enabled && !floating) { 3465 initialRef.current = false; 3466 } 3467 }, [enabled, floating]); 3468 React26.useEffect(() => { 3469 if (!enabled && open) { 3470 initialRef.current = true; 3471 } 3472 }, [enabled, open]); 3473 const reference = React26.useMemo(() => { 3474 function setPointerTypeRef(event) { 3475 setPointerType(event.pointerType); 3476 } 3477 return { 3478 onPointerDown: setPointerTypeRef, 3479 onPointerEnter: setPointerTypeRef, 3480 onMouseMove: handleReferenceEnterOrMove, 3481 onMouseEnter: handleReferenceEnterOrMove 3482 }; 3483 }, [handleReferenceEnterOrMove]); 3484 return React26.useMemo(() => enabled ? { 3485 reference, 3486 trigger: reference 3487 } : {}, [enabled, reference]); 3488 } 3489 3490 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js 3491 var React27 = __toESM(require_react(), 1); 3492 var bubbleHandlerKeys = { 3493 intentional: "onClick", 3494 sloppy: "onPointerDown" 3495 }; 3496 function alwaysFalse() { 3497 return false; 3498 } 3499 function normalizeProp(normalizable) { 3500 return { 3501 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false, 3502 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true 3503 }; 3504 } 3505 function useDismiss(context, props = {}) { 3506 const store3 = "rootStore" in context ? context.rootStore : context; 3507 const open = store3.useState("open"); 3508 const floatingElement = store3.useState("floatingElement"); 3509 const { 3510 dataRef 3511 } = store3.context; 3512 const { 3513 enabled = true, 3514 escapeKey: escapeKey2 = true, 3515 outsidePress: outsidePressProp = true, 3516 outsidePressEvent = "sloppy", 3517 referencePress = alwaysFalse, 3518 referencePressEvent = "sloppy", 3519 bubbles, 3520 externalTree 3521 } = props; 3522 const tree = useFloatingTree(externalTree); 3523 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false); 3524 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp; 3525 const outsidePressEnabled = outsidePress2 !== false; 3526 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent); 3527 const pressStartedInsideRef = React27.useRef(false); 3528 const pressStartPreventedRef = React27.useRef(false); 3529 const suppressNextOutsideClickRef = React27.useRef(false); 3530 const { 3531 escapeKey: escapeKeyBubbles, 3532 outsidePress: outsidePressBubbles 3533 } = normalizeProp(bubbles); 3534 const touchStateRef = React27.useRef(null); 3535 const cancelDismissOnEndTimeout = useTimeout(); 3536 const clearInsideReactTreeTimeout = useTimeout(); 3537 const clearInsideReactTree = useStableCallback(() => { 3538 clearInsideReactTreeTimeout.clear(); 3539 dataRef.current.insideReactTree = false; 3540 }); 3541 const isComposingRef = React27.useRef(false); 3542 const currentPointerTypeRef = React27.useRef(""); 3543 const isReferencePressEnabled = useStableCallback(referencePress); 3544 const closeOnEscapeKeyDown = useStableCallback((event) => { 3545 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") { 3546 return; 3547 } 3548 if (isComposingRef.current) { 3549 return; 3550 } 3551 const nodeId = dataRef.current.floatingContext?.nodeId; 3552 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : []; 3553 if (!escapeKeyBubbles) { 3554 if (children.length > 0) { 3555 let shouldDismiss = true; 3556 children.forEach((child) => { 3557 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) { 3558 shouldDismiss = false; 3559 } 3560 }); 3561 if (!shouldDismiss) { 3562 return; 3563 } 3564 } 3565 } 3566 const native = isReactEvent(event) ? event.nativeEvent : event; 3567 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native); 3568 store3.setOpen(false, eventDetails); 3569 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) { 3570 event.stopPropagation(); 3571 } 3572 }); 3573 const markInsideReactTree = useStableCallback(() => { 3574 dataRef.current.insideReactTree = true; 3575 clearInsideReactTreeTimeout.start(0, clearInsideReactTree); 3576 }); 3577 React27.useEffect(() => { 3578 if (!open || !enabled) { 3579 return void 0; 3580 } 3581 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles; 3582 dataRef.current.__outsidePressBubbles = outsidePressBubbles; 3583 const compositionTimeout = new Timeout(); 3584 const preventedPressSuppressionTimeout = new Timeout(); 3585 function handleCompositionStart() { 3586 compositionTimeout.clear(); 3587 isComposingRef.current = true; 3588 } 3589 function handleCompositionEnd() { 3590 compositionTimeout.start( 3591 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work. 3592 // Only apply to WebKit for the test to remain 0ms. 3593 isWebKit() ? 5 : 0, 3594 () => { 3595 isComposingRef.current = false; 3596 } 3597 ); 3598 } 3599 function suppressImmediateOutsideClickAfterPreventedStart() { 3600 suppressNextOutsideClickRef.current = true; 3601 preventedPressSuppressionTimeout.start(0, () => { 3602 suppressNextOutsideClickRef.current = false; 3603 }); 3604 } 3605 function resetPressStartState() { 3606 pressStartedInsideRef.current = false; 3607 pressStartPreventedRef.current = false; 3608 } 3609 function getOutsidePressEvent() { 3610 const type = currentPointerTypeRef.current; 3611 const computedType = type === "pen" || !type ? "mouse" : type; 3612 const outsidePressEventValue = getOutsidePressEventProp(); 3613 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue; 3614 if (typeof resolved === "string") { 3615 return resolved; 3616 } 3617 return resolved[computedType]; 3618 } 3619 function shouldIgnoreEvent(event) { 3620 const computedOutsidePressEvent = getOutsidePressEvent(); 3621 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click"; 3622 } 3623 function isEventWithinFloatingTree(event) { 3624 const nodeId = dataRef.current.floatingContext?.nodeId; 3625 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating)); 3626 return isEventTargetWithin(event, store3.select("floatingElement")) || isEventTargetWithin(event, store3.select("domReferenceElement")) || targetIsInsideChildren; 3627 } 3628 function closeOnPressOutside(event) { 3629 if (shouldIgnoreEvent(event)) { 3630 clearInsideReactTree(); 3631 return; 3632 } 3633 if (dataRef.current.insideReactTree) { 3634 clearInsideReactTree(); 3635 return; 3636 } 3637 const target = getTarget(event); 3638 const inertSelector = `[$createAttribute("inert")}]`; 3639 const targetRoot = isElement(target) ? target.getRootNode() : null; 3640 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store3.select("floatingElement"))).querySelectorAll(inertSelector)); 3641 const triggers = store3.context.triggerElements; 3642 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) { 3643 return; 3644 } 3645 let targetRootAncestor = isElement(target) ? target : null; 3646 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) { 3647 const nextParent = getParentNode(targetRootAncestor); 3648 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) { 3649 break; 3650 } 3651 targetRootAncestor = nextParent; 3652 } 3653 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay). 3654 !contains(target, store3.select("floatingElement")) && // If the target root element contains none of the markers, then the 3655 // element was injected after the floating element rendered. 3656 markers.every((marker) => !contains(targetRootAncestor, marker))) { 3657 return; 3658 } 3659 if (isHTMLElement(target) && !("touches" in event)) { 3660 const lastTraversableNode = isLastTraversableNode(target); 3661 const style = getComputedStyle2(target); 3662 const scrollRe = /auto|scroll/; 3663 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX); 3664 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY); 3665 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth; 3666 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight; 3667 const isRTL2 = style.direction === "rtl"; 3668 const pressedVerticalScrollbar = canScrollY && (isRTL2 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth); 3669 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight; 3670 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) { 3671 return; 3672 } 3673 } 3674 if (isEventWithinFloatingTree(event)) { 3675 return; 3676 } 3677 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) { 3678 preventedPressSuppressionTimeout.clear(); 3679 suppressNextOutsideClickRef.current = false; 3680 return; 3681 } 3682 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 3683 return; 3684 } 3685 const nodeId = dataRef.current.floatingContext?.nodeId; 3686 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : []; 3687 if (children.length > 0) { 3688 let shouldDismiss = true; 3689 children.forEach((child) => { 3690 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) { 3691 shouldDismiss = false; 3692 } 3693 }); 3694 if (!shouldDismiss) { 3695 return; 3696 } 3697 } 3698 store3.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event)); 3699 clearInsideReactTree(); 3700 } 3701 function handlePointerDown(event) { 3702 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store3.select("open") || !enabled || isEventTargetWithin(event, store3.select("floatingElement")) || isEventTargetWithin(event, store3.select("domReferenceElement"))) { 3703 return; 3704 } 3705 closeOnPressOutside(event); 3706 } 3707 function handleTouchStart(event) { 3708 if (getOutsidePressEvent() !== "sloppy" || !store3.select("open") || !enabled || isEventTargetWithin(event, store3.select("floatingElement")) || isEventTargetWithin(event, store3.select("domReferenceElement"))) { 3709 return; 3710 } 3711 const touch = event.touches[0]; 3712 if (touch) { 3713 touchStateRef.current = { 3714 startTime: Date.now(), 3715 startX: touch.clientX, 3716 startY: touch.clientY, 3717 dismissOnTouchEnd: false, 3718 dismissOnMouseDown: true 3719 }; 3720 cancelDismissOnEndTimeout.start(1e3, () => { 3721 if (touchStateRef.current) { 3722 touchStateRef.current.dismissOnTouchEnd = false; 3723 touchStateRef.current.dismissOnMouseDown = false; 3724 } 3725 }); 3726 } 3727 } 3728 function addTargetEventListenerOnce(event, listener) { 3729 const target = getTarget(event); 3730 if (!target) { 3731 return; 3732 } 3733 const unsubscribe2 = addEventListener(target, event.type, () => { 3734 listener(event); 3735 unsubscribe2(); 3736 }); 3737 } 3738 function handleTouchStartCapture(event) { 3739 currentPointerTypeRef.current = "touch"; 3740 addTargetEventListenerOnce(event, handleTouchStart); 3741 } 3742 function closeOnPressOutsideCapture(event) { 3743 cancelDismissOnEndTimeout.clear(); 3744 if (event.type === "pointerdown") { 3745 currentPointerTypeRef.current = event.pointerType; 3746 } 3747 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) { 3748 return; 3749 } 3750 addTargetEventListenerOnce(event, (targetEvent) => { 3751 if (targetEvent.type === "pointerdown") { 3752 handlePointerDown(targetEvent); 3753 } else { 3754 closeOnPressOutside(targetEvent); 3755 } 3756 }); 3757 } 3758 function handlePressEndCapture(event) { 3759 if (!pressStartedInsideRef.current) { 3760 return; 3761 } 3762 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current; 3763 resetPressStartState(); 3764 if (getOutsidePressEvent() !== "intentional") { 3765 return; 3766 } 3767 if (event.type === "pointercancel") { 3768 if (pressStartedInsideDefaultPrevented) { 3769 suppressImmediateOutsideClickAfterPreventedStart(); 3770 } 3771 return; 3772 } 3773 if (isEventWithinFloatingTree(event)) { 3774 return; 3775 } 3776 if (pressStartedInsideDefaultPrevented) { 3777 suppressImmediateOutsideClickAfterPreventedStart(); 3778 return; 3779 } 3780 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 3781 return; 3782 } 3783 preventedPressSuppressionTimeout.clear(); 3784 suppressNextOutsideClickRef.current = true; 3785 clearInsideReactTree(); 3786 } 3787 function handleTouchMove(event) { 3788 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store3.select("floatingElement")) || isEventTargetWithin(event, store3.select("domReferenceElement"))) { 3789 return; 3790 } 3791 const touch = event.touches[0]; 3792 if (!touch) { 3793 return; 3794 } 3795 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX); 3796 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY); 3797 const distance2 = Math.sqrt(deltaX * deltaX + deltaY * deltaY); 3798 if (distance2 > 5) { 3799 touchStateRef.current.dismissOnTouchEnd = true; 3800 } 3801 if (distance2 > 10) { 3802 closeOnPressOutside(event); 3803 cancelDismissOnEndTimeout.clear(); 3804 touchStateRef.current = null; 3805 } 3806 } 3807 function handleTouchMoveCapture(event) { 3808 addTargetEventListenerOnce(event, handleTouchMove); 3809 } 3810 function handleTouchEnd(event) { 3811 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store3.select("floatingElement")) || isEventTargetWithin(event, store3.select("domReferenceElement"))) { 3812 return; 3813 } 3814 if (touchStateRef.current.dismissOnTouchEnd) { 3815 closeOnPressOutside(event); 3816 } 3817 cancelDismissOnEndTimeout.clear(); 3818 touchStateRef.current = null; 3819 } 3820 function handleTouchEndCapture(event) { 3821 addTargetEventListenerOnce(event, handleTouchEnd); 3822 } 3823 const doc = ownerDocument(floatingElement); 3824 const unsubscribe = mergeCleanups(escapeKey2 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, true), addEventListener(doc, "touchmove", handleTouchMoveCapture, true), addEventListener(doc, "touchend", handleTouchEndCapture, true))); 3825 return () => { 3826 unsubscribe(); 3827 compositionTimeout.clear(); 3828 preventedPressSuppressionTimeout.clear(); 3829 resetPressStartState(); 3830 suppressNextOutsideClickRef.current = false; 3831 }; 3832 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store3, cancelDismissOnEndTimeout]); 3833 React27.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]); 3834 const reference = React27.useMemo(() => ({ 3835 onKeyDown: closeOnEscapeKeyDown, 3836 [bubbleHandlerKeys[referencePressEvent]]: (event) => { 3837 if (!isReferencePressEnabled()) { 3838 return; 3839 } 3840 store3.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent)); 3841 }, 3842 ...referencePressEvent !== "intentional" && { 3843 onClick(event) { 3844 if (!isReferencePressEnabled()) { 3845 return; 3846 } 3847 store3.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent)); 3848 } 3849 } 3850 }), [closeOnEscapeKeyDown, store3, referencePressEvent, isReferencePressEnabled]); 3851 const markPressStartedInsideReactTree = useStableCallback((event) => { 3852 if (!open || !enabled || event.button !== 0) { 3853 return; 3854 } 3855 const target = getTarget(event.nativeEvent); 3856 if (!contains(store3.select("floatingElement"), target)) { 3857 return; 3858 } 3859 if (!pressStartedInsideRef.current) { 3860 pressStartedInsideRef.current = true; 3861 pressStartPreventedRef.current = false; 3862 } 3863 }); 3864 const markInsidePressStartPrevented = useStableCallback((event) => { 3865 if (!open || !enabled) { 3866 return; 3867 } 3868 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) { 3869 return; 3870 } 3871 if (pressStartedInsideRef.current) { 3872 pressStartPreventedRef.current = true; 3873 } 3874 }); 3875 const floating = React27.useMemo(() => ({ 3876 onKeyDown: closeOnEscapeKeyDown, 3877 // `onMouseDown` may be blocked if `event.preventDefault()` is called in 3878 // `onPointerDown`, such as with <NumberField.ScrubArea>. 3879 // See https://github.com/mui/base-ui/pull/3379 3880 onPointerDown: markInsidePressStartPrevented, 3881 onMouseDown: markInsidePressStartPrevented, 3882 onClickCapture: markInsideReactTree, 3883 onMouseDownCapture(event) { 3884 markInsideReactTree(); 3885 markPressStartedInsideReactTree(event); 3886 }, 3887 onPointerDownCapture(event) { 3888 markInsideReactTree(); 3889 markPressStartedInsideReactTree(event); 3890 }, 3891 onMouseUpCapture: markInsideReactTree, 3892 onTouchEndCapture: markInsideReactTree, 3893 onTouchMoveCapture: markInsideReactTree 3894 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]); 3895 return React27.useMemo(() => enabled ? { 3896 reference, 3897 floating, 3898 trigger: reference 3899 } : {}, [enabled, reference, floating]); 3900 } 3901 3902 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js 3903 var React33 = __toESM(require_react(), 1); 3904 3905 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs 3906 function computeCoordsFromPlacement(_ref, placement, rtl) { 3907 let { 3908 reference, 3909 floating 3910 } = _ref; 3911 const sideAxis = getSideAxis(placement); 3912 const alignmentAxis = getAlignmentAxis(placement); 3913 const alignLength = getAxisLength(alignmentAxis); 3914 const side = getSide(placement); 3915 const isVertical = sideAxis === "y"; 3916 const commonX = reference.x + reference.width / 2 - floating.width / 2; 3917 const commonY = reference.y + reference.height / 2 - floating.height / 2; 3918 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; 3919 let coords; 3920 switch (side) { 3921 case "top": 3922 coords = { 3923 x: commonX, 3924 y: reference.y - floating.height 3925 }; 3926 break; 3927 case "bottom": 3928 coords = { 3929 x: commonX, 3930 y: reference.y + reference.height 3931 }; 3932 break; 3933 case "right": 3934 coords = { 3935 x: reference.x + reference.width, 3936 y: commonY 3937 }; 3938 break; 3939 case "left": 3940 coords = { 3941 x: reference.x - floating.width, 3942 y: commonY 3943 }; 3944 break; 3945 default: 3946 coords = { 3947 x: reference.x, 3948 y: reference.y 3949 }; 3950 } 3951 switch (getAlignment(placement)) { 3952 case "start": 3953 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); 3954 break; 3955 case "end": 3956 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); 3957 break; 3958 } 3959 return coords; 3960 } 3961 async function detectOverflow(state, options) { 3962 var _await$platform$isEle; 3963 if (options === void 0) { 3964 options = {}; 3965 } 3966 const { 3967 x: x2, 3968 y: y2, 3969 platform: platform3, 3970 rects, 3971 elements, 3972 strategy 3973 } = state; 3974 const { 3975 boundary = "clippingAncestors", 3976 rootBoundary = "viewport", 3977 elementContext = "floating", 3978 altBoundary = false, 3979 padding = 0 3980 } = evaluate(options, state); 3981 const paddingObject = getPaddingObject(padding); 3982 const altContext = elementContext === "floating" ? "reference" : "floating"; 3983 const element = elements[altBoundary ? altContext : elementContext]; 3984 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({ 3985 element: ((_await$platform$isEle = await (platform3.isElement == null ? void 0 : platform3.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform3.getDocumentElement == null ? void 0 : platform3.getDocumentElement(elements.floating)), 3986 boundary, 3987 rootBoundary, 3988 strategy 3989 })); 3990 const rect = elementContext === "floating" ? { 3991 x: x2, 3992 y: y2, 3993 width: rects.floating.width, 3994 height: rects.floating.height 3995 } : rects.reference; 3996 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating)); 3997 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || { 3998 x: 1, 3999 y: 1 4000 } : { 4001 x: 1, 4002 y: 1 4003 }; 4004 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({ 4005 elements, 4006 rect, 4007 offsetParent, 4008 strategy 4009 }) : rect); 4010 return { 4011 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, 4012 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, 4013 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, 4014 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x 4015 }; 4016 } 4017 var MAX_RESET_COUNT = 50; 4018 var computePosition = async (reference, floating, config) => { 4019 const { 4020 placement = "bottom", 4021 strategy = "absolute", 4022 middleware = [], 4023 platform: platform3 4024 } = config; 4025 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : { 4026 ...platform3, 4027 detectOverflow 4028 }; 4029 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating)); 4030 let rects = await platform3.getElementRects({ 4031 reference, 4032 floating, 4033 strategy 4034 }); 4035 let { 4036 x: x2, 4037 y: y2 4038 } = computeCoordsFromPlacement(rects, placement, rtl); 4039 let statefulPlacement = placement; 4040 let resetCount = 0; 4041 const middlewareData = {}; 4042 for (let i2 = 0; i2 < middleware.length; i2++) { 4043 const currentMiddleware = middleware[i2]; 4044 if (!currentMiddleware) { 4045 continue; 4046 } 4047 const { 4048 name, 4049 fn 4050 } = currentMiddleware; 4051 const { 4052 x: nextX, 4053 y: nextY, 4054 data, 4055 reset 4056 } = await fn({ 4057 x: x2, 4058 y: y2, 4059 initialPlacement: placement, 4060 placement: statefulPlacement, 4061 strategy, 4062 middlewareData, 4063 rects, 4064 platform: platformWithDetectOverflow, 4065 elements: { 4066 reference, 4067 floating 4068 } 4069 }); 4070 x2 = nextX != null ? nextX : x2; 4071 y2 = nextY != null ? nextY : y2; 4072 middlewareData[name] = { 4073 ...middlewareData[name], 4074 ...data 4075 }; 4076 if (reset && resetCount < MAX_RESET_COUNT) { 4077 resetCount++; 4078 if (typeof reset === "object") { 4079 if (reset.placement) { 4080 statefulPlacement = reset.placement; 4081 } 4082 if (reset.rects) { 4083 rects = reset.rects === true ? await platform3.getElementRects({ 4084 reference, 4085 floating, 4086 strategy 4087 }) : reset.rects; 4088 } 4089 ({ 4090 x: x2, 4091 y: y2 4092 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); 4093 } 4094 i2 = -1; 4095 } 4096 } 4097 return { 4098 x: x2, 4099 y: y2, 4100 placement: statefulPlacement, 4101 strategy, 4102 middlewareData 4103 }; 4104 }; 4105 var flip = function(options) { 4106 if (options === void 0) { 4107 options = {}; 4108 } 4109 return { 4110 name: "flip", 4111 options, 4112 async fn(state) { 4113 var _middlewareData$arrow, _middlewareData$flip; 4114 const { 4115 placement, 4116 middlewareData, 4117 rects, 4118 initialPlacement, 4119 platform: platform3, 4120 elements 4121 } = state; 4122 const { 4123 mainAxis: checkMainAxis = true, 4124 crossAxis: checkCrossAxis = true, 4125 fallbackPlacements: specifiedFallbackPlacements, 4126 fallbackStrategy = "bestFit", 4127 fallbackAxisSideDirection = "none", 4128 flipAlignment = true, 4129 ...detectOverflowOptions 4130 } = evaluate(options, state); 4131 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 4132 return {}; 4133 } 4134 const side = getSide(placement); 4135 const initialSideAxis = getSideAxis(initialPlacement); 4136 const isBasePlacement = getSide(initialPlacement) === initialPlacement; 4137 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); 4138 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); 4139 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none"; 4140 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) { 4141 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); 4142 } 4143 const placements2 = [initialPlacement, ...fallbackPlacements]; 4144 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 4145 const overflows = []; 4146 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; 4147 if (checkMainAxis) { 4148 overflows.push(overflow[side]); 4149 } 4150 if (checkCrossAxis) { 4151 const sides2 = getAlignmentSides(placement, rects, rtl); 4152 overflows.push(overflow[sides2[0]], overflow[sides2[1]]); 4153 } 4154 overflowsData = [...overflowsData, { 4155 placement, 4156 overflows 4157 }]; 4158 if (!overflows.every((side2) => side2 <= 0)) { 4159 var _middlewareData$flip2, _overflowsData$filter; 4160 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; 4161 const nextPlacement = placements2[nextIndex]; 4162 if (nextPlacement) { 4163 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false; 4164 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis 4165 // overflows the main axis. 4166 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) { 4167 return { 4168 data: { 4169 index: nextIndex, 4170 overflows: overflowsData 4171 }, 4172 reset: { 4173 placement: nextPlacement 4174 } 4175 }; 4176 } 4177 } 4178 let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a2, b2) => a2.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; 4179 if (!resetPlacement) { 4180 switch (fallbackStrategy) { 4181 case "bestFit": { 4182 var _overflowsData$filter2; 4183 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => { 4184 if (hasFallbackAxisSideDirection) { 4185 const currentSideAxis = getSideAxis(d2.placement); 4186 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal 4187 // reading directions favoring greater width. 4188 currentSideAxis === "y"; 4189 } 4190 return true; 4191 }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0]; 4192 if (placement2) { 4193 resetPlacement = placement2; 4194 } 4195 break; 4196 } 4197 case "initialPlacement": 4198 resetPlacement = initialPlacement; 4199 break; 4200 } 4201 } 4202 if (placement !== resetPlacement) { 4203 return { 4204 reset: { 4205 placement: resetPlacement 4206 } 4207 }; 4208 } 4209 } 4210 return {}; 4211 } 4212 }; 4213 }; 4214 function getSideOffsets(overflow, rect) { 4215 return { 4216 top: overflow.top - rect.height, 4217 right: overflow.right - rect.width, 4218 bottom: overflow.bottom - rect.height, 4219 left: overflow.left - rect.width 4220 }; 4221 } 4222 function isAnySideFullyClipped(overflow) { 4223 return sides.some((side) => overflow[side] >= 0); 4224 } 4225 var hide = function(options) { 4226 if (options === void 0) { 4227 options = {}; 4228 } 4229 return { 4230 name: "hide", 4231 options, 4232 async fn(state) { 4233 const { 4234 rects, 4235 platform: platform3 4236 } = state; 4237 const { 4238 strategy = "referenceHidden", 4239 ...detectOverflowOptions 4240 } = evaluate(options, state); 4241 switch (strategy) { 4242 case "referenceHidden": { 4243 const overflow = await platform3.detectOverflow(state, { 4244 ...detectOverflowOptions, 4245 elementContext: "reference" 4246 }); 4247 const offsets = getSideOffsets(overflow, rects.reference); 4248 return { 4249 data: { 4250 referenceHiddenOffsets: offsets, 4251 referenceHidden: isAnySideFullyClipped(offsets) 4252 } 4253 }; 4254 } 4255 case "escaped": { 4256 const overflow = await platform3.detectOverflow(state, { 4257 ...detectOverflowOptions, 4258 altBoundary: true 4259 }); 4260 const offsets = getSideOffsets(overflow, rects.floating); 4261 return { 4262 data: { 4263 escapedOffsets: offsets, 4264 escaped: isAnySideFullyClipped(offsets) 4265 } 4266 }; 4267 } 4268 default: { 4269 return {}; 4270 } 4271 } 4272 } 4273 }; 4274 }; 4275 var originSides = /* @__PURE__ */ new Set(["left", "top"]); 4276 async function convertValueToCoords(state, options) { 4277 const { 4278 placement, 4279 platform: platform3, 4280 elements 4281 } = state; 4282 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); 4283 const side = getSide(placement); 4284 const alignment = getAlignment(placement); 4285 const isVertical = getSideAxis(placement) === "y"; 4286 const mainAxisMulti = originSides.has(side) ? -1 : 1; 4287 const crossAxisMulti = rtl && isVertical ? -1 : 1; 4288 const rawValue = evaluate(options, state); 4289 let { 4290 mainAxis, 4291 crossAxis, 4292 alignmentAxis 4293 } = typeof rawValue === "number" ? { 4294 mainAxis: rawValue, 4295 crossAxis: 0, 4296 alignmentAxis: null 4297 } : { 4298 mainAxis: rawValue.mainAxis || 0, 4299 crossAxis: rawValue.crossAxis || 0, 4300 alignmentAxis: rawValue.alignmentAxis 4301 }; 4302 if (alignment && typeof alignmentAxis === "number") { 4303 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; 4304 } 4305 return isVertical ? { 4306 x: crossAxis * crossAxisMulti, 4307 y: mainAxis * mainAxisMulti 4308 } : { 4309 x: mainAxis * mainAxisMulti, 4310 y: crossAxis * crossAxisMulti 4311 }; 4312 } 4313 var offset = function(options) { 4314 if (options === void 0) { 4315 options = 0; 4316 } 4317 return { 4318 name: "offset", 4319 options, 4320 async fn(state) { 4321 var _middlewareData$offse, _middlewareData$arrow; 4322 const { 4323 x: x2, 4324 y: y2, 4325 placement, 4326 middlewareData 4327 } = state; 4328 const diffCoords = await convertValueToCoords(state, options); 4329 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 4330 return {}; 4331 } 4332 return { 4333 x: x2 + diffCoords.x, 4334 y: y2 + diffCoords.y, 4335 data: { 4336 ...diffCoords, 4337 placement 4338 } 4339 }; 4340 } 4341 }; 4342 }; 4343 var shift = function(options) { 4344 if (options === void 0) { 4345 options = {}; 4346 } 4347 return { 4348 name: "shift", 4349 options, 4350 async fn(state) { 4351 const { 4352 x: x2, 4353 y: y2, 4354 placement, 4355 platform: platform3 4356 } = state; 4357 const { 4358 mainAxis: checkMainAxis = true, 4359 crossAxis: checkCrossAxis = false, 4360 limiter = { 4361 fn: (_ref) => { 4362 let { 4363 x: x3, 4364 y: y3 4365 } = _ref; 4366 return { 4367 x: x3, 4368 y: y3 4369 }; 4370 } 4371 }, 4372 ...detectOverflowOptions 4373 } = evaluate(options, state); 4374 const coords = { 4375 x: x2, 4376 y: y2 4377 }; 4378 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 4379 const crossAxis = getSideAxis(getSide(placement)); 4380 const mainAxis = getOppositeAxis(crossAxis); 4381 let mainAxisCoord = coords[mainAxis]; 4382 let crossAxisCoord = coords[crossAxis]; 4383 if (checkMainAxis) { 4384 const minSide = mainAxis === "y" ? "top" : "left"; 4385 const maxSide = mainAxis === "y" ? "bottom" : "right"; 4386 const min3 = mainAxisCoord + overflow[minSide]; 4387 const max3 = mainAxisCoord - overflow[maxSide]; 4388 mainAxisCoord = clamp(min3, mainAxisCoord, max3); 4389 } 4390 if (checkCrossAxis) { 4391 const minSide = crossAxis === "y" ? "top" : "left"; 4392 const maxSide = crossAxis === "y" ? "bottom" : "right"; 4393 const min3 = crossAxisCoord + overflow[minSide]; 4394 const max3 = crossAxisCoord - overflow[maxSide]; 4395 crossAxisCoord = clamp(min3, crossAxisCoord, max3); 4396 } 4397 const limitedCoords = limiter.fn({ 4398 ...state, 4399 [mainAxis]: mainAxisCoord, 4400 [crossAxis]: crossAxisCoord 4401 }); 4402 return { 4403 ...limitedCoords, 4404 data: { 4405 x: limitedCoords.x - x2, 4406 y: limitedCoords.y - y2, 4407 enabled: { 4408 [mainAxis]: checkMainAxis, 4409 [crossAxis]: checkCrossAxis 4410 } 4411 } 4412 }; 4413 } 4414 }; 4415 }; 4416 var limitShift = function(options) { 4417 if (options === void 0) { 4418 options = {}; 4419 } 4420 return { 4421 options, 4422 fn(state) { 4423 const { 4424 x: x2, 4425 y: y2, 4426 placement, 4427 rects, 4428 middlewareData 4429 } = state; 4430 const { 4431 offset: offset4 = 0, 4432 mainAxis: checkMainAxis = true, 4433 crossAxis: checkCrossAxis = true 4434 } = evaluate(options, state); 4435 const coords = { 4436 x: x2, 4437 y: y2 4438 }; 4439 const crossAxis = getSideAxis(placement); 4440 const mainAxis = getOppositeAxis(crossAxis); 4441 let mainAxisCoord = coords[mainAxis]; 4442 let crossAxisCoord = coords[crossAxis]; 4443 const rawOffset = evaluate(offset4, state); 4444 const computedOffset = typeof rawOffset === "number" ? { 4445 mainAxis: rawOffset, 4446 crossAxis: 0 4447 } : { 4448 mainAxis: 0, 4449 crossAxis: 0, 4450 ...rawOffset 4451 }; 4452 if (checkMainAxis) { 4453 const len2 = mainAxis === "y" ? "height" : "width"; 4454 const limitMin = rects.reference[mainAxis] - rects.floating[len2] + computedOffset.mainAxis; 4455 const limitMax = rects.reference[mainAxis] + rects.reference[len2] - computedOffset.mainAxis; 4456 if (mainAxisCoord < limitMin) { 4457 mainAxisCoord = limitMin; 4458 } else if (mainAxisCoord > limitMax) { 4459 mainAxisCoord = limitMax; 4460 } 4461 } 4462 if (checkCrossAxis) { 4463 var _middlewareData$offse, _middlewareData$offse2; 4464 const len2 = mainAxis === "y" ? "width" : "height"; 4465 const isOriginSide = originSides.has(getSide(placement)); 4466 const limitMin = rects.reference[crossAxis] - rects.floating[len2] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); 4467 const limitMax = rects.reference[crossAxis] + rects.reference[len2] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); 4468 if (crossAxisCoord < limitMin) { 4469 crossAxisCoord = limitMin; 4470 } else if (crossAxisCoord > limitMax) { 4471 crossAxisCoord = limitMax; 4472 } 4473 } 4474 return { 4475 [mainAxis]: mainAxisCoord, 4476 [crossAxis]: crossAxisCoord 4477 }; 4478 } 4479 }; 4480 }; 4481 var size = function(options) { 4482 if (options === void 0) { 4483 options = {}; 4484 } 4485 return { 4486 name: "size", 4487 options, 4488 async fn(state) { 4489 var _state$middlewareData, _state$middlewareData2; 4490 const { 4491 placement, 4492 rects, 4493 platform: platform3, 4494 elements 4495 } = state; 4496 const { 4497 apply = () => { 4498 }, 4499 ...detectOverflowOptions 4500 } = evaluate(options, state); 4501 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 4502 const side = getSide(placement); 4503 const alignment = getAlignment(placement); 4504 const isYAxis = getSideAxis(placement) === "y"; 4505 const { 4506 width, 4507 height 4508 } = rects.floating; 4509 let heightSide; 4510 let widthSide; 4511 if (side === "top" || side === "bottom") { 4512 heightSide = side; 4513 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; 4514 } else { 4515 widthSide = side; 4516 heightSide = alignment === "end" ? "top" : "bottom"; 4517 } 4518 const maximumClippingHeight = height - overflow.top - overflow.bottom; 4519 const maximumClippingWidth = width - overflow.left - overflow.right; 4520 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); 4521 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); 4522 const noShift = !state.middlewareData.shift; 4523 let availableHeight = overflowAvailableHeight; 4524 let availableWidth = overflowAvailableWidth; 4525 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) { 4526 availableWidth = maximumClippingWidth; 4527 } 4528 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) { 4529 availableHeight = maximumClippingHeight; 4530 } 4531 if (noShift && !alignment) { 4532 const xMin = max(overflow.left, 0); 4533 const xMax = max(overflow.right, 0); 4534 const yMin = max(overflow.top, 0); 4535 const yMax = max(overflow.bottom, 0); 4536 if (isYAxis) { 4537 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); 4538 } else { 4539 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); 4540 } 4541 } 4542 await apply({ 4543 ...state, 4544 availableWidth, 4545 availableHeight 4546 }); 4547 const nextDimensions = await platform3.getDimensions(elements.floating); 4548 if (width !== nextDimensions.width || height !== nextDimensions.height) { 4549 return { 4550 reset: { 4551 rects: true 4552 } 4553 }; 4554 } 4555 return {}; 4556 } 4557 }; 4558 }; 4559 4560 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs 4561 function getCssDimensions(element) { 4562 const css = getComputedStyle2(element); 4563 let width = parseFloat(css.width) || 0; 4564 let height = parseFloat(css.height) || 0; 4565 const hasOffset = isHTMLElement(element); 4566 const offsetWidth = hasOffset ? element.offsetWidth : width; 4567 const offsetHeight = hasOffset ? element.offsetHeight : height; 4568 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 4569 if (shouldFallback) { 4570 width = offsetWidth; 4571 height = offsetHeight; 4572 } 4573 return { 4574 width, 4575 height, 4576 $: shouldFallback 4577 }; 4578 } 4579 function unwrapElement(element) { 4580 return !isElement(element) ? element.contextElement : element; 4581 } 4582 function getScale(element) { 4583 const domElement = unwrapElement(element); 4584 if (!isHTMLElement(domElement)) { 4585 return createCoords(1); 4586 } 4587 const rect = domElement.getBoundingClientRect(); 4588 const { 4589 width, 4590 height, 4591 $: $2 4592 } = getCssDimensions(domElement); 4593 let x2 = ($2 ? round(rect.width) : rect.width) / width; 4594 let y2 = ($2 ? round(rect.height) : rect.height) / height; 4595 if (!x2 || !Number.isFinite(x2)) { 4596 x2 = 1; 4597 } 4598 if (!y2 || !Number.isFinite(y2)) { 4599 y2 = 1; 4600 } 4601 return { 4602 x: x2, 4603 y: y2 4604 }; 4605 } 4606 var noOffsets = /* @__PURE__ */ createCoords(0); 4607 function getVisualOffsets(element) { 4608 const win = getWindow(element); 4609 if (!isWebKit() || !win.visualViewport) { 4610 return noOffsets; 4611 } 4612 return { 4613 x: win.visualViewport.offsetLeft, 4614 y: win.visualViewport.offsetTop 4615 }; 4616 } 4617 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { 4618 if (isFixed === void 0) { 4619 isFixed = false; 4620 } 4621 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { 4622 return false; 4623 } 4624 return isFixed; 4625 } 4626 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { 4627 if (includeScale === void 0) { 4628 includeScale = false; 4629 } 4630 if (isFixedStrategy === void 0) { 4631 isFixedStrategy = false; 4632 } 4633 const clientRect = element.getBoundingClientRect(); 4634 const domElement = unwrapElement(element); 4635 let scale3 = createCoords(1); 4636 if (includeScale) { 4637 if (offsetParent) { 4638 if (isElement(offsetParent)) { 4639 scale3 = getScale(offsetParent); 4640 } 4641 } else { 4642 scale3 = getScale(element); 4643 } 4644 } 4645 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); 4646 let x2 = (clientRect.left + visualOffsets.x) / scale3.x; 4647 let y2 = (clientRect.top + visualOffsets.y) / scale3.y; 4648 let width = clientRect.width / scale3.x; 4649 let height = clientRect.height / scale3.y; 4650 if (domElement) { 4651 const win = getWindow(domElement); 4652 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; 4653 let currentWin = win; 4654 let currentIFrame = getFrameElement(currentWin); 4655 while (currentIFrame && offsetParent && offsetWin !== currentWin) { 4656 const iframeScale = getScale(currentIFrame); 4657 const iframeRect = currentIFrame.getBoundingClientRect(); 4658 const css = getComputedStyle2(currentIFrame); 4659 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; 4660 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; 4661 x2 *= iframeScale.x; 4662 y2 *= iframeScale.y; 4663 width *= iframeScale.x; 4664 height *= iframeScale.y; 4665 x2 += left; 4666 y2 += top; 4667 currentWin = getWindow(currentIFrame); 4668 currentIFrame = getFrameElement(currentWin); 4669 } 4670 } 4671 return rectToClientRect({ 4672 width, 4673 height, 4674 x: x2, 4675 y: y2 4676 }); 4677 } 4678 function getWindowScrollBarX(element, rect) { 4679 const leftScroll = getNodeScroll(element).scrollLeft; 4680 if (!rect) { 4681 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; 4682 } 4683 return rect.left + leftScroll; 4684 } 4685 function getHTMLOffset(documentElement, scroll) { 4686 const htmlRect = documentElement.getBoundingClientRect(); 4687 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect); 4688 const y2 = htmlRect.top + scroll.scrollTop; 4689 return { 4690 x: x2, 4691 y: y2 4692 }; 4693 } 4694 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { 4695 let { 4696 elements, 4697 rect, 4698 offsetParent, 4699 strategy 4700 } = _ref; 4701 const isFixed = strategy === "fixed"; 4702 const documentElement = getDocumentElement(offsetParent); 4703 const topLayer = elements ? isTopLayer(elements.floating) : false; 4704 if (offsetParent === documentElement || topLayer && isFixed) { 4705 return rect; 4706 } 4707 let scroll = { 4708 scrollLeft: 0, 4709 scrollTop: 0 4710 }; 4711 let scale3 = createCoords(1); 4712 const offsets = createCoords(0); 4713 const isOffsetParentAnElement = isHTMLElement(offsetParent); 4714 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 4715 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 4716 scroll = getNodeScroll(offsetParent); 4717 } 4718 if (isOffsetParentAnElement) { 4719 const offsetRect = getBoundingClientRect(offsetParent); 4720 scale3 = getScale(offsetParent); 4721 offsets.x = offsetRect.x + offsetParent.clientLeft; 4722 offsets.y = offsetRect.y + offsetParent.clientTop; 4723 } 4724 } 4725 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 4726 return { 4727 width: rect.width * scale3.x, 4728 height: rect.height * scale3.y, 4729 x: rect.x * scale3.x - scroll.scrollLeft * scale3.x + offsets.x + htmlOffset.x, 4730 y: rect.y * scale3.y - scroll.scrollTop * scale3.y + offsets.y + htmlOffset.y 4731 }; 4732 } 4733 function getClientRects(element) { 4734 return Array.from(element.getClientRects()); 4735 } 4736 function getDocumentRect(element) { 4737 const html = getDocumentElement(element); 4738 const scroll = getNodeScroll(element); 4739 const body = element.ownerDocument.body; 4740 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); 4741 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); 4742 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element); 4743 const y2 = -scroll.scrollTop; 4744 if (getComputedStyle2(body).direction === "rtl") { 4745 x2 += max(html.clientWidth, body.clientWidth) - width; 4746 } 4747 return { 4748 width, 4749 height, 4750 x: x2, 4751 y: y2 4752 }; 4753 } 4754 var SCROLLBAR_MAX = 25; 4755 function getViewportRect(element, strategy) { 4756 const win = getWindow(element); 4757 const html = getDocumentElement(element); 4758 const visualViewport = win.visualViewport; 4759 let width = html.clientWidth; 4760 let height = html.clientHeight; 4761 let x2 = 0; 4762 let y2 = 0; 4763 if (visualViewport) { 4764 width = visualViewport.width; 4765 height = visualViewport.height; 4766 const visualViewportBased = isWebKit(); 4767 if (!visualViewportBased || visualViewportBased && strategy === "fixed") { 4768 x2 = visualViewport.offsetLeft; 4769 y2 = visualViewport.offsetTop; 4770 } 4771 } 4772 const windowScrollbarX = getWindowScrollBarX(html); 4773 if (windowScrollbarX <= 0) { 4774 const doc = html.ownerDocument; 4775 const body = doc.body; 4776 const bodyStyles = getComputedStyle(body); 4777 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0; 4778 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline); 4779 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) { 4780 width -= clippingStableScrollbarWidth; 4781 } 4782 } else if (windowScrollbarX <= SCROLLBAR_MAX) { 4783 width += windowScrollbarX; 4784 } 4785 return { 4786 width, 4787 height, 4788 x: x2, 4789 y: y2 4790 }; 4791 } 4792 function getInnerBoundingClientRect(element, strategy) { 4793 const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); 4794 const top = clientRect.top + element.clientTop; 4795 const left = clientRect.left + element.clientLeft; 4796 const scale3 = isHTMLElement(element) ? getScale(element) : createCoords(1); 4797 const width = element.clientWidth * scale3.x; 4798 const height = element.clientHeight * scale3.y; 4799 const x2 = left * scale3.x; 4800 const y2 = top * scale3.y; 4801 return { 4802 width, 4803 height, 4804 x: x2, 4805 y: y2 4806 }; 4807 } 4808 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { 4809 let rect; 4810 if (clippingAncestor === "viewport") { 4811 rect = getViewportRect(element, strategy); 4812 } else if (clippingAncestor === "document") { 4813 rect = getDocumentRect(getDocumentElement(element)); 4814 } else if (isElement(clippingAncestor)) { 4815 rect = getInnerBoundingClientRect(clippingAncestor, strategy); 4816 } else { 4817 const visualOffsets = getVisualOffsets(element); 4818 rect = { 4819 x: clippingAncestor.x - visualOffsets.x, 4820 y: clippingAncestor.y - visualOffsets.y, 4821 width: clippingAncestor.width, 4822 height: clippingAncestor.height 4823 }; 4824 } 4825 return rectToClientRect(rect); 4826 } 4827 function hasFixedPositionAncestor(element, stopNode) { 4828 const parentNode = getParentNode(element); 4829 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { 4830 return false; 4831 } 4832 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); 4833 } 4834 function getClippingElementAncestors(element, cache) { 4835 const cachedResult = cache.get(element); 4836 if (cachedResult) { 4837 return cachedResult; 4838 } 4839 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); 4840 let currentContainingBlockComputedStyle = null; 4841 const elementIsFixed = getComputedStyle2(element).position === "fixed"; 4842 let currentNode = elementIsFixed ? getParentNode(element) : element; 4843 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { 4844 const computedStyle = getComputedStyle2(currentNode); 4845 const currentNodeIsContaining = isContainingBlock(currentNode); 4846 if (!currentNodeIsContaining && computedStyle.position === "fixed") { 4847 currentContainingBlockComputedStyle = null; 4848 } 4849 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); 4850 if (shouldDropCurrentNode) { 4851 result = result.filter((ancestor) => ancestor !== currentNode); 4852 } else { 4853 currentContainingBlockComputedStyle = computedStyle; 4854 } 4855 currentNode = getParentNode(currentNode); 4856 } 4857 cache.set(element, result); 4858 return result; 4859 } 4860 function getClippingRect(_ref) { 4861 let { 4862 element, 4863 boundary, 4864 rootBoundary, 4865 strategy 4866 } = _ref; 4867 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); 4868 const clippingAncestors = [...elementClippingAncestors, rootBoundary]; 4869 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy); 4870 let top = firstRect.top; 4871 let right = firstRect.right; 4872 let bottom = firstRect.bottom; 4873 let left = firstRect.left; 4874 for (let i2 = 1; i2 < clippingAncestors.length; i2++) { 4875 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy); 4876 top = max(rect.top, top); 4877 right = min(rect.right, right); 4878 bottom = min(rect.bottom, bottom); 4879 left = max(rect.left, left); 4880 } 4881 return { 4882 width: right - left, 4883 height: bottom - top, 4884 x: left, 4885 y: top 4886 }; 4887 } 4888 function getDimensions(element) { 4889 const { 4890 width, 4891 height 4892 } = getCssDimensions(element); 4893 return { 4894 width, 4895 height 4896 }; 4897 } 4898 function getRectRelativeToOffsetParent(element, offsetParent, strategy) { 4899 const isOffsetParentAnElement = isHTMLElement(offsetParent); 4900 const documentElement = getDocumentElement(offsetParent); 4901 const isFixed = strategy === "fixed"; 4902 const rect = getBoundingClientRect(element, true, isFixed, offsetParent); 4903 let scroll = { 4904 scrollLeft: 0, 4905 scrollTop: 0 4906 }; 4907 const offsets = createCoords(0); 4908 function setLeftRTLScrollbarOffset() { 4909 offsets.x = getWindowScrollBarX(documentElement); 4910 } 4911 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 4912 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 4913 scroll = getNodeScroll(offsetParent); 4914 } 4915 if (isOffsetParentAnElement) { 4916 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); 4917 offsets.x = offsetRect.x + offsetParent.clientLeft; 4918 offsets.y = offsetRect.y + offsetParent.clientTop; 4919 } else if (documentElement) { 4920 setLeftRTLScrollbarOffset(); 4921 } 4922 } 4923 if (isFixed && !isOffsetParentAnElement && documentElement) { 4924 setLeftRTLScrollbarOffset(); 4925 } 4926 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 4927 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; 4928 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; 4929 return { 4930 x: x2, 4931 y: y2, 4932 width: rect.width, 4933 height: rect.height 4934 }; 4935 } 4936 function isStaticPositioned(element) { 4937 return getComputedStyle2(element).position === "static"; 4938 } 4939 function getTrueOffsetParent(element, polyfill) { 4940 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") { 4941 return null; 4942 } 4943 if (polyfill) { 4944 return polyfill(element); 4945 } 4946 let rawOffsetParent = element.offsetParent; 4947 if (getDocumentElement(element) === rawOffsetParent) { 4948 rawOffsetParent = rawOffsetParent.ownerDocument.body; 4949 } 4950 return rawOffsetParent; 4951 } 4952 function getOffsetParent(element, polyfill) { 4953 const win = getWindow(element); 4954 if (isTopLayer(element)) { 4955 return win; 4956 } 4957 if (!isHTMLElement(element)) { 4958 let svgOffsetParent = getParentNode(element); 4959 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { 4960 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { 4961 return svgOffsetParent; 4962 } 4963 svgOffsetParent = getParentNode(svgOffsetParent); 4964 } 4965 return win; 4966 } 4967 let offsetParent = getTrueOffsetParent(element, polyfill); 4968 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { 4969 offsetParent = getTrueOffsetParent(offsetParent, polyfill); 4970 } 4971 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { 4972 return win; 4973 } 4974 return offsetParent || getContainingBlock(element) || win; 4975 } 4976 var getElementRects = async function(data) { 4977 const getOffsetParentFn = this.getOffsetParent || getOffsetParent; 4978 const getDimensionsFn = this.getDimensions; 4979 const floatingDimensions = await getDimensionsFn(data.floating); 4980 return { 4981 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), 4982 floating: { 4983 x: 0, 4984 y: 0, 4985 width: floatingDimensions.width, 4986 height: floatingDimensions.height 4987 } 4988 }; 4989 }; 4990 function isRTL(element) { 4991 return getComputedStyle2(element).direction === "rtl"; 4992 } 4993 var platform2 = { 4994 convertOffsetParentRelativeRectToViewportRelativeRect, 4995 getDocumentElement, 4996 getClippingRect, 4997 getOffsetParent, 4998 getElementRects, 4999 getClientRects, 5000 getDimensions, 5001 getScale, 5002 isElement, 5003 isRTL 5004 }; 5005 function rectsAreEqual(a2, b2) { 5006 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height; 5007 } 5008 function observeMove(element, onMove) { 5009 let io = null; 5010 let timeoutId; 5011 const root = getDocumentElement(element); 5012 function cleanup() { 5013 var _io; 5014 clearTimeout(timeoutId); 5015 (_io = io) == null || _io.disconnect(); 5016 io = null; 5017 } 5018 function refresh(skip, threshold) { 5019 if (skip === void 0) { 5020 skip = false; 5021 } 5022 if (threshold === void 0) { 5023 threshold = 1; 5024 } 5025 cleanup(); 5026 const elementRectForRootMargin = element.getBoundingClientRect(); 5027 const { 5028 left, 5029 top, 5030 width, 5031 height 5032 } = elementRectForRootMargin; 5033 if (!skip) { 5034 onMove(); 5035 } 5036 if (!width || !height) { 5037 return; 5038 } 5039 const insetTop = floor(top); 5040 const insetRight = floor(root.clientWidth - (left + width)); 5041 const insetBottom = floor(root.clientHeight - (top + height)); 5042 const insetLeft = floor(left); 5043 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; 5044 const options = { 5045 rootMargin, 5046 threshold: max(0, min(1, threshold)) || 1 5047 }; 5048 let isFirstUpdate = true; 5049 function handleObserve(entries) { 5050 const ratio = entries[0].intersectionRatio; 5051 if (ratio !== threshold) { 5052 if (!isFirstUpdate) { 5053 return refresh(); 5054 } 5055 if (!ratio) { 5056 timeoutId = setTimeout(() => { 5057 refresh(false, 1e-7); 5058 }, 1e3); 5059 } else { 5060 refresh(false, ratio); 5061 } 5062 } 5063 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) { 5064 refresh(); 5065 } 5066 isFirstUpdate = false; 5067 } 5068 try { 5069 io = new IntersectionObserver(handleObserve, { 5070 ...options, 5071 // Handle <iframe>s 5072 root: root.ownerDocument 5073 }); 5074 } catch (_e) { 5075 io = new IntersectionObserver(handleObserve, options); 5076 } 5077 io.observe(element); 5078 } 5079 refresh(true); 5080 return cleanup; 5081 } 5082 function autoUpdate(reference, floating, update2, options) { 5083 if (options === void 0) { 5084 options = {}; 5085 } 5086 const { 5087 ancestorScroll = true, 5088 ancestorResize = true, 5089 elementResize = typeof ResizeObserver === "function", 5090 layoutShift = typeof IntersectionObserver === "function", 5091 animationFrame = false 5092 } = options; 5093 const referenceEl = unwrapElement(reference); 5094 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : []; 5095 ancestors.forEach((ancestor) => { 5096 ancestorScroll && ancestor.addEventListener("scroll", update2, { 5097 passive: true 5098 }); 5099 ancestorResize && ancestor.addEventListener("resize", update2); 5100 }); 5101 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null; 5102 let reobserveFrame = -1; 5103 let resizeObserver = null; 5104 if (elementResize) { 5105 resizeObserver = new ResizeObserver((_ref) => { 5106 let [firstEntry] = _ref; 5107 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) { 5108 resizeObserver.unobserve(floating); 5109 cancelAnimationFrame(reobserveFrame); 5110 reobserveFrame = requestAnimationFrame(() => { 5111 var _resizeObserver; 5112 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating); 5113 }); 5114 } 5115 update2(); 5116 }); 5117 if (referenceEl && !animationFrame) { 5118 resizeObserver.observe(referenceEl); 5119 } 5120 if (floating) { 5121 resizeObserver.observe(floating); 5122 } 5123 } 5124 let frameId; 5125 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null; 5126 if (animationFrame) { 5127 frameLoop(); 5128 } 5129 function frameLoop() { 5130 const nextRefRect = getBoundingClientRect(reference); 5131 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) { 5132 update2(); 5133 } 5134 prevRefRect = nextRefRect; 5135 frameId = requestAnimationFrame(frameLoop); 5136 } 5137 update2(); 5138 return () => { 5139 var _resizeObserver2; 5140 ancestors.forEach((ancestor) => { 5141 ancestorScroll && ancestor.removeEventListener("scroll", update2); 5142 ancestorResize && ancestor.removeEventListener("resize", update2); 5143 }); 5144 cleanupIo == null || cleanupIo(); 5145 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect(); 5146 resizeObserver = null; 5147 if (animationFrame) { 5148 cancelAnimationFrame(frameId); 5149 } 5150 }; 5151 } 5152 var offset2 = offset; 5153 var shift2 = shift; 5154 var flip2 = flip; 5155 var size2 = size; 5156 var hide2 = hide; 5157 var limitShift2 = limitShift; 5158 var computePosition2 = (reference, floating, options) => { 5159 const cache = /* @__PURE__ */ new Map(); 5160 const mergedOptions = { 5161 platform: platform2, 5162 ...options 5163 }; 5164 const platformWithCache = { 5165 ...mergedOptions.platform, 5166 _c: cache 5167 }; 5168 return computePosition(reference, floating, { 5169 ...mergedOptions, 5170 platform: platformWithCache 5171 }); 5172 }; 5173 5174 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs 5175 var React28 = __toESM(require_react(), 1); 5176 var import_react2 = __toESM(require_react(), 1); 5177 var ReactDOM3 = __toESM(require_react_dom(), 1); 5178 var isClient = typeof document !== "undefined"; 5179 var noop2 = function noop3() { 5180 }; 5181 var index = isClient ? import_react2.useLayoutEffect : noop2; 5182 function deepEqual(a2, b2) { 5183 if (a2 === b2) { 5184 return true; 5185 } 5186 if (typeof a2 !== typeof b2) { 5187 return false; 5188 } 5189 if (typeof a2 === "function" && a2.toString() === b2.toString()) { 5190 return true; 5191 } 5192 let length2; 5193 let i2; 5194 let keys; 5195 if (a2 && b2 && typeof a2 === "object") { 5196 if (Array.isArray(a2)) { 5197 length2 = a2.length; 5198 if (length2 !== b2.length) return false; 5199 for (i2 = length2; i2-- !== 0; ) { 5200 if (!deepEqual(a2[i2], b2[i2])) { 5201 return false; 5202 } 5203 } 5204 return true; 5205 } 5206 keys = Object.keys(a2); 5207 length2 = keys.length; 5208 if (length2 !== Object.keys(b2).length) { 5209 return false; 5210 } 5211 for (i2 = length2; i2-- !== 0; ) { 5212 if (!{}.hasOwnProperty.call(b2, keys[i2])) { 5213 return false; 5214 } 5215 } 5216 for (i2 = length2; i2-- !== 0; ) { 5217 const key = keys[i2]; 5218 if (key === "_owner" && a2.$$typeof) { 5219 continue; 5220 } 5221 if (!deepEqual(a2[key], b2[key])) { 5222 return false; 5223 } 5224 } 5225 return true; 5226 } 5227 return a2 !== a2 && b2 !== b2; 5228 } 5229 function getDPR(element) { 5230 if (typeof window === "undefined") { 5231 return 1; 5232 } 5233 const win = element.ownerDocument.defaultView || window; 5234 return win.devicePixelRatio || 1; 5235 } 5236 function roundByDPR(element, value) { 5237 const dpr = getDPR(element); 5238 return Math.round(value * dpr) / dpr; 5239 } 5240 function useLatestRef(value) { 5241 const ref = React28.useRef(value); 5242 index(() => { 5243 ref.current = value; 5244 }); 5245 return ref; 5246 } 5247 function useFloating(options) { 5248 if (options === void 0) { 5249 options = {}; 5250 } 5251 const { 5252 placement = "bottom", 5253 strategy = "absolute", 5254 middleware = [], 5255 platform: platform3, 5256 elements: { 5257 reference: externalReference, 5258 floating: externalFloating 5259 } = {}, 5260 transform = true, 5261 whileElementsMounted, 5262 open 5263 } = options; 5264 const [data, setData] = React28.useState({ 5265 x: 0, 5266 y: 0, 5267 strategy, 5268 placement, 5269 middlewareData: {}, 5270 isPositioned: false 5271 }); 5272 const [latestMiddleware, setLatestMiddleware] = React28.useState(middleware); 5273 if (!deepEqual(latestMiddleware, middleware)) { 5274 setLatestMiddleware(middleware); 5275 } 5276 const [_reference, _setReference] = React28.useState(null); 5277 const [_floating, _setFloating] = React28.useState(null); 5278 const setReference = React28.useCallback((node) => { 5279 if (node !== referenceRef.current) { 5280 referenceRef.current = node; 5281 _setReference(node); 5282 } 5283 }, []); 5284 const setFloating = React28.useCallback((node) => { 5285 if (node !== floatingRef.current) { 5286 floatingRef.current = node; 5287 _setFloating(node); 5288 } 5289 }, []); 5290 const referenceEl = externalReference || _reference; 5291 const floatingEl = externalFloating || _floating; 5292 const referenceRef = React28.useRef(null); 5293 const floatingRef = React28.useRef(null); 5294 const dataRef = React28.useRef(data); 5295 const hasWhileElementsMounted = whileElementsMounted != null; 5296 const whileElementsMountedRef = useLatestRef(whileElementsMounted); 5297 const platformRef = useLatestRef(platform3); 5298 const openRef = useLatestRef(open); 5299 const update2 = React28.useCallback(() => { 5300 if (!referenceRef.current || !floatingRef.current) { 5301 return; 5302 } 5303 const config = { 5304 placement, 5305 strategy, 5306 middleware: latestMiddleware 5307 }; 5308 if (platformRef.current) { 5309 config.platform = platformRef.current; 5310 } 5311 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => { 5312 const fullData = { 5313 ...data2, 5314 // The floating element's position may be recomputed while it's closed 5315 // but still mounted (such as when transitioning out). To ensure 5316 // `isPositioned` will be `false` initially on the next open, avoid 5317 // setting it to `true` when `open === false` (must be specified). 5318 isPositioned: openRef.current !== false 5319 }; 5320 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) { 5321 dataRef.current = fullData; 5322 ReactDOM3.flushSync(() => { 5323 setData(fullData); 5324 }); 5325 } 5326 }); 5327 }, [latestMiddleware, placement, strategy, platformRef, openRef]); 5328 index(() => { 5329 if (open === false && dataRef.current.isPositioned) { 5330 dataRef.current.isPositioned = false; 5331 setData((data2) => ({ 5332 ...data2, 5333 isPositioned: false 5334 })); 5335 } 5336 }, [open]); 5337 const isMountedRef = React28.useRef(false); 5338 index(() => { 5339 isMountedRef.current = true; 5340 return () => { 5341 isMountedRef.current = false; 5342 }; 5343 }, []); 5344 index(() => { 5345 if (referenceEl) referenceRef.current = referenceEl; 5346 if (floatingEl) floatingRef.current = floatingEl; 5347 if (referenceEl && floatingEl) { 5348 if (whileElementsMountedRef.current) { 5349 return whileElementsMountedRef.current(referenceEl, floatingEl, update2); 5350 } 5351 update2(); 5352 } 5353 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]); 5354 const refs = React28.useMemo(() => ({ 5355 reference: referenceRef, 5356 floating: floatingRef, 5357 setReference, 5358 setFloating 5359 }), [setReference, setFloating]); 5360 const elements = React28.useMemo(() => ({ 5361 reference: referenceEl, 5362 floating: floatingEl 5363 }), [referenceEl, floatingEl]); 5364 const floatingStyles = React28.useMemo(() => { 5365 const initialStyles = { 5366 position: strategy, 5367 left: 0, 5368 top: 0 5369 }; 5370 if (!elements.floating) { 5371 return initialStyles; 5372 } 5373 const x2 = roundByDPR(elements.floating, data.x); 5374 const y2 = roundByDPR(elements.floating, data.y); 5375 if (transform) { 5376 return { 5377 ...initialStyles, 5378 transform: "translate(" + x2 + "px, " + y2 + "px)", 5379 ...getDPR(elements.floating) >= 1.5 && { 5380 willChange: "transform" 5381 } 5382 }; 5383 } 5384 return { 5385 position: strategy, 5386 left: x2, 5387 top: y2 5388 }; 5389 }, [strategy, transform, elements.floating, data.x, data.y]); 5390 return React28.useMemo(() => ({ 5391 ...data, 5392 update: update2, 5393 refs, 5394 elements, 5395 floatingStyles 5396 }), [data, update2, refs, elements, floatingStyles]); 5397 } 5398 var offset3 = (options, deps) => { 5399 const result = offset2(options); 5400 return { 5401 name: result.name, 5402 fn: result.fn, 5403 options: [options, deps] 5404 }; 5405 }; 5406 var shift3 = (options, deps) => { 5407 const result = shift2(options); 5408 return { 5409 name: result.name, 5410 fn: result.fn, 5411 options: [options, deps] 5412 }; 5413 }; 5414 var limitShift3 = (options, deps) => { 5415 const result = limitShift2(options); 5416 return { 5417 fn: result.fn, 5418 options: [options, deps] 5419 }; 5420 }; 5421 var flip3 = (options, deps) => { 5422 const result = flip2(options); 5423 return { 5424 name: result.name, 5425 fn: result.fn, 5426 options: [options, deps] 5427 }; 5428 }; 5429 var size3 = (options, deps) => { 5430 const result = size2(options); 5431 return { 5432 name: result.name, 5433 fn: result.fn, 5434 options: [options, deps] 5435 }; 5436 }; 5437 var hide3 = (options, deps) => { 5438 const result = hide2(options); 5439 return { 5440 name: result.name, 5441 fn: result.fn, 5442 options: [options, deps] 5443 }; 5444 }; 5445 5446 // node_modules/@base-ui/utils/esm/store/createSelector.js 5447 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => { 5448 if (other.length > 0) { 5449 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1)); 5450 } 5451 let selector; 5452 if (a2 && b2 && c2 && d2 && e2 && f2) { 5453 selector = (state, a1, a22, a3) => { 5454 const va = a2(state, a1, a22, a3); 5455 const vb = b2(state, a1, a22, a3); 5456 const vc = c2(state, a1, a22, a3); 5457 const vd = d2(state, a1, a22, a3); 5458 const ve = e2(state, a1, a22, a3); 5459 return f2(va, vb, vc, vd, ve, a1, a22, a3); 5460 }; 5461 } else if (a2 && b2 && c2 && d2 && e2) { 5462 selector = (state, a1, a22, a3) => { 5463 const va = a2(state, a1, a22, a3); 5464 const vb = b2(state, a1, a22, a3); 5465 const vc = c2(state, a1, a22, a3); 5466 const vd = d2(state, a1, a22, a3); 5467 return e2(va, vb, vc, vd, a1, a22, a3); 5468 }; 5469 } else if (a2 && b2 && c2 && d2) { 5470 selector = (state, a1, a22, a3) => { 5471 const va = a2(state, a1, a22, a3); 5472 const vb = b2(state, a1, a22, a3); 5473 const vc = c2(state, a1, a22, a3); 5474 return d2(va, vb, vc, a1, a22, a3); 5475 }; 5476 } else if (a2 && b2 && c2) { 5477 selector = (state, a1, a22, a3) => { 5478 const va = a2(state, a1, a22, a3); 5479 const vb = b2(state, a1, a22, a3); 5480 return c2(va, vb, a1, a22, a3); 5481 }; 5482 } else if (a2 && b2) { 5483 selector = (state, a1, a22, a3) => { 5484 const va = a2(state, a1, a22, a3); 5485 return b2(va, a1, a22, a3); 5486 }; 5487 } else if (a2) { 5488 selector = a2; 5489 } else { 5490 throw ( 5491 /* minify-error-disabled */ 5492 new Error("Missing arguments") 5493 ); 5494 } 5495 return selector; 5496 }; 5497 5498 // node_modules/@base-ui/utils/esm/store/useStore.js 5499 var React30 = __toESM(require_react(), 1); 5500 var import_shim = __toESM(require_shim(), 1); 5501 var import_with_selector = __toESM(require_with_selector(), 1); 5502 5503 // node_modules/@base-ui/utils/esm/fastHooks.js 5504 var React29 = __toESM(require_react(), 1); 5505 var hooks = []; 5506 var currentInstance = void 0; 5507 function getInstance() { 5508 return currentInstance; 5509 } 5510 function register(hook) { 5511 hooks.push(hook); 5512 } 5513 function fastComponent(fn) { 5514 const FastComponent = (props, forwardedRef) => { 5515 const instance = useRefWithInit(createInstance).current; 5516 let result; 5517 try { 5518 currentInstance = instance; 5519 for (const hook of hooks) { 5520 hook.before(instance); 5521 } 5522 result = fn(props, forwardedRef); 5523 for (const hook of hooks) { 5524 hook.after(instance); 5525 } 5526 instance.didInitialize = true; 5527 } finally { 5528 currentInstance = void 0; 5529 } 5530 return result; 5531 }; 5532 FastComponent.displayName = fn.displayName || fn.name; 5533 return FastComponent; 5534 } 5535 function fastComponentRef(fn) { 5536 return /* @__PURE__ */ React29.forwardRef(fastComponent(fn)); 5537 } 5538 function createInstance() { 5539 return { 5540 didInitialize: false 5541 }; 5542 } 5543 5544 // node_modules/@base-ui/utils/esm/store/useStore.js 5545 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19); 5546 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy; 5547 function useStore(store3, selector, a1, a2, a3) { 5548 return useStoreImplementation(store3, selector, a1, a2, a3); 5549 } 5550 function useStoreR19(store3, selector, a1, a2, a3) { 5551 const getSelection = React30.useCallback(() => selector(store3.getSnapshot(), a1, a2, a3), [store3, selector, a1, a2, a3]); 5552 return (0, import_shim.useSyncExternalStore)(store3.subscribe, getSelection, getSelection); 5553 } 5554 register({ 5555 before(instance) { 5556 instance.syncIndex = 0; 5557 if (!instance.didInitialize) { 5558 instance.syncTick = 1; 5559 instance.syncHooks = []; 5560 instance.didChangeStore = true; 5561 instance.getSnapshot = () => { 5562 let didChange2 = false; 5563 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) { 5564 const hook = instance.syncHooks[i2]; 5565 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3); 5566 if (hook.didChange || !Object.is(hook.value, value)) { 5567 didChange2 = true; 5568 hook.value = value; 5569 hook.didChange = false; 5570 } 5571 } 5572 if (didChange2) { 5573 instance.syncTick += 1; 5574 } 5575 return instance.syncTick; 5576 }; 5577 } 5578 }, 5579 after(instance) { 5580 if (instance.syncHooks.length > 0) { 5581 if (instance.didChangeStore) { 5582 instance.didChangeStore = false; 5583 instance.subscribe = (onStoreChange) => { 5584 const stores = /* @__PURE__ */ new Set(); 5585 for (const hook of instance.syncHooks) { 5586 stores.add(hook.store); 5587 } 5588 const unsubscribes = []; 5589 for (const store3 of stores) { 5590 unsubscribes.push(store3.subscribe(onStoreChange)); 5591 } 5592 return () => { 5593 for (const unsubscribe of unsubscribes) { 5594 unsubscribe(); 5595 } 5596 }; 5597 }; 5598 } 5599 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot); 5600 } 5601 } 5602 }); 5603 function useStoreFast(store3, selector, a1, a2, a3) { 5604 const instance = getInstance(); 5605 if (!instance) { 5606 return useStoreR19(store3, selector, a1, a2, a3); 5607 } 5608 const index2 = instance.syncIndex; 5609 instance.syncIndex += 1; 5610 let hook; 5611 if (!instance.didInitialize) { 5612 hook = { 5613 store: store3, 5614 selector, 5615 a1, 5616 a2, 5617 a3, 5618 value: selector(store3.getSnapshot(), a1, a2, a3), 5619 didChange: false 5620 }; 5621 instance.syncHooks.push(hook); 5622 } else { 5623 hook = instance.syncHooks[index2]; 5624 if (hook.store !== store3 || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) { 5625 if (hook.store !== store3) { 5626 instance.didChangeStore = true; 5627 } 5628 hook.store = store3; 5629 hook.selector = selector; 5630 hook.a1 = a1; 5631 hook.a2 = a2; 5632 hook.a3 = a3; 5633 hook.didChange = true; 5634 } 5635 } 5636 return hook.value; 5637 } 5638 function useStoreLegacy(store3, selector, a1, a2, a3) { 5639 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store3.subscribe, store3.getSnapshot, store3.getSnapshot, (state) => selector(state, a1, a2, a3)); 5640 } 5641 5642 // node_modules/@base-ui/utils/esm/store/Store.js 5643 var Store = class { 5644 /** 5645 * The current state of the store. 5646 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}. 5647 * To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState). 5648 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers. 5649 * 5650 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification. 5651 */ 5652 // Internal state to handle recursive `setState()` calls 5653 constructor(state) { 5654 this.state = state; 5655 this.listeners = /* @__PURE__ */ new Set(); 5656 this.updateTick = 0; 5657 } 5658 /** 5659 * Registers a listener that will be called whenever the store's state changes. 5660 * 5661 * @param fn The listener function to be called on state changes. 5662 * @returns A function to unsubscribe the listener. 5663 */ 5664 subscribe = (fn) => { 5665 this.listeners.add(fn); 5666 return () => { 5667 this.listeners.delete(fn); 5668 }; 5669 }; 5670 /** 5671 * Returns the current state of the store. 5672 */ 5673 getSnapshot = () => { 5674 return this.state; 5675 }; 5676 /** 5677 * Updates the entire store's state and notifies all registered listeners. 5678 * 5679 * @param newState The new state to set for the store. 5680 */ 5681 setState(newState) { 5682 if (this.state === newState) { 5683 return; 5684 } 5685 this.state = newState; 5686 this.updateTick += 1; 5687 const currentTick = this.updateTick; 5688 for (const listener of this.listeners) { 5689 if (currentTick !== this.updateTick) { 5690 return; 5691 } 5692 listener(newState); 5693 } 5694 } 5695 /** 5696 * Merges the provided changes into the current state and notifies listeners if there are changes. 5697 * 5698 * @param changes An object containing the changes to apply to the current state. 5699 */ 5700 update(changes) { 5701 for (const key in changes) { 5702 if (!Object.is(this.state[key], changes[key])) { 5703 this.setState({ 5704 ...this.state, 5705 ...changes 5706 }); 5707 return; 5708 } 5709 } 5710 } 5711 /** 5712 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed. 5713 * 5714 * @param key The key in the store's state to update. 5715 * @param value The new value to set for the specified key. 5716 */ 5717 set(key, value) { 5718 if (!Object.is(this.state[key], value)) { 5719 this.setState({ 5720 ...this.state, 5721 [key]: value 5722 }); 5723 } 5724 } 5725 /** 5726 * Gives the state a new reference and updates all registered listeners. 5727 */ 5728 notifyAll() { 5729 const newState = { 5730 ...this.state 5731 }; 5732 this.setState(newState); 5733 } 5734 use(selector, a1, a2, a3) { 5735 return useStore(this, selector, a1, a2, a3); 5736 } 5737 }; 5738 5739 // node_modules/@base-ui/utils/esm/store/ReactStore.js 5740 var React31 = __toESM(require_react(), 1); 5741 var ReactStore = class extends Store { 5742 /** 5743 * Creates a new ReactStore instance. 5744 * 5745 * @param state Initial state of the store. 5746 * @param context Non-reactive context values. 5747 * @param selectors Optional selectors for use with `useState`. 5748 */ 5749 constructor(state, context = {}, selectors3) { 5750 super(state); 5751 this.context = context; 5752 this.selectors = selectors3; 5753 } 5754 /** 5755 * Non-reactive values such as refs, callbacks, etc. 5756 */ 5757 /** 5758 * Synchronizes a single external value into the store. 5759 * 5760 * Note that the while the value in `state` is updated immediately, the value returned 5761 * by `useState` is updated before the next render (similarly to React's `useState`). 5762 */ 5763 useSyncedValue(key, value) { 5764 React31.useDebugValue(key); 5765 useIsoLayoutEffect(() => { 5766 if (this.state[key] !== value) { 5767 this.set(key, value); 5768 } 5769 }, [key, value]); 5770 } 5771 /** 5772 * Synchronizes a single external value into the store and 5773 * cleans it up (sets to `undefined`) on unmount. 5774 * 5775 * Note that the while the value in `state` is updated immediately, the value returned 5776 * by `useState` is updated before the next render (similarly to React's `useState`). 5777 */ 5778 useSyncedValueWithCleanup(key, value) { 5779 const store3 = this; 5780 useIsoLayoutEffect(() => { 5781 if (store3.state[key] !== value) { 5782 store3.set(key, value); 5783 } 5784 return () => { 5785 store3.set(key, void 0); 5786 }; 5787 }, [store3, key, value]); 5788 } 5789 /** 5790 * Synchronizes multiple external values into the store. 5791 * 5792 * Note that the while the values in `state` are updated immediately, the values returned 5793 * by `useState` are updated before the next render (similarly to React's `useState`). 5794 */ 5795 useSyncedValues(statePart) { 5796 const store3 = this; 5797 if (true) { 5798 React31.useDebugValue(statePart, (p2) => Object.keys(p2)); 5799 const keys = React31.useRef(Object.keys(statePart)).current; 5800 const nextKeys = Object.keys(statePart); 5801 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) { 5802 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable."); 5803 } 5804 } 5805 const dependencies = Object.values(statePart); 5806 useIsoLayoutEffect(() => { 5807 store3.update(statePart); 5808 }, [store3, ...dependencies]); 5809 } 5810 /** 5811 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled` 5812 * is non-undefined, the store's state at `key` is updated to match `controlled`. 5813 */ 5814 useControlledProp(key, controlled) { 5815 React31.useDebugValue(key); 5816 const isControlled = controlled !== void 0; 5817 useIsoLayoutEffect(() => { 5818 if (isControlled && !Object.is(this.state[key], controlled)) { 5819 super.setState({ 5820 ...this.state, 5821 [key]: controlled 5822 }); 5823 } 5824 }, [key, controlled, isControlled]); 5825 if (true) { 5826 const cache = this.controlledValues ??= /* @__PURE__ */ new Map(); 5827 if (!cache.has(key)) { 5828 cache.set(key, isControlled); 5829 } 5830 const previouslyControlled = cache.get(key); 5831 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) { 5832 console.error(`A component is changing the $isControlled ? "" : "un"}controlled state of $key.toString()} to be $isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`); 5833 } 5834 } 5835 } 5836 /** Gets the current value from the store using a selector with the provided key. 5837 * 5838 * @param key Key of the selector to use. 5839 */ 5840 select(key, a1, a2, a3) { 5841 const selector = this.selectors[key]; 5842 return selector(this.state, a1, a2, a3); 5843 } 5844 /** 5845 * Returns a value from the store's state using a selector function. 5846 * Used to subscribe to specific parts of the state. 5847 * This methods causes a rerender whenever the selected state changes. 5848 * 5849 * @param key Key of the selector to use. 5850 */ 5851 useState(key, a1, a2, a3) { 5852 React31.useDebugValue(key); 5853 return useStore(this, this.selectors[key], a1, a2, a3); 5854 } 5855 /** 5856 * Wraps a function with `useStableCallback` to ensure it has a stable reference 5857 * and assigns it to the context. 5858 * 5859 * @param key Key of the event callback. Must be a function in the context. 5860 * @param fn Function to assign. 5861 */ 5862 useContextCallback(key, fn) { 5863 React31.useDebugValue(key); 5864 const stableFunction = useStableCallback(fn ?? NOOP); 5865 this.context[key] = stableFunction; 5866 } 5867 /** 5868 * Returns a stable setter function for a specific key in the store's state. 5869 * It's commonly used to pass as a ref callback to React elements. 5870 * 5871 * @param key Key of the state to set. 5872 */ 5873 useStateSetter(key) { 5874 const ref = React31.useRef(void 0); 5875 if (ref.current === void 0) { 5876 ref.current = (value) => { 5877 this.set(key, value); 5878 }; 5879 } 5880 return ref.current; 5881 } 5882 /** 5883 * Observes changes derived from the store's selectors and calls the listener when the selected value changes. 5884 * 5885 * @param key Key of the selector to observe. 5886 * @param listener Listener function called when the selector result changes. 5887 */ 5888 observe(selector, listener) { 5889 let selectFn; 5890 if (typeof selector === "function") { 5891 selectFn = selector; 5892 } else { 5893 selectFn = this.selectors[selector]; 5894 } 5895 let prevValue = selectFn(this.state); 5896 listener(prevValue, prevValue, this); 5897 return this.subscribe((nextState) => { 5898 const nextValue = selectFn(nextState); 5899 if (!Object.is(prevValue, nextValue)) { 5900 const oldValue = prevValue; 5901 prevValue = nextValue; 5902 listener(nextValue, oldValue, this); 5903 } 5904 }); 5905 } 5906 }; 5907 5908 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js 5909 var selectors = { 5910 open: createSelector((state) => state.open), 5911 transitionStatus: createSelector((state) => state.transitionStatus), 5912 domReferenceElement: createSelector((state) => state.domReferenceElement), 5913 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement), 5914 floatingElement: createSelector((state) => state.floatingElement), 5915 floatingId: createSelector((state) => state.floatingId) 5916 }; 5917 var FloatingRootStore = class extends ReactStore { 5918 constructor(options) { 5919 const { 5920 syncOnly, 5921 nested, 5922 onOpenChange, 5923 triggerElements, 5924 ...initialState 5925 } = options; 5926 super({ 5927 ...initialState, 5928 positionReference: initialState.referenceElement, 5929 domReferenceElement: initialState.referenceElement 5930 }, { 5931 onOpenChange, 5932 dataRef: { 5933 current: {} 5934 }, 5935 events: createEventEmitter(), 5936 nested, 5937 triggerElements 5938 }, selectors); 5939 this.syncOnly = syncOnly; 5940 } 5941 /** 5942 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction. 5943 */ 5944 syncOpenEvent = (newOpen, event) => { 5945 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing 5946 // click events to upgrade a hover-open. 5947 event != null && isClickLikeEvent(event)) { 5948 this.context.dataRef.current.openEvent = newOpen ? event : void 0; 5949 } 5950 }; 5951 /** 5952 * Runs the root-owned side effects for an open state change. 5953 */ 5954 dispatchOpenChange = (newOpen, eventDetails) => { 5955 this.syncOpenEvent(newOpen, eventDetails.event); 5956 const details = { 5957 open: newOpen, 5958 reason: eventDetails.reason, 5959 nativeEvent: eventDetails.event, 5960 nested: this.context.nested, 5961 triggerElement: eventDetails.trigger 5962 }; 5963 this.context.events.emit("openchange", details); 5964 }; 5965 /** 5966 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments. 5967 * 5968 * @param newOpen The new open state. 5969 * @param eventDetails Details about the event that triggered the open state change. 5970 */ 5971 setOpen = (newOpen, eventDetails) => { 5972 if (this.syncOnly) { 5973 this.context.onOpenChange?.(newOpen, eventDetails); 5974 return; 5975 } 5976 this.dispatchOpenChange(newOpen, eventDetails); 5977 this.context.onOpenChange?.(newOpen, eventDetails); 5978 }; 5979 }; 5980 5981 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js 5982 var React32 = __toESM(require_react(), 1); 5983 function useTriggerRegistration(id, store3) { 5984 const registeredElementIdRef = React32.useRef(null); 5985 const registeredElementRef = React32.useRef(null); 5986 return React32.useCallback((element) => { 5987 if (id === void 0) { 5988 return; 5989 } 5990 if (registeredElementIdRef.current !== null) { 5991 const registeredId = registeredElementIdRef.current; 5992 const registeredElement = registeredElementRef.current; 5993 const currentElement = store3.context.triggerElements.getById(registeredId); 5994 if (registeredElement && currentElement === registeredElement) { 5995 store3.context.triggerElements.delete(registeredId); 5996 } 5997 registeredElementIdRef.current = null; 5998 registeredElementRef.current = null; 5999 } 6000 if (element !== null) { 6001 registeredElementIdRef.current = id; 6002 registeredElementRef.current = element; 6003 store3.context.triggerElements.add(id, element); 6004 } 6005 }, [store3, id]); 6006 } 6007 function useTriggerDataForwarding(triggerId, triggerElementRef, store3, stateUpdates) { 6008 const isMountedByThisTrigger = store3.useState("isMountedByTrigger", triggerId); 6009 const baseRegisterTrigger = useTriggerRegistration(triggerId, store3); 6010 const registerTrigger = useStableCallback((element) => { 6011 baseRegisterTrigger(element); 6012 if (!element || !store3.select("open")) { 6013 return; 6014 } 6015 const activeTriggerId = store3.select("activeTriggerId"); 6016 if (activeTriggerId === triggerId) { 6017 store3.update({ 6018 activeTriggerElement: element, 6019 ...stateUpdates 6020 }); 6021 return; 6022 } 6023 if (activeTriggerId == null) { 6024 store3.update({ 6025 activeTriggerId: triggerId, 6026 activeTriggerElement: element, 6027 ...stateUpdates 6028 }); 6029 } 6030 }); 6031 useIsoLayoutEffect(() => { 6032 if (isMountedByThisTrigger) { 6033 store3.update({ 6034 activeTriggerElement: triggerElementRef.current, 6035 ...stateUpdates 6036 }); 6037 } 6038 }, [isMountedByThisTrigger, store3, triggerElementRef, ...Object.values(stateUpdates)]); 6039 return { 6040 registerTrigger, 6041 isMountedByThisTrigger 6042 }; 6043 } 6044 function useImplicitActiveTrigger(store3) { 6045 const open = store3.useState("open"); 6046 useIsoLayoutEffect(() => { 6047 if (open && !store3.select("activeTriggerId") && store3.context.triggerElements.size === 1) { 6048 const iteratorResult = store3.context.triggerElements.entries().next(); 6049 if (!iteratorResult.done) { 6050 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value; 6051 store3.update({ 6052 activeTriggerId: implicitTriggerId, 6053 activeTriggerElement: implicitTriggerElement 6054 }); 6055 } 6056 } 6057 }, [open, store3]); 6058 } 6059 function useOpenStateTransitions(open, store3, onUnmount) { 6060 const { 6061 mounted, 6062 setMounted, 6063 transitionStatus 6064 } = useTransitionStatus(open); 6065 store3.useSyncedValues({ 6066 mounted, 6067 transitionStatus 6068 }); 6069 const forceUnmount = useStableCallback(() => { 6070 setMounted(false); 6071 store3.update({ 6072 activeTriggerId: null, 6073 activeTriggerElement: null, 6074 mounted: false 6075 }); 6076 onUnmount?.(); 6077 store3.context.onOpenChangeComplete?.(false); 6078 }); 6079 const preventUnmountingOnClose = store3.useState("preventUnmountingOnClose"); 6080 useOpenChangeComplete({ 6081 enabled: !preventUnmountingOnClose, 6082 open, 6083 ref: store3.context.popupRef, 6084 onComplete() { 6085 if (!open) { 6086 forceUnmount(); 6087 } 6088 } 6089 }); 6090 return { 6091 forceUnmount, 6092 transitionStatus 6093 }; 6094 } 6095 6096 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js 6097 var PopupTriggerMap = class { 6098 constructor() { 6099 this.elementsSet = /* @__PURE__ */ new Set(); 6100 this.idMap = /* @__PURE__ */ new Map(); 6101 } 6102 /** 6103 * Adds a trigger element with the given ID. 6104 * 6105 * Note: The provided element is assumed to not be registered under multiple IDs. 6106 */ 6107 add(id, element) { 6108 const existingElement = this.idMap.get(id); 6109 if (existingElement === element) { 6110 return; 6111 } 6112 if (existingElement !== void 0) { 6113 this.elementsSet.delete(existingElement); 6114 } 6115 this.elementsSet.add(element); 6116 this.idMap.set(id, element); 6117 if (true) { 6118 if (this.elementsSet.size !== this.idMap.size) { 6119 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap."); 6120 } 6121 } 6122 } 6123 /** 6124 * Removes the trigger element with the given ID. 6125 */ 6126 delete(id) { 6127 const element = this.idMap.get(id); 6128 if (element) { 6129 this.elementsSet.delete(element); 6130 this.idMap.delete(id); 6131 } 6132 } 6133 /** 6134 * Whether the given element is registered as a trigger. 6135 */ 6136 hasElement(element) { 6137 return this.elementsSet.has(element); 6138 } 6139 /** 6140 * Whether there is a registered trigger element matching the given predicate. 6141 */ 6142 hasMatchingElement(predicate) { 6143 for (const element of this.elementsSet) { 6144 if (predicate(element)) { 6145 return true; 6146 } 6147 } 6148 return false; 6149 } 6150 /** 6151 * Returns the trigger element associated with the given ID, or undefined if no such element exists. 6152 */ 6153 getById(id) { 6154 return this.idMap.get(id); 6155 } 6156 /** 6157 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element]. 6158 */ 6159 entries() { 6160 return this.idMap.entries(); 6161 } 6162 /** 6163 * Returns an iterable of all registered trigger elements. 6164 */ 6165 elements() { 6166 return this.elementsSet.values(); 6167 } 6168 /** 6169 * Returns the number of registered trigger elements. 6170 */ 6171 get size() { 6172 return this.idMap.size; 6173 } 6174 }; 6175 6176 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js 6177 function getEmptyRootContext() { 6178 return new FloatingRootStore({ 6179 open: false, 6180 transitionStatus: void 0, 6181 floatingElement: null, 6182 referenceElement: null, 6183 triggerElements: new PopupTriggerMap(), 6184 floatingId: "", 6185 syncOnly: false, 6186 nested: false, 6187 onOpenChange: void 0 6188 }); 6189 } 6190 6191 // node_modules/@base-ui/react/esm/utils/popups/store.js 6192 function createInitialPopupStoreState() { 6193 return { 6194 open: false, 6195 openProp: void 0, 6196 mounted: false, 6197 transitionStatus: void 0, 6198 floatingRootContext: getEmptyRootContext(), 6199 preventUnmountingOnClose: false, 6200 payload: void 0, 6201 activeTriggerId: null, 6202 activeTriggerElement: null, 6203 triggerIdProp: void 0, 6204 popupElement: null, 6205 positionerElement: null, 6206 activeTriggerProps: EMPTY_OBJECT, 6207 inactiveTriggerProps: EMPTY_OBJECT, 6208 popupProps: EMPTY_OBJECT 6209 }; 6210 } 6211 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId); 6212 var popupStoreSelectors = { 6213 open: createSelector((state) => state.openProp ?? state.open), 6214 mounted: createSelector((state) => state.mounted), 6215 transitionStatus: createSelector((state) => state.transitionStatus), 6216 floatingRootContext: createSelector((state) => state.floatingRootContext), 6217 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose), 6218 payload: createSelector((state) => state.payload), 6219 activeTriggerId: activeTriggerIdSelector, 6220 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null), 6221 /** 6222 * Whether the trigger with the given ID was used to open the popup. 6223 */ 6224 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId), 6225 /** 6226 * Whether the popup is open and was activated by a trigger with the given ID. 6227 */ 6228 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open), 6229 /** 6230 * Whether the popup is mounted and was activated by a trigger with the given ID. 6231 */ 6232 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted), 6233 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps), 6234 popupProps: createSelector((state) => state.popupProps), 6235 popupElement: createSelector((state) => state.popupElement), 6236 positionerElement: createSelector((state) => state.positionerElement) 6237 }; 6238 6239 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js 6240 function useFloatingRootContext(options) { 6241 const { 6242 open = false, 6243 onOpenChange, 6244 elements = {} 6245 } = options; 6246 const floatingId = useId(); 6247 const nested = useFloatingParentNodeId() != null; 6248 if (true) { 6249 const optionDomReference = elements.reference; 6250 if (optionDomReference && !isElement(optionDomReference)) { 6251 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead."); 6252 } 6253 } 6254 const store3 = useRefWithInit(() => new FloatingRootStore({ 6255 open, 6256 transitionStatus: void 0, 6257 onOpenChange, 6258 referenceElement: elements.reference ?? null, 6259 floatingElement: elements.floating ?? null, 6260 triggerElements: new PopupTriggerMap(), 6261 floatingId, 6262 syncOnly: false, 6263 nested 6264 })).current; 6265 useIsoLayoutEffect(() => { 6266 const valuesToSync = { 6267 open, 6268 floatingId 6269 }; 6270 if (elements.reference !== void 0) { 6271 valuesToSync.referenceElement = elements.reference; 6272 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null; 6273 } 6274 if (elements.floating !== void 0) { 6275 valuesToSync.floatingElement = elements.floating; 6276 } 6277 store3.update(valuesToSync); 6278 }, [open, floatingId, elements.reference, elements.floating, store3]); 6279 store3.context.onOpenChange = onOpenChange; 6280 store3.context.nested = nested; 6281 return store3; 6282 } 6283 6284 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js 6285 function useFloating2(options = {}) { 6286 const { 6287 nodeId, 6288 externalTree 6289 } = options; 6290 const internalRootStore = useFloatingRootContext(options); 6291 const rootContext = options.rootContext || internalRootStore; 6292 const rootContextElements = { 6293 reference: rootContext.useState("referenceElement"), 6294 floating: rootContext.useState("floatingElement"), 6295 domReference: rootContext.useState("domReferenceElement") 6296 }; 6297 const [positionReference, setPositionReferenceRaw] = React33.useState(null); 6298 const domReferenceRef = React33.useRef(null); 6299 const tree = useFloatingTree(externalTree); 6300 useIsoLayoutEffect(() => { 6301 if (rootContextElements.domReference) { 6302 domReferenceRef.current = rootContextElements.domReference; 6303 } 6304 }, [rootContextElements.domReference]); 6305 const position = useFloating({ 6306 ...options, 6307 elements: { 6308 ...rootContextElements, 6309 ...positionReference && { 6310 reference: positionReference 6311 } 6312 } 6313 }); 6314 const setPositionReference = React33.useCallback((node) => { 6315 const computedPositionReference = isElement(node) ? { 6316 getBoundingClientRect: () => node.getBoundingClientRect(), 6317 getClientRects: () => node.getClientRects(), 6318 contextElement: node 6319 } : node; 6320 setPositionReferenceRaw(computedPositionReference); 6321 position.refs.setReference(computedPositionReference); 6322 }, [position.refs]); 6323 const [localDomReference, setLocalDomReference] = React33.useState(void 0); 6324 const [localFloatingElement, setLocalFloatingElement] = React33.useState(null); 6325 rootContext.useSyncedValue("referenceElement", localDomReference ?? null); 6326 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null; 6327 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement); 6328 rootContext.useSyncedValue("floatingElement", localFloatingElement); 6329 const setReference = React33.useCallback((node) => { 6330 if (isElement(node) || node === null) { 6331 domReferenceRef.current = node; 6332 setLocalDomReference(node); 6333 } 6334 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to 6335 // `null` to support `positionReference` + an unstable `reference` 6336 // callback ref. 6337 node !== null && !isElement(node)) { 6338 position.refs.setReference(node); 6339 } 6340 }, [position.refs, setLocalDomReference]); 6341 const setFloating = React33.useCallback((node) => { 6342 setLocalFloatingElement(node); 6343 position.refs.setFloating(node); 6344 }, [position.refs]); 6345 const refs = React33.useMemo(() => ({ 6346 ...position.refs, 6347 setReference, 6348 setFloating, 6349 setPositionReference, 6350 domReference: domReferenceRef 6351 }), [position.refs, setReference, setFloating, setPositionReference]); 6352 const elements = React33.useMemo(() => ({ 6353 ...position.elements, 6354 domReference: rootContextElements.domReference 6355 }), [position.elements, rootContextElements.domReference]); 6356 const open = rootContext.useState("open"); 6357 const floatingId = rootContext.useState("floatingId"); 6358 const context = React33.useMemo(() => ({ 6359 ...position, 6360 dataRef: rootContext.context.dataRef, 6361 open, 6362 onOpenChange: rootContext.setOpen, 6363 events: rootContext.context.events, 6364 floatingId, 6365 refs, 6366 elements, 6367 nodeId, 6368 rootStore: rootContext 6369 }), [position, refs, elements, nodeId, rootContext, open, floatingId]); 6370 useIsoLayoutEffect(() => { 6371 rootContext.context.dataRef.current.floatingContext = context; 6372 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId); 6373 if (node) { 6374 node.context = context; 6375 } 6376 }); 6377 return React33.useMemo(() => ({ 6378 ...position, 6379 context, 6380 refs, 6381 elements, 6382 rootStore: rootContext 6383 }), [position, refs, elements, context, rootContext]); 6384 } 6385 6386 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js 6387 function useSyncedFloatingRootContext(options) { 6388 const { 6389 popupStore, 6390 treatPopupAsFloatingElement = false, 6391 onOpenChange 6392 } = options; 6393 const floatingId = useId(); 6394 const nested = useFloatingParentNodeId() != null; 6395 const open = popupStore.useState("open"); 6396 const referenceElement = popupStore.useState("activeTriggerElement"); 6397 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement"); 6398 const triggerElements = popupStore.context.triggerElements; 6399 const store3 = useRefWithInit(() => new FloatingRootStore({ 6400 open, 6401 transitionStatus: void 0, 6402 referenceElement, 6403 floatingElement, 6404 triggerElements, 6405 onOpenChange, 6406 floatingId, 6407 syncOnly: true, 6408 nested 6409 })).current; 6410 useIsoLayoutEffect(() => { 6411 const valuesToSync = { 6412 open, 6413 floatingId, 6414 referenceElement, 6415 floatingElement 6416 }; 6417 if (isElement(referenceElement)) { 6418 valuesToSync.domReferenceElement = referenceElement; 6419 } 6420 if (store3.state.positionReference === store3.state.referenceElement) { 6421 valuesToSync.positionReference = referenceElement; 6422 } 6423 store3.update(valuesToSync); 6424 }, [open, floatingId, referenceElement, floatingElement, store3]); 6425 store3.context.onOpenChange = onOpenChange; 6426 store3.context.nested = nested; 6427 return store3; 6428 } 6429 6430 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js 6431 var React34 = __toESM(require_react(), 1); 6432 var isMacSafari = isMac && isSafari; 6433 function useFocus(context, props = {}) { 6434 const store3 = "rootStore" in context ? context.rootStore : context; 6435 const { 6436 events, 6437 dataRef 6438 } = store3.context; 6439 const { 6440 enabled = true, 6441 delay 6442 } = props; 6443 const blockFocusRef = React34.useRef(false); 6444 const blockedReferenceRef = React34.useRef(null); 6445 const timeout = useTimeout(); 6446 const keyboardModalityRef = React34.useRef(true); 6447 React34.useEffect(() => { 6448 const domReference = store3.select("domReferenceElement"); 6449 if (!enabled) { 6450 return void 0; 6451 } 6452 const win = getWindow(domReference); 6453 function onBlur() { 6454 const currentDomReference = store3.select("domReferenceElement"); 6455 if (!store3.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) { 6456 blockFocusRef.current = true; 6457 } 6458 } 6459 function onKeyDown() { 6460 keyboardModalityRef.current = true; 6461 } 6462 function onPointerDown() { 6463 keyboardModalityRef.current = false; 6464 } 6465 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true)); 6466 }, [store3, enabled]); 6467 React34.useEffect(() => { 6468 if (!enabled) { 6469 return void 0; 6470 } 6471 function onOpenChangeLocal(details) { 6472 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) { 6473 const referenceElement = store3.select("domReferenceElement"); 6474 if (isElement(referenceElement)) { 6475 blockedReferenceRef.current = referenceElement; 6476 blockFocusRef.current = true; 6477 } 6478 } 6479 } 6480 events.on("openchange", onOpenChangeLocal); 6481 return () => { 6482 events.off("openchange", onOpenChangeLocal); 6483 }; 6484 }, [events, enabled, store3]); 6485 const reference = React34.useMemo(() => ({ 6486 onMouseLeave() { 6487 blockFocusRef.current = false; 6488 blockedReferenceRef.current = null; 6489 }, 6490 onFocus(event) { 6491 const focusTarget = event.currentTarget; 6492 if (blockFocusRef.current) { 6493 if (blockedReferenceRef.current === focusTarget) { 6494 return; 6495 } 6496 blockFocusRef.current = false; 6497 blockedReferenceRef.current = null; 6498 } 6499 const target = getTarget(event.nativeEvent); 6500 if (isElement(target)) { 6501 if (isMacSafari && !event.relatedTarget) { 6502 if (!keyboardModalityRef.current && !isTypeableElement(target)) { 6503 return; 6504 } 6505 } else if (!matchesFocusVisible(target)) { 6506 return; 6507 } 6508 } 6509 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store3.context.triggerElements); 6510 const { 6511 nativeEvent, 6512 currentTarget 6513 } = event; 6514 const delayValue = typeof delay === "function" ? delay() : delay; 6515 if (store3.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) { 6516 store3.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 6517 return; 6518 } 6519 timeout.start(delayValue, () => { 6520 if (blockFocusRef.current) { 6521 return; 6522 } 6523 store3.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 6524 }); 6525 }, 6526 onBlur(event) { 6527 blockFocusRef.current = false; 6528 blockedReferenceRef.current = null; 6529 const relatedTarget = event.relatedTarget; 6530 const nativeEvent = event.nativeEvent; 6531 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside"; 6532 timeout.start(0, () => { 6533 const domReference = store3.select("domReferenceElement"); 6534 const activeEl = activeElement(ownerDocument(domReference)); 6535 if (!relatedTarget && activeEl === domReference) { 6536 return; 6537 } 6538 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) { 6539 return; 6540 } 6541 const nextFocusedElement = relatedTarget ?? activeEl; 6542 if (isTargetInsideEnabledTrigger(nextFocusedElement, store3.context.triggerElements)) { 6543 return; 6544 } 6545 store3.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent)); 6546 }); 6547 } 6548 }), [dataRef, store3, timeout, delay]); 6549 return React34.useMemo(() => enabled ? { 6550 reference, 6551 trigger: reference 6552 } : {}, [enabled, reference]); 6553 } 6554 6555 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js 6556 var React35 = __toESM(require_react(), 1); 6557 6558 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js 6559 var HoverInteraction = class _HoverInteraction { 6560 constructor() { 6561 this.pointerType = void 0; 6562 this.interactedInside = false; 6563 this.handler = void 0; 6564 this.blockMouseMove = true; 6565 this.performedPointerEventsMutation = false; 6566 this.pointerEventsScopeElement = null; 6567 this.pointerEventsReferenceElement = null; 6568 this.pointerEventsFloatingElement = null; 6569 this.restTimeoutPending = false; 6570 this.openChangeTimeout = new Timeout(); 6571 this.restTimeout = new Timeout(); 6572 this.handleCloseOptions = void 0; 6573 } 6574 static create() { 6575 return new _HoverInteraction(); 6576 } 6577 dispose = () => { 6578 this.openChangeTimeout.clear(); 6579 this.restTimeout.clear(); 6580 }; 6581 disposeEffect = () => { 6582 return this.dispose; 6583 }; 6584 }; 6585 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap(); 6586 function clearSafePolygonPointerEventsMutation(instance) { 6587 if (!instance.performedPointerEventsMutation) { 6588 return; 6589 } 6590 const scopeElement = instance.pointerEventsScopeElement; 6591 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) { 6592 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events"); 6593 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events"); 6594 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events"); 6595 pointerEventsMutationOwnerByScopeElement.delete(scopeElement); 6596 } 6597 instance.performedPointerEventsMutation = false; 6598 instance.pointerEventsScopeElement = null; 6599 instance.pointerEventsReferenceElement = null; 6600 instance.pointerEventsFloatingElement = null; 6601 } 6602 function applySafePolygonPointerEventsMutation(instance, options) { 6603 const { 6604 scopeElement, 6605 referenceElement, 6606 floatingElement 6607 } = options; 6608 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement); 6609 if (existingOwner && existingOwner !== instance) { 6610 clearSafePolygonPointerEventsMutation(existingOwner); 6611 } 6612 clearSafePolygonPointerEventsMutation(instance); 6613 instance.performedPointerEventsMutation = true; 6614 instance.pointerEventsScopeElement = scopeElement; 6615 instance.pointerEventsReferenceElement = referenceElement; 6616 instance.pointerEventsFloatingElement = floatingElement; 6617 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance); 6618 scopeElement.style.pointerEvents = "none"; 6619 referenceElement.style.pointerEvents = "auto"; 6620 floatingElement.style.pointerEvents = "auto"; 6621 } 6622 function useHoverInteractionSharedState(store3) { 6623 const instance = useRefWithInit(HoverInteraction.create).current; 6624 const data = store3.context.dataRef.current; 6625 if (!data.hoverInteractionState) { 6626 data.hoverInteractionState = instance; 6627 } 6628 useOnMount(data.hoverInteractionState.disposeEffect); 6629 return data.hoverInteractionState; 6630 } 6631 6632 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js 6633 function useHoverFloatingInteraction(context, parameters = {}) { 6634 const store3 = "rootStore" in context ? context.rootStore : context; 6635 const open = store3.useState("open"); 6636 const floatingElement = store3.useState("floatingElement"); 6637 const domReferenceElement = store3.useState("domReferenceElement"); 6638 const { 6639 dataRef 6640 } = store3.context; 6641 const { 6642 enabled = true, 6643 closeDelay: closeDelayProp = 0, 6644 nodeId: nodeIdProp 6645 } = parameters; 6646 const instance = useHoverInteractionSharedState(store3); 6647 const tree = useFloatingTree(); 6648 const parentId = useFloatingParentNodeId(); 6649 const isClickLikeOpenEvent2 = useStableCallback(() => { 6650 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 6651 }); 6652 const isHoverOpen = useStableCallback(() => { 6653 const type = dataRef.current.openEvent?.type; 6654 return type?.includes("mouse") && type !== "mousedown"; 6655 }); 6656 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => { 6657 return isTargetInsideEnabledTrigger(target, store3.context.triggerElements); 6658 }); 6659 const closeWithDelay = React35.useCallback((event) => { 6660 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType); 6661 const close = () => { 6662 store3.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 6663 tree?.events.emit("floating.closed", event); 6664 }; 6665 if (closeDelay) { 6666 instance.openChangeTimeout.start(closeDelay, close); 6667 } else { 6668 instance.openChangeTimeout.clear(); 6669 close(); 6670 } 6671 }, [closeDelayProp, store3, instance, tree]); 6672 const clearPointerEvents = useStableCallback(() => { 6673 clearSafePolygonPointerEventsMutation(instance); 6674 }); 6675 const handleInteractInside = useStableCallback((event) => { 6676 const target = getTarget(event); 6677 if (!isInteractiveElement(target)) { 6678 instance.interactedInside = false; 6679 return; 6680 } 6681 instance.interactedInside = target?.closest("[aria-haspopup]") != null; 6682 }); 6683 useIsoLayoutEffect(() => { 6684 if (!open) { 6685 instance.pointerType = void 0; 6686 instance.restTimeoutPending = false; 6687 instance.interactedInside = false; 6688 clearPointerEvents(); 6689 } 6690 }, [open, instance, clearPointerEvents]); 6691 React35.useEffect(() => { 6692 return clearPointerEvents; 6693 }, [clearPointerEvents]); 6694 useIsoLayoutEffect(() => { 6695 if (!enabled) { 6696 return void 0; 6697 } 6698 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) { 6699 const ref = domReferenceElement; 6700 const floatingEl = floatingElement; 6701 const doc = ownerDocument(floatingElement); 6702 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating; 6703 if (parentFloating) { 6704 parentFloating.style.pointerEvents = ""; 6705 } 6706 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body; 6707 applySafePolygonPointerEventsMutation(instance, { 6708 scopeElement, 6709 referenceElement: ref, 6710 floatingElement: floatingEl 6711 }); 6712 return () => { 6713 clearPointerEvents(); 6714 }; 6715 } 6716 return void 0; 6717 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]); 6718 const childClosedTimeout = useTimeout(); 6719 React35.useEffect(() => { 6720 if (!enabled) { 6721 return void 0; 6722 } 6723 function onFloatingMouseEnter() { 6724 instance.openChangeTimeout.clear(); 6725 childClosedTimeout.clear(); 6726 tree?.events.off("floating.closed", onNodeClosed); 6727 clearPointerEvents(); 6728 } 6729 function onFloatingMouseLeave(event) { 6730 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) { 6731 tree.events.on("floating.closed", onNodeClosed); 6732 return; 6733 } 6734 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) { 6735 return; 6736 } 6737 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp; 6738 const relatedTarget = event.relatedTarget; 6739 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget)); 6740 if (isMovingIntoDescendantFloating) { 6741 return; 6742 } 6743 if (instance.handler) { 6744 instance.handler(event); 6745 return; 6746 } 6747 clearPointerEvents(); 6748 if (!isClickLikeOpenEvent2()) { 6749 closeWithDelay(event); 6750 } 6751 } 6752 function onNodeClosed(event) { 6753 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) { 6754 return; 6755 } 6756 childClosedTimeout.start(0, () => { 6757 tree.events.off("floating.closed", onNodeClosed); 6758 store3.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 6759 tree.events.emit("floating.closed", event); 6760 }); 6761 } 6762 const floating = floatingElement; 6763 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => { 6764 tree?.events.off("floating.closed", onNodeClosed); 6765 }); 6766 }, [enabled, floatingElement, store3, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]); 6767 } 6768 6769 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js 6770 var React36 = __toESM(require_react(), 1); 6771 var ReactDOM4 = __toESM(require_react_dom(), 1); 6772 var EMPTY_REF = { 6773 current: null 6774 }; 6775 function useHoverReferenceInteraction(context, props = {}) { 6776 const store3 = "rootStore" in context ? context.rootStore : context; 6777 const { 6778 dataRef, 6779 events 6780 } = store3.context; 6781 const { 6782 enabled = true, 6783 delay = 0, 6784 handleClose = null, 6785 mouseOnly = false, 6786 restMs = 0, 6787 move = true, 6788 triggerElementRef = EMPTY_REF, 6789 externalTree, 6790 isActiveTrigger = true, 6791 getHandleCloseContext, 6792 isClosing 6793 } = props; 6794 const tree = useFloatingTree(externalTree); 6795 const instance = useHoverInteractionSharedState(store3); 6796 const isHoverCloseActiveRef = React36.useRef(false); 6797 const handleCloseRef = useValueAsRef(handleClose); 6798 const delayRef = useValueAsRef(delay); 6799 const restMsRef = useValueAsRef(restMs); 6800 const enabledRef = useValueAsRef(enabled); 6801 const isClosingRef = useValueAsRef(isClosing); 6802 if (isActiveTrigger) { 6803 instance.handleCloseOptions = handleCloseRef.current?.__options; 6804 } 6805 const isClickLikeOpenEvent2 = useStableCallback(() => { 6806 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 6807 }); 6808 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => { 6809 return isTargetInsideEnabledTrigger(target, store3.context.triggerElements); 6810 }); 6811 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => { 6812 const allTriggers = store3.context.triggerElements; 6813 if (allTriggers.hasElement(currentTarget)) { 6814 return !currentDomReference || !contains(currentDomReference, currentTarget); 6815 } 6816 if (!isElement(target)) { 6817 return false; 6818 } 6819 const targetElement = target; 6820 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement)); 6821 }); 6822 const closeWithDelay = useStableCallback((event, runElseBranch = true) => { 6823 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType); 6824 if (closeDelay) { 6825 instance.openChangeTimeout.start(closeDelay, () => { 6826 store3.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 6827 tree?.events.emit("floating.closed", event); 6828 }); 6829 } else if (runElseBranch) { 6830 instance.openChangeTimeout.clear(); 6831 store3.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 6832 tree?.events.emit("floating.closed", event); 6833 } 6834 }); 6835 const cleanupMouseMoveHandler = useStableCallback(() => { 6836 if (!instance.handler) { 6837 return; 6838 } 6839 const doc = ownerDocument(store3.select("domReferenceElement")); 6840 doc.removeEventListener("mousemove", instance.handler); 6841 instance.handler = void 0; 6842 }); 6843 const clearPointerEvents = useStableCallback(() => { 6844 clearSafePolygonPointerEventsMutation(instance); 6845 }); 6846 React36.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]); 6847 React36.useEffect(() => { 6848 if (!enabled) { 6849 return void 0; 6850 } 6851 function onOpenChangeLocal(details) { 6852 if (!details.open) { 6853 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover; 6854 cleanupMouseMoveHandler(); 6855 instance.openChangeTimeout.clear(); 6856 instance.restTimeout.clear(); 6857 instance.blockMouseMove = true; 6858 instance.restTimeoutPending = false; 6859 } else { 6860 isHoverCloseActiveRef.current = false; 6861 } 6862 } 6863 events.on("openchange", onOpenChangeLocal); 6864 return () => { 6865 events.off("openchange", onOpenChangeLocal); 6866 }; 6867 }, [enabled, events, instance, cleanupMouseMoveHandler]); 6868 React36.useEffect(() => { 6869 if (!enabled) { 6870 return void 0; 6871 } 6872 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store3.select("domReferenceElement") : null); 6873 if (!isElement(trigger)) { 6874 return void 0; 6875 } 6876 function onMouseEnter(event) { 6877 instance.openChangeTimeout.clear(); 6878 instance.blockMouseMove = false; 6879 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 6880 return; 6881 } 6882 const restMsValue = getRestMs(restMsRef.current); 6883 const openDelay = getDelay(delayRef.current, "open", instance.pointerType); 6884 const eventTarget = getTarget(event); 6885 const currentTarget = event.currentTarget ?? null; 6886 const currentDomReference = store3.select("domReferenceElement"); 6887 let triggerNode = currentTarget; 6888 if (isElement(eventTarget) && !store3.context.triggerElements.hasElement(eventTarget)) { 6889 for (const triggerElement of store3.context.triggerElements.elements()) { 6890 if (contains(triggerElement, eventTarget)) { 6891 triggerNode = triggerElement; 6892 break; 6893 } 6894 } 6895 } 6896 if (isElement(currentTarget) && isElement(currentDomReference) && !store3.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) { 6897 triggerNode = currentDomReference; 6898 } 6899 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget); 6900 const isOpen2 = store3.select("open"); 6901 const isInClosingTransition = isClosingRef.current?.() ?? store3.select("transitionStatus") === "ending"; 6902 const isHoverCloseTransition = !isOpen2 && isInClosingTransition && isHoverCloseActiveRef.current; 6903 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition; 6904 const isRestOnlyDelay = restMsValue > 0 && !openDelay; 6905 const shouldOpenImmediately = isOverInactive && (isOpen2 || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition; 6906 const shouldOpen = !isOpen2 || isOverInactive; 6907 if (shouldOpenImmediately) { 6908 store3.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 6909 return; 6910 } 6911 if (isRestOnlyDelay) { 6912 return; 6913 } 6914 if (openDelay) { 6915 instance.openChangeTimeout.start(openDelay, () => { 6916 if (shouldOpen) { 6917 store3.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 6918 } 6919 }); 6920 } else if (shouldOpen) { 6921 store3.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 6922 } 6923 } 6924 function onMouseLeave(event) { 6925 if (isClickLikeOpenEvent2()) { 6926 clearPointerEvents(); 6927 return; 6928 } 6929 cleanupMouseMoveHandler(); 6930 const domReferenceElement = store3.select("domReferenceElement"); 6931 const doc = ownerDocument(domReferenceElement); 6932 instance.restTimeout.clear(); 6933 instance.restTimeoutPending = false; 6934 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.(); 6935 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget); 6936 if (ignoreRelatedTargetTrigger) { 6937 return; 6938 } 6939 if (handleCloseRef.current && handleCloseContextBase) { 6940 if (!store3.select("open")) { 6941 instance.openChangeTimeout.clear(); 6942 } 6943 const currentTrigger = triggerElementRef.current; 6944 instance.handler = handleCloseRef.current({ 6945 ...handleCloseContextBase, 6946 tree, 6947 x: event.clientX, 6948 y: event.clientY, 6949 onClose() { 6950 clearPointerEvents(); 6951 cleanupMouseMoveHandler(); 6952 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store3.select("domReferenceElement")) { 6953 closeWithDelay(event, true); 6954 } 6955 } 6956 }); 6957 doc.addEventListener("mousemove", instance.handler); 6958 instance.handler(event); 6959 return; 6960 } 6961 const shouldClose = instance.pointerType === "touch" ? !contains(store3.select("floatingElement"), event.relatedTarget) : true; 6962 if (shouldClose) { 6963 closeWithDelay(event); 6964 } 6965 } 6966 if (move) { 6967 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, { 6968 once: true 6969 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 6970 } 6971 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 6972 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store3, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]); 6973 return React36.useMemo(() => { 6974 if (!enabled) { 6975 return void 0; 6976 } 6977 function setPointerRef(event) { 6978 instance.pointerType = event.pointerType; 6979 } 6980 return { 6981 onPointerDown: setPointerRef, 6982 onPointerEnter: setPointerRef, 6983 onMouseMove(event) { 6984 const { 6985 nativeEvent 6986 } = event; 6987 const trigger = event.currentTarget; 6988 const currentDomReference = store3.select("domReferenceElement"); 6989 const currentOpen = store3.select("open"); 6990 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target); 6991 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 6992 return; 6993 } 6994 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) { 6995 const floatingElement = store3.select("floatingElement"); 6996 if (floatingElement) { 6997 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body; 6998 applySafePolygonPointerEventsMutation(instance, { 6999 scopeElement, 7000 referenceElement: trigger, 7001 floatingElement 7002 }); 7003 } 7004 } 7005 const restMsValue = getRestMs(restMsRef.current); 7006 if (currentOpen && !isOverInactive || restMsValue === 0) { 7007 return; 7008 } 7009 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) { 7010 return; 7011 } 7012 instance.restTimeout.clear(); 7013 function handleMouseMove() { 7014 instance.restTimeoutPending = false; 7015 if (isClickLikeOpenEvent2()) { 7016 return; 7017 } 7018 const latestOpen = store3.select("open"); 7019 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) { 7020 store3.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger)); 7021 } 7022 } 7023 if (instance.pointerType === "touch") { 7024 ReactDOM4.flushSync(() => { 7025 handleMouseMove(); 7026 }); 7027 } else if (isOverInactive && currentOpen) { 7028 handleMouseMove(); 7029 } else { 7030 instance.restTimeoutPending = true; 7031 instance.restTimeout.start(restMsValue, handleMouseMove); 7032 } 7033 } 7034 }; 7035 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store3, restMsRef]); 7036 } 7037 7038 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js 7039 var React37 = __toESM(require_react(), 1); 7040 function useInteractions(propsList = []) { 7041 const referenceDeps = propsList.map((key) => key?.reference); 7042 const floatingDeps = propsList.map((key) => key?.floating); 7043 const itemDeps = propsList.map((key) => key?.item); 7044 const triggerDeps = propsList.map((key) => key?.trigger); 7045 const getReferenceProps = React37.useCallback( 7046 (userProps) => mergeProps2(userProps, propsList, "reference"), 7047 // eslint-disable-next-line react-hooks/exhaustive-deps 7048 referenceDeps 7049 ); 7050 const getFloatingProps = React37.useCallback( 7051 (userProps) => mergeProps2(userProps, propsList, "floating"), 7052 // eslint-disable-next-line react-hooks/exhaustive-deps 7053 floatingDeps 7054 ); 7055 const getItemProps = React37.useCallback( 7056 (userProps) => mergeProps2(userProps, propsList, "item"), 7057 // eslint-disable-next-line react-hooks/exhaustive-deps 7058 itemDeps 7059 ); 7060 const getTriggerProps = React37.useCallback( 7061 (userProps) => mergeProps2(userProps, propsList, "trigger"), 7062 // eslint-disable-next-line react-hooks/exhaustive-deps 7063 triggerDeps 7064 ); 7065 return React37.useMemo(() => ({ 7066 getReferenceProps, 7067 getFloatingProps, 7068 getItemProps, 7069 getTriggerProps 7070 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]); 7071 } 7072 function mergeProps2(userProps, propsList, elementKey) { 7073 const eventHandlers = /* @__PURE__ */ new Map(); 7074 const isItem = elementKey === "item"; 7075 const outputProps = {}; 7076 if (elementKey === "floating") { 7077 outputProps.tabIndex = -1; 7078 outputProps[FOCUSABLE_ATTRIBUTE] = ""; 7079 } 7080 for (const key in userProps) { 7081 if (isItem && userProps) { 7082 if (key === ACTIVE_KEY || key === SELECTED_KEY) { 7083 continue; 7084 } 7085 } 7086 outputProps[key] = userProps[key]; 7087 } 7088 for (let i2 = 0; i2 < propsList.length; i2 += 1) { 7089 let props; 7090 const propsOrGetProps = propsList[i2]?.[elementKey]; 7091 if (typeof propsOrGetProps === "function") { 7092 props = userProps ? propsOrGetProps(userProps) : null; 7093 } else { 7094 props = propsOrGetProps; 7095 } 7096 if (!props) { 7097 continue; 7098 } 7099 mutablyMergeProps(outputProps, props, isItem, eventHandlers); 7100 } 7101 mutablyMergeProps(outputProps, userProps, isItem, eventHandlers); 7102 return outputProps; 7103 } 7104 function mutablyMergeProps(outputProps, props, isItem, eventHandlers) { 7105 for (const key in props) { 7106 const value = props[key]; 7107 if (isItem && (key === ACTIVE_KEY || key === SELECTED_KEY)) { 7108 continue; 7109 } 7110 if (!key.startsWith("on")) { 7111 outputProps[key] = value; 7112 } else { 7113 if (!eventHandlers.has(key)) { 7114 eventHandlers.set(key, []); 7115 } 7116 if (typeof value === "function") { 7117 eventHandlers.get(key)?.push(value); 7118 outputProps[key] = (...args) => { 7119 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0); 7120 }; 7121 } 7122 } 7123 } 7124 } 7125 7126 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js 7127 var CURSOR_SPEED_THRESHOLD = 0.1; 7128 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD; 7129 var POLYGON_BUFFER = 0.5; 7130 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) { 7131 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi; 7132 } 7133 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) { 7134 let isInsideValue = false; 7135 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) { 7136 isInsideValue = !isInsideValue; 7137 } 7138 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) { 7139 isInsideValue = !isInsideValue; 7140 } 7141 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) { 7142 isInsideValue = !isInsideValue; 7143 } 7144 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) { 7145 isInsideValue = !isInsideValue; 7146 } 7147 return isInsideValue; 7148 } 7149 function isInsideRect(pointX, pointY, rect) { 7150 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height; 7151 } 7152 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) { 7153 const minX = Math.min(x1, x2); 7154 const maxX = Math.max(x1, x2); 7155 const minY = Math.min(y1, y2); 7156 const maxY = Math.max(y1, y2); 7157 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY; 7158 } 7159 function safePolygon(options = {}) { 7160 const { 7161 blockPointerEvents = false 7162 } = options; 7163 const timeout = new Timeout(); 7164 const fn = ({ 7165 x: x2, 7166 y: y2, 7167 placement, 7168 elements, 7169 onClose, 7170 nodeId, 7171 tree 7172 }) => { 7173 const side = placement?.split("-")[0]; 7174 let hasLanded = false; 7175 let lastX = null; 7176 let lastY = null; 7177 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0; 7178 function isCursorMovingSlowly(nextX, nextY) { 7179 const currentTime = performance.now(); 7180 const elapsedTime = currentTime - lastCursorTime; 7181 if (lastX === null || lastY === null || elapsedTime === 0) { 7182 lastX = nextX; 7183 lastY = nextY; 7184 lastCursorTime = currentTime; 7185 return false; 7186 } 7187 const deltaX = nextX - lastX; 7188 const deltaY = nextY - lastY; 7189 const distanceSquared = deltaX * deltaX + deltaY * deltaY; 7190 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED; 7191 lastX = nextX; 7192 lastY = nextY; 7193 lastCursorTime = currentTime; 7194 return distanceSquared < thresholdSquared; 7195 } 7196 function close() { 7197 timeout.clear(); 7198 onClose(); 7199 } 7200 return function onMouseMove(event) { 7201 timeout.clear(); 7202 const domReference = elements.domReference; 7203 const floating = elements.floating; 7204 if (!domReference || !floating || side == null || x2 == null || y2 == null) { 7205 return void 0; 7206 } 7207 const { 7208 clientX, 7209 clientY 7210 } = event; 7211 const target = getTarget(event); 7212 const isLeave = event.type === "mouseleave"; 7213 const isOverFloatingEl = contains(floating, target); 7214 const isOverReferenceEl = contains(domReference, target); 7215 if (isOverFloatingEl) { 7216 hasLanded = true; 7217 if (!isLeave) { 7218 return void 0; 7219 } 7220 } 7221 if (isOverReferenceEl) { 7222 hasLanded = false; 7223 if (!isLeave) { 7224 hasLanded = true; 7225 return void 0; 7226 } 7227 } 7228 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) { 7229 return void 0; 7230 } 7231 function hasOpenChildNode() { 7232 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0); 7233 } 7234 function closeIfNoOpenChild() { 7235 if (!hasOpenChildNode()) { 7236 close(); 7237 } 7238 } 7239 if (hasOpenChildNode()) { 7240 return void 0; 7241 } 7242 const refRect = domReference.getBoundingClientRect(); 7243 const rect = floating.getBoundingClientRect(); 7244 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2; 7245 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2; 7246 const isFloatingWider = rect.width > refRect.width; 7247 const isFloatingTaller = rect.height > refRect.height; 7248 const left = (isFloatingWider ? refRect : rect).left; 7249 const right = (isFloatingWider ? refRect : rect).right; 7250 const top = (isFloatingTaller ? refRect : rect).top; 7251 const bottom = (isFloatingTaller ? refRect : rect).bottom; 7252 if (side === "top" && y2 >= refRect.bottom - 1 || side === "bottom" && y2 <= refRect.top + 1 || side === "left" && x2 >= refRect.right - 1 || side === "right" && x2 <= refRect.left + 1) { 7253 closeIfNoOpenChild(); 7254 return void 0; 7255 } 7256 let isInsideTroughRect = false; 7257 switch (side) { 7258 case "top": 7259 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1); 7260 break; 7261 case "bottom": 7262 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1); 7263 break; 7264 case "left": 7265 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top); 7266 break; 7267 case "right": 7268 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top); 7269 break; 7270 default: 7271 } 7272 if (isInsideTroughRect) { 7273 return void 0; 7274 } 7275 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) { 7276 closeIfNoOpenChild(); 7277 return void 0; 7278 } 7279 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) { 7280 closeIfNoOpenChild(); 7281 return void 0; 7282 } 7283 let isInsidePolygon = false; 7284 switch (side) { 7285 case "top": { 7286 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7287 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7288 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7289 const cursorPointY = y2 + POLYGON_BUFFER + 1; 7290 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top; 7291 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER; 7292 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 7293 break; 7294 } 7295 case "bottom": { 7296 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7297 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7298 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7299 const cursorPointY = y2 - POLYGON_BUFFER; 7300 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom; 7301 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER; 7302 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 7303 break; 7304 } 7305 case "left": { 7306 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7307 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7308 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7309 const cursorPointX = x2 + POLYGON_BUFFER + 1; 7310 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left; 7311 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER; 7312 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY); 7313 break; 7314 } 7315 case "right": { 7316 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7317 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7318 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7319 const cursorPointX = x2 - POLYGON_BUFFER; 7320 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right; 7321 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER; 7322 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom); 7323 break; 7324 } 7325 default: 7326 } 7327 if (!isInsidePolygon) { 7328 closeIfNoOpenChild(); 7329 } else if (!hasLanded) { 7330 timeout.start(40, closeIfNoOpenChild); 7331 } 7332 return void 0; 7333 }; 7334 }; 7335 fn.__options = { 7336 ...options, 7337 blockPointerEvents 7338 }; 7339 return fn; 7340 } 7341 7342 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js 7343 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) { 7344 CommonPopupDataAttributes2["open"] = "data-open"; 7345 CommonPopupDataAttributes2["closed"] = "data-closed"; 7346 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; 7347 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; 7348 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden"; 7349 CommonPopupDataAttributes2["side"] = "data-side"; 7350 CommonPopupDataAttributes2["align"] = "data-align"; 7351 return CommonPopupDataAttributes2; 7352 })({}); 7353 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) { 7354 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open"; 7355 CommonTriggerDataAttributes2["pressed"] = "data-pressed"; 7356 return CommonTriggerDataAttributes2; 7357 })({}); 7358 var TRIGGER_HOOK = { 7359 [CommonTriggerDataAttributes.popupOpen]: "" 7360 }; 7361 var PRESSABLE_TRIGGER_HOOK = { 7362 [CommonTriggerDataAttributes.popupOpen]: "", 7363 [CommonTriggerDataAttributes.pressed]: "" 7364 }; 7365 var POPUP_OPEN_HOOK = { 7366 [CommonPopupDataAttributes.open]: "" 7367 }; 7368 var POPUP_CLOSED_HOOK = { 7369 [CommonPopupDataAttributes.closed]: "" 7370 }; 7371 var ANCHOR_HIDDEN_HOOK = { 7372 [CommonPopupDataAttributes.anchorHidden]: "" 7373 }; 7374 var triggerOpenStateMapping2 = { 7375 open(value) { 7376 if (value) { 7377 return TRIGGER_HOOK; 7378 } 7379 return null; 7380 } 7381 }; 7382 var popupStateMapping = { 7383 open(value) { 7384 if (value) { 7385 return POPUP_OPEN_HOOK; 7386 } 7387 return POPUP_CLOSED_HOOK; 7388 }, 7389 anchorHidden(value) { 7390 if (value) { 7391 return ANCHOR_HIDDEN_HOOK; 7392 } 7393 return null; 7394 } 7395 }; 7396 7397 // node_modules/@base-ui/utils/esm/inertValue.js 7398 function inertValue(value) { 7399 if (isReactVersionAtLeast(19)) { 7400 return value; 7401 } 7402 return value ? "true" : void 0; 7403 } 7404 7405 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js 7406 var React38 = __toESM(require_react(), 1); 7407 7408 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js 7409 var baseArrow = (options) => ({ 7410 name: "arrow", 7411 options, 7412 async fn(state) { 7413 const { 7414 x: x2, 7415 y: y2, 7416 placement, 7417 rects, 7418 platform: platform3, 7419 elements, 7420 middlewareData 7421 } = state; 7422 const { 7423 element, 7424 padding = 0, 7425 offsetParent = "real" 7426 } = evaluate(options, state) || {}; 7427 if (element == null) { 7428 return {}; 7429 } 7430 const paddingObject = getPaddingObject(padding); 7431 const coords = { 7432 x: x2, 7433 y: y2 7434 }; 7435 const axis = getAlignmentAxis(placement); 7436 const length2 = getAxisLength(axis); 7437 const arrowDimensions = await platform3.getDimensions(element); 7438 const isYAxis = axis === "y"; 7439 const minProp = isYAxis ? "top" : "left"; 7440 const maxProp = isYAxis ? "bottom" : "right"; 7441 const clientProp = isYAxis ? "clientHeight" : "clientWidth"; 7442 const endDiff = rects.reference[length2] + rects.reference[axis] - coords[axis] - rects.floating[length2]; 7443 const startDiff = coords[axis] - rects.reference[axis]; 7444 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating; 7445 let clientSize = elements.floating[clientProp] || rects.floating[length2]; 7446 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) { 7447 clientSize = elements.floating[clientProp] || rects.floating[length2]; 7448 } 7449 const centerToReference = endDiff / 2 - startDiff / 2; 7450 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length2] / 2 - 1; 7451 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding); 7452 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding); 7453 const min3 = minPadding; 7454 const max3 = clientSize - arrowDimensions[length2] - maxPadding; 7455 const center = clientSize / 2 - arrowDimensions[length2] / 2 + centerToReference; 7456 const offset4 = clamp(min3, center, max3); 7457 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length2] / 2 - (center < min3 ? minPadding : maxPadding) - arrowDimensions[length2] / 2 < 0; 7458 const alignmentOffset = shouldAddOffset ? center < min3 ? center - min3 : center - max3 : 0; 7459 return { 7460 [axis]: coords[axis] + alignmentOffset, 7461 data: { 7462 [axis]: offset4, 7463 centerOffset: center - offset4 - alignmentOffset, 7464 ...shouldAddOffset && { 7465 alignmentOffset 7466 } 7467 }, 7468 reset: shouldAddOffset 7469 }; 7470 } 7471 }); 7472 var arrow4 = (options, deps) => ({ 7473 ...baseArrow(options), 7474 options: [options, deps] 7475 }); 7476 7477 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js 7478 var hide4 = { 7479 name: "hide", 7480 async fn(state) { 7481 const { 7482 width, 7483 height, 7484 x: x2, 7485 y: y2 7486 } = state.rects.reference; 7487 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0; 7488 const nativeHideResult = await hide3().fn(state); 7489 return { 7490 data: { 7491 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden 7492 } 7493 }; 7494 } 7495 }; 7496 7497 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js 7498 var DEFAULT_SIDES = { 7499 sideX: "left", 7500 sideY: "top" 7501 }; 7502 var adaptiveOrigin = { 7503 name: "adaptiveOrigin", 7504 async fn(state) { 7505 const { 7506 x: rawX, 7507 y: rawY, 7508 rects: { 7509 floating: floatRect 7510 }, 7511 elements: { 7512 floating 7513 }, 7514 platform: platform3, 7515 strategy, 7516 placement 7517 } = state; 7518 const win = getWindow(floating); 7519 const styles = win.getComputedStyle(floating); 7520 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== ""; 7521 if (!hasTransition) { 7522 return { 7523 x: rawX, 7524 y: rawY, 7525 data: DEFAULT_SIDES 7526 }; 7527 } 7528 const offsetParent = await platform3.getOffsetParent?.(floating); 7529 let offsetDimensions = { 7530 width: 0, 7531 height: 0 7532 }; 7533 if (strategy === "fixed" && win?.visualViewport) { 7534 offsetDimensions = { 7535 width: win.visualViewport.width, 7536 height: win.visualViewport.height 7537 }; 7538 } else if (offsetParent === win) { 7539 const doc = ownerDocument(floating); 7540 offsetDimensions = { 7541 width: doc.documentElement.clientWidth, 7542 height: doc.documentElement.clientHeight 7543 }; 7544 } else if (await platform3.isElement?.(offsetParent)) { 7545 offsetDimensions = await platform3.getDimensions(offsetParent); 7546 } 7547 const currentSide = getSide(placement); 7548 let x2 = rawX; 7549 let y2 = rawY; 7550 if (currentSide === "left") { 7551 x2 = offsetDimensions.width - (rawX + floatRect.width); 7552 } 7553 if (currentSide === "top") { 7554 y2 = offsetDimensions.height - (rawY + floatRect.height); 7555 } 7556 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX; 7557 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY; 7558 return { 7559 x: x2, 7560 y: y2, 7561 data: { 7562 sideX, 7563 sideY 7564 } 7565 }; 7566 } 7567 }; 7568 7569 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js 7570 function getLogicalSide(sideParam, renderedSide, isRtl) { 7571 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end"; 7572 const logicalRight = isRtl ? "inline-start" : "inline-end"; 7573 const logicalLeft = isRtl ? "inline-end" : "inline-start"; 7574 return { 7575 top: "top", 7576 right: isLogicalSideParam ? logicalRight : "right", 7577 bottom: "bottom", 7578 left: isLogicalSideParam ? logicalLeft : "left" 7579 }[renderedSide]; 7580 } 7581 function getOffsetData(state, sideParam, isRtl) { 7582 const { 7583 rects, 7584 placement 7585 } = state; 7586 const data = { 7587 side: getLogicalSide(sideParam, getSide(placement), isRtl), 7588 align: getAlignment(placement) || "center", 7589 anchor: { 7590 width: rects.reference.width, 7591 height: rects.reference.height 7592 }, 7593 positioner: { 7594 width: rects.floating.width, 7595 height: rects.floating.height 7596 } 7597 }; 7598 return data; 7599 } 7600 function useAnchorPositioning(params) { 7601 const { 7602 // Public parameters 7603 anchor, 7604 positionMethod = "absolute", 7605 side: sideParam = "bottom", 7606 sideOffset = 0, 7607 align = "center", 7608 alignOffset = 0, 7609 collisionBoundary, 7610 collisionPadding: collisionPaddingParam = 5, 7611 sticky = false, 7612 arrowPadding = 5, 7613 disableAnchorTracking = false, 7614 // Private parameters 7615 keepMounted = false, 7616 floatingRootContext, 7617 mounted, 7618 collisionAvoidance, 7619 shiftCrossAxis = false, 7620 nodeId, 7621 adaptiveOrigin: adaptiveOrigin2, 7622 lazyFlip = false, 7623 externalTree 7624 } = params; 7625 const [mountSide, setMountSide] = React38.useState(null); 7626 if (!mounted && mountSide !== null) { 7627 setMountSide(null); 7628 } 7629 const collisionAvoidanceSide = collisionAvoidance.side || "flip"; 7630 const collisionAvoidanceAlign = collisionAvoidance.align || "flip"; 7631 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end"; 7632 const anchorFn = typeof anchor === "function" ? anchor : void 0; 7633 const anchorFnCallback = useStableCallback(anchorFn); 7634 const anchorDep = anchorFn ? anchorFnCallback : anchor; 7635 const anchorValueRef = useValueAsRef(anchor); 7636 const mountedRef = useValueAsRef(mounted); 7637 const direction = useDirection(); 7638 const isRtl = direction === "rtl"; 7639 const side = mountSide || { 7640 top: "top", 7641 right: "right", 7642 bottom: "bottom", 7643 left: "left", 7644 "inline-end": isRtl ? "left" : "right", 7645 "inline-start": isRtl ? "right" : "left" 7646 }[sideParam]; 7647 const placement = align === "center" ? side : `$side}-$align}`; 7648 let collisionPadding = collisionPaddingParam; 7649 const bias = 1; 7650 const biasTop = sideParam === "bottom" ? bias : 0; 7651 const biasBottom = sideParam === "top" ? bias : 0; 7652 const biasLeft = sideParam === "right" ? bias : 0; 7653 const biasRight = sideParam === "left" ? bias : 0; 7654 if (typeof collisionPadding === "number") { 7655 collisionPadding = { 7656 top: collisionPadding + biasTop, 7657 right: collisionPadding + biasRight, 7658 bottom: collisionPadding + biasBottom, 7659 left: collisionPadding + biasLeft 7660 }; 7661 } else if (collisionPadding) { 7662 collisionPadding = { 7663 top: (collisionPadding.top || 0) + biasTop, 7664 right: (collisionPadding.right || 0) + biasRight, 7665 bottom: (collisionPadding.bottom || 0) + biasBottom, 7666 left: (collisionPadding.left || 0) + biasLeft 7667 }; 7668 } 7669 const commonCollisionProps = { 7670 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary, 7671 padding: collisionPadding 7672 }; 7673 const arrowRef = React38.useRef(null); 7674 const sideOffsetRef = useValueAsRef(sideOffset); 7675 const alignOffsetRef = useValueAsRef(alignOffset); 7676 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0; 7677 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0; 7678 const middleware = [offset3((state) => { 7679 const data = getOffsetData(state, sideParam, isRtl); 7680 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current; 7681 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current; 7682 return { 7683 mainAxis: sideAxis, 7684 crossAxis: alignAxis, 7685 alignmentAxis: alignAxis 7686 }; 7687 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])]; 7688 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift"; 7689 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift"); 7690 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({ 7691 ...commonCollisionProps, 7692 // Ensure the popup flips if it's been limited by its --available-height and it resizes. 7693 // Since the size() padding is smaller than the flip() padding, flip() will take precedence. 7694 padding: { 7695 top: collisionPadding.top + bias, 7696 right: collisionPadding.right + bias, 7697 bottom: collisionPadding.bottom + bias, 7698 left: collisionPadding.left + bias 7699 }, 7700 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip", 7701 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false, 7702 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide 7703 }); 7704 const shiftMiddleware = shiftDisabled ? null : shift3((data) => { 7705 const html = ownerDocument(data.elements.floating).documentElement; 7706 return { 7707 ...commonCollisionProps, 7708 // Use the Layout Viewport to avoid shifting around when pinch-zooming 7709 // for context menus. 7710 rootBoundary: shiftCrossAxis ? { 7711 x: 0, 7712 y: 0, 7713 width: html.clientWidth, 7714 height: html.clientHeight 7715 } : void 0, 7716 mainAxis: collisionAvoidanceAlign !== "none", 7717 crossAxis: crossAxisShiftEnabled, 7718 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => { 7719 if (!arrowRef.current) { 7720 return {}; 7721 } 7722 const { 7723 width, 7724 height 7725 } = arrowRef.current.getBoundingClientRect(); 7726 const sideAxis = getSideAxis(getSide(limitData.placement)); 7727 const arrowSize = sideAxis === "y" ? width : height; 7728 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom; 7729 return { 7730 offset: arrowSize / 2 + offsetAmount / 2 7731 }; 7732 }) 7733 }; 7734 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]); 7735 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") { 7736 middleware.push(shiftMiddleware, flipMiddleware); 7737 } else { 7738 middleware.push(flipMiddleware, shiftMiddleware); 7739 } 7740 middleware.push(size3({ 7741 ...commonCollisionProps, 7742 apply({ 7743 elements: { 7744 floating 7745 }, 7746 availableWidth, 7747 availableHeight, 7748 rects 7749 }) { 7750 if (!mountedRef.current) { 7751 return; 7752 } 7753 const floatingStyle = floating.style; 7754 floatingStyle.setProperty("--available-width", `$availableWidth}px`); 7755 floatingStyle.setProperty("--available-height", `$availableHeight}px`); 7756 const dpr = getWindow(floating).devicePixelRatio || 1; 7757 const { 7758 x: x3, 7759 y: y3, 7760 width, 7761 height 7762 } = rects.reference; 7763 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr; 7764 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr; 7765 floatingStyle.setProperty("--anchor-width", `$anchorWidth}px`); 7766 floatingStyle.setProperty("--anchor-height", `$anchorHeight}px`); 7767 } 7768 }), arrow4(() => ({ 7769 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set, 7770 // we'll create a fake element. 7771 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"), 7772 padding: arrowPadding, 7773 offsetParent: "floating" 7774 }), [arrowPadding]), { 7775 name: "transformOrigin", 7776 fn(state) { 7777 const { 7778 elements: elements2, 7779 middlewareData: middlewareData2, 7780 placement: renderedPlacement2, 7781 rects, 7782 y: y3 7783 } = state; 7784 const currentRenderedSide = getSide(renderedPlacement2); 7785 const currentRenderedAxis = getSideAxis(currentRenderedSide); 7786 const arrowEl = arrowRef.current; 7787 const arrowX = middlewareData2.arrow?.x || 0; 7788 const arrowY = middlewareData2.arrow?.y || 0; 7789 const arrowWidth = arrowEl?.clientWidth || 0; 7790 const arrowHeight = arrowEl?.clientHeight || 0; 7791 const transformX = arrowX + arrowWidth / 2; 7792 const transformY = arrowY + arrowHeight / 2; 7793 const shiftY = Math.abs(middlewareData2.shift?.y || 0); 7794 const halfAnchorHeight = rects.reference.height / 2; 7795 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset; 7796 const isOverlappingAnchor = shiftY > sideOffsetValue; 7797 const adjacentTransformOrigin = { 7798 top: `$transformX}px calc(100% + $sideOffsetValue}px)`, 7799 bottom: `$transformX}px ${-sideOffsetValue}px`, 7800 left: `calc(100% + $sideOffsetValue}px) $transformY}px`, 7801 right: `${-sideOffsetValue}px $transformY}px` 7802 }[currentRenderedSide]; 7803 const overlapTransformOrigin = `$transformX}px $rects.reference.y + halfAnchorHeight - y3}px`; 7804 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin); 7805 return {}; 7806 } 7807 }, hide4, adaptiveOrigin2); 7808 useIsoLayoutEffect(() => { 7809 if (!mounted && floatingRootContext) { 7810 floatingRootContext.update({ 7811 referenceElement: null, 7812 floatingElement: null, 7813 domReferenceElement: null, 7814 positionReference: null 7815 }); 7816 } 7817 }, [mounted, floatingRootContext]); 7818 const autoUpdateOptions = React38.useMemo(() => ({ 7819 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined", 7820 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined" 7821 }), [disableAnchorTracking]); 7822 const { 7823 refs, 7824 elements, 7825 x: x2, 7826 y: y2, 7827 middlewareData, 7828 update: update2, 7829 placement: renderedPlacement, 7830 context, 7831 isPositioned, 7832 floatingStyles: originalFloatingStyles 7833 } = useFloating2({ 7834 rootContext: floatingRootContext, 7835 open: keepMounted ? mounted : void 0, 7836 placement, 7837 middleware, 7838 strategy: positionMethod, 7839 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions), 7840 nodeId, 7841 externalTree 7842 }); 7843 const { 7844 sideX, 7845 sideY 7846 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES; 7847 const resolvedPosition = isPositioned ? positionMethod : "fixed"; 7848 const floatingStyles = React38.useMemo(() => { 7849 const base = adaptiveOrigin2 ? { 7850 position: resolvedPosition, 7851 [sideX]: x2, 7852 [sideY]: y2 7853 } : { 7854 position: resolvedPosition, 7855 ...originalFloatingStyles 7856 }; 7857 if (!isPositioned) { 7858 base.opacity = 0; 7859 } 7860 return base; 7861 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]); 7862 const registeredPositionReferenceRef = React38.useRef(null); 7863 useIsoLayoutEffect(() => { 7864 if (!mounted) { 7865 return; 7866 } 7867 const anchorValue = anchorValueRef.current; 7868 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue; 7869 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null; 7870 const finalAnchor = unwrappedElement || null; 7871 if (finalAnchor !== registeredPositionReferenceRef.current) { 7872 refs.setPositionReference(finalAnchor); 7873 registeredPositionReferenceRef.current = finalAnchor; 7874 } 7875 }, [mounted, refs, anchorDep, anchorValueRef]); 7876 React38.useEffect(() => { 7877 if (!mounted) { 7878 return; 7879 } 7880 const anchorValue = anchorValueRef.current; 7881 if (typeof anchorValue === "function") { 7882 return; 7883 } 7884 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) { 7885 refs.setPositionReference(anchorValue.current); 7886 registeredPositionReferenceRef.current = anchorValue.current; 7887 } 7888 }, [mounted, refs, anchorDep, anchorValueRef]); 7889 React38.useEffect(() => { 7890 if (keepMounted && mounted && elements.domReference && elements.floating) { 7891 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions); 7892 } 7893 return void 0; 7894 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]); 7895 const renderedSide = getSide(renderedPlacement); 7896 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl); 7897 const renderedAlign = getAlignment(renderedPlacement) || "center"; 7898 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden); 7899 useIsoLayoutEffect(() => { 7900 if (lazyFlip && mounted && isPositioned) { 7901 setMountSide(renderedSide); 7902 } 7903 }, [lazyFlip, mounted, isPositioned, renderedSide]); 7904 const arrowStyles = React38.useMemo(() => ({ 7905 position: "absolute", 7906 top: middlewareData.arrow?.y, 7907 left: middlewareData.arrow?.x 7908 }), [middlewareData.arrow]); 7909 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0; 7910 return React38.useMemo(() => ({ 7911 positionerStyles: floatingStyles, 7912 arrowStyles, 7913 arrowRef, 7914 arrowUncentered, 7915 side: logicalRenderedSide, 7916 align: renderedAlign, 7917 physicalSide: renderedSide, 7918 anchorHidden, 7919 refs, 7920 context, 7921 isPositioned, 7922 update: update2 7923 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]); 7924 } 7925 function isRef(param) { 7926 return param != null && "current" in param; 7927 } 7928 7929 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js 7930 function getDisabledMountTransitionStyles(transitionStatus) { 7931 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT; 7932 } 7933 7934 // node_modules/@base-ui/react/esm/utils/usePositioner.js 7935 function usePositioner(componentProps, state, { 7936 styles, 7937 transitionStatus, 7938 props, 7939 refs, 7940 hidden, 7941 inert = false 7942 }) { 7943 const style = { 7944 ...styles 7945 }; 7946 if (inert) { 7947 style.pointerEvents = "none"; 7948 } 7949 return useRenderElement("div", componentProps, { 7950 state, 7951 ref: refs, 7952 props: [{ 7953 role: "presentation", 7954 hidden, 7955 style 7956 }, getDisabledMountTransitionStyles(transitionStatus), props], 7957 stateAttributesMapping: popupStateMapping 7958 }); 7959 } 7960 7961 // node_modules/@base-ui/react/esm/collapsible/index.parts.js 7962 var index_parts_exports = {}; 7963 __export(index_parts_exports, { 7964 Panel: () => CollapsiblePanel, 7965 Root: () => CollapsibleRoot, 7966 Trigger: () => CollapsibleTrigger 7967 }); 7968 7969 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js 7970 var React39 = __toESM(require_react(), 1); 7971 7972 // node_modules/@base-ui/react/esm/collapsible/root/stateAttributesMapping.js 7973 var collapsibleStateAttributesMapping = { 7974 ...collapsibleOpenStateMapping, 7975 ...transitionStatusMapping 7976 }; 7977 7978 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js 7979 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); 7980 var CollapsibleRoot = /* @__PURE__ */ React39.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) { 7981 const { 7982 render: render4, 7983 className, 7984 defaultOpen = false, 7985 disabled: disabled2 = false, 7986 onOpenChange: onOpenChangeProp, 7987 open, 7988 style, 7989 ...elementProps 7990 } = componentProps; 7991 const onOpenChange = useStableCallback(onOpenChangeProp); 7992 const collapsible = useCollapsibleRoot({ 7993 open, 7994 defaultOpen, 7995 onOpenChange, 7996 disabled: disabled2 7997 }); 7998 const state = React39.useMemo(() => ({ 7999 open: collapsible.open, 8000 disabled: collapsible.disabled, 8001 transitionStatus: collapsible.transitionStatus 8002 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]); 8003 const contextValue = React39.useMemo(() => ({ 8004 ...collapsible, 8005 onOpenChange, 8006 state 8007 }), [collapsible, onOpenChange, state]); 8008 const element = useRenderElement("div", componentProps, { 8009 state, 8010 ref: forwardedRef, 8011 props: elementProps, 8012 stateAttributesMapping: collapsibleStateAttributesMapping 8013 }); 8014 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollapsibleRootContext.Provider, { 8015 value: contextValue, 8016 children: element 8017 }); 8018 }); 8019 if (true) CollapsibleRoot.displayName = "CollapsibleRoot"; 8020 8021 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTrigger.js 8022 var React40 = __toESM(require_react(), 1); 8023 var stateAttributesMapping = { 8024 ...triggerOpenStateMapping, 8025 ...transitionStatusMapping 8026 }; 8027 var CollapsibleTrigger = /* @__PURE__ */ React40.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) { 8028 const { 8029 panelId, 8030 open, 8031 handleTrigger, 8032 state, 8033 disabled: contextDisabled 8034 } = useCollapsibleRootContext(); 8035 const { 8036 className, 8037 disabled: disabled2 = contextDisabled, 8038 id, 8039 render: render4, 8040 nativeButton = true, 8041 style, 8042 ...elementProps 8043 } = componentProps; 8044 const { 8045 getButtonProps, 8046 buttonRef 8047 } = useButton({ 8048 disabled: disabled2, 8049 focusableWhenDisabled: true, 8050 native: nativeButton 8051 }); 8052 const props = React40.useMemo(() => ({ 8053 "aria-controls": open ? panelId : void 0, 8054 "aria-expanded": open, 8055 onClick: handleTrigger 8056 }), [panelId, open, handleTrigger]); 8057 const element = useRenderElement("button", componentProps, { 8058 state, 8059 ref: [forwardedRef, buttonRef], 8060 props: [props, elementProps, getButtonProps], 8061 stateAttributesMapping 8062 }); 8063 return element; 8064 }); 8065 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger"; 8066 8067 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js 8068 var React41 = __toESM(require_react(), 1); 8069 8070 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelCssVars.js 8071 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) { 8072 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height"; 8073 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width"; 8074 return CollapsiblePanelCssVars2; 8075 })({}); 8076 8077 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js 8078 var CollapsiblePanel = /* @__PURE__ */ React41.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) { 8079 const { 8080 className, 8081 hiddenUntilFound: hiddenUntilFoundProp, 8082 keepMounted: keepMountedProp, 8083 render: render4, 8084 id: idProp, 8085 style, 8086 ...elementProps 8087 } = componentProps; 8088 if (true) { 8089 useIsoLayoutEffect(() => { 8090 if (hiddenUntilFoundProp && keepMountedProp === false) { 8091 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."); 8092 } 8093 }, [hiddenUntilFoundProp, keepMountedProp]); 8094 } 8095 const { 8096 abortControllerRef, 8097 animationTypeRef, 8098 height, 8099 mounted, 8100 onOpenChange, 8101 open, 8102 panelId, 8103 panelRef, 8104 runOnceAnimationsFinish, 8105 setDimensions, 8106 setHiddenUntilFound, 8107 setKeepMounted, 8108 setMounted, 8109 setPanelIdState, 8110 setOpen, 8111 setVisible, 8112 state, 8113 transitionDimensionRef, 8114 visible, 8115 width, 8116 transitionStatus 8117 } = useCollapsibleRootContext(); 8118 const hiddenUntilFound = hiddenUntilFoundProp ?? false; 8119 const keepMounted = keepMountedProp ?? false; 8120 useIsoLayoutEffect(() => { 8121 if (idProp) { 8122 setPanelIdState(idProp); 8123 return () => { 8124 setPanelIdState(void 0); 8125 }; 8126 } 8127 return void 0; 8128 }, [idProp, setPanelIdState]); 8129 useIsoLayoutEffect(() => { 8130 setHiddenUntilFound(hiddenUntilFound); 8131 }, [setHiddenUntilFound, hiddenUntilFound]); 8132 useIsoLayoutEffect(() => { 8133 setKeepMounted(keepMounted); 8134 }, [setKeepMounted, keepMounted]); 8135 const { 8136 props 8137 } = useCollapsiblePanel({ 8138 abortControllerRef, 8139 animationTypeRef, 8140 externalRef: forwardedRef, 8141 height, 8142 hiddenUntilFound, 8143 id: panelId, 8144 keepMounted, 8145 mounted, 8146 onOpenChange, 8147 open, 8148 panelRef, 8149 runOnceAnimationsFinish, 8150 setDimensions, 8151 setMounted, 8152 setOpen, 8153 setVisible, 8154 transitionDimensionRef, 8155 visible, 8156 width 8157 }); 8158 useOpenChangeComplete({ 8159 open: open && transitionStatus === "idle", 8160 ref: panelRef, 8161 onComplete() { 8162 if (!open) { 8163 return; 8164 } 8165 setDimensions({ 8166 height: void 0, 8167 width: void 0 8168 }); 8169 } 8170 }); 8171 const panelState = React41.useMemo(() => ({ 8172 ...state, 8173 transitionStatus 8174 }), [state, transitionStatus]); 8175 const element = useRenderElement("div", componentProps, { 8176 state: panelState, 8177 ref: [forwardedRef, panelRef], 8178 props: [props, { 8179 style: { 8180 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `$height}px`, 8181 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `$width}px` 8182 } 8183 }, elementProps], 8184 stateAttributesMapping: collapsibleStateAttributesMapping 8185 }); 8186 const shouldRender = keepMounted || hiddenUntilFound || mounted; 8187 if (!shouldRender) { 8188 return null; 8189 } 8190 return element; 8191 }); 8192 if (true) CollapsiblePanel.displayName = "CollapsiblePanel"; 8193 8194 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js 8195 var React44 = __toESM(require_react(), 1); 8196 var ReactDOM5 = __toESM(require_react_dom(), 1); 8197 8198 // node_modules/@base-ui/utils/esm/usePreviousValue.js 8199 var React42 = __toESM(require_react(), 1); 8200 function usePreviousValue(value) { 8201 const [state, setState] = React42.useState({ 8202 current: value, 8203 previous: null 8204 }); 8205 if (value !== state.current) { 8206 setState({ 8207 current: value, 8208 previous: state.current 8209 }); 8210 } 8211 return state.previous; 8212 } 8213 8214 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js 8215 var React43 = __toESM(require_react(), 1); 8216 8217 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js 8218 function getCssDimensions2(element) { 8219 const css = getComputedStyle2(element); 8220 let width = parseFloat(css.width) || 0; 8221 let height = parseFloat(css.height) || 0; 8222 const hasOffset = isHTMLElement(element); 8223 const offsetWidth = hasOffset ? element.offsetWidth : width; 8224 const offsetHeight = hasOffset ? element.offsetHeight : height; 8225 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 8226 if (shouldFallback) { 8227 width = offsetWidth; 8228 height = offsetHeight; 8229 } 8230 return { 8231 width, 8232 height 8233 }; 8234 } 8235 8236 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js 8237 var DEFAULT_ENABLED = () => true; 8238 function usePopupAutoResize(parameters) { 8239 const { 8240 popupElement, 8241 positionerElement, 8242 content, 8243 mounted, 8244 enabled = DEFAULT_ENABLED, 8245 onMeasureLayout: onMeasureLayoutParam, 8246 onMeasureLayoutComplete: onMeasureLayoutCompleteParam, 8247 side, 8248 direction 8249 } = parameters; 8250 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false); 8251 const animationFrame = useAnimationFrame(); 8252 const committedDimensionsRef = React43.useRef(null); 8253 const liveDimensionsRef = React43.useRef(null); 8254 const isInitialRenderRef = React43.useRef(true); 8255 const restoreAnchoringStylesRef = React43.useRef(NOOP); 8256 const onMeasureLayout = useStableCallback(onMeasureLayoutParam); 8257 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam); 8258 const anchoringStyles = React43.useMemo(() => { 8259 let isOriginSide = side === "top"; 8260 let isPhysicalLeft = side === "left"; 8261 if (direction === "rtl") { 8262 isOriginSide = isOriginSide || side === "inline-end"; 8263 isPhysicalLeft = isPhysicalLeft || side === "inline-end"; 8264 } else { 8265 isOriginSide = isOriginSide || side === "inline-start"; 8266 isPhysicalLeft = isPhysicalLeft || side === "inline-start"; 8267 } 8268 return isOriginSide ? { 8269 position: "absolute", 8270 [side === "top" ? "bottom" : "top"]: "0", 8271 [isPhysicalLeft ? "right" : "left"]: "0" 8272 } : EMPTY_OBJECT; 8273 }, [side, direction]); 8274 useIsoLayoutEffect(() => { 8275 if (!mounted || !enabled() || typeof ResizeObserver !== "function") { 8276 restoreAnchoringStylesRef.current = NOOP; 8277 isInitialRenderRef.current = true; 8278 committedDimensionsRef.current = null; 8279 liveDimensionsRef.current = null; 8280 return void 0; 8281 } 8282 if (!popupElement || !positionerElement) { 8283 return void 0; 8284 } 8285 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles); 8286 const observer = new ResizeObserver((entries) => { 8287 const entry = entries[0]; 8288 if (entry) { 8289 liveDimensionsRef.current = { 8290 width: Math.ceil(entry.borderBoxSize[0].inlineSize), 8291 height: Math.ceil(entry.borderBoxSize[0].blockSize) 8292 }; 8293 } 8294 }); 8295 observer.observe(popupElement); 8296 setPopupCssSize(popupElement, "auto"); 8297 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static"); 8298 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none"); 8299 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1"); 8300 const restorePositionerAvailableSize = applyElementStyles(positionerElement, { 8301 "--available-width": "max-content", 8302 "--available-height": "max-content" 8303 }); 8304 function restoreMeasurementOverrides() { 8305 restorePopupPosition(); 8306 restorePopupTransform(); 8307 restorePositionerAvailableSize(); 8308 } 8309 function restoreMeasurementOverridesIncludingScale() { 8310 restoreMeasurementOverrides(); 8311 restorePopupScale(); 8312 } 8313 onMeasureLayout?.(); 8314 if (isInitialRenderRef.current || committedDimensionsRef.current === null) { 8315 setPositionerCssSize(positionerElement, "max-content"); 8316 const dimensions = getCssDimensions2(popupElement); 8317 committedDimensionsRef.current = dimensions; 8318 setPositionerCssSize(positionerElement, dimensions); 8319 restoreMeasurementOverridesIncludingScale(); 8320 onMeasureLayoutComplete?.(null, dimensions); 8321 isInitialRenderRef.current = false; 8322 return () => { 8323 observer.disconnect(); 8324 restoreAnchoringStylesRef.current(); 8325 restoreAnchoringStylesRef.current = NOOP; 8326 }; 8327 } 8328 setPopupCssSize(popupElement, "auto"); 8329 setPositionerCssSize(positionerElement, "max-content"); 8330 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current; 8331 const newDimensions = getCssDimensions2(popupElement); 8332 committedDimensionsRef.current = newDimensions; 8333 if (!previousDimensions) { 8334 setPositionerCssSize(positionerElement, newDimensions); 8335 restoreMeasurementOverridesIncludingScale(); 8336 onMeasureLayoutComplete?.(null, newDimensions); 8337 return () => { 8338 observer.disconnect(); 8339 animationFrame.cancel(); 8340 restoreAnchoringStylesRef.current(); 8341 restoreAnchoringStylesRef.current = NOOP; 8342 }; 8343 } 8344 setPopupCssSize(popupElement, previousDimensions); 8345 restoreMeasurementOverridesIncludingScale(); 8346 onMeasureLayoutComplete?.(previousDimensions, newDimensions); 8347 setPositionerCssSize(positionerElement, newDimensions); 8348 const abortController = new AbortController(); 8349 animationFrame.request(() => { 8350 setPopupCssSize(popupElement, newDimensions); 8351 runOnceAnimationsFinish(() => { 8352 popupElement.style.setProperty("--popup-width", "auto"); 8353 popupElement.style.setProperty("--popup-height", "auto"); 8354 }, abortController.signal); 8355 }); 8356 return () => { 8357 observer.disconnect(); 8358 abortController.abort(); 8359 animationFrame.cancel(); 8360 restoreAnchoringStylesRef.current(); 8361 restoreAnchoringStylesRef.current = NOOP; 8362 }; 8363 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]); 8364 } 8365 function overrideElementStyle(element, property, value) { 8366 const originalValue = element.style.getPropertyValue(property); 8367 element.style.setProperty(property, value); 8368 return () => { 8369 element.style.setProperty(property, originalValue); 8370 }; 8371 } 8372 function applyElementStyles(element, styles) { 8373 const restorers = []; 8374 for (const [key, value] of Object.entries(styles)) { 8375 restorers.push(overrideElementStyle(element, key, value)); 8376 } 8377 return restorers.length ? () => { 8378 restorers.forEach((restore) => restore()); 8379 } : NOOP; 8380 } 8381 function setPopupCssSize(popupElement, size4) { 8382 const width = size4 === "auto" ? "auto" : `$size4.width}px`; 8383 const height = size4 === "auto" ? "auto" : `$size4.height}px`; 8384 popupElement.style.setProperty("--popup-width", width); 8385 popupElement.style.setProperty("--popup-height", height); 8386 } 8387 function setPositionerCssSize(positionerElement, size4) { 8388 const width = size4 === "max-content" ? "max-content" : `$size4.width}px`; 8389 const height = size4 === "max-content" ? "max-content" : `$size4.height}px`; 8390 positionerElement.style.setProperty("--positioner-width", width); 8391 positionerElement.style.setProperty("--positioner-height", height); 8392 } 8393 8394 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js 8395 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); 8396 function usePopupViewport(parameters) { 8397 const { 8398 store: store3, 8399 side, 8400 cssVars, 8401 children 8402 } = parameters; 8403 const direction = useDirection(); 8404 const activeTrigger = store3.useState("activeTriggerElement"); 8405 const activeTriggerId = store3.useState("activeTriggerId"); 8406 const open = store3.useState("open"); 8407 const payload = store3.useState("payload"); 8408 const mounted = store3.useState("mounted"); 8409 const popupElement = store3.useState("popupElement"); 8410 const positionerElement = store3.useState("positionerElement"); 8411 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null); 8412 const currentContentKey = usePopupContentKey(activeTriggerId, payload); 8413 const capturedNodeRef = React44.useRef(null); 8414 const [previousContentNode, setPreviousContentNode] = React44.useState(null); 8415 const [newTriggerOffset, setNewTriggerOffset] = React44.useState(null); 8416 const currentContainerRef = React44.useRef(null); 8417 const previousContainerRef = React44.useRef(null); 8418 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false); 8419 const cleanupFrame = useAnimationFrame(); 8420 const [previousContentDimensions, setPreviousContentDimensions] = React44.useState(null); 8421 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React44.useState(false); 8422 useIsoLayoutEffect(() => { 8423 store3.set("hasViewport", true); 8424 return () => { 8425 store3.set("hasViewport", false); 8426 }; 8427 }, [store3]); 8428 const handleMeasureLayout = useStableCallback(() => { 8429 currentContainerRef.current?.style.setProperty("animation", "none"); 8430 currentContainerRef.current?.style.setProperty("transition", "none"); 8431 previousContainerRef.current?.style.setProperty("display", "none"); 8432 }); 8433 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => { 8434 currentContainerRef.current?.style.removeProperty("animation"); 8435 currentContainerRef.current?.style.removeProperty("transition"); 8436 previousContainerRef.current?.style.removeProperty("display"); 8437 if (previousDimensions) { 8438 setPreviousContentDimensions(previousDimensions); 8439 } 8440 }); 8441 const lastHandledTriggerRef = React44.useRef(null); 8442 useIsoLayoutEffect(() => { 8443 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) { 8444 setPreviousContentNode(capturedNodeRef.current); 8445 setShowStartingStyleAttribute(true); 8446 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger); 8447 setNewTriggerOffset(offset4); 8448 cleanupFrame.request(() => { 8449 ReactDOM5.flushSync(() => { 8450 setShowStartingStyleAttribute(false); 8451 }); 8452 onAnimationsFinished(() => { 8453 setPreviousContentNode(null); 8454 setPreviousContentDimensions(null); 8455 capturedNodeRef.current = null; 8456 }); 8457 }); 8458 lastHandledTriggerRef.current = activeTrigger; 8459 } 8460 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]); 8461 useIsoLayoutEffect(() => { 8462 const source = currentContainerRef.current; 8463 if (!source) { 8464 return; 8465 } 8466 const wrapper = ownerDocument(source).createElement("div"); 8467 for (const child of Array.from(source.childNodes)) { 8468 wrapper.appendChild(child.cloneNode(true)); 8469 } 8470 capturedNodeRef.current = wrapper; 8471 }); 8472 const isTransitioning = previousContentNode != null; 8473 let childrenToRender; 8474 if (!isTransitioning) { 8475 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { 8476 "data-current": true, 8477 ref: currentContainerRef, 8478 children 8479 }, currentContentKey); 8480 } else { 8481 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React44.Fragment, { 8482 children: [/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { 8483 "data-previous": true, 8484 inert: inertValue(true), 8485 ref: previousContainerRef, 8486 style: { 8487 ...previousContentDimensions ? { 8488 [cssVars.popupWidth]: `$previousContentDimensions.width}px`, 8489 [cssVars.popupHeight]: `$previousContentDimensions.height}px` 8490 } : null, 8491 position: "absolute" 8492 }, 8493 "data-ending-style": showStartingStyleAttribute ? void 0 : "" 8494 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { 8495 "data-current": true, 8496 ref: currentContainerRef, 8497 "data-starting-style": showStartingStyleAttribute ? "" : void 0, 8498 children 8499 }, currentContentKey)] 8500 }); 8501 } 8502 useIsoLayoutEffect(() => { 8503 const container = previousContainerRef.current; 8504 if (!container || !previousContentNode) { 8505 return; 8506 } 8507 container.replaceChildren(...Array.from(previousContentNode.childNodes)); 8508 }, [previousContentNode]); 8509 usePopupAutoResize({ 8510 popupElement, 8511 positionerElement, 8512 mounted, 8513 content: payload, 8514 onMeasureLayout: handleMeasureLayout, 8515 onMeasureLayoutComplete: handleMeasureLayoutComplete, 8516 side, 8517 direction 8518 }); 8519 const state = { 8520 activationDirection: getActivationDirection(newTriggerOffset), 8521 transitioning: isTransitioning 8522 }; 8523 return { 8524 children: childrenToRender, 8525 state 8526 }; 8527 } 8528 function getActivationDirection(offset4) { 8529 if (!offset4) { 8530 return void 0; 8531 } 8532 return `$getValueWithTolerance(offset4.horizontal, 5, "right", "left")} $getValueWithTolerance(offset4.vertical, 5, "down", "up")}`; 8533 } 8534 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) { 8535 if (value > tolerance) { 8536 return positiveLabel; 8537 } 8538 if (value < -tolerance) { 8539 return negativeLabel; 8540 } 8541 return ""; 8542 } 8543 function calculateRelativePosition(from, to) { 8544 const fromRect = from.getBoundingClientRect(); 8545 const toRect = to.getBoundingClientRect(); 8546 const fromCenter = { 8547 x: fromRect.left + fromRect.width / 2, 8548 y: fromRect.top + fromRect.height / 2 8549 }; 8550 const toCenter = { 8551 x: toRect.left + toRect.width / 2, 8552 y: toRect.top + toRect.height / 2 8553 }; 8554 return { 8555 horizontal: toCenter.x - fromCenter.x, 8556 vertical: toCenter.y - fromCenter.y 8557 }; 8558 } 8559 function usePopupContentKey(activeTriggerId, payload) { 8560 const [contentKey, setContentKey] = React44.useState(0); 8561 const previousActiveTriggerIdRef = React44.useRef(activeTriggerId); 8562 const previousPayloadRef = React44.useRef(payload); 8563 const pendingPayloadUpdateRef = React44.useRef(false); 8564 useIsoLayoutEffect(() => { 8565 const previousActiveTriggerId = previousActiveTriggerIdRef.current; 8566 const previousPayload = previousPayloadRef.current; 8567 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId; 8568 const payloadChanged = payload !== previousPayload; 8569 if (triggerIdChanged) { 8570 setContentKey((value) => value + 1); 8571 pendingPayloadUpdateRef.current = !payloadChanged; 8572 } else if (pendingPayloadUpdateRef.current && payloadChanged) { 8573 setContentKey((value) => value + 1); 8574 pendingPayloadUpdateRef.current = false; 8575 } 8576 previousActiveTriggerIdRef.current = activeTriggerId; 8577 previousPayloadRef.current = payload; 8578 }, [activeTriggerId, payload]); 8579 return `$activeTriggerId ?? "current"}-$contentKey}`; 8580 } 8581 8582 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js 8583 var React45 = __toESM(require_react(), 1); 8584 var ReactDOM6 = __toESM(require_react_dom(), 1); 8585 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); 8586 var FloatingPortalLite = /* @__PURE__ */ React45.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) { 8587 const { 8588 children, 8589 container, 8590 className, 8591 render: render4, 8592 style, 8593 ...elementProps 8594 } = componentProps; 8595 const { 8596 portalNode, 8597 portalSubtree 8598 } = useFloatingPortalNode({ 8599 container, 8600 ref: forwardedRef, 8601 componentProps, 8602 elementProps 8603 }); 8604 if (!portalSubtree && !portalNode) { 8605 return null; 8606 } 8607 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(React45.Fragment, { 8608 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)] 8609 }); 8610 }); 8611 if (true) FloatingPortalLite.displayName = "FloatingPortalLite"; 8612 8613 // node_modules/@base-ui/react/esm/tooltip/index.parts.js 8614 var index_parts_exports2 = {}; 8615 __export(index_parts_exports2, { 8616 Arrow: () => TooltipArrow, 8617 Handle: () => TooltipHandle, 8618 Popup: () => TooltipPopup, 8619 Portal: () => TooltipPortal, 8620 Positioner: () => TooltipPositioner, 8621 Provider: () => TooltipProvider, 8622 Root: () => TooltipRoot, 8623 Trigger: () => TooltipTrigger, 8624 Viewport: () => TooltipViewport, 8625 createHandle: () => createTooltipHandle 8626 }); 8627 8628 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js 8629 var React48 = __toESM(require_react(), 1); 8630 8631 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js 8632 var React46 = __toESM(require_react(), 1); 8633 var TooltipRootContext = /* @__PURE__ */ React46.createContext(void 0); 8634 if (true) TooltipRootContext.displayName = "TooltipRootContext"; 8635 function useTooltipRootContext(optional) { 8636 const context = React46.useContext(TooltipRootContext); 8637 if (context === void 0 && !optional) { 8638 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72)); 8639 } 8640 return context; 8641 } 8642 8643 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js 8644 var React47 = __toESM(require_react(), 1); 8645 var ReactDOM7 = __toESM(require_react_dom(), 1); 8646 var selectors2 = { 8647 ...popupStoreSelectors, 8648 disabled: createSelector((state) => state.disabled), 8649 instantType: createSelector((state) => state.instantType), 8650 isInstantPhase: createSelector((state) => state.isInstantPhase), 8651 trackCursorAxis: createSelector((state) => state.trackCursorAxis), 8652 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup), 8653 lastOpenChangeReason: createSelector((state) => state.openChangeReason), 8654 closeOnClick: createSelector((state) => state.closeOnClick), 8655 closeDelay: createSelector((state) => state.closeDelay), 8656 hasViewport: createSelector((state) => state.hasViewport) 8657 }; 8658 var TooltipStore = class _TooltipStore extends ReactStore { 8659 constructor(initialState) { 8660 super({ 8661 ...createInitialState(), 8662 ...initialState 8663 }, { 8664 popupRef: /* @__PURE__ */ React47.createRef(), 8665 onOpenChange: void 0, 8666 onOpenChangeComplete: void 0, 8667 triggerElements: new PopupTriggerMap() 8668 }, selectors2); 8669 } 8670 setOpen = (nextOpen, eventDetails) => { 8671 const reason = eventDetails.reason; 8672 const isHover = reason === reason_parts_exports.triggerHover; 8673 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus; 8674 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey); 8675 eventDetails.preventUnmountOnClose = () => { 8676 this.set("preventUnmountingOnClose", true); 8677 }; 8678 this.context.onOpenChange?.(nextOpen, eventDetails); 8679 if (eventDetails.isCanceled) { 8680 return; 8681 } 8682 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails); 8683 const changeState = () => { 8684 const updatedState = { 8685 open: nextOpen, 8686 openChangeReason: reason 8687 }; 8688 if (isFocusOpen) { 8689 updatedState.instantType = "focus"; 8690 } else if (isDismissClose) { 8691 updatedState.instantType = "dismiss"; 8692 } else if (reason === reason_parts_exports.triggerHover) { 8693 updatedState.instantType = void 0; 8694 } 8695 const newTriggerId = eventDetails.trigger?.id ?? null; 8696 if (newTriggerId || nextOpen) { 8697 updatedState.activeTriggerId = newTriggerId; 8698 updatedState.activeTriggerElement = eventDetails.trigger ?? null; 8699 } 8700 this.update(updatedState); 8701 }; 8702 if (isHover) { 8703 ReactDOM7.flushSync(changeState); 8704 } else { 8705 changeState(); 8706 } 8707 }; 8708 static useStore(externalStore, initialState) { 8709 const internalStore = useRefWithInit(() => { 8710 return new _TooltipStore(initialState); 8711 }).current; 8712 const store3 = externalStore ?? internalStore; 8713 const floatingRootContext = useSyncedFloatingRootContext({ 8714 popupStore: store3, 8715 onOpenChange: store3.setOpen 8716 }); 8717 store3.state.floatingRootContext = floatingRootContext; 8718 return store3; 8719 } 8720 }; 8721 function createInitialState() { 8722 return { 8723 ...createInitialPopupStoreState(), 8724 disabled: false, 8725 instantType: void 0, 8726 isInstantPhase: false, 8727 trackCursorAxis: "none", 8728 disableHoverablePopup: false, 8729 openChangeReason: null, 8730 closeOnClick: true, 8731 closeDelay: 0, 8732 hasViewport: false 8733 }; 8734 } 8735 8736 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js 8737 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); 8738 var TooltipRoot = fastComponent(function TooltipRoot2(props) { 8739 const { 8740 disabled: disabled2 = false, 8741 defaultOpen = false, 8742 open: openProp, 8743 disableHoverablePopup = false, 8744 trackCursorAxis = "none", 8745 actionsRef, 8746 onOpenChange, 8747 onOpenChangeComplete, 8748 handle, 8749 triggerId: triggerIdProp, 8750 defaultTriggerId: defaultTriggerIdProp = null, 8751 children 8752 } = props; 8753 const store3 = TooltipStore.useStore(handle?.store, { 8754 open: defaultOpen, 8755 openProp, 8756 activeTriggerId: defaultTriggerIdProp, 8757 triggerIdProp 8758 }); 8759 useOnFirstRender(() => { 8760 if (openProp === void 0 && store3.state.open === false && defaultOpen === true) { 8761 store3.update({ 8762 open: true, 8763 activeTriggerId: defaultTriggerIdProp 8764 }); 8765 } 8766 }); 8767 store3.useControlledProp("openProp", openProp); 8768 store3.useControlledProp("triggerIdProp", triggerIdProp); 8769 store3.useContextCallback("onOpenChange", onOpenChange); 8770 store3.useContextCallback("onOpenChangeComplete", onOpenChangeComplete); 8771 const openState = store3.useState("open"); 8772 const open = !disabled2 && openState; 8773 const activeTriggerId = store3.useState("activeTriggerId"); 8774 const payload = store3.useState("payload"); 8775 store3.useSyncedValues({ 8776 trackCursorAxis, 8777 disableHoverablePopup 8778 }); 8779 useIsoLayoutEffect(() => { 8780 if (openState && disabled2) { 8781 store3.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled)); 8782 } 8783 }, [openState, disabled2, store3]); 8784 store3.useSyncedValue("disabled", disabled2); 8785 useImplicitActiveTrigger(store3); 8786 const { 8787 forceUnmount, 8788 transitionStatus 8789 } = useOpenStateTransitions(open, store3); 8790 const floatingRootContext = store3.select("floatingRootContext"); 8791 const isInstantPhase = store3.useState("isInstantPhase"); 8792 const instantType = store3.useState("instantType"); 8793 const lastOpenChangeReason = store3.useState("lastOpenChangeReason"); 8794 const previousInstantTypeRef = React48.useRef(null); 8795 useIsoLayoutEffect(() => { 8796 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) { 8797 if (instantType !== "delay") { 8798 previousInstantTypeRef.current = instantType; 8799 } 8800 store3.set("instantType", "delay"); 8801 } else if (previousInstantTypeRef.current !== null) { 8802 store3.set("instantType", previousInstantTypeRef.current); 8803 previousInstantTypeRef.current = null; 8804 } 8805 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store3]); 8806 useIsoLayoutEffect(() => { 8807 if (open) { 8808 if (activeTriggerId == null) { 8809 store3.set("payload", void 0); 8810 } 8811 } 8812 }, [store3, activeTriggerId, open]); 8813 const handleImperativeClose = React48.useCallback(() => { 8814 store3.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction)); 8815 }, [store3]); 8816 React48.useImperativeHandle(actionsRef, () => ({ 8817 unmount: forceUnmount, 8818 close: handleImperativeClose 8819 }), [forceUnmount, handleImperativeClose]); 8820 const dismiss = useDismiss(floatingRootContext, { 8821 enabled: !disabled2, 8822 referencePress: () => store3.select("closeOnClick") 8823 }); 8824 const clientPoint = useClientPoint(floatingRootContext, { 8825 enabled: !disabled2 && trackCursorAxis !== "none", 8826 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis 8827 }); 8828 const { 8829 getReferenceProps, 8830 getFloatingProps, 8831 getTriggerProps 8832 } = useInteractions([dismiss, clientPoint]); 8833 const activeTriggerProps = React48.useMemo(() => getReferenceProps(), [getReferenceProps]); 8834 const inactiveTriggerProps = React48.useMemo(() => getTriggerProps(), [getTriggerProps]); 8835 const popupProps = React48.useMemo(() => getFloatingProps(), [getFloatingProps]); 8836 store3.useSyncedValues({ 8837 activeTriggerProps, 8838 inactiveTriggerProps, 8839 popupProps 8840 }); 8841 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipRootContext.Provider, { 8842 value: store3, 8843 children: typeof children === "function" ? children({ 8844 payload 8845 }) : children 8846 }); 8847 }); 8848 if (true) TooltipRoot.displayName = "TooltipRoot"; 8849 8850 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js 8851 var React50 = __toESM(require_react(), 1); 8852 8853 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js 8854 var React49 = __toESM(require_react(), 1); 8855 var TooltipProviderContext = /* @__PURE__ */ React49.createContext(void 0); 8856 if (true) TooltipProviderContext.displayName = "TooltipProviderContext"; 8857 function useTooltipProviderContext() { 8858 return React49.useContext(TooltipProviderContext); 8859 } 8860 8861 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js 8862 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) { 8863 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen"; 8864 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled"; 8865 return TooltipTriggerDataAttributes2; 8866 })({}); 8867 8868 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js 8869 var OPEN_DELAY = 600; 8870 8871 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js 8872 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) { 8873 const { 8874 className, 8875 render: render4, 8876 handle, 8877 payload, 8878 disabled: disabledProp, 8879 delay, 8880 closeOnClick = true, 8881 closeDelay, 8882 id: idProp, 8883 style, 8884 ...elementProps 8885 } = componentProps; 8886 const rootContext = useTooltipRootContext(true); 8887 const store3 = handle?.store ?? rootContext; 8888 if (!store3) { 8889 throw new Error(true ? "Base UI: <Tooltip.Trigger> must be either used within a <Tooltip.Root> component or provided with a handle." : formatErrorMessage_default(82)); 8890 } 8891 const thisTriggerId = useBaseUiId(idProp); 8892 const isTriggerActive = store3.useState("isTriggerActive", thisTriggerId); 8893 const isOpenedByThisTrigger = store3.useState("isOpenedByTrigger", thisTriggerId); 8894 const floatingRootContext = store3.useState("floatingRootContext"); 8895 const triggerElementRef = React50.useRef(null); 8896 const delayWithDefault = delay ?? OPEN_DELAY; 8897 const closeDelayWithDefault = closeDelay ?? 0; 8898 const { 8899 registerTrigger, 8900 isMountedByThisTrigger 8901 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store3, { 8902 payload, 8903 closeOnClick, 8904 closeDelay: closeDelayWithDefault 8905 }); 8906 const providerContext = useTooltipProviderContext(); 8907 const { 8908 delayRef, 8909 isInstantPhase, 8910 hasProvider 8911 } = useDelayGroup(floatingRootContext, { 8912 open: isOpenedByThisTrigger 8913 }); 8914 store3.useSyncedValue("isInstantPhase", isInstantPhase); 8915 const rootDisabled = store3.useState("disabled"); 8916 const disabled2 = disabledProp ?? rootDisabled; 8917 const trackCursorAxis = store3.useState("trackCursorAxis"); 8918 const disableHoverablePopup = store3.useState("disableHoverablePopup"); 8919 const hoverProps = useHoverReferenceInteraction(floatingRootContext, { 8920 enabled: !disabled2, 8921 mouseOnly: true, 8922 move: false, 8923 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null, 8924 restMs() { 8925 const providerDelay = providerContext?.delay; 8926 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0; 8927 let computedRestMs = delayWithDefault; 8928 if (hasProvider) { 8929 if (groupOpenValue !== 0) { 8930 computedRestMs = delay ?? providerDelay ?? delayWithDefault; 8931 } else { 8932 computedRestMs = 0; 8933 } 8934 } 8935 return computedRestMs; 8936 }, 8937 delay() { 8938 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0; 8939 let computedCloseDelay = closeDelayWithDefault; 8940 if (closeDelay == null && hasProvider) { 8941 computedCloseDelay = closeValue; 8942 } 8943 return { 8944 close: computedCloseDelay 8945 }; 8946 }, 8947 triggerElementRef, 8948 isActiveTrigger: isTriggerActive, 8949 isClosing: () => store3.select("transitionStatus") === "ending" 8950 }); 8951 const focusProps = useFocus(floatingRootContext, { 8952 enabled: !disabled2 8953 }).reference; 8954 const state = { 8955 open: isOpenedByThisTrigger 8956 }; 8957 const rootTriggerProps = store3.useState("triggerProps", isMountedByThisTrigger); 8958 const element = useRenderElement("button", componentProps, { 8959 state, 8960 ref: [forwardedRef, registerTrigger, triggerElementRef], 8961 props: [hoverProps, focusProps, rootTriggerProps, { 8962 onPointerDown() { 8963 store3.set("closeOnClick", closeOnClick); 8964 }, 8965 id: thisTriggerId, 8966 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0 8967 }, elementProps], 8968 stateAttributesMapping: triggerOpenStateMapping2 8969 }); 8970 return element; 8971 }); 8972 if (true) TooltipTrigger.displayName = "TooltipTrigger"; 8973 8974 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js 8975 var React52 = __toESM(require_react(), 1); 8976 8977 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js 8978 var React51 = __toESM(require_react(), 1); 8979 var TooltipPortalContext = /* @__PURE__ */ React51.createContext(void 0); 8980 if (true) TooltipPortalContext.displayName = "TooltipPortalContext"; 8981 function useTooltipPortalContext() { 8982 const value = React51.useContext(TooltipPortalContext); 8983 if (value === void 0) { 8984 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70)); 8985 } 8986 return value; 8987 } 8988 8989 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js 8990 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); 8991 var TooltipPortal = /* @__PURE__ */ React52.forwardRef(function TooltipPortal2(props, forwardedRef) { 8992 const { 8993 keepMounted = false, 8994 ...portalProps 8995 } = props; 8996 const store3 = useTooltipRootContext(); 8997 const mounted = store3.useState("mounted"); 8998 const shouldRender = mounted || keepMounted; 8999 if (!shouldRender) { 9000 return null; 9001 } 9002 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPortalContext.Provider, { 9003 value: keepMounted, 9004 children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloatingPortalLite, { 9005 ref: forwardedRef, 9006 ...portalProps 9007 }) 9008 }); 9009 }); 9010 if (true) TooltipPortal.displayName = "TooltipPortal"; 9011 9012 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js 9013 var React54 = __toESM(require_react(), 1); 9014 9015 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js 9016 var React53 = __toESM(require_react(), 1); 9017 var TooltipPositionerContext = /* @__PURE__ */ React53.createContext(void 0); 9018 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext"; 9019 function useTooltipPositionerContext() { 9020 const context = React53.useContext(TooltipPositionerContext); 9021 if (context === void 0) { 9022 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71)); 9023 } 9024 return context; 9025 } 9026 9027 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js 9028 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); 9029 var TooltipPositioner = /* @__PURE__ */ React54.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) { 9030 const { 9031 render: render4, 9032 className, 9033 anchor, 9034 positionMethod = "absolute", 9035 side = "top", 9036 align = "center", 9037 sideOffset = 0, 9038 alignOffset = 0, 9039 collisionBoundary = "clipping-ancestors", 9040 collisionPadding = 5, 9041 arrowPadding = 5, 9042 sticky = false, 9043 disableAnchorTracking = false, 9044 collisionAvoidance = POPUP_COLLISION_AVOIDANCE, 9045 style, 9046 ...elementProps 9047 } = componentProps; 9048 const store3 = useTooltipRootContext(); 9049 const keepMounted = useTooltipPortalContext(); 9050 const open = store3.useState("open"); 9051 const mounted = store3.useState("mounted"); 9052 const trackCursorAxis = store3.useState("trackCursorAxis"); 9053 const disableHoverablePopup = store3.useState("disableHoverablePopup"); 9054 const floatingRootContext = store3.useState("floatingRootContext"); 9055 const instantType = store3.useState("instantType"); 9056 const transitionStatus = store3.useState("transitionStatus"); 9057 const hasViewport = store3.useState("hasViewport"); 9058 const positioning = useAnchorPositioning({ 9059 anchor, 9060 positionMethod, 9061 floatingRootContext, 9062 mounted, 9063 side, 9064 sideOffset, 9065 align, 9066 alignOffset, 9067 collisionBoundary, 9068 collisionPadding, 9069 sticky, 9070 arrowPadding, 9071 disableAnchorTracking, 9072 keepMounted, 9073 collisionAvoidance, 9074 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0 9075 }); 9076 const state = React54.useMemo(() => ({ 9077 open, 9078 side: positioning.side, 9079 align: positioning.align, 9080 anchorHidden: positioning.anchorHidden, 9081 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType 9082 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]); 9083 const element = usePositioner(componentProps, state, { 9084 styles: positioning.positionerStyles, 9085 transitionStatus, 9086 props: elementProps, 9087 refs: [forwardedRef, store3.useStateSetter("positionerElement")], 9088 hidden: !mounted, 9089 inert: !open || trackCursorAxis === "both" || disableHoverablePopup 9090 }); 9091 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipPositionerContext.Provider, { 9092 value: positioning, 9093 children: element 9094 }); 9095 }); 9096 if (true) TooltipPositioner.displayName = "TooltipPositioner"; 9097 9098 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js 9099 var React55 = __toESM(require_react(), 1); 9100 var stateAttributesMapping2 = { 9101 ...popupStateMapping, 9102 ...transitionStatusMapping 9103 }; 9104 var TooltipPopup = /* @__PURE__ */ React55.forwardRef(function TooltipPopup2(componentProps, forwardedRef) { 9105 const { 9106 className, 9107 render: render4, 9108 style, 9109 ...elementProps 9110 } = componentProps; 9111 const store3 = useTooltipRootContext(); 9112 const { 9113 side, 9114 align 9115 } = useTooltipPositionerContext(); 9116 const open = store3.useState("open"); 9117 const instantType = store3.useState("instantType"); 9118 const transitionStatus = store3.useState("transitionStatus"); 9119 const popupProps = store3.useState("popupProps"); 9120 const floatingContext = store3.useState("floatingRootContext"); 9121 useOpenChangeComplete({ 9122 open, 9123 ref: store3.context.popupRef, 9124 onComplete() { 9125 if (open) { 9126 store3.context.onOpenChangeComplete?.(true); 9127 } 9128 } 9129 }); 9130 const disabled2 = store3.useState("disabled"); 9131 const closeDelay = store3.useState("closeDelay"); 9132 useHoverFloatingInteraction(floatingContext, { 9133 enabled: !disabled2, 9134 closeDelay 9135 }); 9136 const state = { 9137 open, 9138 side, 9139 align, 9140 instant: instantType, 9141 transitionStatus 9142 }; 9143 const element = useRenderElement("div", componentProps, { 9144 state, 9145 ref: [forwardedRef, store3.context.popupRef, store3.useStateSetter("popupElement")], 9146 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps], 9147 stateAttributesMapping: stateAttributesMapping2 9148 }); 9149 return element; 9150 }); 9151 if (true) TooltipPopup.displayName = "TooltipPopup"; 9152 9153 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js 9154 var React56 = __toESM(require_react(), 1); 9155 var TooltipArrow = /* @__PURE__ */ React56.forwardRef(function TooltipArrow2(componentProps, forwardedRef) { 9156 const { 9157 className, 9158 render: render4, 9159 style, 9160 ...elementProps 9161 } = componentProps; 9162 const store3 = useTooltipRootContext(); 9163 const open = store3.useState("open"); 9164 const instantType = store3.useState("instantType"); 9165 const { 9166 arrowRef, 9167 side, 9168 align, 9169 arrowUncentered, 9170 arrowStyles 9171 } = useTooltipPositionerContext(); 9172 const state = { 9173 open, 9174 side, 9175 align, 9176 uncentered: arrowUncentered, 9177 instant: instantType 9178 }; 9179 const element = useRenderElement("div", componentProps, { 9180 state, 9181 ref: [forwardedRef, arrowRef], 9182 props: [{ 9183 style: arrowStyles, 9184 "aria-hidden": true 9185 }, elementProps], 9186 stateAttributesMapping: popupStateMapping 9187 }); 9188 return element; 9189 }); 9190 if (true) TooltipArrow.displayName = "TooltipArrow"; 9191 9192 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js 9193 var React57 = __toESM(require_react(), 1); 9194 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); 9195 var TooltipProvider = function TooltipProvider2(props) { 9196 const { 9197 delay, 9198 closeDelay, 9199 timeout = 400 9200 } = props; 9201 const contextValue = React57.useMemo(() => ({ 9202 delay, 9203 closeDelay 9204 }), [delay, closeDelay]); 9205 const delayValue = React57.useMemo(() => ({ 9206 open: delay, 9207 close: closeDelay 9208 }), [delay, closeDelay]); 9209 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipProviderContext.Provider, { 9210 value: contextValue, 9211 children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatingDelayGroup, { 9212 delay: delayValue, 9213 timeoutMs: timeout, 9214 children: props.children 9215 }) 9216 }); 9217 }; 9218 if (true) TooltipProvider.displayName = "TooltipProvider"; 9219 9220 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js 9221 var React58 = __toESM(require_react(), 1); 9222 9223 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js 9224 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) { 9225 TooltipViewportCssVars2["popupWidth"] = "--popup-width"; 9226 TooltipViewportCssVars2["popupHeight"] = "--popup-height"; 9227 return TooltipViewportCssVars2; 9228 })({}); 9229 9230 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js 9231 var stateAttributesMapping3 = { 9232 activationDirection: (value) => value ? { 9233 "data-activation-direction": value 9234 } : null 9235 }; 9236 var TooltipViewport = /* @__PURE__ */ React58.forwardRef(function TooltipViewport2(componentProps, forwardedRef) { 9237 const { 9238 render: render4, 9239 className, 9240 style, 9241 children, 9242 ...elementProps 9243 } = componentProps; 9244 const store3 = useTooltipRootContext(); 9245 const positioner = useTooltipPositionerContext(); 9246 const instantType = store3.useState("instantType"); 9247 const { 9248 children: childrenToRender, 9249 state: viewportState 9250 } = usePopupViewport({ 9251 store: store3, 9252 side: positioner.side, 9253 cssVars: TooltipViewportCssVars, 9254 children 9255 }); 9256 const state = { 9257 activationDirection: viewportState.activationDirection, 9258 transitioning: viewportState.transitioning, 9259 instant: instantType 9260 }; 9261 return useRenderElement("div", componentProps, { 9262 state, 9263 ref: forwardedRef, 9264 props: [elementProps, { 9265 children: childrenToRender 9266 }], 9267 stateAttributesMapping: stateAttributesMapping3 9268 }); 9269 }); 9270 if (true) TooltipViewport.displayName = "TooltipViewport"; 9271 9272 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js 9273 var TooltipHandle = class { 9274 /** 9275 * Internal store holding the tooltip state. 9276 * @internal 9277 */ 9278 constructor() { 9279 this.store = new TooltipStore(); 9280 } 9281 /** 9282 * Opens the tooltip and associates it with the trigger with the given ID. 9283 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop. 9284 * 9285 * This method should only be called in an event handler or an effect (not during rendering). 9286 * 9287 * @param triggerId ID of the trigger to associate with the tooltip. 9288 */ 9289 open(triggerId) { 9290 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0; 9291 if (triggerId && !triggerElement) { 9292 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "$triggerId}".` : formatErrorMessage_default(81, triggerId)); 9293 } 9294 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement)); 9295 } 9296 /** 9297 * Closes the tooltip. 9298 */ 9299 close() { 9300 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0)); 9301 } 9302 /** 9303 * Indicates whether the tooltip is currently open. 9304 */ 9305 get isOpen() { 9306 return this.store.state.open; 9307 } 9308 }; 9309 function createTooltipHandle() { 9310 return new TooltipHandle(); 9311 } 9312 9313 // node_modules/@base-ui/react/esm/use-render/useRender.js 9314 function useRender(params) { 9315 return useRenderElement(params.defaultTagName ?? "div", params, params); 9316 } 9317 9318 // packages/ui/build-module/text/text.mjs 9319 var import_element8 = __toESM(require_element(), 1); 9320 var STYLE_HASH_ATTRIBUTE = "data-wp-hash"; 9321 function getRuntime() { 9322 const globalScope = globalThis; 9323 if (globalScope.__wpStyleRuntime) { 9324 return globalScope.__wpStyleRuntime; 9325 } 9326 globalScope.__wpStyleRuntime = { 9327 documents: /* @__PURE__ */ new Map(), 9328 styles: /* @__PURE__ */ new Map(), 9329 injectedStyles: /* @__PURE__ */ new WeakMap() 9330 }; 9331 if (typeof document !== "undefined") { 9332 registerDocument(document); 9333 } 9334 return globalScope.__wpStyleRuntime; 9335 } 9336 function documentContainsStyleHash(targetDocument, hash) { 9337 if (!targetDocument.head) { 9338 return false; 9339 } 9340 for (const style of targetDocument.head.querySelectorAll( 9341 `style[$STYLE_HASH_ATTRIBUTE}]` 9342 )) { 9343 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) { 9344 return true; 9345 } 9346 } 9347 return false; 9348 } 9349 function injectStyle(targetDocument, hash, css) { 9350 if (!targetDocument.head) { 9351 return; 9352 } 9353 const runtime = getRuntime(); 9354 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9355 if (!injectedStyles) { 9356 injectedStyles = /* @__PURE__ */ new Set(); 9357 runtime.injectedStyles.set(targetDocument, injectedStyles); 9358 } 9359 if (injectedStyles.has(hash)) { 9360 return; 9361 } 9362 if (documentContainsStyleHash(targetDocument, hash)) { 9363 injectedStyles.add(hash); 9364 return; 9365 } 9366 const style = targetDocument.createElement("style"); 9367 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash); 9368 style.appendChild(targetDocument.createTextNode(css)); 9369 targetDocument.head.appendChild(style); 9370 injectedStyles.add(hash); 9371 } 9372 function registerDocument(targetDocument) { 9373 const runtime = getRuntime(); 9374 runtime.documents.set( 9375 targetDocument, 9376 (runtime.documents.get(targetDocument) ?? 0) + 1 9377 ); 9378 for (const [hash, css] of runtime.styles) { 9379 injectStyle(targetDocument, hash, css); 9380 } 9381 return () => { 9382 const count = runtime.documents.get(targetDocument); 9383 if (count === void 0) { 9384 return; 9385 } 9386 if (count <= 1) { 9387 runtime.documents.delete(targetDocument); 9388 return; 9389 } 9390 runtime.documents.set(targetDocument, count - 1); 9391 }; 9392 } 9393 function registerStyle(hash, css) { 9394 const runtime = getRuntime(); 9395 runtime.styles.set(hash, css); 9396 for (const targetDocument of runtime.documents.keys()) { 9397 injectStyle(targetDocument, hash, css); 9398 } 9399 } 9400 if (typeof process === "undefined" || true) { 9401 registerStyle("0c8601dd83", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}'); 9402 } 9403 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" }; 9404 if (typeof process === "undefined" || true) { 9405 registerStyle("1fb29d3a3c", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}"); 9406 } 9407 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" }; 9408 var Text = (0, import_element8.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) { 9409 const element = useRender({ 9410 render: render4, 9411 defaultTagName: "span", 9412 ref, 9413 props: mergeProps(props, { 9414 className: clsx_default( 9415 style_default.text, 9416 global_css_defense_default.heading, 9417 global_css_defense_default.p, 9418 style_default[variant], 9419 className 9420 ) 9421 }) 9422 }); 9423 return element; 9424 }); 9425 9426 // packages/ui/build-module/badge/badge.mjs 9427 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); 9428 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash"; 9429 function getRuntime2() { 9430 const globalScope = globalThis; 9431 if (globalScope.__wpStyleRuntime) { 9432 return globalScope.__wpStyleRuntime; 9433 } 9434 globalScope.__wpStyleRuntime = { 9435 documents: /* @__PURE__ */ new Map(), 9436 styles: /* @__PURE__ */ new Map(), 9437 injectedStyles: /* @__PURE__ */ new WeakMap() 9438 }; 9439 if (typeof document !== "undefined") { 9440 registerDocument2(document); 9441 } 9442 return globalScope.__wpStyleRuntime; 9443 } 9444 function documentContainsStyleHash2(targetDocument, hash) { 9445 if (!targetDocument.head) { 9446 return false; 9447 } 9448 for (const style of targetDocument.head.querySelectorAll( 9449 `style[$STYLE_HASH_ATTRIBUTE2}]` 9450 )) { 9451 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) { 9452 return true; 9453 } 9454 } 9455 return false; 9456 } 9457 function injectStyle2(targetDocument, hash, css) { 9458 if (!targetDocument.head) { 9459 return; 9460 } 9461 const runtime = getRuntime2(); 9462 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9463 if (!injectedStyles) { 9464 injectedStyles = /* @__PURE__ */ new Set(); 9465 runtime.injectedStyles.set(targetDocument, injectedStyles); 9466 } 9467 if (injectedStyles.has(hash)) { 9468 return; 9469 } 9470 if (documentContainsStyleHash2(targetDocument, hash)) { 9471 injectedStyles.add(hash); 9472 return; 9473 } 9474 const style = targetDocument.createElement("style"); 9475 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash); 9476 style.appendChild(targetDocument.createTextNode(css)); 9477 targetDocument.head.appendChild(style); 9478 injectedStyles.add(hash); 9479 } 9480 function registerDocument2(targetDocument) { 9481 const runtime = getRuntime2(); 9482 runtime.documents.set( 9483 targetDocument, 9484 (runtime.documents.get(targetDocument) ?? 0) + 1 9485 ); 9486 for (const [hash, css] of runtime.styles) { 9487 injectStyle2(targetDocument, hash, css); 9488 } 9489 return () => { 9490 const count = runtime.documents.get(targetDocument); 9491 if (count === void 0) { 9492 return; 9493 } 9494 if (count <= 1) { 9495 runtime.documents.delete(targetDocument); 9496 return; 9497 } 9498 runtime.documents.set(targetDocument, count - 1); 9499 }; 9500 } 9501 function registerStyle2(hash, css) { 9502 const runtime = getRuntime2(); 9503 runtime.styles.set(hash, css); 9504 for (const targetDocument of runtime.documents.keys()) { 9505 injectStyle2(targetDocument, hash, css); 9506 } 9507 } 9508 if (typeof process === "undefined" || true) { 9509 registerStyle2("d6a685e1aa", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-bg-surface-error,#f6e6e3);color:var(--wpds-color-fg-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-bg-surface-warning,#fde6be);color:var(--wpds-color-fg-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-bg-surface-caution,#fee995);color:var(--wpds-color-fg-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-bg-surface-success,#c6f7cd);color:var(--wpds-color-fg-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-bg-surface-info,#deebfa);color:var(--wpds-color-fg-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-fg-content-neutral,#1e1e1e);padding-block:calc(var(--wpds-dimension-padding-xs, 4px) - var(--wpds-border-width-xs, 1px));padding-inline:calc(var(--wpds-dimension-padding-sm, 8px) - var(--wpds-border-width-xs, 1px))}}"); 9510 } 9511 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" }; 9512 var Badge = (0, import_element9.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) { 9513 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 9514 Text, 9515 { 9516 ref, 9517 className: clsx_default( 9518 style_default2.badge, 9519 style_default2[`is-$intent}-intent`], 9520 className 9521 ), 9522 ...props, 9523 variant: "body-sm" 9524 } 9525 ); 9526 }); 9527 9528 // packages/ui/build-module/icon/icon.mjs 9529 var import_element10 = __toESM(require_element(), 1); 9530 var import_primitives = __toESM(require_primitives(), 1); 9531 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); 9532 var Icon = (0, import_element10.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) { 9533 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( 9534 import_primitives.SVG, 9535 { 9536 ref, 9537 fill: "currentColor", 9538 ...icon.props, 9539 ...restProps, 9540 width: size4, 9541 height: size4 9542 } 9543 ); 9544 }); 9545 9546 // packages/ui/build-module/card/index.mjs 9547 var card_exports = {}; 9548 __export(card_exports, { 9549 Content: () => Content, 9550 FullBleed: () => FullBleed, 9551 Header: () => Header, 9552 Root: () => Root, 9553 Title: () => Title 9554 }); 9555 9556 // packages/ui/build-module/card/root.mjs 9557 var import_element11 = __toESM(require_element(), 1); 9558 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash"; 9559 function getRuntime3() { 9560 const globalScope = globalThis; 9561 if (globalScope.__wpStyleRuntime) { 9562 return globalScope.__wpStyleRuntime; 9563 } 9564 globalScope.__wpStyleRuntime = { 9565 documents: /* @__PURE__ */ new Map(), 9566 styles: /* @__PURE__ */ new Map(), 9567 injectedStyles: /* @__PURE__ */ new WeakMap() 9568 }; 9569 if (typeof document !== "undefined") { 9570 registerDocument3(document); 9571 } 9572 return globalScope.__wpStyleRuntime; 9573 } 9574 function documentContainsStyleHash3(targetDocument, hash) { 9575 if (!targetDocument.head) { 9576 return false; 9577 } 9578 for (const style of targetDocument.head.querySelectorAll( 9579 `style[$STYLE_HASH_ATTRIBUTE3}]` 9580 )) { 9581 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) { 9582 return true; 9583 } 9584 } 9585 return false; 9586 } 9587 function injectStyle3(targetDocument, hash, css) { 9588 if (!targetDocument.head) { 9589 return; 9590 } 9591 const runtime = getRuntime3(); 9592 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9593 if (!injectedStyles) { 9594 injectedStyles = /* @__PURE__ */ new Set(); 9595 runtime.injectedStyles.set(targetDocument, injectedStyles); 9596 } 9597 if (injectedStyles.has(hash)) { 9598 return; 9599 } 9600 if (documentContainsStyleHash3(targetDocument, hash)) { 9601 injectedStyles.add(hash); 9602 return; 9603 } 9604 const style = targetDocument.createElement("style"); 9605 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash); 9606 style.appendChild(targetDocument.createTextNode(css)); 9607 targetDocument.head.appendChild(style); 9608 injectedStyles.add(hash); 9609 } 9610 function registerDocument3(targetDocument) { 9611 const runtime = getRuntime3(); 9612 runtime.documents.set( 9613 targetDocument, 9614 (runtime.documents.get(targetDocument) ?? 0) + 1 9615 ); 9616 for (const [hash, css] of runtime.styles) { 9617 injectStyle3(targetDocument, hash, css); 9618 } 9619 return () => { 9620 const count = runtime.documents.get(targetDocument); 9621 if (count === void 0) { 9622 return; 9623 } 9624 if (count <= 1) { 9625 runtime.documents.delete(targetDocument); 9626 return; 9627 } 9628 runtime.documents.set(targetDocument, count - 1); 9629 }; 9630 } 9631 function registerStyle3(hash, css) { 9632 const runtime = getRuntime3(); 9633 runtime.styles.set(hash, css); 9634 for (const targetDocument of runtime.documents.keys()) { 9635 injectStyle3(targetDocument, hash, css); 9636 } 9637 } 9638 if (typeof process === "undefined" || true) { 9639 registerStyle3("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}"); 9640 } 9641 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 9642 if (typeof process === "undefined" || true) { 9643 registerStyle3("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}"); 9644 } 9645 var style_default3 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 9646 var Root = (0, import_element11.forwardRef)(function Card({ render: render4, ...restProps }, ref) { 9647 const mergedClassName = clsx_default(style_default3.root, resets_default["box-sizing"]); 9648 const element = useRender({ 9649 defaultTagName: "div", 9650 render: render4, 9651 ref, 9652 props: mergeProps({ className: mergedClassName }, restProps) 9653 }); 9654 return element; 9655 }); 9656 9657 // packages/ui/build-module/card/header.mjs 9658 var import_element12 = __toESM(require_element(), 1); 9659 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash"; 9660 function getRuntime4() { 9661 const globalScope = globalThis; 9662 if (globalScope.__wpStyleRuntime) { 9663 return globalScope.__wpStyleRuntime; 9664 } 9665 globalScope.__wpStyleRuntime = { 9666 documents: /* @__PURE__ */ new Map(), 9667 styles: /* @__PURE__ */ new Map(), 9668 injectedStyles: /* @__PURE__ */ new WeakMap() 9669 }; 9670 if (typeof document !== "undefined") { 9671 registerDocument4(document); 9672 } 9673 return globalScope.__wpStyleRuntime; 9674 } 9675 function documentContainsStyleHash4(targetDocument, hash) { 9676 if (!targetDocument.head) { 9677 return false; 9678 } 9679 for (const style of targetDocument.head.querySelectorAll( 9680 `style[$STYLE_HASH_ATTRIBUTE4}]` 9681 )) { 9682 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) { 9683 return true; 9684 } 9685 } 9686 return false; 9687 } 9688 function injectStyle4(targetDocument, hash, css) { 9689 if (!targetDocument.head) { 9690 return; 9691 } 9692 const runtime = getRuntime4(); 9693 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9694 if (!injectedStyles) { 9695 injectedStyles = /* @__PURE__ */ new Set(); 9696 runtime.injectedStyles.set(targetDocument, injectedStyles); 9697 } 9698 if (injectedStyles.has(hash)) { 9699 return; 9700 } 9701 if (documentContainsStyleHash4(targetDocument, hash)) { 9702 injectedStyles.add(hash); 9703 return; 9704 } 9705 const style = targetDocument.createElement("style"); 9706 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash); 9707 style.appendChild(targetDocument.createTextNode(css)); 9708 targetDocument.head.appendChild(style); 9709 injectedStyles.add(hash); 9710 } 9711 function registerDocument4(targetDocument) { 9712 const runtime = getRuntime4(); 9713 runtime.documents.set( 9714 targetDocument, 9715 (runtime.documents.get(targetDocument) ?? 0) + 1 9716 ); 9717 for (const [hash, css] of runtime.styles) { 9718 injectStyle4(targetDocument, hash, css); 9719 } 9720 return () => { 9721 const count = runtime.documents.get(targetDocument); 9722 if (count === void 0) { 9723 return; 9724 } 9725 if (count <= 1) { 9726 runtime.documents.delete(targetDocument); 9727 return; 9728 } 9729 runtime.documents.set(targetDocument, count - 1); 9730 }; 9731 } 9732 function registerStyle4(hash, css) { 9733 const runtime = getRuntime4(); 9734 runtime.styles.set(hash, css); 9735 for (const targetDocument of runtime.documents.keys()) { 9736 injectStyle4(targetDocument, hash, css); 9737 } 9738 } 9739 if (typeof process === "undefined" || true) { 9740 registerStyle4("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}"); 9741 } 9742 var style_default4 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 9743 var Header = (0, import_element12.forwardRef)( 9744 function CardHeader({ render: render4, ...props }, ref) { 9745 const element = useRender({ 9746 defaultTagName: "div", 9747 render: render4, 9748 ref, 9749 props: mergeProps({ className: style_default4.header }, props) 9750 }); 9751 return element; 9752 } 9753 ); 9754 9755 // packages/ui/build-module/card/content.mjs 9756 var import_element13 = __toESM(require_element(), 1); 9757 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash"; 9758 function getRuntime5() { 9759 const globalScope = globalThis; 9760 if (globalScope.__wpStyleRuntime) { 9761 return globalScope.__wpStyleRuntime; 9762 } 9763 globalScope.__wpStyleRuntime = { 9764 documents: /* @__PURE__ */ new Map(), 9765 styles: /* @__PURE__ */ new Map(), 9766 injectedStyles: /* @__PURE__ */ new WeakMap() 9767 }; 9768 if (typeof document !== "undefined") { 9769 registerDocument5(document); 9770 } 9771 return globalScope.__wpStyleRuntime; 9772 } 9773 function documentContainsStyleHash5(targetDocument, hash) { 9774 if (!targetDocument.head) { 9775 return false; 9776 } 9777 for (const style of targetDocument.head.querySelectorAll( 9778 `style[$STYLE_HASH_ATTRIBUTE5}]` 9779 )) { 9780 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) { 9781 return true; 9782 } 9783 } 9784 return false; 9785 } 9786 function injectStyle5(targetDocument, hash, css) { 9787 if (!targetDocument.head) { 9788 return; 9789 } 9790 const runtime = getRuntime5(); 9791 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9792 if (!injectedStyles) { 9793 injectedStyles = /* @__PURE__ */ new Set(); 9794 runtime.injectedStyles.set(targetDocument, injectedStyles); 9795 } 9796 if (injectedStyles.has(hash)) { 9797 return; 9798 } 9799 if (documentContainsStyleHash5(targetDocument, hash)) { 9800 injectedStyles.add(hash); 9801 return; 9802 } 9803 const style = targetDocument.createElement("style"); 9804 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash); 9805 style.appendChild(targetDocument.createTextNode(css)); 9806 targetDocument.head.appendChild(style); 9807 injectedStyles.add(hash); 9808 } 9809 function registerDocument5(targetDocument) { 9810 const runtime = getRuntime5(); 9811 runtime.documents.set( 9812 targetDocument, 9813 (runtime.documents.get(targetDocument) ?? 0) + 1 9814 ); 9815 for (const [hash, css] of runtime.styles) { 9816 injectStyle5(targetDocument, hash, css); 9817 } 9818 return () => { 9819 const count = runtime.documents.get(targetDocument); 9820 if (count === void 0) { 9821 return; 9822 } 9823 if (count <= 1) { 9824 runtime.documents.delete(targetDocument); 9825 return; 9826 } 9827 runtime.documents.set(targetDocument, count - 1); 9828 }; 9829 } 9830 function registerStyle5(hash, css) { 9831 const runtime = getRuntime5(); 9832 runtime.styles.set(hash, css); 9833 for (const targetDocument of runtime.documents.keys()) { 9834 injectStyle5(targetDocument, hash, css); 9835 } 9836 } 9837 if (typeof process === "undefined" || true) { 9838 registerStyle5("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}"); 9839 } 9840 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 9841 var Content = (0, import_element13.forwardRef)( 9842 function CardContent({ render: render4, ...props }, ref) { 9843 const element = useRender({ 9844 defaultTagName: "div", 9845 render: render4, 9846 ref, 9847 props: mergeProps({ className: style_default5.content }, props) 9848 }); 9849 return element; 9850 } 9851 ); 9852 9853 // packages/ui/build-module/card/full-bleed.mjs 9854 var import_element14 = __toESM(require_element(), 1); 9855 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash"; 9856 function getRuntime6() { 9857 const globalScope = globalThis; 9858 if (globalScope.__wpStyleRuntime) { 9859 return globalScope.__wpStyleRuntime; 9860 } 9861 globalScope.__wpStyleRuntime = { 9862 documents: /* @__PURE__ */ new Map(), 9863 styles: /* @__PURE__ */ new Map(), 9864 injectedStyles: /* @__PURE__ */ new WeakMap() 9865 }; 9866 if (typeof document !== "undefined") { 9867 registerDocument6(document); 9868 } 9869 return globalScope.__wpStyleRuntime; 9870 } 9871 function documentContainsStyleHash6(targetDocument, hash) { 9872 if (!targetDocument.head) { 9873 return false; 9874 } 9875 for (const style of targetDocument.head.querySelectorAll( 9876 `style[$STYLE_HASH_ATTRIBUTE6}]` 9877 )) { 9878 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) { 9879 return true; 9880 } 9881 } 9882 return false; 9883 } 9884 function injectStyle6(targetDocument, hash, css) { 9885 if (!targetDocument.head) { 9886 return; 9887 } 9888 const runtime = getRuntime6(); 9889 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9890 if (!injectedStyles) { 9891 injectedStyles = /* @__PURE__ */ new Set(); 9892 runtime.injectedStyles.set(targetDocument, injectedStyles); 9893 } 9894 if (injectedStyles.has(hash)) { 9895 return; 9896 } 9897 if (documentContainsStyleHash6(targetDocument, hash)) { 9898 injectedStyles.add(hash); 9899 return; 9900 } 9901 const style = targetDocument.createElement("style"); 9902 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash); 9903 style.appendChild(targetDocument.createTextNode(css)); 9904 targetDocument.head.appendChild(style); 9905 injectedStyles.add(hash); 9906 } 9907 function registerDocument6(targetDocument) { 9908 const runtime = getRuntime6(); 9909 runtime.documents.set( 9910 targetDocument, 9911 (runtime.documents.get(targetDocument) ?? 0) + 1 9912 ); 9913 for (const [hash, css] of runtime.styles) { 9914 injectStyle6(targetDocument, hash, css); 9915 } 9916 return () => { 9917 const count = runtime.documents.get(targetDocument); 9918 if (count === void 0) { 9919 return; 9920 } 9921 if (count <= 1) { 9922 runtime.documents.delete(targetDocument); 9923 return; 9924 } 9925 runtime.documents.set(targetDocument, count - 1); 9926 }; 9927 } 9928 function registerStyle6(hash, css) { 9929 const runtime = getRuntime6(); 9930 runtime.styles.set(hash, css); 9931 for (const targetDocument of runtime.documents.keys()) { 9932 injectStyle6(targetDocument, hash, css); 9933 } 9934 } 9935 if (typeof process === "undefined" || true) { 9936 registerStyle6("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}"); 9937 } 9938 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 9939 var FullBleed = (0, import_element14.forwardRef)( 9940 function CardFullBleed({ render: render4, ...props }, ref) { 9941 const element = useRender({ 9942 defaultTagName: "div", 9943 render: render4, 9944 ref, 9945 props: mergeProps( 9946 { className: style_default6.fullbleed }, 9947 props 9948 ) 9949 }); 9950 return element; 9951 } 9952 ); 9953 9954 // packages/ui/build-module/card/title.mjs 9955 var import_element15 = __toESM(require_element(), 1); 9956 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); 9957 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", {}); 9958 var Title = (0, import_element15.forwardRef)( 9959 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) { 9960 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 9961 Text, 9962 { 9963 ref, 9964 variant: "heading-lg", 9965 render: render4, 9966 ...props, 9967 children 9968 } 9969 ); 9970 } 9971 ); 9972 9973 // packages/ui/build-module/collapsible/panel.mjs 9974 var import_element16 = __toESM(require_element(), 1); 9975 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); 9976 var Panel = (0, import_element16.forwardRef)( 9977 function CollapsiblePanel3(props, forwardedRef) { 9978 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props }); 9979 } 9980 ); 9981 9982 // packages/ui/build-module/collapsible/root.mjs 9983 var import_element17 = __toESM(require_element(), 1); 9984 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); 9985 var Root2 = (0, import_element17.forwardRef)( 9986 function CollapsibleRoot3(props, forwardedRef) { 9987 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props }); 9988 } 9989 ); 9990 9991 // packages/ui/build-module/collapsible/trigger.mjs 9992 var import_element18 = __toESM(require_element(), 1); 9993 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); 9994 var Trigger = (0, import_element18.forwardRef)( 9995 function CollapsibleTrigger3(props, forwardedRef) { 9996 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props }); 9997 } 9998 ); 9999 10000 // packages/ui/build-module/collapsible-card/index.mjs 10001 var collapsible_card_exports = {}; 10002 __export(collapsible_card_exports, { 10003 Content: () => Content2, 10004 Header: () => Header2, 10005 HeaderDescription: () => HeaderDescription, 10006 Root: () => Root3 10007 }); 10008 10009 // packages/ui/build-module/collapsible-card/root.mjs 10010 var import_element19 = __toESM(require_element(), 1); 10011 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); 10012 var Root3 = (0, import_element19.forwardRef)( 10013 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) { 10014 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)( 10015 Root2, 10016 { 10017 ref, 10018 render: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Root, { render: render4 }), 10019 ...restProps 10020 } 10021 ); 10022 } 10023 ); 10024 10025 // packages/ui/build-module/collapsible-card/header.mjs 10026 var import_element21 = __toESM(require_element(), 1); 10027 10028 // packages/icons/build-module/library/check.mjs 10029 var import_primitives2 = __toESM(require_primitives(), 1); 10030 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); 10031 var check_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives2.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 10032 10033 // packages/icons/build-module/library/chevron-down.mjs 10034 var import_primitives3 = __toESM(require_primitives(), 1); 10035 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); 10036 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives3.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) }); 10037 10038 // packages/icons/build-module/library/close-small.mjs 10039 var import_primitives4 = __toESM(require_primitives(), 1); 10040 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); 10041 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives4.Path, { d: "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" }) }); 10042 10043 // packages/icons/build-module/library/close.mjs 10044 var import_primitives5 = __toESM(require_primitives(), 1); 10045 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); 10046 var close_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives5.Path, { d: "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" }) }); 10047 10048 // packages/icons/build-module/library/drawer-right.mjs 10049 var import_primitives6 = __toESM(require_primitives(), 1); 10050 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); 10051 var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives6.Path, { 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" }) }); 10052 10053 // packages/icons/build-module/library/envelope.mjs 10054 var import_primitives7 = __toESM(require_primitives(), 1); 10055 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); 10056 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives7.Path, { 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" }) }); 10057 10058 // packages/icons/build-module/library/error.mjs 10059 var import_primitives8 = __toESM(require_primitives(), 1); 10060 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); 10061 var error_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives8.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) }); 10062 10063 // packages/icons/build-module/library/flip-horizontal.mjs 10064 var import_primitives9 = __toESM(require_primitives(), 1); 10065 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); 10066 var flip_horizontal_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives9.Path, { d: "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" }) }); 10067 10068 // packages/icons/build-module/library/flip-vertical.mjs 10069 var import_primitives10 = __toESM(require_primitives(), 1); 10070 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); 10071 var flip_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives10.Path, { d: "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" }) }); 10072 10073 // packages/icons/build-module/library/keyboard.mjs 10074 var import_primitives11 = __toESM(require_primitives(), 1); 10075 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); 10076 var keyboard_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10077 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives11.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" }), 10078 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives11.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" }) 10079 ] }); 10080 10081 // packages/icons/build-module/library/link.mjs 10082 var import_primitives12 = __toESM(require_primitives(), 1); 10083 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); 10084 var link_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives12.Path, { d: "M10 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" }) }); 10085 10086 // packages/icons/build-module/library/mobile.mjs 10087 var import_primitives13 = __toESM(require_primitives(), 1); 10088 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); 10089 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives13.Path, { d: "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" }) }); 10090 10091 // packages/icons/build-module/library/pencil.mjs 10092 var import_primitives14 = __toESM(require_primitives(), 1); 10093 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); 10094 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives14.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) }); 10095 10096 // packages/icons/build-module/library/redo.mjs 10097 var import_primitives15 = __toESM(require_primitives(), 1); 10098 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1); 10099 var redo_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives15.Path, { 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" }) }); 10100 10101 // packages/icons/build-module/library/rotate-left.mjs 10102 var import_primitives16 = __toESM(require_primitives(), 1); 10103 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1); 10104 var rotate_left_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives16.Path, { 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" }) }); 10105 10106 // packages/icons/build-module/library/rotate-right.mjs 10107 var import_primitives17 = __toESM(require_primitives(), 1); 10108 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1); 10109 var rotate_right_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives17.Path, { d: "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" }) }); 10110 10111 // packages/icons/build-module/library/seen.mjs 10112 var import_primitives18 = __toESM(require_primitives(), 1); 10113 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1); 10114 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives18.Path, { d: "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" }) }); 10115 10116 // packages/icons/build-module/library/star-empty.mjs 10117 var import_primitives19 = __toESM(require_primitives(), 1); 10118 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1); 10119 var star_empty_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives19.Path, { 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" }) }); 10120 10121 // packages/icons/build-module/library/star-filled.mjs 10122 var import_primitives20 = __toESM(require_primitives(), 1); 10123 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1); 10124 var star_filled_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives20.Path, { d: "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" }) }); 10125 10126 // packages/icons/build-module/library/undo.mjs 10127 var import_primitives21 = __toESM(require_primitives(), 1); 10128 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1); 10129 var undo_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives21.Path, { d: "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" }) }); 10130 10131 // packages/icons/build-module/library/unseen.mjs 10132 var import_primitives22 = __toESM(require_primitives(), 1); 10133 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1); 10134 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives22.Path, { d: "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" }) }); 10135 10136 // packages/ui/build-module/collapsible-card/context.mjs 10137 var import_element20 = __toESM(require_element(), 1); 10138 var HeaderDescriptionIdContext = (0, import_element20.createContext)({ 10139 setDescriptionId: () => { 10140 } 10141 }); 10142 10143 // packages/ui/build-module/collapsible-card/header.mjs 10144 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1); 10145 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash"; 10146 function getRuntime7() { 10147 const globalScope = globalThis; 10148 if (globalScope.__wpStyleRuntime) { 10149 return globalScope.__wpStyleRuntime; 10150 } 10151 globalScope.__wpStyleRuntime = { 10152 documents: /* @__PURE__ */ new Map(), 10153 styles: /* @__PURE__ */ new Map(), 10154 injectedStyles: /* @__PURE__ */ new WeakMap() 10155 }; 10156 if (typeof document !== "undefined") { 10157 registerDocument7(document); 10158 } 10159 return globalScope.__wpStyleRuntime; 10160 } 10161 function documentContainsStyleHash7(targetDocument, hash) { 10162 if (!targetDocument.head) { 10163 return false; 10164 } 10165 for (const style of targetDocument.head.querySelectorAll( 10166 `style[$STYLE_HASH_ATTRIBUTE7}]` 10167 )) { 10168 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) { 10169 return true; 10170 } 10171 } 10172 return false; 10173 } 10174 function injectStyle7(targetDocument, hash, css) { 10175 if (!targetDocument.head) { 10176 return; 10177 } 10178 const runtime = getRuntime7(); 10179 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10180 if (!injectedStyles) { 10181 injectedStyles = /* @__PURE__ */ new Set(); 10182 runtime.injectedStyles.set(targetDocument, injectedStyles); 10183 } 10184 if (injectedStyles.has(hash)) { 10185 return; 10186 } 10187 if (documentContainsStyleHash7(targetDocument, hash)) { 10188 injectedStyles.add(hash); 10189 return; 10190 } 10191 const style = targetDocument.createElement("style"); 10192 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash); 10193 style.appendChild(targetDocument.createTextNode(css)); 10194 targetDocument.head.appendChild(style); 10195 injectedStyles.add(hash); 10196 } 10197 function registerDocument7(targetDocument) { 10198 const runtime = getRuntime7(); 10199 runtime.documents.set( 10200 targetDocument, 10201 (runtime.documents.get(targetDocument) ?? 0) + 1 10202 ); 10203 for (const [hash, css] of runtime.styles) { 10204 injectStyle7(targetDocument, hash, css); 10205 } 10206 return () => { 10207 const count = runtime.documents.get(targetDocument); 10208 if (count === void 0) { 10209 return; 10210 } 10211 if (count <= 1) { 10212 runtime.documents.delete(targetDocument); 10213 return; 10214 } 10215 runtime.documents.set(targetDocument, count - 1); 10216 }; 10217 } 10218 function registerStyle7(hash, css) { 10219 const runtime = getRuntime7(); 10220 runtime.styles.set(hash, css); 10221 for (const targetDocument of runtime.documents.keys()) { 10222 injectStyle7(targetDocument, hash, css); 10223 } 10224 } 10225 if (typeof process === "undefined" || true) { 10226 registerStyle7("f1b9bb6252", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}"); 10227 } 10228 var style_default7 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" }; 10229 if (typeof process === "undefined" || true) { 10230 registerStyle7("1fb29d3a3c", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}"); 10231 } 10232 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" }; 10233 if (typeof process === "undefined" || true) { 10234 registerStyle7("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}"); 10235 } 10236 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" }; 10237 var Header2 = (0, import_element21.forwardRef)( 10238 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) { 10239 const [descriptionId, setDescriptionId] = (0, import_element21.useState)(); 10240 const contextValue = (0, import_element21.useMemo)( 10241 () => ({ setDescriptionId }), 10242 [setDescriptionId] 10243 ); 10244 return useRender({ 10245 defaultTagName: "div", 10246 render: render4, 10247 ref, 10248 props: mergeProps(restProps, { 10249 className: clsx_default( 10250 global_css_defense_default2.heading, 10251 style_default7["heading-wrapper"], 10252 className 10253 ), 10254 children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)( 10255 Trigger, 10256 { 10257 className: style_default7.header, 10258 render: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Header, {}), 10259 nativeButton: false, 10260 "aria-describedby": descriptionId, 10261 children: [ 10262 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: style_default7["header-content"], children }), 10263 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 10264 "div", 10265 { 10266 className: clsx_default( 10267 style_default7["header-trigger-positioner"] 10268 ), 10269 children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 10270 "div", 10271 { 10272 className: clsx_default( 10273 style_default7["header-trigger-wrapper"], 10274 global_css_defense_default2.div, 10275 // While the interactive trigger element is the whole header, 10276 // the focus ring will be displayed only on the icon to visually 10277 // emulate it being the button. 10278 focus_default["outset-ring--focus-parent-visible"] 10279 ), 10280 children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 10281 Icon, 10282 { 10283 icon: chevron_down_default, 10284 className: style_default7["header-trigger"] 10285 } 10286 ) 10287 } 10288 ) 10289 } 10290 ) 10291 ] 10292 } 10293 ) }) 10294 }) 10295 }); 10296 } 10297 ); 10298 10299 // packages/ui/build-module/collapsible-card/header-description.mjs 10300 var import_element22 = __toESM(require_element(), 1); 10301 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1); 10302 var HeaderDescription = (0, import_element22.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) { 10303 const descriptionId = (0, import_element22.useId)(); 10304 const { setDescriptionId } = (0, import_element22.useContext)(HeaderDescriptionIdContext); 10305 (0, import_element22.useEffect)(() => { 10306 setDescriptionId(descriptionId); 10307 return () => setDescriptionId(void 0); 10308 }, [descriptionId, setDescriptionId]); 10309 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 10310 "div", 10311 { 10312 ref, 10313 id: descriptionId, 10314 "aria-hidden": "true", 10315 className, 10316 ...restProps, 10317 children 10318 } 10319 ); 10320 }); 10321 10322 // packages/ui/build-module/collapsible-card/content.mjs 10323 var import_element23 = __toESM(require_element(), 1); 10324 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1); 10325 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash"; 10326 function getRuntime8() { 10327 const globalScope = globalThis; 10328 if (globalScope.__wpStyleRuntime) { 10329 return globalScope.__wpStyleRuntime; 10330 } 10331 globalScope.__wpStyleRuntime = { 10332 documents: /* @__PURE__ */ new Map(), 10333 styles: /* @__PURE__ */ new Map(), 10334 injectedStyles: /* @__PURE__ */ new WeakMap() 10335 }; 10336 if (typeof document !== "undefined") { 10337 registerDocument8(document); 10338 } 10339 return globalScope.__wpStyleRuntime; 10340 } 10341 function documentContainsStyleHash8(targetDocument, hash) { 10342 if (!targetDocument.head) { 10343 return false; 10344 } 10345 for (const style of targetDocument.head.querySelectorAll( 10346 `style[$STYLE_HASH_ATTRIBUTE8}]` 10347 )) { 10348 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) { 10349 return true; 10350 } 10351 } 10352 return false; 10353 } 10354 function injectStyle8(targetDocument, hash, css) { 10355 if (!targetDocument.head) { 10356 return; 10357 } 10358 const runtime = getRuntime8(); 10359 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10360 if (!injectedStyles) { 10361 injectedStyles = /* @__PURE__ */ new Set(); 10362 runtime.injectedStyles.set(targetDocument, injectedStyles); 10363 } 10364 if (injectedStyles.has(hash)) { 10365 return; 10366 } 10367 if (documentContainsStyleHash8(targetDocument, hash)) { 10368 injectedStyles.add(hash); 10369 return; 10370 } 10371 const style = targetDocument.createElement("style"); 10372 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash); 10373 style.appendChild(targetDocument.createTextNode(css)); 10374 targetDocument.head.appendChild(style); 10375 injectedStyles.add(hash); 10376 } 10377 function registerDocument8(targetDocument) { 10378 const runtime = getRuntime8(); 10379 runtime.documents.set( 10380 targetDocument, 10381 (runtime.documents.get(targetDocument) ?? 0) + 1 10382 ); 10383 for (const [hash, css] of runtime.styles) { 10384 injectStyle8(targetDocument, hash, css); 10385 } 10386 return () => { 10387 const count = runtime.documents.get(targetDocument); 10388 if (count === void 0) { 10389 return; 10390 } 10391 if (count <= 1) { 10392 runtime.documents.delete(targetDocument); 10393 return; 10394 } 10395 runtime.documents.set(targetDocument, count - 1); 10396 }; 10397 } 10398 function registerStyle8(hash, css) { 10399 const runtime = getRuntime8(); 10400 runtime.styles.set(hash, css); 10401 for (const targetDocument of runtime.documents.keys()) { 10402 injectStyle8(targetDocument, hash, css); 10403 } 10404 } 10405 if (typeof process === "undefined" || true) { 10406 registerStyle8("f1b9bb6252", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}"); 10407 } 10408 var style_default8 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" }; 10409 var Content2 = (0, import_element23.forwardRef)( 10410 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) { 10411 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 10412 Panel, 10413 { 10414 ref, 10415 className: (state) => clsx_default( 10416 style_default8.content, 10417 state.open && state.transitionStatus === "idle" && style_default8.overflowVisible, 10418 className 10419 ), 10420 hiddenUntilFound, 10421 ...restProps, 10422 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 10423 Content, 10424 { 10425 className: style_default8["content-inner"], 10426 render: render4, 10427 children 10428 } 10429 ) 10430 } 10431 ); 10432 } 10433 ); 10434 10435 // packages/ui/build-module/utils/render-slot-with-children.mjs 10436 var import_element24 = __toESM(require_element(), 1); 10437 function renderSlotWithChildren(slot, defaultSlot, children) { 10438 return (0, import_element24.cloneElement)( 10439 slot ?? defaultSlot, 10440 { children } 10441 ); 10442 } 10443 10444 // packages/ui/build-module/lock-unlock.mjs 10445 var import_private_apis = __toESM(require_private_apis(), 1); 10446 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 10447 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 10448 "@wordpress/ui" 10449 ); 10450 10451 // packages/ui/build-module/stack/stack.mjs 10452 var import_element25 = __toESM(require_element(), 1); 10453 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash"; 10454 function getRuntime9() { 10455 const globalScope = globalThis; 10456 if (globalScope.__wpStyleRuntime) { 10457 return globalScope.__wpStyleRuntime; 10458 } 10459 globalScope.__wpStyleRuntime = { 10460 documents: /* @__PURE__ */ new Map(), 10461 styles: /* @__PURE__ */ new Map(), 10462 injectedStyles: /* @__PURE__ */ new WeakMap() 10463 }; 10464 if (typeof document !== "undefined") { 10465 registerDocument9(document); 10466 } 10467 return globalScope.__wpStyleRuntime; 10468 } 10469 function documentContainsStyleHash9(targetDocument, hash) { 10470 if (!targetDocument.head) { 10471 return false; 10472 } 10473 for (const style of targetDocument.head.querySelectorAll( 10474 `style[$STYLE_HASH_ATTRIBUTE9}]` 10475 )) { 10476 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) { 10477 return true; 10478 } 10479 } 10480 return false; 10481 } 10482 function injectStyle9(targetDocument, hash, css) { 10483 if (!targetDocument.head) { 10484 return; 10485 } 10486 const runtime = getRuntime9(); 10487 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10488 if (!injectedStyles) { 10489 injectedStyles = /* @__PURE__ */ new Set(); 10490 runtime.injectedStyles.set(targetDocument, injectedStyles); 10491 } 10492 if (injectedStyles.has(hash)) { 10493 return; 10494 } 10495 if (documentContainsStyleHash9(targetDocument, hash)) { 10496 injectedStyles.add(hash); 10497 return; 10498 } 10499 const style = targetDocument.createElement("style"); 10500 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash); 10501 style.appendChild(targetDocument.createTextNode(css)); 10502 targetDocument.head.appendChild(style); 10503 injectedStyles.add(hash); 10504 } 10505 function registerDocument9(targetDocument) { 10506 const runtime = getRuntime9(); 10507 runtime.documents.set( 10508 targetDocument, 10509 (runtime.documents.get(targetDocument) ?? 0) + 1 10510 ); 10511 for (const [hash, css] of runtime.styles) { 10512 injectStyle9(targetDocument, hash, css); 10513 } 10514 return () => { 10515 const count = runtime.documents.get(targetDocument); 10516 if (count === void 0) { 10517 return; 10518 } 10519 if (count <= 1) { 10520 runtime.documents.delete(targetDocument); 10521 return; 10522 } 10523 runtime.documents.set(targetDocument, count - 1); 10524 }; 10525 } 10526 function registerStyle9(hash, css) { 10527 const runtime = getRuntime9(); 10528 runtime.styles.set(hash, css); 10529 for (const targetDocument of runtime.documents.keys()) { 10530 injectStyle9(targetDocument, hash, css); 10531 } 10532 } 10533 if (typeof process === "undefined" || true) { 10534 registerStyle9("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}"); 10535 } 10536 var style_default9 = { "stack": "_19ce0419607e1896__stack" }; 10537 var gapTokens = { 10538 xs: "var(--wpds-dimension-gap-xs, 4px)", 10539 sm: "var(--wpds-dimension-gap-sm, 8px)", 10540 md: "var(--wpds-dimension-gap-md, 12px)", 10541 lg: "var(--wpds-dimension-gap-lg, 16px)", 10542 xl: "var(--wpds-dimension-gap-xl, 24px)", 10543 "2xl": "var(--wpds-dimension-gap-2xl, 32px)", 10544 "3xl": "var(--wpds-dimension-gap-3xl, 40px)" 10545 }; 10546 var Stack = (0, import_element25.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) { 10547 const style = { 10548 gap: gap && gapTokens[gap], 10549 alignItems: align, 10550 justifyContent: justify, 10551 flexDirection: direction, 10552 flexWrap: wrap 10553 }; 10554 const element = useRender({ 10555 render: render4, 10556 ref, 10557 props: mergeProps(props, { style, className: style_default9.stack }) 10558 }); 10559 return element; 10560 }); 10561 10562 // packages/ui/build-module/tooltip/index.mjs 10563 var tooltip_exports = {}; 10564 __export(tooltip_exports, { 10565 Popup: () => Popup, 10566 Portal: () => Portal, 10567 Positioner: () => Positioner, 10568 Provider: () => Provider, 10569 Root: () => Root4, 10570 Trigger: () => Trigger2 10571 }); 10572 10573 // packages/ui/build-module/tooltip/popup.mjs 10574 var import_element28 = __toESM(require_element(), 1); 10575 var import_theme = __toESM(require_theme(), 1); 10576 10577 // packages/ui/build-module/tooltip/portal.mjs 10578 var import_element26 = __toESM(require_element(), 1); 10579 10580 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs 10581 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash"; 10582 function getRuntime10() { 10583 const globalScope = globalThis; 10584 if (globalScope.__wpStyleRuntime) { 10585 return globalScope.__wpStyleRuntime; 10586 } 10587 globalScope.__wpStyleRuntime = { 10588 documents: /* @__PURE__ */ new Map(), 10589 styles: /* @__PURE__ */ new Map(), 10590 injectedStyles: /* @__PURE__ */ new WeakMap() 10591 }; 10592 if (typeof document !== "undefined") { 10593 registerDocument10(document); 10594 } 10595 return globalScope.__wpStyleRuntime; 10596 } 10597 function documentContainsStyleHash10(targetDocument, hash) { 10598 if (!targetDocument.head) { 10599 return false; 10600 } 10601 for (const style of targetDocument.head.querySelectorAll( 10602 `style[$STYLE_HASH_ATTRIBUTE10}]` 10603 )) { 10604 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) { 10605 return true; 10606 } 10607 } 10608 return false; 10609 } 10610 function injectStyle10(targetDocument, hash, css) { 10611 if (!targetDocument.head) { 10612 return; 10613 } 10614 const runtime = getRuntime10(); 10615 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10616 if (!injectedStyles) { 10617 injectedStyles = /* @__PURE__ */ new Set(); 10618 runtime.injectedStyles.set(targetDocument, injectedStyles); 10619 } 10620 if (injectedStyles.has(hash)) { 10621 return; 10622 } 10623 if (documentContainsStyleHash10(targetDocument, hash)) { 10624 injectedStyles.add(hash); 10625 return; 10626 } 10627 const style = targetDocument.createElement("style"); 10628 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash); 10629 style.appendChild(targetDocument.createTextNode(css)); 10630 targetDocument.head.appendChild(style); 10631 injectedStyles.add(hash); 10632 } 10633 function registerDocument10(targetDocument) { 10634 const runtime = getRuntime10(); 10635 runtime.documents.set( 10636 targetDocument, 10637 (runtime.documents.get(targetDocument) ?? 0) + 1 10638 ); 10639 for (const [hash, css] of runtime.styles) { 10640 injectStyle10(targetDocument, hash, css); 10641 } 10642 return () => { 10643 const count = runtime.documents.get(targetDocument); 10644 if (count === void 0) { 10645 return; 10646 } 10647 if (count <= 1) { 10648 runtime.documents.delete(targetDocument); 10649 return; 10650 } 10651 runtime.documents.set(targetDocument, count - 1); 10652 }; 10653 } 10654 function registerStyle10(hash, css) { 10655 const runtime = getRuntime10(); 10656 runtime.styles.set(hash, css); 10657 for (const targetDocument of runtime.documents.keys()) { 10658 injectStyle10(targetDocument, hash, css); 10659 } 10660 } 10661 if (typeof process === "undefined" || true) { 10662 registerStyle10("45eb1fe20f", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui-utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}"); 10663 } 10664 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" }; 10665 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot"; 10666 function resolveOwnerDocument() { 10667 return typeof document === "undefined" ? null : document; 10668 } 10669 function isInWordPressEnvironment() { 10670 let topWp; 10671 try { 10672 topWp = window.top?.wp; 10673 } catch { 10674 } 10675 const wp = topWp ?? window.wp; 10676 return typeof wp?.components === "object" && wp.components !== null; 10677 } 10678 var cachedSlot = null; 10679 function createSlot(ownerDocument2) { 10680 const element = ownerDocument2.createElement("div"); 10681 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, ""); 10682 if (wp_compat_overlay_slot_default.slot) { 10683 element.classList.add(wp_compat_overlay_slot_default.slot); 10684 } 10685 ownerDocument2.body.appendChild(element); 10686 return element; 10687 } 10688 function getWpCompatOverlaySlot() { 10689 if (typeof window === "undefined") { 10690 return void 0; 10691 } 10692 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) { 10693 return void 0; 10694 } 10695 const ownerDocument2 = resolveOwnerDocument(); 10696 if (!ownerDocument2 || !ownerDocument2.body) { 10697 return void 0; 10698 } 10699 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) { 10700 return cachedSlot; 10701 } 10702 const existing = ownerDocument2.querySelector( 10703 `[$WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]` 10704 ); 10705 if (existing instanceof HTMLDivElement) { 10706 cachedSlot = existing; 10707 return existing; 10708 } 10709 if (cachedSlot?.isConnected) { 10710 cachedSlot.remove(); 10711 } 10712 cachedSlot = createSlot(ownerDocument2); 10713 return cachedSlot; 10714 } 10715 10716 // packages/ui/build-module/tooltip/portal.mjs 10717 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1); 10718 var Portal = (0, import_element26.forwardRef)( 10719 function TooltipPortal3({ container, ...restProps }, ref) { 10720 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 10721 index_parts_exports2.Portal, 10722 { 10723 container: container ?? getWpCompatOverlaySlot(), 10724 ...restProps, 10725 ref 10726 } 10727 ); 10728 } 10729 ); 10730 10731 // packages/ui/build-module/tooltip/positioner.mjs 10732 var import_element27 = __toESM(require_element(), 1); 10733 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1); 10734 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash"; 10735 function getRuntime11() { 10736 const globalScope = globalThis; 10737 if (globalScope.__wpStyleRuntime) { 10738 return globalScope.__wpStyleRuntime; 10739 } 10740 globalScope.__wpStyleRuntime = { 10741 documents: /* @__PURE__ */ new Map(), 10742 styles: /* @__PURE__ */ new Map(), 10743 injectedStyles: /* @__PURE__ */ new WeakMap() 10744 }; 10745 if (typeof document !== "undefined") { 10746 registerDocument11(document); 10747 } 10748 return globalScope.__wpStyleRuntime; 10749 } 10750 function documentContainsStyleHash11(targetDocument, hash) { 10751 if (!targetDocument.head) { 10752 return false; 10753 } 10754 for (const style of targetDocument.head.querySelectorAll( 10755 `style[$STYLE_HASH_ATTRIBUTE11}]` 10756 )) { 10757 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) { 10758 return true; 10759 } 10760 } 10761 return false; 10762 } 10763 function injectStyle11(targetDocument, hash, css) { 10764 if (!targetDocument.head) { 10765 return; 10766 } 10767 const runtime = getRuntime11(); 10768 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10769 if (!injectedStyles) { 10770 injectedStyles = /* @__PURE__ */ new Set(); 10771 runtime.injectedStyles.set(targetDocument, injectedStyles); 10772 } 10773 if (injectedStyles.has(hash)) { 10774 return; 10775 } 10776 if (documentContainsStyleHash11(targetDocument, hash)) { 10777 injectedStyles.add(hash); 10778 return; 10779 } 10780 const style = targetDocument.createElement("style"); 10781 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash); 10782 style.appendChild(targetDocument.createTextNode(css)); 10783 targetDocument.head.appendChild(style); 10784 injectedStyles.add(hash); 10785 } 10786 function registerDocument11(targetDocument) { 10787 const runtime = getRuntime11(); 10788 runtime.documents.set( 10789 targetDocument, 10790 (runtime.documents.get(targetDocument) ?? 0) + 1 10791 ); 10792 for (const [hash, css] of runtime.styles) { 10793 injectStyle11(targetDocument, hash, css); 10794 } 10795 return () => { 10796 const count = runtime.documents.get(targetDocument); 10797 if (count === void 0) { 10798 return; 10799 } 10800 if (count <= 1) { 10801 runtime.documents.delete(targetDocument); 10802 return; 10803 } 10804 runtime.documents.set(targetDocument, count - 1); 10805 }; 10806 } 10807 function registerStyle11(hash, css) { 10808 const runtime = getRuntime11(); 10809 runtime.styles.set(hash, css); 10810 for (const targetDocument of runtime.documents.keys()) { 10811 injectStyle11(targetDocument, hash, css); 10812 } 10813 } 10814 if (typeof process === "undefined" || true) { 10815 registerStyle11("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}"); 10816 } 10817 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 10818 if (typeof process === "undefined" || true) { 10819 registerStyle11("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}'); 10820 } 10821 var style_default10 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 10822 var Positioner = (0, import_element27.forwardRef)( 10823 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) { 10824 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)( 10825 index_parts_exports2.Positioner, 10826 { 10827 ref, 10828 align, 10829 side, 10830 sideOffset, 10831 ...props, 10832 className: clsx_default( 10833 resets_default2["box-sizing"], 10834 style_default10.positioner, 10835 className 10836 ) 10837 } 10838 ); 10839 } 10840 ); 10841 10842 // packages/ui/build-module/tooltip/popup.mjs 10843 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1); 10844 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash"; 10845 function getRuntime12() { 10846 const globalScope = globalThis; 10847 if (globalScope.__wpStyleRuntime) { 10848 return globalScope.__wpStyleRuntime; 10849 } 10850 globalScope.__wpStyleRuntime = { 10851 documents: /* @__PURE__ */ new Map(), 10852 styles: /* @__PURE__ */ new Map(), 10853 injectedStyles: /* @__PURE__ */ new WeakMap() 10854 }; 10855 if (typeof document !== "undefined") { 10856 registerDocument12(document); 10857 } 10858 return globalScope.__wpStyleRuntime; 10859 } 10860 function documentContainsStyleHash12(targetDocument, hash) { 10861 if (!targetDocument.head) { 10862 return false; 10863 } 10864 for (const style of targetDocument.head.querySelectorAll( 10865 `style[$STYLE_HASH_ATTRIBUTE12}]` 10866 )) { 10867 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) { 10868 return true; 10869 } 10870 } 10871 return false; 10872 } 10873 function injectStyle12(targetDocument, hash, css) { 10874 if (!targetDocument.head) { 10875 return; 10876 } 10877 const runtime = getRuntime12(); 10878 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10879 if (!injectedStyles) { 10880 injectedStyles = /* @__PURE__ */ new Set(); 10881 runtime.injectedStyles.set(targetDocument, injectedStyles); 10882 } 10883 if (injectedStyles.has(hash)) { 10884 return; 10885 } 10886 if (documentContainsStyleHash12(targetDocument, hash)) { 10887 injectedStyles.add(hash); 10888 return; 10889 } 10890 const style = targetDocument.createElement("style"); 10891 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash); 10892 style.appendChild(targetDocument.createTextNode(css)); 10893 targetDocument.head.appendChild(style); 10894 injectedStyles.add(hash); 10895 } 10896 function registerDocument12(targetDocument) { 10897 const runtime = getRuntime12(); 10898 runtime.documents.set( 10899 targetDocument, 10900 (runtime.documents.get(targetDocument) ?? 0) + 1 10901 ); 10902 for (const [hash, css] of runtime.styles) { 10903 injectStyle12(targetDocument, hash, css); 10904 } 10905 return () => { 10906 const count = runtime.documents.get(targetDocument); 10907 if (count === void 0) { 10908 return; 10909 } 10910 if (count <= 1) { 10911 runtime.documents.delete(targetDocument); 10912 return; 10913 } 10914 runtime.documents.set(targetDocument, count - 1); 10915 }; 10916 } 10917 function registerStyle12(hash, css) { 10918 const runtime = getRuntime12(); 10919 runtime.styles.set(hash, css); 10920 for (const targetDocument of runtime.documents.keys()) { 10921 injectStyle12(targetDocument, hash, css); 10922 } 10923 } 10924 if (typeof process === "undefined" || true) { 10925 registerStyle12("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}'); 10926 } 10927 var style_default11 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 10928 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider; 10929 var Popup = (0, import_element28.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) { 10930 const popupContent = ( 10931 /* This should ideally use whatever dark color makes sense, 10932 * and not be hardcoded to #1e1e1e. The solutions would be to: 10933 * - review the design of the tooltip, in case we want to stop 10934 * hardcoding it to a dark background 10935 * - create new semantic tokens as needed (aliasing either the 10936 * "inverted bg" or "perma-dark bg" private tokens) and have 10937 * Tooltip.Popup use them; 10938 * - remove the hardcoded `bg` setting from the `ThemeProvider` 10939 * below 10940 */ 10941 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 10942 index_parts_exports2.Popup, 10943 { 10944 ref, 10945 className: clsx_default(style_default11.popup, className), 10946 ...props, 10947 children 10948 } 10949 ) }) 10950 ); 10951 const positionedPopup = renderSlotWithChildren( 10952 positioner, 10953 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Positioner, {}), 10954 popupContent 10955 ); 10956 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Portal, {}), positionedPopup); 10957 }); 10958 10959 // packages/ui/build-module/tooltip/trigger.mjs 10960 var import_element29 = __toESM(require_element(), 1); 10961 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1); 10962 var Trigger2 = (0, import_element29.forwardRef)( 10963 function TooltipTrigger3(props, ref) { 10964 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(index_parts_exports2.Trigger, { ref, ...props }); 10965 } 10966 ); 10967 10968 // packages/ui/build-module/tooltip/root.mjs 10969 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1); 10970 function Root4(props) { 10971 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(index_parts_exports2.Root, { ...props }); 10972 } 10973 10974 // packages/ui/build-module/tooltip/provider.mjs 10975 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1); 10976 function Provider({ ...props }) { 10977 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(index_parts_exports2.Provider, { ...props }); 10978 } 10979 10980 // packages/ui/build-module/visually-hidden/visually-hidden.mjs 10981 var import_element30 = __toESM(require_element(), 1); 10982 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash"; 10983 function getRuntime13() { 10984 const globalScope = globalThis; 10985 if (globalScope.__wpStyleRuntime) { 10986 return globalScope.__wpStyleRuntime; 10987 } 10988 globalScope.__wpStyleRuntime = { 10989 documents: /* @__PURE__ */ new Map(), 10990 styles: /* @__PURE__ */ new Map(), 10991 injectedStyles: /* @__PURE__ */ new WeakMap() 10992 }; 10993 if (typeof document !== "undefined") { 10994 registerDocument13(document); 10995 } 10996 return globalScope.__wpStyleRuntime; 10997 } 10998 function documentContainsStyleHash13(targetDocument, hash) { 10999 if (!targetDocument.head) { 11000 return false; 11001 } 11002 for (const style of targetDocument.head.querySelectorAll( 11003 `style[$STYLE_HASH_ATTRIBUTE13}]` 11004 )) { 11005 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) { 11006 return true; 11007 } 11008 } 11009 return false; 11010 } 11011 function injectStyle13(targetDocument, hash, css) { 11012 if (!targetDocument.head) { 11013 return; 11014 } 11015 const runtime = getRuntime13(); 11016 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11017 if (!injectedStyles) { 11018 injectedStyles = /* @__PURE__ */ new Set(); 11019 runtime.injectedStyles.set(targetDocument, injectedStyles); 11020 } 11021 if (injectedStyles.has(hash)) { 11022 return; 11023 } 11024 if (documentContainsStyleHash13(targetDocument, hash)) { 11025 injectedStyles.add(hash); 11026 return; 11027 } 11028 const style = targetDocument.createElement("style"); 11029 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash); 11030 style.appendChild(targetDocument.createTextNode(css)); 11031 targetDocument.head.appendChild(style); 11032 injectedStyles.add(hash); 11033 } 11034 function registerDocument13(targetDocument) { 11035 const runtime = getRuntime13(); 11036 runtime.documents.set( 11037 targetDocument, 11038 (runtime.documents.get(targetDocument) ?? 0) + 1 11039 ); 11040 for (const [hash, css] of runtime.styles) { 11041 injectStyle13(targetDocument, hash, css); 11042 } 11043 return () => { 11044 const count = runtime.documents.get(targetDocument); 11045 if (count === void 0) { 11046 return; 11047 } 11048 if (count <= 1) { 11049 runtime.documents.delete(targetDocument); 11050 return; 11051 } 11052 runtime.documents.set(targetDocument, count - 1); 11053 }; 11054 } 11055 function registerStyle13(hash, css) { 11056 const runtime = getRuntime13(); 11057 runtime.styles.set(hash, css); 11058 for (const targetDocument of runtime.documents.keys()) { 11059 injectStyle13(targetDocument, hash, css); 11060 } 11061 } 11062 if (typeof process === "undefined" || true) { 11063 registerStyle13("c46e8cb841", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}"); 11064 } 11065 var style_default12 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" }; 11066 var VisuallyHidden = (0, import_element30.forwardRef)( 11067 function VisuallyHidden2({ render: render4, ...restProps }, ref) { 11068 const element = useRender({ 11069 render: render4, 11070 ref, 11071 props: mergeProps( 11072 { className: style_default12["visually-hidden"] }, 11073 restProps, 11074 { 11075 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it. 11076 "data-visually-hidden": "" 11077 } 11078 ) 11079 }); 11080 return element; 11081 } 11082 ); 11083 11084 // packages/ui/build-module/link/link.mjs 11085 var import_element31 = __toESM(require_element(), 1); 11086 var import_i18n = __toESM(require_i18n(), 1); 11087 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1); 11088 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash"; 11089 function getRuntime14() { 11090 const globalScope = globalThis; 11091 if (globalScope.__wpStyleRuntime) { 11092 return globalScope.__wpStyleRuntime; 11093 } 11094 globalScope.__wpStyleRuntime = { 11095 documents: /* @__PURE__ */ new Map(), 11096 styles: /* @__PURE__ */ new Map(), 11097 injectedStyles: /* @__PURE__ */ new WeakMap() 11098 }; 11099 if (typeof document !== "undefined") { 11100 registerDocument14(document); 11101 } 11102 return globalScope.__wpStyleRuntime; 11103 } 11104 function documentContainsStyleHash14(targetDocument, hash) { 11105 if (!targetDocument.head) { 11106 return false; 11107 } 11108 for (const style of targetDocument.head.querySelectorAll( 11109 `style[$STYLE_HASH_ATTRIBUTE14}]` 11110 )) { 11111 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) { 11112 return true; 11113 } 11114 } 11115 return false; 11116 } 11117 function injectStyle14(targetDocument, hash, css) { 11118 if (!targetDocument.head) { 11119 return; 11120 } 11121 const runtime = getRuntime14(); 11122 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11123 if (!injectedStyles) { 11124 injectedStyles = /* @__PURE__ */ new Set(); 11125 runtime.injectedStyles.set(targetDocument, injectedStyles); 11126 } 11127 if (injectedStyles.has(hash)) { 11128 return; 11129 } 11130 if (documentContainsStyleHash14(targetDocument, hash)) { 11131 injectedStyles.add(hash); 11132 return; 11133 } 11134 const style = targetDocument.createElement("style"); 11135 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash); 11136 style.appendChild(targetDocument.createTextNode(css)); 11137 targetDocument.head.appendChild(style); 11138 injectedStyles.add(hash); 11139 } 11140 function registerDocument14(targetDocument) { 11141 const runtime = getRuntime14(); 11142 runtime.documents.set( 11143 targetDocument, 11144 (runtime.documents.get(targetDocument) ?? 0) + 1 11145 ); 11146 for (const [hash, css] of runtime.styles) { 11147 injectStyle14(targetDocument, hash, css); 11148 } 11149 return () => { 11150 const count = runtime.documents.get(targetDocument); 11151 if (count === void 0) { 11152 return; 11153 } 11154 if (count <= 1) { 11155 runtime.documents.delete(targetDocument); 11156 return; 11157 } 11158 runtime.documents.set(targetDocument, count - 1); 11159 }; 11160 } 11161 function registerStyle14(hash, css) { 11162 const runtime = getRuntime14(); 11163 runtime.styles.set(hash, css); 11164 for (const targetDocument of runtime.documents.keys()) { 11165 injectStyle14(targetDocument, hash, css); 11166 } 11167 } 11168 if (typeof process === "undefined" || true) { 11169 registerStyle14("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}"); 11170 } 11171 var resets_default3 = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 11172 if (typeof process === "undefined" || true) { 11173 registerStyle14("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}"); 11174 } 11175 var focus_default2 = { "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" }; 11176 if (typeof process === "undefined" || true) { 11177 registerStyle14("90a23568f8", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-regular,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}'); 11178 } 11179 var style_default13 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" }; 11180 if (typeof process === "undefined" || true) { 11181 registerStyle14("1fb29d3a3c", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}"); 11182 } 11183 var global_css_defense_default3 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" }; 11184 var Link = (0, import_element31.forwardRef)(function Link2({ 11185 children, 11186 variant = "default", 11187 tone = "brand", 11188 openInNewTab = false, 11189 render: render4, 11190 className, 11191 ...props 11192 }, ref) { 11193 const element = useRender({ 11194 render: render4, 11195 defaultTagName: "a", 11196 ref, 11197 props: mergeProps(props, { 11198 className: clsx_default( 11199 global_css_defense_default3.a, 11200 resets_default3["box-sizing"], 11201 focus_default2["outset-ring--focus"], 11202 variant !== "unstyled" && style_default13.link, 11203 variant !== "unstyled" && style_default13[`is-$tone}`], 11204 variant === "unstyled" && style_default13["is-unstyled"], 11205 className 11206 ), 11207 target: openInNewTab ? "_blank" : void 0, 11208 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [ 11209 children, 11210 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 11211 "span", 11212 { 11213 className: style_default13["link-icon"], 11214 role: "img", 11215 "aria-label": ( 11216 /* translators: accessibility text appended to link text */ 11217 (0, import_i18n.__)("(opens in a new tab)") 11218 ) 11219 } 11220 ) 11221 ] }) 11222 }) 11223 }); 11224 return element; 11225 }); 11226 11227 // packages/admin-ui/build-module/breadcrumbs/index.mjs 11228 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1); 11229 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash"; 11230 function getRuntime15() { 11231 const globalScope = globalThis; 11232 if (globalScope.__wpStyleRuntime) { 11233 return globalScope.__wpStyleRuntime; 11234 } 11235 globalScope.__wpStyleRuntime = { 11236 documents: /* @__PURE__ */ new Map(), 11237 styles: /* @__PURE__ */ new Map(), 11238 injectedStyles: /* @__PURE__ */ new WeakMap() 11239 }; 11240 if (typeof document !== "undefined") { 11241 registerDocument15(document); 11242 } 11243 return globalScope.__wpStyleRuntime; 11244 } 11245 function documentContainsStyleHash15(targetDocument, hash) { 11246 if (!targetDocument.head) { 11247 return false; 11248 } 11249 for (const style of targetDocument.head.querySelectorAll( 11250 `style[$STYLE_HASH_ATTRIBUTE15}]` 11251 )) { 11252 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) { 11253 return true; 11254 } 11255 } 11256 return false; 11257 } 11258 function injectStyle15(targetDocument, hash, css) { 11259 if (!targetDocument.head) { 11260 return; 11261 } 11262 const runtime = getRuntime15(); 11263 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11264 if (!injectedStyles) { 11265 injectedStyles = /* @__PURE__ */ new Set(); 11266 runtime.injectedStyles.set(targetDocument, injectedStyles); 11267 } 11268 if (injectedStyles.has(hash)) { 11269 return; 11270 } 11271 if (documentContainsStyleHash15(targetDocument, hash)) { 11272 injectedStyles.add(hash); 11273 return; 11274 } 11275 const style = targetDocument.createElement("style"); 11276 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash); 11277 style.appendChild(targetDocument.createTextNode(css)); 11278 targetDocument.head.appendChild(style); 11279 injectedStyles.add(hash); 11280 } 11281 function registerDocument15(targetDocument) { 11282 const runtime = getRuntime15(); 11283 runtime.documents.set( 11284 targetDocument, 11285 (runtime.documents.get(targetDocument) ?? 0) + 1 11286 ); 11287 for (const [hash, css] of runtime.styles) { 11288 injectStyle15(targetDocument, hash, css); 11289 } 11290 return () => { 11291 const count = runtime.documents.get(targetDocument); 11292 if (count === void 0) { 11293 return; 11294 } 11295 if (count <= 1) { 11296 runtime.documents.delete(targetDocument); 11297 return; 11298 } 11299 runtime.documents.set(targetDocument, count - 1); 11300 }; 11301 } 11302 function registerStyle15(hash, css) { 11303 const runtime = getRuntime15(); 11304 runtime.styles.set(hash, css); 11305 for (const targetDocument of runtime.documents.keys()) { 11306 injectStyle15(targetDocument, hash, css); 11307 } 11308 } 11309 if (typeof process === "undefined" || true) { 11310 registerStyle15("846edc217c", "._5f4053eba32ce092__list{list-style:none;margin:0;padding:0}._5f4053eba32ce092__list>li{flex-shrink:0}._5f4053eba32ce092__list>li:last-child{flex-shrink:1;min-width:0}.d1978551971a3360__current{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._6d9152063d443376__separator{color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);margin:0 var(--wpds-dimension-gap-sm,8px);user-select:none}"); 11311 } 11312 var style_default14 = { "list": "_5f4053eba32ce092__list", "current": "d1978551971a3360__current", "separator": "_6d9152063d443376__separator" }; 11313 var Breadcrumbs = ({ items }) => { 11314 if (!items.length) { 11315 return null; 11316 } 11317 const precedingItems = items.slice(0, -1); 11318 const lastItem = items[items.length - 1]; 11319 if (true) { 11320 const invalidItem = precedingItems.find((item) => !item.to); 11321 if (invalidItem) { 11322 throw new Error( 11323 `Breadcrumbs: item "$invalidItem.label}" is missing a \`to\` prop. All items except the last one must have a \`to\` prop.` 11324 ); 11325 } 11326 } 11327 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("nav", { "aria-label": (0, import_i18n2.__)("Breadcrumbs"), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)( 11328 Stack, 11329 { 11330 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("ul", {}), 11331 direction: "row", 11332 align: "center", 11333 className: style_default14.list, 11334 children: [ 11335 precedingItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("li", { children: [ 11336 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11337 Text, 11338 { 11339 variant: "body-lg", 11340 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11341 Link, 11342 { 11343 tone: "neutral", 11344 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(RouterLink, { to: item.to }) 11345 } 11346 ), 11347 children: item.label 11348 } 11349 ), 11350 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11351 Text, 11352 { 11353 variant: "body-lg", 11354 "aria-hidden": "true", 11355 className: style_default14.separator, 11356 children: "/" 11357 } 11358 ) 11359 ] }, index2)), 11360 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("li", { children: lastItem.to ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11361 Text, 11362 { 11363 variant: "body-lg", 11364 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11365 Link, 11366 { 11367 tone: "neutral", 11368 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(RouterLink, { to: lastItem.to }) 11369 } 11370 ), 11371 children: lastItem.label 11372 } 11373 ) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11374 Text, 11375 { 11376 variant: "heading-lg", 11377 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("h1", {}), 11378 className: style_default14.current, 11379 children: lastItem.label 11380 } 11381 ) }) 11382 ] 11383 } 11384 ) }); 11385 }; 11386 var breadcrumbs_default = Breadcrumbs; 11387 11388 // packages/admin-ui/build-module/navigable-region/index.mjs 11389 var import_element32 = __toESM(require_element(), 1); 11390 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1); 11391 var NavigableRegion = (0, import_element32.forwardRef)( 11392 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => { 11393 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 11394 Tag, 11395 { 11396 ref, 11397 className: clsx_default("admin-ui-navigable-region", className), 11398 "aria-label": ariaLabel, 11399 role: "region", 11400 tabIndex: "-1", 11401 ...props, 11402 children 11403 } 11404 ); 11405 } 11406 ); 11407 NavigableRegion.displayName = "NavigableRegion"; 11408 var navigable_region_default = NavigableRegion; 11409 11410 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs 11411 var import_components = __toESM(require_components(), 1); 11412 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle"); 11413 11414 // packages/admin-ui/build-module/page/header.mjs 11415 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1); 11416 var STYLE_HASH_ATTRIBUTE16 = "data-wp-hash"; 11417 function getRuntime16() { 11418 const globalScope = globalThis; 11419 if (globalScope.__wpStyleRuntime) { 11420 return globalScope.__wpStyleRuntime; 11421 } 11422 globalScope.__wpStyleRuntime = { 11423 documents: /* @__PURE__ */ new Map(), 11424 styles: /* @__PURE__ */ new Map(), 11425 injectedStyles: /* @__PURE__ */ new WeakMap() 11426 }; 11427 if (typeof document !== "undefined") { 11428 registerDocument16(document); 11429 } 11430 return globalScope.__wpStyleRuntime; 11431 } 11432 function documentContainsStyleHash16(targetDocument, hash) { 11433 if (!targetDocument.head) { 11434 return false; 11435 } 11436 for (const style of targetDocument.head.querySelectorAll( 11437 `style[$STYLE_HASH_ATTRIBUTE16}]` 11438 )) { 11439 if (style.getAttribute(STYLE_HASH_ATTRIBUTE16) === hash) { 11440 return true; 11441 } 11442 } 11443 return false; 11444 } 11445 function injectStyle16(targetDocument, hash, css) { 11446 if (!targetDocument.head) { 11447 return; 11448 } 11449 const runtime = getRuntime16(); 11450 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11451 if (!injectedStyles) { 11452 injectedStyles = /* @__PURE__ */ new Set(); 11453 runtime.injectedStyles.set(targetDocument, injectedStyles); 11454 } 11455 if (injectedStyles.has(hash)) { 11456 return; 11457 } 11458 if (documentContainsStyleHash16(targetDocument, hash)) { 11459 injectedStyles.add(hash); 11460 return; 11461 } 11462 const style = targetDocument.createElement("style"); 11463 style.setAttribute(STYLE_HASH_ATTRIBUTE16, hash); 11464 style.appendChild(targetDocument.createTextNode(css)); 11465 targetDocument.head.appendChild(style); 11466 injectedStyles.add(hash); 11467 } 11468 function registerDocument16(targetDocument) { 11469 const runtime = getRuntime16(); 11470 runtime.documents.set( 11471 targetDocument, 11472 (runtime.documents.get(targetDocument) ?? 0) + 1 11473 ); 11474 for (const [hash, css] of runtime.styles) { 11475 injectStyle16(targetDocument, hash, css); 11476 } 11477 return () => { 11478 const count = runtime.documents.get(targetDocument); 11479 if (count === void 0) { 11480 return; 11481 } 11482 if (count <= 1) { 11483 runtime.documents.delete(targetDocument); 11484 return; 11485 } 11486 runtime.documents.set(targetDocument, count - 1); 11487 }; 11488 } 11489 function registerStyle16(hash, css) { 11490 const runtime = getRuntime16(); 11491 runtime.styles.set(hash, css); 11492 for (const targetDocument of runtime.documents.keys()) { 11493 injectStyle16(targetDocument, hash, css); 11494 } 11495 } 11496 if (typeof process === "undefined" || true) { 11497 registerStyle16("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}"); 11498 } 11499 var style_default15 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" }; 11500 function Header3({ 11501 headingLevel = 1, 11502 breadcrumbs, 11503 badges, 11504 visual, 11505 title, 11506 subTitle, 11507 actions, 11508 showSidebarToggle = true 11509 }) { 11510 const HeadingTag = `h$headingLevel}`; 11511 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "column", className: style_default15.header, children: [ 11512 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)( 11513 Stack, 11514 { 11515 className: style_default15["header-content"], 11516 direction: "row", 11517 gap: "sm", 11518 justify: "space-between", 11519 children: [ 11520 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [ 11521 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)( 11522 SidebarToggleSlot, 11523 { 11524 bubblesVirtually: true, 11525 className: style_default15["sidebar-toggle-slot"] 11526 } 11527 ), 11528 visual && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)( 11529 "div", 11530 { 11531 className: style_default15["header-visual"], 11532 "aria-hidden": "true", 11533 children: visual 11534 } 11535 ), 11536 title && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)( 11537 Text, 11538 { 11539 className: style_default15["header-title"], 11540 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(HeadingTag, {}), 11541 variant: "heading-lg", 11542 children: title 11543 } 11544 ), 11545 breadcrumbs, 11546 badges 11547 ] }), 11548 actions && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)( 11549 Stack, 11550 { 11551 align: "center", 11552 className: style_default15["header-actions"], 11553 direction: "row", 11554 gap: "sm", 11555 children: actions 11556 } 11557 ) 11558 ] 11559 } 11560 ), 11561 subTitle && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)( 11562 Text, 11563 { 11564 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", {}), 11565 variant: "body-md", 11566 className: style_default15["header-subtitle"], 11567 children: subTitle 11568 } 11569 ) 11570 ] }); 11571 } 11572 11573 // packages/admin-ui/build-module/page/index.mjs 11574 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1); 11575 var STYLE_HASH_ATTRIBUTE17 = "data-wp-hash"; 11576 function getRuntime17() { 11577 const globalScope = globalThis; 11578 if (globalScope.__wpStyleRuntime) { 11579 return globalScope.__wpStyleRuntime; 11580 } 11581 globalScope.__wpStyleRuntime = { 11582 documents: /* @__PURE__ */ new Map(), 11583 styles: /* @__PURE__ */ new Map(), 11584 injectedStyles: /* @__PURE__ */ new WeakMap() 11585 }; 11586 if (typeof document !== "undefined") { 11587 registerDocument17(document); 11588 } 11589 return globalScope.__wpStyleRuntime; 11590 } 11591 function documentContainsStyleHash17(targetDocument, hash) { 11592 if (!targetDocument.head) { 11593 return false; 11594 } 11595 for (const style of targetDocument.head.querySelectorAll( 11596 `style[$STYLE_HASH_ATTRIBUTE17}]` 11597 )) { 11598 if (style.getAttribute(STYLE_HASH_ATTRIBUTE17) === hash) { 11599 return true; 11600 } 11601 } 11602 return false; 11603 } 11604 function injectStyle17(targetDocument, hash, css) { 11605 if (!targetDocument.head) { 11606 return; 11607 } 11608 const runtime = getRuntime17(); 11609 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11610 if (!injectedStyles) { 11611 injectedStyles = /* @__PURE__ */ new Set(); 11612 runtime.injectedStyles.set(targetDocument, injectedStyles); 11613 } 11614 if (injectedStyles.has(hash)) { 11615 return; 11616 } 11617 if (documentContainsStyleHash17(targetDocument, hash)) { 11618 injectedStyles.add(hash); 11619 return; 11620 } 11621 const style = targetDocument.createElement("style"); 11622 style.setAttribute(STYLE_HASH_ATTRIBUTE17, hash); 11623 style.appendChild(targetDocument.createTextNode(css)); 11624 targetDocument.head.appendChild(style); 11625 injectedStyles.add(hash); 11626 } 11627 function registerDocument17(targetDocument) { 11628 const runtime = getRuntime17(); 11629 runtime.documents.set( 11630 targetDocument, 11631 (runtime.documents.get(targetDocument) ?? 0) + 1 11632 ); 11633 for (const [hash, css] of runtime.styles) { 11634 injectStyle17(targetDocument, hash, css); 11635 } 11636 return () => { 11637 const count = runtime.documents.get(targetDocument); 11638 if (count === void 0) { 11639 return; 11640 } 11641 if (count <= 1) { 11642 runtime.documents.delete(targetDocument); 11643 return; 11644 } 11645 runtime.documents.set(targetDocument, count - 1); 11646 }; 11647 } 11648 function registerStyle17(hash, css) { 11649 const runtime = getRuntime17(); 11650 runtime.styles.set(hash, css); 11651 for (const targetDocument of runtime.documents.keys()) { 11652 injectStyle17(targetDocument, hash, css); 11653 } 11654 } 11655 if (typeof process === "undefined" || true) { 11656 registerStyle17("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}"); 11657 } 11658 var style_default16 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" }; 11659 function Page({ 11660 headingLevel, 11661 breadcrumbs, 11662 badges, 11663 visual, 11664 title, 11665 subTitle, 11666 children, 11667 className, 11668 actions, 11669 ariaLabel, 11670 hasPadding = false, 11671 showSidebarToggle = true 11672 }) { 11673 const classes = clsx_default(style_default16.page, className); 11674 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : ""); 11675 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [ 11676 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 11677 Header3, 11678 { 11679 headingLevel, 11680 breadcrumbs, 11681 badges, 11682 visual, 11683 title, 11684 subTitle, 11685 actions, 11686 showSidebarToggle 11687 } 11688 ), 11689 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 11690 "div", 11691 { 11692 className: clsx_default( 11693 style_default16.content, 11694 style_default16["has-padding"] 11695 ), 11696 children 11697 } 11698 ) : children 11699 ] }); 11700 } 11701 Page.SidebarToggleFill = SidebarToggleFill; 11702 var page_default = Page; 11703 11704 // routes/media-editor/stage.tsx 11705 var import_core_data3 = __toESM(require_core_data()); 11706 var import_data10 = __toESM(require_data()); 11707 var import_editor = __toESM(require_editor()); 11708 var import_html_entities = __toESM(require_html_entities()); 11709 var import_i18n38 = __toESM(require_i18n()); 11710 11711 // packages/media-editor/build-module/components/media-editor-provider/index.mjs 11712 var import_element33 = __toESM(require_element(), 1); 11713 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1); 11714 var MediaEditorContext = (0, import_element33.createContext)( 11715 void 0 11716 ); 11717 function MediaEditorProvider({ 11718 value, 11719 onChange, 11720 settings = {}, 11721 children 11722 }) { 11723 const contextValue = { 11724 media: value, 11725 onChange, 11726 fields: settings.fields || [] 11727 }; 11728 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(MediaEditorContext.Provider, { value: contextValue, children }); 11729 } 11730 function useMediaEditorContext() { 11731 const context = (0, import_element33.useContext)(MediaEditorContext); 11732 if (!context) { 11733 throw new Error( 11734 "useMediaEditorContext must be used within MediaEditorProvider" 11735 ); 11736 } 11737 return context; 11738 } 11739 11740 // packages/media-editor/build-module/components/media-preview/index.mjs 11741 var import_components2 = __toESM(require_components(), 1); 11742 var import_element34 = __toESM(require_element(), 1); 11743 var import_i18n3 = __toESM(require_i18n(), 1); 11744 11745 // packages/media-editor/build-module/utils/get-media-type.mjs 11746 function getMediaTypeFromMimeType(mimeType) { 11747 if (!mimeType) { 11748 return { type: "application" }; 11749 } 11750 if (mimeType.startsWith("image/")) { 11751 return { type: "image" }; 11752 } 11753 if (mimeType.startsWith("video/")) { 11754 return { type: "video" }; 11755 } 11756 if (mimeType.startsWith("audio/")) { 11757 return { type: "audio" }; 11758 } 11759 return { type: "application" }; 11760 } 11761 11762 // packages/media-editor/build-module/components/media-preview/index.mjs 11763 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1); 11764 function MediaPreviewContent({ 11765 mediaType, 11766 mediaUrl, 11767 altText, 11768 displayTitle, 11769 mimeType, 11770 onLoad, 11771 onError, 11772 loadingState 11773 }) { 11774 switch (mediaType.type) { 11775 case "image": 11776 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)( 11777 "img", 11778 { 11779 className: loadingState === "loaded" ? "loaded" : "", 11780 src: mediaUrl, 11781 alt: altText || "", 11782 onLoad, 11783 onError 11784 } 11785 ); 11786 case "video": 11787 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("video", { src: mediaUrl, controls: true, onError, children: displayTitle }); 11788 case "audio": 11789 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("audio", { src: mediaUrl, controls: true, onError, children: displayTitle }); 11790 default: 11791 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "media-editor-preview__file-info", children: [ 11792 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "media-editor-preview__file-name", children: displayTitle }), 11793 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "media-editor-preview__mime-type", children: mimeType }), 11794 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)( 11795 "a", 11796 { 11797 href: mediaUrl, 11798 target: "_blank", 11799 rel: "noopener", 11800 className: "media-editor-preview__download-link", 11801 children: (0, import_i18n3.__)("View file") 11802 } 11803 ) 11804 ] }); 11805 } 11806 } 11807 function MediaPreview(props) { 11808 const [loadingState, setLoadingState] = (0, import_element34.useState)("loading"); 11809 const { media } = useMediaEditorContext(); 11810 const { 11811 source_url: mediaUrl, 11812 mime_type: mimeType, 11813 alt_text: altText, 11814 title 11815 } = media || {}; 11816 const mediaType = getMediaTypeFromMimeType(mimeType); 11817 if (!mediaUrl) { 11818 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "media-editor-preview media-editor-preview--empty", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { children: (0, import_i18n3.__)("No media file available.") }) }); 11819 } 11820 if (loadingState === "error") { 11821 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "media-editor-preview media-editor-preview--error", children: [ 11822 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { children: (0, import_i18n3.__)("Failed to load media file.") }), 11823 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "media-editor-preview__url", children: mediaUrl }) 11824 ] }); 11825 } 11826 const displayTitle = typeof title === "string" ? title : title?.rendered || title?.raw; 11827 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)( 11828 "div", 11829 { 11830 ...props, 11831 className: `media-editor-preview media-editor-preview--$mediaType.type}`, 11832 children: [ 11833 mediaType.type === "image" && loadingState === "loading" && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "media-editor-preview__spinner", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components2.Spinner, {}) }), 11834 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)( 11835 MediaPreviewContent, 11836 { 11837 mediaType, 11838 mediaUrl, 11839 altText, 11840 displayTitle, 11841 mimeType, 11842 onLoad: () => setLoadingState("loaded"), 11843 onError: () => setLoadingState("error"), 11844 loadingState 11845 } 11846 ) 11847 ] 11848 } 11849 ); 11850 } 11851 11852 // packages/dataviews/build-module/constants.mjs 11853 var import_i18n4 = __toESM(require_i18n(), 1); 11854 var OPERATOR_IS_ANY = "isAny"; 11855 var OPERATOR_IS_NONE = "isNone"; 11856 var OPERATOR_IS_ALL = "isAll"; 11857 var OPERATOR_IS_NOT_ALL = "isNotAll"; 11858 var OPERATOR_BETWEEN = "between"; 11859 var OPERATOR_IN_THE_PAST = "inThePast"; 11860 var OPERATOR_OVER = "over"; 11861 var OPERATOR_IS = "is"; 11862 var OPERATOR_IS_NOT = "isNot"; 11863 var OPERATOR_LESS_THAN = "lessThan"; 11864 var OPERATOR_GREATER_THAN = "greaterThan"; 11865 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual"; 11866 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual"; 11867 var OPERATOR_BEFORE = "before"; 11868 var OPERATOR_AFTER = "after"; 11869 var OPERATOR_BEFORE_INC = "beforeInc"; 11870 var OPERATOR_AFTER_INC = "afterInc"; 11871 var OPERATOR_CONTAINS = "contains"; 11872 var OPERATOR_NOT_CONTAINS = "notContains"; 11873 var OPERATOR_STARTS_WITH = "startsWith"; 11874 var OPERATOR_ON = "on"; 11875 var OPERATOR_NOT_ON = "notOn"; 11876 var sortLabels = { 11877 asc: (0, import_i18n4.__)("Sort ascending"), 11878 desc: (0, import_i18n4.__)("Sort descending") 11879 }; 11880 11881 // packages/dataviews/build-module/lock-unlock.mjs 11882 var import_private_apis2 = __toESM(require_private_apis(), 1); 11883 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 11884 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 11885 "@wordpress/dataviews" 11886 ); 11887 11888 // packages/dataviews/build-module/hooks/use-elements.mjs 11889 var import_element35 = __toESM(require_element(), 1); 11890 var EMPTY_ARRAY2 = []; 11891 function useElements({ 11892 elements, 11893 getElements 11894 }) { 11895 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY2; 11896 const [records, setRecords] = (0, import_element35.useState)(staticElements); 11897 const [isLoading, setIsLoading] = (0, import_element35.useState)(false); 11898 (0, import_element35.useEffect)(() => { 11899 if (!getElements) { 11900 setRecords(staticElements); 11901 return; 11902 } 11903 let cancelled = false; 11904 setIsLoading(true); 11905 getElements().then((fetchedElements) => { 11906 if (!cancelled) { 11907 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements; 11908 setRecords(dynamicElements); 11909 } 11910 }).catch(() => { 11911 if (!cancelled) { 11912 setRecords(staticElements); 11913 } 11914 }).finally(() => { 11915 if (!cancelled) { 11916 setIsLoading(false); 11917 } 11918 }); 11919 return () => { 11920 cancelled = true; 11921 }; 11922 }, [getElements, staticElements]); 11923 return { 11924 elements: records, 11925 isLoading 11926 }; 11927 } 11928 11929 // node_modules/date-fns/constants.js 11930 var daysInYear = 365.2425; 11931 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 11932 var minTime = -maxTime; 11933 var millisecondsInWeek = 6048e5; 11934 var millisecondsInDay = 864e5; 11935 var secondsInHour = 3600; 11936 var secondsInDay = secondsInHour * 24; 11937 var secondsInWeek = secondsInDay * 7; 11938 var secondsInYear = secondsInDay * daysInYear; 11939 var secondsInMonth = secondsInYear / 12; 11940 var secondsInQuarter = secondsInMonth * 3; 11941 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom"); 11942 11943 // node_modules/date-fns/constructFrom.js 11944 function constructFrom(date, value) { 11945 if (typeof date === "function") return date(value); 11946 if (date && typeof date === "object" && constructFromSymbol in date) 11947 return date[constructFromSymbol](value); 11948 if (date instanceof Date) return new date.constructor(value); 11949 return new Date(value); 11950 } 11951 11952 // node_modules/date-fns/toDate.js 11953 function toDate(argument, context) { 11954 return constructFrom(context || argument, argument); 11955 } 11956 11957 // node_modules/date-fns/addDays.js 11958 function addDays(date, amount, options) { 11959 const _date = toDate(date, options?.in); 11960 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 11961 if (!amount) return _date; 11962 _date.setDate(_date.getDate() + amount); 11963 return _date; 11964 } 11965 11966 // node_modules/date-fns/addMonths.js 11967 function addMonths(date, amount, options) { 11968 const _date = toDate(date, options?.in); 11969 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 11970 if (!amount) { 11971 return _date; 11972 } 11973 const dayOfMonth = _date.getDate(); 11974 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime()); 11975 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 11976 const daysInMonth = endOfDesiredMonth.getDate(); 11977 if (dayOfMonth >= daysInMonth) { 11978 return endOfDesiredMonth; 11979 } else { 11980 _date.setFullYear( 11981 endOfDesiredMonth.getFullYear(), 11982 endOfDesiredMonth.getMonth(), 11983 dayOfMonth 11984 ); 11985 return _date; 11986 } 11987 } 11988 11989 // node_modules/date-fns/_lib/defaultOptions.js 11990 var defaultOptions = {}; 11991 function getDefaultOptions() { 11992 return defaultOptions; 11993 } 11994 11995 // node_modules/date-fns/startOfWeek.js 11996 function startOfWeek(date, options) { 11997 const defaultOptions2 = getDefaultOptions(); 11998 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 11999 const _date = toDate(date, options?.in); 12000 const day = _date.getDay(); 12001 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; 12002 _date.setDate(_date.getDate() - diff); 12003 _date.setHours(0, 0, 0, 0); 12004 return _date; 12005 } 12006 12007 // node_modules/date-fns/startOfISOWeek.js 12008 function startOfISOWeek(date, options) { 12009 return startOfWeek(date, { ...options, weekStartsOn: 1 }); 12010 } 12011 12012 // node_modules/date-fns/getISOWeekYear.js 12013 function getISOWeekYear(date, options) { 12014 const _date = toDate(date, options?.in); 12015 const year = _date.getFullYear(); 12016 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); 12017 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); 12018 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); 12019 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); 12020 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); 12021 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); 12022 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); 12023 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); 12024 if (_date.getTime() >= startOfNextYear.getTime()) { 12025 return year + 1; 12026 } else if (_date.getTime() >= startOfThisYear.getTime()) { 12027 return year; 12028 } else { 12029 return year - 1; 12030 } 12031 } 12032 12033 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js 12034 function getTimezoneOffsetInMilliseconds(date) { 12035 const _date = toDate(date); 12036 const utcDate = new Date( 12037 Date.UTC( 12038 _date.getFullYear(), 12039 _date.getMonth(), 12040 _date.getDate(), 12041 _date.getHours(), 12042 _date.getMinutes(), 12043 _date.getSeconds(), 12044 _date.getMilliseconds() 12045 ) 12046 ); 12047 utcDate.setUTCFullYear(_date.getFullYear()); 12048 return +date - +utcDate; 12049 } 12050 12051 // node_modules/date-fns/_lib/normalizeDates.js 12052 function normalizeDates(context, ...dates) { 12053 const normalize2 = constructFrom.bind( 12054 null, 12055 context || dates.find((date) => typeof date === "object") 12056 ); 12057 return dates.map(normalize2); 12058 } 12059 12060 // node_modules/date-fns/startOfDay.js 12061 function startOfDay(date, options) { 12062 const _date = toDate(date, options?.in); 12063 _date.setHours(0, 0, 0, 0); 12064 return _date; 12065 } 12066 12067 // node_modules/date-fns/differenceInCalendarDays.js 12068 function differenceInCalendarDays(laterDate, earlierDate, options) { 12069 const [laterDate_, earlierDate_] = normalizeDates( 12070 options?.in, 12071 laterDate, 12072 earlierDate 12073 ); 12074 const laterStartOfDay = startOfDay(laterDate_); 12075 const earlierStartOfDay = startOfDay(earlierDate_); 12076 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); 12077 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); 12078 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); 12079 } 12080 12081 // node_modules/date-fns/startOfISOWeekYear.js 12082 function startOfISOWeekYear(date, options) { 12083 const year = getISOWeekYear(date, options); 12084 const fourthOfJanuary = constructFrom(options?.in || date, 0); 12085 fourthOfJanuary.setFullYear(year, 0, 4); 12086 fourthOfJanuary.setHours(0, 0, 0, 0); 12087 return startOfISOWeek(fourthOfJanuary); 12088 } 12089 12090 // node_modules/date-fns/addWeeks.js 12091 function addWeeks(date, amount, options) { 12092 return addDays(date, amount * 7, options); 12093 } 12094 12095 // node_modules/date-fns/addYears.js 12096 function addYears(date, amount, options) { 12097 return addMonths(date, amount * 12, options); 12098 } 12099 12100 // node_modules/date-fns/isDate.js 12101 function isDate(value) { 12102 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; 12103 } 12104 12105 // node_modules/date-fns/isValid.js 12106 function isValid(date) { 12107 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date))); 12108 } 12109 12110 // node_modules/date-fns/startOfMonth.js 12111 function startOfMonth(date, options) { 12112 const _date = toDate(date, options?.in); 12113 _date.setDate(1); 12114 _date.setHours(0, 0, 0, 0); 12115 return _date; 12116 } 12117 12118 // node_modules/date-fns/startOfYear.js 12119 function startOfYear(date, options) { 12120 const date_ = toDate(date, options?.in); 12121 date_.setFullYear(date_.getFullYear(), 0, 1); 12122 date_.setHours(0, 0, 0, 0); 12123 return date_; 12124 } 12125 12126 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js 12127 var formatDistanceLocale = { 12128 lessThanXSeconds: { 12129 one: "less than a second", 12130 other: "less than {{count}} seconds" 12131 }, 12132 xSeconds: { 12133 one: "1 second", 12134 other: "{{count}} seconds" 12135 }, 12136 halfAMinute: "half a minute", 12137 lessThanXMinutes: { 12138 one: "less than a minute", 12139 other: "less than {{count}} minutes" 12140 }, 12141 xMinutes: { 12142 one: "1 minute", 12143 other: "{{count}} minutes" 12144 }, 12145 aboutXHours: { 12146 one: "about 1 hour", 12147 other: "about {{count}} hours" 12148 }, 12149 xHours: { 12150 one: "1 hour", 12151 other: "{{count}} hours" 12152 }, 12153 xDays: { 12154 one: "1 day", 12155 other: "{{count}} days" 12156 }, 12157 aboutXWeeks: { 12158 one: "about 1 week", 12159 other: "about {{count}} weeks" 12160 }, 12161 xWeeks: { 12162 one: "1 week", 12163 other: "{{count}} weeks" 12164 }, 12165 aboutXMonths: { 12166 one: "about 1 month", 12167 other: "about {{count}} months" 12168 }, 12169 xMonths: { 12170 one: "1 month", 12171 other: "{{count}} months" 12172 }, 12173 aboutXYears: { 12174 one: "about 1 year", 12175 other: "about {{count}} years" 12176 }, 12177 xYears: { 12178 one: "1 year", 12179 other: "{{count}} years" 12180 }, 12181 overXYears: { 12182 one: "over 1 year", 12183 other: "over {{count}} years" 12184 }, 12185 almostXYears: { 12186 one: "almost 1 year", 12187 other: "almost {{count}} years" 12188 } 12189 }; 12190 var formatDistance = (token, count, options) => { 12191 let result; 12192 const tokenValue = formatDistanceLocale[token]; 12193 if (typeof tokenValue === "string") { 12194 result = tokenValue; 12195 } else if (count === 1) { 12196 result = tokenValue.one; 12197 } else { 12198 result = tokenValue.other.replace("{{count}}", count.toString()); 12199 } 12200 if (options?.addSuffix) { 12201 if (options.comparison && options.comparison > 0) { 12202 return "in " + result; 12203 } else { 12204 return result + " ago"; 12205 } 12206 } 12207 return result; 12208 }; 12209 12210 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js 12211 function buildFormatLongFn(args) { 12212 return (options = {}) => { 12213 const width = options.width ? String(options.width) : args.defaultWidth; 12214 const format6 = args.formats[width] || args.formats[args.defaultWidth]; 12215 return format6; 12216 }; 12217 } 12218 12219 // node_modules/date-fns/locale/en-US/_lib/formatLong.js 12220 var dateFormats = { 12221 full: "EEEE, MMMM do, y", 12222 long: "MMMM do, y", 12223 medium: "MMM d, y", 12224 short: "MM/dd/yyyy" 12225 }; 12226 var timeFormats = { 12227 full: "h:mm:ss a zzzz", 12228 long: "h:mm:ss a z", 12229 medium: "h:mm:ss a", 12230 short: "h:mm a" 12231 }; 12232 var dateTimeFormats = { 12233 full: "{{date}} 'at' {{time}}", 12234 long: "{{date}} 'at' {{time}}", 12235 medium: "{{date}}, {{time}}", 12236 short: "{{date}}, {{time}}" 12237 }; 12238 var formatLong = { 12239 date: buildFormatLongFn({ 12240 formats: dateFormats, 12241 defaultWidth: "full" 12242 }), 12243 time: buildFormatLongFn({ 12244 formats: timeFormats, 12245 defaultWidth: "full" 12246 }), 12247 dateTime: buildFormatLongFn({ 12248 formats: dateTimeFormats, 12249 defaultWidth: "full" 12250 }) 12251 }; 12252 12253 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js 12254 var formatRelativeLocale = { 12255 lastWeek: "'last' eeee 'at' p", 12256 yesterday: "'yesterday at' p", 12257 today: "'today at' p", 12258 tomorrow: "'tomorrow at' p", 12259 nextWeek: "eeee 'at' p", 12260 other: "P" 12261 }; 12262 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; 12263 12264 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js 12265 function buildLocalizeFn(args) { 12266 return (value, options) => { 12267 const context = options?.context ? String(options.context) : "standalone"; 12268 let valuesArray; 12269 if (context === "formatting" && args.formattingValues) { 12270 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; 12271 const width = options?.width ? String(options.width) : defaultWidth; 12272 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; 12273 } else { 12274 const defaultWidth = args.defaultWidth; 12275 const width = options?.width ? String(options.width) : args.defaultWidth; 12276 valuesArray = args.values[width] || args.values[defaultWidth]; 12277 } 12278 const index2 = args.argumentCallback ? args.argumentCallback(value) : value; 12279 return valuesArray[index2]; 12280 }; 12281 } 12282 12283 // node_modules/date-fns/locale/en-US/_lib/localize.js 12284 var eraValues = { 12285 narrow: ["B", "A"], 12286 abbreviated: ["BC", "AD"], 12287 wide: ["Before Christ", "Anno Domini"] 12288 }; 12289 var quarterValues = { 12290 narrow: ["1", "2", "3", "4"], 12291 abbreviated: ["Q1", "Q2", "Q3", "Q4"], 12292 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] 12293 }; 12294 var monthValues = { 12295 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], 12296 abbreviated: [ 12297 "Jan", 12298 "Feb", 12299 "Mar", 12300 "Apr", 12301 "May", 12302 "Jun", 12303 "Jul", 12304 "Aug", 12305 "Sep", 12306 "Oct", 12307 "Nov", 12308 "Dec" 12309 ], 12310 wide: [ 12311 "January", 12312 "February", 12313 "March", 12314 "April", 12315 "May", 12316 "June", 12317 "July", 12318 "August", 12319 "September", 12320 "October", 12321 "November", 12322 "December" 12323 ] 12324 }; 12325 var dayValues = { 12326 narrow: ["S", "M", "T", "W", "T", "F", "S"], 12327 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 12328 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 12329 wide: [ 12330 "Sunday", 12331 "Monday", 12332 "Tuesday", 12333 "Wednesday", 12334 "Thursday", 12335 "Friday", 12336 "Saturday" 12337 ] 12338 }; 12339 var dayPeriodValues = { 12340 narrow: { 12341 am: "a", 12342 pm: "p", 12343 midnight: "mi", 12344 noon: "n", 12345 morning: "morning", 12346 afternoon: "afternoon", 12347 evening: "evening", 12348 night: "night" 12349 }, 12350 abbreviated: { 12351 am: "AM", 12352 pm: "PM", 12353 midnight: "midnight", 12354 noon: "noon", 12355 morning: "morning", 12356 afternoon: "afternoon", 12357 evening: "evening", 12358 night: "night" 12359 }, 12360 wide: { 12361 am: "a.m.", 12362 pm: "p.m.", 12363 midnight: "midnight", 12364 noon: "noon", 12365 morning: "morning", 12366 afternoon: "afternoon", 12367 evening: "evening", 12368 night: "night" 12369 } 12370 }; 12371 var formattingDayPeriodValues = { 12372 narrow: { 12373 am: "a", 12374 pm: "p", 12375 midnight: "mi", 12376 noon: "n", 12377 morning: "in the morning", 12378 afternoon: "in the afternoon", 12379 evening: "in the evening", 12380 night: "at night" 12381 }, 12382 abbreviated: { 12383 am: "AM", 12384 pm: "PM", 12385 midnight: "midnight", 12386 noon: "noon", 12387 morning: "in the morning", 12388 afternoon: "in the afternoon", 12389 evening: "in the evening", 12390 night: "at night" 12391 }, 12392 wide: { 12393 am: "a.m.", 12394 pm: "p.m.", 12395 midnight: "midnight", 12396 noon: "noon", 12397 morning: "in the morning", 12398 afternoon: "in the afternoon", 12399 evening: "in the evening", 12400 night: "at night" 12401 } 12402 }; 12403 var ordinalNumber = (dirtyNumber, _options) => { 12404 const number = Number(dirtyNumber); 12405 const rem100 = number % 100; 12406 if (rem100 > 20 || rem100 < 10) { 12407 switch (rem100 % 10) { 12408 case 1: 12409 return number + "st"; 12410 case 2: 12411 return number + "nd"; 12412 case 3: 12413 return number + "rd"; 12414 } 12415 } 12416 return number + "th"; 12417 }; 12418 var localize = { 12419 ordinalNumber, 12420 era: buildLocalizeFn({ 12421 values: eraValues, 12422 defaultWidth: "wide" 12423 }), 12424 quarter: buildLocalizeFn({ 12425 values: quarterValues, 12426 defaultWidth: "wide", 12427 argumentCallback: (quarter) => quarter - 1 12428 }), 12429 month: buildLocalizeFn({ 12430 values: monthValues, 12431 defaultWidth: "wide" 12432 }), 12433 day: buildLocalizeFn({ 12434 values: dayValues, 12435 defaultWidth: "wide" 12436 }), 12437 dayPeriod: buildLocalizeFn({ 12438 values: dayPeriodValues, 12439 defaultWidth: "wide", 12440 formattingValues: formattingDayPeriodValues, 12441 defaultFormattingWidth: "wide" 12442 }) 12443 }; 12444 12445 // node_modules/date-fns/locale/_lib/buildMatchFn.js 12446 function buildMatchFn(args) { 12447 return (string, options = {}) => { 12448 const width = options.width; 12449 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; 12450 const matchResult = string.match(matchPattern); 12451 if (!matchResult) { 12452 return null; 12453 } 12454 const matchedString = matchResult[0]; 12455 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; 12456 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : ( 12457 // [TODO] -- I challenge you to fix the type 12458 findKey(parsePatterns, (pattern) => pattern.test(matchedString)) 12459 ); 12460 let value; 12461 value = args.valueCallback ? args.valueCallback(key) : key; 12462 value = options.valueCallback ? ( 12463 // [TODO] -- I challenge you to fix the type 12464 options.valueCallback(value) 12465 ) : value; 12466 const rest = string.slice(matchedString.length); 12467 return { value, rest }; 12468 }; 12469 } 12470 function findKey(object, predicate) { 12471 for (const key in object) { 12472 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { 12473 return key; 12474 } 12475 } 12476 return void 0; 12477 } 12478 function findIndex(array, predicate) { 12479 for (let key = 0; key < array.length; key++) { 12480 if (predicate(array[key])) { 12481 return key; 12482 } 12483 } 12484 return void 0; 12485 } 12486 12487 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js 12488 function buildMatchPatternFn(args) { 12489 return (string, options = {}) => { 12490 const matchResult = string.match(args.matchPattern); 12491 if (!matchResult) return null; 12492 const matchedString = matchResult[0]; 12493 const parseResult = string.match(args.parsePattern); 12494 if (!parseResult) return null; 12495 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; 12496 value = options.valueCallback ? options.valueCallback(value) : value; 12497 const rest = string.slice(matchedString.length); 12498 return { value, rest }; 12499 }; 12500 } 12501 12502 // node_modules/date-fns/locale/en-US/_lib/match.js 12503 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; 12504 var parseOrdinalNumberPattern = /\d+/i; 12505 var matchEraPatterns = { 12506 narrow: /^(b|a)/i, 12507 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, 12508 wide: /^(before christ|before common era|anno domini|common era)/i 12509 }; 12510 var parseEraPatterns = { 12511 any: [/^b/i, /^(a|c)/i] 12512 }; 12513 var matchQuarterPatterns = { 12514 narrow: /^[1234]/i, 12515 abbreviated: /^q[1234]/i, 12516 wide: /^[1234](th|st|nd|rd)? quarter/i 12517 }; 12518 var parseQuarterPatterns = { 12519 any: [/1/i, /2/i, /3/i, /4/i] 12520 }; 12521 var matchMonthPatterns = { 12522 narrow: /^[jfmasond]/i, 12523 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, 12524 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i 12525 }; 12526 var parseMonthPatterns = { 12527 narrow: [ 12528 /^j/i, 12529 /^f/i, 12530 /^m/i, 12531 /^a/i, 12532 /^m/i, 12533 /^j/i, 12534 /^j/i, 12535 /^a/i, 12536 /^s/i, 12537 /^o/i, 12538 /^n/i, 12539 /^d/i 12540 ], 12541 any: [ 12542 /^ja/i, 12543 /^f/i, 12544 /^mar/i, 12545 /^ap/i, 12546 /^may/i, 12547 /^jun/i, 12548 /^jul/i, 12549 /^au/i, 12550 /^s/i, 12551 /^o/i, 12552 /^n/i, 12553 /^d/i 12554 ] 12555 }; 12556 var matchDayPatterns = { 12557 narrow: /^[smtwf]/i, 12558 short: /^(su|mo|tu|we|th|fr|sa)/i, 12559 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, 12560 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i 12561 }; 12562 var parseDayPatterns = { 12563 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], 12564 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] 12565 }; 12566 var matchDayPeriodPatterns = { 12567 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, 12568 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i 12569 }; 12570 var parseDayPeriodPatterns = { 12571 any: { 12572 am: /^a/i, 12573 pm: /^p/i, 12574 midnight: /^mi/i, 12575 noon: /^no/i, 12576 morning: /morning/i, 12577 afternoon: /afternoon/i, 12578 evening: /evening/i, 12579 night: /night/i 12580 } 12581 }; 12582 var match = { 12583 ordinalNumber: buildMatchPatternFn({ 12584 matchPattern: matchOrdinalNumberPattern, 12585 parsePattern: parseOrdinalNumberPattern, 12586 valueCallback: (value) => parseInt(value, 10) 12587 }), 12588 era: buildMatchFn({ 12589 matchPatterns: matchEraPatterns, 12590 defaultMatchWidth: "wide", 12591 parsePatterns: parseEraPatterns, 12592 defaultParseWidth: "any" 12593 }), 12594 quarter: buildMatchFn({ 12595 matchPatterns: matchQuarterPatterns, 12596 defaultMatchWidth: "wide", 12597 parsePatterns: parseQuarterPatterns, 12598 defaultParseWidth: "any", 12599 valueCallback: (index2) => index2 + 1 12600 }), 12601 month: buildMatchFn({ 12602 matchPatterns: matchMonthPatterns, 12603 defaultMatchWidth: "wide", 12604 parsePatterns: parseMonthPatterns, 12605 defaultParseWidth: "any" 12606 }), 12607 day: buildMatchFn({ 12608 matchPatterns: matchDayPatterns, 12609 defaultMatchWidth: "wide", 12610 parsePatterns: parseDayPatterns, 12611 defaultParseWidth: "any" 12612 }), 12613 dayPeriod: buildMatchFn({ 12614 matchPatterns: matchDayPeriodPatterns, 12615 defaultMatchWidth: "any", 12616 parsePatterns: parseDayPeriodPatterns, 12617 defaultParseWidth: "any" 12618 }) 12619 }; 12620 12621 // node_modules/date-fns/locale/en-US.js 12622 var enUS = { 12623 code: "en-US", 12624 formatDistance, 12625 formatLong, 12626 formatRelative, 12627 localize, 12628 match, 12629 options: { 12630 weekStartsOn: 0, 12631 firstWeekContainsDate: 1 12632 } 12633 }; 12634 12635 // node_modules/date-fns/getDayOfYear.js 12636 function getDayOfYear(date, options) { 12637 const _date = toDate(date, options?.in); 12638 const diff = differenceInCalendarDays(_date, startOfYear(_date)); 12639 const dayOfYear = diff + 1; 12640 return dayOfYear; 12641 } 12642 12643 // node_modules/date-fns/getISOWeek.js 12644 function getISOWeek(date, options) { 12645 const _date = toDate(date, options?.in); 12646 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); 12647 return Math.round(diff / millisecondsInWeek) + 1; 12648 } 12649 12650 // node_modules/date-fns/getWeekYear.js 12651 function getWeekYear(date, options) { 12652 const _date = toDate(date, options?.in); 12653 const year = _date.getFullYear(); 12654 const defaultOptions2 = getDefaultOptions(); 12655 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 12656 const firstWeekOfNextYear = constructFrom(options?.in || date, 0); 12657 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); 12658 firstWeekOfNextYear.setHours(0, 0, 0, 0); 12659 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); 12660 const firstWeekOfThisYear = constructFrom(options?.in || date, 0); 12661 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); 12662 firstWeekOfThisYear.setHours(0, 0, 0, 0); 12663 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); 12664 if (+_date >= +startOfNextYear) { 12665 return year + 1; 12666 } else if (+_date >= +startOfThisYear) { 12667 return year; 12668 } else { 12669 return year - 1; 12670 } 12671 } 12672 12673 // node_modules/date-fns/startOfWeekYear.js 12674 function startOfWeekYear(date, options) { 12675 const defaultOptions2 = getDefaultOptions(); 12676 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 12677 const year = getWeekYear(date, options); 12678 const firstWeek = constructFrom(options?.in || date, 0); 12679 firstWeek.setFullYear(year, 0, firstWeekContainsDate); 12680 firstWeek.setHours(0, 0, 0, 0); 12681 const _date = startOfWeek(firstWeek, options); 12682 return _date; 12683 } 12684 12685 // node_modules/date-fns/getWeek.js 12686 function getWeek(date, options) { 12687 const _date = toDate(date, options?.in); 12688 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); 12689 return Math.round(diff / millisecondsInWeek) + 1; 12690 } 12691 12692 // node_modules/date-fns/_lib/addLeadingZeros.js 12693 function addLeadingZeros(number, targetLength) { 12694 const sign = number < 0 ? "-" : ""; 12695 const output = Math.abs(number).toString().padStart(targetLength, "0"); 12696 return sign + output; 12697 } 12698 12699 // node_modules/date-fns/_lib/format/lightFormatters.js 12700 var lightFormatters = { 12701 // Year 12702 y(date, token) { 12703 const signedYear = date.getFullYear(); 12704 const year = signedYear > 0 ? signedYear : 1 - signedYear; 12705 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); 12706 }, 12707 // Month 12708 M(date, token) { 12709 const month = date.getMonth(); 12710 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); 12711 }, 12712 // Day of the month 12713 d(date, token) { 12714 return addLeadingZeros(date.getDate(), token.length); 12715 }, 12716 // AM or PM 12717 a(date, token) { 12718 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am"; 12719 switch (token) { 12720 case "a": 12721 case "aa": 12722 return dayPeriodEnumValue.toUpperCase(); 12723 case "aaa": 12724 return dayPeriodEnumValue; 12725 case "aaaaa": 12726 return dayPeriodEnumValue[0]; 12727 case "aaaa": 12728 default: 12729 return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; 12730 } 12731 }, 12732 // Hour [1-12] 12733 h(date, token) { 12734 return addLeadingZeros(date.getHours() % 12 || 12, token.length); 12735 }, 12736 // Hour [0-23] 12737 H(date, token) { 12738 return addLeadingZeros(date.getHours(), token.length); 12739 }, 12740 // Minute 12741 m(date, token) { 12742 return addLeadingZeros(date.getMinutes(), token.length); 12743 }, 12744 // Second 12745 s(date, token) { 12746 return addLeadingZeros(date.getSeconds(), token.length); 12747 }, 12748 // Fraction of second 12749 S(date, token) { 12750 const numberOfDigits = token.length; 12751 const milliseconds = date.getMilliseconds(); 12752 const fractionalSeconds = Math.trunc( 12753 milliseconds * Math.pow(10, numberOfDigits - 3) 12754 ); 12755 return addLeadingZeros(fractionalSeconds, token.length); 12756 } 12757 }; 12758 12759 // node_modules/date-fns/_lib/format/formatters.js 12760 var dayPeriodEnum = { 12761 am: "am", 12762 pm: "pm", 12763 midnight: "midnight", 12764 noon: "noon", 12765 morning: "morning", 12766 afternoon: "afternoon", 12767 evening: "evening", 12768 night: "night" 12769 }; 12770 var formatters = { 12771 // Era 12772 G: function(date, token, localize2) { 12773 const era = date.getFullYear() > 0 ? 1 : 0; 12774 switch (token) { 12775 // AD, BC 12776 case "G": 12777 case "GG": 12778 case "GGG": 12779 return localize2.era(era, { width: "abbreviated" }); 12780 // A, B 12781 case "GGGGG": 12782 return localize2.era(era, { width: "narrow" }); 12783 // Anno Domini, Before Christ 12784 case "GGGG": 12785 default: 12786 return localize2.era(era, { width: "wide" }); 12787 } 12788 }, 12789 // Year 12790 y: function(date, token, localize2) { 12791 if (token === "yo") { 12792 const signedYear = date.getFullYear(); 12793 const year = signedYear > 0 ? signedYear : 1 - signedYear; 12794 return localize2.ordinalNumber(year, { unit: "year" }); 12795 } 12796 return lightFormatters.y(date, token); 12797 }, 12798 // Local week-numbering year 12799 Y: function(date, token, localize2, options) { 12800 const signedWeekYear = getWeekYear(date, options); 12801 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; 12802 if (token === "YY") { 12803 const twoDigitYear = weekYear % 100; 12804 return addLeadingZeros(twoDigitYear, 2); 12805 } 12806 if (token === "Yo") { 12807 return localize2.ordinalNumber(weekYear, { unit: "year" }); 12808 } 12809 return addLeadingZeros(weekYear, token.length); 12810 }, 12811 // ISO week-numbering year 12812 R: function(date, token) { 12813 const isoWeekYear = getISOWeekYear(date); 12814 return addLeadingZeros(isoWeekYear, token.length); 12815 }, 12816 // Extended year. This is a single number designating the year of this calendar system. 12817 // The main difference between `y` and `u` localizers are B.C. years: 12818 // | Year | `y` | `u` | 12819 // |------|-----|-----| 12820 // | AC 1 | 1 | 1 | 12821 // | BC 1 | 1 | 0 | 12822 // | BC 2 | 2 | -1 | 12823 // Also `yy` always returns the last two digits of a year, 12824 // while `uu` pads single digit years to 2 characters and returns other years unchanged. 12825 u: function(date, token) { 12826 const year = date.getFullYear(); 12827 return addLeadingZeros(year, token.length); 12828 }, 12829 // Quarter 12830 Q: function(date, token, localize2) { 12831 const quarter = Math.ceil((date.getMonth() + 1) / 3); 12832 switch (token) { 12833 // 1, 2, 3, 4 12834 case "Q": 12835 return String(quarter); 12836 // 01, 02, 03, 04 12837 case "QQ": 12838 return addLeadingZeros(quarter, 2); 12839 // 1st, 2nd, 3rd, 4th 12840 case "Qo": 12841 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 12842 // Q1, Q2, Q3, Q4 12843 case "QQQ": 12844 return localize2.quarter(quarter, { 12845 width: "abbreviated", 12846 context: "formatting" 12847 }); 12848 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 12849 case "QQQQQ": 12850 return localize2.quarter(quarter, { 12851 width: "narrow", 12852 context: "formatting" 12853 }); 12854 // 1st quarter, 2nd quarter, ... 12855 case "QQQQ": 12856 default: 12857 return localize2.quarter(quarter, { 12858 width: "wide", 12859 context: "formatting" 12860 }); 12861 } 12862 }, 12863 // Stand-alone quarter 12864 q: function(date, token, localize2) { 12865 const quarter = Math.ceil((date.getMonth() + 1) / 3); 12866 switch (token) { 12867 // 1, 2, 3, 4 12868 case "q": 12869 return String(quarter); 12870 // 01, 02, 03, 04 12871 case "qq": 12872 return addLeadingZeros(quarter, 2); 12873 // 1st, 2nd, 3rd, 4th 12874 case "qo": 12875 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 12876 // Q1, Q2, Q3, Q4 12877 case "qqq": 12878 return localize2.quarter(quarter, { 12879 width: "abbreviated", 12880 context: "standalone" 12881 }); 12882 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 12883 case "qqqqq": 12884 return localize2.quarter(quarter, { 12885 width: "narrow", 12886 context: "standalone" 12887 }); 12888 // 1st quarter, 2nd quarter, ... 12889 case "qqqq": 12890 default: 12891 return localize2.quarter(quarter, { 12892 width: "wide", 12893 context: "standalone" 12894 }); 12895 } 12896 }, 12897 // Month 12898 M: function(date, token, localize2) { 12899 const month = date.getMonth(); 12900 switch (token) { 12901 case "M": 12902 case "MM": 12903 return lightFormatters.M(date, token); 12904 // 1st, 2nd, ..., 12th 12905 case "Mo": 12906 return localize2.ordinalNumber(month + 1, { unit: "month" }); 12907 // Jan, Feb, ..., Dec 12908 case "MMM": 12909 return localize2.month(month, { 12910 width: "abbreviated", 12911 context: "formatting" 12912 }); 12913 // J, F, ..., D 12914 case "MMMMM": 12915 return localize2.month(month, { 12916 width: "narrow", 12917 context: "formatting" 12918 }); 12919 // January, February, ..., December 12920 case "MMMM": 12921 default: 12922 return localize2.month(month, { width: "wide", context: "formatting" }); 12923 } 12924 }, 12925 // Stand-alone month 12926 L: function(date, token, localize2) { 12927 const month = date.getMonth(); 12928 switch (token) { 12929 // 1, 2, ..., 12 12930 case "L": 12931 return String(month + 1); 12932 // 01, 02, ..., 12 12933 case "LL": 12934 return addLeadingZeros(month + 1, 2); 12935 // 1st, 2nd, ..., 12th 12936 case "Lo": 12937 return localize2.ordinalNumber(month + 1, { unit: "month" }); 12938 // Jan, Feb, ..., Dec 12939 case "LLL": 12940 return localize2.month(month, { 12941 width: "abbreviated", 12942 context: "standalone" 12943 }); 12944 // J, F, ..., D 12945 case "LLLLL": 12946 return localize2.month(month, { 12947 width: "narrow", 12948 context: "standalone" 12949 }); 12950 // January, February, ..., December 12951 case "LLLL": 12952 default: 12953 return localize2.month(month, { width: "wide", context: "standalone" }); 12954 } 12955 }, 12956 // Local week of year 12957 w: function(date, token, localize2, options) { 12958 const week = getWeek(date, options); 12959 if (token === "wo") { 12960 return localize2.ordinalNumber(week, { unit: "week" }); 12961 } 12962 return addLeadingZeros(week, token.length); 12963 }, 12964 // ISO week of year 12965 I: function(date, token, localize2) { 12966 const isoWeek = getISOWeek(date); 12967 if (token === "Io") { 12968 return localize2.ordinalNumber(isoWeek, { unit: "week" }); 12969 } 12970 return addLeadingZeros(isoWeek, token.length); 12971 }, 12972 // Day of the month 12973 d: function(date, token, localize2) { 12974 if (token === "do") { 12975 return localize2.ordinalNumber(date.getDate(), { unit: "date" }); 12976 } 12977 return lightFormatters.d(date, token); 12978 }, 12979 // Day of year 12980 D: function(date, token, localize2) { 12981 const dayOfYear = getDayOfYear(date); 12982 if (token === "Do") { 12983 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); 12984 } 12985 return addLeadingZeros(dayOfYear, token.length); 12986 }, 12987 // Day of week 12988 E: function(date, token, localize2) { 12989 const dayOfWeek = date.getDay(); 12990 switch (token) { 12991 // Tue 12992 case "E": 12993 case "EE": 12994 case "EEE": 12995 return localize2.day(dayOfWeek, { 12996 width: "abbreviated", 12997 context: "formatting" 12998 }); 12999 // T 13000 case "EEEEE": 13001 return localize2.day(dayOfWeek, { 13002 width: "narrow", 13003 context: "formatting" 13004 }); 13005 // Tu 13006 case "EEEEEE": 13007 return localize2.day(dayOfWeek, { 13008 width: "short", 13009 context: "formatting" 13010 }); 13011 // Tuesday 13012 case "EEEE": 13013 default: 13014 return localize2.day(dayOfWeek, { 13015 width: "wide", 13016 context: "formatting" 13017 }); 13018 } 13019 }, 13020 // Local day of week 13021 e: function(date, token, localize2, options) { 13022 const dayOfWeek = date.getDay(); 13023 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 13024 switch (token) { 13025 // Numerical value (Nth day of week with current locale or weekStartsOn) 13026 case "e": 13027 return String(localDayOfWeek); 13028 // Padded numerical value 13029 case "ee": 13030 return addLeadingZeros(localDayOfWeek, 2); 13031 // 1st, 2nd, ..., 7th 13032 case "eo": 13033 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 13034 case "eee": 13035 return localize2.day(dayOfWeek, { 13036 width: "abbreviated", 13037 context: "formatting" 13038 }); 13039 // T 13040 case "eeeee": 13041 return localize2.day(dayOfWeek, { 13042 width: "narrow", 13043 context: "formatting" 13044 }); 13045 // Tu 13046 case "eeeeee": 13047 return localize2.day(dayOfWeek, { 13048 width: "short", 13049 context: "formatting" 13050 }); 13051 // Tuesday 13052 case "eeee": 13053 default: 13054 return localize2.day(dayOfWeek, { 13055 width: "wide", 13056 context: "formatting" 13057 }); 13058 } 13059 }, 13060 // Stand-alone local day of week 13061 c: function(date, token, localize2, options) { 13062 const dayOfWeek = date.getDay(); 13063 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 13064 switch (token) { 13065 // Numerical value (same as in `e`) 13066 case "c": 13067 return String(localDayOfWeek); 13068 // Padded numerical value 13069 case "cc": 13070 return addLeadingZeros(localDayOfWeek, token.length); 13071 // 1st, 2nd, ..., 7th 13072 case "co": 13073 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 13074 case "ccc": 13075 return localize2.day(dayOfWeek, { 13076 width: "abbreviated", 13077 context: "standalone" 13078 }); 13079 // T 13080 case "ccccc": 13081 return localize2.day(dayOfWeek, { 13082 width: "narrow", 13083 context: "standalone" 13084 }); 13085 // Tu 13086 case "cccccc": 13087 return localize2.day(dayOfWeek, { 13088 width: "short", 13089 context: "standalone" 13090 }); 13091 // Tuesday 13092 case "cccc": 13093 default: 13094 return localize2.day(dayOfWeek, { 13095 width: "wide", 13096 context: "standalone" 13097 }); 13098 } 13099 }, 13100 // ISO day of week 13101 i: function(date, token, localize2) { 13102 const dayOfWeek = date.getDay(); 13103 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; 13104 switch (token) { 13105 // 2 13106 case "i": 13107 return String(isoDayOfWeek); 13108 // 02 13109 case "ii": 13110 return addLeadingZeros(isoDayOfWeek, token.length); 13111 // 2nd 13112 case "io": 13113 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); 13114 // Tue 13115 case "iii": 13116 return localize2.day(dayOfWeek, { 13117 width: "abbreviated", 13118 context: "formatting" 13119 }); 13120 // T 13121 case "iiiii": 13122 return localize2.day(dayOfWeek, { 13123 width: "narrow", 13124 context: "formatting" 13125 }); 13126 // Tu 13127 case "iiiiii": 13128 return localize2.day(dayOfWeek, { 13129 width: "short", 13130 context: "formatting" 13131 }); 13132 // Tuesday 13133 case "iiii": 13134 default: 13135 return localize2.day(dayOfWeek, { 13136 width: "wide", 13137 context: "formatting" 13138 }); 13139 } 13140 }, 13141 // AM or PM 13142 a: function(date, token, localize2) { 13143 const hours = date.getHours(); 13144 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 13145 switch (token) { 13146 case "a": 13147 case "aa": 13148 return localize2.dayPeriod(dayPeriodEnumValue, { 13149 width: "abbreviated", 13150 context: "formatting" 13151 }); 13152 case "aaa": 13153 return localize2.dayPeriod(dayPeriodEnumValue, { 13154 width: "abbreviated", 13155 context: "formatting" 13156 }).toLowerCase(); 13157 case "aaaaa": 13158 return localize2.dayPeriod(dayPeriodEnumValue, { 13159 width: "narrow", 13160 context: "formatting" 13161 }); 13162 case "aaaa": 13163 default: 13164 return localize2.dayPeriod(dayPeriodEnumValue, { 13165 width: "wide", 13166 context: "formatting" 13167 }); 13168 } 13169 }, 13170 // AM, PM, midnight, noon 13171 b: function(date, token, localize2) { 13172 const hours = date.getHours(); 13173 let dayPeriodEnumValue; 13174 if (hours === 12) { 13175 dayPeriodEnumValue = dayPeriodEnum.noon; 13176 } else if (hours === 0) { 13177 dayPeriodEnumValue = dayPeriodEnum.midnight; 13178 } else { 13179 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 13180 } 13181 switch (token) { 13182 case "b": 13183 case "bb": 13184 return localize2.dayPeriod(dayPeriodEnumValue, { 13185 width: "abbreviated", 13186 context: "formatting" 13187 }); 13188 case "bbb": 13189 return localize2.dayPeriod(dayPeriodEnumValue, { 13190 width: "abbreviated", 13191 context: "formatting" 13192 }).toLowerCase(); 13193 case "bbbbb": 13194 return localize2.dayPeriod(dayPeriodEnumValue, { 13195 width: "narrow", 13196 context: "formatting" 13197 }); 13198 case "bbbb": 13199 default: 13200 return localize2.dayPeriod(dayPeriodEnumValue, { 13201 width: "wide", 13202 context: "formatting" 13203 }); 13204 } 13205 }, 13206 // in the morning, in the afternoon, in the evening, at night 13207 B: function(date, token, localize2) { 13208 const hours = date.getHours(); 13209 let dayPeriodEnumValue; 13210 if (hours >= 17) { 13211 dayPeriodEnumValue = dayPeriodEnum.evening; 13212 } else if (hours >= 12) { 13213 dayPeriodEnumValue = dayPeriodEnum.afternoon; 13214 } else if (hours >= 4) { 13215 dayPeriodEnumValue = dayPeriodEnum.morning; 13216 } else { 13217 dayPeriodEnumValue = dayPeriodEnum.night; 13218 } 13219 switch (token) { 13220 case "B": 13221 case "BB": 13222 case "BBB": 13223 return localize2.dayPeriod(dayPeriodEnumValue, { 13224 width: "abbreviated", 13225 context: "formatting" 13226 }); 13227 case "BBBBB": 13228 return localize2.dayPeriod(dayPeriodEnumValue, { 13229 width: "narrow", 13230 context: "formatting" 13231 }); 13232 case "BBBB": 13233 default: 13234 return localize2.dayPeriod(dayPeriodEnumValue, { 13235 width: "wide", 13236 context: "formatting" 13237 }); 13238 } 13239 }, 13240 // Hour [1-12] 13241 h: function(date, token, localize2) { 13242 if (token === "ho") { 13243 let hours = date.getHours() % 12; 13244 if (hours === 0) hours = 12; 13245 return localize2.ordinalNumber(hours, { unit: "hour" }); 13246 } 13247 return lightFormatters.h(date, token); 13248 }, 13249 // Hour [0-23] 13250 H: function(date, token, localize2) { 13251 if (token === "Ho") { 13252 return localize2.ordinalNumber(date.getHours(), { unit: "hour" }); 13253 } 13254 return lightFormatters.H(date, token); 13255 }, 13256 // Hour [0-11] 13257 K: function(date, token, localize2) { 13258 const hours = date.getHours() % 12; 13259 if (token === "Ko") { 13260 return localize2.ordinalNumber(hours, { unit: "hour" }); 13261 } 13262 return addLeadingZeros(hours, token.length); 13263 }, 13264 // Hour [1-24] 13265 k: function(date, token, localize2) { 13266 let hours = date.getHours(); 13267 if (hours === 0) hours = 24; 13268 if (token === "ko") { 13269 return localize2.ordinalNumber(hours, { unit: "hour" }); 13270 } 13271 return addLeadingZeros(hours, token.length); 13272 }, 13273 // Minute 13274 m: function(date, token, localize2) { 13275 if (token === "mo") { 13276 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" }); 13277 } 13278 return lightFormatters.m(date, token); 13279 }, 13280 // Second 13281 s: function(date, token, localize2) { 13282 if (token === "so") { 13283 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" }); 13284 } 13285 return lightFormatters.s(date, token); 13286 }, 13287 // Fraction of second 13288 S: function(date, token) { 13289 return lightFormatters.S(date, token); 13290 }, 13291 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) 13292 X: function(date, token, _localize) { 13293 const timezoneOffset = date.getTimezoneOffset(); 13294 if (timezoneOffset === 0) { 13295 return "Z"; 13296 } 13297 switch (token) { 13298 // Hours and optional minutes 13299 case "X": 13300 return formatTimezoneWithOptionalMinutes(timezoneOffset); 13301 // Hours, minutes and optional seconds without `:` delimiter 13302 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 13303 // so this token always has the same output as `XX` 13304 case "XXXX": 13305 case "XX": 13306 return formatTimezone(timezoneOffset); 13307 // Hours, minutes and optional seconds with `:` delimiter 13308 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 13309 // so this token always has the same output as `XXX` 13310 case "XXXXX": 13311 case "XXX": 13312 // Hours and minutes with `:` delimiter 13313 default: 13314 return formatTimezone(timezoneOffset, ":"); 13315 } 13316 }, 13317 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) 13318 x: function(date, token, _localize) { 13319 const timezoneOffset = date.getTimezoneOffset(); 13320 switch (token) { 13321 // Hours and optional minutes 13322 case "x": 13323 return formatTimezoneWithOptionalMinutes(timezoneOffset); 13324 // Hours, minutes and optional seconds without `:` delimiter 13325 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 13326 // so this token always has the same output as `xx` 13327 case "xxxx": 13328 case "xx": 13329 return formatTimezone(timezoneOffset); 13330 // Hours, minutes and optional seconds with `:` delimiter 13331 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 13332 // so this token always has the same output as `xxx` 13333 case "xxxxx": 13334 case "xxx": 13335 // Hours and minutes with `:` delimiter 13336 default: 13337 return formatTimezone(timezoneOffset, ":"); 13338 } 13339 }, 13340 // Timezone (GMT) 13341 O: function(date, token, _localize) { 13342 const timezoneOffset = date.getTimezoneOffset(); 13343 switch (token) { 13344 // Short 13345 case "O": 13346 case "OO": 13347 case "OOO": 13348 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 13349 // Long 13350 case "OOOO": 13351 default: 13352 return "GMT" + formatTimezone(timezoneOffset, ":"); 13353 } 13354 }, 13355 // Timezone (specific non-location) 13356 z: function(date, token, _localize) { 13357 const timezoneOffset = date.getTimezoneOffset(); 13358 switch (token) { 13359 // Short 13360 case "z": 13361 case "zz": 13362 case "zzz": 13363 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 13364 // Long 13365 case "zzzz": 13366 default: 13367 return "GMT" + formatTimezone(timezoneOffset, ":"); 13368 } 13369 }, 13370 // Seconds timestamp 13371 t: function(date, token, _localize) { 13372 const timestamp = Math.trunc(+date / 1e3); 13373 return addLeadingZeros(timestamp, token.length); 13374 }, 13375 // Milliseconds timestamp 13376 T: function(date, token, _localize) { 13377 return addLeadingZeros(+date, token.length); 13378 } 13379 }; 13380 function formatTimezoneShort(offset4, delimiter = "") { 13381 const sign = offset4 > 0 ? "-" : "+"; 13382 const absOffset = Math.abs(offset4); 13383 const hours = Math.trunc(absOffset / 60); 13384 const minutes = absOffset % 60; 13385 if (minutes === 0) { 13386 return sign + String(hours); 13387 } 13388 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); 13389 } 13390 function formatTimezoneWithOptionalMinutes(offset4, delimiter) { 13391 if (offset4 % 60 === 0) { 13392 const sign = offset4 > 0 ? "-" : "+"; 13393 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2); 13394 } 13395 return formatTimezone(offset4, delimiter); 13396 } 13397 function formatTimezone(offset4, delimiter = "") { 13398 const sign = offset4 > 0 ? "-" : "+"; 13399 const absOffset = Math.abs(offset4); 13400 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2); 13401 const minutes = addLeadingZeros(absOffset % 60, 2); 13402 return sign + hours + delimiter + minutes; 13403 } 13404 13405 // node_modules/date-fns/_lib/format/longFormatters.js 13406 var dateLongFormatter = (pattern, formatLong2) => { 13407 switch (pattern) { 13408 case "P": 13409 return formatLong2.date({ width: "short" }); 13410 case "PP": 13411 return formatLong2.date({ width: "medium" }); 13412 case "PPP": 13413 return formatLong2.date({ width: "long" }); 13414 case "PPPP": 13415 default: 13416 return formatLong2.date({ width: "full" }); 13417 } 13418 }; 13419 var timeLongFormatter = (pattern, formatLong2) => { 13420 switch (pattern) { 13421 case "p": 13422 return formatLong2.time({ width: "short" }); 13423 case "pp": 13424 return formatLong2.time({ width: "medium" }); 13425 case "ppp": 13426 return formatLong2.time({ width: "long" }); 13427 case "pppp": 13428 default: 13429 return formatLong2.time({ width: "full" }); 13430 } 13431 }; 13432 var dateTimeLongFormatter = (pattern, formatLong2) => { 13433 const matchResult = pattern.match(/(P+)(p+)?/) || []; 13434 const datePattern = matchResult[1]; 13435 const timePattern = matchResult[2]; 13436 if (!timePattern) { 13437 return dateLongFormatter(pattern, formatLong2); 13438 } 13439 let dateTimeFormat; 13440 switch (datePattern) { 13441 case "P": 13442 dateTimeFormat = formatLong2.dateTime({ width: "short" }); 13443 break; 13444 case "PP": 13445 dateTimeFormat = formatLong2.dateTime({ width: "medium" }); 13446 break; 13447 case "PPP": 13448 dateTimeFormat = formatLong2.dateTime({ width: "long" }); 13449 break; 13450 case "PPPP": 13451 default: 13452 dateTimeFormat = formatLong2.dateTime({ width: "full" }); 13453 break; 13454 } 13455 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); 13456 }; 13457 var longFormatters = { 13458 p: timeLongFormatter, 13459 P: dateTimeLongFormatter 13460 }; 13461 13462 // node_modules/date-fns/_lib/protectedTokens.js 13463 var dayOfYearTokenRE = /^D+$/; 13464 var weekYearTokenRE = /^Y+$/; 13465 var throwTokens = ["D", "DD", "YY", "YYYY"]; 13466 function isProtectedDayOfYearToken(token) { 13467 return dayOfYearTokenRE.test(token); 13468 } 13469 function isProtectedWeekYearToken(token) { 13470 return weekYearTokenRE.test(token); 13471 } 13472 function warnOrThrowProtectedError(token, format6, input) { 13473 const _message = message(token, format6, input); 13474 console.warn(_message); 13475 if (throwTokens.includes(token)) throw new RangeError(_message); 13476 } 13477 function message(token, format6, input) { 13478 const subject = token[0] === "Y" ? "years" : "days of the month"; 13479 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`; 13480 } 13481 13482 // node_modules/date-fns/format.js 13483 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; 13484 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; 13485 var escapedStringRegExp = /^'([^]*?)'?$/; 13486 var doubleQuoteRegExp = /''/g; 13487 var unescapedLatinCharacterRegExp = /[a-zA-Z]/; 13488 function format(date, formatStr, options) { 13489 const defaultOptions2 = getDefaultOptions(); 13490 const locale = options?.locale ?? defaultOptions2.locale ?? enUS; 13491 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 13492 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 13493 const originalDate = toDate(date, options?.in); 13494 if (!isValid(originalDate)) { 13495 throw new RangeError("Invalid time value"); 13496 } 13497 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { 13498 const firstCharacter = substring[0]; 13499 if (firstCharacter === "p" || firstCharacter === "P") { 13500 const longFormatter = longFormatters[firstCharacter]; 13501 return longFormatter(substring, locale.formatLong); 13502 } 13503 return substring; 13504 }).join("").match(formattingTokensRegExp).map((substring) => { 13505 if (substring === "''") { 13506 return { isToken: false, value: "'" }; 13507 } 13508 const firstCharacter = substring[0]; 13509 if (firstCharacter === "'") { 13510 return { isToken: false, value: cleanEscapedString(substring) }; 13511 } 13512 if (formatters[firstCharacter]) { 13513 return { isToken: true, value: substring }; 13514 } 13515 if (firstCharacter.match(unescapedLatinCharacterRegExp)) { 13516 throw new RangeError( 13517 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" 13518 ); 13519 } 13520 return { isToken: false, value: substring }; 13521 }); 13522 if (locale.localize.preprocessor) { 13523 parts = locale.localize.preprocessor(originalDate, parts); 13524 } 13525 const formatterOptions = { 13526 firstWeekContainsDate, 13527 weekStartsOn, 13528 locale 13529 }; 13530 return parts.map((part) => { 13531 if (!part.isToken) return part.value; 13532 const token = part.value; 13533 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) { 13534 warnOrThrowProtectedError(token, formatStr, String(date)); 13535 } 13536 const formatter = formatters[token[0]]; 13537 return formatter(originalDate, token, locale.localize, formatterOptions); 13538 }).join(""); 13539 } 13540 function cleanEscapedString(input) { 13541 const matched = input.match(escapedStringRegExp); 13542 if (!matched) { 13543 return input; 13544 } 13545 return matched[1].replace(doubleQuoteRegExp, "'"); 13546 } 13547 13548 // node_modules/date-fns/subDays.js 13549 function subDays(date, amount, options) { 13550 return addDays(date, -amount, options); 13551 } 13552 13553 // node_modules/date-fns/subMonths.js 13554 function subMonths(date, amount, options) { 13555 return addMonths(date, -amount, options); 13556 } 13557 13558 // node_modules/date-fns/subWeeks.js 13559 function subWeeks(date, amount, options) { 13560 return addWeeks(date, -amount, options); 13561 } 13562 13563 // node_modules/date-fns/subYears.js 13564 function subYears(date, amount, options) { 13565 return addYears(date, -amount, options); 13566 } 13567 13568 // packages/dataviews/build-module/utils/operators.mjs 13569 var import_i18n5 = __toESM(require_i18n(), 1); 13570 var import_element36 = __toESM(require_element(), 1); 13571 var import_date = __toESM(require_date(), 1); 13572 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1); 13573 var filterTextWrappers = { 13574 Name: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }), 13575 Value: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" }) 13576 }; 13577 function getRelativeDate(value, unit) { 13578 switch (unit) { 13579 case "days": 13580 return subDays(/* @__PURE__ */ new Date(), value); 13581 case "weeks": 13582 return subWeeks(/* @__PURE__ */ new Date(), value); 13583 case "months": 13584 return subMonths(/* @__PURE__ */ new Date(), value); 13585 case "years": 13586 return subYears(/* @__PURE__ */ new Date(), value); 13587 default: 13588 return /* @__PURE__ */ new Date(); 13589 } 13590 } 13591 var isNoneOperatorDefinition = { 13592 /* translators: DataViews operator name */ 13593 label: (0, import_i18n5.__)("Is none of"), 13594 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13595 (0, import_i18n5.sprintf)( 13596 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 13597 (0, import_i18n5.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 13598 filter.name, 13599 activeElements.map((element) => element.label).join(", ") 13600 ), 13601 filterTextWrappers 13602 ), 13603 filter: ((item, field, filterValue) => { 13604 if (!filterValue?.length) { 13605 return true; 13606 } 13607 const fieldValue = field.getValue({ item }); 13608 if (Array.isArray(fieldValue)) { 13609 return !filterValue.some( 13610 (fv) => fieldValue.includes(fv) 13611 ); 13612 } else if (typeof fieldValue === "string") { 13613 return !filterValue.includes(fieldValue); 13614 } 13615 return false; 13616 }), 13617 selection: "multi" 13618 }; 13619 var OPERATORS = [ 13620 { 13621 name: OPERATOR_IS_ANY, 13622 /* translators: DataViews operator name */ 13623 label: (0, import_i18n5.__)("Includes"), 13624 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13625 (0, import_i18n5.sprintf)( 13626 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ 13627 (0, import_i18n5.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"), 13628 filter.name, 13629 activeElements.map((element) => element.label).join(", ") 13630 ), 13631 filterTextWrappers 13632 ), 13633 filter(item, field, filterValue) { 13634 if (!filterValue?.length) { 13635 return true; 13636 } 13637 const fieldValue = field.getValue({ item }); 13638 if (Array.isArray(fieldValue)) { 13639 return filterValue.some( 13640 (fv) => fieldValue.includes(fv) 13641 ); 13642 } else if (typeof fieldValue === "string") { 13643 return filterValue.includes(fieldValue); 13644 } 13645 return false; 13646 }, 13647 selection: "multi" 13648 }, 13649 { 13650 name: OPERATOR_IS_NONE, 13651 ...isNoneOperatorDefinition 13652 }, 13653 { 13654 name: OPERATOR_IS_ALL, 13655 /* translators: DataViews operator name */ 13656 label: (0, import_i18n5.__)("Includes all"), 13657 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13658 (0, import_i18n5.sprintf)( 13659 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ 13660 (0, import_i18n5.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"), 13661 filter.name, 13662 activeElements.map((element) => element.label).join(", ") 13663 ), 13664 filterTextWrappers 13665 ), 13666 filter(item, field, filterValue) { 13667 if (!filterValue?.length) { 13668 return true; 13669 } 13670 return filterValue.every((value) => { 13671 return field.getValue({ item })?.includes(value); 13672 }); 13673 }, 13674 selection: "multi" 13675 }, 13676 { 13677 name: OPERATOR_IS_NOT_ALL, 13678 ...isNoneOperatorDefinition 13679 }, 13680 { 13681 name: OPERATOR_BETWEEN, 13682 /* translators: DataViews operator name */ 13683 label: (0, import_i18n5.__)("Between (inc)"), 13684 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13685 (0, import_i18n5.sprintf)( 13686 /* 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". */ 13687 (0, import_i18n5.__)( 13688 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>" 13689 ), 13690 filter.name, 13691 activeElements[0].label[0], 13692 activeElements[0].label[1] 13693 ), 13694 filterTextWrappers 13695 ), 13696 filter(item, field, filterValue) { 13697 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) { 13698 return true; 13699 } 13700 const fieldValue = field.getValue({ item }); 13701 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") { 13702 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1]; 13703 } 13704 return false; 13705 }, 13706 selection: "custom" 13707 }, 13708 { 13709 name: OPERATOR_IN_THE_PAST, 13710 /* translators: DataViews operator name */ 13711 label: (0, import_i18n5.__)("In the past"), 13712 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13713 (0, import_i18n5.sprintf)( 13714 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ 13715 (0, import_i18n5.__)( 13716 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>" 13717 ), 13718 filter.name, 13719 `$activeElements[0].value.value} $activeElements[0].value.unit}` 13720 ), 13721 filterTextWrappers 13722 ), 13723 filter(item, field, filterValue) { 13724 if (filterValue?.value === void 0 || filterValue?.unit === void 0) { 13725 return true; 13726 } 13727 const targetDate = getRelativeDate( 13728 filterValue.value, 13729 filterValue.unit 13730 ); 13731 const fieldValue = (0, import_date.getDate)(field.getValue({ item })); 13732 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date(); 13733 }, 13734 selection: "custom" 13735 }, 13736 { 13737 name: OPERATOR_OVER, 13738 /* translators: DataViews operator name */ 13739 label: (0, import_i18n5.__)("Over"), 13740 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13741 (0, import_i18n5.sprintf)( 13742 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ 13743 (0, import_i18n5.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"), 13744 filter.name, 13745 `$activeElements[0].value.value} $activeElements[0].value.unit}` 13746 ), 13747 filterTextWrappers 13748 ), 13749 filter(item, field, filterValue) { 13750 if (filterValue?.value === void 0 || filterValue?.unit === void 0) { 13751 return true; 13752 } 13753 const targetDate = getRelativeDate( 13754 filterValue.value, 13755 filterValue.unit 13756 ); 13757 const fieldValue = (0, import_date.getDate)(field.getValue({ item })); 13758 return fieldValue < targetDate; 13759 }, 13760 selection: "custom" 13761 }, 13762 { 13763 name: OPERATOR_IS, 13764 /* translators: DataViews operator name */ 13765 label: (0, import_i18n5.__)("Is"), 13766 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13767 (0, import_i18n5.sprintf)( 13768 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ 13769 (0, import_i18n5.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 13770 filter.name, 13771 activeElements[0].label 13772 ), 13773 filterTextWrappers 13774 ), 13775 filter(item, field, filterValue) { 13776 return filterValue === field.getValue({ item }) || filterValue === void 0; 13777 }, 13778 selection: "single" 13779 }, 13780 { 13781 name: OPERATOR_IS_NOT, 13782 /* translators: DataViews operator name */ 13783 label: (0, import_i18n5.__)("Is not"), 13784 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13785 (0, import_i18n5.sprintf)( 13786 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ 13787 (0, import_i18n5.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 13788 filter.name, 13789 activeElements[0].label 13790 ), 13791 filterTextWrappers 13792 ), 13793 filter(item, field, filterValue) { 13794 return filterValue !== field.getValue({ item }); 13795 }, 13796 selection: "single" 13797 }, 13798 { 13799 name: OPERATOR_LESS_THAN, 13800 /* translators: DataViews operator name */ 13801 label: (0, import_i18n5.__)("Less than"), 13802 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13803 (0, import_i18n5.sprintf)( 13804 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ 13805 (0, import_i18n5.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"), 13806 filter.name, 13807 activeElements[0].label 13808 ), 13809 filterTextWrappers 13810 ), 13811 filter(item, field, filterValue) { 13812 if (filterValue === void 0) { 13813 return true; 13814 } 13815 const fieldValue = field.getValue({ item }); 13816 return fieldValue < filterValue; 13817 }, 13818 selection: "single" 13819 }, 13820 { 13821 name: OPERATOR_GREATER_THAN, 13822 /* translators: DataViews operator name */ 13823 label: (0, import_i18n5.__)("Greater than"), 13824 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13825 (0, import_i18n5.sprintf)( 13826 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ 13827 (0, import_i18n5.__)( 13828 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>" 13829 ), 13830 filter.name, 13831 activeElements[0].label 13832 ), 13833 filterTextWrappers 13834 ), 13835 filter(item, field, filterValue) { 13836 if (filterValue === void 0) { 13837 return true; 13838 } 13839 const fieldValue = field.getValue({ item }); 13840 return fieldValue > filterValue; 13841 }, 13842 selection: "single" 13843 }, 13844 { 13845 name: OPERATOR_LESS_THAN_OR_EQUAL, 13846 /* translators: DataViews operator name */ 13847 label: (0, import_i18n5.__)("Less than or equal"), 13848 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13849 (0, import_i18n5.sprintf)( 13850 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ 13851 (0, import_i18n5.__)( 13852 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>" 13853 ), 13854 filter.name, 13855 activeElements[0].label 13856 ), 13857 filterTextWrappers 13858 ), 13859 filter(item, field, filterValue) { 13860 if (filterValue === void 0) { 13861 return true; 13862 } 13863 const fieldValue = field.getValue({ item }); 13864 return fieldValue <= filterValue; 13865 }, 13866 selection: "single" 13867 }, 13868 { 13869 name: OPERATOR_GREATER_THAN_OR_EQUAL, 13870 /* translators: DataViews operator name */ 13871 label: (0, import_i18n5.__)("Greater than or equal"), 13872 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13873 (0, import_i18n5.sprintf)( 13874 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ 13875 (0, import_i18n5.__)( 13876 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>" 13877 ), 13878 filter.name, 13879 activeElements[0].label 13880 ), 13881 filterTextWrappers 13882 ), 13883 filter(item, field, filterValue) { 13884 if (filterValue === void 0) { 13885 return true; 13886 } 13887 const fieldValue = field.getValue({ item }); 13888 return fieldValue >= filterValue; 13889 }, 13890 selection: "single" 13891 }, 13892 { 13893 name: OPERATOR_BEFORE, 13894 /* translators: DataViews operator name */ 13895 label: (0, import_i18n5.__)("Before"), 13896 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13897 (0, import_i18n5.sprintf)( 13898 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ 13899 (0, import_i18n5.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"), 13900 filter.name, 13901 activeElements[0].label 13902 ), 13903 filterTextWrappers 13904 ), 13905 filter(item, field, filterValue) { 13906 if (filterValue === void 0) { 13907 return true; 13908 } 13909 const filterDate = (0, import_date.getDate)(filterValue); 13910 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 13911 return fieldDate < filterDate; 13912 }, 13913 selection: "single" 13914 }, 13915 { 13916 name: OPERATOR_AFTER, 13917 /* translators: DataViews operator name */ 13918 label: (0, import_i18n5.__)("After"), 13919 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13920 (0, import_i18n5.sprintf)( 13921 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ 13922 (0, import_i18n5.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"), 13923 filter.name, 13924 activeElements[0].label 13925 ), 13926 filterTextWrappers 13927 ), 13928 filter(item, field, filterValue) { 13929 if (filterValue === void 0) { 13930 return true; 13931 } 13932 const filterDate = (0, import_date.getDate)(filterValue); 13933 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 13934 return fieldDate > filterDate; 13935 }, 13936 selection: "single" 13937 }, 13938 { 13939 name: OPERATOR_BEFORE_INC, 13940 /* translators: DataViews operator name */ 13941 label: (0, import_i18n5.__)("Before (inc)"), 13942 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13943 (0, import_i18n5.sprintf)( 13944 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ 13945 (0, import_i18n5.__)( 13946 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>" 13947 ), 13948 filter.name, 13949 activeElements[0].label 13950 ), 13951 filterTextWrappers 13952 ), 13953 filter(item, field, filterValue) { 13954 if (filterValue === void 0) { 13955 return true; 13956 } 13957 const filterDate = (0, import_date.getDate)(filterValue); 13958 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 13959 return fieldDate <= filterDate; 13960 }, 13961 selection: "single" 13962 }, 13963 { 13964 name: OPERATOR_AFTER_INC, 13965 /* translators: DataViews operator name */ 13966 label: (0, import_i18n5.__)("After (inc)"), 13967 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13968 (0, import_i18n5.sprintf)( 13969 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ 13970 (0, import_i18n5.__)( 13971 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>" 13972 ), 13973 filter.name, 13974 activeElements[0].label 13975 ), 13976 filterTextWrappers 13977 ), 13978 filter(item, field, filterValue) { 13979 if (filterValue === void 0) { 13980 return true; 13981 } 13982 const filterDate = (0, import_date.getDate)(filterValue); 13983 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 13984 return fieldDate >= filterDate; 13985 }, 13986 selection: "single" 13987 }, 13988 { 13989 name: OPERATOR_CONTAINS, 13990 /* translators: DataViews operator name */ 13991 label: (0, import_i18n5.__)("Contains"), 13992 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 13993 (0, import_i18n5.sprintf)( 13994 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ 13995 (0, import_i18n5.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"), 13996 filter.name, 13997 activeElements[0].label 13998 ), 13999 filterTextWrappers 14000 ), 14001 filter(item, field, filterValue) { 14002 if (filterValue === void 0) { 14003 return true; 14004 } 14005 const fieldValue = field.getValue({ item }); 14006 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase()); 14007 }, 14008 selection: "single" 14009 }, 14010 { 14011 name: OPERATOR_NOT_CONTAINS, 14012 /* translators: DataViews operator name */ 14013 label: (0, import_i18n5.__)("Doesn't contain"), 14014 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 14015 (0, import_i18n5.sprintf)( 14016 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ 14017 (0, import_i18n5.__)( 14018 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>" 14019 ), 14020 filter.name, 14021 activeElements[0].label 14022 ), 14023 filterTextWrappers 14024 ), 14025 filter(item, field, filterValue) { 14026 if (filterValue === void 0) { 14027 return true; 14028 } 14029 const fieldValue = field.getValue({ item }); 14030 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase()); 14031 }, 14032 selection: "single" 14033 }, 14034 { 14035 name: OPERATOR_STARTS_WITH, 14036 /* translators: DataViews operator name */ 14037 label: (0, import_i18n5.__)("Starts with"), 14038 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 14039 (0, import_i18n5.sprintf)( 14040 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ 14041 (0, import_i18n5.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"), 14042 filter.name, 14043 activeElements[0].label 14044 ), 14045 filterTextWrappers 14046 ), 14047 filter(item, field, filterValue) { 14048 if (filterValue === void 0) { 14049 return true; 14050 } 14051 const fieldValue = field.getValue({ item }); 14052 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase()); 14053 }, 14054 selection: "single" 14055 }, 14056 { 14057 name: OPERATOR_ON, 14058 /* translators: DataViews operator name */ 14059 label: (0, import_i18n5.__)("On"), 14060 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 14061 (0, import_i18n5.sprintf)( 14062 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ 14063 (0, import_i18n5.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 14064 filter.name, 14065 activeElements[0].label 14066 ), 14067 filterTextWrappers 14068 ), 14069 filter(item, field, filterValue) { 14070 if (filterValue === void 0) { 14071 return true; 14072 } 14073 const filterDate = (0, import_date.getDate)(filterValue); 14074 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 14075 return filterDate.getTime() === fieldDate.getTime(); 14076 }, 14077 selection: "single" 14078 }, 14079 { 14080 name: OPERATOR_NOT_ON, 14081 /* translators: DataViews operator name */ 14082 label: (0, import_i18n5.__)("Not on"), 14083 filterText: (filter, activeElements) => (0, import_element36.createInterpolateElement)( 14084 (0, import_i18n5.sprintf)( 14085 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ 14086 (0, import_i18n5.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 14087 filter.name, 14088 activeElements[0].label 14089 ), 14090 filterTextWrappers 14091 ), 14092 filter(item, field, filterValue) { 14093 if (filterValue === void 0) { 14094 return true; 14095 } 14096 const filterDate = (0, import_date.getDate)(filterValue); 14097 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 14098 return filterDate.getTime() !== fieldDate.getTime(); 14099 }, 14100 selection: "single" 14101 } 14102 ]; 14103 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name); 14104 var getAllOperatorNames = () => OPERATORS.map((op) => op.name); 14105 14106 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs 14107 var import_components3 = __toESM(require_components(), 1); 14108 var import_element37 = __toESM(require_element(), 1); 14109 14110 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs 14111 function getCustomValidity(isValid2, validity) { 14112 let customValidity; 14113 if (isValid2?.required && validity?.required) { 14114 customValidity = validity?.required?.message ? validity.required : void 0; 14115 } else if (isValid2?.pattern && validity?.pattern) { 14116 customValidity = validity.pattern; 14117 } else if (isValid2?.min && validity?.min) { 14118 customValidity = validity.min; 14119 } else if (isValid2?.max && validity?.max) { 14120 customValidity = validity.max; 14121 } else if (isValid2?.minLength && validity?.minLength) { 14122 customValidity = validity.minLength; 14123 } else if (isValid2?.maxLength && validity?.maxLength) { 14124 customValidity = validity.maxLength; 14125 } else if (isValid2?.elements && validity?.elements) { 14126 customValidity = validity.elements; 14127 } else if (validity?.custom) { 14128 customValidity = validity.custom; 14129 } 14130 return customValidity; 14131 } 14132 14133 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs 14134 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1); 14135 var { ValidatedCheckboxControl } = unlock2(import_components3.privateApis); 14136 function Checkbox({ 14137 field, 14138 onChange, 14139 data, 14140 hideLabelFromVision, 14141 markWhenOptional, 14142 validity 14143 }) { 14144 const { getValue, setValue, label, description, isValid: isValid2 } = field; 14145 const disabled2 = field.isDisabled({ item: data, field }); 14146 const onChangeControl = (0, import_element37.useCallback)(() => { 14147 onChange( 14148 setValue({ item: data, value: !getValue({ item: data }) }) 14149 ); 14150 }, [data, getValue, onChange, setValue]); 14151 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 14152 ValidatedCheckboxControl, 14153 { 14154 required: !!field.isValid?.required, 14155 markWhenOptional, 14156 customValidity: getCustomValidity(isValid2, validity), 14157 hidden: hideLabelFromVision, 14158 label, 14159 help: description, 14160 checked: getValue({ item: data }), 14161 onChange: onChangeControl, 14162 disabled: disabled2 14163 } 14164 ); 14165 } 14166 14167 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs 14168 var import_components4 = __toESM(require_components(), 1); 14169 var import_element38 = __toESM(require_element(), 1); 14170 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1); 14171 var { ValidatedComboboxControl } = unlock2(import_components4.privateApis); 14172 function Combobox({ 14173 data, 14174 field, 14175 onChange, 14176 hideLabelFromVision, 14177 validity 14178 }) { 14179 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field; 14180 const value = getValue({ item: data }) ?? ""; 14181 const onChangeControl = (0, import_element38.useCallback)( 14182 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })), 14183 [data, onChange, setValue] 14184 ); 14185 const { elements, isLoading } = useElements({ 14186 elements: field.elements, 14187 getElements: field.getElements 14188 }); 14189 if (isLoading) { 14190 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components4.Spinner, {}); 14191 } 14192 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 14193 ValidatedComboboxControl, 14194 { 14195 required: !!field.isValid?.required, 14196 customValidity: getCustomValidity(isValid2, validity), 14197 label, 14198 value, 14199 help: description, 14200 placeholder, 14201 options: elements, 14202 onChange: onChangeControl, 14203 hideLabelFromVision, 14204 allowReset: true, 14205 expandOnFocus: true 14206 } 14207 ); 14208 } 14209 14210 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs 14211 var import_components6 = __toESM(require_components(), 1); 14212 var import_element41 = __toESM(require_element(), 1); 14213 var import_i18n7 = __toESM(require_i18n(), 1); 14214 var import_date3 = __toESM(require_date(), 1); 14215 14216 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs 14217 var import_components5 = __toESM(require_components(), 1); 14218 var import_element39 = __toESM(require_element(), 1); 14219 var import_i18n6 = __toESM(require_i18n(), 1); 14220 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1); 14221 var TIME_UNITS_OPTIONS = { 14222 [OPERATOR_IN_THE_PAST]: [ 14223 { value: "days", label: (0, import_i18n6.__)("Days") }, 14224 { value: "weeks", label: (0, import_i18n6.__)("Weeks") }, 14225 { value: "months", label: (0, import_i18n6.__)("Months") }, 14226 { value: "years", label: (0, import_i18n6.__)("Years") } 14227 ], 14228 [OPERATOR_OVER]: [ 14229 { value: "days", label: (0, import_i18n6.__)("Days ago") }, 14230 { value: "weeks", label: (0, import_i18n6.__)("Weeks ago") }, 14231 { value: "months", label: (0, import_i18n6.__)("Months ago") }, 14232 { value: "years", label: (0, import_i18n6.__)("Years ago") } 14233 ] 14234 }; 14235 function RelativeDateControl({ 14236 className, 14237 data, 14238 field, 14239 onChange, 14240 hideLabelFromVision, 14241 operator 14242 }) { 14243 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"]; 14244 const { id, label, description, getValue, setValue } = field; 14245 const disabled2 = field.isDisabled({ item: data, field }); 14246 const fieldValue = getValue({ item: data }); 14247 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {}; 14248 const onChangeValue = (0, import_element39.useCallback)( 14249 (newValue) => onChange( 14250 setValue({ 14251 item: data, 14252 value: { value: Number(newValue), unit } 14253 }) 14254 ), 14255 [onChange, setValue, data, unit] 14256 ); 14257 const onChangeUnit = (0, import_element39.useCallback)( 14258 (newUnit) => onChange( 14259 setValue({ 14260 item: data, 14261 value: { value: relValue, unit: newUnit } 14262 }) 14263 ), 14264 [onChange, setValue, data, relValue] 14265 ); 14266 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 14267 import_components5.BaseControl, 14268 { 14269 id, 14270 className: clsx_default(className, "dataviews-controls__relative-date"), 14271 label, 14272 hideLabelFromVision, 14273 help: description, 14274 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Stack, { direction: "row", gap: "sm", children: [ 14275 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 14276 import_components5.__experimentalNumberControl, 14277 { 14278 __next40pxDefaultSize: true, 14279 className: "dataviews-controls__relative-date-number", 14280 spinControls: "none", 14281 min: 1, 14282 step: 1, 14283 value: relValue, 14284 onChange: onChangeValue, 14285 disabled: disabled2 14286 } 14287 ), 14288 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 14289 import_components5.SelectControl, 14290 { 14291 className: "dataviews-controls__relative-date-unit", 14292 __next40pxDefaultSize: true, 14293 label: (0, import_i18n6.__)("Unit"), 14294 value: unit, 14295 options, 14296 onChange: onChangeUnit, 14297 hideLabelFromVision: true, 14298 disabled: disabled2 14299 } 14300 ) 14301 ] }) 14302 } 14303 ); 14304 } 14305 14306 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs 14307 var import_element40 = __toESM(require_element(), 1); 14308 function useDisabledDateMatchers(isValid2, parseDateFn) { 14309 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0; 14310 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0; 14311 const disabledMatchers = (0, import_element40.useMemo)(() => { 14312 const matchers = []; 14313 if (minConstraint) { 14314 const minDate = parseDateFn(minConstraint); 14315 if (minDate) { 14316 matchers.push({ before: minDate }); 14317 } 14318 } 14319 if (maxConstraint) { 14320 const maxDate = parseDateFn(maxConstraint); 14321 if (maxDate) { 14322 matchers.push({ after: maxDate }); 14323 } 14324 } 14325 return matchers.length > 0 ? matchers : void 0; 14326 }, [minConstraint, maxConstraint, parseDateFn]); 14327 return { minConstraint, maxConstraint, disabledMatchers }; 14328 } 14329 14330 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs 14331 var import_date2 = __toESM(require_date(), 1); 14332 function parseDateTime(dateTimeString) { 14333 if (!dateTimeString) { 14334 return null; 14335 } 14336 const parsed = (0, import_date2.getDate)(dateTimeString); 14337 return parsed && isValid(parsed) ? parsed : null; 14338 } 14339 14340 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs 14341 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1); 14342 var { DateCalendar, ValidatedInputControl } = unlock2(import_components6.privateApis); 14343 var formatDateTime = (value) => { 14344 if (!value) { 14345 return ""; 14346 } 14347 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value)); 14348 }; 14349 function CalendarDateTimeControl({ 14350 data, 14351 field, 14352 onChange, 14353 hideLabelFromVision, 14354 markWhenOptional, 14355 validity, 14356 config 14357 }) { 14358 const { compact } = config || {}; 14359 const { id, label, description, setValue, getValue, isValid: isValid2 } = field; 14360 const disabled2 = field.isDisabled({ item: data, field }); 14361 const fieldValue = getValue({ item: data }); 14362 const value = typeof fieldValue === "string" ? fieldValue : void 0; 14363 const [calendarMonth, setCalendarMonth] = (0, import_element41.useState)(() => { 14364 const parsedDate = parseDateTime(value); 14365 return parsedDate || /* @__PURE__ */ new Date(); 14366 }); 14367 const inputControlRef = (0, import_element41.useRef)(null); 14368 const validationTimeoutRef = (0, import_element41.useRef)(void 0); 14369 const previousFocusRef = (0, import_element41.useRef)(null); 14370 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime); 14371 const onChangeCallback = (0, import_element41.useCallback)( 14372 (newValue) => onChange(setValue({ item: data, value: newValue })), 14373 [data, onChange, setValue] 14374 ); 14375 (0, import_element41.useEffect)(() => { 14376 return () => { 14377 if (validationTimeoutRef.current) { 14378 clearTimeout(validationTimeoutRef.current); 14379 } 14380 }; 14381 }, []); 14382 const onSelectDate = (0, import_element41.useCallback)( 14383 (newDate) => { 14384 let dateTimeValue; 14385 if (newDate) { 14386 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate); 14387 let wpTime; 14388 if (value) { 14389 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value)); 14390 } else { 14391 wpTime = (0, import_date3.dateI18n)("H:i", newDate); 14392 } 14393 const finalDateTime = (0, import_date3.getDate)(`$wpDate}T$wpTime}`); 14394 dateTimeValue = finalDateTime.toISOString(); 14395 onChangeCallback(dateTimeValue); 14396 if (validationTimeoutRef.current) { 14397 clearTimeout(validationTimeoutRef.current); 14398 } 14399 } else { 14400 onChangeCallback(void 0); 14401 } 14402 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement; 14403 validationTimeoutRef.current = setTimeout(() => { 14404 if (inputControlRef.current) { 14405 inputControlRef.current.focus(); 14406 inputControlRef.current.blur(); 14407 onChangeCallback(dateTimeValue); 14408 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) { 14409 previousFocusRef.current.focus(); 14410 } 14411 } 14412 }, 0); 14413 }, 14414 [onChangeCallback, value] 14415 ); 14416 const handleManualDateTimeChange = (0, import_element41.useCallback)( 14417 (newValue) => { 14418 if (newValue) { 14419 const dateTime = (0, import_date3.getDate)(newValue); 14420 onChangeCallback(dateTime.toISOString()); 14421 const parsedDate = parseDateTime(dateTime.toISOString()); 14422 if (parsedDate) { 14423 setCalendarMonth(parsedDate); 14424 } 14425 } else { 14426 onChangeCallback(void 0); 14427 } 14428 }, 14429 [onChangeCallback] 14430 ); 14431 const { format: fieldFormat } = field; 14432 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 14433 const { 14434 timezone: { string: timezoneString } 14435 } = (0, import_date3.getSettings)(); 14436 let displayLabel = label; 14437 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) { 14438 displayLabel = `$label} (${(0, import_i18n7.__)("Required")})`; 14439 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) { 14440 displayLabel = `$label} (${(0, import_i18n7.__)("Optional")})`; 14441 } 14442 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 14443 import_components6.BaseControl, 14444 { 14445 id, 14446 label: displayLabel, 14447 help: description, 14448 hideLabelFromVision, 14449 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 14450 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 14451 ValidatedInputControl, 14452 { 14453 ref: inputControlRef, 14454 __next40pxDefaultSize: true, 14455 required: !!isValid2?.required, 14456 customValidity: getCustomValidity(isValid2, validity), 14457 type: "datetime-local", 14458 label: (0, import_i18n7.__)("Date time"), 14459 hideLabelFromVision: true, 14460 value: formatDateTime(value), 14461 onChange: handleManualDateTimeChange, 14462 disabled: disabled2, 14463 min: minConstraint ? formatDateTime(minConstraint) : void 0, 14464 max: maxConstraint ? formatDateTime(maxConstraint) : void 0 14465 } 14466 ), 14467 !compact && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 14468 DateCalendar, 14469 { 14470 style: { width: "100%" }, 14471 selected: value ? parseDateTime(value) || void 0 : void 0, 14472 onSelect: onSelectDate, 14473 month: calendarMonth, 14474 onMonthChange: setCalendarMonth, 14475 timeZone: timezoneString || void 0, 14476 weekStartsOn, 14477 disabled: disabled2 || disabledMatchers 14478 } 14479 ) 14480 ] }) 14481 } 14482 ); 14483 } 14484 function DateTime({ 14485 data, 14486 field, 14487 onChange, 14488 hideLabelFromVision, 14489 markWhenOptional, 14490 operator, 14491 validity, 14492 config 14493 }) { 14494 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 14495 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 14496 RelativeDateControl, 14497 { 14498 className: "dataviews-controls__datetime", 14499 data, 14500 field, 14501 onChange, 14502 hideLabelFromVision, 14503 operator 14504 } 14505 ); 14506 } 14507 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 14508 CalendarDateTimeControl, 14509 { 14510 data, 14511 field, 14512 onChange, 14513 hideLabelFromVision, 14514 markWhenOptional, 14515 validity, 14516 config 14517 } 14518 ); 14519 } 14520 14521 // packages/dataviews/build-module/components/dataform-controls/date.mjs 14522 var import_components7 = __toESM(require_components(), 1); 14523 var import_element42 = __toESM(require_element(), 1); 14524 var import_i18n8 = __toESM(require_i18n(), 1); 14525 var import_date4 = __toESM(require_date(), 1); 14526 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1); 14527 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components7.privateApis); 14528 var DATE_PRESETS = [ 14529 { 14530 id: "today", 14531 label: (0, import_i18n8.__)("Today"), 14532 getValue: () => (0, import_date4.getDate)(null) 14533 }, 14534 { 14535 id: "yesterday", 14536 label: (0, import_i18n8.__)("Yesterday"), 14537 getValue: () => { 14538 const today = (0, import_date4.getDate)(null); 14539 return subDays(today, 1); 14540 } 14541 }, 14542 { 14543 id: "past-week", 14544 label: (0, import_i18n8.__)("Past week"), 14545 getValue: () => { 14546 const today = (0, import_date4.getDate)(null); 14547 return subDays(today, 7); 14548 } 14549 }, 14550 { 14551 id: "past-month", 14552 label: (0, import_i18n8.__)("Past month"), 14553 getValue: () => { 14554 const today = (0, import_date4.getDate)(null); 14555 return subMonths(today, 1); 14556 } 14557 } 14558 ]; 14559 var DATE_RANGE_PRESETS = [ 14560 { 14561 id: "last-7-days", 14562 label: (0, import_i18n8.__)("Last 7 days"), 14563 getValue: () => { 14564 const today = (0, import_date4.getDate)(null); 14565 return [subDays(today, 7), today]; 14566 } 14567 }, 14568 { 14569 id: "last-30-days", 14570 label: (0, import_i18n8.__)("Last 30 days"), 14571 getValue: () => { 14572 const today = (0, import_date4.getDate)(null); 14573 return [subDays(today, 30), today]; 14574 } 14575 }, 14576 { 14577 id: "month-to-date", 14578 label: (0, import_i18n8.__)("Month to date"), 14579 getValue: () => { 14580 const today = (0, import_date4.getDate)(null); 14581 return [startOfMonth(today), today]; 14582 } 14583 }, 14584 { 14585 id: "last-year", 14586 label: (0, import_i18n8.__)("Last year"), 14587 getValue: () => { 14588 const today = (0, import_date4.getDate)(null); 14589 return [subYears(today, 1), today]; 14590 } 14591 }, 14592 { 14593 id: "year-to-date", 14594 label: (0, import_i18n8.__)("Year to date"), 14595 getValue: () => { 14596 const today = (0, import_date4.getDate)(null); 14597 return [startOfYear(today), today]; 14598 } 14599 } 14600 ]; 14601 var parseDate = (dateString) => { 14602 if (!dateString) { 14603 return null; 14604 } 14605 const parsed = (0, import_date4.getDate)(dateString); 14606 return parsed && isValid(parsed) ? parsed : null; 14607 }; 14608 var formatDate = (date) => { 14609 if (!date) { 14610 return ""; 14611 } 14612 return typeof date === "string" ? date : format(date, "yyyy-MM-dd"); 14613 }; 14614 function ValidatedDateControl({ 14615 field, 14616 validity, 14617 inputRefs, 14618 isTouched, 14619 setIsTouched, 14620 children 14621 }) { 14622 const { isValid: isValid2 } = field; 14623 const [customValidity, setCustomValidity] = (0, import_element42.useState)(void 0); 14624 const validateRefs = (0, import_element42.useCallback)(() => { 14625 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 14626 for (const ref of refs) { 14627 const input = ref.current; 14628 if (input && !input.validity.valid) { 14629 setCustomValidity({ 14630 type: "invalid", 14631 message: input.validationMessage 14632 }); 14633 return; 14634 } 14635 } 14636 setCustomValidity(void 0); 14637 }, [inputRefs]); 14638 (0, import_element42.useEffect)(() => { 14639 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 14640 const result = validity ? getCustomValidity(isValid2, validity) : void 0; 14641 for (const ref of refs) { 14642 const input = ref.current; 14643 if (input) { 14644 input.setCustomValidity( 14645 result?.type === "invalid" && result.message ? result.message : "" 14646 ); 14647 } 14648 } 14649 }, [inputRefs, isValid2, validity]); 14650 (0, import_element42.useEffect)(() => { 14651 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 14652 const handleInvalid = (event) => { 14653 event.preventDefault(); 14654 setIsTouched(true); 14655 }; 14656 for (const ref of refs) { 14657 ref.current?.addEventListener("invalid", handleInvalid); 14658 } 14659 return () => { 14660 for (const ref of refs) { 14661 ref.current?.removeEventListener("invalid", handleInvalid); 14662 } 14663 }; 14664 }, [inputRefs, setIsTouched]); 14665 (0, import_element42.useEffect)(() => { 14666 if (!isTouched) { 14667 return; 14668 } 14669 const result = validity ? getCustomValidity(isValid2, validity) : void 0; 14670 if (result) { 14671 setCustomValidity(result); 14672 } else { 14673 validateRefs(); 14674 } 14675 }, [isTouched, isValid2, validity, validateRefs]); 14676 const onBlur = (event) => { 14677 if (isTouched) { 14678 return; 14679 } 14680 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 14681 setIsTouched(true); 14682 } 14683 }; 14684 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { onBlur, children: [ 14685 children, 14686 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)( 14687 "p", 14688 { 14689 className: clsx_default( 14690 "components-validated-control__indicator", 14691 customValidity.type === "invalid" ? "is-invalid" : void 0 14692 ), 14693 children: [ 14694 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 14695 import_components7.Icon, 14696 { 14697 className: "components-validated-control__indicator-icon", 14698 icon: error_default, 14699 size: 16, 14700 fill: "currentColor" 14701 } 14702 ), 14703 customValidity.message 14704 ] 14705 } 14706 ) }) 14707 ] }); 14708 } 14709 function CalendarDateControl({ 14710 data, 14711 field, 14712 onChange, 14713 hideLabelFromVision, 14714 markWhenOptional, 14715 validity 14716 }) { 14717 const { 14718 id, 14719 label, 14720 description, 14721 setValue, 14722 getValue, 14723 isValid: isValid2, 14724 format: fieldFormat 14725 } = field; 14726 const disabled2 = field.isDisabled({ item: data, field }); 14727 const [selectedPresetId, setSelectedPresetId] = (0, import_element42.useState)( 14728 null 14729 ); 14730 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 14731 const fieldValue = getValue({ item: data }); 14732 const value = typeof fieldValue === "string" ? fieldValue : void 0; 14733 const [calendarMonth, setCalendarMonth] = (0, import_element42.useState)(() => { 14734 const parsedDate = parseDate(value); 14735 return parsedDate || /* @__PURE__ */ new Date(); 14736 }); 14737 const [isTouched, setIsTouched] = (0, import_element42.useState)(false); 14738 const validityTargetRef = (0, import_element42.useRef)(null); 14739 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate); 14740 const onChangeCallback = (0, import_element42.useCallback)( 14741 (newValue) => onChange(setValue({ item: data, value: newValue })), 14742 [data, onChange, setValue] 14743 ); 14744 const onSelectDate = (0, import_element42.useCallback)( 14745 (newDate) => { 14746 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0; 14747 onChangeCallback(dateValue); 14748 setSelectedPresetId(null); 14749 setIsTouched(true); 14750 }, 14751 [onChangeCallback] 14752 ); 14753 const handlePresetClick = (0, import_element42.useCallback)( 14754 (preset) => { 14755 const presetDate = preset.getValue(); 14756 const dateValue = formatDate(presetDate); 14757 setCalendarMonth(presetDate); 14758 onChangeCallback(dateValue); 14759 setSelectedPresetId(preset.id); 14760 setIsTouched(true); 14761 }, 14762 [onChangeCallback] 14763 ); 14764 const handleManualDateChange = (0, import_element42.useCallback)( 14765 (newValue) => { 14766 onChangeCallback(newValue); 14767 if (newValue) { 14768 const parsedDate = parseDate(newValue); 14769 if (parsedDate) { 14770 setCalendarMonth(parsedDate); 14771 } 14772 } 14773 setSelectedPresetId(null); 14774 setIsTouched(true); 14775 }, 14776 [onChangeCallback] 14777 ); 14778 const { 14779 timezone: { string: timezoneString } 14780 } = (0, import_date4.getSettings)(); 14781 let displayLabel = label; 14782 if (isValid2?.required && !markWhenOptional) { 14783 displayLabel = `$label} (${(0, import_i18n8.__)("Required")})`; 14784 } else if (!isValid2?.required && markWhenOptional) { 14785 displayLabel = `$label} (${(0, import_i18n8.__)("Optional")})`; 14786 } 14787 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 14788 ValidatedDateControl, 14789 { 14790 field, 14791 validity, 14792 inputRefs: validityTargetRef, 14793 isTouched, 14794 setIsTouched, 14795 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 14796 import_components7.BaseControl, 14797 { 14798 id, 14799 className: "dataviews-controls__date", 14800 label: displayLabel, 14801 help: description, 14802 hideLabelFromVision, 14803 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 14804 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)( 14805 Stack, 14806 { 14807 direction: "row", 14808 gap: "sm", 14809 wrap: "wrap", 14810 justify: "flex-start", 14811 children: [ 14812 DATE_PRESETS.map((preset) => { 14813 const isSelected = selectedPresetId === preset.id; 14814 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 14815 import_components7.Button, 14816 { 14817 className: "dataviews-controls__date-preset", 14818 variant: "tertiary", 14819 isPressed: isSelected, 14820 size: "small", 14821 disabled: disabled2, 14822 accessibleWhenDisabled: true, 14823 onClick: () => handlePresetClick(preset), 14824 children: preset.label 14825 }, 14826 preset.id 14827 ); 14828 }), 14829 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 14830 import_components7.Button, 14831 { 14832 className: "dataviews-controls__date-preset", 14833 variant: "tertiary", 14834 isPressed: !selectedPresetId, 14835 size: "small", 14836 disabled: !!selectedPresetId || disabled2, 14837 accessibleWhenDisabled: true, 14838 children: (0, import_i18n8.__)("Custom") 14839 } 14840 ) 14841 ] 14842 } 14843 ), 14844 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 14845 import_components7.__experimentalInputControl, 14846 { 14847 __next40pxDefaultSize: true, 14848 ref: validityTargetRef, 14849 type: "date", 14850 label: (0, import_i18n8.__)("Date"), 14851 hideLabelFromVision: true, 14852 value, 14853 onChange: handleManualDateChange, 14854 required: !!field.isValid?.required, 14855 disabled: disabled2, 14856 min: minConstraint, 14857 max: maxConstraint 14858 } 14859 ), 14860 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 14861 DateCalendar2, 14862 { 14863 style: { width: "100%" }, 14864 selected: value ? parseDate(value) || void 0 : void 0, 14865 onSelect: onSelectDate, 14866 month: calendarMonth, 14867 onMonthChange: setCalendarMonth, 14868 timeZone: timezoneString || void 0, 14869 weekStartsOn, 14870 disabled: disabled2 || disabledMatchers, 14871 disableNavigation: disabled2 14872 } 14873 ) 14874 ] }) 14875 } 14876 ) 14877 } 14878 ); 14879 } 14880 function CalendarDateRangeControl({ 14881 data, 14882 field, 14883 onChange, 14884 hideLabelFromVision, 14885 markWhenOptional, 14886 validity 14887 }) { 14888 const { 14889 id, 14890 label, 14891 description, 14892 getValue, 14893 setValue, 14894 isValid: isValid2, 14895 format: fieldFormat 14896 } = field; 14897 const disabled2 = field.isDisabled({ item: data, field }); 14898 let value; 14899 const fieldValue = getValue({ item: data }); 14900 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) { 14901 value = fieldValue; 14902 } 14903 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 14904 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate); 14905 const onChangeCallback = (0, import_element42.useCallback)( 14906 (newValue) => { 14907 onChange( 14908 setValue({ 14909 item: data, 14910 value: newValue 14911 }) 14912 ); 14913 }, 14914 [data, onChange, setValue] 14915 ); 14916 const [selectedPresetId, setSelectedPresetId] = (0, import_element42.useState)( 14917 null 14918 ); 14919 const selectedRange = (0, import_element42.useMemo)(() => { 14920 if (!value) { 14921 return { from: void 0, to: void 0 }; 14922 } 14923 const [from, to] = value; 14924 return { 14925 from: parseDate(from) || void 0, 14926 to: parseDate(to) || void 0 14927 }; 14928 }, [value]); 14929 const [calendarMonth, setCalendarMonth] = (0, import_element42.useState)(() => { 14930 return selectedRange.from || /* @__PURE__ */ new Date(); 14931 }); 14932 const [isTouched, setIsTouched] = (0, import_element42.useState)(false); 14933 const fromInputRef = (0, import_element42.useRef)(null); 14934 const toInputRef = (0, import_element42.useRef)(null); 14935 const updateDateRange = (0, import_element42.useCallback)( 14936 (fromDate, toDate2) => { 14937 if (fromDate && toDate2) { 14938 onChangeCallback([ 14939 formatDate(fromDate), 14940 formatDate(toDate2) 14941 ]); 14942 } else if (!fromDate && !toDate2) { 14943 onChangeCallback(void 0); 14944 } 14945 }, 14946 [onChangeCallback] 14947 ); 14948 const onSelectCalendarRange = (0, import_element42.useCallback)( 14949 (newRange) => { 14950 updateDateRange(newRange?.from, newRange?.to); 14951 setSelectedPresetId(null); 14952 setIsTouched(true); 14953 }, 14954 [updateDateRange] 14955 ); 14956 const handlePresetClick = (0, import_element42.useCallback)( 14957 (preset) => { 14958 const [startDate, endDate] = preset.getValue(); 14959 setCalendarMonth(startDate); 14960 updateDateRange(startDate, endDate); 14961 setSelectedPresetId(preset.id); 14962 setIsTouched(true); 14963 }, 14964 [updateDateRange] 14965 ); 14966 const handleManualDateChange = (0, import_element42.useCallback)( 14967 (fromOrTo, newValue) => { 14968 const [currentFrom, currentTo] = value || [ 14969 void 0, 14970 void 0 14971 ]; 14972 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom; 14973 const updatedTo = fromOrTo === "to" ? newValue : currentTo; 14974 updateDateRange(updatedFrom, updatedTo); 14975 if (newValue) { 14976 const parsedDate = parseDate(newValue); 14977 if (parsedDate) { 14978 setCalendarMonth(parsedDate); 14979 } 14980 } 14981 setSelectedPresetId(null); 14982 setIsTouched(true); 14983 }, 14984 [value, updateDateRange] 14985 ); 14986 const { timezone } = (0, import_date4.getSettings)(); 14987 let displayLabel = label; 14988 if (field.isValid?.required && !markWhenOptional) { 14989 displayLabel = `$label} (${(0, import_i18n8.__)("Required")})`; 14990 } else if (!field.isValid?.required && markWhenOptional) { 14991 displayLabel = `$label} (${(0, import_i18n8.__)("Optional")})`; 14992 } 14993 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 14994 ValidatedDateControl, 14995 { 14996 field, 14997 validity, 14998 inputRefs: [fromInputRef, toInputRef], 14999 isTouched, 15000 setIsTouched, 15001 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 15002 import_components7.BaseControl, 15003 { 15004 id, 15005 className: "dataviews-controls__date", 15006 label: displayLabel, 15007 help: description, 15008 hideLabelFromVision, 15009 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 15010 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)( 15011 Stack, 15012 { 15013 direction: "row", 15014 gap: "sm", 15015 wrap: "wrap", 15016 justify: "flex-start", 15017 children: [ 15018 DATE_RANGE_PRESETS.map((preset) => { 15019 const isSelected = selectedPresetId === preset.id; 15020 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 15021 import_components7.Button, 15022 { 15023 className: "dataviews-controls__date-preset", 15024 variant: "tertiary", 15025 isPressed: isSelected, 15026 size: "small", 15027 disabled: disabled2, 15028 accessibleWhenDisabled: true, 15029 onClick: () => handlePresetClick(preset), 15030 children: preset.label 15031 }, 15032 preset.id 15033 ); 15034 }), 15035 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 15036 import_components7.Button, 15037 { 15038 className: "dataviews-controls__date-preset", 15039 variant: "tertiary", 15040 isPressed: !selectedPresetId, 15041 size: "small", 15042 accessibleWhenDisabled: true, 15043 disabled: !!selectedPresetId || disabled2, 15044 children: (0, import_i18n8.__)("Custom") 15045 } 15046 ) 15047 ] 15048 } 15049 ), 15050 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)( 15051 Stack, 15052 { 15053 direction: "row", 15054 gap: "sm", 15055 justify: "space-between", 15056 className: "dataviews-controls__date-range-inputs", 15057 children: [ 15058 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 15059 import_components7.__experimentalInputControl, 15060 { 15061 __next40pxDefaultSize: true, 15062 ref: fromInputRef, 15063 type: "date", 15064 label: (0, import_i18n8.__)("From"), 15065 hideLabelFromVision: true, 15066 value: value?.[0], 15067 onChange: (newValue) => handleManualDateChange("from", newValue), 15068 required: !!field.isValid?.required, 15069 disabled: disabled2, 15070 min: minConstraint, 15071 max: maxConstraint 15072 } 15073 ), 15074 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 15075 import_components7.__experimentalInputControl, 15076 { 15077 __next40pxDefaultSize: true, 15078 ref: toInputRef, 15079 type: "date", 15080 label: (0, import_i18n8.__)("To"), 15081 hideLabelFromVision: true, 15082 value: value?.[1], 15083 onChange: (newValue) => handleManualDateChange("to", newValue), 15084 required: !!field.isValid?.required, 15085 disabled: disabled2, 15086 min: minConstraint, 15087 max: maxConstraint 15088 } 15089 ) 15090 ] 15091 } 15092 ), 15093 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 15094 DateRangeCalendar, 15095 { 15096 style: { width: "100%" }, 15097 selected: selectedRange, 15098 onSelect: onSelectCalendarRange, 15099 month: calendarMonth, 15100 onMonthChange: setCalendarMonth, 15101 timeZone: timezone.string || void 0, 15102 weekStartsOn, 15103 disabled: disabled2 || disabledMatchers 15104 } 15105 ) 15106 ] }) 15107 } 15108 ) 15109 } 15110 ); 15111 } 15112 function DateControl({ 15113 data, 15114 field, 15115 onChange, 15116 hideLabelFromVision, 15117 markWhenOptional, 15118 operator, 15119 validity 15120 }) { 15121 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 15122 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 15123 RelativeDateControl, 15124 { 15125 className: "dataviews-controls__date", 15126 data, 15127 field, 15128 onChange, 15129 hideLabelFromVision, 15130 operator 15131 } 15132 ); 15133 } 15134 if (operator === OPERATOR_BETWEEN) { 15135 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 15136 CalendarDateRangeControl, 15137 { 15138 data, 15139 field, 15140 onChange, 15141 hideLabelFromVision, 15142 markWhenOptional, 15143 validity 15144 } 15145 ); 15146 } 15147 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 15148 CalendarDateControl, 15149 { 15150 data, 15151 field, 15152 onChange, 15153 hideLabelFromVision, 15154 markWhenOptional, 15155 validity 15156 } 15157 ); 15158 } 15159 15160 // packages/dataviews/build-module/components/dataform-controls/select.mjs 15161 var import_components8 = __toESM(require_components(), 1); 15162 var import_element43 = __toESM(require_element(), 1); 15163 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1); 15164 var { ValidatedSelectControl } = unlock2(import_components8.privateApis); 15165 function Select({ 15166 data, 15167 field, 15168 onChange, 15169 hideLabelFromVision, 15170 markWhenOptional, 15171 validity 15172 }) { 15173 const { type, label, description, getValue, setValue, isValid: isValid2 } = field; 15174 const disabled2 = field.isDisabled({ item: data, field }); 15175 const isMultiple = type === "array"; 15176 const value = getValue({ item: data }) ?? (isMultiple ? [] : ""); 15177 const onChangeControl = (0, import_element43.useCallback)( 15178 (newValue) => onChange(setValue({ item: data, value: newValue })), 15179 [data, onChange, setValue] 15180 ); 15181 const { elements, isLoading } = useElements({ 15182 elements: field.elements, 15183 getElements: field.getElements 15184 }); 15185 if (isLoading) { 15186 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components8.Spinner, {}); 15187 } 15188 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 15189 ValidatedSelectControl, 15190 { 15191 required: !!field.isValid?.required, 15192 markWhenOptional, 15193 customValidity: getCustomValidity(isValid2, validity), 15194 label, 15195 value, 15196 help: description, 15197 options: elements, 15198 onChange: onChangeControl, 15199 __next40pxDefaultSize: true, 15200 hideLabelFromVision, 15201 multiple: isMultiple, 15202 disabled: disabled2 15203 } 15204 ); 15205 } 15206 15207 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs 15208 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1); 15209 var ELEMENTS_THRESHOLD = 10; 15210 function AdaptiveSelect(props) { 15211 const { field } = props; 15212 const { elements } = useElements({ 15213 elements: field.elements, 15214 getElements: field.getElements 15215 }); 15216 if (elements.length >= ELEMENTS_THRESHOLD) { 15217 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Combobox, { ...props }); 15218 } 15219 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Select, { ...props }); 15220 } 15221 15222 // packages/dataviews/build-module/components/dataform-controls/email.mjs 15223 var import_components10 = __toESM(require_components(), 1); 15224 15225 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs 15226 var import_components9 = __toESM(require_components(), 1); 15227 var import_element44 = __toESM(require_element(), 1); 15228 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1); 15229 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components9.privateApis); 15230 function ValidatedText({ 15231 data, 15232 field, 15233 onChange, 15234 hideLabelFromVision, 15235 markWhenOptional, 15236 type, 15237 prefix, 15238 suffix, 15239 validity 15240 }) { 15241 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 15242 const value = getValue({ item: data }); 15243 const disabled2 = field.isDisabled({ item: data, field }); 15244 const onChangeControl = (0, import_element44.useCallback)( 15245 (newValue) => onChange( 15246 setValue({ 15247 item: data, 15248 value: newValue 15249 }) 15250 ), 15251 [data, setValue, onChange] 15252 ); 15253 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 15254 ValidatedInputControl2, 15255 { 15256 required: !!isValid2.required, 15257 markWhenOptional, 15258 customValidity: getCustomValidity(isValid2, validity), 15259 label, 15260 placeholder, 15261 value: value ?? "", 15262 help: description, 15263 onChange: onChangeControl, 15264 hideLabelFromVision, 15265 type, 15266 prefix, 15267 suffix, 15268 disabled: disabled2, 15269 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0, 15270 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 15271 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 15272 __next40pxDefaultSize: true 15273 } 15274 ); 15275 } 15276 15277 // packages/dataviews/build-module/components/dataform-controls/email.mjs 15278 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1); 15279 function Email({ 15280 data, 15281 field, 15282 onChange, 15283 hideLabelFromVision, 15284 markWhenOptional, 15285 validity 15286 }) { 15287 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 15288 ValidatedText, 15289 { 15290 ...{ 15291 data, 15292 field, 15293 onChange, 15294 hideLabelFromVision, 15295 markWhenOptional, 15296 validity, 15297 type: "email", 15298 prefix: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components10.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components10.Icon, { icon: envelope_default }) }) 15299 } 15300 } 15301 ); 15302 } 15303 15304 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs 15305 var import_components11 = __toESM(require_components(), 1); 15306 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1); 15307 function Telephone({ 15308 data, 15309 field, 15310 onChange, 15311 hideLabelFromVision, 15312 markWhenOptional, 15313 validity 15314 }) { 15315 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 15316 ValidatedText, 15317 { 15318 ...{ 15319 data, 15320 field, 15321 onChange, 15322 hideLabelFromVision, 15323 markWhenOptional, 15324 validity, 15325 type: "tel", 15326 prefix: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components11.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components11.Icon, { icon: mobile_default }) }) 15327 } 15328 } 15329 ); 15330 } 15331 15332 // packages/dataviews/build-module/components/dataform-controls/url.mjs 15333 var import_components12 = __toESM(require_components(), 1); 15334 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1); 15335 function Url({ 15336 data, 15337 field, 15338 onChange, 15339 hideLabelFromVision, 15340 markWhenOptional, 15341 validity 15342 }) { 15343 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 15344 ValidatedText, 15345 { 15346 ...{ 15347 data, 15348 field, 15349 onChange, 15350 hideLabelFromVision, 15351 markWhenOptional, 15352 validity, 15353 type: "url", 15354 prefix: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components12.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components12.Icon, { icon: link_default }) }) 15355 } 15356 } 15357 ); 15358 } 15359 15360 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs 15361 var import_components13 = __toESM(require_components(), 1); 15362 var import_element45 = __toESM(require_element(), 1); 15363 var import_i18n9 = __toESM(require_i18n(), 1); 15364 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1); 15365 var { ValidatedNumberControl } = unlock2(import_components13.privateApis); 15366 function toNumberOrEmpty(value) { 15367 if (value === "" || value === void 0) { 15368 return ""; 15369 } 15370 const number = Number(value); 15371 return Number.isFinite(number) ? number : ""; 15372 } 15373 function BetweenControls({ 15374 value, 15375 onChange, 15376 hideLabelFromVision, 15377 step 15378 }) { 15379 const [min3 = "", max3 = ""] = value; 15380 const onChangeMin = (0, import_element45.useCallback)( 15381 (newValue) => onChange([toNumberOrEmpty(newValue), max3]), 15382 [onChange, max3] 15383 ); 15384 const onChangeMax = (0, import_element45.useCallback)( 15385 (newValue) => onChange([min3, toNumberOrEmpty(newValue)]), 15386 [onChange, min3] 15387 ); 15388 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 15389 import_components13.BaseControl, 15390 { 15391 help: (0, import_i18n9.__)("The max. value must be greater than the min. value."), 15392 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_components13.Flex, { direction: "row", gap: 4, children: [ 15393 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 15394 import_components13.__experimentalNumberControl, 15395 { 15396 label: (0, import_i18n9.__)("Min."), 15397 value: min3, 15398 max: max3 ? Number(max3) - step : void 0, 15399 onChange: onChangeMin, 15400 __next40pxDefaultSize: true, 15401 hideLabelFromVision, 15402 step 15403 } 15404 ), 15405 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 15406 import_components13.__experimentalNumberControl, 15407 { 15408 label: (0, import_i18n9.__)("Max."), 15409 value: max3, 15410 min: min3 ? Number(min3) + step : void 0, 15411 onChange: onChangeMax, 15412 __next40pxDefaultSize: true, 15413 hideLabelFromVision, 15414 step 15415 } 15416 ) 15417 ] }) 15418 } 15419 ); 15420 } 15421 function ValidatedNumber({ 15422 data, 15423 field, 15424 onChange, 15425 hideLabelFromVision, 15426 markWhenOptional, 15427 operator, 15428 validity 15429 }) { 15430 const decimals = field.format?.decimals ?? 0; 15431 const step = Math.pow(10, Math.abs(decimals) * -1); 15432 const { label, description, getValue, setValue, isValid: isValid2 } = field; 15433 const value = getValue({ item: data }) ?? ""; 15434 const disabled2 = field.isDisabled({ item: data, field }); 15435 const onChangeControl = (0, import_element45.useCallback)( 15436 (newValue) => { 15437 onChange( 15438 setValue({ 15439 item: data, 15440 // Do not convert an empty string or undefined to a number, 15441 // otherwise there's a mismatch between the UI control (empty) 15442 // and the data relied by onChange (0). 15443 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue) 15444 }) 15445 ); 15446 }, 15447 [data, onChange, setValue] 15448 ); 15449 const onChangeBetweenControls = (0, import_element45.useCallback)( 15450 (newValue) => { 15451 onChange( 15452 setValue({ 15453 item: data, 15454 value: newValue 15455 }) 15456 ); 15457 }, 15458 [data, onChange, setValue] 15459 ); 15460 if (operator === OPERATOR_BETWEEN) { 15461 let valueBetween = ["", ""]; 15462 if (Array.isArray(value) && value.length === 2 && value.every( 15463 (element) => typeof element === "number" || element === "" 15464 )) { 15465 valueBetween = value; 15466 } 15467 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 15468 BetweenControls, 15469 { 15470 value: valueBetween, 15471 onChange: onChangeBetweenControls, 15472 hideLabelFromVision, 15473 step 15474 } 15475 ); 15476 } 15477 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 15478 ValidatedNumberControl, 15479 { 15480 required: !!isValid2.required, 15481 markWhenOptional, 15482 customValidity: getCustomValidity(isValid2, validity), 15483 label, 15484 help: description, 15485 value, 15486 onChange: onChangeControl, 15487 __next40pxDefaultSize: true, 15488 hideLabelFromVision, 15489 step, 15490 min: isValid2.min ? isValid2.min.constraint : void 0, 15491 max: isValid2.max ? isValid2.max.constraint : void 0, 15492 disabled: disabled2 15493 } 15494 ); 15495 } 15496 15497 // packages/dataviews/build-module/components/dataform-controls/integer.mjs 15498 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1); 15499 function Integer(props) { 15500 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ValidatedNumber, { ...props }); 15501 } 15502 15503 // packages/dataviews/build-module/components/dataform-controls/number.mjs 15504 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1); 15505 function Number2(props) { 15506 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ValidatedNumber, { ...props }); 15507 } 15508 15509 // packages/dataviews/build-module/components/dataform-controls/radio.mjs 15510 var import_components14 = __toESM(require_components(), 1); 15511 var import_element46 = __toESM(require_element(), 1); 15512 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1); 15513 var { ValidatedRadioControl } = unlock2(import_components14.privateApis); 15514 function Radio({ 15515 data, 15516 field, 15517 onChange, 15518 hideLabelFromVision, 15519 markWhenOptional, 15520 validity 15521 }) { 15522 const { label, description, getValue, setValue, isValid: isValid2 } = field; 15523 const disabled2 = field.isDisabled({ item: data, field }); 15524 const { elements, isLoading } = useElements({ 15525 elements: field.elements, 15526 getElements: field.getElements 15527 }); 15528 const value = getValue({ item: data }); 15529 const onChangeControl = (0, import_element46.useCallback)( 15530 (newValue) => onChange(setValue({ item: data, value: newValue })), 15531 [data, onChange, setValue] 15532 ); 15533 if (isLoading) { 15534 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components14.Spinner, {}); 15535 } 15536 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 15537 ValidatedRadioControl, 15538 { 15539 required: !!field.isValid?.required, 15540 markWhenOptional, 15541 customValidity: getCustomValidity(isValid2, validity), 15542 label, 15543 help: description, 15544 onChange: onChangeControl, 15545 options: elements, 15546 selected: value, 15547 hideLabelFromVision, 15548 disabled: disabled2 15549 } 15550 ); 15551 } 15552 15553 // packages/dataviews/build-module/components/dataform-controls/text.mjs 15554 var import_element47 = __toESM(require_element(), 1); 15555 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1); 15556 function Text3({ 15557 data, 15558 field, 15559 onChange, 15560 hideLabelFromVision, 15561 markWhenOptional, 15562 config, 15563 validity 15564 }) { 15565 const { prefix, suffix } = config || {}; 15566 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 15567 ValidatedText, 15568 { 15569 ...{ 15570 data, 15571 field, 15572 onChange, 15573 hideLabelFromVision, 15574 markWhenOptional, 15575 validity, 15576 prefix: prefix ? (0, import_element47.createElement)(prefix) : void 0, 15577 suffix: suffix ? (0, import_element47.createElement)(suffix) : void 0 15578 } 15579 } 15580 ); 15581 } 15582 15583 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs 15584 var import_components15 = __toESM(require_components(), 1); 15585 var import_element48 = __toESM(require_element(), 1); 15586 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1); 15587 var { ValidatedToggleControl } = unlock2(import_components15.privateApis); 15588 function Toggle({ 15589 field, 15590 onChange, 15591 data, 15592 hideLabelFromVision, 15593 markWhenOptional, 15594 validity 15595 }) { 15596 const { label, description, getValue, setValue, isValid: isValid2 } = field; 15597 const disabled2 = field.isDisabled({ item: data, field }); 15598 const onChangeControl = (0, import_element48.useCallback)(() => { 15599 onChange( 15600 setValue({ item: data, value: !getValue({ item: data }) }) 15601 ); 15602 }, [onChange, setValue, data, getValue]); 15603 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15604 ValidatedToggleControl, 15605 { 15606 required: !!isValid2.required, 15607 markWhenOptional, 15608 customValidity: getCustomValidity(isValid2, validity), 15609 hidden: hideLabelFromVision, 15610 label, 15611 help: description, 15612 checked: getValue({ item: data }), 15613 onChange: onChangeControl, 15614 disabled: disabled2 15615 } 15616 ); 15617 } 15618 15619 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs 15620 var import_components16 = __toESM(require_components(), 1); 15621 var import_element49 = __toESM(require_element(), 1); 15622 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1); 15623 var { ValidatedTextareaControl } = unlock2(import_components16.privateApis); 15624 function Textarea({ 15625 data, 15626 field, 15627 onChange, 15628 hideLabelFromVision, 15629 markWhenOptional, 15630 config, 15631 validity 15632 }) { 15633 const { rows = 4 } = config || {}; 15634 const disabled2 = field.isDisabled({ item: data, field }); 15635 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 15636 const value = field.getValue({ item: data }); 15637 const onChangeControl = (0, import_element49.useCallback)( 15638 (newValue) => onChange(setValue({ item: data, value: newValue })), 15639 [data, onChange, setValue] 15640 ); 15641 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 15642 ValidatedTextareaControl, 15643 { 15644 required: !!isValid2.required, 15645 markWhenOptional, 15646 customValidity: getCustomValidity(isValid2, validity), 15647 label, 15648 placeholder, 15649 value: value ?? "", 15650 help: description, 15651 onChange: onChangeControl, 15652 rows, 15653 disabled: disabled2, 15654 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 15655 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 15656 __next40pxDefaultSize: true, 15657 hideLabelFromVision 15658 } 15659 ); 15660 } 15661 15662 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs 15663 var import_components17 = __toESM(require_components(), 1); 15664 var import_element50 = __toESM(require_element(), 1); 15665 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1); 15666 var { ValidatedToggleGroupControl } = unlock2(import_components17.privateApis); 15667 function ToggleGroup({ 15668 data, 15669 field, 15670 onChange, 15671 hideLabelFromVision, 15672 markWhenOptional, 15673 validity 15674 }) { 15675 const { getValue, setValue, isValid: isValid2 } = field; 15676 const disabled2 = field.isDisabled({ item: data, field }); 15677 const value = getValue({ item: data }); 15678 const onChangeControl = (0, import_element50.useCallback)( 15679 (newValue) => onChange(setValue({ item: data, value: newValue })), 15680 [data, onChange, setValue] 15681 ); 15682 const { elements, isLoading } = useElements({ 15683 elements: field.elements, 15684 getElements: field.getElements 15685 }); 15686 if (isLoading) { 15687 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components17.Spinner, {}); 15688 } 15689 if (elements.length === 0) { 15690 return null; 15691 } 15692 const selectedOption = elements.find((el) => el.value === value); 15693 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 15694 ValidatedToggleGroupControl, 15695 { 15696 required: !!field.isValid?.required, 15697 markWhenOptional, 15698 customValidity: getCustomValidity(isValid2, validity), 15699 __next40pxDefaultSize: true, 15700 isBlock: true, 15701 label: field.label, 15702 help: selectedOption?.description || field.description, 15703 onChange: onChangeControl, 15704 value, 15705 hideLabelFromVision, 15706 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 15707 import_components17.__experimentalToggleGroupControlOption, 15708 { 15709 label: el.label, 15710 value: el.value, 15711 disabled: disabled2 15712 }, 15713 el.value 15714 )) 15715 } 15716 ); 15717 } 15718 15719 // packages/dataviews/build-module/components/dataform-controls/array.mjs 15720 var import_components18 = __toESM(require_components(), 1); 15721 var import_element51 = __toESM(require_element(), 1); 15722 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1); 15723 var { ValidatedFormTokenField } = unlock2(import_components18.privateApis); 15724 function ArrayControl({ 15725 data, 15726 field, 15727 onChange, 15728 hideLabelFromVision, 15729 markWhenOptional, 15730 validity 15731 }) { 15732 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 15733 const value = getValue({ item: data }); 15734 const disabled2 = field.isDisabled({ item: data, field }); 15735 const { elements, isLoading } = useElements({ 15736 elements: field.elements, 15737 getElements: field.getElements 15738 }); 15739 const arrayValueAsElements = (0, import_element51.useMemo)( 15740 () => Array.isArray(value) ? value.map((token) => { 15741 const element = elements?.find( 15742 (suggestion) => suggestion.value === token 15743 ); 15744 return element || { value: token, label: token }; 15745 }) : [], 15746 [value, elements] 15747 ); 15748 const onChangeControl = (0, import_element51.useCallback)( 15749 (tokens) => { 15750 const valueTokens = tokens.map((token) => { 15751 if (typeof token === "object" && "value" in token) { 15752 return token.value; 15753 } 15754 return token; 15755 }); 15756 onChange(setValue({ item: data, value: valueTokens })); 15757 }, 15758 [onChange, setValue, data] 15759 ); 15760 if (isLoading) { 15761 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components18.Spinner, {}); 15762 } 15763 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 15764 ValidatedFormTokenField, 15765 { 15766 required: !!isValid2?.required, 15767 markWhenOptional, 15768 customValidity: getCustomValidity(isValid2, validity), 15769 label: hideLabelFromVision ? void 0 : label, 15770 value: arrayValueAsElements, 15771 onChange: onChangeControl, 15772 placeholder, 15773 suggestions: elements?.map((element) => element.value), 15774 disabled: disabled2, 15775 __experimentalValidateInput: (token) => { 15776 if (field.isValid?.elements && elements) { 15777 return elements.some( 15778 (element) => element.value === token || element.label === token 15779 ); 15780 } 15781 return true; 15782 }, 15783 __experimentalExpandOnFocus: elements && elements.length > 0, 15784 help: description ?? (field.isValid?.elements ? "" : void 0), 15785 displayTransform: (token) => { 15786 if (typeof token === "object" && "label" in token) { 15787 return token.label; 15788 } 15789 if (typeof token === "string" && elements) { 15790 const element = elements.find( 15791 (el) => el.value === token 15792 ); 15793 return element?.label || token; 15794 } 15795 return token; 15796 }, 15797 __experimentalRenderItem: ({ item }) => { 15798 if (typeof item === "string" && elements) { 15799 const element = elements.find( 15800 (el) => el.value === item 15801 ); 15802 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { children: element?.label || item }); 15803 } 15804 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { children: item }); 15805 } 15806 } 15807 ); 15808 } 15809 15810 // node_modules/colord/index.mjs 15811 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 15812 var t = function(r3) { 15813 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 15814 }; 15815 var n = function(r3, t2, n2) { 15816 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0; 15817 }; 15818 var e = function(r3, t2, n2) { 15819 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2; 15820 }; 15821 var u = function(r3) { 15822 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360; 15823 }; 15824 var a = function(r3) { 15825 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) }; 15826 }; 15827 var o = function(r3) { 15828 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 15829 }; 15830 var i = /^#([0-9a-f]{3,8})$/i; 15831 var s = function(r3) { 15832 var t2 = r3.toString(16); 15833 return t2.length < 2 ? "0" + t2 : t2; 15834 }; 15835 var h = function(r3) { 15836 var t2 = r3.r, n2 = r3.g, e2 = r3.b, u2 = r3.a, a2 = Math.max(t2, n2, e2), o2 = a2 - Math.min(t2, n2, e2), i2 = o2 ? a2 === t2 ? (n2 - e2) / o2 : a2 === n2 ? 2 + (e2 - t2) / o2 : 4 + (t2 - n2) / o2 : 0; 15837 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 15838 }; 15839 var b = function(r3) { 15840 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a; 15841 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100; 15842 var a2 = Math.floor(t2), o2 = e2 * (1 - n2), i2 = e2 * (1 - (t2 - a2) * n2), s2 = e2 * (1 - (1 - t2 + a2) * n2), h2 = a2 % 6; 15843 return { r: 255 * [e2, i2, o2, o2, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o2, o2][h2], b: 255 * [o2, o2, s2, e2, e2, i2][h2], a: u2 }; 15844 }; 15845 var g = function(r3) { 15846 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) }; 15847 }; 15848 var d = function(r3) { 15849 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) }; 15850 }; 15851 var f = function(r3) { 15852 return b((n2 = (t2 = r3).s, { h: t2.h, s: (n2 *= ((e2 = t2.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t2.a })); 15853 var t2, n2, e2; 15854 }; 15855 var c = function(r3) { 15856 return { h: (t2 = h(r3)).h, s: (u2 = (200 - (n2 = t2.s)) * (e2 = t2.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t2.a }; 15857 var t2, n2, e2, u2; 15858 }; 15859 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 15860 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 15861 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 15862 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 15863 var y = { string: [[function(r3) { 15864 var t2 = i.exec(r3); 15865 return t2 ? (r3 = t2[1]).length <= 4 ? { r: parseInt(r3[0] + r3[0], 16), g: parseInt(r3[1] + r3[1], 16), b: parseInt(r3[2] + r3[2], 16), a: 4 === r3.length ? n(parseInt(r3[3] + r3[3], 16) / 255, 2) : 1 } : 6 === r3.length || 8 === r3.length ? { r: parseInt(r3.substr(0, 2), 16), g: parseInt(r3.substr(2, 2), 16), b: parseInt(r3.substr(4, 2), 16), a: 8 === r3.length ? n(parseInt(r3.substr(6, 2), 16) / 255, 2) : 1 } : null : null; 15866 }, "hex"], [function(r3) { 15867 var t2 = v.exec(r3) || m.exec(r3); 15868 return t2 ? t2[2] !== t2[4] || t2[4] !== t2[6] ? null : a({ r: Number(t2[1]) / (t2[2] ? 100 / 255 : 1), g: Number(t2[3]) / (t2[4] ? 100 / 255 : 1), b: Number(t2[5]) / (t2[6] ? 100 / 255 : 1), a: void 0 === t2[7] ? 1 : Number(t2[7]) / (t2[8] ? 100 : 1) }) : null; 15869 }, "rgb"], [function(t2) { 15870 var n2 = l.exec(t2) || p.exec(t2); 15871 if (!n2) return null; 15872 var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r2[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) }); 15873 return f(a2); 15874 }, "hsl"]], object: [[function(r3) { 15875 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2; 15876 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 15877 }, "rgb"], [function(r3) { 15878 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2; 15879 if (!t(n2) || !t(e2) || !t(u2)) return null; 15880 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) }); 15881 return f(i2); 15882 }, "hsl"], [function(r3) { 15883 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2; 15884 if (!t(n2) || !t(a2) || !t(o2)) return null; 15885 var h2 = (function(r4) { 15886 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) }; 15887 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) }); 15888 return b(h2); 15889 }, "hsv"]] }; 15890 var N = function(r3, t2) { 15891 for (var n2 = 0; n2 < t2.length; n2++) { 15892 var e2 = t2[n2][0](r3); 15893 if (e2) return [e2, t2[n2][1]]; 15894 } 15895 return [null, void 0]; 15896 }; 15897 var x = function(r3) { 15898 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0]; 15899 }; 15900 var M = function(r3, t2) { 15901 var n2 = c(r3); 15902 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a }; 15903 }; 15904 var H = function(r3) { 15905 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255; 15906 }; 15907 var $ = function(r3, t2) { 15908 var n2 = c(r3); 15909 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a }; 15910 }; 15911 var j = (function() { 15912 function r3(r4) { 15913 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 15914 } 15915 return r3.prototype.isValid = function() { 15916 return null !== this.parsed; 15917 }, r3.prototype.brightness = function() { 15918 return n(H(this.rgba), 2); 15919 }, r3.prototype.isDark = function() { 15920 return H(this.rgba) < 0.5; 15921 }, r3.prototype.isLight = function() { 15922 return H(this.rgba) >= 0.5; 15923 }, r3.prototype.toHex = function() { 15924 return r4 = o(this.rgba), t2 = r4.r, e2 = r4.g, u2 = r4.b, i2 = (a2 = r4.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t2) + s(e2) + s(u2) + i2; 15925 var r4, t2, e2, u2, a2, i2; 15926 }, r3.prototype.toRgb = function() { 15927 return o(this.rgba); 15928 }, r3.prototype.toRgbString = function() { 15929 return r4 = o(this.rgba), t2 = r4.r, n2 = r4.g, e2 = r4.b, (u2 = r4.a) < 1 ? "rgba(" + t2 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t2 + ", " + n2 + ", " + e2 + ")"; 15930 var r4, t2, n2, e2, u2; 15931 }, r3.prototype.toHsl = function() { 15932 return d(c(this.rgba)); 15933 }, r3.prototype.toHslString = function() { 15934 return r4 = d(c(this.rgba)), t2 = r4.h, n2 = r4.s, e2 = r4.l, (u2 = r4.a) < 1 ? "hsla(" + t2 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t2 + ", " + n2 + "%, " + e2 + "%)"; 15935 var r4, t2, n2, e2, u2; 15936 }, r3.prototype.toHsv = function() { 15937 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) }; 15938 var r4; 15939 }, r3.prototype.invert = function() { 15940 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a }); 15941 var r4; 15942 }, r3.prototype.saturate = function(r4) { 15943 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4)); 15944 }, r3.prototype.desaturate = function(r4) { 15945 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4)); 15946 }, r3.prototype.grayscale = function() { 15947 return w(M(this.rgba, -1)); 15948 }, r3.prototype.lighten = function(r4) { 15949 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4)); 15950 }, r3.prototype.darken = function(r4) { 15951 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4)); 15952 }, r3.prototype.rotate = function(r4) { 15953 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4); 15954 }, r3.prototype.alpha = function(r4) { 15955 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3); 15956 var t2; 15957 }, r3.prototype.hue = function(r4) { 15958 var t2 = c(this.rgba); 15959 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h); 15960 }, r3.prototype.isEqual = function(r4) { 15961 return this.toHex() === w(r4).toHex(); 15962 }, r3; 15963 })(); 15964 var w = function(r3) { 15965 return r3 instanceof j ? r3 : new j(r3); 15966 }; 15967 15968 // packages/dataviews/build-module/components/dataform-controls/color.mjs 15969 var import_components19 = __toESM(require_components(), 1); 15970 var import_element52 = __toESM(require_element(), 1); 15971 var import_i18n10 = __toESM(require_i18n(), 1); 15972 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1); 15973 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components19.privateApis); 15974 var ColorPickerDropdown = ({ 15975 color, 15976 onColorChange, 15977 disabled: disabled2 15978 }) => { 15979 const validColor = color && w(color).isValid() ? color : "#ffffff"; 15980 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15981 import_components19.Dropdown, 15982 { 15983 className: "dataviews-controls__color-picker-dropdown", 15984 popoverProps: { resize: false }, 15985 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15986 import_components19.Button, 15987 { 15988 onClick: onToggle, 15989 "aria-label": (0, import_i18n10.__)("Open color picker"), 15990 size: "small", 15991 disabled: disabled2, 15992 accessibleWhenDisabled: true, 15993 icon: () => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components19.ColorIndicator, { colorValue: validColor }) 15994 } 15995 ), 15996 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components19.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15997 import_components19.ColorPicker, 15998 { 15999 color: validColor, 16000 onChange: onColorChange, 16001 enableAlpha: true 16002 } 16003 ) }) 16004 } 16005 ); 16006 }; 16007 function Color({ 16008 data, 16009 field, 16010 onChange, 16011 hideLabelFromVision, 16012 markWhenOptional, 16013 validity 16014 }) { 16015 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 16016 const disabled2 = field.isDisabled({ item: data, field }); 16017 const value = field.getValue({ item: data }) || ""; 16018 const handleColorChange = (0, import_element52.useCallback)( 16019 (newColor) => { 16020 onChange(setValue({ item: data, value: newColor })); 16021 }, 16022 [data, onChange, setValue] 16023 ); 16024 const handleInputChange = (0, import_element52.useCallback)( 16025 (newValue) => { 16026 onChange(setValue({ item: data, value: newValue || "" })); 16027 }, 16028 [data, onChange, setValue] 16029 ); 16030 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 16031 ValidatedInputControl3, 16032 { 16033 required: !!field.isValid?.required, 16034 markWhenOptional, 16035 customValidity: getCustomValidity(isValid2, validity), 16036 label, 16037 placeholder, 16038 value, 16039 help: description, 16040 onChange: handleInputChange, 16041 hideLabelFromVision, 16042 type: "text", 16043 disabled: disabled2, 16044 prefix: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components19.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 16045 ColorPickerDropdown, 16046 { 16047 color: value, 16048 onColorChange: handleColorChange, 16049 disabled: disabled2 16050 } 16051 ) }) 16052 } 16053 ); 16054 } 16055 16056 // packages/dataviews/build-module/components/dataform-controls/password.mjs 16057 var import_components20 = __toESM(require_components(), 1); 16058 var import_element53 = __toESM(require_element(), 1); 16059 var import_i18n11 = __toESM(require_i18n(), 1); 16060 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1); 16061 function Password({ 16062 data, 16063 field, 16064 onChange, 16065 hideLabelFromVision, 16066 markWhenOptional, 16067 validity 16068 }) { 16069 const [isVisible, setIsVisible] = (0, import_element53.useState)(false); 16070 const disabled2 = field.isDisabled({ item: data, field }); 16071 const toggleVisibility = (0, import_element53.useCallback)(() => { 16072 setIsVisible((prev) => !prev); 16073 }, []); 16074 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16075 ValidatedText, 16076 { 16077 ...{ 16078 data, 16079 field, 16080 onChange, 16081 hideLabelFromVision, 16082 markWhenOptional, 16083 validity, 16084 type: isVisible ? "text" : "password", 16085 suffix: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components20.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 16086 import_components20.Button, 16087 { 16088 icon: isVisible ? unseen_default : seen_default, 16089 onClick: toggleVisibility, 16090 size: "small", 16091 label: isVisible ? (0, import_i18n11.__)("Hide password") : (0, import_i18n11.__)("Show password"), 16092 disabled: disabled2, 16093 accessibleWhenDisabled: true 16094 } 16095 ) }) 16096 } 16097 } 16098 ); 16099 } 16100 16101 // packages/dataviews/build-module/field-types/utils/has-elements.mjs 16102 function hasElements(field) { 16103 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function"; 16104 } 16105 16106 // packages/dataviews/build-module/components/dataform-controls/index.mjs 16107 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1); 16108 var FORM_CONTROLS = { 16109 adaptiveSelect: AdaptiveSelect, 16110 array: ArrayControl, 16111 checkbox: Checkbox, 16112 color: Color, 16113 combobox: Combobox, 16114 datetime: DateTime, 16115 date: DateControl, 16116 email: Email, 16117 telephone: Telephone, 16118 url: Url, 16119 integer: Integer, 16120 number: Number2, 16121 password: Password, 16122 radio: Radio, 16123 select: Select, 16124 text: Text3, 16125 toggle: Toggle, 16126 textarea: Textarea, 16127 toggleGroup: ToggleGroup 16128 }; 16129 function isEditConfig(value) { 16130 return value && typeof value === "object" && typeof value.control === "string"; 16131 } 16132 function createConfiguredControl(config) { 16133 const { control, ...controlConfig } = config; 16134 const BaseControlType = getControlByType(control); 16135 if (BaseControlType === null) { 16136 return null; 16137 } 16138 return function ConfiguredControl(props) { 16139 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(BaseControlType, { ...props, config: controlConfig }); 16140 }; 16141 } 16142 function getControl(field, fallback) { 16143 if (typeof field.Edit === "function") { 16144 return field.Edit; 16145 } 16146 if (typeof field.Edit === "string") { 16147 return getControlByType(field.Edit); 16148 } 16149 if (isEditConfig(field.Edit)) { 16150 return createConfiguredControl(field.Edit); 16151 } 16152 if (hasElements(field) && field.type !== "array") { 16153 return getControlByType("adaptiveSelect"); 16154 } 16155 if (fallback === null) { 16156 return null; 16157 } 16158 return getControlByType(fallback); 16159 } 16160 function getControlByType(type) { 16161 if (Object.keys(FORM_CONTROLS).includes(type)) { 16162 return FORM_CONTROLS[type]; 16163 } 16164 return null; 16165 } 16166 16167 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs 16168 function getFilterBy(field, defaultOperators, validOperators) { 16169 if (field.filterBy === false) { 16170 return false; 16171 } 16172 const operators = field.filterBy?.operators?.filter( 16173 (op) => validOperators.includes(op) 16174 ) ?? defaultOperators; 16175 if (operators.length === 0) { 16176 return false; 16177 } 16178 return { 16179 isPrimary: !!field.filterBy?.isPrimary, 16180 operators 16181 }; 16182 } 16183 var get_filter_by_default = getFilterBy; 16184 16185 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs 16186 var getValueFromId = (id) => ({ item }) => { 16187 const path = id.split("."); 16188 let value = item; 16189 for (const segment of path) { 16190 if (value.hasOwnProperty(segment)) { 16191 value = value[segment]; 16192 } else { 16193 value = void 0; 16194 } 16195 } 16196 return value; 16197 }; 16198 var get_value_from_id_default = getValueFromId; 16199 16200 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs 16201 var setValueFromId = (id) => ({ value }) => { 16202 const path = id.split("."); 16203 const result = {}; 16204 let current = result; 16205 for (const segment of path.slice(0, -1)) { 16206 current[segment] = {}; 16207 current = current[segment]; 16208 } 16209 current[path.at(-1)] = value; 16210 return result; 16211 }; 16212 var set_value_from_id_default = setValueFromId; 16213 16214 // packages/dataviews/build-module/field-types/email.mjs 16215 var import_i18n12 = __toESM(require_i18n(), 1); 16216 16217 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs 16218 function RenderFromElements({ 16219 item, 16220 field 16221 }) { 16222 const { elements, isLoading } = useElements({ 16223 elements: field.elements, 16224 getElements: field.getElements 16225 }); 16226 const value = field.getValue({ item }); 16227 if (isLoading) { 16228 return value; 16229 } 16230 if (elements.length === 0) { 16231 return value; 16232 } 16233 return elements?.find((element) => element.value === value)?.label || field.getValue({ item }); 16234 } 16235 16236 // packages/dataviews/build-module/field-types/utils/render-default.mjs 16237 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1); 16238 function render({ 16239 item, 16240 field 16241 }) { 16242 if (field.hasElements) { 16243 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(RenderFromElements, { item, field }); 16244 } 16245 return field.getValueFormatted({ item, field }); 16246 } 16247 16248 // packages/dataviews/build-module/field-types/utils/sort-text.mjs 16249 var sort_text_default = (a2, b2, direction) => { 16250 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2); 16251 }; 16252 16253 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs 16254 function isValidRequired(item, field) { 16255 const value = field.getValue({ item }); 16256 return ![void 0, "", null].includes(value); 16257 } 16258 16259 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs 16260 function isValidMinLength(item, field) { 16261 if (typeof field.isValid.minLength?.constraint !== "number") { 16262 return false; 16263 } 16264 const value = field.getValue({ item }); 16265 if ([void 0, "", null].includes(value)) { 16266 return true; 16267 } 16268 return String(value).length >= field.isValid.minLength.constraint; 16269 } 16270 16271 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs 16272 function isValidMaxLength(item, field) { 16273 if (typeof field.isValid.maxLength?.constraint !== "number") { 16274 return false; 16275 } 16276 const value = field.getValue({ item }); 16277 if ([void 0, "", null].includes(value)) { 16278 return true; 16279 } 16280 return String(value).length <= field.isValid.maxLength.constraint; 16281 } 16282 16283 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs 16284 function isValidPattern(item, field) { 16285 if (field.isValid.pattern?.constraint === void 0) { 16286 return true; 16287 } 16288 try { 16289 const regexp = new RegExp(field.isValid.pattern.constraint); 16290 const value = field.getValue({ item }); 16291 if ([void 0, "", null].includes(value)) { 16292 return true; 16293 } 16294 return regexp.test(String(value)); 16295 } catch { 16296 return false; 16297 } 16298 } 16299 16300 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs 16301 function isValidElements(item, field) { 16302 const elements = field.elements ?? []; 16303 const validValues = elements.map((el) => el.value); 16304 if (validValues.length === 0) { 16305 return true; 16306 } 16307 const value = field.getValue({ item }); 16308 return [].concat(value).every((v2) => validValues.includes(v2)); 16309 } 16310 16311 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs 16312 function getValueFormatted({ 16313 item, 16314 field 16315 }) { 16316 return field.getValue({ item }); 16317 } 16318 var get_value_formatted_default_default = getValueFormatted; 16319 16320 // packages/dataviews/build-module/field-types/email.mjs 16321 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])?)*$/; 16322 function isValidCustom(item, field) { 16323 const value = field.getValue({ item }); 16324 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) { 16325 return (0, import_i18n12.__)("Value must be a valid email address."); 16326 } 16327 return null; 16328 } 16329 var email_default = { 16330 type: "email", 16331 render, 16332 Edit: "email", 16333 sort: sort_text_default, 16334 enableSorting: true, 16335 enableGlobalSearch: false, 16336 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 16337 validOperators: [ 16338 OPERATOR_IS, 16339 OPERATOR_IS_NOT, 16340 OPERATOR_CONTAINS, 16341 OPERATOR_NOT_CONTAINS, 16342 OPERATOR_STARTS_WITH, 16343 // Multiple selection 16344 OPERATOR_IS_ANY, 16345 OPERATOR_IS_NONE, 16346 OPERATOR_IS_ALL, 16347 OPERATOR_IS_NOT_ALL 16348 ], 16349 format: {}, 16350 getValueFormatted: get_value_formatted_default_default, 16351 validate: { 16352 required: isValidRequired, 16353 pattern: isValidPattern, 16354 minLength: isValidMinLength, 16355 maxLength: isValidMaxLength, 16356 elements: isValidElements, 16357 custom: isValidCustom 16358 } 16359 }; 16360 16361 // packages/dataviews/build-module/field-types/integer.mjs 16362 var import_i18n13 = __toESM(require_i18n(), 1); 16363 16364 // packages/dataviews/build-module/field-types/utils/sort-number.mjs 16365 var sort_number_default = (a2, b2, direction) => { 16366 return direction === "asc" ? a2 - b2 : b2 - a2; 16367 }; 16368 16369 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs 16370 function isValidMin(item, field) { 16371 if (typeof field.isValid.min?.constraint !== "number") { 16372 return false; 16373 } 16374 const value = field.getValue({ item }); 16375 if ([void 0, "", null].includes(value)) { 16376 return true; 16377 } 16378 return Number(value) >= field.isValid.min.constraint; 16379 } 16380 16381 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs 16382 function isValidMax(item, field) { 16383 if (typeof field.isValid.max?.constraint !== "number") { 16384 return false; 16385 } 16386 const value = field.getValue({ item }); 16387 if ([void 0, "", null].includes(value)) { 16388 return true; 16389 } 16390 return Number(value) <= field.isValid.max.constraint; 16391 } 16392 16393 // packages/dataviews/build-module/field-types/integer.mjs 16394 var format2 = { 16395 separatorThousand: "," 16396 }; 16397 function getValueFormatted2({ 16398 item, 16399 field 16400 }) { 16401 let value = field.getValue({ item }); 16402 if (value === null || value === void 0) { 16403 return ""; 16404 } 16405 value = Number(value); 16406 if (!Number.isFinite(value)) { 16407 return String(value); 16408 } 16409 let formatInteger; 16410 if (field.type !== "integer") { 16411 formatInteger = format2; 16412 } else { 16413 formatInteger = field.format; 16414 } 16415 const { separatorThousand } = formatInteger; 16416 const integerValue = Math.trunc(value); 16417 if (!separatorThousand) { 16418 return String(integerValue); 16419 } 16420 return String(integerValue).replace( 16421 /\B(?=(\d{3})+(?!\d))/g, 16422 separatorThousand 16423 ); 16424 } 16425 function isValidCustom2(item, field) { 16426 const value = field.getValue({ item }); 16427 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) { 16428 return (0, import_i18n13.__)("Value must be an integer."); 16429 } 16430 return null; 16431 } 16432 var integer_default = { 16433 type: "integer", 16434 render, 16435 Edit: "integer", 16436 sort: sort_number_default, 16437 enableSorting: true, 16438 enableGlobalSearch: false, 16439 defaultOperators: [ 16440 OPERATOR_IS, 16441 OPERATOR_IS_NOT, 16442 OPERATOR_LESS_THAN, 16443 OPERATOR_GREATER_THAN, 16444 OPERATOR_LESS_THAN_OR_EQUAL, 16445 OPERATOR_GREATER_THAN_OR_EQUAL, 16446 OPERATOR_BETWEEN 16447 ], 16448 validOperators: [ 16449 // Single-selection 16450 OPERATOR_IS, 16451 OPERATOR_IS_NOT, 16452 OPERATOR_LESS_THAN, 16453 OPERATOR_GREATER_THAN, 16454 OPERATOR_LESS_THAN_OR_EQUAL, 16455 OPERATOR_GREATER_THAN_OR_EQUAL, 16456 OPERATOR_BETWEEN, 16457 // Multiple-selection 16458 OPERATOR_IS_ANY, 16459 OPERATOR_IS_NONE, 16460 OPERATOR_IS_ALL, 16461 OPERATOR_IS_NOT_ALL 16462 ], 16463 format: format2, 16464 getValueFormatted: getValueFormatted2, 16465 validate: { 16466 required: isValidRequired, 16467 min: isValidMin, 16468 max: isValidMax, 16469 elements: isValidElements, 16470 custom: isValidCustom2 16471 } 16472 }; 16473 16474 // packages/dataviews/build-module/field-types/number.mjs 16475 var import_i18n14 = __toESM(require_i18n(), 1); 16476 var format3 = { 16477 separatorThousand: ",", 16478 separatorDecimal: ".", 16479 decimals: 2 16480 }; 16481 function getValueFormatted3({ 16482 item, 16483 field 16484 }) { 16485 let value = field.getValue({ item }); 16486 if (value === null || value === void 0) { 16487 return ""; 16488 } 16489 value = Number(value); 16490 if (!Number.isFinite(value)) { 16491 return String(value); 16492 } 16493 let formatNumber; 16494 if (field.type !== "number") { 16495 formatNumber = format3; 16496 } else { 16497 formatNumber = field.format; 16498 } 16499 const { separatorThousand, separatorDecimal, decimals } = formatNumber; 16500 const fixedValue = value.toFixed(decimals); 16501 const [integerPart, decimalPart] = fixedValue.split("."); 16502 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart; 16503 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart; 16504 } 16505 function isEmpty(value) { 16506 return value === "" || value === void 0 || value === null; 16507 } 16508 function isValidCustom3(item, field) { 16509 const value = field.getValue({ item }); 16510 if (!isEmpty(value) && !Number.isFinite(value)) { 16511 return (0, import_i18n14.__)("Value must be a number."); 16512 } 16513 return null; 16514 } 16515 var number_default = { 16516 type: "number", 16517 render, 16518 Edit: "number", 16519 sort: sort_number_default, 16520 enableSorting: true, 16521 enableGlobalSearch: false, 16522 defaultOperators: [ 16523 OPERATOR_IS, 16524 OPERATOR_IS_NOT, 16525 OPERATOR_LESS_THAN, 16526 OPERATOR_GREATER_THAN, 16527 OPERATOR_LESS_THAN_OR_EQUAL, 16528 OPERATOR_GREATER_THAN_OR_EQUAL, 16529 OPERATOR_BETWEEN 16530 ], 16531 validOperators: [ 16532 // Single-selection 16533 OPERATOR_IS, 16534 OPERATOR_IS_NOT, 16535 OPERATOR_LESS_THAN, 16536 OPERATOR_GREATER_THAN, 16537 OPERATOR_LESS_THAN_OR_EQUAL, 16538 OPERATOR_GREATER_THAN_OR_EQUAL, 16539 OPERATOR_BETWEEN, 16540 // Multiple-selection 16541 OPERATOR_IS_ANY, 16542 OPERATOR_IS_NONE, 16543 OPERATOR_IS_ALL, 16544 OPERATOR_IS_NOT_ALL 16545 ], 16546 format: format3, 16547 getValueFormatted: getValueFormatted3, 16548 validate: { 16549 required: isValidRequired, 16550 min: isValidMin, 16551 max: isValidMax, 16552 elements: isValidElements, 16553 custom: isValidCustom3 16554 } 16555 }; 16556 16557 // packages/dataviews/build-module/field-types/text.mjs 16558 var text_default = { 16559 type: "text", 16560 render, 16561 Edit: "text", 16562 sort: sort_text_default, 16563 enableSorting: true, 16564 enableGlobalSearch: false, 16565 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 16566 validOperators: [ 16567 // Single selection 16568 OPERATOR_IS, 16569 OPERATOR_IS_NOT, 16570 OPERATOR_CONTAINS, 16571 OPERATOR_NOT_CONTAINS, 16572 OPERATOR_STARTS_WITH, 16573 // Multiple selection 16574 OPERATOR_IS_ANY, 16575 OPERATOR_IS_NONE, 16576 OPERATOR_IS_ALL, 16577 OPERATOR_IS_NOT_ALL 16578 ], 16579 format: {}, 16580 getValueFormatted: get_value_formatted_default_default, 16581 validate: { 16582 required: isValidRequired, 16583 pattern: isValidPattern, 16584 minLength: isValidMinLength, 16585 maxLength: isValidMaxLength, 16586 elements: isValidElements 16587 } 16588 }; 16589 16590 // packages/dataviews/build-module/field-types/datetime.mjs 16591 var import_date7 = __toESM(require_date(), 1); 16592 16593 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs 16594 var import_date6 = __toESM(require_date(), 1); 16595 function parseDateLike(value) { 16596 if (!value) { 16597 return null; 16598 } 16599 if (!isValid(new Date(value))) { 16600 return null; 16601 } 16602 const parsed = (0, import_date6.getDate)(value); 16603 return parsed && isValid(parsed) ? parsed : null; 16604 } 16605 function validateDateLikeBoundary(item, field, boundary) { 16606 const constraint = field.isValid[boundary]?.constraint; 16607 if (typeof constraint !== "string") { 16608 return false; 16609 } 16610 const value = field.getValue({ item }); 16611 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value; 16612 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") { 16613 return true; 16614 } 16615 const parsedConstraint = parseDateLike(constraint); 16616 const parsedValue = parseDateLike(String(boundaryValue)); 16617 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime()); 16618 } 16619 function isValidMinDate(item, field) { 16620 return validateDateLikeBoundary(item, field, "min"); 16621 } 16622 function isValidMaxDate(item, field) { 16623 return validateDateLikeBoundary(item, field, "max"); 16624 } 16625 16626 // packages/dataviews/build-module/field-types/datetime.mjs 16627 var format4 = { 16628 datetime: (0, import_date7.getSettings)().formats.datetime, 16629 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek 16630 }; 16631 function getValueFormatted4({ 16632 item, 16633 field 16634 }) { 16635 const value = field.getValue({ item }); 16636 if (["", void 0, null].includes(value)) { 16637 return ""; 16638 } 16639 let formatDatetime; 16640 if (field.type !== "datetime") { 16641 formatDatetime = format4; 16642 } else { 16643 formatDatetime = field.format; 16644 } 16645 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value)); 16646 } 16647 var sort = (a2, b2, direction) => { 16648 const timeA = new Date(a2).getTime(); 16649 const timeB = new Date(b2).getTime(); 16650 return direction === "asc" ? timeA - timeB : timeB - timeA; 16651 }; 16652 var datetime_default = { 16653 type: "datetime", 16654 render, 16655 Edit: "datetime", 16656 sort, 16657 enableSorting: true, 16658 enableGlobalSearch: false, 16659 defaultOperators: [ 16660 OPERATOR_ON, 16661 OPERATOR_NOT_ON, 16662 OPERATOR_BEFORE, 16663 OPERATOR_AFTER, 16664 OPERATOR_BEFORE_INC, 16665 OPERATOR_AFTER_INC, 16666 OPERATOR_IN_THE_PAST, 16667 OPERATOR_OVER 16668 ], 16669 validOperators: [ 16670 OPERATOR_ON, 16671 OPERATOR_NOT_ON, 16672 OPERATOR_BEFORE, 16673 OPERATOR_AFTER, 16674 OPERATOR_BEFORE_INC, 16675 OPERATOR_AFTER_INC, 16676 OPERATOR_IN_THE_PAST, 16677 OPERATOR_OVER 16678 ], 16679 format: format4, 16680 getValueFormatted: getValueFormatted4, 16681 validate: { 16682 required: isValidRequired, 16683 elements: isValidElements, 16684 min: isValidMinDate, 16685 max: isValidMaxDate 16686 } 16687 }; 16688 16689 // packages/dataviews/build-module/field-types/date.mjs 16690 var import_date8 = __toESM(require_date(), 1); 16691 var format5 = { 16692 date: (0, import_date8.getSettings)().formats.date, 16693 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek 16694 }; 16695 function getValueFormatted5({ 16696 item, 16697 field 16698 }) { 16699 const value = field.getValue({ item }); 16700 if (["", void 0, null].includes(value)) { 16701 return ""; 16702 } 16703 let formatDate2; 16704 if (field.type !== "date") { 16705 formatDate2 = format5; 16706 } else { 16707 formatDate2 = field.format; 16708 } 16709 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value)); 16710 } 16711 var sort2 = (a2, b2, direction) => { 16712 const timeA = new Date(a2).getTime(); 16713 const timeB = new Date(b2).getTime(); 16714 return direction === "asc" ? timeA - timeB : timeB - timeA; 16715 }; 16716 var date_default = { 16717 type: "date", 16718 render, 16719 Edit: "date", 16720 sort: sort2, 16721 enableSorting: true, 16722 enableGlobalSearch: false, 16723 defaultOperators: [ 16724 OPERATOR_ON, 16725 OPERATOR_NOT_ON, 16726 OPERATOR_BEFORE, 16727 OPERATOR_AFTER, 16728 OPERATOR_BEFORE_INC, 16729 OPERATOR_AFTER_INC, 16730 OPERATOR_IN_THE_PAST, 16731 OPERATOR_OVER, 16732 OPERATOR_BETWEEN 16733 ], 16734 validOperators: [ 16735 OPERATOR_ON, 16736 OPERATOR_NOT_ON, 16737 OPERATOR_BEFORE, 16738 OPERATOR_AFTER, 16739 OPERATOR_BEFORE_INC, 16740 OPERATOR_AFTER_INC, 16741 OPERATOR_IN_THE_PAST, 16742 OPERATOR_OVER, 16743 OPERATOR_BETWEEN 16744 ], 16745 format: format5, 16746 getValueFormatted: getValueFormatted5, 16747 validate: { 16748 required: isValidRequired, 16749 elements: isValidElements, 16750 min: isValidMinDate, 16751 max: isValidMaxDate 16752 } 16753 }; 16754 16755 // packages/dataviews/build-module/field-types/boolean.mjs 16756 var import_i18n15 = __toESM(require_i18n(), 1); 16757 16758 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs 16759 function isValidRequiredForBool(item, field) { 16760 const value = field.getValue({ item }); 16761 return value === true; 16762 } 16763 16764 // packages/dataviews/build-module/field-types/boolean.mjs 16765 function getValueFormatted6({ 16766 item, 16767 field 16768 }) { 16769 const value = field.getValue({ item }); 16770 if (value === true) { 16771 return (0, import_i18n15.__)("True"); 16772 } 16773 if (value === false) { 16774 return (0, import_i18n15.__)("False"); 16775 } 16776 return ""; 16777 } 16778 function isValidCustom4(item, field) { 16779 const value = field.getValue({ item }); 16780 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) { 16781 return (0, import_i18n15.__)("Value must be true, false, or undefined"); 16782 } 16783 return null; 16784 } 16785 var sort3 = (a2, b2, direction) => { 16786 const boolA = Boolean(a2); 16787 const boolB = Boolean(b2); 16788 if (boolA === boolB) { 16789 return 0; 16790 } 16791 if (direction === "asc") { 16792 return boolA ? 1 : -1; 16793 } 16794 return boolA ? -1 : 1; 16795 }; 16796 var boolean_default = { 16797 type: "boolean", 16798 render, 16799 Edit: "checkbox", 16800 sort: sort3, 16801 validate: { 16802 required: isValidRequiredForBool, 16803 elements: isValidElements, 16804 custom: isValidCustom4 16805 }, 16806 enableSorting: true, 16807 enableGlobalSearch: false, 16808 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 16809 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 16810 format: {}, 16811 getValueFormatted: getValueFormatted6 16812 }; 16813 16814 // packages/dataviews/build-module/field-types/media.mjs 16815 var media_default = { 16816 type: "media", 16817 render: () => null, 16818 Edit: null, 16819 sort: () => 0, 16820 enableSorting: false, 16821 enableGlobalSearch: false, 16822 defaultOperators: [], 16823 validOperators: [], 16824 format: {}, 16825 getValueFormatted: get_value_formatted_default_default, 16826 // cannot validate any constraint, so 16827 // the only available validation for the field author 16828 // would be providing a custom validator. 16829 validate: {} 16830 }; 16831 16832 // packages/dataviews/build-module/field-types/array.mjs 16833 var import_i18n16 = __toESM(require_i18n(), 1); 16834 16835 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs 16836 function isValidRequiredForArray(item, field) { 16837 const value = field.getValue({ item }); 16838 return Array.isArray(value) && value.length > 0 && value.every( 16839 (element) => ![void 0, "", null].includes(element) 16840 ); 16841 } 16842 16843 // packages/dataviews/build-module/field-types/array.mjs 16844 function getValueFormatted7({ 16845 item, 16846 field 16847 }) { 16848 const value = field.getValue({ item }); 16849 const arr = Array.isArray(value) ? value : []; 16850 return arr.join(", "); 16851 } 16852 function render2({ item, field }) { 16853 return getValueFormatted7({ item, field }); 16854 } 16855 function isValidCustom5(item, field) { 16856 const value = field.getValue({ item }); 16857 if (![void 0, "", null].includes(value) && !Array.isArray(value)) { 16858 return (0, import_i18n16.__)("Value must be an array."); 16859 } 16860 if (!value.every((v2) => typeof v2 === "string")) { 16861 return (0, import_i18n16.__)("Every value must be a string."); 16862 } 16863 return null; 16864 } 16865 var sort4 = (a2, b2, direction) => { 16866 const arrA = Array.isArray(a2) ? a2 : []; 16867 const arrB = Array.isArray(b2) ? b2 : []; 16868 if (arrA.length !== arrB.length) { 16869 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length; 16870 } 16871 const joinedA = arrA.join(","); 16872 const joinedB = arrB.join(","); 16873 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA); 16874 }; 16875 var array_default = { 16876 type: "array", 16877 render: render2, 16878 Edit: "array", 16879 sort: sort4, 16880 enableSorting: true, 16881 enableGlobalSearch: false, 16882 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 16883 validOperators: [ 16884 OPERATOR_IS_ANY, 16885 OPERATOR_IS_NONE, 16886 OPERATOR_IS_ALL, 16887 OPERATOR_IS_NOT_ALL 16888 ], 16889 format: {}, 16890 getValueFormatted: getValueFormatted7, 16891 validate: { 16892 required: isValidRequiredForArray, 16893 elements: isValidElements, 16894 custom: isValidCustom5 16895 } 16896 }; 16897 16898 // packages/dataviews/build-module/field-types/password.mjs 16899 function getValueFormatted8({ 16900 item, 16901 field 16902 }) { 16903 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : ""; 16904 } 16905 var password_default = { 16906 type: "password", 16907 render, 16908 Edit: "password", 16909 sort: () => 0, 16910 // Passwords should not be sortable for security reasons 16911 enableSorting: false, 16912 enableGlobalSearch: false, 16913 defaultOperators: [], 16914 validOperators: [], 16915 format: {}, 16916 getValueFormatted: getValueFormatted8, 16917 validate: { 16918 required: isValidRequired, 16919 pattern: isValidPattern, 16920 minLength: isValidMinLength, 16921 maxLength: isValidMaxLength, 16922 elements: isValidElements 16923 } 16924 }; 16925 16926 // packages/dataviews/build-module/field-types/telephone.mjs 16927 var telephone_default = { 16928 type: "telephone", 16929 render, 16930 Edit: "telephone", 16931 sort: sort_text_default, 16932 enableSorting: true, 16933 enableGlobalSearch: false, 16934 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 16935 validOperators: [ 16936 OPERATOR_IS, 16937 OPERATOR_IS_NOT, 16938 OPERATOR_CONTAINS, 16939 OPERATOR_NOT_CONTAINS, 16940 OPERATOR_STARTS_WITH, 16941 // Multiple selection 16942 OPERATOR_IS_ANY, 16943 OPERATOR_IS_NONE, 16944 OPERATOR_IS_ALL, 16945 OPERATOR_IS_NOT_ALL 16946 ], 16947 format: {}, 16948 getValueFormatted: get_value_formatted_default_default, 16949 validate: { 16950 required: isValidRequired, 16951 pattern: isValidPattern, 16952 minLength: isValidMinLength, 16953 maxLength: isValidMaxLength, 16954 elements: isValidElements 16955 } 16956 }; 16957 16958 // packages/dataviews/build-module/field-types/color.mjs 16959 var import_i18n17 = __toESM(require_i18n(), 1); 16960 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1); 16961 function render3({ item, field }) { 16962 if (field.hasElements) { 16963 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(RenderFromElements, { item, field }); 16964 } 16965 const value = get_value_formatted_default_default({ item, field }); 16966 if (!value || !w(value).isValid()) { 16967 return value; 16968 } 16969 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [ 16970 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 16971 "div", 16972 { 16973 style: { 16974 width: "16px", 16975 height: "16px", 16976 borderRadius: "50%", 16977 backgroundColor: value, 16978 border: "1px solid #ddd", 16979 flexShrink: 0 16980 } 16981 } 16982 ), 16983 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { children: value }) 16984 ] }); 16985 } 16986 function isValidCustom6(item, field) { 16987 const value = field.getValue({ item }); 16988 if (![void 0, "", null].includes(value) && !w(value).isValid()) { 16989 return (0, import_i18n17.__)("Value must be a valid color."); 16990 } 16991 return null; 16992 } 16993 var sort5 = (a2, b2, direction) => { 16994 const colorA = w(a2); 16995 const colorB = w(b2); 16996 if (!colorA.isValid() && !colorB.isValid()) { 16997 return 0; 16998 } 16999 if (!colorA.isValid()) { 17000 return direction === "asc" ? 1 : -1; 17001 } 17002 if (!colorB.isValid()) { 17003 return direction === "asc" ? -1 : 1; 17004 } 17005 const hslA = colorA.toHsl(); 17006 const hslB = colorB.toHsl(); 17007 if (hslA.h !== hslB.h) { 17008 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h; 17009 } 17010 if (hslA.s !== hslB.s) { 17011 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s; 17012 } 17013 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l; 17014 }; 17015 var color_default = { 17016 type: "color", 17017 render: render3, 17018 Edit: "color", 17019 sort: sort5, 17020 enableSorting: true, 17021 enableGlobalSearch: false, 17022 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 17023 validOperators: [ 17024 OPERATOR_IS, 17025 OPERATOR_IS_NOT, 17026 OPERATOR_IS_ANY, 17027 OPERATOR_IS_NONE 17028 ], 17029 format: {}, 17030 getValueFormatted: get_value_formatted_default_default, 17031 validate: { 17032 required: isValidRequired, 17033 elements: isValidElements, 17034 custom: isValidCustom6 17035 } 17036 }; 17037 17038 // packages/dataviews/build-module/field-types/url.mjs 17039 var url_default = { 17040 type: "url", 17041 render, 17042 Edit: "url", 17043 sort: sort_text_default, 17044 enableSorting: true, 17045 enableGlobalSearch: false, 17046 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 17047 validOperators: [ 17048 OPERATOR_IS, 17049 OPERATOR_IS_NOT, 17050 OPERATOR_CONTAINS, 17051 OPERATOR_NOT_CONTAINS, 17052 OPERATOR_STARTS_WITH, 17053 // Multiple selection 17054 OPERATOR_IS_ANY, 17055 OPERATOR_IS_NONE, 17056 OPERATOR_IS_ALL, 17057 OPERATOR_IS_NOT_ALL 17058 ], 17059 format: {}, 17060 getValueFormatted: get_value_formatted_default_default, 17061 validate: { 17062 required: isValidRequired, 17063 pattern: isValidPattern, 17064 minLength: isValidMinLength, 17065 maxLength: isValidMaxLength, 17066 elements: isValidElements 17067 } 17068 }; 17069 17070 // packages/dataviews/build-module/field-types/no-type.mjs 17071 var sort6 = (a2, b2, direction) => { 17072 if (typeof a2 === "number" && typeof b2 === "number") { 17073 return sort_number_default(a2, b2, direction); 17074 } 17075 return sort_text_default(a2, b2, direction); 17076 }; 17077 var no_type_default = { 17078 // type: no type for this one 17079 render, 17080 Edit: null, 17081 sort: sort6, 17082 enableSorting: true, 17083 enableGlobalSearch: false, 17084 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 17085 validOperators: getAllOperatorNames(), 17086 format: {}, 17087 getValueFormatted: get_value_formatted_default_default, 17088 validate: { 17089 required: isValidRequired, 17090 elements: isValidElements 17091 } 17092 }; 17093 17094 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs 17095 function supportsNumericRangeConstraint(type) { 17096 return type === "integer" || type === "number"; 17097 } 17098 function supportsDateRangeConstraint(type) { 17099 return type === "date" || type === "datetime"; 17100 } 17101 function normalizeRangeRule(value, fieldType, key) { 17102 const validator = fieldType.validate[key]; 17103 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) { 17104 return { constraint: value, validate: validator }; 17105 } 17106 return void 0; 17107 } 17108 function getIsValid(field, fieldType) { 17109 const rules = field.isValid; 17110 let required; 17111 if (rules?.required === true && fieldType.validate.required !== void 0) { 17112 required = { 17113 constraint: true, 17114 validate: fieldType.validate.required 17115 }; 17116 } 17117 let elements; 17118 if ((rules?.elements === true || // elements is enabled unless the field opts-out 17119 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) { 17120 elements = { 17121 constraint: true, 17122 validate: fieldType.validate.elements 17123 }; 17124 } 17125 const min3 = normalizeRangeRule(rules?.min, fieldType, "min"); 17126 const max3 = normalizeRangeRule(rules?.max, fieldType, "max"); 17127 const minLengthValue = rules?.minLength; 17128 let minLength; 17129 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) { 17130 minLength = { 17131 constraint: minLengthValue, 17132 validate: fieldType.validate.minLength 17133 }; 17134 } 17135 const maxLengthValue = rules?.maxLength; 17136 let maxLength; 17137 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) { 17138 maxLength = { 17139 constraint: maxLengthValue, 17140 validate: fieldType.validate.maxLength 17141 }; 17142 } 17143 const patternValue = rules?.pattern; 17144 let pattern; 17145 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) { 17146 pattern = { 17147 constraint: patternValue, 17148 validate: fieldType.validate.pattern 17149 }; 17150 } 17151 const custom = rules?.custom ?? fieldType.validate.custom; 17152 return { 17153 required, 17154 elements, 17155 min: min3, 17156 max: max3, 17157 minLength, 17158 maxLength, 17159 pattern, 17160 custom 17161 }; 17162 } 17163 17164 // packages/dataviews/build-module/field-types/utils/get-filter.mjs 17165 function getFilter(fieldType) { 17166 return fieldType.validOperators.reduce((accumulator, operator) => { 17167 const operatorObj = getOperatorByName(operator); 17168 if (operatorObj?.filter) { 17169 accumulator[operator] = operatorObj.filter; 17170 } 17171 return accumulator; 17172 }, {}); 17173 } 17174 17175 // packages/dataviews/build-module/field-types/utils/get-format.mjs 17176 function getFormat(field, fieldType) { 17177 return { 17178 ...fieldType.format, 17179 ...field.format 17180 }; 17181 } 17182 var get_format_default = getFormat; 17183 17184 // packages/dataviews/build-module/field-types/index.mjs 17185 function getFieldTypeByName(type) { 17186 const found = [ 17187 email_default, 17188 integer_default, 17189 number_default, 17190 text_default, 17191 datetime_default, 17192 date_default, 17193 boolean_default, 17194 media_default, 17195 array_default, 17196 password_default, 17197 telephone_default, 17198 color_default, 17199 url_default 17200 ].find((fieldType) => fieldType?.type === type); 17201 if (!!found) { 17202 return found; 17203 } 17204 return no_type_default; 17205 } 17206 function normalizeFields(fields) { 17207 return fields.map((field) => { 17208 const fieldType = getFieldTypeByName(field.type); 17209 const getValue = field.getValue || get_value_from_id_default(field.id); 17210 const sort7 = function(a2, b2, direction) { 17211 const aValue = getValue({ item: a2 }); 17212 const bValue = getValue({ item: b2 }); 17213 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction); 17214 }; 17215 return { 17216 id: field.id, 17217 label: field.label || field.id, 17218 header: field.header || field.label || field.id, 17219 description: field.description, 17220 placeholder: field.placeholder, 17221 getValue, 17222 setValue: field.setValue || set_value_from_id_default(field.id), 17223 elements: field.elements, 17224 getElements: field.getElements, 17225 hasElements: hasElements(field), 17226 isVisible: field.isVisible, 17227 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled, 17228 enableHiding: field.enableHiding ?? true, 17229 readOnly: field.readOnly ?? false, 17230 // The type provides defaults for the following props 17231 type: fieldType.type, 17232 render: field.render ?? fieldType.render, 17233 Edit: getControl(field, fieldType.Edit), 17234 sort: sort7, 17235 enableSorting: field.enableSorting ?? fieldType.enableSorting, 17236 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch, 17237 isValid: getIsValid(field, fieldType), 17238 filterBy: get_filter_by_default( 17239 field, 17240 fieldType.defaultOperators, 17241 fieldType.validOperators 17242 ), 17243 filter: getFilter(fieldType), 17244 format: get_format_default(field, fieldType), 17245 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted 17246 }; 17247 }); 17248 } 17249 17250 // packages/dataviews/build-module/dataform/index.mjs 17251 var import_element65 = __toESM(require_element(), 1); 17252 17253 // packages/dataviews/build-module/components/dataform-context/index.mjs 17254 var import_element54 = __toESM(require_element(), 1); 17255 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1); 17256 var DataFormContext = (0, import_element54.createContext)({ 17257 fields: [] 17258 }); 17259 DataFormContext.displayName = "DataFormContext"; 17260 function DataFormProvider({ 17261 fields, 17262 children 17263 }) { 17264 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(DataFormContext.Provider, { value: { fields }, children }); 17265 } 17266 var dataform_context_default = DataFormContext; 17267 17268 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs 17269 var import_element64 = __toESM(require_element(), 1); 17270 17271 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs 17272 var import_element55 = __toESM(require_element(), 1); 17273 var import_components21 = __toESM(require_components(), 1); 17274 17275 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs 17276 var import_i18n18 = __toESM(require_i18n(), 1); 17277 var DEFAULT_LAYOUT = { 17278 type: "regular", 17279 labelPosition: "top" 17280 }; 17281 var normalizeCardSummaryField = (sum) => { 17282 if (typeof sum === "string") { 17283 return [{ id: sum, visibility: "when-collapsed" }]; 17284 } 17285 return sum.map((item) => { 17286 if (typeof item === "string") { 17287 return { id: item, visibility: "when-collapsed" }; 17288 } 17289 return { id: item.id, visibility: item.visibility }; 17290 }); 17291 }; 17292 function normalizeLayout(layout) { 17293 let normalizedLayout = DEFAULT_LAYOUT; 17294 if (layout?.type === "regular") { 17295 normalizedLayout = { 17296 type: "regular", 17297 labelPosition: layout?.labelPosition ?? "top" 17298 }; 17299 } else if (layout?.type === "panel") { 17300 const summary = layout.summary ?? []; 17301 const normalizedSummary = Array.isArray(summary) ? summary : [summary]; 17302 const openAs = layout?.openAs; 17303 let normalizedOpenAs; 17304 if (typeof openAs === "object" && openAs.type === "modal") { 17305 normalizedOpenAs = { 17306 type: "modal", 17307 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n18.__)("Apply"), 17308 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n18.__)("Cancel") 17309 }; 17310 } else if (openAs === "modal") { 17311 normalizedOpenAs = { 17312 type: "modal", 17313 applyLabel: (0, import_i18n18.__)("Apply"), 17314 cancelLabel: (0, import_i18n18.__)("Cancel") 17315 }; 17316 } else { 17317 normalizedOpenAs = { type: "dropdown" }; 17318 } 17319 normalizedLayout = { 17320 type: "panel", 17321 labelPosition: layout?.labelPosition ?? "side", 17322 openAs: normalizedOpenAs, 17323 summary: normalizedSummary, 17324 editVisibility: layout?.editVisibility ?? "on-hover" 17325 }; 17326 } else if (layout?.type === "card") { 17327 if (layout.withHeader === false) { 17328 normalizedLayout = { 17329 type: "card", 17330 withHeader: false, 17331 isOpened: true, 17332 summary: [], 17333 isCollapsible: false 17334 }; 17335 } else { 17336 const summary = layout.summary ?? []; 17337 normalizedLayout = { 17338 type: "card", 17339 withHeader: true, 17340 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true, 17341 summary: normalizeCardSummaryField(summary), 17342 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible 17343 }; 17344 } 17345 } else if (layout?.type === "row") { 17346 normalizedLayout = { 17347 type: "row", 17348 alignment: layout?.alignment ?? "center", 17349 styles: layout?.styles ?? {} 17350 }; 17351 } else if (layout?.type === "details") { 17352 normalizedLayout = { 17353 type: "details", 17354 summary: layout?.summary ?? "" 17355 }; 17356 } 17357 return normalizedLayout; 17358 } 17359 function normalizeForm(form) { 17360 const normalizedFormLayout = normalizeLayout(form?.layout); 17361 const normalizedFields = (form.fields ?? []).map( 17362 (field) => { 17363 if (typeof field === "string") { 17364 return { 17365 id: field, 17366 layout: normalizedFormLayout 17367 }; 17368 } 17369 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout; 17370 return { 17371 id: field.id, 17372 layout: fieldLayout, 17373 ...!!field.label && { label: field.label }, 17374 ...!!field.description && { 17375 description: field.description 17376 }, 17377 ..."children" in field && Array.isArray(field.children) && { 17378 children: normalizeForm({ 17379 fields: field.children, 17380 layout: DEFAULT_LAYOUT 17381 }).fields 17382 } 17383 }; 17384 } 17385 ); 17386 return { 17387 layout: normalizedFormLayout, 17388 fields: normalizedFields 17389 }; 17390 } 17391 var normalize_form_default = normalizeForm; 17392 17393 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs 17394 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1); 17395 function Header4({ title }) { 17396 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 17397 Stack, 17398 { 17399 direction: "column", 17400 className: "dataforms-layouts-regular__header", 17401 gap: "lg", 17402 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.__experimentalHeading, { level: 2, size: 13, children: title }) }) 17403 } 17404 ); 17405 } 17406 function FormRegularField({ 17407 data, 17408 field, 17409 onChange, 17410 hideLabelFromVision, 17411 markWhenOptional, 17412 validity 17413 }) { 17414 const { fields } = (0, import_element55.useContext)(dataform_context_default); 17415 const layout = field.layout; 17416 const form = (0, import_element55.useMemo)( 17417 () => ({ 17418 layout: DEFAULT_LAYOUT, 17419 fields: !!field.children ? field.children : [] 17420 }), 17421 [field] 17422 ); 17423 if (!!field.children) { 17424 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, { children: [ 17425 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Header4, { title: field.label }), 17426 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 17427 DataFormLayout, 17428 { 17429 data, 17430 form, 17431 onChange, 17432 validity: validity?.children 17433 } 17434 ) 17435 ] }); 17436 } 17437 const labelPosition = layout.labelPosition; 17438 const fieldDefinition = fields.find( 17439 (fieldDef) => fieldDef.id === field.id 17440 ); 17441 if (!fieldDefinition || !fieldDefinition.Edit) { 17442 return null; 17443 } 17444 if (labelPosition === "side") { 17445 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)( 17446 Stack, 17447 { 17448 direction: "row", 17449 className: "dataforms-layouts-regular__field", 17450 gap: "sm", 17451 children: [ 17452 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 17453 "div", 17454 { 17455 className: clsx_default( 17456 "dataforms-layouts-regular__field-label", 17457 `dataforms-layouts-regular__field-label--label-position-$labelPosition}` 17458 ), 17459 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.BaseControl.VisualLabel, { children: fieldDefinition.label }) 17460 } 17461 ), 17462 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 17463 fieldDefinition.render, 17464 { 17465 item: data, 17466 field: fieldDefinition 17467 } 17468 ) : /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 17469 fieldDefinition.Edit, 17470 { 17471 data, 17472 field: fieldDefinition, 17473 onChange, 17474 hideLabelFromVision: true, 17475 markWhenOptional, 17476 validity 17477 }, 17478 fieldDefinition.id 17479 ) }) 17480 ] 17481 } 17482 ); 17483 } 17484 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_jsx_runtime83.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, { children: [ 17485 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.BaseControl.VisualLabel, { children: fieldDefinition.label }), 17486 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 17487 fieldDefinition.render, 17488 { 17489 item: data, 17490 field: fieldDefinition 17491 } 17492 ) 17493 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 17494 fieldDefinition.Edit, 17495 { 17496 data, 17497 field: fieldDefinition, 17498 onChange, 17499 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision, 17500 markWhenOptional, 17501 validity 17502 } 17503 ) }); 17504 } 17505 17506 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs 17507 var import_deepmerge2 = __toESM(require_cjs(), 1); 17508 var import_components24 = __toESM(require_components(), 1); 17509 var import_element60 = __toESM(require_element(), 1); 17510 var import_compose2 = __toESM(require_compose(), 1); 17511 17512 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs 17513 var import_components23 = __toESM(require_components(), 1); 17514 var import_i18n19 = __toESM(require_i18n(), 1); 17515 var import_compose = __toESM(require_compose(), 1); 17516 var import_element56 = __toESM(require_element(), 1); 17517 17518 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs 17519 function getLabelClassName(labelPosition, showError) { 17520 return clsx_default( 17521 "dataforms-layouts-panel__field-label", 17522 `dataforms-layouts-panel__field-label--label-position-$labelPosition}`, 17523 { "has-error": showError } 17524 ); 17525 } 17526 var get_label_classname_default = getLabelClassName; 17527 17528 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs 17529 var import_components22 = __toESM(require_components(), 1); 17530 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1); 17531 function getLabelContent(showError, errorMessage, fieldLabel) { 17532 return showError ? /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(tooltip_exports.Root, { children: [ 17533 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)( 17534 tooltip_exports.Trigger, 17535 { 17536 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [ 17537 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_components22.Icon, { icon: error_default, size: 16 }), 17538 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(VisuallyHidden, { children: [ 17539 errorMessage, 17540 ": " 17541 ] }), 17542 fieldLabel 17543 ] }) 17544 } 17545 ), 17546 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(tooltip_exports.Popup, { children: errorMessage }) 17547 ] }) : fieldLabel; 17548 } 17549 var get_label_content_default = getLabelContent; 17550 17551 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs 17552 function getFirstValidationError(validity) { 17553 if (!validity) { 17554 return void 0; 17555 } 17556 const validityRules = Object.keys(validity).filter( 17557 (key) => key !== "children" 17558 ); 17559 for (const key of validityRules) { 17560 const rule = validity[key]; 17561 if (rule === void 0) { 17562 continue; 17563 } 17564 if (rule.type === "invalid") { 17565 if (rule.message) { 17566 return rule.message; 17567 } 17568 if (key === "required") { 17569 return "A required field is empty"; 17570 } 17571 return "Unidentified validation error"; 17572 } 17573 } 17574 if (validity.children) { 17575 for (const childValidity of Object.values(validity.children)) { 17576 const childError = getFirstValidationError(childValidity); 17577 if (childError) { 17578 return childError; 17579 } 17580 } 17581 } 17582 return void 0; 17583 } 17584 var get_first_validation_error_default = getFirstValidationError; 17585 17586 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs 17587 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1); 17588 function SummaryButton({ 17589 data, 17590 field, 17591 fieldLabel, 17592 summaryFields, 17593 validity, 17594 touched, 17595 disabled: disabled2, 17596 onClick, 17597 "aria-expanded": ariaExpanded 17598 }) { 17599 const { labelPosition, editVisibility } = field.layout; 17600 const errorMessage = get_first_validation_error_default(validity); 17601 const showError = touched && !!errorMessage; 17602 const labelClassName = get_label_classname_default(labelPosition, showError); 17603 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel); 17604 const className = clsx_default( 17605 "dataforms-layouts-panel__field-trigger", 17606 `dataforms-layouts-panel__field-trigger--label-$labelPosition}`, 17607 { 17608 "is-disabled": disabled2, 17609 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always" 17610 } 17611 ); 17612 const controlId = (0, import_compose.useInstanceId)( 17613 SummaryButton, 17614 "dataforms-layouts-panel__field-control" 17615 ); 17616 const ariaLabel = showError ? (0, import_i18n19.sprintf)( 17617 // translators: %s: Field name. 17618 (0, import_i18n19._x)("Edit %s (has errors)", "field"), 17619 fieldLabel || "" 17620 ) : (0, import_i18n19.sprintf)( 17621 // translators: %s: Field name. 17622 (0, import_i18n19._x)("Edit %s", "field"), 17623 fieldLabel || "" 17624 ); 17625 const rowRef = (0, import_element56.useRef)(null); 17626 const handleRowClick = () => { 17627 const selection = rowRef.current?.ownerDocument.defaultView?.getSelection(); 17628 if (selection && selection.toString().length > 0) { 17629 return; 17630 } 17631 onClick(); 17632 }; 17633 const handleKeyDown = (event) => { 17634 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) { 17635 event.preventDefault(); 17636 onClick(); 17637 } 17638 }; 17639 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)( 17640 "div", 17641 { 17642 ref: rowRef, 17643 className, 17644 onClick: !disabled2 ? handleRowClick : void 0, 17645 onKeyDown: !disabled2 ? handleKeyDown : void 0, 17646 children: [ 17647 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { className: labelClassName, children: labelContent }), 17648 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(tooltip_exports.Root, { children: [ 17649 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 17650 tooltip_exports.Trigger, 17651 { 17652 render: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 17653 "span", 17654 { 17655 className: "dataforms-layouts-panel__field-label-error-content", 17656 role: "img", 17657 "aria-label": errorMessage, 17658 children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_components23.Icon, { icon: error_default, size: 16 }) 17659 } 17660 ) 17661 } 17662 ), 17663 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(tooltip_exports.Popup, { children: errorMessage }) 17664 ] }), 17665 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 17666 "span", 17667 { 17668 id: `$controlId}`, 17669 className: "dataforms-layouts-panel__field-control", 17670 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 17671 "span", 17672 { 17673 style: { 17674 display: "flex", 17675 flexDirection: "column", 17676 alignItems: "flex-start", 17677 width: "100%", 17678 gap: "2px" 17679 }, 17680 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 17681 "span", 17682 { 17683 style: { width: "100%" }, 17684 children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 17685 summaryField.render, 17686 { 17687 item: data, 17688 field: summaryField 17689 } 17690 ) 17691 }, 17692 summaryField.id 17693 )) 17694 } 17695 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 17696 summaryField.render, 17697 { 17698 item: data, 17699 field: summaryField 17700 }, 17701 summaryField.id 17702 )) 17703 } 17704 ), 17705 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 17706 import_components23.Button, 17707 { 17708 className: "dataforms-layouts-panel__field-trigger-icon", 17709 label: ariaLabel, 17710 icon: pencil_default, 17711 size: "small", 17712 "aria-expanded": ariaExpanded, 17713 "aria-haspopup": "dialog", 17714 "aria-describedby": `$controlId}` 17715 } 17716 ) 17717 ] 17718 } 17719 ); 17720 } 17721 17722 // packages/dataviews/build-module/hooks/use-form-validity.mjs 17723 var import_deepmerge = __toESM(require_cjs(), 1); 17724 var import_es6 = __toESM(require_es6(), 1); 17725 var import_element57 = __toESM(require_element(), 1); 17726 var import_i18n20 = __toESM(require_i18n(), 1); 17727 function isFormValid(formValidity) { 17728 if (!formValidity) { 17729 return true; 17730 } 17731 return Object.values(formValidity).every((fieldValidation) => { 17732 return Object.entries(fieldValidation).every( 17733 ([key, validation]) => { 17734 if (key === "children" && validation && typeof validation === "object") { 17735 return isFormValid(validation); 17736 } 17737 return validation.type !== "invalid" && validation.type !== "validating"; 17738 } 17739 ); 17740 }); 17741 } 17742 function getFormFieldsToValidate(form, fields) { 17743 const normalizedForm = normalize_form_default(form); 17744 if (normalizedForm.fields.length === 0) { 17745 return []; 17746 } 17747 const fieldsMap = /* @__PURE__ */ new Map(); 17748 fields.forEach((field) => { 17749 fieldsMap.set(field.id, field); 17750 }); 17751 function processFormField(formField) { 17752 if ("children" in formField && Array.isArray(formField.children)) { 17753 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null); 17754 if (processedChildren.length === 0) { 17755 return null; 17756 } 17757 const fieldDef2 = fieldsMap.get(formField.id); 17758 if (fieldDef2) { 17759 const [normalizedField2] = normalizeFields([ 17760 fieldDef2 17761 ]); 17762 return { 17763 id: formField.id, 17764 children: processedChildren, 17765 field: normalizedField2 17766 }; 17767 } 17768 return { 17769 id: formField.id, 17770 children: processedChildren 17771 }; 17772 } 17773 const fieldDef = fieldsMap.get(formField.id); 17774 if (!fieldDef) { 17775 return null; 17776 } 17777 const [normalizedField] = normalizeFields([fieldDef]); 17778 return { 17779 id: formField.id, 17780 children: [], 17781 field: normalizedField 17782 }; 17783 } 17784 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null); 17785 return toValidate; 17786 } 17787 function setValidityAtPath(formValidity, fieldValidity, path) { 17788 if (!formValidity) { 17789 formValidity = {}; 17790 } 17791 if (path.length === 0) { 17792 return formValidity; 17793 } 17794 const result = { ...formValidity }; 17795 let current = result; 17796 for (let i2 = 0; i2 < path.length - 1; i2++) { 17797 const segment = path[i2]; 17798 if (!current[segment]) { 17799 current[segment] = {}; 17800 } 17801 current[segment] = { ...current[segment] }; 17802 current = current[segment]; 17803 } 17804 const finalKey = path[path.length - 1]; 17805 current[finalKey] = { 17806 ...current[finalKey] || {}, 17807 ...fieldValidity 17808 }; 17809 return result; 17810 } 17811 function removeValidationProperty(formValidity, path, property) { 17812 if (!formValidity || path.length === 0) { 17813 return formValidity; 17814 } 17815 const result = { ...formValidity }; 17816 let current = result; 17817 for (let i2 = 0; i2 < path.length - 1; i2++) { 17818 const segment = path[i2]; 17819 if (!current[segment]) { 17820 return formValidity; 17821 } 17822 current[segment] = { ...current[segment] }; 17823 current = current[segment]; 17824 } 17825 const finalKey = path[path.length - 1]; 17826 if (!current[finalKey]) { 17827 return formValidity; 17828 } 17829 const fieldValidity = { ...current[finalKey] }; 17830 delete fieldValidity[property]; 17831 if (Object.keys(fieldValidity).length === 0) { 17832 delete current[finalKey]; 17833 } else { 17834 current[finalKey] = fieldValidity; 17835 } 17836 if (Object.keys(result).length === 0) { 17837 return void 0; 17838 } 17839 return result; 17840 } 17841 function handleElementsValidationAsync(promise, formField, promiseHandler) { 17842 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler; 17843 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1; 17844 elementsCounterRef.current[formField.id] = currentToken; 17845 promise.then((result) => { 17846 if (currentToken !== elementsCounterRef.current[formField.id]) { 17847 return; 17848 } 17849 if (!Array.isArray(result)) { 17850 setFormValidity((prev) => { 17851 const newFormValidity = setValidityAtPath( 17852 prev, 17853 { 17854 elements: { 17855 type: "invalid", 17856 message: (0, import_i18n20.__)("Could not validate elements.") 17857 } 17858 }, 17859 [...path, formField.id] 17860 ); 17861 return newFormValidity; 17862 }); 17863 return; 17864 } 17865 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, { 17866 ...formField.field, 17867 elements: result 17868 })) { 17869 setFormValidity((prev) => { 17870 const newFormValidity = setValidityAtPath( 17871 prev, 17872 { 17873 elements: { 17874 type: "invalid", 17875 message: (0, import_i18n20.__)( 17876 "Value must be one of the elements." 17877 ) 17878 } 17879 }, 17880 [...path, formField.id] 17881 ); 17882 return newFormValidity; 17883 }); 17884 } else { 17885 setFormValidity((prev) => { 17886 return removeValidationProperty( 17887 prev, 17888 [...path, formField.id], 17889 "elements" 17890 ); 17891 }); 17892 } 17893 }).catch((error2) => { 17894 if (currentToken !== elementsCounterRef.current[formField.id]) { 17895 return; 17896 } 17897 let errorMessage; 17898 if (error2 instanceof Error) { 17899 errorMessage = error2.message; 17900 } else { 17901 errorMessage = String(error2) || (0, import_i18n20.__)( 17902 "Unknown error when running elements validation asynchronously." 17903 ); 17904 } 17905 setFormValidity((prev) => { 17906 const newFormValidity = setValidityAtPath( 17907 prev, 17908 { 17909 elements: { 17910 type: "invalid", 17911 message: errorMessage 17912 } 17913 }, 17914 [...path, formField.id] 17915 ); 17916 return newFormValidity; 17917 }); 17918 }); 17919 } 17920 function handleCustomValidationAsync(promise, formField, promiseHandler) { 17921 const { customCounterRef, setFormValidity, path } = promiseHandler; 17922 const currentToken = (customCounterRef.current[formField.id] || 0) + 1; 17923 customCounterRef.current[formField.id] = currentToken; 17924 promise.then((result) => { 17925 if (currentToken !== customCounterRef.current[formField.id]) { 17926 return; 17927 } 17928 if (result === null) { 17929 setFormValidity((prev) => { 17930 return removeValidationProperty( 17931 prev, 17932 [...path, formField.id], 17933 "custom" 17934 ); 17935 }); 17936 return; 17937 } 17938 if (typeof result === "string") { 17939 setFormValidity((prev) => { 17940 const newFormValidity = setValidityAtPath( 17941 prev, 17942 { 17943 custom: { 17944 type: "invalid", 17945 message: result 17946 } 17947 }, 17948 [...path, formField.id] 17949 ); 17950 return newFormValidity; 17951 }); 17952 return; 17953 } 17954 setFormValidity((prev) => { 17955 const newFormValidity = setValidityAtPath( 17956 prev, 17957 { 17958 custom: { 17959 type: "invalid", 17960 message: (0, import_i18n20.__)("Validation could not be processed.") 17961 } 17962 }, 17963 [...path, formField.id] 17964 ); 17965 return newFormValidity; 17966 }); 17967 }).catch((error2) => { 17968 if (currentToken !== customCounterRef.current[formField.id]) { 17969 return; 17970 } 17971 let errorMessage; 17972 if (error2 instanceof Error) { 17973 errorMessage = error2.message; 17974 } else { 17975 errorMessage = String(error2) || (0, import_i18n20.__)( 17976 "Unknown error when running custom validation asynchronously." 17977 ); 17978 } 17979 setFormValidity((prev) => { 17980 const newFormValidity = setValidityAtPath( 17981 prev, 17982 { 17983 custom: { 17984 type: "invalid", 17985 message: errorMessage 17986 } 17987 }, 17988 [...path, formField.id] 17989 ); 17990 return newFormValidity; 17991 }); 17992 }); 17993 } 17994 function validateFormField(item, formField, promiseHandler) { 17995 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) { 17996 return { 17997 required: { type: "invalid" } 17998 }; 17999 } 18000 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) { 18001 return { 18002 pattern: { 18003 type: "invalid", 18004 message: (0, import_i18n20.__)("Value does not match the required pattern.") 18005 } 18006 }; 18007 } 18008 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) { 18009 return { 18010 min: { 18011 type: "invalid", 18012 message: (0, import_i18n20.__)("Value is below the minimum.") 18013 } 18014 }; 18015 } 18016 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) { 18017 return { 18018 max: { 18019 type: "invalid", 18020 message: (0, import_i18n20.__)("Value is above the maximum.") 18021 } 18022 }; 18023 } 18024 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) { 18025 return { 18026 minLength: { 18027 type: "invalid", 18028 message: (0, import_i18n20.__)("Value is too short.") 18029 } 18030 }; 18031 } 18032 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) { 18033 return { 18034 maxLength: { 18035 type: "invalid", 18036 message: (0, import_i18n20.__)("Value is too long.") 18037 } 18038 }; 18039 } 18040 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) { 18041 return { 18042 elements: { 18043 type: "invalid", 18044 message: (0, import_i18n20.__)("Value must be one of the elements.") 18045 } 18046 }; 18047 } 18048 let customError; 18049 if (!!formField.field && formField.field.isValid.custom) { 18050 try { 18051 const value = formField.field.getValue({ item }); 18052 customError = formField.field.isValid.custom( 18053 (0, import_deepmerge.default)( 18054 item, 18055 formField.field.setValue({ 18056 item, 18057 value 18058 }) 18059 ), 18060 formField.field 18061 ); 18062 } catch (error2) { 18063 let errorMessage; 18064 if (error2 instanceof Error) { 18065 errorMessage = error2.message; 18066 } else { 18067 errorMessage = String(error2) || (0, import_i18n20.__)("Unknown error when running custom validation."); 18068 } 18069 return { 18070 custom: { 18071 type: "invalid", 18072 message: errorMessage 18073 } 18074 }; 18075 } 18076 } 18077 if (typeof customError === "string") { 18078 return { 18079 custom: { 18080 type: "invalid", 18081 message: customError 18082 } 18083 }; 18084 } 18085 const fieldValidity = {}; 18086 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") { 18087 handleElementsValidationAsync( 18088 formField.field.getElements(), 18089 formField, 18090 promiseHandler 18091 ); 18092 fieldValidity.elements = { 18093 type: "validating", 18094 message: (0, import_i18n20.__)("Validating\u2026") 18095 }; 18096 } 18097 if (customError instanceof Promise) { 18098 handleCustomValidationAsync(customError, formField, promiseHandler); 18099 fieldValidity.custom = { 18100 type: "validating", 18101 message: (0, import_i18n20.__)("Validating\u2026") 18102 }; 18103 } 18104 if (Object.keys(fieldValidity).length > 0) { 18105 return fieldValidity; 18106 } 18107 if (formField.children.length > 0) { 18108 const result = {}; 18109 formField.children.forEach((child) => { 18110 result[child.id] = validateFormField(item, child, { 18111 ...promiseHandler, 18112 path: [...promiseHandler.path, formField.id, "children"] 18113 }); 18114 }); 18115 const filteredResult = {}; 18116 Object.entries(result).forEach(([key, value]) => { 18117 if (value !== void 0) { 18118 filteredResult[key] = value; 18119 } 18120 }); 18121 if (Object.keys(filteredResult).length === 0) { 18122 return void 0; 18123 } 18124 return { 18125 children: filteredResult 18126 }; 18127 } 18128 return void 0; 18129 } 18130 function getFormFieldValue(formField, item) { 18131 const fieldValue = formField?.field?.getValue({ item }); 18132 if (formField.children.length === 0) { 18133 return fieldValue; 18134 } 18135 const childrenValues = formField.children.map( 18136 (child) => getFormFieldValue(child, item) 18137 ); 18138 if (!childrenValues) { 18139 return fieldValue; 18140 } 18141 return { 18142 value: fieldValue, 18143 children: childrenValues 18144 }; 18145 } 18146 function useFormValidity(item, fields, form) { 18147 const [formValidity, setFormValidity] = (0, import_element57.useState)(); 18148 const customCounterRef = (0, import_element57.useRef)({}); 18149 const elementsCounterRef = (0, import_element57.useRef)({}); 18150 const previousValuesRef = (0, import_element57.useRef)({}); 18151 const validate = (0, import_element57.useCallback)(() => { 18152 const promiseHandler = { 18153 customCounterRef, 18154 elementsCounterRef, 18155 setFormValidity, 18156 path: [], 18157 item 18158 }; 18159 const formFieldsToValidate = getFormFieldsToValidate(form, fields); 18160 if (formFieldsToValidate.length === 0) { 18161 setFormValidity(void 0); 18162 return; 18163 } 18164 const newFormValidity = {}; 18165 const untouchedFields = []; 18166 formFieldsToValidate.forEach((formField) => { 18167 const value = getFormFieldValue(formField, item); 18168 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es6.default)( 18169 previousValuesRef.current[formField.id], 18170 value 18171 )) { 18172 untouchedFields.push(formField.id); 18173 return; 18174 } 18175 previousValuesRef.current[formField.id] = value; 18176 const fieldValidity = validateFormField( 18177 item, 18178 formField, 18179 promiseHandler 18180 ); 18181 if (fieldValidity !== void 0) { 18182 newFormValidity[formField.id] = fieldValidity; 18183 } 18184 }); 18185 setFormValidity((existingFormValidity) => { 18186 let validity = { 18187 ...existingFormValidity, 18188 ...newFormValidity 18189 }; 18190 const fieldsToKeep = [ 18191 ...untouchedFields, 18192 ...Object.keys(newFormValidity) 18193 ]; 18194 Object.keys(validity).forEach((key) => { 18195 if (validity && !fieldsToKeep.includes(key)) { 18196 delete validity[key]; 18197 } 18198 }); 18199 if (Object.keys(validity).length === 0) { 18200 validity = void 0; 18201 } 18202 const areEqual = (0, import_es6.default)(existingFormValidity, validity); 18203 if (areEqual) { 18204 return existingFormValidity; 18205 } 18206 return validity; 18207 }); 18208 }, [item, fields, form]); 18209 (0, import_element57.useEffect)(() => { 18210 validate(); 18211 }, [validate]); 18212 return { 18213 validity: formValidity, 18214 isValid: isFormValid(formValidity) 18215 }; 18216 } 18217 var use_form_validity_default = useFormValidity; 18218 18219 // packages/dataviews/build-module/hooks/use-report-validity.mjs 18220 var import_element58 = __toESM(require_element(), 1); 18221 function useReportValidity(ref, shouldReport) { 18222 (0, import_element58.useEffect)(() => { 18223 if (shouldReport && ref.current) { 18224 const inputs = ref.current.querySelectorAll( 18225 "input, textarea, select" 18226 ); 18227 inputs.forEach((input) => { 18228 input.reportValidity(); 18229 }); 18230 } 18231 }, [shouldReport, ref]); 18232 } 18233 18234 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs 18235 var import_element59 = __toESM(require_element(), 1); 18236 18237 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs 18238 function extractSummaryIds(summary) { 18239 if (Array.isArray(summary)) { 18240 return summary.map( 18241 (item) => typeof item === "string" ? item : item.id 18242 ); 18243 } 18244 return []; 18245 } 18246 var getSummaryFields = (summaryField, fields) => { 18247 if (Array.isArray(summaryField) && summaryField.length > 0) { 18248 const summaryIds = extractSummaryIds(summaryField); 18249 return summaryIds.map( 18250 (summaryId) => fields.find((_field) => _field.id === summaryId) 18251 ).filter((_field) => _field !== void 0); 18252 } 18253 return []; 18254 }; 18255 18256 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs 18257 var getFieldDefinition = (field, fields) => { 18258 const fieldDefinition = fields.find((_field) => _field.id === field.id); 18259 if (!fieldDefinition) { 18260 return fields.find((_field) => { 18261 if (!!field.children) { 18262 const simpleChildren = field.children.filter( 18263 (child) => !child.children 18264 ); 18265 if (simpleChildren.length === 0) { 18266 return false; 18267 } 18268 return _field.id === simpleChildren[0].id; 18269 } 18270 return _field.id === field.id; 18271 }); 18272 } 18273 return fieldDefinition; 18274 }; 18275 function useFieldFromFormField(field) { 18276 const { fields } = (0, import_element59.useContext)(dataform_context_default); 18277 const layout = field.layout; 18278 const summaryFields = getSummaryFields(layout.summary, fields); 18279 const fieldDefinition = getFieldDefinition(field, fields); 18280 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label; 18281 if (summaryFields.length === 0) { 18282 return { 18283 summaryFields: fieldDefinition ? [fieldDefinition] : [], 18284 fieldDefinition, 18285 fieldLabel 18286 }; 18287 } 18288 return { 18289 summaryFields, 18290 fieldDefinition, 18291 fieldLabel 18292 }; 18293 } 18294 var use_field_from_form_field_default = useFieldFromFormField; 18295 18296 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs 18297 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1); 18298 function ModalContent({ 18299 data, 18300 field, 18301 onChange, 18302 fieldLabel, 18303 onClose, 18304 touched 18305 }) { 18306 const { openAs } = field.layout; 18307 const { applyLabel, cancelLabel } = openAs; 18308 const { fields } = (0, import_element60.useContext)(dataform_context_default); 18309 const [changes, setChanges] = (0, import_element60.useState)({}); 18310 const modalData = (0, import_element60.useMemo)(() => { 18311 return (0, import_deepmerge2.default)(data, changes, { 18312 arrayMerge: (target, source) => source 18313 }); 18314 }, [data, changes]); 18315 const form = (0, import_element60.useMemo)( 18316 () => ({ 18317 layout: DEFAULT_LAYOUT, 18318 fields: !!field.children ? field.children : ( 18319 // If not explicit children return the field id itself. 18320 [{ id: field.id, layout: DEFAULT_LAYOUT }] 18321 ) 18322 }), 18323 [field] 18324 ); 18325 const fieldsAsFieldType = fields.map((f2) => ({ 18326 ...f2, 18327 Edit: f2.Edit === null ? void 0 : f2.Edit, 18328 isValid: { 18329 required: f2.isValid.required?.constraint, 18330 elements: f2.isValid.elements?.constraint, 18331 min: f2.isValid.min?.constraint, 18332 max: f2.isValid.max?.constraint, 18333 pattern: f2.isValid.pattern?.constraint, 18334 minLength: f2.isValid.minLength?.constraint, 18335 maxLength: f2.isValid.maxLength?.constraint 18336 } 18337 })); 18338 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form); 18339 const onApply = () => { 18340 onChange(changes); 18341 onClose(); 18342 }; 18343 const handleOnChange = (newValue) => { 18344 setChanges( 18345 (prev) => (0, import_deepmerge2.default)(prev, newValue, { 18346 arrayMerge: (target, source) => source 18347 }) 18348 ); 18349 }; 18350 const focusOnMountRef = (0, import_compose2.useFocusOnMount)("firstInputElement"); 18351 const contentRef = (0, import_element60.useRef)(null); 18352 const mergedRef = (0, import_compose2.useMergeRefs)([focusOnMountRef, contentRef]); 18353 useReportValidity(contentRef, touched); 18354 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)( 18355 import_components24.Modal, 18356 { 18357 className: "dataforms-layouts-panel__modal", 18358 onRequestClose: onClose, 18359 isFullScreen: false, 18360 title: fieldLabel, 18361 size: "medium", 18362 children: [ 18363 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 18364 DataFormLayout, 18365 { 18366 data: modalData, 18367 form, 18368 onChange: handleOnChange, 18369 validity, 18370 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 18371 FieldLayout, 18372 { 18373 data: modalData, 18374 field: childField, 18375 onChange: handleOnChange, 18376 hideLabelFromVision: form.fields.length < 2, 18377 markWhenOptional, 18378 validity: childFieldValidity 18379 }, 18380 childField.id 18381 ) 18382 } 18383 ) }), 18384 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)( 18385 Stack, 18386 { 18387 direction: "row", 18388 className: "dataforms-layouts-panel__modal-footer", 18389 gap: "md", 18390 children: [ 18391 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_components24.__experimentalSpacer, { style: { flex: 1 } }), 18392 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 18393 import_components24.Button, 18394 { 18395 variant: "tertiary", 18396 onClick: onClose, 18397 __next40pxDefaultSize: true, 18398 children: cancelLabel 18399 } 18400 ), 18401 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 18402 import_components24.Button, 18403 { 18404 variant: "primary", 18405 onClick: onApply, 18406 __next40pxDefaultSize: true, 18407 children: applyLabel 18408 } 18409 ) 18410 ] 18411 } 18412 ) 18413 ] 18414 } 18415 ); 18416 } 18417 function PanelModal({ 18418 data, 18419 field, 18420 onChange, 18421 validity 18422 }) { 18423 const [touched, setTouched] = (0, import_element60.useState)(false); 18424 const [isOpen2, setIsOpen] = (0, import_element60.useState)(false); 18425 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field); 18426 if (!fieldDefinition) { 18427 return null; 18428 } 18429 const handleClose = () => { 18430 setIsOpen(false); 18431 setTouched(true); 18432 }; 18433 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_jsx_runtime86.Fragment, { children: [ 18434 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 18435 SummaryButton, 18436 { 18437 data, 18438 field, 18439 fieldLabel, 18440 summaryFields, 18441 validity, 18442 touched, 18443 disabled: fieldDefinition.readOnly === true, 18444 onClick: () => setIsOpen(true), 18445 "aria-expanded": isOpen2 18446 } 18447 ), 18448 isOpen2 && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 18449 ModalContent, 18450 { 18451 data, 18452 field, 18453 onChange, 18454 fieldLabel: fieldLabel ?? "", 18455 onClose: handleClose, 18456 touched 18457 } 18458 ) 18459 ] }); 18460 } 18461 var modal_default = PanelModal; 18462 18463 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs 18464 var import_components25 = __toESM(require_components(), 1); 18465 var import_i18n21 = __toESM(require_i18n(), 1); 18466 var import_element61 = __toESM(require_element(), 1); 18467 var import_compose3 = __toESM(require_compose(), 1); 18468 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1); 18469 function DropdownHeader({ 18470 title, 18471 onClose 18472 }) { 18473 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 18474 Stack, 18475 { 18476 direction: "column", 18477 className: "dataforms-layouts-panel__dropdown-header", 18478 gap: "lg", 18479 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [ 18480 title && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_components25.__experimentalHeading, { level: 2, size: 13, children: title }), 18481 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_components25.__experimentalSpacer, { style: { flex: 1 } }), 18482 onClose && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 18483 import_components25.Button, 18484 { 18485 label: (0, import_i18n21.__)("Close"), 18486 icon: close_small_default, 18487 onClick: onClose, 18488 size: "small" 18489 } 18490 ) 18491 ] }) 18492 } 18493 ); 18494 } 18495 function DropdownContentWithValidation({ 18496 touched, 18497 children 18498 }) { 18499 const ref = (0, import_element61.useRef)(null); 18500 useReportValidity(ref, touched); 18501 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { ref, children }); 18502 } 18503 function PanelDropdown({ 18504 data, 18505 field, 18506 onChange, 18507 validity 18508 }) { 18509 const [touched, setTouched] = (0, import_element61.useState)(false); 18510 const [popoverAnchor, setPopoverAnchor] = (0, import_element61.useState)( 18511 null 18512 ); 18513 const popoverProps = (0, import_element61.useMemo)( 18514 () => ({ 18515 // Anchor the popover to the middle of the entire row so that it doesn't 18516 // move around when the label changes. 18517 anchor: popoverAnchor, 18518 placement: "left-start", 18519 offset: 36, 18520 shift: true 18521 }), 18522 [popoverAnchor] 18523 ); 18524 const [dialogRef, dialogProps] = (0, import_compose3.__experimentalUseDialog)({ 18525 focusOnMount: "firstInputElement" 18526 }); 18527 const form = (0, import_element61.useMemo)( 18528 () => ({ 18529 layout: DEFAULT_LAYOUT, 18530 fields: !!field.children ? field.children : ( 18531 // If not explicit children return the field id itself. 18532 [{ id: field.id, layout: DEFAULT_LAYOUT }] 18533 ) 18534 }), 18535 [field] 18536 ); 18537 const formValidity = (0, import_element61.useMemo)(() => { 18538 if (validity === void 0) { 18539 return void 0; 18540 } 18541 if (!!field.children) { 18542 return validity?.children; 18543 } 18544 return { [field.id]: validity }; 18545 }, [validity, field]); 18546 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field); 18547 if (!fieldDefinition) { 18548 return null; 18549 } 18550 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 18551 "div", 18552 { 18553 ref: setPopoverAnchor, 18554 className: "dataforms-layouts-panel__field-dropdown-anchor", 18555 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 18556 import_components25.Dropdown, 18557 { 18558 contentClassName: "dataforms-layouts-panel__field-dropdown", 18559 popoverProps, 18560 focusOnMount: false, 18561 onToggle: (willOpen) => { 18562 if (!willOpen) { 18563 setTouched(true); 18564 } 18565 }, 18566 renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 18567 SummaryButton, 18568 { 18569 data, 18570 field, 18571 fieldLabel, 18572 summaryFields, 18573 validity, 18574 touched, 18575 disabled: fieldDefinition.readOnly === true, 18576 onClick: onToggle, 18577 "aria-expanded": isOpen2 18578 } 18579 ), 18580 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [ 18581 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 18582 DropdownHeader, 18583 { 18584 title: fieldLabel, 18585 onClose 18586 } 18587 ), 18588 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 18589 DataFormLayout, 18590 { 18591 data, 18592 form, 18593 onChange, 18594 validity: formValidity, 18595 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 18596 FieldLayout, 18597 { 18598 data, 18599 field: childField, 18600 onChange, 18601 hideLabelFromVision: (form?.fields ?? []).length < 2, 18602 markWhenOptional, 18603 validity: childFieldValidity 18604 }, 18605 childField.id 18606 ) 18607 } 18608 ) 18609 ] }) }) 18610 } 18611 ) 18612 } 18613 ); 18614 } 18615 var dropdown_default = PanelDropdown; 18616 18617 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs 18618 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1); 18619 function FormPanelField({ 18620 data, 18621 field, 18622 onChange, 18623 validity 18624 }) { 18625 const layout = field.layout; 18626 if (layout.openAs.type === "modal") { 18627 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 18628 modal_default, 18629 { 18630 data, 18631 field, 18632 onChange, 18633 validity 18634 } 18635 ); 18636 } 18637 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 18638 dropdown_default, 18639 { 18640 data, 18641 field, 18642 onChange, 18643 validity 18644 } 18645 ); 18646 } 18647 18648 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs 18649 var import_element62 = __toESM(require_element(), 1); 18650 18651 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs 18652 var import_i18n22 = __toESM(require_i18n(), 1); 18653 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1); 18654 function countInvalidFields(validity) { 18655 if (!validity) { 18656 return 0; 18657 } 18658 let count = 0; 18659 const validityRules = Object.keys(validity).filter( 18660 (key) => key !== "children" 18661 ); 18662 for (const key of validityRules) { 18663 const rule = validity[key]; 18664 if (rule?.type === "invalid") { 18665 count++; 18666 } 18667 } 18668 if (validity.children) { 18669 for (const childValidity of Object.values(validity.children)) { 18670 count += countInvalidFields(childValidity); 18671 } 18672 } 18673 return count; 18674 } 18675 function ValidationBadge({ 18676 validity 18677 }) { 18678 const invalidCount = countInvalidFields(validity); 18679 if (invalidCount === 0) { 18680 return null; 18681 } 18682 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Badge, { intent: "high", children: (0, import_i18n22.sprintf)( 18683 /* translators: %d: Number of fields that need attention */ 18684 (0, import_i18n22._n)( 18685 "%d field needs attention", 18686 "%d fields need attention", 18687 invalidCount 18688 ), 18689 invalidCount 18690 ) }); 18691 } 18692 18693 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs 18694 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1); 18695 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen2) { 18696 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) { 18697 return false; 18698 } 18699 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig]; 18700 const fieldConfig = summaryConfigArray.find((config) => { 18701 if (typeof config === "string") { 18702 return config === summaryField.id; 18703 } 18704 if (typeof config === "object" && "id" in config) { 18705 return config.id === summaryField.id; 18706 } 18707 return false; 18708 }); 18709 if (!fieldConfig) { 18710 return false; 18711 } 18712 if (typeof fieldConfig === "string") { 18713 return true; 18714 } 18715 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) { 18716 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen2; 18717 } 18718 return true; 18719 } 18720 function HeaderContent({ 18721 data, 18722 fields, 18723 label, 18724 layout, 18725 isOpen: isOpen2, 18726 touched, 18727 validity 18728 }) { 18729 const summaryFields = getSummaryFields(layout.summary, fields); 18730 const visibleSummaryFields = summaryFields.filter( 18731 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen2) 18732 ); 18733 const hasBadge = touched && layout.isCollapsible; 18734 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader; 18735 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 18736 Stack, 18737 { 18738 align: "center", 18739 justify: "space-between", 18740 className: "dataforms-layouts-card__field-header-content", 18741 children: [ 18742 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(card_exports.Title, { children: label }), 18743 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [ 18744 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ValidationBadge, { validity }), 18745 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 18746 summaryField.render, 18747 { 18748 item: data, 18749 field: summaryField 18750 }, 18751 summaryField.id 18752 )) }) 18753 ] }) 18754 ] 18755 } 18756 ); 18757 } 18758 function BodyContent({ 18759 data, 18760 field, 18761 form, 18762 onChange, 18763 hideLabelFromVision, 18764 markWhenOptional, 18765 validity, 18766 withHeader 18767 }) { 18768 if (field.children) { 18769 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_jsx_runtime90.Fragment, { children: [ 18770 field.description && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }), 18771 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 18772 DataFormLayout, 18773 { 18774 data, 18775 form, 18776 onChange, 18777 validity: validity?.children 18778 } 18779 ) 18780 ] }); 18781 } 18782 const SingleFieldLayout = getFormFieldLayout("regular")?.component; 18783 if (!SingleFieldLayout) { 18784 return null; 18785 } 18786 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 18787 SingleFieldLayout, 18788 { 18789 data, 18790 field, 18791 onChange, 18792 hideLabelFromVision: hideLabelFromVision || withHeader, 18793 markWhenOptional, 18794 validity 18795 } 18796 ); 18797 } 18798 function FormCardField({ 18799 data, 18800 field, 18801 onChange, 18802 hideLabelFromVision, 18803 markWhenOptional, 18804 validity 18805 }) { 18806 const { fields } = (0, import_element62.useContext)(dataform_context_default); 18807 const layout = field.layout; 18808 const contentRef = (0, import_element62.useRef)(null); 18809 const form = (0, import_element62.useMemo)( 18810 () => ({ 18811 layout: DEFAULT_LAYOUT, 18812 fields: field.children ?? [] 18813 }), 18814 [field] 18815 ); 18816 const { isOpened, isCollapsible } = layout; 18817 const [isOpen2, setIsOpen] = (0, import_element62.useState)(isOpened); 18818 const [touched, setTouched] = (0, import_element62.useState)(false); 18819 (0, import_element62.useEffect)(() => { 18820 setIsOpen(isOpened); 18821 }, [isOpened]); 18822 const handleOpenChange = (0, import_element62.useCallback)((open) => { 18823 if (!open) { 18824 setTouched(true); 18825 } 18826 setIsOpen(open); 18827 }, []); 18828 const handleBlur = (0, import_element62.useCallback)(() => { 18829 setTouched(true); 18830 }, []); 18831 useReportValidity( 18832 contentRef, 18833 (isCollapsible ? isOpen2 : true) && touched 18834 ); 18835 let label = field.label; 18836 let withHeader; 18837 if (field.children) { 18838 withHeader = !!label && layout.withHeader; 18839 } else { 18840 const fieldDefinition = fields.find( 18841 (fieldDef) => fieldDef.id === field.id 18842 ); 18843 if (!fieldDefinition || !fieldDefinition.Edit) { 18844 return null; 18845 } 18846 label = fieldDefinition.label; 18847 withHeader = !!label && layout.withHeader; 18848 } 18849 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 18850 BodyContent, 18851 { 18852 data, 18853 field, 18854 form, 18855 onChange, 18856 hideLabelFromVision, 18857 markWhenOptional, 18858 validity, 18859 withHeader 18860 } 18861 ); 18862 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 18863 HeaderContent, 18864 { 18865 data, 18866 fields, 18867 label, 18868 layout, 18869 isOpen: isCollapsible ? !!isOpen2 : true, 18870 touched, 18871 validity 18872 } 18873 ); 18874 if (withHeader && isCollapsible) { 18875 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 18876 collapsible_card_exports.Root, 18877 { 18878 className: "dataforms-layouts-card__field", 18879 open: isOpen2, 18880 onOpenChange: handleOpenChange, 18881 children: [ 18882 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(collapsible_card_exports.Header, { children: headerContent }), 18883 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 18884 collapsible_card_exports.Content, 18885 { 18886 ref: contentRef, 18887 onBlur: handleBlur, 18888 children: bodyContent 18889 } 18890 ) 18891 ] 18892 } 18893 ); 18894 } 18895 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [ 18896 withHeader && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(card_exports.Header, { children: headerContent }), 18897 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent }) 18898 ] }); 18899 } 18900 18901 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs 18902 var import_components26 = __toESM(require_components(), 1); 18903 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1); 18904 function Header5({ title }) { 18905 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 18906 Stack, 18907 { 18908 direction: "column", 18909 className: "dataforms-layouts-row__header", 18910 gap: "lg", 18911 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_components26.__experimentalHeading, { level: 2, size: 13, children: title }) }) 18912 } 18913 ); 18914 } 18915 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_jsx_runtime91.Fragment, { children }); 18916 function FormRowField({ 18917 data, 18918 field, 18919 onChange, 18920 hideLabelFromVision, 18921 markWhenOptional, 18922 validity 18923 }) { 18924 const layout = field.layout; 18925 if (!!field.children) { 18926 const form = { 18927 layout: DEFAULT_LAYOUT, 18928 fields: field.children 18929 }; 18930 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "dataforms-layouts-row__field", children: [ 18931 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Header5, { title: field.label }), 18932 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 18933 DataFormLayout, 18934 { 18935 data, 18936 form, 18937 onChange, 18938 validity: validity?.children, 18939 as: EMPTY_WRAPPER, 18940 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 18941 "div", 18942 { 18943 className: "dataforms-layouts-row__field-control", 18944 style: layout.styles[childField.id], 18945 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 18946 FieldLayout, 18947 { 18948 data, 18949 field: childField, 18950 onChange, 18951 hideLabelFromVision, 18952 markWhenOptional, 18953 validity: childFieldValidity 18954 } 18955 ) 18956 }, 18957 childField.id 18958 ) 18959 } 18960 ) }) 18961 ] }); 18962 } 18963 const RegularLayout = getFormFieldLayout("regular")?.component; 18964 if (!RegularLayout) { 18965 return null; 18966 } 18967 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_jsx_runtime91.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 18968 RegularLayout, 18969 { 18970 data, 18971 field, 18972 onChange, 18973 markWhenOptional, 18974 validity 18975 } 18976 ) }) }); 18977 } 18978 18979 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs 18980 var import_element63 = __toESM(require_element(), 1); 18981 var import_i18n23 = __toESM(require_i18n(), 1); 18982 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1); 18983 function FormDetailsField({ 18984 data, 18985 field, 18986 onChange, 18987 validity 18988 }) { 18989 const { fields } = (0, import_element63.useContext)(dataform_context_default); 18990 const detailsRef = (0, import_element63.useRef)(null); 18991 const contentRef = (0, import_element63.useRef)(null); 18992 const [touched, setTouched] = (0, import_element63.useState)(false); 18993 const [isOpen2, setIsOpen] = (0, import_element63.useState)(false); 18994 const form = (0, import_element63.useMemo)( 18995 () => ({ 18996 layout: DEFAULT_LAYOUT, 18997 fields: field.children ?? [] 18998 }), 18999 [field] 19000 ); 19001 (0, import_element63.useEffect)(() => { 19002 const details = detailsRef.current; 19003 if (!details) { 19004 return; 19005 } 19006 const handleToggle = () => { 19007 const nowOpen = details.open; 19008 if (!nowOpen) { 19009 setTouched(true); 19010 } 19011 setIsOpen(nowOpen); 19012 }; 19013 details.addEventListener("toggle", handleToggle); 19014 return () => { 19015 details.removeEventListener("toggle", handleToggle); 19016 }; 19017 }, []); 19018 useReportValidity(contentRef, isOpen2 && touched); 19019 const handleBlur = (0, import_element63.useCallback)(() => { 19020 setTouched(true); 19021 }, []); 19022 if (!field.children) { 19023 return null; 19024 } 19025 const summaryFieldId = field.layout.summary ?? ""; 19026 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0; 19027 let summaryContent; 19028 if (summaryField && summaryField.render) { 19029 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(summaryField.render, { item: data, field: summaryField }); 19030 } else { 19031 summaryContent = field.label || (0, import_i18n23.__)("More details"); 19032 } 19033 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)( 19034 "details", 19035 { 19036 ref: detailsRef, 19037 className: "dataforms-layouts-details__details", 19038 children: [ 19039 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)( 19040 Stack, 19041 { 19042 direction: "row", 19043 align: "center", 19044 gap: "md", 19045 className: "dataforms-layouts-details__summary-content", 19046 children: [ 19047 summaryContent, 19048 touched && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ValidationBadge, { validity }) 19049 ] 19050 } 19051 ) }), 19052 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 19053 "div", 19054 { 19055 ref: contentRef, 19056 className: "dataforms-layouts-details__content", 19057 onBlur: handleBlur, 19058 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 19059 DataFormLayout, 19060 { 19061 data, 19062 form, 19063 onChange, 19064 validity: validity?.children 19065 } 19066 ) 19067 } 19068 ) 19069 ] 19070 } 19071 ); 19072 } 19073 19074 // packages/dataviews/build-module/components/dataform-layouts/index.mjs 19075 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1); 19076 var FORM_FIELD_LAYOUTS = [ 19077 { 19078 type: "regular", 19079 component: FormRegularField, 19080 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 19081 Stack, 19082 { 19083 direction: "column", 19084 className: "dataforms-layouts__wrapper", 19085 gap: "lg", 19086 children 19087 } 19088 ) 19089 }, 19090 { 19091 type: "panel", 19092 component: FormPanelField, 19093 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 19094 Stack, 19095 { 19096 direction: "column", 19097 className: "dataforms-layouts__wrapper", 19098 gap: "md", 19099 children 19100 } 19101 ) 19102 }, 19103 { 19104 type: "card", 19105 component: FormCardField, 19106 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 19107 Stack, 19108 { 19109 direction: "column", 19110 className: "dataforms-layouts__wrapper", 19111 gap: "xl", 19112 children 19113 } 19114 ) 19115 }, 19116 { 19117 type: "row", 19118 component: FormRowField, 19119 wrapper: ({ 19120 children, 19121 layout 19122 }) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 19123 Stack, 19124 { 19125 direction: "column", 19126 className: "dataforms-layouts__wrapper", 19127 gap: "lg", 19128 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 19129 Stack, 19130 { 19131 direction: "row", 19132 gap: "lg", 19133 align: layout.alignment, 19134 children 19135 } 19136 ) }) 19137 } 19138 ) 19139 }, 19140 { 19141 type: "details", 19142 component: FormDetailsField 19143 } 19144 ]; 19145 function getFormFieldLayout(type) { 19146 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type); 19147 } 19148 19149 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs 19150 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1); 19151 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children }); 19152 function DataFormLayout({ 19153 data, 19154 form, 19155 onChange, 19156 validity, 19157 children, 19158 as 19159 }) { 19160 const { fields: fieldDefinitions } = (0, import_element64.useContext)(dataform_context_default); 19161 const markWhenOptional = (0, import_element64.useMemo)(() => { 19162 const requiredCount = fieldDefinitions.filter( 19163 (f2) => !!f2.isValid?.required 19164 ).length; 19165 const optionalCount = fieldDefinitions.length - requiredCount; 19166 return requiredCount > optionalCount; 19167 }, [fieldDefinitions]); 19168 function getFieldDefinition2(field) { 19169 return fieldDefinitions.find( 19170 (fieldDefinition) => fieldDefinition.id === field.id 19171 ); 19172 } 19173 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER; 19174 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => { 19175 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component; 19176 if (!FieldLayout) { 19177 return null; 19178 } 19179 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0; 19180 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) { 19181 return null; 19182 } 19183 if (children) { 19184 return children( 19185 FieldLayout, 19186 formField, 19187 validity?.[formField.id], 19188 markWhenOptional 19189 ); 19190 } 19191 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 19192 FieldLayout, 19193 { 19194 data, 19195 field: formField, 19196 onChange, 19197 markWhenOptional, 19198 validity: validity?.[formField.id] 19199 }, 19200 formField.id 19201 ); 19202 }) }); 19203 } 19204 19205 // packages/dataviews/build-module/dataform/index.mjs 19206 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1); 19207 function DataForm({ 19208 data, 19209 form, 19210 fields, 19211 onChange, 19212 validity 19213 }) { 19214 const normalizedForm = (0, import_element65.useMemo)(() => normalize_form_default(form), [form]); 19215 const normalizedFields = (0, import_element65.useMemo)( 19216 () => normalizeFields(fields), 19217 [fields] 19218 ); 19219 if (!form.fields) { 19220 return null; 19221 } 19222 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 19223 DataFormLayout, 19224 { 19225 data, 19226 form: normalizedForm, 19227 onChange, 19228 validity 19229 } 19230 ) }); 19231 } 19232 19233 // packages/media-editor/build-module/components/media-form/index.mjs 19234 var import_components28 = __toESM(require_components(), 1); 19235 var import_i18n24 = __toESM(require_i18n(), 1); 19236 var import_element66 = __toESM(require_element(), 1); 19237 19238 // packages/media-editor/build-module/components/media-form/sidebar-datetime-view.mjs 19239 var import_date10 = __toESM(require_date(), 1); 19240 var import_components27 = __toESM(require_components(), 1); 19241 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1); 19242 function SidebarDatetimeView({ 19243 item, 19244 field 19245 }) { 19246 const value = field.getValue({ item }); 19247 if (!value) { 19248 return null; 19249 } 19250 const settings = (0, import_date10.getSettings)(); 19251 const dateOnly = (0, import_date10.dateI18n)(settings.formats.date, (0, import_date10.getDate)(value)); 19252 const fullDatetime = (0, import_date10.dateI18n)( 19253 settings.formats.datetimeAbbreviated, 19254 (0, import_date10.getDate)(value) 19255 ); 19256 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components27.Tooltip, { text: fullDatetime, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 19257 "time", 19258 { 19259 dateTime: value, 19260 "aria-label": fullDatetime, 19261 tabIndex: -1, 19262 children: dateOnly 19263 } 19264 ) }); 19265 } 19266 19267 // packages/media-editor/build-module/components/media-form/index.mjs 19268 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1); 19269 function MediaForm({ 19270 form: formOverrides, 19271 header 19272 }) { 19273 const { media, fields, onChange } = useMediaEditorContext(); 19274 const formFields = (0, import_element66.useMemo)( 19275 () => fields.map( 19276 (field) => field.type === "datetime" && field.readOnly ? { ...field, render: SidebarDatetimeView } : field 19277 ), 19278 [fields] 19279 ); 19280 if (!media || !onChange) { 19281 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "media-editor-form media-editor-form--loading", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components28.Spinner, {}) }); 19282 } 19283 const defaultForm = { 19284 layout: { 19285 type: "panel" 19286 }, 19287 fields: fields.map((field) => { 19288 if (["title", "alt_text", "caption", "description"].includes( 19289 field.id 19290 )) { 19291 return { 19292 id: field.id, 19293 layout: { 19294 type: "regular", 19295 labelPosition: "top" 19296 } 19297 }; 19298 } 19299 return field.id; 19300 }) 19301 }; 19302 const form = formOverrides || defaultForm; 19303 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "media-editor-form", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_components28.__experimentalVStack, { spacing: 4, children: [ 19304 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("h2", {}), children: (0, import_i18n24.__)("Media details") }), 19305 header, 19306 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 19307 DataForm, 19308 { 19309 data: media, 19310 fields: formFields, 19311 form, 19312 onChange 19313 } 19314 ) 19315 ] }) }); 19316 } 19317 19318 // packages/media-editor/build-module/lock-unlock.mjs 19319 var import_private_apis3 = __toESM(require_private_apis(), 1); 19320 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 19321 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 19322 "@wordpress/media-editor" 19323 ); 19324 19325 // packages/media-editor/build-module/store/index.mjs 19326 var import_data = __toESM(require_data(), 1); 19327 19328 // packages/media-editor/build-module/store/reducer.mjs 19329 var DEFAULT_STATE = { 19330 isOpen: false, 19331 id: null, 19332 onUpdate: null, 19333 onClose: null 19334 }; 19335 function reducer(state = DEFAULT_STATE, action) { 19336 switch (action.type) { 19337 case "OPEN_MEDIA_EDITOR_MODAL": { 19338 const { id, onUpdate, onClose } = action; 19339 return { 19340 isOpen: true, 19341 id, 19342 onUpdate, 19343 onClose 19344 }; 19345 } 19346 case "CLOSE_MEDIA_EDITOR_MODAL": 19347 return DEFAULT_STATE; 19348 } 19349 return state; 19350 } 19351 19352 // packages/media-editor/build-module/store/actions.mjs 19353 var actions_exports = {}; 19354 __export(actions_exports, { 19355 closeMediaEditorModal: () => closeMediaEditorModal, 19356 openMediaEditorModal: () => openMediaEditorModal 19357 }); 19358 function openMediaEditorModal({ 19359 id, 19360 onUpdate, 19361 onClose 19362 }) { 19363 return { 19364 type: "OPEN_MEDIA_EDITOR_MODAL", 19365 id, 19366 onUpdate: onUpdate ?? null, 19367 onClose: onClose ?? null 19368 }; 19369 } 19370 function closeMediaEditorModal() { 19371 return { type: "CLOSE_MEDIA_EDITOR_MODAL" }; 19372 } 19373 19374 // packages/media-editor/build-module/store/selectors.mjs 19375 var selectors_exports = {}; 19376 __export(selectors_exports, { 19377 getId: () => getId, 19378 getOnClose: () => getOnClose, 19379 getOnUpdate: () => getOnUpdate, 19380 isOpen: () => isOpen 19381 }); 19382 function isOpen(state) { 19383 return state.isOpen; 19384 } 19385 function getId(state) { 19386 return state.id; 19387 } 19388 function getOnUpdate(state) { 19389 return state.onUpdate; 19390 } 19391 function getOnClose(state) { 19392 return state.onClose; 19393 } 19394 19395 // packages/media-editor/build-module/store/constants.mjs 19396 var STORE_NAME = "core/media-editor"; 19397 19398 // packages/media-editor/build-module/store/index.mjs 19399 var store = (0, import_data.createReduxStore)(STORE_NAME, { 19400 reducer, 19401 actions: actions_exports, 19402 selectors: selectors_exports 19403 }); 19404 (0, import_data.register)(store); 19405 19406 // packages/media-editor/build-module/components/media-editor-modal/index.mjs 19407 var import_components40 = __toESM(require_components(), 1); 19408 var import_data9 = __toESM(require_data(), 1); 19409 var import_i18n37 = __toESM(require_i18n(), 1); 19410 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1); 19411 var import_notices3 = __toESM(require_notices(), 1); 19412 19413 // packages/media-editor/build-module/components/media-editor/index.mjs 19414 var import_components39 = __toESM(require_components(), 1); 19415 var import_compose6 = __toESM(require_compose(), 1); 19416 var import_data8 = __toESM(require_data(), 1); 19417 var import_core_data2 = __toESM(require_core_data(), 1); 19418 var import_element87 = __toESM(require_element(), 1); 19419 var import_i18n36 = __toESM(require_i18n(), 1); 19420 var import_keycodes2 = __toESM(require_keycodes(), 1); 19421 var import_notices2 = __toESM(require_notices(), 1); 19422 19423 // packages/interface/build-module/components/complementary-area/index.mjs 19424 var import_components33 = __toESM(require_components(), 1); 19425 var import_data6 = __toESM(require_data(), 1); 19426 var import_i18n25 = __toESM(require_i18n(), 1); 19427 var import_element68 = __toESM(require_element(), 1); 19428 var import_viewport = __toESM(require_viewport(), 1); 19429 var import_preferences3 = __toESM(require_preferences(), 1); 19430 var import_compose4 = __toESM(require_compose(), 1); 19431 var import_plugins2 = __toESM(require_plugins(), 1); 19432 19433 // packages/interface/build-module/components/complementary-area-toggle/index.mjs 19434 var import_components29 = __toESM(require_components(), 1); 19435 var import_data5 = __toESM(require_data(), 1); 19436 var import_plugins = __toESM(require_plugins(), 1); 19437 19438 // packages/interface/build-module/store/index.mjs 19439 var import_data4 = __toESM(require_data(), 1); 19440 19441 // packages/interface/build-module/store/actions.mjs 19442 var actions_exports2 = {}; 19443 __export(actions_exports2, { 19444 closeModal: () => closeModal, 19445 disableComplementaryArea: () => disableComplementaryArea, 19446 enableComplementaryArea: () => enableComplementaryArea, 19447 openModal: () => openModal, 19448 pinItem: () => pinItem, 19449 setDefaultComplementaryArea: () => setDefaultComplementaryArea, 19450 setFeatureDefaults: () => setFeatureDefaults, 19451 setFeatureValue: () => setFeatureValue, 19452 toggleFeature: () => toggleFeature, 19453 unpinItem: () => unpinItem 19454 }); 19455 var import_deprecated2 = __toESM(require_deprecated(), 1); 19456 var import_preferences = __toESM(require_preferences(), 1); 19457 19458 // packages/interface/build-module/store/deprecated.mjs 19459 var import_deprecated = __toESM(require_deprecated(), 1); 19460 function normalizeComplementaryAreaScope(scope) { 19461 if (["core/edit-post", "core/edit-site"].includes(scope)) { 19462 (0, import_deprecated.default)(`$scope} interface scope`, { 19463 alternative: "core interface scope", 19464 hint: "core/edit-post and core/edit-site are merging.", 19465 version: "6.6" 19466 }); 19467 return "core"; 19468 } 19469 return scope; 19470 } 19471 function normalizeComplementaryAreaName(scope, name) { 19472 if (scope === "core" && name === "edit-site/template") { 19473 (0, import_deprecated.default)(`edit-site/template sidebar`, { 19474 alternative: "edit-post/document", 19475 version: "6.6" 19476 }); 19477 return "edit-post/document"; 19478 } 19479 if (scope === "core" && name === "edit-site/block-inspector") { 19480 (0, import_deprecated.default)(`edit-site/block-inspector sidebar`, { 19481 alternative: "edit-post/block", 19482 version: "6.6" 19483 }); 19484 return "edit-post/block"; 19485 } 19486 return name; 19487 } 19488 19489 // packages/interface/build-module/store/actions.mjs 19490 var setDefaultComplementaryArea = (scope, area) => { 19491 scope = normalizeComplementaryAreaScope(scope); 19492 area = normalizeComplementaryAreaName(scope, area); 19493 return { 19494 type: "SET_DEFAULT_COMPLEMENTARY_AREA", 19495 scope, 19496 area 19497 }; 19498 }; 19499 var enableComplementaryArea = (scope, area) => ({ registry, dispatch }) => { 19500 if (!area) { 19501 return; 19502 } 19503 scope = normalizeComplementaryAreaScope(scope); 19504 area = normalizeComplementaryAreaName(scope, area); 19505 const isComplementaryAreaVisible = registry.select(import_preferences.store).get(scope, "isComplementaryAreaVisible"); 19506 if (!isComplementaryAreaVisible) { 19507 registry.dispatch(import_preferences.store).set(scope, "isComplementaryAreaVisible", true); 19508 } 19509 dispatch({ 19510 type: "ENABLE_COMPLEMENTARY_AREA", 19511 scope, 19512 area 19513 }); 19514 }; 19515 var disableComplementaryArea = (scope) => ({ registry }) => { 19516 scope = normalizeComplementaryAreaScope(scope); 19517 const isComplementaryAreaVisible = registry.select(import_preferences.store).get(scope, "isComplementaryAreaVisible"); 19518 if (isComplementaryAreaVisible) { 19519 registry.dispatch(import_preferences.store).set(scope, "isComplementaryAreaVisible", false); 19520 } 19521 }; 19522 var pinItem = (scope, item) => ({ registry }) => { 19523 if (!item) { 19524 return; 19525 } 19526 scope = normalizeComplementaryAreaScope(scope); 19527 item = normalizeComplementaryAreaName(scope, item); 19528 const pinnedItems = registry.select(import_preferences.store).get(scope, "pinnedItems"); 19529 if (pinnedItems?.[item] === true) { 19530 return; 19531 } 19532 registry.dispatch(import_preferences.store).set(scope, "pinnedItems", { 19533 ...pinnedItems, 19534 [item]: true 19535 }); 19536 }; 19537 var unpinItem = (scope, item) => ({ registry }) => { 19538 if (!item) { 19539 return; 19540 } 19541 scope = normalizeComplementaryAreaScope(scope); 19542 item = normalizeComplementaryAreaName(scope, item); 19543 const pinnedItems = registry.select(import_preferences.store).get(scope, "pinnedItems"); 19544 registry.dispatch(import_preferences.store).set(scope, "pinnedItems", { 19545 ...pinnedItems, 19546 [item]: false 19547 }); 19548 }; 19549 function toggleFeature(scope, featureName) { 19550 return function({ registry }) { 19551 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).toggleFeature`, { 19552 since: "6.0", 19553 alternative: `dispatch( 'core/preferences' ).toggle` 19554 }); 19555 registry.dispatch(import_preferences.store).toggle(scope, featureName); 19556 }; 19557 } 19558 function setFeatureValue(scope, featureName, value) { 19559 return function({ registry }) { 19560 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).setFeatureValue`, { 19561 since: "6.0", 19562 alternative: `dispatch( 'core/preferences' ).set` 19563 }); 19564 registry.dispatch(import_preferences.store).set(scope, featureName, !!value); 19565 }; 19566 } 19567 function setFeatureDefaults(scope, defaults) { 19568 return function({ registry }) { 19569 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).setFeatureDefaults`, { 19570 since: "6.0", 19571 alternative: `dispatch( 'core/preferences' ).setDefaults` 19572 }); 19573 registry.dispatch(import_preferences.store).setDefaults(scope, defaults); 19574 }; 19575 } 19576 function openModal(name) { 19577 return { 19578 type: "OPEN_MODAL", 19579 name 19580 }; 19581 } 19582 function closeModal() { 19583 return { 19584 type: "CLOSE_MODAL" 19585 }; 19586 } 19587 19588 // packages/interface/build-module/store/selectors.mjs 19589 var selectors_exports2 = {}; 19590 __export(selectors_exports2, { 19591 getActiveComplementaryArea: () => getActiveComplementaryArea, 19592 isComplementaryAreaLoading: () => isComplementaryAreaLoading, 19593 isFeatureActive: () => isFeatureActive, 19594 isItemPinned: () => isItemPinned, 19595 isModalActive: () => isModalActive 19596 }); 19597 var import_data2 = __toESM(require_data(), 1); 19598 var import_deprecated4 = __toESM(require_deprecated(), 1); 19599 var import_preferences2 = __toESM(require_preferences(), 1); 19600 var getActiveComplementaryArea = (0, import_data2.createRegistrySelector)( 19601 (select) => (state, scope) => { 19602 scope = normalizeComplementaryAreaScope(scope); 19603 const isComplementaryAreaVisible = select(import_preferences2.store).get( 19604 scope, 19605 "isComplementaryAreaVisible" 19606 ); 19607 if (isComplementaryAreaVisible === void 0) { 19608 return void 0; 19609 } 19610 if (isComplementaryAreaVisible === false) { 19611 return null; 19612 } 19613 return state?.complementaryAreas?.[scope]; 19614 } 19615 ); 19616 var isComplementaryAreaLoading = (0, import_data2.createRegistrySelector)( 19617 (select) => (state, scope) => { 19618 scope = normalizeComplementaryAreaScope(scope); 19619 const isVisible = select(import_preferences2.store).get( 19620 scope, 19621 "isComplementaryAreaVisible" 19622 ); 19623 const identifier = state?.complementaryAreas?.[scope]; 19624 return isVisible && identifier === void 0; 19625 } 19626 ); 19627 var isItemPinned = (0, import_data2.createRegistrySelector)( 19628 (select) => (state, scope, item) => { 19629 scope = normalizeComplementaryAreaScope(scope); 19630 item = normalizeComplementaryAreaName(scope, item); 19631 const pinnedItems = select(import_preferences2.store).get( 19632 scope, 19633 "pinnedItems" 19634 ); 19635 return pinnedItems?.[item] ?? true; 19636 } 19637 ); 19638 var isFeatureActive = (0, import_data2.createRegistrySelector)( 19639 (select) => (state, scope, featureName) => { 19640 (0, import_deprecated4.default)( 19641 `select( 'core/interface' ).isFeatureActive( scope, featureName )`, 19642 { 19643 since: "6.0", 19644 alternative: `select( 'core/preferences' ).get( scope, featureName )` 19645 } 19646 ); 19647 return !!select(import_preferences2.store).get(scope, featureName); 19648 } 19649 ); 19650 function isModalActive(state, modalName) { 19651 return state.activeModal === modalName; 19652 } 19653 19654 // packages/interface/build-module/store/reducer.mjs 19655 var import_data3 = __toESM(require_data(), 1); 19656 function complementaryAreas(state = {}, action) { 19657 switch (action.type) { 19658 case "SET_DEFAULT_COMPLEMENTARY_AREA": { 19659 const { scope, area } = action; 19660 if (state[scope]) { 19661 return state; 19662 } 19663 return { 19664 ...state, 19665 [scope]: area 19666 }; 19667 } 19668 case "ENABLE_COMPLEMENTARY_AREA": { 19669 const { scope, area } = action; 19670 return { 19671 ...state, 19672 [scope]: area 19673 }; 19674 } 19675 } 19676 return state; 19677 } 19678 function activeModal(state = null, action) { 19679 switch (action.type) { 19680 case "OPEN_MODAL": 19681 return action.name; 19682 case "CLOSE_MODAL": 19683 return null; 19684 } 19685 return state; 19686 } 19687 var reducer_default = (0, import_data3.combineReducers)({ 19688 complementaryAreas, 19689 activeModal 19690 }); 19691 19692 // packages/interface/build-module/store/constants.mjs 19693 var STORE_NAME2 = "core/interface"; 19694 19695 // packages/interface/build-module/store/index.mjs 19696 var store2 = (0, import_data4.createReduxStore)(STORE_NAME2, { 19697 reducer: reducer_default, 19698 actions: actions_exports2, 19699 selectors: selectors_exports2 19700 }); 19701 (0, import_data4.register)(store2); 19702 19703 // packages/interface/build-module/components/complementary-area-toggle/index.mjs 19704 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1); 19705 function roleSupportsCheckedState(role) { 19706 return [ 19707 "checkbox", 19708 "option", 19709 "radio", 19710 "switch", 19711 "menuitemcheckbox", 19712 "menuitemradio", 19713 "treeitem" 19714 ].includes(role); 19715 } 19716 function ComplementaryAreaToggle({ 19717 as = import_components29.Button, 19718 scope, 19719 identifier: identifierProp, 19720 icon: iconProp, 19721 selectedIcon, 19722 name, 19723 shortcut, 19724 ...props 19725 }) { 19726 const ComponentToUse = as; 19727 const context = (0, import_plugins.usePluginContext)(); 19728 const icon = iconProp || context.icon; 19729 const identifier = identifierProp || `$context.name}/$name}`; 19730 const isSelected = (0, import_data5.useSelect)( 19731 (select) => select(store2).getActiveComplementaryArea(scope) === identifier, 19732 [identifier, scope] 19733 ); 19734 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data5.useDispatch)(store2); 19735 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 19736 ComponentToUse, 19737 { 19738 icon: selectedIcon && isSelected ? selectedIcon : icon, 19739 "aria-controls": identifier.replace("/", ":"), 19740 "aria-checked": roleSupportsCheckedState(props.role) ? isSelected : void 0, 19741 onClick: () => { 19742 if (isSelected) { 19743 disableComplementaryArea2(scope); 19744 } else { 19745 enableComplementaryArea2(scope, identifier); 19746 } 19747 }, 19748 shortcut, 19749 ...props 19750 } 19751 ); 19752 } 19753 19754 // packages/interface/build-module/components/complementary-area-header/index.mjs 19755 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1); 19756 var ComplementaryAreaHeader = ({ 19757 children, 19758 className, 19759 toggleButtonProps 19760 }) => { 19761 const toggleButton = /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(ComplementaryAreaToggle, { icon: close_small_default, ...toggleButtonProps }); 19762 return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)( 19763 "div", 19764 { 19765 className: clsx_default( 19766 "components-panel__header", 19767 "interface-complementary-area-header", 19768 className 19769 ), 19770 tabIndex: -1, 19771 children: [ 19772 children, 19773 toggleButton 19774 ] 19775 } 19776 ); 19777 }; 19778 var complementary_area_header_default = ComplementaryAreaHeader; 19779 19780 // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs 19781 var import_components31 = __toESM(require_components(), 1); 19782 19783 // packages/interface/build-module/components/action-item/index.mjs 19784 var import_components30 = __toESM(require_components(), 1); 19785 var import_element67 = __toESM(require_element(), 1); 19786 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1); 19787 var noop4 = () => { 19788 }; 19789 function ActionItemSlot({ 19790 name, 19791 as: Component = import_components30.MenuGroup, 19792 fillProps = {}, 19793 bubblesVirtually, 19794 ...props 19795 }) { 19796 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 19797 import_components30.Slot, 19798 { 19799 name, 19800 bubblesVirtually, 19801 fillProps, 19802 children: (fills) => { 19803 if (!import_element67.Children.toArray(fills).length) { 19804 return null; 19805 } 19806 const initializedByPlugins = []; 19807 import_element67.Children.forEach( 19808 fills, 19809 ({ 19810 props: { __unstableExplicitMenuItem, __unstableTarget } 19811 }) => { 19812 if (__unstableTarget && __unstableExplicitMenuItem) { 19813 initializedByPlugins.push(__unstableTarget); 19814 } 19815 } 19816 ); 19817 const children = import_element67.Children.map(fills, (child) => { 19818 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes( 19819 child.props.__unstableTarget 19820 )) { 19821 return null; 19822 } 19823 return child; 19824 }); 19825 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Component, { ...props, children }); 19826 } 19827 } 19828 ); 19829 } 19830 function ActionItem({ name, as: Component = import_components30.Button, onClick, ...props }) { 19831 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components30.Fill, { name, children: ({ onClick: fpOnClick }) => { 19832 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 19833 Component, 19834 { 19835 onClick: onClick || fpOnClick ? (...args) => { 19836 (onClick || noop4)(...args); 19837 (fpOnClick || noop4)(...args); 19838 } : void 0, 19839 ...props 19840 } 19841 ); 19842 } }); 19843 } 19844 ActionItem.Slot = ActionItemSlot; 19845 var action_item_default = ActionItem; 19846 19847 // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs 19848 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1); 19849 var PluginsMenuItem = ({ 19850 // Menu item is marked with unstable prop for backward compatibility. 19851 // They are removed so they don't leak to DOM elements. 19852 // @see https://github.com/WordPress/gutenberg/issues/14457 19853 __unstableExplicitMenuItem, 19854 __unstableTarget, 19855 ...restProps 19856 }) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components31.MenuItem, { ...restProps }); 19857 function ComplementaryAreaMoreMenuItem({ 19858 scope, 19859 target, 19860 __unstableExplicitMenuItem, 19861 ...props 19862 }) { 19863 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19864 ComplementaryAreaToggle, 19865 { 19866 as: (toggleProps) => { 19867 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19868 action_item_default, 19869 { 19870 __unstableExplicitMenuItem, 19871 __unstableTarget: `$scope}/$target}`, 19872 as: PluginsMenuItem, 19873 name: `$scope}/plugin-more-menu`, 19874 ...toggleProps 19875 } 19876 ); 19877 }, 19878 role: "menuitemcheckbox", 19879 selectedIcon: check_default, 19880 name: target, 19881 scope, 19882 ...props 19883 } 19884 ); 19885 } 19886 19887 // packages/interface/build-module/components/pinned-items/index.mjs 19888 var import_components32 = __toESM(require_components(), 1); 19889 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1); 19890 function PinnedItems({ scope, ...props }) { 19891 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components32.Fill, { name: `PinnedItems/$scope}`, ...props }); 19892 } 19893 function PinnedItemsSlot({ scope, className, ...props }) { 19894 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components32.Slot, { name: `PinnedItems/$scope}`, ...props, children: (fills) => fills?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 19895 "div", 19896 { 19897 className: clsx_default( 19898 className, 19899 "interface-pinned-items" 19900 ), 19901 children: fills 19902 } 19903 ) }); 19904 } 19905 PinnedItems.Slot = PinnedItemsSlot; 19906 var pinned_items_default = PinnedItems; 19907 19908 // packages/interface/build-module/components/complementary-area/index.mjs 19909 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1); 19910 var ANIMATION_DURATION = 0.3; 19911 function ComplementaryAreaSlot({ scope, ...props }) { 19912 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components33.Slot, { name: `ComplementaryArea/$scope}`, ...props }); 19913 } 19914 var SIDEBAR_WIDTH = 280; 19915 var variants = { 19916 open: { width: SIDEBAR_WIDTH }, 19917 closed: { width: 0 }, 19918 mobileOpen: { width: "100vw" } 19919 }; 19920 function ComplementaryAreaFill({ 19921 activeArea, 19922 isActive, 19923 scope, 19924 children, 19925 className, 19926 id 19927 }) { 19928 const disableMotion = (0, import_compose4.useReducedMotion)(); 19929 const isMobileViewport = (0, import_compose4.useViewportMatch)("medium", "<"); 19930 const previousActiveArea = (0, import_compose4.usePrevious)(activeArea); 19931 const previousIsActive = (0, import_compose4.usePrevious)(isActive); 19932 const [, setState] = (0, import_element68.useState)({}); 19933 (0, import_element68.useEffect)(() => { 19934 setState({}); 19935 }, [isActive]); 19936 const transition = { 19937 type: "tween", 19938 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION, 19939 ease: [0.6, 0, 0.4, 1] 19940 }; 19941 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components33.Fill, { name: `ComplementaryArea/$scope}`, children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components33.__unstableAnimatePresence, { initial: false, children: (previousIsActive || isActive) && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19942 import_components33.__unstableMotion.div, 19943 { 19944 variants, 19945 initial: "closed", 19946 animate: isMobileViewport ? "mobileOpen" : "open", 19947 exit: "closed", 19948 transition, 19949 className: "interface-complementary-area__fill", 19950 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19951 "div", 19952 { 19953 id, 19954 className, 19955 style: { 19956 width: isMobileViewport ? "100vw" : SIDEBAR_WIDTH 19957 }, 19958 children 19959 } 19960 ) 19961 } 19962 ) }) }); 19963 } 19964 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) { 19965 const previousIsSmallRef = (0, import_element68.useRef)(false); 19966 const shouldOpenWhenNotSmallRef = (0, import_element68.useRef)(false); 19967 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data6.useDispatch)(store2); 19968 (0, import_element68.useEffect)(() => { 19969 if (isActive && isSmall && !previousIsSmallRef.current) { 19970 disableComplementaryArea2(scope); 19971 shouldOpenWhenNotSmallRef.current = true; 19972 } else if ( 19973 // If there is a flag indicating the complementary area should be 19974 // enabled when we go from small to big window size and we are going 19975 // from a small to big window size. 19976 shouldOpenWhenNotSmallRef.current && !isSmall && previousIsSmallRef.current 19977 ) { 19978 shouldOpenWhenNotSmallRef.current = false; 19979 enableComplementaryArea2(scope, identifier); 19980 } else if ( 19981 // If the flag is indicating the current complementary should be 19982 // reopened but another complementary area becomes active, remove 19983 // the flag. 19984 shouldOpenWhenNotSmallRef.current && activeArea && activeArea !== identifier 19985 ) { 19986 shouldOpenWhenNotSmallRef.current = false; 19987 } 19988 if (isSmall !== previousIsSmallRef.current) { 19989 previousIsSmallRef.current = isSmall; 19990 } 19991 }, [ 19992 isActive, 19993 isSmall, 19994 scope, 19995 identifier, 19996 activeArea, 19997 disableComplementaryArea2, 19998 enableComplementaryArea2 19999 ]); 20000 } 20001 function ComplementaryArea({ 20002 children, 20003 className, 20004 closeLabel = (0, import_i18n25.__)("Close plugin"), 20005 identifier: identifierProp, 20006 header, 20007 headerClassName, 20008 icon: iconProp, 20009 isPinnable = true, 20010 panelClassName, 20011 scope, 20012 name, 20013 title, 20014 toggleShortcut, 20015 isActiveByDefault 20016 }) { 20017 const context = (0, import_plugins2.usePluginContext)(); 20018 const icon = iconProp || context.icon; 20019 const identifier = identifierProp || `$context.name}/$name}`; 20020 const [isReady, setIsReady] = (0, import_element68.useState)(false); 20021 const { 20022 isLoading, 20023 isActive, 20024 isPinned, 20025 activeArea, 20026 isSmall, 20027 isLarge, 20028 showIconLabels 20029 } = (0, import_data6.useSelect)( 20030 (select) => { 20031 const { 20032 getActiveComplementaryArea: getActiveComplementaryArea2, 20033 isComplementaryAreaLoading: isComplementaryAreaLoading2, 20034 isItemPinned: isItemPinned2 20035 } = select(store2); 20036 const { get } = select(import_preferences3.store); 20037 const _activeArea = getActiveComplementaryArea2(scope); 20038 return { 20039 isLoading: isComplementaryAreaLoading2(scope), 20040 isActive: _activeArea === identifier, 20041 isPinned: isItemPinned2(scope, identifier), 20042 activeArea: _activeArea, 20043 isSmall: select(import_viewport.store).isViewportMatch("< medium"), 20044 isLarge: select(import_viewport.store).isViewportMatch("large"), 20045 showIconLabels: get("core", "showIconLabels") 20046 }; 20047 }, 20048 [identifier, scope] 20049 ); 20050 const isMobileViewport = (0, import_compose4.useViewportMatch)("medium", "<"); 20051 useAdjustComplementaryListener( 20052 scope, 20053 identifier, 20054 activeArea, 20055 isActive, 20056 isSmall 20057 ); 20058 const { 20059 enableComplementaryArea: enableComplementaryArea2, 20060 disableComplementaryArea: disableComplementaryArea2, 20061 pinItem: pinItem2, 20062 unpinItem: unpinItem2 20063 } = (0, import_data6.useDispatch)(store2); 20064 (0, import_element68.useEffect)(() => { 20065 if (isActiveByDefault && activeArea === void 0 && !isSmall) { 20066 enableComplementaryArea2(scope, identifier); 20067 } else if (activeArea === void 0 && isSmall) { 20068 disableComplementaryArea2(scope, identifier); 20069 } 20070 setIsReady(true); 20071 }, [ 20072 activeArea, 20073 isActiveByDefault, 20074 scope, 20075 identifier, 20076 isSmall, 20077 enableComplementaryArea2, 20078 disableComplementaryArea2 20079 ]); 20080 if (!isReady) { 20081 return; 20082 } 20083 return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_jsx_runtime103.Fragment, { children: [ 20084 isPinnable && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(pinned_items_default, { scope, children: isPinned && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 20085 ComplementaryAreaToggle, 20086 { 20087 scope, 20088 identifier, 20089 isPressed: isActive && (!showIconLabels || isLarge), 20090 "aria-expanded": isActive, 20091 "aria-disabled": isLoading, 20092 label: title, 20093 icon: showIconLabels ? check_default : icon, 20094 showTooltip: !showIconLabels, 20095 variant: showIconLabels ? "tertiary" : void 0, 20096 size: "compact", 20097 shortcut: toggleShortcut 20098 } 20099 ) }), 20100 name && isPinnable && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 20101 ComplementaryAreaMoreMenuItem, 20102 { 20103 target: name, 20104 scope, 20105 icon, 20106 identifier, 20107 children: title 20108 } 20109 ), 20110 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)( 20111 ComplementaryAreaFill, 20112 { 20113 activeArea, 20114 isActive, 20115 className: clsx_default("interface-complementary-area", className), 20116 scope, 20117 id: identifier.replace("/", ":"), 20118 children: [ 20119 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 20120 complementary_area_header_default, 20121 { 20122 className: headerClassName, 20123 closeLabel, 20124 onClose: () => disableComplementaryArea2(scope), 20125 toggleButtonProps: { 20126 label: closeLabel, 20127 size: "compact", 20128 shortcut: toggleShortcut, 20129 scope, 20130 identifier 20131 }, 20132 children: header || /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_jsx_runtime103.Fragment, { children: [ 20133 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("h2", { className: "interface-complementary-area-header__title", children: title }), 20134 isPinnable && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 20135 import_components33.Button, 20136 { 20137 className: "interface-complementary-area__pin-unpin-item", 20138 icon: isPinned ? star_filled_default : star_empty_default, 20139 label: isPinned ? (0, import_i18n25.__)("Unpin from toolbar") : (0, import_i18n25.__)("Pin to toolbar"), 20140 onClick: () => (isPinned ? unpinItem2 : pinItem2)( 20141 scope, 20142 identifier 20143 ), 20144 isPressed: isPinned, 20145 "aria-expanded": isPinned, 20146 size: "compact" 20147 } 20148 ) 20149 ] }) 20150 } 20151 ), 20152 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components33.Panel, { className: panelClassName, children }) 20153 ] 20154 } 20155 ) 20156 ] }); 20157 } 20158 ComplementaryArea.Slot = ComplementaryAreaSlot; 20159 var complementary_area_default = ComplementaryArea; 20160 20161 // packages/interface/build-module/components/interface-skeleton/index.mjs 20162 var import_element69 = __toESM(require_element(), 1); 20163 var import_components34 = __toESM(require_components(), 1); 20164 var import_i18n26 = __toESM(require_i18n(), 1); 20165 var import_compose5 = __toESM(require_compose(), 1); 20166 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1); 20167 var ANIMATION_DURATION2 = 0.25; 20168 var commonTransition = { 20169 type: "tween", 20170 duration: ANIMATION_DURATION2, 20171 ease: [0.6, 0, 0.4, 1] 20172 }; 20173 function useHTMLClass(className) { 20174 (0, import_element69.useEffect)(() => { 20175 const element = document && document.querySelector(`html:not(.$className})`); 20176 if (!element) { 20177 return; 20178 } 20179 element.classList.toggle(className); 20180 return () => { 20181 element.classList.toggle(className); 20182 }; 20183 }, [className]); 20184 } 20185 var headerVariants = { 20186 hidden: { opacity: 1, marginTop: -60 }, 20187 visible: { opacity: 1, marginTop: 0 }, 20188 distractionFreeHover: { 20189 opacity: 1, 20190 marginTop: 0, 20191 transition: { 20192 ...commonTransition, 20193 delay: 0.2, 20194 delayChildren: 0.2 20195 } 20196 }, 20197 distractionFreeHidden: { 20198 opacity: 0, 20199 marginTop: -60 20200 }, 20201 distractionFreeDisabled: { 20202 opacity: 0, 20203 marginTop: 0, 20204 transition: { 20205 ...commonTransition, 20206 delay: 0.8, 20207 delayChildren: 0.8 20208 } 20209 } 20210 }; 20211 function InterfaceSkeleton({ 20212 isDistractionFree, 20213 footer, 20214 header, 20215 editorNotices, 20216 sidebar, 20217 secondarySidebar, 20218 content, 20219 actions, 20220 labels, 20221 className 20222 }, ref) { 20223 const [secondarySidebarResizeListener, secondarySidebarSize] = (0, import_compose5.useResizeObserver)(); 20224 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<"); 20225 const disableMotion = (0, import_compose5.useReducedMotion)(); 20226 const defaultTransition = { 20227 type: "tween", 20228 duration: disableMotion ? 0 : ANIMATION_DURATION2, 20229 ease: [0.6, 0, 0.4, 1] 20230 }; 20231 useHTMLClass("interface-interface-skeleton__html-container"); 20232 const defaultLabels = { 20233 /* translators: accessibility text for the top bar landmark region. */ 20234 header: (0, import_i18n26._x)("Header", "header landmark area"), 20235 /* translators: accessibility text for the content landmark region. */ 20236 body: (0, import_i18n26.__)("Content"), 20237 /* translators: accessibility text for the secondary sidebar landmark region. */ 20238 secondarySidebar: (0, import_i18n26.__)("Block Library"), 20239 /* translators: accessibility text for the settings landmark region. */ 20240 sidebar: (0, import_i18n26._x)("Settings", "settings landmark area"), 20241 /* translators: accessibility text for the publish landmark region. */ 20242 actions: (0, import_i18n26.__)("Publish"), 20243 /* translators: accessibility text for the footer landmark region. */ 20244 footer: (0, import_i18n26.__)("Footer") 20245 }; 20246 const mergedLabels = { ...defaultLabels, ...labels }; 20247 return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)( 20248 "div", 20249 { 20250 ref, 20251 className: clsx_default( 20252 className, 20253 "interface-interface-skeleton", 20254 !!footer && "has-footer" 20255 ), 20256 children: [ 20257 /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "interface-interface-skeleton__editor", children: [ 20258 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components34.__unstableAnimatePresence, { initial: false, children: !!header && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 20259 navigable_region_default, 20260 { 20261 as: import_components34.__unstableMotion.div, 20262 className: "interface-interface-skeleton__header", 20263 ariaLabel: mergedLabels.header, 20264 initial: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden", 20265 whileHover: isDistractionFree && !isMobileViewport ? "distractionFreeHover" : "visible", 20266 animate: isDistractionFree && !isMobileViewport ? "distractionFreeDisabled" : "visible", 20267 exit: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden", 20268 variants: headerVariants, 20269 transition: defaultTransition, 20270 children: header 20271 } 20272 ) }), 20273 isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "interface-interface-skeleton__header", children: editorNotices }), 20274 /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "interface-interface-skeleton__body", children: [ 20275 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components34.__unstableAnimatePresence, { initial: false, children: !!secondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 20276 navigable_region_default, 20277 { 20278 className: "interface-interface-skeleton__secondary-sidebar", 20279 ariaLabel: mergedLabels.secondarySidebar, 20280 as: import_components34.__unstableMotion.div, 20281 initial: "closed", 20282 animate: "open", 20283 exit: "closed", 20284 variants: { 20285 open: { width: secondarySidebarSize.width }, 20286 closed: { width: 0 } 20287 }, 20288 transition: defaultTransition, 20289 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)( 20290 import_components34.__unstableMotion.div, 20291 { 20292 style: { 20293 position: "absolute", 20294 width: isMobileViewport ? "100vw" : "fit-content", 20295 height: "100%", 20296 left: 0 20297 }, 20298 variants: { 20299 open: { x: 0 }, 20300 closed: { x: "-100%" } 20301 }, 20302 transition: defaultTransition, 20303 children: [ 20304 secondarySidebarResizeListener, 20305 secondarySidebar 20306 ] 20307 } 20308 ) 20309 } 20310 ) }), 20311 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 20312 navigable_region_default, 20313 { 20314 className: "interface-interface-skeleton__content", 20315 ariaLabel: mergedLabels.body, 20316 children: content 20317 } 20318 ), 20319 !!sidebar && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 20320 navigable_region_default, 20321 { 20322 className: "interface-interface-skeleton__sidebar", 20323 ariaLabel: mergedLabels.sidebar, 20324 children: sidebar 20325 } 20326 ), 20327 !!actions && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 20328 navigable_region_default, 20329 { 20330 className: "interface-interface-skeleton__actions", 20331 ariaLabel: mergedLabels.actions, 20332 children: actions 20333 } 20334 ) 20335 ] }) 20336 ] }), 20337 !!footer && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 20338 navigable_region_default, 20339 { 20340 className: "interface-interface-skeleton__footer", 20341 ariaLabel: mergedLabels.footer, 20342 children: footer 20343 } 20344 ) 20345 ] 20346 } 20347 ); 20348 } 20349 var interface_skeleton_default = (0, import_element69.forwardRef)(InterfaceSkeleton); 20350 20351 // packages/media-editor/build-module/components/media-editor-canvas/index.mjs 20352 var import_element80 = __toESM(require_element(), 1); 20353 20354 // packages/media-editor/build-module/image-editor/core/constants.mjs 20355 var import_i18n27 = __toESM(require_i18n(), 1); 20356 var MIN_ZOOM = 1; 20357 var ABSOLUTE_MIN_ZOOM = 0.1; 20358 var MAX_ZOOM = 10; 20359 var MIN_CROP_PIXELS = 24; 20360 var DEFAULT_WHEEL_ZOOM_SPEED = 25e-4; 20361 var DEFAULT_KEYBOARD_STEP = 0.01; 20362 var KEYBOARD_SHIFT_STEP_MULTIPLIER = 10; 20363 var MAX_ROTATION_OFFSET = 45; 20364 var DEFAULT_CROP_RECT = { 20365 x: 0, 20366 y: 0, 20367 width: 1, 20368 height: 1 20369 }; 20370 var DEFAULT_FLIP = { 20371 horizontal: false, 20372 vertical: false 20373 }; 20374 var DEFAULT_PAN = { 20375 x: 0, 20376 y: 0 20377 }; 20378 var DEFAULT_STATE2 = { 20379 image: null, 20380 pan: { ...DEFAULT_PAN }, 20381 zoom: MIN_ZOOM, 20382 rotation: 0, 20383 basePan: { ...DEFAULT_PAN }, 20384 baseZoom: MIN_ZOOM, 20385 baseRotation: 0, 20386 flip: { ...DEFAULT_FLIP }, 20387 cropRect: { ...DEFAULT_CROP_RECT } 20388 }; 20389 var ORIGINAL_ASPECT_RATIO = -1; 20390 var DEFAULT_ASPECT_RATIOS = [ 20391 { label: (0, import_i18n27.__)("Free"), value: 0 }, 20392 { label: (0, import_i18n27.__)("Original"), value: ORIGINAL_ASPECT_RATIO }, 20393 { label: (0, import_i18n27.__)("Square (1:1)"), value: 1 }, 20394 { label: (0, import_i18n27.__)("Landscape (16:9)"), value: 16 / 9 }, 20395 { label: (0, import_i18n27.__)("Portrait (9:16)"), value: 9 / 16 }, 20396 { label: (0, import_i18n27.__)("Classic (4:3)"), value: 4 / 3 }, 20397 { label: (0, import_i18n27.__)("Classic portrait (3:4)"), value: 3 / 4 }, 20398 { label: (0, import_i18n27.__)("Photo (3:2)"), value: 3 / 2 }, 20399 { label: (0, import_i18n27.__)("Photo portrait (2:3)"), value: 2 / 3 } 20400 ]; 20401 20402 // node_modules/gl-matrix/esm/common.js 20403 var EPSILON = 1e-6; 20404 var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array; 20405 var RANDOM = Math.random; 20406 function round2(a2) { 20407 if (a2 >= 0) return Math.round(a2); 20408 return a2 % 0.5 === 0 ? Math.floor(a2) : Math.round(a2); 20409 } 20410 var degree = Math.PI / 180; 20411 var radian = 180 / Math.PI; 20412 20413 // node_modules/gl-matrix/esm/mat2d.js 20414 var mat2d_exports = {}; 20415 __export(mat2d_exports, { 20416 add: () => add, 20417 clone: () => clone, 20418 copy: () => copy, 20419 create: () => create, 20420 determinant: () => determinant, 20421 equals: () => equals, 20422 exactEquals: () => exactEquals, 20423 frob: () => frob, 20424 fromRotation: () => fromRotation, 20425 fromScaling: () => fromScaling, 20426 fromTranslation: () => fromTranslation, 20427 fromValues: () => fromValues, 20428 identity: () => identity, 20429 invert: () => invert, 20430 mul: () => mul, 20431 multiply: () => multiply, 20432 multiplyScalar: () => multiplyScalar, 20433 multiplyScalarAndAdd: () => multiplyScalarAndAdd, 20434 rotate: () => rotate, 20435 scale: () => scale, 20436 set: () => set3, 20437 str: () => str, 20438 sub: () => sub, 20439 subtract: () => subtract, 20440 translate: () => translate 20441 }); 20442 function create() { 20443 var out = new ARRAY_TYPE(6); 20444 if (ARRAY_TYPE != Float32Array) { 20445 out[1] = 0; 20446 out[2] = 0; 20447 out[4] = 0; 20448 out[5] = 0; 20449 } 20450 out[0] = 1; 20451 out[3] = 1; 20452 return out; 20453 } 20454 function clone(a2) { 20455 var out = new ARRAY_TYPE(6); 20456 out[0] = a2[0]; 20457 out[1] = a2[1]; 20458 out[2] = a2[2]; 20459 out[3] = a2[3]; 20460 out[4] = a2[4]; 20461 out[5] = a2[5]; 20462 return out; 20463 } 20464 function copy(out, a2) { 20465 out[0] = a2[0]; 20466 out[1] = a2[1]; 20467 out[2] = a2[2]; 20468 out[3] = a2[3]; 20469 out[4] = a2[4]; 20470 out[5] = a2[5]; 20471 return out; 20472 } 20473 function identity(out) { 20474 out[0] = 1; 20475 out[1] = 0; 20476 out[2] = 0; 20477 out[3] = 1; 20478 out[4] = 0; 20479 out[5] = 0; 20480 return out; 20481 } 20482 function fromValues(a2, b2, c2, d2, tx, ty) { 20483 var out = new ARRAY_TYPE(6); 20484 out[0] = a2; 20485 out[1] = b2; 20486 out[2] = c2; 20487 out[3] = d2; 20488 out[4] = tx; 20489 out[5] = ty; 20490 return out; 20491 } 20492 function set3(out, a2, b2, c2, d2, tx, ty) { 20493 out[0] = a2; 20494 out[1] = b2; 20495 out[2] = c2; 20496 out[3] = d2; 20497 out[4] = tx; 20498 out[5] = ty; 20499 return out; 20500 } 20501 function invert(out, a2) { 20502 var aa = a2[0], ab = a2[1], ac = a2[2], ad = a2[3]; 20503 var atx = a2[4], aty = a2[5]; 20504 var det = aa * ad - ab * ac; 20505 if (!det) { 20506 return null; 20507 } 20508 det = 1 / det; 20509 out[0] = ad * det; 20510 out[1] = -ab * det; 20511 out[2] = -ac * det; 20512 out[3] = aa * det; 20513 out[4] = (ac * aty - ad * atx) * det; 20514 out[5] = (ab * atx - aa * aty) * det; 20515 return out; 20516 } 20517 function determinant(a2) { 20518 return a2[0] * a2[3] - a2[1] * a2[2]; 20519 } 20520 function multiply(out, a2, b2) { 20521 var a0 = a2[0], a1 = a2[1], a22 = a2[2], a3 = a2[3], a4 = a2[4], a5 = a2[5]; 20522 var b0 = b2[0], b1 = b2[1], b22 = b2[2], b3 = b2[3], b4 = b2[4], b5 = b2[5]; 20523 out[0] = a0 * b0 + a22 * b1; 20524 out[1] = a1 * b0 + a3 * b1; 20525 out[2] = a0 * b22 + a22 * b3; 20526 out[3] = a1 * b22 + a3 * b3; 20527 out[4] = a0 * b4 + a22 * b5 + a4; 20528 out[5] = a1 * b4 + a3 * b5 + a5; 20529 return out; 20530 } 20531 function rotate(out, a2, rad) { 20532 var a0 = a2[0], a1 = a2[1], a22 = a2[2], a3 = a2[3], a4 = a2[4], a5 = a2[5]; 20533 var s2 = Math.sin(rad); 20534 var c2 = Math.cos(rad); 20535 out[0] = a0 * c2 + a22 * s2; 20536 out[1] = a1 * c2 + a3 * s2; 20537 out[2] = a0 * -s2 + a22 * c2; 20538 out[3] = a1 * -s2 + a3 * c2; 20539 out[4] = a4; 20540 out[5] = a5; 20541 return out; 20542 } 20543 function scale(out, a2, v2) { 20544 var a0 = a2[0], a1 = a2[1], a22 = a2[2], a3 = a2[3], a4 = a2[4], a5 = a2[5]; 20545 var v0 = v2[0], v1 = v2[1]; 20546 out[0] = a0 * v0; 20547 out[1] = a1 * v0; 20548 out[2] = a22 * v1; 20549 out[3] = a3 * v1; 20550 out[4] = a4; 20551 out[5] = a5; 20552 return out; 20553 } 20554 function translate(out, a2, v2) { 20555 var a0 = a2[0], a1 = a2[1], a22 = a2[2], a3 = a2[3], a4 = a2[4], a5 = a2[5]; 20556 var v0 = v2[0], v1 = v2[1]; 20557 out[0] = a0; 20558 out[1] = a1; 20559 out[2] = a22; 20560 out[3] = a3; 20561 out[4] = a0 * v0 + a22 * v1 + a4; 20562 out[5] = a1 * v0 + a3 * v1 + a5; 20563 return out; 20564 } 20565 function fromRotation(out, rad) { 20566 var s2 = Math.sin(rad), c2 = Math.cos(rad); 20567 out[0] = c2; 20568 out[1] = s2; 20569 out[2] = -s2; 20570 out[3] = c2; 20571 out[4] = 0; 20572 out[5] = 0; 20573 return out; 20574 } 20575 function fromScaling(out, v2) { 20576 out[0] = v2[0]; 20577 out[1] = 0; 20578 out[2] = 0; 20579 out[3] = v2[1]; 20580 out[4] = 0; 20581 out[5] = 0; 20582 return out; 20583 } 20584 function fromTranslation(out, v2) { 20585 out[0] = 1; 20586 out[1] = 0; 20587 out[2] = 0; 20588 out[3] = 1; 20589 out[4] = v2[0]; 20590 out[5] = v2[1]; 20591 return out; 20592 } 20593 function str(a2) { 20594 return "mat2d(" + a2[0] + ", " + a2[1] + ", " + a2[2] + ", " + a2[3] + ", " + a2[4] + ", " + a2[5] + ")"; 20595 } 20596 function frob(a2) { 20597 return Math.sqrt(a2[0] * a2[0] + a2[1] * a2[1] + a2[2] * a2[2] + a2[3] * a2[3] + a2[4] * a2[4] + a2[5] * a2[5] + 1); 20598 } 20599 function add(out, a2, b2) { 20600 out[0] = a2[0] + b2[0]; 20601 out[1] = a2[1] + b2[1]; 20602 out[2] = a2[2] + b2[2]; 20603 out[3] = a2[3] + b2[3]; 20604 out[4] = a2[4] + b2[4]; 20605 out[5] = a2[5] + b2[5]; 20606 return out; 20607 } 20608 function subtract(out, a2, b2) { 20609 out[0] = a2[0] - b2[0]; 20610 out[1] = a2[1] - b2[1]; 20611 out[2] = a2[2] - b2[2]; 20612 out[3] = a2[3] - b2[3]; 20613 out[4] = a2[4] - b2[4]; 20614 out[5] = a2[5] - b2[5]; 20615 return out; 20616 } 20617 function multiplyScalar(out, a2, b2) { 20618 out[0] = a2[0] * b2; 20619 out[1] = a2[1] * b2; 20620 out[2] = a2[2] * b2; 20621 out[3] = a2[3] * b2; 20622 out[4] = a2[4] * b2; 20623 out[5] = a2[5] * b2; 20624 return out; 20625 } 20626 function multiplyScalarAndAdd(out, a2, b2, scale3) { 20627 out[0] = a2[0] + b2[0] * scale3; 20628 out[1] = a2[1] + b2[1] * scale3; 20629 out[2] = a2[2] + b2[2] * scale3; 20630 out[3] = a2[3] + b2[3] * scale3; 20631 out[4] = a2[4] + b2[4] * scale3; 20632 out[5] = a2[5] + b2[5] * scale3; 20633 return out; 20634 } 20635 function exactEquals(a2, b2) { 20636 return a2[0] === b2[0] && a2[1] === b2[1] && a2[2] === b2[2] && a2[3] === b2[3] && a2[4] === b2[4] && a2[5] === b2[5]; 20637 } 20638 function equals(a2, b2) { 20639 var a0 = a2[0], a1 = a2[1], a22 = a2[2], a3 = a2[3], a4 = a2[4], a5 = a2[5]; 20640 var b0 = b2[0], b1 = b2[1], b22 = b2[2], b3 = b2[3], b4 = b2[4], b5 = b2[5]; 20641 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(a3 - b3) <= EPSILON * Math.max(1, Math.abs(a3), Math.abs(b3)) && 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)); 20642 } 20643 var mul = multiply; 20644 var sub = subtract; 20645 20646 // node_modules/gl-matrix/esm/vec2.js 20647 var vec2_exports = {}; 20648 __export(vec2_exports, { 20649 add: () => add2, 20650 angle: () => angle, 20651 ceil: () => ceil, 20652 clone: () => clone2, 20653 copy: () => copy2, 20654 create: () => create2, 20655 cross: () => cross, 20656 dist: () => dist, 20657 distance: () => distance, 20658 div: () => div, 20659 divide: () => divide, 20660 dot: () => dot, 20661 equals: () => equals2, 20662 exactEquals: () => exactEquals2, 20663 floor: () => floor2, 20664 forEach: () => forEach, 20665 fromValues: () => fromValues2, 20666 inverse: () => inverse, 20667 len: () => len, 20668 length: () => length, 20669 lerp: () => lerp, 20670 max: () => max2, 20671 min: () => min2, 20672 mul: () => mul2, 20673 multiply: () => multiply2, 20674 negate: () => negate, 20675 normalize: () => normalize, 20676 random: () => random, 20677 rotate: () => rotate2, 20678 round: () => round3, 20679 scale: () => scale2, 20680 scaleAndAdd: () => scaleAndAdd, 20681 set: () => set4, 20682 signedAngle: () => signedAngle, 20683 sqrDist: () => sqrDist, 20684 sqrLen: () => sqrLen, 20685 squaredDistance: () => squaredDistance, 20686 squaredLength: () => squaredLength, 20687 str: () => str2, 20688 sub: () => sub2, 20689 subtract: () => subtract2, 20690 transformMat2: () => transformMat2, 20691 transformMat2d: () => transformMat2d, 20692 transformMat3: () => transformMat3, 20693 transformMat4: () => transformMat4, 20694 zero: () => zero 20695 }); 20696 function create2() { 20697 var out = new ARRAY_TYPE(2); 20698 if (ARRAY_TYPE != Float32Array) { 20699 out[0] = 0; 20700 out[1] = 0; 20701 } 20702 return out; 20703 } 20704 function clone2(a2) { 20705 var out = new ARRAY_TYPE(2); 20706 out[0] = a2[0]; 20707 out[1] = a2[1]; 20708 return out; 20709 } 20710 function fromValues2(x2, y2) { 20711 var out = new ARRAY_TYPE(2); 20712 out[0] = x2; 20713 out[1] = y2; 20714 return out; 20715 } 20716 function copy2(out, a2) { 20717 out[0] = a2[0]; 20718 out[1] = a2[1]; 20719 return out; 20720 } 20721 function set4(out, x2, y2) { 20722 out[0] = x2; 20723 out[1] = y2; 20724 return out; 20725 } 20726 function add2(out, a2, b2) { 20727 out[0] = a2[0] + b2[0]; 20728 out[1] = a2[1] + b2[1]; 20729 return out; 20730 } 20731 function subtract2(out, a2, b2) { 20732 out[0] = a2[0] - b2[0]; 20733 out[1] = a2[1] - b2[1]; 20734 return out; 20735 } 20736 function multiply2(out, a2, b2) { 20737 out[0] = a2[0] * b2[0]; 20738 out[1] = a2[1] * b2[1]; 20739 return out; 20740 } 20741 function divide(out, a2, b2) { 20742 out[0] = a2[0] / b2[0]; 20743 out[1] = a2[1] / b2[1]; 20744 return out; 20745 } 20746 function ceil(out, a2) { 20747 out[0] = Math.ceil(a2[0]); 20748 out[1] = Math.ceil(a2[1]); 20749 return out; 20750 } 20751 function floor2(out, a2) { 20752 out[0] = Math.floor(a2[0]); 20753 out[1] = Math.floor(a2[1]); 20754 return out; 20755 } 20756 function min2(out, a2, b2) { 20757 out[0] = Math.min(a2[0], b2[0]); 20758 out[1] = Math.min(a2[1], b2[1]); 20759 return out; 20760 } 20761 function max2(out, a2, b2) { 20762 out[0] = Math.max(a2[0], b2[0]); 20763 out[1] = Math.max(a2[1], b2[1]); 20764 return out; 20765 } 20766 function round3(out, a2) { 20767 out[0] = round2(a2[0]); 20768 out[1] = round2(a2[1]); 20769 return out; 20770 } 20771 function scale2(out, a2, b2) { 20772 out[0] = a2[0] * b2; 20773 out[1] = a2[1] * b2; 20774 return out; 20775 } 20776 function scaleAndAdd(out, a2, b2, scale3) { 20777 out[0] = a2[0] + b2[0] * scale3; 20778 out[1] = a2[1] + b2[1] * scale3; 20779 return out; 20780 } 20781 function distance(a2, b2) { 20782 var x2 = b2[0] - a2[0], y2 = b2[1] - a2[1]; 20783 return Math.sqrt(x2 * x2 + y2 * y2); 20784 } 20785 function squaredDistance(a2, b2) { 20786 var x2 = b2[0] - a2[0], y2 = b2[1] - a2[1]; 20787 return x2 * x2 + y2 * y2; 20788 } 20789 function length(a2) { 20790 var x2 = a2[0], y2 = a2[1]; 20791 return Math.sqrt(x2 * x2 + y2 * y2); 20792 } 20793 function squaredLength(a2) { 20794 var x2 = a2[0], y2 = a2[1]; 20795 return x2 * x2 + y2 * y2; 20796 } 20797 function negate(out, a2) { 20798 out[0] = -a2[0]; 20799 out[1] = -a2[1]; 20800 return out; 20801 } 20802 function inverse(out, a2) { 20803 out[0] = 1 / a2[0]; 20804 out[1] = 1 / a2[1]; 20805 return out; 20806 } 20807 function normalize(out, a2) { 20808 var x2 = a2[0], y2 = a2[1]; 20809 var len2 = x2 * x2 + y2 * y2; 20810 if (len2 > 0) { 20811 len2 = 1 / Math.sqrt(len2); 20812 } 20813 out[0] = a2[0] * len2; 20814 out[1] = a2[1] * len2; 20815 return out; 20816 } 20817 function dot(a2, b2) { 20818 return a2[0] * b2[0] + a2[1] * b2[1]; 20819 } 20820 function cross(out, a2, b2) { 20821 var z = a2[0] * b2[1] - a2[1] * b2[0]; 20822 out[0] = out[1] = 0; 20823 out[2] = z; 20824 return out; 20825 } 20826 function lerp(out, a2, b2, t2) { 20827 var ax = a2[0], ay = a2[1]; 20828 out[0] = ax + t2 * (b2[0] - ax); 20829 out[1] = ay + t2 * (b2[1] - ay); 20830 return out; 20831 } 20832 function random(out, scale3) { 20833 scale3 = scale3 === void 0 ? 1 : scale3; 20834 var r3 = RANDOM() * 2 * Math.PI; 20835 out[0] = Math.cos(r3) * scale3; 20836 out[1] = Math.sin(r3) * scale3; 20837 return out; 20838 } 20839 function transformMat2(out, a2, m2) { 20840 var x2 = a2[0], y2 = a2[1]; 20841 out[0] = m2[0] * x2 + m2[2] * y2; 20842 out[1] = m2[1] * x2 + m2[3] * y2; 20843 return out; 20844 } 20845 function transformMat2d(out, a2, m2) { 20846 var x2 = a2[0], y2 = a2[1]; 20847 out[0] = m2[0] * x2 + m2[2] * y2 + m2[4]; 20848 out[1] = m2[1] * x2 + m2[3] * y2 + m2[5]; 20849 return out; 20850 } 20851 function transformMat3(out, a2, m2) { 20852 var x2 = a2[0], y2 = a2[1]; 20853 out[0] = m2[0] * x2 + m2[3] * y2 + m2[6]; 20854 out[1] = m2[1] * x2 + m2[4] * y2 + m2[7]; 20855 return out; 20856 } 20857 function transformMat4(out, a2, m2) { 20858 var x2 = a2[0]; 20859 var y2 = a2[1]; 20860 out[0] = m2[0] * x2 + m2[4] * y2 + m2[12]; 20861 out[1] = m2[1] * x2 + m2[5] * y2 + m2[13]; 20862 return out; 20863 } 20864 function rotate2(out, a2, b2, rad) { 20865 var p0 = a2[0] - b2[0], p1 = a2[1] - b2[1], sinC = Math.sin(rad), cosC = Math.cos(rad); 20866 out[0] = p0 * cosC - p1 * sinC + b2[0]; 20867 out[1] = p0 * sinC + p1 * cosC + b2[1]; 20868 return out; 20869 } 20870 function angle(a2, b2) { 20871 var ax = a2[0], ay = a2[1], bx = b2[0], by = b2[1]; 20872 return Math.abs(Math.atan2(ay * bx - ax * by, ax * bx + ay * by)); 20873 } 20874 function signedAngle(a2, b2) { 20875 var ax = a2[0], ay = a2[1], bx = b2[0], by = b2[1]; 20876 return Math.atan2(ax * by - ay * bx, ax * bx + ay * by); 20877 } 20878 function zero(out) { 20879 out[0] = 0; 20880 out[1] = 0; 20881 return out; 20882 } 20883 function str2(a2) { 20884 return "vec2(" + a2[0] + ", " + a2[1] + ")"; 20885 } 20886 function exactEquals2(a2, b2) { 20887 return a2[0] === b2[0] && a2[1] === b2[1]; 20888 } 20889 function equals2(a2, b2) { 20890 var a0 = a2[0], a1 = a2[1]; 20891 var b0 = b2[0], b1 = b2[1]; 20892 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)); 20893 } 20894 var len = length; 20895 var sub2 = subtract2; 20896 var mul2 = multiply2; 20897 var div = divide; 20898 var dist = distance; 20899 var sqrDist = squaredDistance; 20900 var sqrLen = squaredLength; 20901 var forEach = (function() { 20902 var vec = create2(); 20903 return function(a2, stride, offset4, count, fn, arg) { 20904 var i2, l2; 20905 if (!stride) { 20906 stride = 2; 20907 } 20908 if (!offset4) { 20909 offset4 = 0; 20910 } 20911 if (count) { 20912 l2 = Math.min(count * stride + offset4, a2.length); 20913 } else { 20914 l2 = a2.length; 20915 } 20916 for (i2 = offset4; i2 < l2; i2 += stride) { 20917 vec[0] = a2[i2]; 20918 vec[1] = a2[i2 + 1]; 20919 fn(vec, vec, arg); 20920 a2[i2] = vec[0]; 20921 a2[i2 + 1] = vec[1]; 20922 } 20923 return a2; 20924 }; 20925 })(); 20926 20927 // packages/media-editor/build-module/image-editor/core/math/rotation.mjs 20928 function normalizeRotation(degrees) { 20929 if (degrees >= 0) { 20930 return degrees % 360; 20931 } 20932 return (360 + degrees % 360) % 360; 20933 } 20934 function degreesToRadians(degrees) { 20935 return degrees * Math.PI / 180; 20936 } 20937 20938 // packages/media-editor/build-module/image-editor/core/math/sanitize.mjs 20939 var MAX_SAFE_MAGNITUDE = 1e6; 20940 function safeBoundedNumber(value, fallback) { 20941 if (!Number.isFinite(value)) { 20942 return fallback; 20943 } 20944 if (Math.abs(value) > MAX_SAFE_MAGNITUDE) { 20945 return fallback; 20946 } 20947 return value; 20948 } 20949 function isSafeNumber(value) { 20950 return Number.isFinite(value) && Math.abs(value) <= MAX_SAFE_MAGNITUDE; 20951 } 20952 function isValidSize(size4) { 20953 return Number.isFinite(size4.width) && Number.isFinite(size4.height) && size4.width >= Number.EPSILON && size4.height >= Number.EPSILON && size4.width <= MAX_SAFE_MAGNITUDE && size4.height <= MAX_SAFE_MAGNITUDE; 20954 } 20955 function sanitizeRect(rect) { 20956 const x2 = safeBoundedNumber(rect.x, 0); 20957 const y2 = safeBoundedNumber(rect.y, 0); 20958 const width = safeBoundedNumber(rect.width, 0); 20959 const height = safeBoundedNumber(rect.height, 0); 20960 if (x2 === rect.x && y2 === rect.y && width === rect.width && height === rect.height) { 20961 return rect; 20962 } 20963 return { x: x2, y: y2, width, height }; 20964 } 20965 function sanitizeCropperState(state) { 20966 const panX = safeBoundedNumber(state.pan.x, 0); 20967 const panY = safeBoundedNumber(state.pan.y, 0); 20968 const basePanX = safeBoundedNumber(state.basePan.x, 0); 20969 const basePanY = safeBoundedNumber(state.basePan.y, 0); 20970 const rotation = safeBoundedNumber(state.rotation, 0); 20971 const baseRotation = safeBoundedNumber(state.baseRotation, 0); 20972 const rawZoom = safeBoundedNumber(state.zoom, 1); 20973 const zoom = rawZoom >= Number.EPSILON ? rawZoom : 1; 20974 const rawBaseZoom = safeBoundedNumber(state.baseZoom, 1); 20975 const baseZoom = rawBaseZoom >= Number.EPSILON ? rawBaseZoom : 1; 20976 const cropRect = sanitizeRect(state.cropRect); 20977 const panUnchanged = panX === state.pan.x && panY === state.pan.y; 20978 const basePanUnchanged = basePanX === state.basePan.x && basePanY === state.basePan.y; 20979 if (panUnchanged && basePanUnchanged && zoom === state.zoom && baseZoom === state.baseZoom && rotation === state.rotation && baseRotation === state.baseRotation && cropRect === state.cropRect) { 20980 return state; 20981 } 20982 return { 20983 ...state, 20984 pan: panUnchanged ? state.pan : { x: panX, y: panY }, 20985 zoom, 20986 rotation, 20987 basePan: basePanUnchanged ? state.basePan : { x: basePanX, y: basePanY }, 20988 baseZoom, 20989 baseRotation, 20990 cropRect 20991 }; 20992 } 20993 20994 // packages/media-editor/build-module/image-editor/core/camera.mjs 20995 var _scratchMat = mat2d_exports.create(); 20996 var _scratchVec = vec2_exports.create(); 20997 function getRotatedBBox(width, height, rotation) { 20998 if (!isSafeNumber(width) || !isSafeNumber(height) || !isSafeNumber(rotation) || width <= 0 || height <= 0) { 20999 return { width: 0, height: 0 }; 21000 } 21001 const rad = degreesToRadians(rotation); 21002 const cosR = Math.abs(Math.cos(rad)); 21003 const sinR = Math.abs(Math.sin(rad)); 21004 return { 21005 width: cosR * width + sinR * height, 21006 height: sinR * width + cosR * height 21007 }; 21008 } 21009 function getImageFit(containerSize, imageSize, rotation) { 21010 if (!isValidSize(containerSize) || !isValidSize(imageSize)) { 21011 return { 21012 elementSize: { width: 0, height: 0 }, 21013 visualSize: { width: 0, height: 0 } 21014 }; 21015 } 21016 const safeRotation = safeBoundedNumber(rotation, 0); 21017 const snapRotation = Math.round(safeRotation / 90) * 90; 21018 const naturalBBox = getRotatedBBox( 21019 imageSize.width, 21020 imageSize.height, 21021 snapRotation 21022 ); 21023 if (naturalBBox.width === 0 || naturalBBox.height === 0) { 21024 return { 21025 elementSize: { width: 0, height: 0 }, 21026 visualSize: { width: 0, height: 0 } 21027 }; 21028 } 21029 const fitScale = Math.min( 21030 containerSize.width / naturalBBox.width, 21031 containerSize.height / naturalBBox.height 21032 ); 21033 const renderedW = imageSize.width * fitScale; 21034 const renderedH = imageSize.height * fitScale; 21035 const visualSize = getRotatedBBox(renderedW, renderedH, snapRotation); 21036 return { 21037 elementSize: { width: renderedW, height: renderedH }, 21038 visualSize 21039 }; 21040 } 21041 function createCamera(state, containerSize, imageSize) { 21042 const m2 = mat2d_exports.create(); 21043 if (!isValidSize(containerSize) || !isValidSize(imageSize)) { 21044 return m2; 21045 } 21046 const safeState = sanitizeCropperState(state); 21047 const snapRotation = Math.round(safeState.rotation / 90) * 90; 21048 const naturalBBox = getRotatedBBox( 21049 imageSize.width, 21050 imageSize.height, 21051 snapRotation 21052 ); 21053 if (naturalBBox.width === 0 || naturalBBox.height === 0) { 21054 return m2; 21055 } 21056 const fitScale = Math.min( 21057 containerSize.width / naturalBBox.width, 21058 containerSize.height / naturalBBox.height 21059 ); 21060 const renderedW = imageSize.width * fitScale; 21061 const renderedH = imageSize.height * fitScale; 21062 const { width: visualW, height: visualH } = getRotatedBBox( 21063 renderedW, 21064 renderedH, 21065 snapRotation 21066 ); 21067 mat2d_exports.translate(m2, m2, [ 21068 containerSize.width / 2, 21069 containerSize.height / 2 21070 ]); 21071 mat2d_exports.translate(m2, m2, [ 21072 safeState.pan.x * visualW, 21073 safeState.pan.y * visualH 21074 ]); 21075 mat2d_exports.scale(m2, m2, [ 21076 safeState.flip.horizontal ? -1 : 1, 21077 safeState.flip.vertical ? -1 : 1 21078 ]); 21079 mat2d_exports.rotate(m2, m2, degreesToRadians(safeState.rotation)); 21080 mat2d_exports.scale(m2, m2, [safeState.zoom, safeState.zoom]); 21081 mat2d_exports.translate(m2, m2, [-renderedW / 2, -renderedH / 2]); 21082 mat2d_exports.scale(m2, m2, [renderedW, renderedH]); 21083 return m2; 21084 } 21085 function aabb(camera, corners) { 21086 const screenCorners = corners.map((c2) => { 21087 const out = vec2_exports.create(); 21088 vec2_exports.transformMat2d(out, c2, camera); 21089 return out; 21090 }); 21091 let minX = screenCorners[0][0]; 21092 let maxX = screenCorners[0][0]; 21093 let minY = screenCorners[0][1]; 21094 let maxY = screenCorners[0][1]; 21095 for (let i2 = 1; i2 < screenCorners.length; i2++) { 21096 const s2 = screenCorners[i2]; 21097 if (s2[0] < minX) { 21098 minX = s2[0]; 21099 } 21100 if (s2[0] > maxX) { 21101 maxX = s2[0]; 21102 } 21103 if (s2[1] < minY) { 21104 minY = s2[1]; 21105 } 21106 if (s2[1] > maxY) { 21107 maxY = s2[1]; 21108 } 21109 } 21110 return { left: minX, top: minY, width: maxX - minX, height: maxY - minY }; 21111 } 21112 function getVisibleBounds(camera) { 21113 return aabb(camera, [ 21114 [0, 0], 21115 [1, 0], 21116 [1, 1], 21117 [0, 1] 21118 ]); 21119 } 21120 function createExportCamera(state, imageSize, outputSize) { 21121 const m2 = mat2d_exports.create(); 21122 if (!isValidSize(imageSize) || !isValidSize(outputSize)) { 21123 return m2; 21124 } 21125 const { rotation, flip: flip4, cropRect, zoom, pan } = sanitizeCropperState(state); 21126 const snapRotation = Math.round(rotation / 90) * 90; 21127 const { width: rotW, height: rotH } = getRotatedBBox( 21128 imageSize.width, 21129 imageSize.height, 21130 snapRotation 21131 ); 21132 const naturalCropW = cropRect.width * rotW; 21133 const naturalCropH = cropRect.height * rotH; 21134 const outputScaleX = naturalCropW > 0 ? outputSize.width / naturalCropW : 1; 21135 const outputScaleY = naturalCropH > 0 ? outputSize.height / naturalCropH : 1; 21136 const cropOffsetX = cropRect.x * rotW + outputSize.width / 2 / outputScaleX; 21137 const cropOffsetY = cropRect.y * rotH + outputSize.height / 2 / outputScaleY; 21138 const visualCenterX = rotW / 2 + pan.x * rotW; 21139 const visualCenterY = rotH / 2 + pan.y * rotH; 21140 mat2d_exports.scale(m2, m2, [outputScaleX, outputScaleY]); 21141 mat2d_exports.translate(m2, m2, [ 21142 visualCenterX - cropOffsetX + outputSize.width / 2 / outputScaleX, 21143 visualCenterY - cropOffsetY + outputSize.height / 2 / outputScaleY 21144 ]); 21145 mat2d_exports.scale(m2, m2, [flip4.horizontal ? -1 : 1, flip4.vertical ? -1 : 1]); 21146 mat2d_exports.rotate(m2, m2, degreesToRadians(rotation)); 21147 mat2d_exports.scale(m2, m2, [zoom, zoom]); 21148 mat2d_exports.translate(m2, m2, [-imageSize.width / 2, -imageSize.height / 2]); 21149 return m2; 21150 } 21151 21152 // packages/media-editor/build-module/image-editor/core/export/canvas-renderer.mjs 21153 var DEFAULT_QUALITY = 0.92; 21154 function loadImage(src) { 21155 return new Promise((resolve, reject) => { 21156 const image = new Image(); 21157 image.addEventListener("load", () => resolve(image)); 21158 image.addEventListener("error", (error2) => reject(error2)); 21159 image.crossOrigin = "anonymous"; 21160 image.src = src; 21161 }); 21162 } 21163 function renderToCanvas(image, state) { 21164 const { naturalWidth, naturalHeight } = image; 21165 const { rotation, cropRect } = state; 21166 const imageSize = { width: naturalWidth, height: naturalHeight }; 21167 const snapRotation = Math.round(rotation / 90) * 90; 21168 const rotBBox = getRotatedBBox(naturalWidth, naturalHeight, snapRotation); 21169 const outW = Math.round(cropRect.width * rotBBox.width); 21170 const outH = Math.round(cropRect.height * rotBBox.height); 21171 const canvas = document.createElement("canvas"); 21172 canvas.width = outW; 21173 canvas.height = outH; 21174 const ctx = canvas.getContext("2d"); 21175 if (!ctx) { 21176 throw new Error( 21177 "Could not obtain a 2D context for the export canvas." 21178 ); 21179 } 21180 const camera = createExportCamera(state, imageSize, { 21181 width: outW, 21182 height: outH 21183 }); 21184 ctx.setTransform( 21185 camera[0], 21186 camera[1], 21187 camera[2], 21188 camera[3], 21189 camera[4], 21190 camera[5] 21191 ); 21192 ctx.drawImage(image, 0, 0); 21193 return canvas; 21194 } 21195 function canvasToBlob(canvas, mimeType = "image/png", quality = DEFAULT_QUALITY) { 21196 return new Promise((resolve, reject) => { 21197 canvas.toBlob( 21198 (blob) => { 21199 if (blob) { 21200 resolve(blob); 21201 } else { 21202 reject(new Error("Canvas toBlob returned null.")); 21203 } 21204 }, 21205 mimeType, 21206 quality 21207 ); 21208 }); 21209 } 21210 async function exportCroppedImage(src, state, mimeType = "image/png", quality = DEFAULT_QUALITY) { 21211 const image = await loadImage(src); 21212 const canvas = renderToCanvas(image, state); 21213 return canvasToBlob(canvas, mimeType, quality); 21214 } 21215 21216 // packages/media-editor/build-module/image-editor/core/containment.mjs 21217 var EPSILON2 = 1e-9; 21218 function getVisualDimensions(rotation, imageAspectRatio) { 21219 const rad = degreesToRadians(rotation); 21220 const absC = Math.abs(Math.cos(rad)); 21221 const absS = Math.abs(Math.sin(rad)); 21222 const bbox = getRotatedBBox(imageAspectRatio, 1, rotation); 21223 return { 21224 visualW: bbox.width, 21225 visualH: bbox.height, 21226 absC, 21227 absS 21228 }; 21229 } 21230 function getMinZoomForCover(rotation, imageAspectRatio, cropRect) { 21231 const aspectRatio = Math.max(imageAspectRatio, Number.EPSILON); 21232 const snapRotation = Math.round(rotation / 90) * 90; 21233 const { visualW: snapVisualW, visualH: snapVisualH } = getVisualDimensions( 21234 snapRotation, 21235 aspectRatio 21236 ); 21237 const { absC, absS } = getVisualDimensions(rotation, aspectRatio); 21238 const cropHalfW = cropRect.width * snapVisualW / 2; 21239 const cropHalfH = cropRect.height * snapVisualH / 2; 21240 const spanAlpha = cropHalfW * absC + cropHalfH * absS; 21241 const spanBeta = cropHalfW * absS + cropHalfH * absC; 21242 const zoomFromAlpha = 2 * spanAlpha / aspectRatio; 21243 const zoomFromBeta = 2 * spanBeta; 21244 return Math.max(zoomFromAlpha, zoomFromBeta); 21245 } 21246 function getMinZoom(state) { 21247 if (!state.image) { 21248 return MIN_ZOOM; 21249 } 21250 const imageSize = { 21251 width: state.image.naturalWidth, 21252 height: state.image.naturalHeight 21253 }; 21254 if (!isValidSize(imageSize)) { 21255 return MIN_ZOOM; 21256 } 21257 const safeState = sanitizeCropperState(state); 21258 const aspectRatio = imageSize.width / imageSize.height; 21259 return Math.max( 21260 ABSOLUTE_MIN_ZOOM, 21261 getMinZoomForCover( 21262 safeState.rotation, 21263 aspectRatio, 21264 safeState.cropRect 21265 ) 21266 ); 21267 } 21268 function getImageCropBounds(state, elementSize, visualSize) { 21269 if (!isValidSize(elementSize) || !isValidSize(visualSize)) { 21270 return { minX: 0, minY: 0, maxX: 1, maxY: 1 }; 21271 } 21272 const safeState = sanitizeCropperState(state); 21273 const tx = safeState.pan.x * visualSize.width; 21274 const ty = safeState.pan.y * visualSize.height; 21275 const rad = degreesToRadians(safeState.rotation); 21276 const cos = Math.cos(rad); 21277 const sin = Math.sin(rad); 21278 const sx = safeState.flip.horizontal ? -1 : 1; 21279 const sy = safeState.flip.vertical ? -1 : 1; 21280 const z = safeState.zoom; 21281 const ma = sx * cos * z; 21282 const mb = sy * sin * z; 21283 const mc = -sx * sin * z; 21284 const md = sy * cos * z; 21285 const hw = elementSize.width / 2; 21286 const hh = elementSize.height / 2; 21287 const corners = [ 21288 [-hw, -hh], 21289 [hw, -hh], 21290 [hw, hh], 21291 [-hw, hh] 21292 ]; 21293 let imgMinX = Infinity; 21294 let imgMaxX = -Infinity; 21295 let imgMinY = Infinity; 21296 let imgMaxY = -Infinity; 21297 for (const [cx, cy] of corners) { 21298 const screenX = ma * cx + mc * cy + tx; 21299 const screenY = mb * cx + md * cy + ty; 21300 const nx = screenX / visualSize.width + 0.5; 21301 const ny = screenY / visualSize.height + 0.5; 21302 imgMinX = Math.min(imgMinX, nx); 21303 imgMaxX = Math.max(imgMaxX, nx); 21304 imgMinY = Math.min(imgMinY, ny); 21305 imgMaxY = Math.max(imgMaxY, ny); 21306 } 21307 return { 21308 minX: imgMinX, 21309 minY: imgMinY, 21310 maxX: imgMaxX, 21311 maxY: imgMaxY 21312 }; 21313 } 21314 function restrictCropRect(cropRect, zoom, rotation, imageAspectRatio) { 21315 const safeRect = sanitizeRect(cropRect); 21316 const zoomCandidate = safeBoundedNumber(zoom, 1); 21317 const safeZoom = zoomCandidate >= Number.EPSILON ? zoomCandidate : 1; 21318 const safeRotation = safeBoundedNumber(rotation, 0); 21319 const safeAspect = safeBoundedNumber(imageAspectRatio, 1); 21320 const aspectRatio = Math.max(safeAspect, Number.EPSILON); 21321 const snapRotation = Math.round(safeRotation / 90) * 90; 21322 const { visualW, visualH } = getVisualDimensions( 21323 snapRotation, 21324 aspectRatio 21325 ); 21326 const { absC, absS } = getVisualDimensions(safeRotation, aspectRatio); 21327 const W = safeRect.width; 21328 const H2 = safeRect.height; 21329 const cropWPx = W * visualW; 21330 const cropHPx = H2 * visualH; 21331 const spanAlpha = cropWPx * absC + cropHPx * absS; 21332 const spanBeta = cropWPx * absS + cropHPx * absC; 21333 const limitAlpha = aspectRatio * safeZoom; 21334 const limitBeta = safeZoom; 21335 let t2 = 1; 21336 if (spanAlpha > 0) { 21337 t2 = Math.min(t2, limitAlpha / spanAlpha); 21338 } 21339 if (spanBeta > 0) { 21340 t2 = Math.min(t2, limitBeta / spanBeta); 21341 } 21342 if (t2 >= 1 - EPSILON2) { 21343 return safeRect; 21344 } 21345 const newW = W * t2; 21346 const newH = H2 * t2; 21347 const centerX = safeRect.x + W / 2; 21348 const centerY = safeRect.y + H2 / 2; 21349 let newX = centerX - newW / 2; 21350 let newY = centerY - newH / 2; 21351 newX = Math.max(0, Math.min(newX, 1 - newW)); 21352 newY = Math.max(0, Math.min(newY, 1 - newH)); 21353 return { x: newX, y: newY, width: newW, height: newH }; 21354 } 21355 var CANONICAL_CONTAINER = { width: 1e3, height: 1e3 }; 21356 var _scratchMat2 = mat2d_exports.create(); 21357 var _scratchVec2 = vec2_exports.create(); 21358 function restrictPanZoom(state, imageSize, cropRect) { 21359 const safeState = sanitizeCropperState(state); 21360 const safeCropRect = sanitizeRect(cropRect); 21361 const aspectRatio = isValidSize(imageSize) ? imageSize.width / imageSize.height : 1; 21362 const minZoom = Math.max( 21363 ABSOLUTE_MIN_ZOOM, 21364 getMinZoomForCover(safeState.rotation, aspectRatio, safeCropRect) 21365 ); 21366 const zoom = Math.min(MAX_ZOOM, Math.max(safeState.zoom, minZoom)); 21367 const candidateState = { ...safeState, zoom }; 21368 const camera = createCamera( 21369 candidateState, 21370 CANONICAL_CONTAINER, 21371 imageSize 21372 ); 21373 const snapRotation = Math.round(safeState.rotation / 90) * 90; 21374 const baseCamera = createCamera( 21375 { 21376 ...candidateState, 21377 pan: { x: 0, y: 0 }, 21378 zoom: 1, 21379 rotation: snapRotation 21380 }, 21381 CANONICAL_CONTAINER, 21382 imageSize 21383 ); 21384 const visibleBounds = getVisibleBounds(baseCamera); 21385 const stencilCorners = [ 21386 [ 21387 visibleBounds.left + safeCropRect.x * visibleBounds.width, 21388 visibleBounds.top + safeCropRect.y * visibleBounds.height 21389 ], 21390 [ 21391 visibleBounds.left + (safeCropRect.x + safeCropRect.width) * visibleBounds.width, 21392 visibleBounds.top + safeCropRect.y * visibleBounds.height 21393 ], 21394 [ 21395 visibleBounds.left + (safeCropRect.x + safeCropRect.width) * visibleBounds.width, 21396 visibleBounds.top + (safeCropRect.y + safeCropRect.height) * visibleBounds.height 21397 ], 21398 [ 21399 visibleBounds.left + safeCropRect.x * visibleBounds.width, 21400 visibleBounds.top + (safeCropRect.y + safeCropRect.height) * visibleBounds.height 21401 ] 21402 ]; 21403 mat2d_exports.invert(_scratchMat2, camera); 21404 let minWx = Infinity; 21405 let maxWx = -Infinity; 21406 let minWy = Infinity; 21407 let maxWy = -Infinity; 21408 for (const corner of stencilCorners) { 21409 vec2_exports.transformMat2d(_scratchVec2, corner, _scratchMat2); 21410 const w2 = _scratchVec2; 21411 if (w2[0] < minWx) { 21412 minWx = w2[0]; 21413 } 21414 if (w2[0] > maxWx) { 21415 maxWx = w2[0]; 21416 } 21417 if (w2[1] < minWy) { 21418 minWy = w2[1]; 21419 } 21420 if (w2[1] > maxWy) { 21421 maxWy = w2[1]; 21422 } 21423 } 21424 if (minWx >= -EPSILON2 && maxWx <= 1 + EPSILON2 && minWy >= -EPSILON2 && maxWy <= 1 + EPSILON2) { 21425 return { pan: safeState.pan, zoom }; 21426 } 21427 let dwx = 0; 21428 let dwy = 0; 21429 if (minWx < 0 && maxWx <= 1 + EPSILON2) { 21430 dwx = -minWx; 21431 } else if (maxWx > 1 && minWx >= -EPSILON2) { 21432 dwx = 1 - maxWx; 21433 } else if (minWx < 0 && maxWx > 1) { 21434 dwx = (1 - maxWx - minWx) / 2; 21435 } 21436 if (minWy < 0 && maxWy <= 1 + EPSILON2) { 21437 dwy = -minWy; 21438 } else if (maxWy > 1 && minWy >= -EPSILON2) { 21439 dwy = 1 - maxWy; 21440 } else if (minWy < 0 && maxWy > 1) { 21441 dwy = (1 - maxWy - minWy) / 2; 21442 } 21443 const dsx = camera[0] * dwx + camera[2] * dwy; 21444 const dsy = camera[1] * dwx + camera[3] * dwy; 21445 const newPanX = safeState.pan.x - (visibleBounds.width > 0 ? dsx / visibleBounds.width : 0); 21446 const newPanY = safeState.pan.y - (visibleBounds.height > 0 ? dsy / visibleBounds.height : 0); 21447 return { 21448 pan: { x: newPanX, y: newPanY }, 21449 zoom 21450 }; 21451 } 21452 21453 // packages/media-editor/build-module/image-editor/core/state.mjs 21454 var STATE_EPSILON = 1e-6; 21455 function nearlyEqual(a2, b2) { 21456 return Math.abs(a2 - b2) < STATE_EPSILON; 21457 } 21458 function areCropperStatesEqual(a2, b2) { 21459 const aImage = a2.image; 21460 const bImage = b2.image; 21461 return aImage?.src === bImage?.src && aImage?.naturalWidth === bImage?.naturalWidth && aImage?.naturalHeight === bImage?.naturalHeight && nearlyEqual(a2.pan.x, b2.pan.x) && nearlyEqual(a2.pan.y, b2.pan.y) && nearlyEqual(a2.zoom, b2.zoom) && nearlyEqual(a2.rotation, b2.rotation) && a2.flip.horizontal === b2.flip.horizontal && a2.flip.vertical === b2.flip.vertical && nearlyEqual(a2.cropRect.x, b2.cropRect.x) && nearlyEqual(a2.cropRect.y, b2.cropRect.y) && nearlyEqual(a2.cropRect.width, b2.cropRect.width) && nearlyEqual(a2.cropRect.height, b2.cropRect.height); 21462 } 21463 function clampRequestedZoom(state, zoom) { 21464 if (state.image) { 21465 return Math.min(MAX_ZOOM, Math.max(ABSOLUTE_MIN_ZOOM, zoom)); 21466 } 21467 return Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, zoom)); 21468 } 21469 function operationToAction(state, op) { 21470 switch (op.type) { 21471 case "crop": 21472 return { type: "SET_CROP_RECT", payload: { ...op.rect } }; 21473 case "rotate": { 21474 const singleFlip = state.flip.horizontal !== state.flip.vertical; 21475 const fieldDelta = singleFlip ? -op.degrees : op.degrees; 21476 return { 21477 type: "SET_ROTATION", 21478 payload: normalizeRotation(state.rotation + fieldDelta) 21479 }; 21480 } 21481 case "flip": 21482 return { 21483 type: "SET_FLIP", 21484 payload: { 21485 ...state.flip, 21486 [op.direction]: !state.flip[op.direction] 21487 } 21488 }; 21489 case "zoom": 21490 return { type: "SET_ZOOM", payload: op.factor }; 21491 } 21492 } 21493 function enforceContainment(state) { 21494 if (!state.image) { 21495 return state; 21496 } 21497 const imageSize = { 21498 width: state.image.naturalWidth, 21499 height: state.image.naturalHeight 21500 }; 21501 const imageAspectRatio = imageSize.width / imageSize.height; 21502 const { pan: panAfterZoom, zoom } = restrictPanZoom( 21503 state, 21504 imageSize, 21505 state.cropRect 21506 ); 21507 const cropRect = restrictCropRect( 21508 state.cropRect, 21509 zoom, 21510 state.rotation, 21511 imageAspectRatio 21512 ); 21513 let pan = panAfterZoom; 21514 if (cropRect !== state.cropRect) { 21515 ({ pan } = restrictPanZoom( 21516 { ...state, zoom, cropRect }, 21517 imageSize, 21518 cropRect 21519 )); 21520 } 21521 if (pan.x === state.pan.x && pan.y === state.pan.y && zoom === state.zoom && cropRect === state.cropRect) { 21522 return state; 21523 } 21524 return { ...state, pan, zoom, cropRect }; 21525 } 21526 function commitBase(next) { 21527 if (next.basePan.x === next.pan.x && next.basePan.y === next.pan.y && next.baseZoom === next.zoom && next.baseRotation === next.rotation) { 21528 return next; 21529 } 21530 return { 21531 ...next, 21532 basePan: { x: next.pan.x, y: next.pan.y }, 21533 baseZoom: next.zoom, 21534 baseRotation: next.rotation 21535 }; 21536 } 21537 function cropperReducer(state, action) { 21538 switch (action.type) { 21539 case "SET_IMAGE": 21540 return commitBase( 21541 enforceContainment({ 21542 ...state, 21543 image: action.payload 21544 }) 21545 ); 21546 case "SET_PAN": 21547 return commitBase( 21548 enforceContainment({ 21549 ...state, 21550 pan: action.payload 21551 }) 21552 ); 21553 case "SET_ZOOM": { 21554 const z = clampRequestedZoom(state, action.payload); 21555 return commitBase( 21556 enforceContainment({ 21557 ...state, 21558 zoom: z 21559 }) 21560 ); 21561 } 21562 case "SET_ZOOM_AT_POINT": { 21563 const z = clampRequestedZoom(state, action.payload.zoom); 21564 return commitBase( 21565 enforceContainment({ 21566 ...state, 21567 zoom: z, 21568 pan: action.payload.pan 21569 }) 21570 ); 21571 } 21572 case "SET_ROTATION": { 21573 const newRotation = normalizeRotation(action.payload); 21574 const singleFlip = state.flip.horizontal !== state.flip.vertical; 21575 const deltaRad = degreesToRadians( 21576 newRotation - state.baseRotation 21577 ); 21578 const cos = Math.cos(deltaRad); 21579 const sin = Math.sin(deltaRad) * (singleFlip ? -1 : 1); 21580 const cropCx = state.cropRect.x + state.cropRect.width / 2; 21581 const cropCy = state.cropRect.y + state.cropRect.height / 2; 21582 const ox = cropCx - 0.5; 21583 const oy = cropCy - 0.5; 21584 const dx = state.basePan.x - ox; 21585 const dy = state.basePan.y - oy; 21586 return enforceContainment({ 21587 ...state, 21588 rotation: newRotation, 21589 zoom: state.baseZoom, 21590 pan: { 21591 x: ox + cos * dx - sin * dy, 21592 y: oy + sin * dx + cos * dy 21593 } 21594 }); 21595 } 21596 case "SNAP_ROTATE_90": { 21597 const rawDir = action.payload.direction; 21598 const singleFlip = state.flip.horizontal !== state.flip.vertical; 21599 const fieldDir = singleFlip ? -rawDir : rawDir; 21600 const rot90 = normalizeRotation(state.rotation + fieldDir * 90); 21601 const rect = state.cropRect; 21602 const cx = rect.x + rect.width / 2; 21603 const cy = rect.y + rect.height / 2; 21604 const newPanX = rawDir === 1 ? -state.pan.y : state.pan.y; 21605 const newPanY = rawDir === 1 ? state.pan.x : -state.pan.x; 21606 return commitBase( 21607 enforceContainment({ 21608 ...state, 21609 rotation: rot90, 21610 zoom: state.baseZoom, 21611 pan: { x: newPanX, y: newPanY }, 21612 cropRect: { 21613 x: cx - rect.height / 2, 21614 y: cy - rect.width / 2, 21615 width: rect.height, 21616 height: rect.width 21617 } 21618 }) 21619 ); 21620 } 21621 case "SET_FLIP": { 21622 const oldFlip = state.flip; 21623 const newFlip = action.payload; 21624 const flippedH = oldFlip.horizontal !== newFlip.horizontal; 21625 const flippedV = oldFlip.vertical !== newFlip.vertical; 21626 const rect = state.cropRect; 21627 return commitBase( 21628 enforceContainment({ 21629 ...state, 21630 flip: newFlip, 21631 pan: { 21632 x: flippedH ? -state.pan.x : state.pan.x, 21633 y: flippedV ? -state.pan.y : state.pan.y 21634 }, 21635 cropRect: { 21636 x: flippedH ? 1 - rect.x - rect.width : rect.x, 21637 y: flippedV ? 1 - rect.y - rect.height : rect.y, 21638 width: rect.width, 21639 height: rect.height 21640 } 21641 }) 21642 ); 21643 } 21644 case "SET_CROP_RECT": 21645 return commitBase( 21646 enforceContainment({ 21647 ...state, 21648 cropRect: action.payload 21649 }) 21650 ); 21651 case "SETTLE_CROP": { 21652 const rect = state.cropRect; 21653 if (rect.width === 0 || rect.height === 0 || !state.image) { 21654 return state; 21655 } 21656 const fitScale = 1 / Math.max(rect.width, rect.height); 21657 const zoomCap = state.zoom > 0 ? MAX_ZOOM / state.zoom : fitScale; 21658 const s2 = Math.min(fitScale, zoomCap); 21659 const newW = rect.width * s2; 21660 const newH = rect.height * s2; 21661 const oldCx = rect.x + rect.width / 2; 21662 const oldCy = rect.y + rect.height / 2; 21663 return commitBase( 21664 enforceContainment({ 21665 ...state, 21666 zoom: state.zoom * s2, 21667 pan: { 21668 x: (state.pan.x - oldCx + 0.5) * s2, 21669 y: (state.pan.y - oldCy + 0.5) * s2 21670 }, 21671 cropRect: { 21672 x: (1 - newW) / 2, 21673 y: (1 - newH) / 2, 21674 width: newW, 21675 height: newH 21676 } 21677 }) 21678 ); 21679 } 21680 case "APPLY_OPERATION": 21681 return cropperReducer( 21682 state, 21683 operationToAction(state, action.payload) 21684 ); 21685 case "RESET": 21686 return commitBase( 21687 enforceContainment({ 21688 ...DEFAULT_STATE2, 21689 image: state.image, 21690 ...action.payload 21691 }) 21692 ); 21693 } 21694 } 21695 21696 // packages/media-editor/build-module/image-editor/core/setter-helpers.mjs 21697 function buildFocalPointZoomAction(state, requestedZoom) { 21698 const clampedZoom = Math.min( 21699 MAX_ZOOM, 21700 Math.max(getMinZoom(state), requestedZoom) 21701 ); 21702 if (clampedZoom === state.zoom) { 21703 return null; 21704 } 21705 const { cropRect } = state; 21706 const focalNormX = cropRect.x + cropRect.width / 2 - 0.5; 21707 const focalNormY = cropRect.y + cropRect.height / 2 - 0.5; 21708 const zoomRatio = 1 - clampedZoom / state.zoom; 21709 const newPanX = state.pan.x + (focalNormX - state.pan.x) * zoomRatio; 21710 const newPanY = state.pan.y + (focalNormY - state.pan.y) * zoomRatio; 21711 const imageSize = state.image ? { 21712 width: state.image.naturalWidth, 21713 height: state.image.naturalHeight 21714 } : { width: 1, height: 1 }; 21715 const { pan: clampedPan } = restrictPanZoom( 21716 { 21717 ...state, 21718 zoom: clampedZoom, 21719 pan: { x: newPanX, y: newPanY } 21720 }, 21721 imageSize, 21722 state.cropRect 21723 ); 21724 return { 21725 type: "SET_ZOOM_AT_POINT", 21726 payload: { zoom: clampedZoom, pan: clampedPan } 21727 }; 21728 } 21729 21730 // packages/media-editor/build-module/image-editor/react/hooks/build-cropper-setters.mjs 21731 function buildCropperSetters(dispatchCropperAction, getCropperState) { 21732 return { 21733 setPan: (pan) => dispatchCropperAction({ type: "SET_PAN", payload: pan }), 21734 setZoom: (zoom) => { 21735 const action = buildFocalPointZoomAction(getCropperState(), zoom); 21736 if (action) { 21737 dispatchCropperAction(action); 21738 } 21739 }, 21740 setZoomAtPoint: (zoom, pan) => dispatchCropperAction({ 21741 type: "SET_ZOOM_AT_POINT", 21742 payload: { zoom, pan } 21743 }), 21744 setRotation: (rotation) => dispatchCropperAction({ 21745 type: "SET_ROTATION", 21746 payload: rotation 21747 }), 21748 setFlip: (flip4) => dispatchCropperAction({ type: "SET_FLIP", payload: flip4 }), 21749 toggleFlip: (direction) => { 21750 const { flip: flip4 } = getCropperState(); 21751 dispatchCropperAction({ 21752 type: "SET_FLIP", 21753 payload: { ...flip4, [direction]: !flip4[direction] } 21754 }); 21755 }, 21756 snapRotate90: (direction) => dispatchCropperAction({ 21757 type: "SNAP_ROTATE_90", 21758 payload: { direction } 21759 }), 21760 setCropRect: (rect) => dispatchCropperAction({ 21761 type: "SET_CROP_RECT", 21762 payload: rect 21763 }), 21764 settleCrop: () => dispatchCropperAction({ type: "SETTLE_CROP" }), 21765 applyOperation: (op) => dispatchCropperAction({ 21766 type: "APPLY_OPERATION", 21767 payload: op 21768 }) 21769 }; 21770 } 21771 21772 // packages/media-editor/build-module/image-editor/react/components/cropper.mjs 21773 var import_element77 = __toESM(require_element(), 1); 21774 var import_i18n30 = __toESM(require_i18n(), 1); 21775 21776 // packages/media-editor/build-module/image-editor/core/crop-rect.mjs 21777 function computeInscribedRect(aspectRatio, visualSize) { 21778 let w2 = 1; 21779 let h2 = 1; 21780 if (aspectRatio && aspectRatio > 0 && visualSize.width > 0) { 21781 const normalizedRatio = aspectRatio * visualSize.height / visualSize.width; 21782 if (normalizedRatio <= 1) { 21783 w2 = normalizedRatio; 21784 } else { 21785 h2 = 1 / normalizedRatio; 21786 } 21787 } 21788 return { 21789 x: (1 - w2) / 2, 21790 y: (1 - h2) / 2, 21791 width: w2, 21792 height: h2 21793 }; 21794 } 21795 21796 // packages/media-editor/build-module/image-editor/react/hooks/use-interaction.mjs 21797 var import_element70 = __toESM(require_element(), 1); 21798 21799 // packages/media-editor/build-module/image-editor/core/interaction-controller.mjs 21800 var DOUBLE_TAP_TIME = 300; 21801 var DOUBLE_TAP_DISTANCE = 30; 21802 var ZOOM_ANIMATION_DURATION = 200; 21803 function getImageSizeFromState(state) { 21804 return state.image ? { width: state.image.naturalWidth, height: state.image.naturalHeight } : { width: 1, height: 1 }; 21805 } 21806 function getTouchDistance(t1, t2) { 21807 const dx = t1.clientX - t2.clientX; 21808 const dy = t1.clientY - t2.clientY; 21809 return Math.sqrt(dx * dx + dy * dy); 21810 } 21811 var InteractionController = class { 21812 options; 21813 /** Current drag/zoom status. */ 21814 isDragging = false; 21815 isZooming = false; 21816 /** Active drag state during pointer interactions. */ 21817 drag = null; 21818 /** Active touch state during touch interactions. */ 21819 touch = null; 21820 /** Cleanup function for active touch listeners on document. */ 21821 touchCleanup = null; 21822 /** 21823 * Cleanup function for active pointer-drag listeners on the 21824 * captured element. Set while a pointer drag is in progress so 21825 * `destroy()` can tear the drag down cleanly if the consumer 21826 * unmounts mid-drag. Cleared on pointerup/lostpointercapture. 21827 */ 21828 pointerCleanup = null; 21829 /** Last tap info for double-tap detection. */ 21830 lastTap = null; 21831 /** Timer for the zoom animation state (double-tap). */ 21832 zoomTimer; 21833 /** Timer for wheel gesture debounce. */ 21834 wheelGestureTimer; 21835 /** Whether a wheel gesture is currently active. */ 21836 wheelGestureActive = false; 21837 /** Current requestAnimationFrame ID. */ 21838 rafId = 0; 21839 constructor(options) { 21840 this.options = options; 21841 } 21842 /** Read minZoom lazily so option changes take effect immediately. */ 21843 get minZoom() { 21844 return this.options.minZoom ?? MIN_ZOOM; 21845 } 21846 /** Read maxZoom lazily so option changes take effect immediately. */ 21847 get maxZoom() { 21848 return this.options.maxZoom ?? MAX_ZOOM; 21849 } 21850 /** Read zoomSpeed lazily so option changes take effect immediately. */ 21851 get zoomSpeed() { 21852 return this.options.zoomSpeed ?? DEFAULT_WHEEL_ZOOM_SPEED; 21853 } 21854 /** Read keyboardStep lazily so option changes take effect immediately. */ 21855 get keyboardStep() { 21856 return this.options.keyboardStep ?? DEFAULT_KEYBOARD_STEP; 21857 } 21858 /** 21859 * Get the keyboard pan step, including modifier-based coarse movement. 21860 * 21861 * @param event The native KeyboardEvent. 21862 * @return The normalized pan step. 21863 */ 21864 getKeyboardStep(event) { 21865 return event.shiftKey ? this.keyboardStep * KEYBOARD_SHIFT_STEP_MULTIPLIER : this.keyboardStep; 21866 } 21867 /** Read doubleTapZoom lazily so option changes take effect immediately. */ 21868 get doubleTapZoom() { 21869 return this.options.doubleTapZoom ?? 2; 21870 } 21871 /** 21872 * Update the drag/zoom status and notify via callback if changed. 21873 * 21874 * @param update Partial status with isDragging and/or isZooming. 21875 */ 21876 setStatus(update2) { 21877 let changed = false; 21878 if (update2.isDragging !== void 0 && update2.isDragging !== this.isDragging) { 21879 this.isDragging = update2.isDragging; 21880 changed = true; 21881 } 21882 if (update2.isZooming !== void 0 && update2.isZooming !== this.isZooming) { 21883 this.isZooming = update2.isZooming; 21884 changed = true; 21885 } 21886 if (changed) { 21887 this.options.onStatusChange?.({ 21888 isDragging: this.isDragging, 21889 isZooming: this.isZooming 21890 }); 21891 } 21892 } 21893 /** 21894 * Handle a pointer-down event on the container element. 21895 * 21896 * Initiates a drag (pan) interaction. Captures the pointer on the 21897 * provided element and registers pointermove/pointerup/lostpointercapture 21898 * listeners for the duration of the drag. 21899 * 21900 * @param e The native PointerEvent. 21901 * @param el The DOM element to capture the pointer on. 21902 */ 21903 handlePointerDown(e2, el) { 21904 if (e2.button !== 0) { 21905 return; 21906 } 21907 e2.preventDefault(); 21908 const ownerDoc = el.ownerDocument; 21909 if (ownerDoc?.activeElement instanceof HTMLElement && ownerDoc.activeElement !== el) { 21910 ownerDoc.activeElement.blur(); 21911 } 21912 el.focus(); 21913 el.setPointerCapture(e2.pointerId); 21914 this.setStatus({ isDragging: true }); 21915 this.options.onGestureStart?.(); 21916 const currentState = this.options.getState(); 21917 this.drag = { 21918 startX: e2.clientX, 21919 startY: e2.clientY, 21920 startPanX: currentState.pan.x, 21921 startPanY: currentState.pan.y 21922 }; 21923 const onPointerMove = (moveEvent) => { 21924 const drag2 = this.drag; 21925 if (!drag2) { 21926 return; 21927 } 21928 const pe = moveEvent; 21929 cancelAnimationFrame(this.rafId); 21930 this.rafId = requestAnimationFrame(() => { 21931 const s2 = this.options.getState(); 21932 const imgSize = this.options.getImageSize(); 21933 const containerSize = this.options.getContainerSize(); 21934 const panSize = imgSize ?? containerSize; 21935 const deltaX = panSize.width > 0 ? (pe.clientX - drag2.startX) / panSize.width : 0; 21936 const deltaY = panSize.height > 0 ? (pe.clientY - drag2.startY) / panSize.height : 0; 21937 const { pan: newCrop } = restrictPanZoom( 21938 { 21939 ...s2, 21940 pan: { 21941 x: drag2.startPanX + deltaX, 21942 y: drag2.startPanY + deltaY 21943 } 21944 }, 21945 getImageSizeFromState(s2), 21946 s2.cropRect 21947 ); 21948 this.options.actions.setPan(newCrop); 21949 }); 21950 }; 21951 const removeListeners = () => { 21952 el.removeEventListener("pointermove", onPointerMove); 21953 el.removeEventListener("pointerup", onPointerUp); 21954 el.removeEventListener("lostpointercapture", onPointerUp); 21955 }; 21956 const onPointerUp = () => { 21957 this.setStatus({ isDragging: false }); 21958 this.options.onGestureEnd?.(); 21959 this.drag = null; 21960 cancelAnimationFrame(this.rafId); 21961 removeListeners(); 21962 this.pointerCleanup = null; 21963 }; 21964 el.addEventListener("pointermove", onPointerMove); 21965 el.addEventListener("pointerup", onPointerUp); 21966 el.addEventListener("lostpointercapture", onPointerUp); 21967 this.pointerCleanup = removeListeners; 21968 } 21969 /** 21970 * Handle a wheel event on the container element. 21971 * 21972 * Implements focal-point zoom: the point under the cursor stays 21973 * stationary on screen while the zoom level changes. 21974 * 21975 * Must be registered with `{ passive: false }` to allow preventDefault. 21976 * 21977 * @param e The native WheelEvent. 21978 */ 21979 handleWheel(e2) { 21980 e2.preventDefault(); 21981 if (this.drag) { 21982 return; 21983 } 21984 if (!this.wheelGestureActive) { 21985 this.wheelGestureActive = true; 21986 this.options.onGestureStart?.(); 21987 } 21988 clearTimeout(this.wheelGestureTimer); 21989 this.wheelGestureTimer = setTimeout(() => { 21990 this.wheelGestureActive = false; 21991 this.options.onGestureEnd?.(); 21992 }, DOUBLE_TAP_TIME); 21993 const s2 = this.options.getState(); 21994 const delta = -e2.deltaY * this.zoomSpeed; 21995 const newZoom = Math.min( 21996 this.maxZoom, 21997 Math.max(this.minZoom, s2.zoom + delta) 21998 ); 21999 if (newZoom === s2.zoom) { 22000 return; 22001 } 22002 const containerSize = this.options.getContainerSize(); 22003 const imgSize = this.options.getImageSize(); 22004 const visSize = imgSize ?? containerSize; 22005 const target = e2.currentTarget; 22006 const rect = target instanceof Element ? target.getBoundingClientRect() : void 0; 22007 if (visSize.width > 0 && visSize.height > 0 && rect) { 22008 const fx = e2.clientX - rect.left - containerSize.width / 2; 22009 const fy = e2.clientY - rect.top - containerSize.height / 2; 22010 const zoomRatio = 1 - newZoom / s2.zoom; 22011 const focalNormX = fx / visSize.width; 22012 const focalNormY = fy / visSize.height; 22013 const newCropX = s2.pan.x + (focalNormX - s2.pan.x) * zoomRatio; 22014 const newCropY = s2.pan.y + (focalNormY - s2.pan.y) * zoomRatio; 22015 const { pan: clampedCrop } = restrictPanZoom( 22016 { ...s2, zoom: newZoom, pan: { x: newCropX, y: newCropY } }, 22017 getImageSizeFromState(s2), 22018 s2.cropRect 22019 ); 22020 this.options.actions.setZoomAtPoint(newZoom, clampedCrop); 22021 } else { 22022 this.options.actions.setZoom(newZoom); 22023 } 22024 } 22025 /** 22026 * Handle a touch-start event on the container element. 22027 * 22028 * Supports single-finger pan, two-finger pinch zoom, and 22029 * double-tap to toggle between fit and 2x zoom. Registers 22030 * touchmove/touchend/touchcancel on the provided document for the 22031 * duration of the gesture. 22032 * 22033 * @param e The native TouchEvent. 22034 * @param containerRect The bounding rect of the container element. 22035 * @param doc The document to register move/end listeners on. 22036 * Defaults to globalThis.document. Pass the iframe's 22037 * contentDocument when running inside an iframe. 22038 */ 22039 handleTouchStart(e2, containerRect, doc = document) { 22040 if (this.touch && e2.touches.length === 2) { 22041 const s2 = this.options.getState(); 22042 const distance2 = getTouchDistance(e2.touches[0], e2.touches[1]); 22043 const midX = (e2.touches[0].clientX + e2.touches[1].clientX) / 2; 22044 const midY = (e2.touches[0].clientY + e2.touches[1].clientY) / 2; 22045 this.touch.didPinch = true; 22046 this.touch.startDistance = distance2; 22047 this.touch.startZoom = s2.zoom; 22048 this.touch.startPanX = s2.pan.x; 22049 this.touch.startPanY = s2.pan.y; 22050 this.touch.startMidX = midX; 22051 this.touch.startMidY = midY; 22052 this.touch.containerRect = containerRect; 22053 this.setStatus({ isDragging: false }); 22054 return; 22055 } 22056 if (e2.touches.length === 1) { 22057 const tapX = e2.touches[0].clientX; 22058 const tapY = e2.touches[0].clientY; 22059 if (this.tryDoubleTap(e2, tapX, tapY, containerRect)) { 22060 return; 22061 } 22062 const currentState = this.options.getState(); 22063 this.touch = { 22064 startDistance: 0, 22065 startZoom: currentState.zoom, 22066 lastTouchX: e2.touches[0].clientX, 22067 lastTouchY: e2.touches[0].clientY, 22068 startPanX: currentState.pan.x, 22069 startPanY: currentState.pan.y, 22070 containerRect, 22071 startMidX: 0, 22072 startMidY: 0, 22073 didPinch: false, 22074 moved: false 22075 }; 22076 this.options.onGestureStart?.(); 22077 } else if (e2.touches.length === 2) { 22078 const currentState = this.options.getState(); 22079 const distance2 = getTouchDistance(e2.touches[0], e2.touches[1]); 22080 const midX = (e2.touches[0].clientX + e2.touches[1].clientX) / 2; 22081 const midY = (e2.touches[0].clientY + e2.touches[1].clientY) / 2; 22082 this.touch = { 22083 startDistance: distance2, 22084 startZoom: currentState.zoom, 22085 lastTouchX: 0, 22086 lastTouchY: 0, 22087 startPanX: currentState.pan.x, 22088 startPanY: currentState.pan.y, 22089 containerRect, 22090 startMidX: midX, 22091 startMidY: midY, 22092 didPinch: true, 22093 moved: false 22094 }; 22095 this.options.onGestureStart?.(); 22096 } 22097 const onTouchEnd = () => { 22098 this.touch = null; 22099 this.touchCleanup = null; 22100 cancelAnimationFrame(this.rafId); 22101 doc.removeEventListener("touchmove", this.handleTouchMove); 22102 doc.removeEventListener("touchend", onTouchEnd); 22103 doc.removeEventListener("touchcancel", onTouchEnd); 22104 this.setStatus({ isDragging: false }); 22105 this.options.onGestureEnd?.(); 22106 }; 22107 this.touchCleanup?.(); 22108 doc.addEventListener("touchmove", this.handleTouchMove, { 22109 passive: false 22110 }); 22111 doc.addEventListener("touchend", onTouchEnd); 22112 doc.addEventListener("touchcancel", onTouchEnd); 22113 this.touchCleanup = onTouchEnd; 22114 } 22115 // Handle a touchmove event during an active touch gesture. Decides pinch 22116 // vs. pan based on current `moveEvent.touches.length`, so the gesture 22117 // can transition between modes without timing sensitivity (e.g. fingers 22118 // landing 0ms vs 200ms apart). Arrow-property binding so `this` stays 22119 // attached when used as an event listener. 22120 handleTouchMove = (moveEvent) => { 22121 const touch = this.touch; 22122 if (!touch) { 22123 return; 22124 } 22125 cancelAnimationFrame(this.rafId); 22126 this.rafId = requestAnimationFrame(() => { 22127 const s2 = this.options.getState(); 22128 if (moveEvent.touches.length === 2) { 22129 if (!touch.didPinch) { 22130 touch.didPinch = true; 22131 touch.startDistance = getTouchDistance( 22132 moveEvent.touches[0], 22133 moveEvent.touches[1] 22134 ); 22135 touch.startZoom = s2.zoom; 22136 touch.startPanX = s2.pan.x; 22137 touch.startPanY = s2.pan.y; 22138 touch.startMidX = (moveEvent.touches[0].clientX + moveEvent.touches[1].clientX) / 2; 22139 touch.startMidY = (moveEvent.touches[0].clientY + moveEvent.touches[1].clientY) / 2; 22140 this.setStatus({ isDragging: false }); 22141 return; 22142 } 22143 const latestContainerSize = this.options.getContainerSize(); 22144 const latestImageSize = this.options.getImageSize(); 22145 const t0 = moveEvent.touches[0]; 22146 const t1 = moveEvent.touches[1]; 22147 const currentDistance = getTouchDistance(t0, t1); 22148 const ratio = currentDistance / touch.startDistance; 22149 const newZoom = Math.min( 22150 this.maxZoom, 22151 Math.max(this.minZoom, touch.startZoom * ratio) 22152 ); 22153 const visSize = latestImageSize ?? latestContainerSize; 22154 const rect = touch.containerRect; 22155 if (visSize.width > 0 && visSize.height > 0 && rect) { 22156 const mx = (t0.clientX + t1.clientX) / 2 - rect.left - latestContainerSize.width / 2; 22157 const my = (t0.clientY + t1.clientY) / 2 - rect.top - latestContainerSize.height / 2; 22158 const startMx = touch.startMidX - rect.left - latestContainerSize.width / 2; 22159 const startMy = touch.startMidY - rect.top - latestContainerSize.height / 2; 22160 const panDx = visSize.width > 0 ? (mx - startMx) / visSize.width : 0; 22161 const panDy = visSize.height > 0 ? (my - startMy) / visSize.height : 0; 22162 const zoomRatio = s2.zoom !== 0 ? 1 - newZoom / s2.zoom : 0; 22163 const focalNormX = mx / visSize.width; 22164 const focalNormY = my / visSize.height; 22165 const zoomCropX = s2.pan.x + (focalNormX - s2.pan.x) * zoomRatio; 22166 const zoomCropY = s2.pan.y + (focalNormY - s2.pan.y) * zoomRatio; 22167 const newCropX = touch.startPanX + panDx + (zoomCropX - s2.pan.x); 22168 const newCropY = touch.startPanY + panDy + (zoomCropY - s2.pan.y); 22169 const { pan: clampedCrop } = restrictPanZoom( 22170 { 22171 ...s2, 22172 zoom: newZoom, 22173 pan: { x: newCropX, y: newCropY } 22174 }, 22175 getImageSizeFromState(s2), 22176 s2.cropRect 22177 ); 22178 this.options.actions.setZoomAtPoint(newZoom, clampedCrop); 22179 } else if (newZoom !== s2.zoom) { 22180 this.options.actions.setZoom(newZoom); 22181 } 22182 } else if (moveEvent.touches.length === 1 && !touch.didPinch) { 22183 if (!touch.moved) { 22184 touch.moved = true; 22185 this.setStatus({ isDragging: true }); 22186 } 22187 const panImageSize = this.options.getImageSize(); 22188 const panContainerSize = this.options.getContainerSize(); 22189 const panSize = panImageSize ?? panContainerSize; 22190 const deltaX = panSize.width > 0 ? (moveEvent.touches[0].clientX - touch.lastTouchX) / panSize.width : 0; 22191 const deltaY = panSize.height > 0 ? (moveEvent.touches[0].clientY - touch.lastTouchY) / panSize.height : 0; 22192 const { pan: newCrop } = restrictPanZoom( 22193 { 22194 ...s2, 22195 pan: { 22196 x: touch.startPanX + deltaX, 22197 y: touch.startPanY + deltaY 22198 } 22199 }, 22200 getImageSizeFromState(s2), 22201 s2.cropRect 22202 ); 22203 this.options.actions.setPan(newCrop); 22204 } 22205 }); 22206 }; 22207 // Handle double-tap-to-toggle-zoom. On a second tap within the configured 22208 // time/distance threshold, toggles zoom between `minZoom` and 22209 // `doubleTapZoom` around the tap point and dispatches. Returns `true` if 22210 // the tap was handled as a double-tap (caller should early-return), 22211 // `false` otherwise (caller proceeds with normal single-tap handling). 22212 // Either way, records the tap for next time. 22213 tryDoubleTap(e2, tapX, tapY, containerRect) { 22214 const now = Date.now(); 22215 const lastTap = this.lastTap; 22216 if (!lastTap) { 22217 this.lastTap = { time: now, x: tapX, y: tapY }; 22218 return false; 22219 } 22220 const timeDelta = now - lastTap.time; 22221 const distDelta = Math.sqrt( 22222 (tapX - lastTap.x) ** 2 + (tapY - lastTap.y) ** 2 22223 ); 22224 const isDoubleTap = timeDelta < DOUBLE_TAP_TIME && distDelta < DOUBLE_TAP_DISTANCE; 22225 if (!isDoubleTap) { 22226 this.lastTap = { time: now, x: tapX, y: tapY }; 22227 return false; 22228 } 22229 e2.preventDefault(); 22230 this.lastTap = null; 22231 const currentState = this.options.getState(); 22232 const containerSize = this.options.getContainerSize(); 22233 const imgSize = this.options.getImageSize(); 22234 const targetZoom = currentState.zoom > (this.minZoom + this.doubleTapZoom) / 2 ? this.minZoom : this.doubleTapZoom; 22235 const visSize = imgSize ?? containerSize; 22236 this.setStatus({ isZooming: true }); 22237 clearTimeout(this.zoomTimer); 22238 this.zoomTimer = setTimeout(() => { 22239 this.setStatus({ isZooming: false }); 22240 }, ZOOM_ANIMATION_DURATION); 22241 this.options.onGestureStart?.(); 22242 if (visSize.width > 0 && visSize.height > 0) { 22243 const fx = tapX - containerRect.left - containerSize.width / 2; 22244 const fy = tapY - containerRect.top - containerSize.height / 2; 22245 const zoomRatio = 1 - targetZoom / currentState.zoom; 22246 const focalNormX = fx / visSize.width; 22247 const focalNormY = fy / visSize.height; 22248 const newCropX = currentState.pan.x + (focalNormX - currentState.pan.x) * zoomRatio; 22249 const newCropY = currentState.pan.y + (focalNormY - currentState.pan.y) * zoomRatio; 22250 const { pan: clampedCrop } = restrictPanZoom( 22251 { 22252 ...currentState, 22253 zoom: targetZoom, 22254 pan: { x: newCropX, y: newCropY } 22255 }, 22256 getImageSizeFromState(currentState), 22257 currentState.cropRect 22258 ); 22259 this.options.actions.setZoomAtPoint(targetZoom, clampedCrop); 22260 } else { 22261 this.options.actions.setZoom(targetZoom); 22262 } 22263 this.options.onGestureEnd?.(); 22264 return true; 22265 } 22266 /** 22267 * Handle a keydown event on the container element. 22268 * 22269 * Supports arrow keys for panning, +/- for zoom, and r/R for rotation. 22270 * 22271 * @param e The native KeyboardEvent. 22272 */ 22273 handleKeyDown(e2) { 22274 const currentState = this.options.getState(); 22275 switch (e2.key) { 22276 case "ArrowUp": { 22277 e2.preventDefault(); 22278 const keyboardStep = this.getKeyboardStep(e2); 22279 const { pan: newCrop } = restrictPanZoom( 22280 { 22281 ...currentState, 22282 pan: { 22283 x: currentState.pan.x, 22284 y: currentState.pan.y + keyboardStep 22285 } 22286 }, 22287 getImageSizeFromState(currentState), 22288 currentState.cropRect 22289 ); 22290 this.options.actions.setPan(newCrop); 22291 break; 22292 } 22293 case "ArrowDown": { 22294 e2.preventDefault(); 22295 const keyboardStep = this.getKeyboardStep(e2); 22296 const { pan: newCrop } = restrictPanZoom( 22297 { 22298 ...currentState, 22299 pan: { 22300 x: currentState.pan.x, 22301 y: currentState.pan.y - keyboardStep 22302 } 22303 }, 22304 getImageSizeFromState(currentState), 22305 currentState.cropRect 22306 ); 22307 this.options.actions.setPan(newCrop); 22308 break; 22309 } 22310 case "ArrowLeft": { 22311 e2.preventDefault(); 22312 const keyboardStep = this.getKeyboardStep(e2); 22313 const { pan: newCrop } = restrictPanZoom( 22314 { 22315 ...currentState, 22316 pan: { 22317 x: currentState.pan.x + keyboardStep, 22318 y: currentState.pan.y 22319 } 22320 }, 22321 getImageSizeFromState(currentState), 22322 currentState.cropRect 22323 ); 22324 this.options.actions.setPan(newCrop); 22325 break; 22326 } 22327 case "ArrowRight": { 22328 e2.preventDefault(); 22329 const keyboardStep = this.getKeyboardStep(e2); 22330 const { pan: newCrop } = restrictPanZoom( 22331 { 22332 ...currentState, 22333 pan: { 22334 x: currentState.pan.x - keyboardStep, 22335 y: currentState.pan.y 22336 } 22337 }, 22338 getImageSizeFromState(currentState), 22339 currentState.cropRect 22340 ); 22341 this.options.actions.setPan(newCrop); 22342 break; 22343 } 22344 case "+": 22345 case "=": { 22346 e2.preventDefault(); 22347 const newZoom = Math.min( 22348 this.maxZoom, 22349 Math.max(this.minZoom, currentState.zoom + 0.5) 22350 ); 22351 this.options.actions.setZoom(newZoom); 22352 break; 22353 } 22354 case "-": 22355 case "_": { 22356 e2.preventDefault(); 22357 const newZoom = Math.min( 22358 this.maxZoom, 22359 Math.max(this.minZoom, currentState.zoom - 0.5) 22360 ); 22361 this.options.actions.setZoom(newZoom); 22362 break; 22363 } 22364 case "r": 22365 case "R": { 22366 if (e2.metaKey || e2.ctrlKey || e2.altKey) { 22367 break; 22368 } 22369 e2.preventDefault(); 22370 this.options.actions.snapRotate90(e2.shiftKey ? -1 : 1); 22371 break; 22372 } 22373 case "h": 22374 case "H": { 22375 if (e2.metaKey || e2.ctrlKey || e2.altKey || e2.shiftKey) { 22376 break; 22377 } 22378 e2.preventDefault(); 22379 this.options.actions.toggleFlip?.("horizontal"); 22380 break; 22381 } 22382 case "v": 22383 case "V": { 22384 if (e2.metaKey || e2.ctrlKey || e2.altKey || e2.shiftKey) { 22385 break; 22386 } 22387 e2.preventDefault(); 22388 this.options.actions.toggleFlip?.("vertical"); 22389 break; 22390 } 22391 } 22392 } 22393 /** 22394 * Clean up all timers, animation frames, and active touch listeners. 22395 * 22396 * Must be called when the controller is no longer needed (e.g., on 22397 * component unmount or element removal). 22398 */ 22399 destroy() { 22400 cancelAnimationFrame(this.rafId); 22401 clearTimeout(this.zoomTimer); 22402 clearTimeout(this.wheelGestureTimer); 22403 this.touchCleanup?.(); 22404 this.touchCleanup = null; 22405 this.pointerCleanup?.(); 22406 this.pointerCleanup = null; 22407 this.drag = null; 22408 this.touch = null; 22409 this.lastTap = null; 22410 } 22411 }; 22412 22413 // packages/media-editor/build-module/image-editor/react/hooks/use-interaction.mjs 22414 var KEYBOARD_INTERACTION_IDLE_MS = 300; 22415 function isHandledKeyboardPan(event) { 22416 switch (event.key) { 22417 case "ArrowUp": 22418 case "ArrowDown": 22419 case "ArrowLeft": 22420 case "ArrowRight": 22421 return true; 22422 default: 22423 return false; 22424 } 22425 } 22426 function isHandledKeyboardZoom(event) { 22427 switch (event.key) { 22428 case "+": 22429 case "=": 22430 case "-": 22431 case "_": 22432 return true; 22433 default: 22434 return false; 22435 } 22436 } 22437 function useInteraction(state, actions, containerSize, imageSize, options) { 22438 const [isDragging, setIsDragging] = (0, import_element70.useState)(false); 22439 const [isZooming, setIsZooming] = (0, import_element70.useState)(false); 22440 const [isGestureActive, setIsGestureActive] = (0, import_element70.useState)(false); 22441 const [isKeyboardPanning, setIsKeyboardPanning] = (0, import_element70.useState)(false); 22442 const keyboardInteractionTimerRef = (0, import_element70.useRef)(void 0); 22443 const isKeyboardGestureActiveRef = (0, import_element70.useRef)(false); 22444 const stateRef = (0, import_element70.useRef)(state); 22445 stateRef.current = state; 22446 const containerSizeRef = (0, import_element70.useRef)(containerSize); 22447 containerSizeRef.current = containerSize; 22448 const imageSizeRef = (0, import_element70.useRef)(imageSize); 22449 imageSizeRef.current = imageSize; 22450 const optionsRef = (0, import_element70.useRef)(options); 22451 optionsRef.current = options; 22452 const actionsRef = (0, import_element70.useRef)(actions); 22453 actionsRef.current = actions; 22454 const controllerRef = (0, import_element70.useRef)(null); 22455 const startPlacementGesture = (0, import_element70.useCallback)(() => { 22456 setIsGestureActive(true); 22457 }, []); 22458 const stopPlacementGesture = (0, import_element70.useCallback)(() => { 22459 setIsGestureActive(false); 22460 }, []); 22461 const signalKeyboardGesture = (0, import_element70.useCallback)(() => { 22462 if (!isKeyboardGestureActiveRef.current) { 22463 isKeyboardGestureActiveRef.current = true; 22464 optionsRef.current?.onGestureStart?.(); 22465 } 22466 clearTimeout(keyboardInteractionTimerRef.current); 22467 keyboardInteractionTimerRef.current = setTimeout(() => { 22468 isKeyboardGestureActiveRef.current = false; 22469 setIsKeyboardPanning(false); 22470 optionsRef.current?.onGestureEnd?.(); 22471 }, KEYBOARD_INTERACTION_IDLE_MS); 22472 }, []); 22473 (0, import_element70.useEffect)(() => { 22474 return () => { 22475 clearTimeout(keyboardInteractionTimerRef.current); 22476 }; 22477 }, []); 22478 (0, import_element70.useEffect)(() => { 22479 const controller = new InteractionController({ 22480 getState: () => stateRef.current, 22481 actions: { 22482 setPan: (pan) => actionsRef.current.setPan(pan), 22483 setZoom: (zoom) => actionsRef.current.setZoom(zoom), 22484 setZoomAtPoint: (zoom, pan) => actionsRef.current.setZoomAtPoint(zoom, pan), 22485 snapRotate90: (direction) => actionsRef.current.snapRotate90(direction), 22486 toggleFlip: (direction) => actionsRef.current.toggleFlip?.(direction) 22487 }, 22488 getContainerSize: () => containerSizeRef.current, 22489 getImageSize: () => imageSizeRef.current, 22490 get minZoom() { 22491 return optionsRef.current?.minZoom; 22492 }, 22493 get maxZoom() { 22494 return optionsRef.current?.maxZoom; 22495 }, 22496 get zoomSpeed() { 22497 return optionsRef.current?.zoomSpeed; 22498 }, 22499 get keyboardStep() { 22500 return optionsRef.current?.keyboardStep; 22501 }, 22502 get doubleTapZoom() { 22503 return optionsRef.current?.doubleTapZoom; 22504 }, 22505 onGestureStart: () => { 22506 startPlacementGesture(); 22507 optionsRef.current?.onGestureStart?.(); 22508 }, 22509 onGestureEnd: () => { 22510 stopPlacementGesture(); 22511 optionsRef.current?.onGestureEnd?.(); 22512 }, 22513 onStatusChange: (status) => { 22514 setIsDragging(status.isDragging); 22515 setIsZooming(status.isZooming); 22516 } 22517 }); 22518 controllerRef.current = controller; 22519 return () => { 22520 controller.destroy(); 22521 controllerRef.current = null; 22522 }; 22523 }, [startPlacementGesture, stopPlacementGesture]); 22524 const onPointerDown = (0, import_element70.useCallback)((e2) => { 22525 const el = e2.currentTarget; 22526 controllerRef.current?.handlePointerDown(e2.nativeEvent, el); 22527 }, []); 22528 const onTouchStart = (0, import_element70.useCallback)((e2) => { 22529 const el = e2.currentTarget; 22530 const rect = el.getBoundingClientRect(); 22531 controllerRef.current?.handleTouchStart( 22532 e2.nativeEvent, 22533 rect, 22534 el.ownerDocument 22535 ); 22536 }, []); 22537 const onKeyDown = (0, import_element70.useCallback)( 22538 (e2) => { 22539 if (isHandledKeyboardPan(e2.nativeEvent)) { 22540 setIsKeyboardPanning(true); 22541 signalKeyboardGesture(); 22542 } else if (isHandledKeyboardZoom(e2.nativeEvent)) { 22543 signalKeyboardGesture(); 22544 } 22545 controllerRef.current?.handleKeyDown(e2.nativeEvent); 22546 }, 22547 [signalKeyboardGesture] 22548 ); 22549 const onWheelNative = (0, import_element70.useCallback)((e2) => { 22550 controllerRef.current?.handleWheel(e2); 22551 }, []); 22552 return { 22553 handlers: { 22554 onPointerDown, 22555 onTouchStart, 22556 onKeyDown 22557 }, 22558 onWheelNative, 22559 isDragging, 22560 isZooming, 22561 isPlacementActive: isGestureActive || isKeyboardPanning || isZooming 22562 }; 22563 } 22564 22565 // packages/media-editor/build-module/image-editor/react/hooks/use-transform-style.mjs 22566 var import_element71 = __toESM(require_element(), 1); 22567 22568 // packages/media-editor/build-module/image-editor/core/transform-style.mjs 22569 var IDENTITY_MATRIX_STYLE = "matrix(1, 0, 0, 1, 0, 0)"; 22570 function computeTransformStyle(state, imageSize) { 22571 if (!isValidSize(imageSize)) { 22572 return IDENTITY_MATRIX_STYLE; 22573 } 22574 const safeState = sanitizeCropperState(state); 22575 const translateX = safeState.pan.x * imageSize.width; 22576 const translateY = safeState.pan.y * imageSize.height; 22577 const rad = degreesToRadians(safeState.rotation); 22578 const cos = Math.cos(rad); 22579 const sin = Math.sin(rad); 22580 const sx = safeState.flip.horizontal ? -1 : 1; 22581 const sy = safeState.flip.vertical ? -1 : 1; 22582 const z = safeState.zoom; 22583 const a2 = sx * cos * z; 22584 const b2 = sy * sin * z; 22585 const c2 = -sx * sin * z; 22586 const d2 = sy * cos * z; 22587 return `matrix($a2}, $b2}, $c2}, $d2}, $translateX}, $translateY})`; 22588 } 22589 22590 // packages/media-editor/build-module/image-editor/react/hooks/use-transform-style.mjs 22591 function useTransformStyle(state, imageSize) { 22592 return (0, import_element71.useMemo)( 22593 () => computeTransformStyle(state, imageSize), 22594 [state, imageSize] 22595 ); 22596 } 22597 22598 // packages/media-editor/build-module/image-editor/react/hooks/use-aria-announcer.mjs 22599 var import_element72 = __toESM(require_element(), 1); 22600 var import_i18n28 = __toESM(require_i18n(), 1); 22601 var ARIA_DEBOUNCE_MS = 300; 22602 function buildFlipAnnouncement(state) { 22603 const { horizontal, vertical } = state.flip; 22604 if (horizontal && vertical) { 22605 return (0, import_i18n28.__)("Flipped horizontally and vertically"); 22606 } 22607 if (horizontal) { 22608 return (0, import_i18n28.__)("Flipped horizontally"); 22609 } 22610 if (vertical) { 22611 return (0, import_i18n28.__)("Flipped vertically"); 22612 } 22613 return (0, import_i18n28.__)("Flip removed"); 22614 } 22615 function buildAnnouncement(state, previousState) { 22616 if (previousState && (previousState.flip.horizontal !== state.flip.horizontal || previousState.flip.vertical !== state.flip.vertical)) { 22617 return buildFlipAnnouncement(state); 22618 } 22619 const parts = []; 22620 parts.push( 22621 (0, import_i18n28.sprintf)( 22622 /* translators: %d: zoom level as a percentage. */ 22623 (0, import_i18n28.__)("Zoom %d%%"), 22624 Math.round(state.zoom * 100) 22625 ) 22626 ); 22627 if (state.rotation !== 0) { 22628 parts.push( 22629 (0, import_i18n28.sprintf)( 22630 /* translators: %d: rotation angle in degrees. */ 22631 (0, import_i18n28.__)("Rotation %d degrees"), 22632 Math.round(state.rotation) 22633 ) 22634 ); 22635 } 22636 const cropW = Math.round(state.cropRect.width * 100); 22637 const cropH = Math.round(state.cropRect.height * 100); 22638 parts.push( 22639 (0, import_i18n28.sprintf)( 22640 /* translators: 1: crop width as a percentage, 2: crop height as a percentage. */ 22641 (0, import_i18n28.__)("Crop %1$d%% by %2$d%%"), 22642 cropW, 22643 cropH 22644 ) 22645 ); 22646 if (state.flip.horizontal || state.flip.vertical) { 22647 parts.push(buildFlipAnnouncement(state)); 22648 } 22649 return parts.join(", "); 22650 } 22651 function useAriaAnnouncer(state) { 22652 const [ariaMessage, setAriaMessage] = (0, import_element72.useState)(""); 22653 const timerRef = (0, import_element72.useRef)( 22654 void 0 22655 ); 22656 const prevMessageRef = (0, import_element72.useRef)(""); 22657 const prevStateRef = (0, import_element72.useRef)(null); 22658 const latestStateRef = (0, import_element72.useRef)(state); 22659 (0, import_element72.useLayoutEffect)(() => { 22660 latestStateRef.current = state; 22661 }, [state]); 22662 (0, import_element72.useEffect)(() => { 22663 clearTimeout(timerRef.current); 22664 timerRef.current = setTimeout(() => { 22665 const current = latestStateRef.current; 22666 const msg = buildAnnouncement(current, prevStateRef.current); 22667 prevStateRef.current = current; 22668 if (msg !== prevMessageRef.current) { 22669 prevMessageRef.current = msg; 22670 setAriaMessage(msg); 22671 } 22672 }, ARIA_DEBOUNCE_MS); 22673 return () => { 22674 clearTimeout(timerRef.current); 22675 }; 22676 }, [ 22677 state.zoom, 22678 state.rotation, 22679 state.cropRect.width, 22680 state.cropRect.height, 22681 state.flip.horizontal, 22682 state.flip.vertical 22683 ]); 22684 return ariaMessage; 22685 } 22686 22687 // packages/media-editor/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs 22688 var import_element73 = __toESM(require_element(), 1); 22689 var import_i18n29 = __toESM(require_i18n(), 1); 22690 22691 // packages/media-editor/build-module/image-editor/core/stencil-math.mjs 22692 var DEFAULT_MIN_CROP_SIZE = { width: 0.05, height: 0.05 }; 22693 function computeFreeResizeRect(drag2, clientX, clientY, imageSize, bounds, minCropSize = DEFAULT_MIN_CROP_SIZE) { 22694 const dx = imageSize.width > 0 ? (clientX - drag2.startX) / imageSize.width : 0; 22695 const dy = imageSize.height > 0 ? (clientY - drag2.startY) / imageSize.height : 0; 22696 const s2 = drag2.startRect; 22697 const handle = drag2.handle; 22698 let edgeTop = s2.y; 22699 let edgeBottom = s2.y + s2.height; 22700 let edgeLeft = s2.x; 22701 let edgeRight = s2.x + s2.width; 22702 if (handle === "n" || handle === "nw" || handle === "ne") { 22703 edgeTop = Math.max( 22704 bounds.minY, 22705 Math.min(s2.y + dy, edgeBottom - minCropSize.height) 22706 ); 22707 } 22708 if (handle === "s" || handle === "sw" || handle === "se") { 22709 edgeBottom = Math.max( 22710 edgeTop + minCropSize.height, 22711 Math.min(s2.y + s2.height + dy, bounds.maxY) 22712 ); 22713 } 22714 if (handle === "w" || handle === "nw" || handle === "sw") { 22715 edgeLeft = Math.max( 22716 bounds.minX, 22717 Math.min(s2.x + dx, edgeRight - minCropSize.width) 22718 ); 22719 } 22720 if (handle === "e" || handle === "ne" || handle === "se") { 22721 edgeRight = Math.max( 22722 edgeLeft + minCropSize.width, 22723 Math.min(s2.x + s2.width + dx, bounds.maxX) 22724 ); 22725 } 22726 return { 22727 x: edgeLeft, 22728 y: edgeTop, 22729 width: edgeRight - edgeLeft, 22730 height: edgeBottom - edgeTop 22731 }; 22732 } 22733 function computeLockedResizeRect(drag2, clientX, clientY, imageSize, bounds, normalizedRatio, minCropSize = DEFAULT_MIN_CROP_SIZE) { 22734 if (normalizedRatio <= 0 || imageSize.width <= 0 || imageSize.height <= 0) { 22735 return { ...drag2.startRect }; 22736 } 22737 const dx = (clientX - drag2.startX) / imageSize.width; 22738 const dy = (clientY - drag2.startY) / imageSize.height; 22739 const s2 = drag2.startRect; 22740 const handle = drag2.handle; 22741 const anchorX = handle === "nw" || handle === "sw" ? s2.x + s2.width : s2.x; 22742 const anchorY = handle === "nw" || handle === "ne" ? s2.y + s2.height : s2.y; 22743 const dirX = handle === "nw" || handle === "sw" ? -1 : 1; 22744 const dirY = handle === "nw" || handle === "ne" ? -1 : 1; 22745 const draggedX = (handle === "nw" || handle === "sw" ? s2.x : s2.x + s2.width) + dx; 22746 const draggedY = (handle === "nw" || handle === "ne" ? s2.y : s2.y + s2.height) + dy; 22747 let distW = (draggedX - anchorX) * dirX; 22748 let distH = (draggedY - anchorY) * dirY; 22749 const minDistW = Math.max( 22750 minCropSize.width, 22751 minCropSize.height * normalizedRatio 22752 ); 22753 const minDistH = minDistW / normalizedRatio; 22754 distW = Math.max(distW, minDistW); 22755 distH = Math.max(distH, minDistH); 22756 const pixelDistW = distW * imageSize.width; 22757 const pixelDistH = distH * imageSize.height; 22758 const pixelRatio = normalizedRatio * imageSize.width / imageSize.height; 22759 if (pixelDistW / pixelDistH > pixelRatio) { 22760 distH = distW / normalizedRatio; 22761 } else { 22762 distW = distH * normalizedRatio; 22763 } 22764 const maxW = dirX > 0 ? bounds.maxX - anchorX : anchorX - bounds.minX; 22765 const maxH = dirY > 0 ? bounds.maxY - anchorY : anchorY - bounds.minY; 22766 if (distW > maxW) { 22767 distW = maxW; 22768 distH = distW / normalizedRatio; 22769 } 22770 if (distH > maxH) { 22771 distH = maxH; 22772 distW = distH * normalizedRatio; 22773 } 22774 distW = Math.max(distW, minDistW); 22775 distH = Math.max(distH, minDistH); 22776 const newX = dirX > 0 ? anchorX : anchorX - distW; 22777 const newY = dirY > 0 ? anchorY : anchorY - distH; 22778 return { x: newX, y: newY, width: distW, height: distH }; 22779 } 22780 function computeShiftLockedResizeRect(drag2, clientX, clientY, imageSize, bounds, minCropSize = DEFAULT_MIN_CROP_SIZE) { 22781 const s2 = drag2.startRect; 22782 const pixelW = s2.width * imageSize.width; 22783 const pixelH = s2.height * imageSize.height; 22784 if (pixelH <= 0 || pixelW <= 0) { 22785 return computeFreeResizeRect( 22786 drag2, 22787 clientX, 22788 clientY, 22789 imageSize, 22790 bounds, 22791 minCropSize 22792 ); 22793 } 22794 const normalizedRatio = s2.width / s2.height; 22795 const handle = drag2.handle; 22796 if (handle === "nw" || handle === "ne" || handle === "sw" || handle === "se") { 22797 return computeLockedResizeRect( 22798 drag2, 22799 clientX, 22800 clientY, 22801 imageSize, 22802 bounds, 22803 normalizedRatio, 22804 minCropSize 22805 ); 22806 } 22807 const free = computeFreeResizeRect( 22808 drag2, 22809 clientX, 22810 clientY, 22811 imageSize, 22812 bounds, 22813 minCropSize 22814 ); 22815 if (handle === "n" || handle === "s") { 22816 let newHeight2 = free.height; 22817 let newWidth2 = newHeight2 * normalizedRatio; 22818 const centerX = s2.x + s2.width / 2; 22819 const maxWidth = Math.min(centerX - bounds.minX, bounds.maxX - centerX) * 2; 22820 if (newWidth2 > maxWidth) { 22821 newWidth2 = maxWidth; 22822 newHeight2 = newWidth2 / normalizedRatio; 22823 } 22824 const minHeight = Math.max( 22825 minCropSize.height, 22826 minCropSize.width / normalizedRatio 22827 ); 22828 if (newHeight2 < minHeight) { 22829 newHeight2 = minHeight; 22830 newWidth2 = newHeight2 * normalizedRatio; 22831 } 22832 const newY = handle === "n" ? s2.y + s2.height - newHeight2 : s2.y; 22833 return { 22834 x: centerX - newWidth2 / 2, 22835 y: newY, 22836 width: newWidth2, 22837 height: newHeight2 22838 }; 22839 } 22840 let newWidth = free.width; 22841 let newHeight = newWidth / normalizedRatio; 22842 const centerY = s2.y + s2.height / 2; 22843 const maxHeight = Math.min(centerY - bounds.minY, bounds.maxY - centerY) * 2; 22844 if (newHeight > maxHeight) { 22845 newHeight = maxHeight; 22846 newWidth = newHeight * normalizedRatio; 22847 } 22848 const minWidth = Math.max( 22849 minCropSize.width, 22850 minCropSize.height * normalizedRatio 22851 ); 22852 if (newWidth < minWidth) { 22853 newWidth = minWidth; 22854 newHeight = newWidth / normalizedRatio; 22855 } 22856 const newX = handle === "w" ? s2.x + s2.width - newWidth : s2.x; 22857 return { 22858 x: newX, 22859 y: centerY - newHeight / 2, 22860 width: newWidth, 22861 height: newHeight 22862 }; 22863 } 22864 22865 // packages/media-editor/build-module/image-editor/react/visually-hidden-style.mjs 22866 var VISUALLY_HIDDEN_STYLE = { 22867 position: "absolute", 22868 width: 1, 22869 height: 1, 22870 padding: 0, 22871 margin: -1, 22872 overflow: "hidden", 22873 clip: "rect(0, 0, 0, 0)", 22874 whiteSpace: "nowrap", 22875 border: 0 22876 }; 22877 22878 // packages/media-editor/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs 22879 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1); 22880 var CORNER_POSITIONS = ["nw", "ne", "se", "sw"]; 22881 var ALL_POSITIONS = [ 22882 "nw", 22883 "n", 22884 "ne", 22885 "e", 22886 "se", 22887 "s", 22888 "sw", 22889 "w" 22890 ]; 22891 function getHandleLabel(pos) { 22892 switch (pos) { 22893 case "n": 22894 return (0, import_i18n29.__)("Resize top edge"); 22895 case "s": 22896 return (0, import_i18n29.__)("Resize bottom edge"); 22897 case "e": 22898 return (0, import_i18n29.__)("Resize right edge"); 22899 case "w": 22900 return (0, import_i18n29.__)("Resize left edge"); 22901 case "nw": 22902 return (0, import_i18n29.__)("Resize top-left corner"); 22903 case "ne": 22904 return (0, import_i18n29.__)("Resize top-right corner"); 22905 case "sw": 22906 return (0, import_i18n29.__)("Resize bottom-left corner"); 22907 case "se": 22908 return (0, import_i18n29.__)("Resize bottom-right corner"); 22909 } 22910 } 22911 var KEYBOARD_SETTLE_DELAY = 500; 22912 function RectangleStencil({ 22913 cropRect, 22914 containerSize, 22915 imageSize, 22916 onCropChange, 22917 onResizeStart, 22918 onResizeEnd, 22919 aspectRatio, 22920 freeformCrop = false, 22921 stencilTransition, 22922 cropBounds, 22923 onEscape, 22924 minCropSize 22925 }) { 22926 const boundsMinX = cropBounds?.minX ?? 0; 22927 const boundsMinY = cropBounds?.minY ?? 0; 22928 const boundsMaxX = cropBounds?.maxX ?? 1; 22929 const boundsMaxY = cropBounds?.maxY ?? 1; 22930 const bounds = (0, import_element73.useMemo)( 22931 () => ({ 22932 minX: boundsMinX, 22933 minY: boundsMinY, 22934 maxX: boundsMaxX, 22935 maxY: boundsMaxY 22936 }), 22937 [boundsMinX, boundsMinY, boundsMaxX, boundsMaxY] 22938 ); 22939 const keyboardSettleTimerRef = (0, import_element73.useRef)(void 0); 22940 const keyboardResizeActiveRef = (0, import_element73.useRef)(false); 22941 const resizeHandleDescriptionId = (0, import_element73.useId)(); 22942 const hasLockedRatio = !!(aspectRatio && aspectRatio > 0); 22943 (0, import_element73.useEffect)(() => { 22944 return () => { 22945 clearTimeout(keyboardSettleTimerRef.current); 22946 keyboardResizeActiveRef.current = false; 22947 }; 22948 }, []); 22949 const latestHandlersRef = (0, import_element73.useRef)(null); 22950 const normalizedRatio = (0, import_element73.useMemo)(() => { 22951 if (!hasLockedRatio || imageSize.width === 0) { 22952 return 0; 22953 } 22954 return aspectRatio * imageSize.height / imageSize.width; 22955 }, [aspectRatio, hasLockedRatio, imageSize.width, imageSize.height]); 22956 const offsetX = (containerSize.width - imageSize.width) / 2; 22957 const offsetY = (containerSize.height - imageSize.height) / 2; 22958 const left = offsetX + cropRect.x * imageSize.width; 22959 const top = offsetY + cropRect.y * imageSize.height; 22960 const width = cropRect.width * imageSize.width; 22961 const height = cropRect.height * imageSize.height; 22962 const handlePointerDown = (0, import_element73.useCallback)( 22963 (handle, event) => { 22964 if (event.button !== 0) { 22965 return; 22966 } 22967 event.preventDefault(); 22968 event.stopPropagation(); 22969 const ownerDoc = event.currentTarget.ownerDocument; 22970 if (ownerDoc.activeElement instanceof HTMLElement) { 22971 ownerDoc.activeElement.blur(); 22972 } 22973 const el = event.currentTarget; 22974 el.setPointerCapture(event.pointerId); 22975 const drag2 = { 22976 handle, 22977 startX: event.clientX, 22978 startY: event.clientY, 22979 startRect: { ...cropRect } 22980 }; 22981 let rafId = 0; 22982 let latestX = event.clientX; 22983 let latestY = event.clientY; 22984 let latestShift = event.shiftKey; 22985 const onMove = (e2) => { 22986 const pe = e2; 22987 latestX = pe.clientX; 22988 latestY = pe.clientY; 22989 latestShift = pe.shiftKey; 22990 if (rafId) { 22991 return; 22992 } 22993 rafId = requestAnimationFrame(() => { 22994 rafId = 0; 22995 const h2 = latestHandlersRef.current; 22996 if (!h2) { 22997 return; 22998 } 22999 let newRect; 23000 if (h2.hasLockedRatio) { 23001 newRect = h2.computeLockedRect(drag2, latestX, latestY); 23002 } else if (latestShift) { 23003 newRect = h2.computeShiftLockedRect( 23004 drag2, 23005 latestX, 23006 latestY 23007 ); 23008 } else { 23009 newRect = h2.computeFreeRect(drag2, latestX, latestY); 23010 } 23011 h2.onCropChange(newRect); 23012 }); 23013 }; 23014 let ended = false; 23015 const onEnd = () => { 23016 if (ended) { 23017 return; 23018 } 23019 ended = true; 23020 if (rafId) { 23021 cancelAnimationFrame(rafId); 23022 rafId = 0; 23023 } 23024 el.removeEventListener("pointermove", onMove); 23025 el.removeEventListener("pointerup", onEnd); 23026 el.removeEventListener("lostpointercapture", onEnd); 23027 latestHandlersRef.current?.onResizeEnd?.(); 23028 el.focus({ preventScroll: true }); 23029 }; 23030 el.addEventListener("pointermove", onMove); 23031 el.addEventListener("pointerup", onEnd); 23032 el.addEventListener("lostpointercapture", onEnd); 23033 onResizeStart?.(handle); 23034 clearTimeout(keyboardSettleTimerRef.current); 23035 keyboardResizeActiveRef.current = false; 23036 }, 23037 [cropRect, onResizeStart] 23038 ); 23039 const computeFreeRect = (0, import_element73.useCallback)( 23040 (drag2, clientX, clientY) => computeFreeResizeRect( 23041 drag2, 23042 clientX, 23043 clientY, 23044 imageSize, 23045 bounds, 23046 minCropSize 23047 ), 23048 [imageSize, bounds, minCropSize] 23049 ); 23050 const computeLockedRect = (0, import_element73.useCallback)( 23051 (drag2, clientX, clientY) => computeLockedResizeRect( 23052 drag2, 23053 clientX, 23054 clientY, 23055 imageSize, 23056 bounds, 23057 normalizedRatio, 23058 minCropSize 23059 ), 23060 [imageSize, bounds, normalizedRatio, minCropSize] 23061 ); 23062 const computeShiftLockedRect = (0, import_element73.useCallback)( 23063 (drag2, clientX, clientY) => computeShiftLockedResizeRect( 23064 drag2, 23065 clientX, 23066 clientY, 23067 imageSize, 23068 bounds, 23069 minCropSize 23070 ), 23071 [imageSize, bounds, minCropSize] 23072 ); 23073 latestHandlersRef.current = { 23074 hasLockedRatio, 23075 computeLockedRect, 23076 computeFreeRect, 23077 computeShiftLockedRect, 23078 onCropChange, 23079 onResizeEnd 23080 }; 23081 const handleKeyDown = (0, import_element73.useCallback)( 23082 (handle, event) => { 23083 const key = event.key; 23084 if (key === "Escape") { 23085 event.preventDefault(); 23086 event.stopPropagation(); 23087 onEscape?.(); 23088 return; 23089 } 23090 if (key !== "ArrowUp" && key !== "ArrowDown" && key !== "ArrowLeft" && key !== "ArrowRight") { 23091 return; 23092 } 23093 event.preventDefault(); 23094 event.stopPropagation(); 23095 if (!keyboardResizeActiveRef.current) { 23096 keyboardResizeActiveRef.current = true; 23097 onResizeStart?.(handle); 23098 } 23099 const scheduleKeyboardResizeEnd = () => { 23100 clearTimeout(keyboardSettleTimerRef.current); 23101 keyboardSettleTimerRef.current = setTimeout(() => { 23102 keyboardResizeActiveRef.current = false; 23103 onResizeEnd?.(); 23104 }, KEYBOARD_SETTLE_DELAY); 23105 }; 23106 const step = event.shiftKey ? DEFAULT_KEYBOARD_STEP * KEYBOARD_SHIFT_STEP_MULTIPLIER : DEFAULT_KEYBOARD_STEP; 23107 let dx = 0; 23108 let dy = 0; 23109 if (key === "ArrowLeft") { 23110 dx = -step; 23111 } 23112 if (key === "ArrowRight") { 23113 dx = step; 23114 } 23115 if (key === "ArrowUp") { 23116 dy = -step; 23117 } 23118 if (key === "ArrowDown") { 23119 dy = step; 23120 } 23121 if (hasLockedRatio) { 23122 const syntheticDrag = { 23123 handle, 23124 startX: 0, 23125 startY: 0, 23126 startRect: { ...cropRect } 23127 }; 23128 const clientX = dx * imageSize.width; 23129 const clientY = dy * imageSize.height; 23130 onCropChange( 23131 computeLockedRect(syntheticDrag, clientX, clientY) 23132 ); 23133 scheduleKeyboardResizeEnd(); 23134 } else { 23135 const syntheticDrag = { 23136 handle, 23137 startX: 0, 23138 startY: 0, 23139 startRect: { ...cropRect } 23140 }; 23141 const clientX = dx * imageSize.width; 23142 const clientY = dy * imageSize.height; 23143 onCropChange( 23144 computeFreeRect(syntheticDrag, clientX, clientY) 23145 ); 23146 scheduleKeyboardResizeEnd(); 23147 } 23148 }, 23149 [ 23150 cropRect, 23151 hasLockedRatio, 23152 imageSize.width, 23153 imageSize.height, 23154 computeLockedRect, 23155 computeFreeRect, 23156 onCropChange, 23157 onResizeStart, 23158 onResizeEnd, 23159 onEscape 23160 ] 23161 ); 23162 if (containerSize.width === 0 || containerSize.height === 0) { 23163 return null; 23164 } 23165 const handles = hasLockedRatio ? CORNER_POSITIONS : ALL_POSITIONS; 23166 return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)( 23167 "div", 23168 { 23169 className: "wp-media-editor-image-editor__stencil", 23170 style: { 23171 left, 23172 top, 23173 width, 23174 height, 23175 transition: stencilTransition 23176 }, 23177 children: [ 23178 freeformCrop && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 23179 "div", 23180 { 23181 id: resizeHandleDescriptionId, 23182 style: VISUALLY_HIDDEN_STYLE, 23183 children: (0, import_i18n29.__)( 23184 "Use arrow keys to resize the crop area. Hold Shift for larger steps." 23185 ) 23186 } 23187 ), 23188 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 23189 "div", 23190 { 23191 className: "wp-media-editor-image-editor__stencil-rect", 23192 style: { 23193 width: "100%", 23194 height: "100%", 23195 top: 0, 23196 left: 0 23197 } 23198 } 23199 ), 23200 freeformCrop && handles.map((pos) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 23201 "button", 23202 { 23203 type: "button", 23204 className: `wp-media-editor-image-editor__handle wp-media-editor-image-editor__handle--$pos}`, 23205 onPointerDown: (event) => handlePointerDown(pos, event), 23206 onTouchStart: (event) => event.stopPropagation(), 23207 onKeyDown: (event) => handleKeyDown(pos, event), 23208 "aria-label": getHandleLabel(pos), 23209 "aria-describedby": resizeHandleDescriptionId 23210 }, 23211 pos 23212 )) 23213 ] 23214 } 23215 ); 23216 } 23217 23218 // packages/media-editor/build-module/image-editor/react/components/overlays/dimming-overlay.mjs 23219 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1); 23220 function DimmingOverlay({ 23221 cropRect, 23222 containerSize, 23223 imageSize, 23224 transition 23225 }) { 23226 if (containerSize.width === 0 || containerSize.height === 0) { 23227 return null; 23228 } 23229 const offsetX = (containerSize.width - imageSize.width) / 2; 23230 const offsetY = (containerSize.height - imageSize.height) / 2; 23231 const left = offsetX + cropRect.x * imageSize.width; 23232 const top = offsetY + cropRect.y * imageSize.height; 23233 const width = cropRect.width * imageSize.width; 23234 const height = cropRect.height * imageSize.height; 23235 const composedTransition = transition ? `$transition}, box-shadow 0.15s ease` : void 0; 23236 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 23237 "div", 23238 { 23239 className: "wp-media-editor-image-editor__dimming", 23240 style: { 23241 left, 23242 top, 23243 width, 23244 height, 23245 transition: composedTransition 23246 } 23247 } 23248 ); 23249 } 23250 23251 // packages/media-editor/build-module/image-editor/react/components/overlays/grid-overlay.mjs 23252 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1); 23253 function GridOverlay({ 23254 cropRect, 23255 containerSize, 23256 imageSize 23257 }) { 23258 if (containerSize.width === 0 || containerSize.height === 0) { 23259 return null; 23260 } 23261 const offsetX = (containerSize.width - imageSize.width) / 2; 23262 const offsetY = (containerSize.height - imageSize.height) / 2; 23263 const left = offsetX + cropRect.x * imageSize.width; 23264 const top = offsetY + cropRect.y * imageSize.height; 23265 const width = cropRect.width * imageSize.width; 23266 const height = cropRect.height * imageSize.height; 23267 const thirdW = width / 3; 23268 const thirdH = height / 3; 23269 return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)( 23270 "div", 23271 { 23272 className: "wp-media-editor-image-editor__grid", 23273 "data-testid": "cropper-grid", 23274 style: { 23275 left, 23276 top, 23277 width, 23278 height 23279 }, 23280 children: [ 23281 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 23282 "div", 23283 { 23284 className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal", 23285 style: { top: thirdH } 23286 } 23287 ), 23288 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 23289 "div", 23290 { 23291 className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal", 23292 style: { top: thirdH * 2 } 23293 } 23294 ), 23295 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 23296 "div", 23297 { 23298 className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical", 23299 style: { left: thirdW } 23300 } 23301 ), 23302 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 23303 "div", 23304 { 23305 className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical", 23306 style: { left: thirdW * 2 } 23307 } 23308 ) 23309 ] 23310 } 23311 ); 23312 } 23313 23314 // packages/media-editor/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs 23315 var import_element74 = __toESM(require_element(), 1); 23316 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1); 23317 var HANDLE_GAP_PX = 12; 23318 var TRANSLATE_PERCENT = { 23319 before: "-100%", 23320 center: "-50%", 23321 after: "0" 23322 }; 23323 var GAP_DIRECTION = { 23324 before: -1, 23325 center: 0, 23326 after: 1 23327 }; 23328 var OPPOSITE_SIDE = { 23329 before: "after", 23330 center: "center", 23331 after: "before" 23332 }; 23333 function preferredAnchor(handle) { 23334 let x2 = "center"; 23335 if (handle.includes("w")) { 23336 x2 = "before"; 23337 } else if (handle.includes("e")) { 23338 x2 = "after"; 23339 } 23340 let y2 = "center"; 23341 if (handle.includes("n")) { 23342 y2 = "before"; 23343 } else if (handle.includes("s")) { 23344 y2 = "after"; 23345 } 23346 return { x: x2, y: y2 }; 23347 } 23348 function sideStart(side, handlePos, length2) { 23349 if (side === "before") { 23350 return handlePos - HANDLE_GAP_PX - length2; 23351 } 23352 if (side === "after") { 23353 return handlePos + HANDLE_GAP_PX; 23354 } 23355 return handlePos - length2 / 2; 23356 } 23357 function fittingSide(preferred, handlePos, length2, containerLength) { 23358 const fits = (side) => { 23359 const start = sideStart(side, handlePos, length2); 23360 return start >= 0 && start + length2 <= containerLength; 23361 }; 23362 if (fits(preferred)) { 23363 return preferred; 23364 } 23365 const opposite = OPPOSITE_SIDE[preferred]; 23366 if (opposite !== preferred && fits(opposite)) { 23367 return opposite; 23368 } 23369 if (preferred !== "center" && fits("center")) { 23370 return "center"; 23371 } 23372 const overflow = (side) => { 23373 const start = sideStart(side, handlePos, length2); 23374 return Math.max(0, -start) + Math.max(0, start + length2 - containerLength); 23375 }; 23376 const candidates = [preferred, opposite, "center"]; 23377 return candidates.reduce( 23378 (best, side) => overflow(side) < overflow(best) ? side : best 23379 ); 23380 } 23381 function DimensionsOverlay({ 23382 cropRect, 23383 containerSize, 23384 imageSize, 23385 activeHandle, 23386 outputWidth, 23387 outputHeight 23388 }) { 23389 const tooltipRef = (0, import_element74.useRef)(null); 23390 const [tooltipSize, setTooltipSize] = (0, import_element74.useState)(null); 23391 (0, import_element74.useLayoutEffect)(() => { 23392 if (!tooltipRef.current) { 23393 return; 23394 } 23395 const rect = tooltipRef.current.getBoundingClientRect(); 23396 setTooltipSize((prev) => { 23397 if (prev && prev.width === rect.width && prev.height === rect.height) { 23398 return prev; 23399 } 23400 return { width: rect.width, height: rect.height }; 23401 }); 23402 }, [outputWidth, outputHeight]); 23403 if (!activeHandle || containerSize.width === 0 || containerSize.height === 0) { 23404 return null; 23405 } 23406 const offsetX = (containerSize.width - imageSize.width) / 2; 23407 const offsetY = (containerSize.height - imageSize.height) / 2; 23408 const left = offsetX + cropRect.x * imageSize.width; 23409 const top = offsetY + cropRect.y * imageSize.height; 23410 const width = cropRect.width * imageSize.width; 23411 const height = cropRect.height * imageSize.height; 23412 let handleX = left + width / 2; 23413 if (activeHandle.includes("w")) { 23414 handleX = left; 23415 } else if (activeHandle.includes("e")) { 23416 handleX = left + width; 23417 } 23418 let handleY = top + height / 2; 23419 if (activeHandle.includes("n")) { 23420 handleY = top; 23421 } else if (activeHandle.includes("s")) { 23422 handleY = top + height; 23423 } 23424 const preferred = preferredAnchor(activeHandle); 23425 const anchor = tooltipSize ? { 23426 x: fittingSide( 23427 preferred.x, 23428 handleX, 23429 tooltipSize.width, 23430 containerSize.width 23431 ), 23432 y: fittingSide( 23433 preferred.y, 23434 handleY, 23435 tooltipSize.height, 23436 containerSize.height 23437 ) 23438 } : preferred; 23439 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 23440 "div", 23441 { 23442 ref: tooltipRef, 23443 className: "wp-media-editor-image-editor__dimensions-tooltip", 23444 "data-testid": "cropper-dimensions-tooltip", 23445 style: { 23446 left: handleX + GAP_DIRECTION[anchor.x] * HANDLE_GAP_PX, 23447 top: handleY + GAP_DIRECTION[anchor.y] * HANDLE_GAP_PX, 23448 transform: `translate($TRANSLATE_PERCENT[anchor.x]}, $TRANSLATE_PERCENT[anchor.y]})` 23449 }, 23450 "aria-hidden": "true", 23451 children: `W: $Math.round(outputWidth)}px H: $Math.round( 23452 outputHeight 23453 )}px` 23454 } 23455 ); 23456 } 23457 23458 // packages/media-editor/build-module/image-editor/core/source-region.mjs 23459 function getSourceRegion(state, imageSize) { 23460 const safeState = sanitizeCropperState(state); 23461 if (!isValidSize(imageSize)) { 23462 return { 23463 x: 0, 23464 y: 0, 23465 width: 0, 23466 height: 0, 23467 rotation: safeState.rotation, 23468 flip: { ...safeState.flip }, 23469 zoom: safeState.zoom 23470 }; 23471 } 23472 const syntheticContainer = { width: 1e3, height: 1e3 }; 23473 const camera = createCamera(safeState, syntheticContainer, imageSize); 23474 const inv = mat2d_exports.create(); 23475 mat2d_exports.invert(inv, camera); 23476 const baseCamera = createCamera( 23477 { ...safeState, pan: { x: 0, y: 0 }, zoom: 1 }, 23478 syntheticContainer, 23479 imageSize 23480 ); 23481 const visibleBounds = getVisibleBounds(baseCamera); 23482 const cropRect = safeState.cropRect; 23483 const cropCenterScreenX = visibleBounds.left + (cropRect.x + cropRect.width / 2) * visibleBounds.width; 23484 const cropCenterScreenY = visibleBounds.top + (cropRect.y + cropRect.height / 2) * visibleBounds.height; 23485 const srcCenter = vec2_exports.create(); 23486 vec2_exports.transformMat2d( 23487 srcCenter, 23488 [cropCenterScreenX, cropCenterScreenY], 23489 inv 23490 ); 23491 const snapRotation = Math.round(safeState.rotation / 90) * 90; 23492 const { width: rotW, height: rotH } = getRotatedBBox( 23493 imageSize.width, 23494 imageSize.height, 23495 snapRotation 23496 ); 23497 const sourceW = cropRect.width * rotW / safeState.zoom; 23498 const sourceH = cropRect.height * rotH / safeState.zoom; 23499 return { 23500 x: srcCenter[0] * imageSize.width - sourceW / 2, 23501 y: srcCenter[1] * imageSize.height - sourceH / 2, 23502 width: sourceW, 23503 height: sourceH, 23504 rotation: safeState.rotation, 23505 flip: { ...safeState.flip }, 23506 zoom: safeState.zoom 23507 }; 23508 } 23509 23510 // packages/media-editor/build-module/image-editor/react/components/viewport-provider.mjs 23511 var import_element76 = __toESM(require_element(), 1); 23512 23513 // packages/media-editor/build-module/image-editor/react/hooks/use-viewport-state.mjs 23514 var import_element75 = __toESM(require_element(), 1); 23515 23516 // packages/media-editor/build-module/image-editor/core/viewport-state.mjs 23517 var DEFAULT_VIEWPORT_STATE = { 23518 zoom: 1, 23519 pan: { x: 0, y: 0 } 23520 }; 23521 function viewportReducer(state, action) { 23522 switch (action.type) { 23523 case "SET_VIEWPORT_ZOOM": { 23524 const zoom = Math.min(4, Math.max(0.1, action.payload)); 23525 return zoom === state.zoom ? state : { ...state, zoom }; 23526 } 23527 case "SET_VIEWPORT_PAN": { 23528 const { x: x2, y: y2 } = action.payload; 23529 return x2 === state.pan.x && y2 === state.pan.y ? state : { ...state, pan: action.payload }; 23530 } 23531 case "RESET_VIEWPORT": 23532 return state.zoom === DEFAULT_VIEWPORT_STATE.zoom && state.pan.x === DEFAULT_VIEWPORT_STATE.pan.x && state.pan.y === DEFAULT_VIEWPORT_STATE.pan.y ? state : DEFAULT_VIEWPORT_STATE; 23533 } 23534 } 23535 23536 // packages/media-editor/build-module/image-editor/react/hooks/use-viewport-state.mjs 23537 function useViewportState() { 23538 const [viewport, dispatch] = (0, import_element75.useReducer)( 23539 viewportReducer, 23540 DEFAULT_VIEWPORT_STATE 23541 ); 23542 const setViewportZoom = (0, import_element75.useCallback)((zoom) => { 23543 dispatch({ type: "SET_VIEWPORT_ZOOM", payload: zoom }); 23544 }, []); 23545 const setViewportPan = (0, import_element75.useCallback)((pan) => { 23546 dispatch({ type: "SET_VIEWPORT_PAN", payload: pan }); 23547 }, []); 23548 const resetViewport = (0, import_element75.useCallback)(() => { 23549 dispatch({ type: "RESET_VIEWPORT" }); 23550 }, []); 23551 return (0, import_element75.useMemo)( 23552 () => ({ viewport, setViewportZoom, setViewportPan, resetViewport }), 23553 [viewport, setViewportZoom, setViewportPan, resetViewport] 23554 ); 23555 } 23556 23557 // packages/media-editor/build-module/image-editor/react/components/viewport-provider.mjs 23558 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1); 23559 var ViewportContext = (0, import_element76.createContext)(null); 23560 function ViewportProvider({ 23561 children 23562 }) { 23563 const viewportState = useViewportState(); 23564 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ViewportContext.Provider, { value: viewportState, children }); 23565 } 23566 function useViewport() { 23567 const context = (0, import_element76.useContext)(ViewportContext); 23568 if (!context) { 23569 throw new Error( 23570 "useViewport must be used within a ViewportProvider." 23571 ); 23572 } 23573 return context; 23574 } 23575 23576 // packages/media-editor/build-module/image-editor/react/components/cropper.mjs 23577 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1); 23578 var CROP_RECT_EPSILON = 1e-6; 23579 function CropperInner({ 23580 src, 23581 controller, 23582 stencil: StencilComponent = RectangleStencil, 23583 showGrid = false, 23584 isPlacementActive = false, 23585 showDimming = true, 23586 showDimensions = true, 23587 minZoom, 23588 maxZoom, 23589 aspectRatio, 23590 freeformCrop = false, 23591 focusOnMount = false, 23592 onImageLoaded, 23593 onStateChange, 23594 onGestureStart, 23595 onGestureEnd, 23596 className 23597 }, ref) { 23598 const { 23599 state, 23600 setImage, 23601 setCropRect, 23602 settleCrop, 23603 setVisualSize, 23604 adjustCropRectForViewport 23605 } = controller; 23606 const { 23607 viewport: viewportState, 23608 setViewportPan, 23609 resetViewport 23610 } = useViewport(); 23611 const canvasRef = (0, import_element77.useRef)(null); 23612 const cropAreaDescriptionId = (0, import_element77.useId)(); 23613 const [isCropAreaFocused, setIsCropAreaFocused] = (0, import_element77.useState)(focusOnMount); 23614 const [isFocusVisible, setIsFocusVisible] = (0, import_element77.useState)(false); 23615 const [canvasSize, setCanvasSize] = (0, import_element77.useState)({ 23616 width: 0, 23617 height: 0 23618 }); 23619 (0, import_element77.useLayoutEffect)(() => { 23620 if (focusOnMount) { 23621 canvasRef.current?.focus({ preventScroll: true }); 23622 } 23623 }, [focusOnMount]); 23624 const handleCropAreaFocus = (0, import_element77.useCallback)( 23625 (event) => { 23626 const target = event.target; 23627 if (target === event.currentTarget) { 23628 setIsCropAreaFocused(true); 23629 } 23630 if (event.relatedTarget !== null && target.matches(":focus-visible")) { 23631 setIsFocusVisible(true); 23632 } 23633 }, 23634 [] 23635 ); 23636 const handleCropAreaBlur = (0, import_element77.useCallback)( 23637 (event) => { 23638 if (event.target === event.currentTarget) { 23639 setIsCropAreaFocused(false); 23640 } 23641 if (!event.currentTarget.contains( 23642 event.relatedTarget 23643 )) { 23644 setIsFocusVisible(false); 23645 } 23646 }, 23647 [] 23648 ); 23649 (0, import_element77.useEffect)(() => { 23650 const element = canvasRef.current; 23651 if (!element) { 23652 return; 23653 } 23654 const observer = new ResizeObserver((entries) => { 23655 for (const entry of entries) { 23656 const { width, height } = entry.contentRect; 23657 setCanvasSize((prev) => { 23658 if (prev.width === width && prev.height === height) { 23659 return prev; 23660 } 23661 return { width, height }; 23662 }); 23663 } 23664 }); 23665 observer.observe(element); 23666 return () => { 23667 observer.disconnect(); 23668 }; 23669 }, []); 23670 (0, import_element77.useEffect)(() => { 23671 onStateChange?.(state); 23672 }, [state, onStateChange]); 23673 const ariaMessage = useAriaAnnouncer(state); 23674 const naturalWidth = state.image?.naturalWidth ?? 0; 23675 const naturalHeight = state.image?.naturalHeight ?? 0; 23676 const { elementSize, visualSize } = (0, import_element77.useMemo)( 23677 () => getImageFit( 23678 canvasSize, 23679 { width: naturalWidth, height: naturalHeight }, 23680 state.rotation 23681 ), 23682 [canvasSize, naturalWidth, naturalHeight, state.rotation] 23683 ); 23684 const minCropSize = (0, import_element77.useMemo)(() => { 23685 if (naturalWidth <= 0 || naturalHeight <= 0) { 23686 return void 0; 23687 } 23688 const snapRotation = Math.round(state.rotation / 90) * 90; 23689 const bbox = getRotatedBBox( 23690 naturalWidth, 23691 naturalHeight, 23692 snapRotation 23693 ); 23694 return { 23695 width: Math.min(1, MIN_CROP_PIXELS * state.zoom / bbox.width), 23696 height: Math.min( 23697 1, 23698 MIN_CROP_PIXELS * state.zoom / bbox.height 23699 ) 23700 }; 23701 }, [naturalWidth, naturalHeight, state.rotation, state.zoom]); 23702 (0, import_element77.useEffect)(() => { 23703 setVisualSize(visualSize); 23704 }, [visualSize, setVisualSize]); 23705 (0, import_element77.useEffect)(() => { 23706 if (freeformCrop || visualSize.width === 0 || visualSize.height === 0 || !aspectRatio || aspectRatio <= 0) { 23707 return; 23708 } 23709 const rect = computeInscribedRect(aspectRatio, visualSize); 23710 const current = state.cropRect; 23711 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) { 23712 return; 23713 } 23714 adjustCropRectForViewport(rect); 23715 }, [ 23716 freeformCrop, 23717 aspectRatio, 23718 visualSize, 23719 adjustCropRectForViewport, 23720 state.cropRect 23721 ]); 23722 const prevAspectRatioRef = (0, import_element77.useRef)(aspectRatio); 23723 (0, import_element77.useEffect)(() => { 23724 if (prevAspectRatioRef.current === aspectRatio) { 23725 return; 23726 } 23727 prevAspectRatioRef.current = aspectRatio; 23728 if (!freeformCrop || visualSize.width === 0 || visualSize.height === 0 || !aspectRatio || aspectRatio <= 0) { 23729 return; 23730 } 23731 const rect = computeInscribedRect(aspectRatio, visualSize); 23732 const current = state.cropRect; 23733 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) { 23734 return; 23735 } 23736 adjustCropRectForViewport(rect); 23737 }, [ 23738 aspectRatio, 23739 freeformCrop, 23740 visualSize, 23741 adjustCropRectForViewport, 23742 state.cropRect 23743 ]); 23744 const cropBounds = (0, import_element77.useMemo)(() => { 23745 if (!state.image || elementSize.width === 0) { 23746 return void 0; 23747 } 23748 return getImageCropBounds(state, elementSize, visualSize); 23749 }, [state, elementSize, visualSize]); 23750 const effectiveMinZoom = minZoom !== void 0 ? minZoom : getMinZoom(state); 23751 const [isResizing, setIsResizing] = (0, import_element77.useState)(false); 23752 const isResizingRef = (0, import_element77.useRef)(false); 23753 const isSettlingRef = (0, import_element77.useRef)(false); 23754 const [activeHandle, setActiveHandle] = (0, import_element77.useState)( 23755 null 23756 ); 23757 const { 23758 handlers, 23759 onWheelNative, 23760 isDragging, 23761 isZooming, 23762 isPlacementActive: isInteractionPlacementActive 23763 } = useInteraction(state, controller, canvasSize, visualSize, { 23764 minZoom: effectiveMinZoom, 23765 maxZoom, 23766 onGestureStart, 23767 onGestureEnd 23768 }); 23769 const canvasHandlers = { 23770 ...handlers, 23771 onPointerDownCapture: () => { 23772 setIsFocusVisible(false); 23773 }, 23774 onKeyDownCapture: (event) => { 23775 if (!["Shift", "Control", "Alt", "Meta"].includes(event.key)) { 23776 setIsFocusVisible(true); 23777 } 23778 }, 23779 onPointerDown: (event) => { 23780 handlers.onPointerDown?.(event); 23781 setIsFocusVisible(false); 23782 } 23783 }; 23784 (0, import_element77.useEffect)(() => { 23785 const el = canvasRef.current; 23786 if (!el) { 23787 return; 23788 } 23789 const handleWheel = (event) => { 23790 if (isResizingRef.current || isSettlingRef.current) { 23791 event.preventDefault(); 23792 return; 23793 } 23794 onWheelNative(event); 23795 }; 23796 el.addEventListener("wheel", handleWheel, { 23797 passive: false 23798 }); 23799 return () => { 23800 el.removeEventListener("wheel", handleWheel); 23801 }; 23802 }, [onWheelNative]); 23803 const transformString = useTransformStyle(state, visualSize); 23804 const handleImageLoad = (0, import_element77.useCallback)( 23805 (event) => { 23806 const img = event.currentTarget; 23807 const size4 = { 23808 width: img.naturalWidth, 23809 height: img.naturalHeight 23810 }; 23811 setImage({ 23812 src, 23813 naturalWidth: size4.width, 23814 naturalHeight: size4.height 23815 }); 23816 onImageLoaded?.(size4); 23817 }, 23818 [src, setImage, onImageLoaded] 23819 ); 23820 const handleCropChange = (0, import_element77.useCallback)( 23821 (rect) => { 23822 setCropRect(rect); 23823 if (isResizingRef.current && visualSize.width > 0 && visualSize.height > 0) { 23824 const offsetX = (canvasSize.width - visualSize.width) / 2; 23825 const offsetY = (canvasSize.height - visualSize.height) / 2; 23826 const rightOverflow = Math.max( 23827 0, 23828 offsetX + (rect.x + rect.width) * visualSize.width - canvasSize.width 23829 ); 23830 const leftOverflow = Math.max( 23831 0, 23832 -(offsetX + rect.x * visualSize.width) 23833 ); 23834 const bottomOverflow = Math.max( 23835 0, 23836 offsetY + (rect.y + rect.height) * visualSize.height - canvasSize.height 23837 ); 23838 const topOverflow = Math.max( 23839 0, 23840 -(offsetY + rect.y * visualSize.height) 23841 ); 23842 setViewportPan({ 23843 x: -rightOverflow + leftOverflow, 23844 y: -bottomOverflow + topOverflow 23845 }); 23846 } 23847 }, 23848 [setCropRect, setViewportPan, canvasSize, visualSize] 23849 ); 23850 const [settling, setSettling] = (0, import_element77.useState)(false); 23851 const settleTimerRef = (0, import_element77.useRef)(void 0); 23852 (0, import_element77.useEffect)(() => { 23853 return () => { 23854 clearTimeout(settleTimerRef.current); 23855 }; 23856 }, []); 23857 const isInteractiveGrid = showGrid === "interactive"; 23858 const showInteractiveGrid = isInteractiveGrid && (isInteractionPlacementActive || isResizing || isPlacementActive); 23859 const outputSize = (0, import_element77.useMemo)(() => { 23860 if (!showDimensions || !activeHandle || !state.image) { 23861 return null; 23862 } 23863 const region = getSourceRegion(state, { 23864 width: state.image.naturalWidth, 23865 height: state.image.naturalHeight 23866 }); 23867 return { width: region.width, height: region.height }; 23868 }, [showDimensions, activeHandle, state]); 23869 const handleEscape = (0, import_element77.useCallback)(() => { 23870 setIsFocusVisible(true); 23871 canvasRef.current?.focus({ preventScroll: true }); 23872 }, []); 23873 const handleResizeStart = (0, import_element77.useCallback)( 23874 (handle) => { 23875 isResizingRef.current = true; 23876 setIsResizing(true); 23877 setActiveHandle(handle ?? null); 23878 clearTimeout(settleTimerRef.current); 23879 isSettlingRef.current = false; 23880 setSettling(false); 23881 resetViewport(); 23882 onGestureStart?.(); 23883 }, 23884 [onGestureStart, resetViewport] 23885 ); 23886 const handleResizeEnd = (0, import_element77.useCallback)(() => { 23887 isResizingRef.current = false; 23888 setIsResizing(false); 23889 setActiveHandle(null); 23890 isSettlingRef.current = true; 23891 setSettling(true); 23892 resetViewport(); 23893 settleCrop(); 23894 onGestureEnd?.(); 23895 clearTimeout(settleTimerRef.current); 23896 settleTimerRef.current = setTimeout(() => { 23897 isSettlingRef.current = false; 23898 setSettling(false); 23899 }, 200); 23900 }, [settleCrop, onGestureEnd, resetViewport]); 23901 let imageTransition; 23902 if (settling) { 23903 imageTransition = "transform 200ms ease-out"; 23904 } else if (isZooming) { 23905 imageTransition = "transform 150ms linear"; 23906 } 23907 const settleStencilTransition = settling ? "left 200ms ease-out, top 200ms ease-out, width 200ms ease-out, height 200ms ease-out" : void 0; 23908 const imageStyle = (0, import_element77.useMemo)(() => { 23909 if (elementSize.width === 0 || elementSize.height === 0) { 23910 return {}; 23911 } 23912 const centerX = (canvasSize.width - elementSize.width) / 2; 23913 const centerY = (canvasSize.height - elementSize.height) / 2; 23914 return { 23915 width: elementSize.width, 23916 height: elementSize.height, 23917 maxWidth: elementSize.width, 23918 maxHeight: elementSize.height, 23919 left: centerX, 23920 top: centerY, 23921 transform: transformString, 23922 transition: imageTransition 23923 }; 23924 }, [canvasSize, elementSize, transformString, imageTransition]); 23925 const settleTransition = settling ? "transform 200ms ease-out" : void 0; 23926 const willChange = isResizing || settling ? "transform" : void 0; 23927 let stageStyle; 23928 if (viewportState.pan.x !== 0 || viewportState.pan.y !== 0) { 23929 stageStyle = { 23930 transform: `translate($viewportState.pan.x}px, $viewportState.pan.y}px)`, 23931 transition: settleTransition, 23932 willChange 23933 }; 23934 } else if (settling) { 23935 stageStyle = { transition: settleTransition, willChange }; 23936 } 23937 const setContainerRef = (0, import_element77.useCallback)( 23938 (element) => { 23939 if (typeof ref === "function") { 23940 ref(element); 23941 } else if (ref) { 23942 ref.current = element; 23943 } 23944 }, 23945 [ref] 23946 ); 23947 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 23948 "div", 23949 { 23950 ref: setContainerRef, 23951 className: clsx_default( 23952 "wp-media-editor-image-editor", 23953 isDragging && "wp-media-editor-image-editor--dragging", 23954 className 23955 ), 23956 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)( 23957 "div", 23958 { 23959 ref: canvasRef, 23960 className: clsx_default( 23961 "wp-media-editor-image-editor__canvas", 23962 isInteractiveGrid && "wp-media-editor-image-editor__canvas--grid-interactive", 23963 showInteractiveGrid && "wp-media-editor-image-editor__canvas--show-grid", 23964 settling && "wp-media-editor-image-editor__canvas--settling", 23965 // Marks the cropper as in keyboard-interaction mode. 23966 // CSS uses :focus on the canvas to show the stencil 23967 // outline and :focus on a handle to show its ring, 23968 // so the class applies whenever any cropper element 23969 // has keyboard focus. 23970 isFocusVisible && "wp-media-editor-image-editor__canvas--focus-visible" 23971 ), 23972 tabIndex: 0, 23973 role: "group", 23974 "aria-label": (0, import_i18n30.__)("Crop area"), 23975 "aria-describedby": isCropAreaFocused ? cropAreaDescriptionId : void 0, 23976 onFocus: handleCropAreaFocus, 23977 onBlur: handleCropAreaBlur, 23978 ...canvasHandlers, 23979 children: [ 23980 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 23981 "div", 23982 { 23983 id: cropAreaDescriptionId, 23984 style: VISUALLY_HIDDEN_STYLE, 23985 children: (0, import_i18n30.__)( 23986 "When this area is focused, use arrow keys to move the image and plus or minus to zoom. Tab to resize handles and controls." 23987 ) 23988 } 23989 ), 23990 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)( 23991 "div", 23992 { 23993 className: "wp-media-editor-image-editor__stage", 23994 "data-testid": "cropper-stage", 23995 style: stageStyle, 23996 children: [ 23997 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 23998 "img", 23999 { 24000 className: "wp-media-editor-image-editor__image", 24001 src, 24002 alt: "", 24003 onLoad: handleImageLoad, 24004 style: imageStyle, 24005 draggable: false 24006 } 24007 ), 24008 showDimming && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 24009 DimmingOverlay, 24010 { 24011 cropRect: state.cropRect, 24012 containerSize: canvasSize, 24013 imageSize: visualSize, 24014 transition: settleStencilTransition 24015 } 24016 ), 24017 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 24018 StencilComponent, 24019 { 24020 cropRect: state.cropRect, 24021 containerSize: canvasSize, 24022 imageSize: visualSize, 24023 onCropChange: handleCropChange, 24024 onResizeStart: handleResizeStart, 24025 onResizeEnd: handleResizeEnd, 24026 onEscape: handleEscape, 24027 aspectRatio, 24028 freeformCrop, 24029 stencilTransition: settleStencilTransition, 24030 cropBounds, 24031 minCropSize 24032 } 24033 ), 24034 (showGrid === true || isInteractiveGrid) && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 24035 GridOverlay, 24036 { 24037 cropRect: state.cropRect, 24038 containerSize: canvasSize, 24039 imageSize: visualSize 24040 } 24041 ), 24042 activeHandle && outputSize && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 24043 DimensionsOverlay, 24044 { 24045 cropRect: state.cropRect, 24046 containerSize: canvasSize, 24047 imageSize: visualSize, 24048 activeHandle, 24049 outputWidth: outputSize.width, 24050 outputHeight: outputSize.height 24051 } 24052 ) 24053 ] 24054 } 24055 ), 24056 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 24057 "div", 24058 { 24059 "aria-live": "polite", 24060 "aria-atomic": "true", 24061 className: "wp-media-editor-image-editor__aria-live", 24062 style: VISUALLY_HIDDEN_STYLE, 24063 children: ariaMessage 24064 } 24065 ) 24066 ] 24067 } 24068 ) 24069 } 24070 ); 24071 } 24072 var CropperInnerWithRef = (0, import_element77.forwardRef)( 24073 CropperInner 24074 ); 24075 var Cropper = (0, import_element77.forwardRef)( 24076 (props, ref) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(ViewportProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(CropperInnerWithRef, { ...props, ref }) }) 24077 ); 24078 24079 // packages/media-editor/build-module/state/use-media-editor-state.mjs 24080 var import_element78 = __toESM(require_element(), 1); 24081 24082 // packages/media-editor/build-module/state/types.mjs 24083 var DEFAULT_CROP_OPTIONS = { 24084 aspectRatioValue: "0" 24085 }; 24086 24087 // packages/media-editor/build-module/state/composite-reducer.mjs 24088 function mediaEditorReducer(state, action) { 24089 switch (action.type) { 24090 case "CROPPER": { 24091 const nextCropper = cropperReducer(state.cropper, action.action); 24092 if (nextCropper === state.cropper) { 24093 return state; 24094 } 24095 return { ...state, cropper: nextCropper }; 24096 } 24097 case "SET_ASPECT_RATIO_VALUE": { 24098 const { presetKey, resolved, visualSize } = action.payload; 24099 const shouldReshape = resolved !== void 0 && resolved > 0 && visualSize.width > 0 && visualSize.height > 0; 24100 const nextCropOptions = { 24101 ...state.cropOptions, 24102 aspectRatioValue: presetKey 24103 }; 24104 if (!shouldReshape) { 24105 if (state.cropOptions.aspectRatioValue === presetKey) { 24106 return state; 24107 } 24108 return { ...state, cropOptions: nextCropOptions }; 24109 } 24110 const newCropRect = computeInscribedRect(resolved, visualSize); 24111 const nextCropper = cropperReducer(state.cropper, { 24112 type: "SET_CROP_RECT", 24113 payload: newCropRect 24114 }); 24115 return { 24116 cropper: nextCropper, 24117 cropOptions: nextCropOptions 24118 }; 24119 } 24120 case "RESET_CROP_OPTIONS": { 24121 if (state.cropOptions.aspectRatioValue === DEFAULT_CROP_OPTIONS.aspectRatioValue) { 24122 return state; 24123 } 24124 return { 24125 ...state, 24126 cropOptions: { ...DEFAULT_CROP_OPTIONS } 24127 }; 24128 } 24129 case "RESTORE_SNAPSHOT": 24130 return action.payload; 24131 case "VIEWPORT_ADJUST_CROP_RECT": { 24132 const nextCropper = cropperReducer(state.cropper, { 24133 type: "SET_CROP_RECT", 24134 payload: action.payload 24135 }); 24136 if (nextCropper === state.cropper) { 24137 return state; 24138 } 24139 return { ...state, cropper: nextCropper }; 24140 } 24141 } 24142 } 24143 function areMediaEditorStatesEqual(a2, b2) { 24144 if (a2 === b2) { 24145 return true; 24146 } 24147 return areCropperStatesEqual(a2.cropper, b2.cropper) && a2.cropOptions.aspectRatioValue === b2.cropOptions.aspectRatioValue; 24148 } 24149 function buildInitialMediaEditorState(initialCropper, initialOptions) { 24150 return { 24151 cropper: initialCropper, 24152 cropOptions: { ...DEFAULT_CROP_OPTIONS, ...initialOptions } 24153 }; 24154 } 24155 24156 // packages/media-editor/build-module/state/use-media-editor-state.mjs 24157 function resolveAspectRatio(presetKey, cropperImage) { 24158 const num = parseFloat(presetKey); 24159 if (num === 0 || Number.isNaN(num)) { 24160 return void 0; 24161 } 24162 if (num === ORIGINAL_ASPECT_RATIO) { 24163 if (cropperImage && cropperImage.naturalWidth > 0 && cropperImage.naturalHeight > 0) { 24164 return cropperImage.naturalWidth / cropperImage.naturalHeight; 24165 } 24166 return void 0; 24167 } 24168 if (num > 0) { 24169 return num; 24170 } 24171 return void 0; 24172 } 24173 function areCropperImagesEqual(a2, b2) { 24174 return a2?.src === b2?.src && a2?.naturalWidth === b2?.naturalWidth && a2?.naturalHeight === b2?.naturalHeight; 24175 } 24176 function useMediaEditorState(initialState) { 24177 const [state, dispatch] = (0, import_element78.useReducer)( 24178 mediaEditorReducer, 24179 null, 24180 () => buildInitialMediaEditorState( 24181 enforceContainment({ 24182 ...DEFAULT_STATE2, 24183 ...initialState?.cropper 24184 }), 24185 initialState?.cropOptions 24186 ) 24187 ); 24188 const [initialBaseline, setInitialBaseline] = (0, import_element78.useState)(() => state); 24189 const stateRef = (0, import_element78.useRef)(state); 24190 const visualSizeRef = (0, import_element78.useRef)({ width: 0, height: 0 }); 24191 const historyRef = (0, import_element78.useRef)([]); 24192 const redoStackRef = (0, import_element78.useRef)([]); 24193 const [hasUndo, setHasUndo] = (0, import_element78.useState)(false); 24194 const [hasRedo, setHasRedo] = (0, import_element78.useState)(false); 24195 const isGestureOpenRef = (0, import_element78.useRef)(false); 24196 const gestureSnapshotRef = (0, import_element78.useRef)(null); 24197 const pushSnapshot = (0, import_element78.useCallback)((snapshot) => { 24198 const last = historyRef.current[historyRef.current.length - 1]; 24199 if (last && areMediaEditorStatesEqual(last, snapshot)) { 24200 return; 24201 } 24202 historyRef.current = [...historyRef.current, snapshot]; 24203 redoStackRef.current = []; 24204 setHasUndo(true); 24205 setHasRedo(false); 24206 }, []); 24207 const dispatchWithHistory = (0, import_element78.useCallback)( 24208 (action, recordHistory = true) => { 24209 const preState = stateRef.current; 24210 const postState = mediaEditorReducer(preState, action); 24211 if (recordHistory) { 24212 if (!areMediaEditorStatesEqual(preState, postState)) { 24213 if (isGestureOpenRef.current) { 24214 if (gestureSnapshotRef.current === null) { 24215 gestureSnapshotRef.current = preState; 24216 } 24217 } else { 24218 pushSnapshot(preState); 24219 } 24220 } 24221 } 24222 stateRef.current = postState; 24223 dispatch(action); 24224 }, 24225 [pushSnapshot] 24226 ); 24227 const beginGesture = (0, import_element78.useCallback)(() => { 24228 if (isGestureOpenRef.current) { 24229 return; 24230 } 24231 isGestureOpenRef.current = true; 24232 gestureSnapshotRef.current = null; 24233 }, []); 24234 const endGesture = (0, import_element78.useCallback)(() => { 24235 const snapshot = gestureSnapshotRef.current; 24236 if (snapshot && !areMediaEditorStatesEqual(snapshot, stateRef.current)) { 24237 pushSnapshot(snapshot); 24238 } 24239 gestureSnapshotRef.current = null; 24240 isGestureOpenRef.current = false; 24241 }, [pushSnapshot]); 24242 const dispatchCropperAction = (0, import_element78.useCallback)( 24243 (action) => { 24244 dispatchWithHistory({ type: "CROPPER", action }); 24245 }, 24246 [dispatchWithHistory] 24247 ); 24248 const cropperSetters = (0, import_element78.useMemo)( 24249 () => buildCropperSetters( 24250 dispatchCropperAction, 24251 () => stateRef.current.cropper 24252 ), 24253 [dispatchCropperAction] 24254 ); 24255 const setImage = (0, import_element78.useCallback)((image) => { 24256 if (areCropperImagesEqual(stateRef.current.cropper.image, image)) { 24257 return; 24258 } 24259 const action = { 24260 type: "CROPPER", 24261 action: { type: "SET_IMAGE", payload: image } 24262 }; 24263 const next = mediaEditorReducer(stateRef.current, action); 24264 stateRef.current = next; 24265 dispatch(action); 24266 setInitialBaseline(next); 24267 isGestureOpenRef.current = false; 24268 gestureSnapshotRef.current = null; 24269 historyRef.current = []; 24270 redoStackRef.current = []; 24271 setHasUndo(false); 24272 setHasRedo(false); 24273 }, []); 24274 const reset = (0, import_element78.useCallback)( 24275 (resetState) => { 24276 dispatchWithHistory({ 24277 type: "CROPPER", 24278 action: { type: "RESET", payload: resetState } 24279 }); 24280 }, 24281 [dispatchWithHistory] 24282 ); 24283 const setAspectRatioValue = (0, import_element78.useCallback)( 24284 (presetKey) => { 24285 const resolved = resolveAspectRatio( 24286 presetKey, 24287 stateRef.current.cropper.image 24288 ); 24289 dispatchWithHistory({ 24290 type: "SET_ASPECT_RATIO_VALUE", 24291 payload: { 24292 presetKey, 24293 resolved, 24294 visualSize: visualSizeRef.current 24295 } 24296 }); 24297 }, 24298 [dispatchWithHistory] 24299 ); 24300 const resetCropOptions = (0, import_element78.useCallback)(() => { 24301 dispatchWithHistory({ type: "RESET_CROP_OPTIONS" }); 24302 }, [dispatchWithHistory]); 24303 const undo = (0, import_element78.useCallback)(() => { 24304 endGesture(); 24305 const prev = historyRef.current[historyRef.current.length - 1]; 24306 if (!prev) { 24307 return; 24308 } 24309 redoStackRef.current = [stateRef.current, ...redoStackRef.current]; 24310 historyRef.current = historyRef.current.slice(0, -1); 24311 setHasUndo(historyRef.current.length > 0); 24312 setHasRedo(true); 24313 stateRef.current = prev; 24314 dispatch({ type: "RESTORE_SNAPSHOT", payload: prev }); 24315 }, [endGesture]); 24316 const redo = (0, import_element78.useCallback)(() => { 24317 endGesture(); 24318 const next = redoStackRef.current[0]; 24319 if (!next) { 24320 return; 24321 } 24322 historyRef.current = [...historyRef.current, stateRef.current]; 24323 redoStackRef.current = redoStackRef.current.slice(1); 24324 setHasUndo(true); 24325 setHasRedo(redoStackRef.current.length > 0); 24326 stateRef.current = next; 24327 dispatch({ type: "RESTORE_SNAPSHOT", payload: next }); 24328 }, [endGesture]); 24329 const setVisualSize = (0, import_element78.useCallback)((size4) => { 24330 visualSizeRef.current = size4; 24331 }, []); 24332 const adjustCropRectForViewport = (0, import_element78.useCallback)( 24333 (rect) => { 24334 dispatchWithHistory( 24335 { type: "VIEWPORT_ADJUST_CROP_RECT", payload: rect }, 24336 false 24337 ); 24338 }, 24339 [dispatchWithHistory] 24340 ); 24341 const isDirty = !areMediaEditorStatesEqual(state, initialBaseline); 24342 const isCropperDirty = !areCropperStatesEqual( 24343 state.cropper, 24344 initialBaseline.cropper 24345 ); 24346 const getCroppedImage = (0, import_element78.useCallback)( 24347 (mimeType, quality) => { 24348 if (!state.cropper.image) { 24349 return Promise.reject( 24350 new Error("No image loaded \u2014 call setImage first.") 24351 ); 24352 } 24353 return exportCroppedImage( 24354 state.cropper.image.src, 24355 state.cropper, 24356 mimeType, 24357 quality 24358 ); 24359 }, 24360 [state.cropper] 24361 ); 24362 const controller = (0, import_element78.useMemo)( 24363 () => ({ 24364 // CropperController surface (state is the cropper slice so a 24365 // <Cropper> takes this controller as-is). 24366 ...cropperSetters, 24367 state: state.cropper, 24368 setImage, 24369 reset, 24370 isDirty, 24371 getCroppedImage, 24372 // Composite extensions 24373 cropOptions: state.cropOptions, 24374 setAspectRatioValue, 24375 resetCropOptions, 24376 isCropperDirty, 24377 hasUndo, 24378 hasRedo, 24379 undo, 24380 redo, 24381 beginGesture, 24382 endGesture, 24383 setVisualSize, 24384 adjustCropRectForViewport 24385 }), 24386 [ 24387 cropperSetters, 24388 state.cropper, 24389 setImage, 24390 reset, 24391 isDirty, 24392 getCroppedImage, 24393 state.cropOptions, 24394 setAspectRatioValue, 24395 resetCropOptions, 24396 isCropperDirty, 24397 hasUndo, 24398 hasRedo, 24399 undo, 24400 redo, 24401 beginGesture, 24402 endGesture, 24403 setVisualSize, 24404 adjustCropRectForViewport 24405 ] 24406 ); 24407 return controller; 24408 } 24409 24410 // packages/media-editor/build-module/state/media-editor-state-provider.mjs 24411 var import_element79 = __toESM(require_element(), 1); 24412 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1); 24413 var MediaEditorStateContext = (0, import_element79.createContext)( 24414 null 24415 ); 24416 function MediaEditorStateProvider({ 24417 initialCropperState, 24418 initialCropOptions, 24419 children 24420 }) { 24421 const controller = useMediaEditorState({ 24422 cropper: initialCropperState, 24423 cropOptions: initialCropOptions 24424 }); 24425 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(MediaEditorStateContext.Provider, { value: controller, children }); 24426 } 24427 function useMediaEditor() { 24428 const context = (0, import_element79.useContext)(MediaEditorStateContext); 24429 if (!context) { 24430 throw new Error( 24431 "useMediaEditor must be used within a MediaEditorStateProvider." 24432 ); 24433 } 24434 return context; 24435 } 24436 24437 // packages/media-editor/build-module/components/media-editor-canvas/index.mjs 24438 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1); 24439 function MediaEditorCanvas({ 24440 focusOnMount, 24441 isPlacementActive = false, 24442 onGestureStart, 24443 onGestureEnd 24444 }) { 24445 const { media } = useMediaEditorContext(); 24446 const controller = useMediaEditor(); 24447 const { aspectRatioValue } = controller.cropOptions; 24448 const cropperImage = controller.state.image; 24449 const { beginGesture, endGesture, setImage } = controller; 24450 const aspectRatio = (0, import_element80.useMemo)( 24451 () => resolveAspectRatio(aspectRatioValue, cropperImage), 24452 [aspectRatioValue, cropperImage] 24453 ); 24454 const handleGestureStart = (0, import_element80.useCallback)(() => { 24455 beginGesture(); 24456 onGestureStart?.(); 24457 }, [beginGesture, onGestureStart]); 24458 const handleGestureEnd = (0, import_element80.useCallback)(() => { 24459 endGesture(); 24460 onGestureEnd?.(); 24461 }, [endGesture, onGestureEnd]); 24462 const mediaUrl = media?.source_url; 24463 const mediaType = getMediaTypeFromMimeType(media?.mime_type); 24464 const mediaWidth = Number(media?.media_details?.width); 24465 const mediaHeight = Number(media?.media_details?.height); 24466 (0, import_element80.useEffect)(() => { 24467 if (cropperImage || !mediaUrl || !Number.isFinite(mediaWidth) || !Number.isFinite(mediaHeight) || mediaWidth <= 0 || mediaHeight <= 0) { 24468 return; 24469 } 24470 setImage({ 24471 src: mediaUrl, 24472 naturalWidth: mediaWidth, 24473 naturalHeight: mediaHeight 24474 }); 24475 }, [cropperImage, mediaUrl, mediaWidth, mediaHeight, setImage]); 24476 if (!mediaUrl || mediaType.type !== "image") { 24477 return null; 24478 } 24479 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "media-editor-canvas", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)( 24480 Cropper, 24481 { 24482 src: mediaUrl, 24483 controller, 24484 aspectRatio, 24485 freeformCrop: true, 24486 focusOnMount, 24487 showGrid: "interactive", 24488 isPlacementActive, 24489 onGestureStart: handleGestureStart, 24490 onGestureEnd: handleGestureEnd 24491 } 24492 ) }); 24493 } 24494 24495 // packages/media-editor/build-module/components/media-editor-fine-rotation/index.mjs 24496 var import_i18n31 = __toESM(require_i18n(), 1); 24497 24498 // packages/media-editor/build-module/hooks/use-crop-gesture-handlers.mjs 24499 var import_element81 = __toESM(require_element(), 1); 24500 var CROP_CONTROL_ATTR = "data-crop-control"; 24501 var KEYBOARD_GESTURE_IDLE_MS = 300; 24502 function useCropGestureHandlers(options = {}) { 24503 const { commitOnKeyUp = true } = options; 24504 const { beginGesture, endGesture } = useMediaEditor(); 24505 const keyboardTimerRef = (0, import_element81.useRef)(void 0); 24506 const clearKeyboardTimer = (0, import_element81.useCallback)(() => { 24507 clearTimeout(keyboardTimerRef.current); 24508 }, []); 24509 const scheduleKeyboardEnd = (0, import_element81.useCallback)(() => { 24510 clearKeyboardTimer(); 24511 keyboardTimerRef.current = setTimeout(() => { 24512 endGesture(); 24513 }, KEYBOARD_GESTURE_IDLE_MS); 24514 }, [clearKeyboardTimer, endGesture]); 24515 (0, import_element81.useEffect)(() => clearKeyboardTimer, [clearKeyboardTimer]); 24516 const handlePointerDownCapture = (0, import_element81.useCallback)(() => { 24517 clearKeyboardTimer(); 24518 beginGesture(); 24519 }, [beginGesture, clearKeyboardTimer]); 24520 const handlePointerEnd = (0, import_element81.useCallback)(() => { 24521 clearKeyboardTimer(); 24522 endGesture(); 24523 }, [clearKeyboardTimer, endGesture]); 24524 const handleKeyDownCapture = (0, import_element81.useCallback)(() => { 24525 beginGesture(); 24526 if (!commitOnKeyUp) { 24527 scheduleKeyboardEnd(); 24528 } 24529 }, [beginGesture, commitOnKeyUp, scheduleKeyboardEnd]); 24530 const handleKeyUp = (0, import_element81.useCallback)(() => { 24531 if (commitOnKeyUp) { 24532 endGesture(); 24533 return; 24534 } 24535 scheduleKeyboardEnd(); 24536 }, [commitOnKeyUp, endGesture, scheduleKeyboardEnd]); 24537 return { 24538 [CROP_CONTROL_ATTR]: true, 24539 onPointerDownCapture: handlePointerDownCapture, 24540 onPointerUp: handlePointerEnd, 24541 onPointerCancel: handlePointerEnd, 24542 onKeyDownCapture: handleKeyDownCapture, 24543 onKeyUp: handleKeyUp 24544 }; 24545 } 24546 24547 // packages/media-editor/build-module/components/rotation-ruler/index.mjs 24548 var import_element83 = __toESM(require_element(), 1); 24549 24550 // packages/media-editor/build-module/components/rotation-ruler/use-ruler-drag.mjs 24551 var import_element82 = __toESM(require_element(), 1); 24552 function pxToValueDelta(deltaPx, pixelsPerStep, step) { 24553 return -deltaPx / pixelsPerStep * step; 24554 } 24555 function clampValue(value, min3, max3) { 24556 if (value < min3) { 24557 return min3; 24558 } 24559 if (value > max3) { 24560 return max3; 24561 } 24562 return value; 24563 } 24564 function quantize(value, step) { 24565 return Math.round(value / step) * step; 24566 } 24567 function useRulerDrag(options) { 24568 const { 24569 value, 24570 onChange, 24571 min: min3, 24572 max: max3, 24573 step, 24574 pixelsPerStep, 24575 disabled: disabled2, 24576 onPointerDownStart 24577 } = options; 24578 const latestRef = (0, import_element82.useRef)({ 24579 value, 24580 startX: 0, 24581 startValue: 0, 24582 activeStep: step, 24583 dragging: false, 24584 captureElement: null, 24585 capturePointerId: 0, 24586 windowPointerUp: null 24587 }); 24588 (0, import_element82.useEffect)(() => { 24589 latestRef.current.value = value; 24590 }, [value]); 24591 const endDrag = (0, import_element82.useCallback)(() => { 24592 const state = latestRef.current; 24593 if (!state.dragging) { 24594 return; 24595 } 24596 state.dragging = false; 24597 if (state.captureElement && state.captureElement.hasPointerCapture(state.capturePointerId)) { 24598 state.captureElement.releasePointerCapture( 24599 state.capturePointerId 24600 ); 24601 } 24602 state.captureElement = null; 24603 if (state.windowPointerUp) { 24604 window.removeEventListener("pointerup", state.windowPointerUp); 24605 window.removeEventListener( 24606 "pointercancel", 24607 state.windowPointerUp 24608 ); 24609 state.windowPointerUp = null; 24610 } 24611 }, []); 24612 (0, import_element82.useEffect)(() => endDrag, [endDrag]); 24613 const onPointerDown = (0, import_element82.useCallback)( 24614 (event) => { 24615 if (disabled2 || event.button !== 0) { 24616 return; 24617 } 24618 const state = latestRef.current; 24619 event.currentTarget.setPointerCapture(event.pointerId); 24620 state.captureElement = event.currentTarget; 24621 state.capturePointerId = event.pointerId; 24622 state.startX = event.clientX; 24623 state.startValue = state.value; 24624 state.activeStep = event.shiftKey ? step / 2 : step; 24625 state.dragging = true; 24626 onPointerDownStart?.(); 24627 const onWindowUp = () => endDrag(); 24628 state.windowPointerUp = onWindowUp; 24629 window.addEventListener("pointerup", onWindowUp); 24630 window.addEventListener("pointercancel", onWindowUp); 24631 }, 24632 [disabled2, onPointerDownStart, endDrag, step] 24633 ); 24634 const onPointerMove = (0, import_element82.useCallback)( 24635 (event) => { 24636 const state = latestRef.current; 24637 if (!state.dragging) { 24638 return; 24639 } 24640 const requestedStep = event.shiftKey ? step / 2 : step; 24641 if (requestedStep !== state.activeStep) { 24642 state.startX = event.clientX; 24643 state.startValue = state.value; 24644 state.activeStep = requestedStep; 24645 } 24646 const deltaPx = event.clientX - state.startX; 24647 const deltaValue = pxToValueDelta( 24648 deltaPx, 24649 pixelsPerStep, 24650 state.activeStep 24651 ); 24652 const raw = state.startValue + deltaValue; 24653 const stepped = quantize(raw, state.activeStep); 24654 const next = clampValue(stepped, min3, max3); 24655 if (next !== state.value) { 24656 state.value = next; 24657 onChange(next); 24658 } 24659 }, 24660 [onChange, min3, max3, step, pixelsPerStep] 24661 ); 24662 return { 24663 onPointerDown, 24664 onPointerMove, 24665 onPointerUp: endDrag, 24666 onPointerCancel: endDrag 24667 }; 24668 } 24669 24670 // packages/media-editor/build-module/components/rotation-ruler/index.mjs 24671 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1); 24672 var STRIP_HEIGHT = 32; 24673 var LABEL_BASELINE_Y = 11; 24674 var MAJOR_INTERVAL = 15; 24675 var TICK_HEIGHT_MINOR = 4; 24676 var TICK_HEIGHT_MID = 8; 24677 var TICK_HEIGHT_MAJOR = 14; 24678 function useTicks(min3, max3) { 24679 return (0, import_element83.useMemo)(() => { 24680 const out = []; 24681 for (let v2 = Math.ceil(min3); v2 <= Math.floor(max3); v2 += 1) { 24682 let kind = "minor"; 24683 let height = TICK_HEIGHT_MINOR; 24684 if (v2 % 15 === 0) { 24685 kind = "major"; 24686 height = TICK_HEIGHT_MAJOR; 24687 } else if (v2 % 5 === 0) { 24688 kind = "mid"; 24689 height = TICK_HEIGHT_MID; 24690 } 24691 out.push({ value: v2, kind, height }); 24692 } 24693 return out; 24694 }, [min3, max3]); 24695 } 24696 function formatValue(value) { 24697 const rounded = Math.round(value * 10) / 10; 24698 return Number.isInteger(rounded) ? rounded.toFixed(0) : rounded.toFixed(1); 24699 } 24700 function RotationRuler(props) { 24701 const { 24702 value, 24703 onChange, 24704 min: min3 = -45, 24705 max: max3 = 45, 24706 step = 1, 24707 label, 24708 unit = "\xB0", 24709 pixelsPerStep = 6, 24710 className, 24711 id, 24712 disabled: disabled2 = false 24713 } = props; 24714 const inputRef = (0, import_element83.useRef)(null); 24715 const generatedId = (0, import_element83.useId)(); 24716 const inputId = id ?? generatedId; 24717 const dragHandlers = useRulerDrag({ 24718 value, 24719 onChange, 24720 min: min3, 24721 max: max3, 24722 step, 24723 pixelsPerStep, 24724 disabled: disabled2, 24725 onPointerDownStart: () => inputRef.current?.focus() 24726 }); 24727 const handleKeyDown = (event) => { 24728 const isIncrement = event.key === "ArrowRight" || event.key === "ArrowUp"; 24729 const isDecrement = event.key === "ArrowLeft" || event.key === "ArrowDown"; 24730 if (!isIncrement && !isDecrement) { 24731 return; 24732 } 24733 event.preventDefault(); 24734 if (disabled2) { 24735 return; 24736 } 24737 const direction = isIncrement ? 1 : -1; 24738 const magnitude = event.shiftKey ? step / 2 : step; 24739 const next = clampValue(value + direction * magnitude, min3, max3); 24740 if (next !== value) { 24741 onChange(next); 24742 } 24743 }; 24744 const display = `$formatValue(value)}$unit}`; 24745 const ticks = useTicks(min3, max3); 24746 const pxPerUnit = pixelsPerStep / step; 24747 const stripStyle = (0, import_element83.useMemo)(() => { 24748 const offset4 = -value * pxPerUnit; 24749 return { 24750 transform: `translateX(calc(-50% + $offset4}px))` 24751 }; 24752 }, [value, pxPerUnit]); 24753 const closestMajor = Math.round(value / MAJOR_INTERVAL) * MAJOR_INTERVAL; 24754 const onMajor = Math.abs(value - closestMajor) < 0.01; 24755 const numberText = onMajor ? `$closestMajor}` : formatValue(value); 24756 const isNegative = numberText.startsWith("-"); 24757 const digits = isNegative ? numberText.slice(1) : numberText; 24758 const majorTicks = ticks.filter((tick) => tick.kind === "major"); 24759 return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)( 24760 "div", 24761 { 24762 className: clsx_default("rotation-ruler", className), 24763 role: "presentation", 24764 "data-disabled": disabled2 || void 0, 24765 ...dragHandlers, 24766 children: [ 24767 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)( 24768 "input", 24769 { 24770 ref: inputRef, 24771 id: inputId, 24772 type: "range", 24773 className: "rotation-ruler__input", 24774 min: min3, 24775 max: max3, 24776 step: "any", 24777 value, 24778 disabled: disabled2, 24779 "aria-label": label, 24780 "aria-valuetext": display, 24781 onChange: (event) => onChange( 24782 clampValue(event.target.valueAsNumber, min3, max3) 24783 ), 24784 onKeyDown: handleKeyDown 24785 } 24786 ), 24787 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("div", { className: "rotation-ruler__strip", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)( 24788 "svg", 24789 { 24790 className: "rotation-ruler__ticks", 24791 style: stripStyle, 24792 width: (max3 - min3) * pxPerUnit, 24793 height: STRIP_HEIGHT, 24794 viewBox: `$min3 * pxPerUnit} 0 ${(max3 - min3) * pxPerUnit} $STRIP_HEIGHT}`, 24795 preserveAspectRatio: "xMidYMid meet", 24796 children: [ 24797 ticks.map((tick) => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)( 24798 "line", 24799 { 24800 x1: tick.value * pxPerUnit, 24801 x2: tick.value * pxPerUnit, 24802 y1: STRIP_HEIGHT - tick.height, 24803 y2: STRIP_HEIGHT, 24804 className: `rotation-ruler__tick rotation-ruler__tick--$tick.kind}` 24805 }, 24806 tick.value 24807 )), 24808 majorTicks.map((tick) => /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)( 24809 "text", 24810 { 24811 x: tick.value * pxPerUnit, 24812 y: LABEL_BASELINE_Y, 24813 textAnchor: "middle", 24814 className: "rotation-ruler__label", 24815 children: [ 24816 tick.value, 24817 unit 24818 ] 24819 }, 24820 tick.value 24821 )) 24822 ] 24823 } 24824 ) }), 24825 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("div", { className: "rotation-ruler__active-label", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)("span", { className: "rotation-ruler__active-label-number", children: [ 24826 isNegative && /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("span", { className: "rotation-ruler__active-label-sign", children: "-" }), 24827 digits, 24828 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("span", { className: "rotation-ruler__active-label-unit", children: unit }) 24829 ] }) }), 24830 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("div", { className: "rotation-ruler__pointer", "aria-hidden": "true" }) 24831 ] 24832 } 24833 ); 24834 } 24835 24836 // packages/media-editor/build-module/components/media-editor-fine-rotation/index.mjs 24837 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1); 24838 function MediaEditorFineRotation({ 24839 onPlacementControlInteraction 24840 }) { 24841 const { state, setRotation } = useMediaEditor(); 24842 const rotationGestureHandlers = useCropGestureHandlers({ 24843 commitOnKeyUp: false 24844 }); 24845 const baseAngle = Math.round(state.rotation / 90) * 90; 24846 const singleFlip = state.flip.horizontal !== state.flip.vertical; 24847 const visualDir = singleFlip ? -1 : 1; 24848 const fineOffset = (state.rotation - baseAngle) * visualDir; 24849 const handleRotationSlider = (value) => { 24850 const EPS = 0.01; 24851 const clamped = Math.max( 24852 -MAX_ROTATION_OFFSET + EPS, 24853 Math.min(MAX_ROTATION_OFFSET - EPS, value) 24854 ); 24855 onPlacementControlInteraction?.(); 24856 setRotation(baseAngle + clamped * visualDir); 24857 }; 24858 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)( 24859 "div", 24860 { 24861 role: "presentation", 24862 className: "media-editor-fine-rotation", 24863 ...rotationGestureHandlers, 24864 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)( 24865 RotationRuler, 24866 { 24867 label: (0, import_i18n31.__)("Fine rotation"), 24868 min: -MAX_ROTATION_OFFSET, 24869 max: MAX_ROTATION_OFFSET, 24870 value: fineOffset, 24871 onChange: handleRotationSlider 24872 } 24873 ) 24874 } 24875 ); 24876 } 24877 24878 // packages/media-editor/build-module/components/media-editor-transform-controls/index.mjs 24879 var import_components36 = __toESM(require_components(), 1); 24880 var import_i18n32 = __toESM(require_i18n(), 1); 24881 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1); 24882 function MediaEditorTransformControls() { 24883 const { state, setFlip, snapRotate90 } = useMediaEditor(); 24884 return /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)("div", { className: "media-editor-transform-controls", children: [ 24885 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)( 24886 import_components36.Button, 24887 { 24888 size: "compact", 24889 icon: rotate_left_default, 24890 label: (0, import_i18n32.__)("Rotate 90\xB0 counter-clockwise"), 24891 showTooltip: true, 24892 onClick: () => snapRotate90(-1) 24893 } 24894 ), 24895 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)( 24896 import_components36.Button, 24897 { 24898 size: "compact", 24899 icon: rotate_right_default, 24900 label: (0, import_i18n32.__)("Rotate 90\xB0 clockwise"), 24901 showTooltip: true, 24902 onClick: () => snapRotate90(1) 24903 } 24904 ), 24905 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)( 24906 import_components36.Button, 24907 { 24908 size: "compact", 24909 icon: flip_horizontal_default, 24910 label: (0, import_i18n32.__)("Flip horizontal"), 24911 showTooltip: true, 24912 isPressed: state.flip.horizontal, 24913 onClick: () => setFlip({ 24914 horizontal: !state.flip.horizontal, 24915 vertical: state.flip.vertical 24916 }) 24917 } 24918 ), 24919 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)( 24920 import_components36.Button, 24921 { 24922 size: "compact", 24923 icon: flip_vertical_default, 24924 label: (0, import_i18n32.__)("Flip vertical"), 24925 showTooltip: true, 24926 isPressed: state.flip.vertical, 24927 onClick: () => setFlip({ 24928 horizontal: state.flip.horizontal, 24929 vertical: !state.flip.vertical 24930 }) 24931 } 24932 ) 24933 ] }); 24934 } 24935 24936 // packages/media-editor/build-module/components/media-editor-crop-panel/index.mjs 24937 var import_components37 = __toESM(require_components(), 1); 24938 var import_i18n33 = __toESM(require_i18n(), 1); 24939 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1); 24940 var ZOOM_PERCENTAGE_SCALE = 100; 24941 var MAX_ZOOM_PERCENTAGE = MAX_ZOOM * ZOOM_PERCENTAGE_SCALE; 24942 function getZoomPercentageForDisplay(zoom) { 24943 return Math.round(zoom * ZOOM_PERCENTAGE_SCALE); 24944 } 24945 function getMinZoomPercentageForDisplay(zoom) { 24946 return Math.ceil(zoom * ZOOM_PERCENTAGE_SCALE); 24947 } 24948 function MediaEditorCropPanel({ 24949 aspectRatioValue, 24950 onAspectRatioChange, 24951 onPlacementControlInteraction, 24952 aspectRatioOptions 24953 }) { 24954 const { state, setZoom } = useMediaEditor(); 24955 const zoomGestureHandlers = useCropGestureHandlers(); 24956 const minZoom = getMinZoom(state); 24957 const zoomPercentage = getZoomPercentageForDisplay(state.zoom); 24958 const minZoomPercentage = getMinZoomPercentageForDisplay(minZoom); 24959 return ( 24960 // Tag the whole panel as a crop-control region so the modal's 24961 // Cmd+Z handler doesn't mistake the SelectControl input for a 24962 // metadata field (which would suppress undo). 24963 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)( 24964 Stack, 24965 { 24966 direction: "column", 24967 gap: "xl", 24968 ...{ [CROP_CONTROL_ATTR]: true }, 24969 children: [ 24970 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("h2", {}), children: (0, import_i18n33.__)("Crop options") }), 24971 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)( 24972 import_components37.SelectControl, 24973 { 24974 __next40pxDefaultSize: true, 24975 label: (0, import_i18n33.__)("Aspect ratio"), 24976 value: aspectRatioValue, 24977 onChange: onAspectRatioChange, 24978 options: aspectRatioOptions.map((preset) => ({ 24979 label: preset.label, 24980 value: preset.value.toString() 24981 })) 24982 } 24983 ), 24984 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("div", { role: "presentation", ...zoomGestureHandlers, children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)( 24985 import_components37.RangeControl, 24986 { 24987 __next40pxDefaultSize: true, 24988 label: (0, import_i18n33.__)("Zoom (%)"), 24989 min: minZoomPercentage, 24990 max: MAX_ZOOM_PERCENTAGE, 24991 step: 1, 24992 shiftStep: 10, 24993 value: zoomPercentage, 24994 onChange: (value) => { 24995 onPlacementControlInteraction?.(); 24996 setZoom( 24997 typeof value === "number" ? value / ZOOM_PERCENTAGE_SCALE : minZoom 24998 ); 24999 }, 25000 renderTooltipContent: (value) => { 25001 const percentage = typeof value === "number" ? value : minZoomPercentage; 25002 return (0, import_i18n33.sprintf)( 25003 /* translators: %d: zoom level as a percentage. */ 25004 (0, import_i18n33.__)("%d%%"), 25005 Math.round(percentage) 25006 ); 25007 } 25008 } 25009 ) }) 25010 ] 25011 } 25012 ) 25013 ); 25014 } 25015 25016 // packages/media-editor/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs 25017 var import_components38 = __toESM(require_components(), 1); 25018 var import_element84 = __toESM(require_element(), 1); 25019 var import_i18n34 = __toESM(require_i18n(), 1); 25020 var import_keycodes = __toESM(require_keycodes(), 1); 25021 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1); 25022 var SHORTCUTS = [ 25023 { 25024 description: (0, import_i18n34.__)("Undo"), 25025 keyCombination: { modifier: "primary", character: "z" } 25026 }, 25027 { 25028 description: (0, import_i18n34.__)("Redo"), 25029 keyCombination: { modifier: "primaryShift", character: "z" } 25030 }, 25031 { 25032 description: (0, import_i18n34.__)("Pan"), 25033 keyCombination: { 25034 character: ["\u2191", "\u2193", "\u2190", "\u2192"], 25035 ariaLabel: (0, import_i18n34.__)("Arrow keys") 25036 } 25037 }, 25038 { 25039 description: (0, import_i18n34.__)("Zoom in"), 25040 keyCombination: { character: "+" } 25041 }, 25042 { 25043 description: (0, import_i18n34.__)("Zoom out"), 25044 keyCombination: { character: "-" } 25045 }, 25046 { 25047 description: (0, import_i18n34.__)("Rotate 90\xB0 clockwise"), 25048 keyCombination: { character: "R" } 25049 }, 25050 { 25051 description: (0, import_i18n34.__)("Rotate 90\xB0 counter-clockwise"), 25052 keyCombination: { modifier: "shift", character: "R" } 25053 }, 25054 { 25055 description: (0, import_i18n34.__)("Flip horizontal"), 25056 keyCombination: { character: "H" } 25057 }, 25058 { 25059 description: (0, import_i18n34.__)("Flip vertical"), 25060 keyCombination: { character: "V" } 25061 }, 25062 { 25063 description: (0, import_i18n34.__)("Pan or resize crop (large step)"), 25064 keyCombination: { 25065 modifier: "shift", 25066 character: ["\u2191", "\u2193", "\u2190", "\u2192"], 25067 ariaLabel: (0, import_i18n34.__)("Shift + Arrow keys") 25068 } 25069 } 25070 ]; 25071 function KeyCombinationDisplay({ 25072 keyCombination 25073 }) { 25074 const { modifier, character, ariaLabel } = keyCombination; 25075 let keys; 25076 if (Array.isArray(character)) { 25077 if (modifier) { 25078 const sample = import_keycodes.displayShortcutList[modifier](character[0]); 25079 keys = [...sample.slice(0, -1), ...character]; 25080 } else { 25081 keys = character; 25082 } 25083 } else { 25084 keys = modifier ? import_keycodes.displayShortcutList[modifier](character) : [character]; 25085 } 25086 const charString = Array.isArray(character) ? character.join("") : character; 25087 let label; 25088 if (ariaLabel) { 25089 label = ariaLabel; 25090 } else if (modifier) { 25091 label = import_keycodes.shortcutAriaLabel[modifier](charString); 25092 } else { 25093 label = charString; 25094 } 25095 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)( 25096 "kbd", 25097 { 25098 className: "media-editor-keyboard-shortcuts-modal__shortcut-term", 25099 "aria-label": label, 25100 children: keys.map( 25101 (key, index2) => key === "+" && modifier ? /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_element84.Fragment, { children: key }, index2) : /* @__PURE__ */ (0, import_jsx_runtime117.jsx)( 25102 "kbd", 25103 { 25104 className: "media-editor-keyboard-shortcuts-modal__shortcut-key", 25105 children: key 25106 }, 25107 index2 25108 ) 25109 ) 25110 } 25111 ); 25112 } 25113 function MediaEditorKeyboardShortcutsModal({ 25114 onClose 25115 }) { 25116 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)( 25117 import_components38.Modal, 25118 { 25119 className: "media-editor-keyboard-shortcuts-modal", 25120 title: (0, import_i18n34.__)("Keyboard shortcuts"), 25121 onRequestClose: onClose, 25122 children: [ 25123 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("p", { className: "media-editor-keyboard-shortcuts-modal__note", children: (0, import_i18n34.__)( 25124 "These shortcuts work when the image editor has focus." 25125 ) }), 25126 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)( 25127 "ul", 25128 { 25129 className: "media-editor-keyboard-shortcuts-modal__shortcut-list", 25130 role: "list", 25131 children: SHORTCUTS.map(({ description, keyCombination }, index2) => /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)( 25132 "li", 25133 { 25134 className: "media-editor-keyboard-shortcuts-modal__shortcut", 25135 children: [ 25136 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("span", { className: "media-editor-keyboard-shortcuts-modal__shortcut-description", children: description }), 25137 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)( 25138 KeyCombinationDisplay, 25139 { 25140 keyCombination 25141 } 25142 ) 25143 ] 25144 }, 25145 index2 25146 )) 25147 } 25148 ) 25149 ] 25150 } 25151 ); 25152 } 25153 25154 // packages/media-editor/build-module/components/media-editor/use-save-media-editor.mjs 25155 var import_api_fetch = __toESM(require_api_fetch(), 1); 25156 var import_data7 = __toESM(require_data(), 1); 25157 var import_core_data = __toESM(require_core_data(), 1); 25158 var import_element85 = __toESM(require_element(), 1); 25159 var import_i18n35 = __toESM(require_i18n(), 1); 25160 var import_notices = __toESM(require_notices(), 1); 25161 25162 // packages/media-editor/build-module/components/media-editor-modal/build-modifiers.mjs 25163 var CROP_TOLERANCE = 0.1; 25164 function buildModifiers(state, imageSize) { 25165 const modifiers = []; 25166 if (imageSize.width === 0 || imageSize.height === 0) { 25167 return modifiers; 25168 } 25169 const { cropRect, pan, zoom, flip: flip4 } = state; 25170 const hasFlipH = flip4.horizontal; 25171 const hasFlipV = flip4.vertical; 25172 if (hasFlipH || hasFlipV) { 25173 modifiers.push({ 25174 type: "flip", 25175 args: { flip: { horizontal: hasFlipH, vertical: hasFlipV } } 25176 }); 25177 } 25178 const rawAngle = (state.rotation % 360 + 360) % 360; 25179 const singleAxisFlip = hasFlipH !== hasFlipV; 25180 const signedAngle2 = singleAxisFlip ? (360 - rawAngle) % 360 : rawAngle; 25181 if (signedAngle2 !== 0) { 25182 modifiers.push({ type: "rotate", args: { angle: signedAngle2 } }); 25183 } 25184 const snapRotation = Math.round(state.rotation / 90) * 90; 25185 const { width: snapW, height: snapH } = getRotatedBBox( 25186 imageSize.width, 25187 imageSize.height, 25188 snapRotation 25189 ); 25190 const { width: fullW, height: fullH } = getRotatedBBox( 25191 imageSize.width, 25192 imageSize.height, 25193 state.rotation 25194 ); 25195 const imgLeft = 0.5 + pan.x - zoom / 2; 25196 const imgTop = 0.5 + pan.y - zoom / 2; 25197 const snapX = (cropRect.x - imgLeft) / zoom * snapW; 25198 const snapY = (cropRect.y - imgTop) / zoom * snapH; 25199 const widthPx = cropRect.width / zoom * snapW; 25200 const heightPx = cropRect.height / zoom * snapH; 25201 const offsetX = (fullW - snapW) / 2; 25202 const offsetY = (fullH - snapH) / 2; 25203 const fullX = snapX + offsetX; 25204 const fullY = snapY + offsetY; 25205 const leftPct = fullX / fullW * 100; 25206 const topPct = fullY / fullH * 100; 25207 const widthPct = widthPx / fullW * 100; 25208 const heightPct = heightPx / fullH * 100; 25209 const coversFullFrame = leftPct <= CROP_TOLERANCE && topPct <= CROP_TOLERANCE && widthPct >= 100 - CROP_TOLERANCE && heightPct >= 100 - CROP_TOLERANCE; 25210 if (!coversFullFrame) { 25211 modifiers.push({ 25212 type: "crop", 25213 args: { 25214 left: leftPct, 25215 top: topPct, 25216 width: widthPct, 25217 height: heightPct 25218 } 25219 }); 25220 } 25221 return modifiers; 25222 } 25223 25224 // packages/media-editor/build-module/components/media-editor/use-save-media-editor.mjs 25225 var METADATA_EDIT_KEYS = [ 25226 "title", 25227 "caption", 25228 "description", 25229 "alt_text", 25230 "post" 25231 ]; 25232 var MEDIA_EDITOR_NOTICES_CONTEXT = "media-editor"; 25233 function getCropModifiers(cropper) { 25234 if (!cropper.isCropperDirty || !cropper.state.image) { 25235 return []; 25236 } 25237 return buildModifiers(cropper.state, { 25238 width: cropper.state.image.naturalWidth, 25239 height: cropper.state.image.naturalHeight 25240 }); 25241 } 25242 function getMetadataEdits(pendingEdits, media) { 25243 const metadataEdits = {}; 25244 for (const key of METADATA_EDIT_KEYS) { 25245 if (pendingEdits && key in pendingEdits) { 25246 metadataEdits[key] = pendingEdits[key]; 25247 } 25248 } 25249 if (!("post" in metadataEdits) && media?.post !== void 0) { 25250 metadataEdits.post = media.post; 25251 } 25252 return metadataEdits; 25253 } 25254 function useSaveMediaEditor({ 25255 cropper, 25256 id, 25257 isImage, 25258 media, 25259 onSaved 25260 }) { 25261 const registry = (0, import_data7.useRegistry)(); 25262 const { 25263 clearEntityRecordEdits, 25264 receiveEntityRecords, 25265 saveEditedEntityRecord 25266 } = (0, import_data7.useDispatch)(import_core_data.store); 25267 const { createErrorNotice, removeAllNotices } = (0, import_data7.useDispatch)(import_notices.store); 25268 const [isSaving, setIsSaving] = (0, import_element85.useState)(false); 25269 const save = (0, import_element85.useCallback)(async () => { 25270 removeAllNotices("snackbar", MEDIA_EDITOR_NOTICES_CONTEXT); 25271 setIsSaving(true); 25272 try { 25273 let saved; 25274 const modifiers = getCropModifiers(cropper); 25275 const previous = modifiers.length > 0 && media ? { 25276 id, 25277 url: media.source_url 25278 } : void 0; 25279 if (modifiers.length > 0) { 25280 const pendingEdits = registry.select(import_core_data.store).getEntityRecordNonTransientEdits( 25281 "postType", 25282 "attachment", 25283 id 25284 ); 25285 const metadataEdits = getMetadataEdits(pendingEdits, media); 25286 saved = await (0, import_api_fetch.default)({ 25287 path: `/wp/v2/media/$id}/edit`, 25288 method: "POST", 25289 data: { 25290 src: media?.source_url, 25291 modifiers, 25292 ...metadataEdits 25293 } 25294 }); 25295 if (saved) { 25296 receiveEntityRecords( 25297 "postType", 25298 "attachment", 25299 saved, 25300 void 0, 25301 true 25302 ); 25303 } 25304 } else { 25305 saved = await saveEditedEntityRecord( 25306 "postType", 25307 "attachment", 25308 id 25309 ); 25310 } 25311 const next = saved ?? media; 25312 if (next && next.id !== id) { 25313 clearEntityRecordEdits("postType", "attachment", id); 25314 } 25315 if (next && next.id) { 25316 if (next.id === id) { 25317 cropper.reset(); 25318 } 25319 onSaved?.({ 25320 id: next.id, 25321 url: next.source_url, 25322 media: next, 25323 previous 25324 }); 25325 } 25326 } catch (error2) { 25327 const message2 = error2 instanceof Error ? error2.message : error2?.message ?? (0, import_i18n35.__)("An unknown error occurred."); 25328 createErrorNotice( 25329 isImage ? (0, import_i18n35.sprintf)( 25330 /* translators: %s: Error message. */ 25331 (0, import_i18n35.__)("Could not save image. %s"), 25332 message2 25333 ) : (0, import_i18n35.sprintf)( 25334 /* translators: %s: Error message. */ 25335 (0, import_i18n35.__)("Could not save media. %s"), 25336 message2 25337 ), 25338 { 25339 type: "snackbar", 25340 context: MEDIA_EDITOR_NOTICES_CONTEXT 25341 } 25342 ); 25343 } finally { 25344 setIsSaving(false); 25345 } 25346 }, [ 25347 clearEntityRecordEdits, 25348 createErrorNotice, 25349 cropper, 25350 id, 25351 isImage, 25352 media, 25353 onSaved, 25354 receiveEntityRecords, 25355 registry, 25356 removeAllNotices, 25357 saveEditedEntityRecord 25358 ]); 25359 return { isSaving, save }; 25360 } 25361 25362 // packages/media-editor/build-module/components/media-editor/use-crop-options.mjs 25363 var import_element86 = __toESM(require_element(), 1); 25364 function getAspectRatioOptions(aspectRatioPresets) { 25365 return [ 25366 ...DEFAULT_ASPECT_RATIOS.filter((preset) => preset.value <= 0), 25367 ...aspectRatioPresets ?? DEFAULT_ASPECT_RATIOS.filter((preset) => preset.value > 0) 25368 ]; 25369 } 25370 function useCropOptions({ 25371 aspectRatioPresets 25372 } = {}) { 25373 const controller = useMediaEditor(); 25374 const { aspectRatioValue } = controller.cropOptions; 25375 const cropperImage = controller.state.image; 25376 const aspectRatioOptions = (0, import_element86.useMemo)( 25377 () => getAspectRatioOptions(aspectRatioPresets), 25378 [aspectRatioPresets] 25379 ); 25380 const resolvedAspectRatio = (0, import_element86.useMemo)( 25381 () => resolveAspectRatio(aspectRatioValue, cropperImage), 25382 [aspectRatioValue, cropperImage] 25383 ); 25384 return { 25385 aspectRatioValue, 25386 setAspectRatioValue: controller.setAspectRatioValue, 25387 aspectRatioOptions, 25388 resolvedAspectRatio, 25389 resetCropOptions: controller.resetCropOptions 25390 }; 25391 } 25392 25393 // packages/media-editor/build-module/components/media-editor/index.mjs 25394 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1); 25395 var ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" }; 25396 var PLACEMENT_CONTROL_IDLE_MS = 300; 25397 var { Tabs } = unlock3(import_components39.privateApis); 25398 function MediaEditorSidebar({ tabs }) { 25399 const tabsContextValue = (0, import_element87.useContext)(Tabs.Context); 25400 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25401 complementary_area_default, 25402 { 25403 scope: "media-editor", 25404 identifier: "media-editor/details", 25405 title: (0, import_i18n36.__)("Details"), 25406 icon: drawer_right_default, 25407 isActiveByDefault: true, 25408 className: "media-editor__sidebar", 25409 panelClassName: "media-editor__sidebar-panel", 25410 headerClassName: "media-editor__sidebar-header", 25411 header: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Tabs.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Tabs.TabList, { children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Tabs.Tab, { tabId: tab.id, children: tab.title }, tab.id)) }) }), 25412 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Tabs.Context.Provider, { value: tabsContextValue, children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25413 Tabs.TabPanel, 25414 { 25415 tabId: tab.id, 25416 focusable: false, 25417 children: tab.panel 25418 }, 25419 tab.id 25420 )) }) 25421 } 25422 ); 25423 } 25424 function HeaderActions({ 25425 isSaving, 25426 isImage, 25427 showCloseButton = false, 25428 onCancel 25429 }) { 25430 const [isShortcutsModalOpen, setIsShortcutsModalOpen] = (0, import_element87.useState)(false); 25431 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)( 25432 import_components39.Flex, 25433 { 25434 className: "media-editor__header-actions", 25435 justify: "flex-end", 25436 expanded: false, 25437 gap: 2, 25438 children: [ 25439 isImage && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25440 import_components39.Button, 25441 { 25442 size: "compact", 25443 icon: keyboard_default, 25444 label: (0, import_i18n36.__)("Keyboard shortcuts"), 25445 onClick: () => setIsShortcutsModalOpen(true) 25446 } 25447 ), 25448 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(pinned_items_default.Slot, { scope: "media-editor" }), 25449 showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25450 import_components39.Button, 25451 { 25452 size: "compact", 25453 icon: close_default, 25454 label: (0, import_i18n36.__)("Close"), 25455 onClick: onCancel, 25456 disabled: isSaving, 25457 accessibleWhenDisabled: true 25458 } 25459 ), 25460 isShortcutsModalOpen && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25461 MediaEditorKeyboardShortcutsModal, 25462 { 25463 onClose: () => setIsShortcutsModalOpen(false) 25464 } 25465 ) 25466 ] 25467 } 25468 ); 25469 } 25470 function HistoryActions({ 25471 isUndoRedoDisabled = false, 25472 onReset 25473 }) { 25474 const { 25475 reset, 25476 isDirty, 25477 hasUndo, 25478 hasRedo, 25479 undo: undoCrop, 25480 redo: redoCrop, 25481 beginGesture, 25482 endGesture 25483 } = useMediaEditor(); 25484 const handleUndo = () => { 25485 if (isUndoRedoDisabled) { 25486 return; 25487 } 25488 undoCrop(); 25489 }; 25490 const handleRedo = () => { 25491 if (isUndoRedoDisabled) { 25492 return; 25493 } 25494 redoCrop(); 25495 }; 25496 const handleReset = () => { 25497 beginGesture(); 25498 reset(); 25499 onReset(); 25500 endGesture(); 25501 }; 25502 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)( 25503 import_components39.Flex, 25504 { 25505 className: "media-editor__history-actions", 25506 expanded: false, 25507 gap: 2, 25508 children: [ 25509 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25510 import_components39.Button, 25511 { 25512 size: "compact", 25513 icon: undo_default, 25514 label: (0, import_i18n36.__)("Undo"), 25515 showTooltip: true, 25516 shortcut: import_keycodes2.displayShortcut.primary("z"), 25517 disabled: isUndoRedoDisabled || !hasUndo, 25518 accessibleWhenDisabled: true, 25519 onClick: handleUndo 25520 } 25521 ), 25522 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25523 import_components39.Button, 25524 { 25525 size: "compact", 25526 icon: redo_default, 25527 label: (0, import_i18n36.__)("Redo"), 25528 showTooltip: true, 25529 shortcut: (0, import_keycodes2.isAppleOS)() ? import_keycodes2.displayShortcut.primaryShift("z") : import_keycodes2.displayShortcut.primary("y"), 25530 disabled: isUndoRedoDisabled || !hasRedo, 25531 accessibleWhenDisabled: true, 25532 onClick: handleRedo 25533 } 25534 ), 25535 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25536 import_components39.Button, 25537 { 25538 size: "compact", 25539 variant: "tertiary", 25540 disabled: !isDirty, 25541 accessibleWhenDisabled: true, 25542 onClick: handleReset, 25543 children: (0, import_i18n36.__)("Reset") 25544 } 25545 ) 25546 ] 25547 } 25548 ); 25549 } 25550 function FooterActions({ 25551 isSaving, 25552 hasMedia, 25553 hasChanges, 25554 onCancel, 25555 onSave 25556 }) { 25557 const saveDisabled = isSaving || !hasMedia || !hasChanges; 25558 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)( 25559 import_components39.Flex, 25560 { 25561 className: "media-editor__footer-actions", 25562 justify: "flex-end", 25563 expanded: false, 25564 gap: 2, 25565 children: [ 25566 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25567 import_components39.Button, 25568 { 25569 __next40pxDefaultSize: true, 25570 variant: "tertiary", 25571 onClick: onCancel, 25572 disabled: isSaving, 25573 accessibleWhenDisabled: true, 25574 children: (0, import_i18n36.__)("Cancel") 25575 } 25576 ), 25577 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25578 import_components39.Button, 25579 { 25580 __next40pxDefaultSize: true, 25581 variant: "primary", 25582 onClick: onSave, 25583 isBusy: isSaving, 25584 disabled: saveDisabled, 25585 accessibleWhenDisabled: true, 25586 children: (0, import_i18n36.__)("Save") 25587 } 25588 ) 25589 ] 25590 } 25591 ); 25592 } 25593 function MediaEditorContent({ 25594 fields = [], 25595 id, 25596 aspectRatioPresets, 25597 onClose, 25598 onSaved, 25599 renderFrame, 25600 noticesClassName = "media-editor__snackbar", 25601 noticesPortalElement, 25602 showCloseButton = false, 25603 shouldCloseOnEsc = false 25604 }) { 25605 const cropper = useMediaEditor(); 25606 const isWideViewport = (0, import_compose6.useViewportMatch)("xlarge"); 25607 const isMediumViewport = (0, import_compose6.useViewportMatch)("medium"); 25608 let footerLayout = "narrow"; 25609 if (isWideViewport) { 25610 footerLayout = "wide"; 25611 } else if (isMediumViewport) { 25612 footerLayout = "medium"; 25613 } 25614 const { media, hasEdits } = (0, import_data8.useSelect)( 25615 (select) => { 25616 const { 25617 getEditedEntityRecord, 25618 getEntityRecord, 25619 hasEditsForEntityRecord 25620 } = select(import_core_data2.store); 25621 getEntityRecord( 25622 "postType", 25623 "attachment", 25624 id, 25625 ATTACHMENT_EMBED_QUERY 25626 ); 25627 return { 25628 media: getEditedEntityRecord( 25629 "postType", 25630 "attachment", 25631 id 25632 ), 25633 hasEdits: hasEditsForEntityRecord( 25634 "postType", 25635 "attachment", 25636 id 25637 ) 25638 }; 25639 }, 25640 [id] 25641 ); 25642 const hasChanges = cropper.isCropperDirty || hasEdits; 25643 const { clearEntityRecordEdits, editEntityRecord, invalidateResolution } = (0, import_data8.useDispatch)(import_core_data2.store); 25644 const { removeAllNotices } = (0, import_data8.useDispatch)(import_notices2.store); 25645 const [isDiscardDialogOpen, setIsDiscardDialogOpen] = (0, import_element87.useState)(false); 25646 const [isPlacementActive, setIsPlacementActive] = (0, import_element87.useState)(false); 25647 const [isCanvasGestureActive, setIsCanvasGestureActive] = (0, import_element87.useState)(false); 25648 const placementControlTimerRef = (0, import_element87.useRef)(void 0); 25649 const signalPlacementControlInteraction = (0, import_element87.useCallback)(() => { 25650 setIsPlacementActive(true); 25651 clearTimeout(placementControlTimerRef.current); 25652 placementControlTimerRef.current = setTimeout(() => { 25653 setIsPlacementActive(false); 25654 }, PLACEMENT_CONTROL_IDLE_MS); 25655 }, []); 25656 const handleCanvasGestureStart = (0, import_element87.useCallback)(() => { 25657 setIsCanvasGestureActive(true); 25658 }, []); 25659 const handleCanvasGestureEnd = (0, import_element87.useCallback)(() => { 25660 setIsCanvasGestureActive(false); 25661 }, []); 25662 const isCropInteractionActive = isPlacementActive || isCanvasGestureActive; 25663 (0, import_element87.useEffect)(() => { 25664 return () => { 25665 clearTimeout(placementControlTimerRef.current); 25666 }; 25667 }, []); 25668 (0, import_element87.useEffect)(() => { 25669 setIsPlacementActive(false); 25670 setIsCanvasGestureActive(false); 25671 }, [id]); 25672 (0, import_element87.useEffect)(() => { 25673 invalidateResolution("getEntityRecord", [ 25674 "postType", 25675 "attachment", 25676 id, 25677 ATTACHMENT_EMBED_QUERY 25678 ]); 25679 }, [id, invalidateResolution]); 25680 const mediaType = getMediaTypeFromMimeType(media?.mime_type).type; 25681 const isImage = !!media && mediaType === "image"; 25682 const { 25683 aspectRatioValue, 25684 setAspectRatioValue, 25685 aspectRatioOptions, 25686 resetCropOptions 25687 } = useCropOptions({ 25688 aspectRatioPresets 25689 }); 25690 const { isSaving, save: saveMediaEditor } = useSaveMediaEditor({ 25691 cropper, 25692 id, 25693 isImage, 25694 media, 25695 onSaved 25696 }); 25697 const tabs = (0, import_element87.useMemo)(() => { 25698 const detailsTab = { 25699 id: "details", 25700 title: (0, import_i18n36.__)("Details"), 25701 panel: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25702 Stack, 25703 { 25704 className: "media-editor__panel", 25705 direction: "column", 25706 gap: "lg", 25707 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(MediaForm, {}) 25708 } 25709 ) 25710 }; 25711 if (!isImage) { 25712 return [detailsTab]; 25713 } 25714 return [ 25715 { 25716 id: "crop", 25717 title: (0, import_i18n36.__)("Crop"), 25718 panel: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25719 Stack, 25720 { 25721 className: "media-editor__panel", 25722 direction: "column", 25723 gap: "lg", 25724 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25725 MediaEditorCropPanel, 25726 { 25727 aspectRatioValue, 25728 onAspectRatioChange: setAspectRatioValue, 25729 onPlacementControlInteraction: signalPlacementControlInteraction, 25730 aspectRatioOptions 25731 } 25732 ) 25733 } 25734 ) 25735 }, 25736 detailsTab 25737 ]; 25738 }, [ 25739 isImage, 25740 aspectRatioValue, 25741 setAspectRatioValue, 25742 aspectRatioOptions, 25743 signalPlacementControlInteraction 25744 ]); 25745 const handleChange = (updates) => { 25746 editEntityRecord("postType", "attachment", id, updates); 25747 }; 25748 const discardAndClose = () => { 25749 removeAllNotices("snackbar", MEDIA_EDITOR_NOTICES_CONTEXT); 25750 clearEntityRecordEdits("postType", "attachment", id); 25751 onClose?.(); 25752 }; 25753 const handleRequestClose = () => { 25754 if (isSaving) { 25755 return; 25756 } 25757 if (hasChanges) { 25758 setIsDiscardDialogOpen(true); 25759 return; 25760 } 25761 discardAndClose(); 25762 }; 25763 const handleKeyDown = (event) => { 25764 const isUndoShortcut = import_keycodes2.isKeyboardEvent.primary(event, "z"); 25765 const isRedoShortcut = import_keycodes2.isKeyboardEvent.primaryShift(event, "z") || !(0, import_keycodes2.isAppleOS)() && import_keycodes2.isKeyboardEvent.primary(event, "y"); 25766 if ((isUndoShortcut || isRedoShortcut) && isImage) { 25767 const target = event.target; 25768 const isMetadataField = (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) && !target.closest(`[$CROP_CONTROL_ATTR}]`); 25769 if (!isMetadataField) { 25770 event.preventDefault(); 25771 if (isCropInteractionActive) { 25772 return; 25773 } 25774 if (isRedoShortcut) { 25775 cropper.redo(); 25776 } else { 25777 cropper.undo(); 25778 } 25779 } 25780 } 25781 if (shouldCloseOnEsc) { 25782 if (event.code !== "Escape" && event.key !== "Escape") { 25783 return; 25784 } 25785 if (isSaving) { 25786 event.preventDefault(); 25787 return; 25788 } 25789 if (hasChanges) { 25790 event.preventDefault(); 25791 setIsDiscardDialogOpen(true); 25792 } 25793 } 25794 }; 25795 const snackbar = /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25796 import_notices2.SnackbarNotices, 25797 { 25798 className: noticesClassName, 25799 context: MEDIA_EDITOR_NOTICES_CONTEXT 25800 } 25801 ); 25802 const children = /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)( 25803 MediaEditorProvider, 25804 { 25805 value: media ?? void 0, 25806 onChange: handleChange, 25807 settings: { fields }, 25808 children: [ 25809 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "media-editor", children: !media ? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "media-editor__loading", children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components39.Spinner, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(import_jsx_runtime118.Fragment, { children: [ 25810 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Tabs, { children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(MediaEditorSidebar, { tabs }) }), 25811 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25812 interface_skeleton_default, 25813 { 25814 className: "media-editor__skeleton", 25815 labels: { 25816 body: isImage ? (0, import_i18n36.__)("Image editor") : (0, import_i18n36.__)("Media preview"), 25817 sidebar: (0, import_i18n36.__)("Media details") 25818 }, 25819 content: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "media-editor__canvas", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25820 MediaEditorCanvas, 25821 { 25822 focusOnMount: true, 25823 isPlacementActive, 25824 onGestureStart: handleCanvasGestureStart, 25825 onGestureEnd: handleCanvasGestureEnd 25826 } 25827 ) : /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(MediaPreview, {}) }), 25828 sidebar: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(complementary_area_default.Slot, { scope: "media-editor" }) 25829 } 25830 ) 25831 ] }) }), 25832 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25833 import_components39.__experimentalConfirmDialog, 25834 { 25835 isOpen: isDiscardDialogOpen, 25836 confirmButtonText: (0, import_i18n36.__)("Discard"), 25837 cancelButtonText: (0, import_i18n36.__)("Keep editing"), 25838 onCancel: () => setIsDiscardDialogOpen(false), 25839 onConfirm: () => { 25840 setIsDiscardDialogOpen(false); 25841 discardAndClose(); 25842 }, 25843 children: (0, import_i18n36.__)( 25844 "Are you sure you want to discard your unsaved changes?" 25845 ) 25846 } 25847 ), 25848 noticesPortalElement ? (0, import_element87.createPortal)(snackbar, noticesPortalElement) : snackbar 25849 ] 25850 } 25851 ); 25852 const history = isImage ? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25853 HistoryActions, 25854 { 25855 isUndoRedoDisabled: isCropInteractionActive, 25856 onReset: resetCropOptions 25857 } 25858 ) : null; 25859 const ruler = isImage ? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25860 MediaEditorFineRotation, 25861 { 25862 onPlacementControlInteraction: signalPlacementControlInteraction 25863 } 25864 ) : null; 25865 const transform = isImage ? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(MediaEditorTransformControls, {}) : null; 25866 const actions = /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25867 FooterActions, 25868 { 25869 isSaving, 25870 hasMedia: !!media, 25871 hasChanges, 25872 onCancel: handleRequestClose, 25873 onSave: saveMediaEditor 25874 } 25875 ); 25876 let footerActions; 25877 if (footerLayout === "wide") { 25878 footerActions = /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(import_jsx_runtime118.Fragment, { children: [ 25879 history, 25880 isImage && /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { className: "media-editor-modal__footer-toolbar", children: [ 25881 ruler, 25882 transform 25883 ] }), 25884 actions 25885 ] }); 25886 } else if (footerLayout === "medium") { 25887 footerActions = /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(import_jsx_runtime118.Fragment, { children: [ 25888 ruler, 25889 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { className: "media-editor-modal__footer-row", children: [ 25890 history, 25891 transform, 25892 actions 25893 ] }) 25894 ] }); 25895 } else { 25896 footerActions = /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(import_jsx_runtime118.Fragment, { children: [ 25897 ruler, 25898 transform, 25899 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { className: "media-editor-modal__footer-row", children: [ 25900 history, 25901 actions 25902 ] }) 25903 ] }); 25904 } 25905 return renderFrame({ 25906 children, 25907 headerActions: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 25908 HeaderActions, 25909 { 25910 isSaving, 25911 isImage, 25912 showCloseButton, 25913 onCancel: handleRequestClose 25914 } 25915 ), 25916 footerActions, 25917 footerLayout, 25918 onRequestClose: handleRequestClose, 25919 onKeyDown: handleKeyDown, 25920 shouldCloseOnClickOutside: !hasChanges && !isSaving, 25921 isSaving, 25922 hasChanges, 25923 hasMedia: !!media 25924 }); 25925 } 25926 function MediaEditor(props) { 25927 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(MediaEditorStateProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(MediaEditorContent, { ...props }) }, props.id); 25928 } 25929 var media_editor_default = MediaEditor; 25930 25931 // packages/media-editor/build-module/components/media-editor-modal/index.mjs 25932 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1); 25933 function MediaEditorModal({ 25934 fields = [], 25935 aspectRatioPresets 25936 }) { 25937 const { isModalOpen, id, onUpdate, onClose } = (0, import_data9.useSelect)((select) => { 25938 const { isOpen: isOpen2, getId: getId2, getOnUpdate: getOnUpdate2, getOnClose: getOnClose2 } = select(store); 25939 return { 25940 isModalOpen: isOpen2(), 25941 id: getId2(), 25942 onUpdate: getOnUpdate2(), 25943 onClose: getOnClose2() 25944 }; 25945 }, []); 25946 const { closeMediaEditorModal: closeMediaEditorModal2 } = (0, import_data9.useDispatch)(store); 25947 const { createSuccessNotice } = (0, import_data9.useDispatch)(import_notices3.store); 25948 if (!isModalOpen || !id) { 25949 return null; 25950 } 25951 const portalElement = typeof document === "undefined" ? null : document.body; 25952 const stopKeyDownPropagation = (event) => { 25953 event.stopPropagation(); 25954 }; 25955 const handleClose = () => { 25956 closeMediaEditorModal2(); 25957 onClose?.(); 25958 }; 25959 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 25960 media_editor_default, 25961 { 25962 id, 25963 fields, 25964 aspectRatioPresets, 25965 showCloseButton: true, 25966 shouldCloseOnEsc: true, 25967 noticesClassName: "media-editor-modal__snackbar", 25968 noticesPortalElement: portalElement, 25969 onClose: handleClose, 25970 onSaved: ({ id: savedId, url, previous }) => { 25971 if (savedId && onUpdate) { 25972 const update2 = { 25973 id: savedId, 25974 url 25975 }; 25976 onUpdate(update2); 25977 } 25978 handleClose(); 25979 if (previous && savedId !== previous.id && onUpdate) { 25980 createSuccessNotice((0, import_i18n37.__)("Image edited."), { 25981 type: "snackbar", 25982 actions: [ 25983 { 25984 label: (0, import_i18n37.__)("Undo"), 25985 onClick: () => { 25986 onUpdate({ 25987 id: previous.id, 25988 url: previous.url 25989 }); 25990 } 25991 } 25992 ] 25993 }); 25994 } 25995 }, 25996 renderFrame: ({ 25997 children, 25998 headerActions, 25999 footerActions, 26000 footerLayout, 26001 onRequestClose, 26002 onKeyDown, 26003 shouldCloseOnClickOutside 26004 }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 26005 import_keyboard_shortcuts.ShortcutProvider, 26006 { 26007 className: "media-editor-modal__shortcut-scope", 26008 onKeyDown: stopKeyDownPropagation, 26009 children: /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)( 26010 import_components40.Modal, 26011 { 26012 className: "media-editor-modal", 26013 title: (0, import_i18n37.__)("Edit media"), 26014 size: "fill", 26015 isDismissible: false, 26016 shouldCloseOnClickOutside, 26017 onKeyDown, 26018 onRequestClose, 26019 headerActions, 26020 children: [ 26021 children, 26022 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 26023 "div", 26024 { 26025 className: `media-editor-modal__footer is-$footerLayout}`, 26026 role: "region", 26027 "aria-label": (0, import_i18n37.__)("Editor actions"), 26028 children: footerActions 26029 } 26030 ) 26031 ] 26032 } 26033 ) 26034 } 26035 ) 26036 } 26037 ); 26038 } 26039 26040 // packages/media-editor/build-module/private-apis.mjs 26041 var privateApis12 = {}; 26042 lock3(privateApis12, { 26043 store, 26044 MediaEditor, 26045 MediaEditorModal 26046 }); 26047 26048 // routes/media-editor/stage.tsx 26049 import { useNavigate, useParams } from "@wordpress/route"; 26050 26051 // routes/lock-unlock.ts 26052 var import_private_apis5 = __toESM(require_private_apis()); 26053 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis5.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 26054 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 26055 "@wordpress/routes" 26056 ); 26057 26058 // routes/media-editor/style.scss 26059 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='dbfa5da8e5']")) { 26060 const style = document.createElement("style"); 26061 style.setAttribute("data-wp-hash", "dbfa5da8e5"); 26062 style.appendChild(document.createTextNode('.media-editor-preview{align-items:center;box-sizing:border-box;display:flex;justify-content:center;min-height:100%;padding:32px;position:relative}.media-editor-preview__spinner{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.media-editor-preview--loading{height:100%;width:100%}.media-editor-preview--image img{height:auto;max-height:100%;max-width:100%;object-fit:contain;opacity:0;width:auto}@keyframes __wp-base-styles-fade-in{0%{opacity:0}to{opacity:1}}@media not (prefers-reduced-motion){.media-editor-preview--image img.loaded{animation:__wp-base-styles-fade-in .08s linear 0s;animation-fill-mode:forwards}}.media-editor-preview--video video{height:auto;max-height:100%;max-width:100%;object-fit:contain;width:auto}.media-editor-preview--audio audio{max-width:100%}.media-editor-preview--file{text-align:center}.media-editor-preview__file-info{background:#f0f0f0;border-radius:2px;padding:24px}.media-editor-preview__file-name{font-weight:600;margin-bottom:8px}.media-editor-preview__mime-type{color:#757575;font-size:.9em;margin-bottom:16px}.media-editor-preview__download-link{display:inline-block;margin-top:8px}.media-editor-preview--empty,.media-editor-preview--error{color:#757575;text-align:center}.media-editor-preview__url{color:#949494;font-size:.9em;margin-top:8px;word-break:break-all}.wp-media-editor-image-editor{cursor:grab;height:100%;overflow:hidden;position:relative;touch-action:none;-webkit-user-select:none;user-select:none;width:100%}.wp-media-editor-image-editor__canvas{inset:22px;position:absolute}.wp-media-editor-image-editor__canvas:focus{outline:none}.wp-media-editor-image-editor__stage{inset:0;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__canvas--settling .wp-media-editor-image-editor__grid{opacity:0;transition:none}.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__dimensions-tooltip{background:#fff;box-shadow:0 0 0 1px #0000000f,0 1px 2px #00000014;color:#1e1e1e;font-size:11px;font-variant-numeric:tabular-nums;line-height:1.4;padding:2px 6px;pointer-events:none;position:absolute;white-space:nowrap;z-index:2}.wp-media-editor-image-editor__stencil-rect{border:1px solid #ffffffb3;box-sizing:border-box;pointer-events:none;position:absolute;transition:border-color .15s ease,box-shadow .15s ease}.wp-media-editor-image-editor__canvas--focus-visible:focus .wp-media-editor-image-editor__stencil-rect{border-color:var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba));box-shadow:0 0 0 1px var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba))}.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__canvas--focus-visible .wp-media-editor-image-editor__handle:focus{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}.media-editor{display:flex;flex:1;flex-direction:column;height:100%;min-height:0}.media-editor .media-editor__loading{align-items:center;display:flex;height:100%;justify-content:center}.media-editor .interface-interface-skeleton{bottom:auto;flex:1;flex-direction:column;height:100%;left:auto;max-height:none;position:relative;right:auto;top:auto}.media-editor .interface-interface-skeleton__editor{flex:1;min-width:0}.media-editor .media-editor__canvas{align-items:center;background:#f0f0f0;display:flex;height:100%;justify-content:center;overflow:auto}.media-editor .media-editor__canvas .media-editor-preview{height:100%}.media-editor .media-editor__canvas img,.media-editor .media-editor__canvas video{max-height:100%;max-width:100%;object-fit:contain}.media-editor .media-editor__sidebar{box-sizing:border-box}.media-editor .media-editor__sidebar *,.media-editor .media-editor__sidebar :after,.media-editor .media-editor__sidebar :before{box-sizing:inherit}.media-editor .media-editor__panel{padding:16px}.media-editor .components-panel__header.media-editor__sidebar-header{padding-left:0;padding-right:8px}.media-editor .components-panel__header.media-editor__sidebar-header .components-button.has-icon{padding:0}@media (min-width:782px){.media-editor .components-panel__header.media-editor__sidebar-header .components-button.has-icon{display:flex}}.media-editor__snackbar{bottom:24px;box-sizing:border-box;display:flex;flex-direction:column;left:0;padding-inline:16px;pointer-events:none;position:fixed;right:0}.media-editor__snackbar .components-snackbar{margin-inline:auto}.media-editor-modal.components-modal__frame .components-modal__content{display:flex;flex-direction:column;margin-bottom:0;min-height:0;padding:0}.media-editor-modal.components-modal__frame .components-modal__children-container{display:flex;flex:1;flex-direction:column;min-height:0}.media-editor-modal.components-modal__frame .media-editor-modal__footer{background:#fff;border-top:1px solid #ddd;display:flex;flex-shrink:0;gap:16px;padding:8px 24px}.media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide{align-items:center;flex-direction:row}.media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide .media-editor-modal__footer-toolbar{align-items:center;display:flex;flex:1 1 0;gap:8px;justify-content:center;min-width:0}.media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide .media-editor-fine-rotation{flex:1 1 280px;max-width:360px;min-width:0}.media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide .media-editor-transform-controls{border-left:1px solid #ddd;padding-left:12px}.media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide .media-editor__footer-actions{margin-left:auto}.media-editor-modal.components-modal__frame .media-editor-modal__footer.is-medium,.media-editor-modal.components-modal__frame .media-editor-modal__footer.is-narrow{flex-direction:column}.media-editor-modal.components-modal__frame .media-editor-modal__footer.is-narrow>.media-editor-transform-controls{align-self:center}.media-editor-modal__footer-row{align-items:center;display:flex;flex-wrap:wrap;gap:16px}.media-editor-modal__footer-row .media-editor-transform-controls,.media-editor-modal__footer-row .media-editor__footer-actions{margin-left:auto}.media-editor-modal,.media-editor-modal__snackbar{display:flex;flex-direction:column}.media-editor-modal__snackbar{bottom:24px;box-sizing:border-box;left:0;padding-inline:16px;pointer-events:none;position:fixed;right:0}.media-editor-modal__snackbar .components-snackbar{margin-inline:auto}.media-editor-modal__snackbar{z-index:1000001}.media-editor-canvas{height:100%;position:relative;width:100%}.media-editor-transform-controls{align-items:center;display:flex;flex-wrap:nowrap;gap:8px}.media-editor-keyboard-shortcuts-modal{min-width:280px}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__note{color:#757575;font-size:13px;margin:0 0 16px}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut-list{list-style:none;margin:0;padding:0}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut{align-items:baseline;border-top:1px solid #ddd;display:flex;margin-bottom:0;padding:.6rem 0}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut:last-child{border-bottom:1px solid #ddd}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut-description{flex:1;margin:0}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut-term{background:none;font-weight:600;margin:0 0 0 1rem;padding:0;text-align:right}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut-key{border-radius:8%;margin:0 .2rem;padding:.25rem .5rem}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut-key:last-child{margin:0 0 0 .2rem}.rotation-ruler{box-sizing:border-box;color:#1e1e1e;container-type:inline-size;cursor:ew-resize;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;height:32px;min-width:180px;padding:0 8px;position:relative;touch-action:none;-webkit-user-select:none;user-select:none}.rotation-ruler[data-disabled]{cursor:default;opacity:.5;pointer-events:none}.rotation-ruler:has(.rotation-ruler__input:focus-visible){border-radius:4px;outline:2px solid var(--wp-admin-theme-color,#3858e9);outline-offset:2px}.rotation-ruler__input{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.rotation-ruler__pointer{background:var(--wp-admin-theme-color,#3858e9);border-radius:1px;bottom:0;height:18px;left:50%;pointer-events:none;position:absolute;transform:translateX(-50%);width:2px}.rotation-ruler__strip{inset:0;mask-image:linear-gradient(90deg,#0000 0,#000 8px,#000 calc(100% - 8px),#0000);-webkit-mask-image:linear-gradient(90deg,#0000 0,#000 8px,#000 calc(100% - 8px),#0000);overflow:hidden;position:absolute}.rotation-ruler__ticks{display:block;left:50%;overflow:visible;position:absolute;top:0}.rotation-ruler__tick{stroke:currentColor;stroke-width:1}.rotation-ruler__tick--minor{opacity:.35}.rotation-ruler__tick--mid{opacity:.6}.rotation-ruler__tick--major{opacity:1}.rotation-ruler__label{fill:currentColor;font-size:10px;font-weight:400;opacity:.45}.rotation-ruler__active-label{color:#1e1e1e;font-size:12px;font-weight:600;height:14px;left:50%;line-height:14px;pointer-events:none;position:absolute;top:0;transform:translateX(-50%)}.rotation-ruler__active-label:before{background:linear-gradient(90deg,#0000 0,#fff 12px,#fff calc(100% - 12px),#0000);content:"";height:100%;left:50%;position:absolute;top:0;transform:translateX(-50%);width:60px}.rotation-ruler__active-label-number{display:inline-block;position:relative}.rotation-ruler__active-label-sign{position:absolute;right:100%;top:0}.rotation-ruler__active-label-unit{left:100%;position:absolute;top:0}@container (max-width: 220px){.rotation-ruler__tick--minor{opacity:0}}@media (prefers-reduced-motion:reduce){.rotation-ruler__ticks{transition:none}}.media-editor-route__content{display:flex;flex:1;min-height:0;overflow:hidden}')); 26063 document.head.appendChild(style); 26064 } 26065 26066 // routes/media-editor/stage.tsx 26067 var { usePostFields } = unlock4(import_editor.privateApis); 26068 var { MediaEditor: MediaEditor2 } = unlock4(privateApis12); 26069 var MEDIA_LIST_PATH = "/types/attachment/list/all"; 26070 var MEDIA_LIBRARY_ADMIN_PATH = "upload.php"; 26071 var MEDIA_EDITOR_ADMIN_PAGE = "media-editor-wp-admin"; 26072 function isMediaEditorAdminPage() { 26073 return typeof window !== "undefined" && new URLSearchParams(window.location.search).get("page") === MEDIA_EDITOR_ADMIN_PAGE; 26074 } 26075 function getMediaTitle(media) { 26076 const title = typeof media?.title === "string" ? media.title : media?.title?.rendered || media?.title?.raw; 26077 return title ? (0, import_html_entities.decodeEntities)(title) : (0, import_i18n38.__)("Edit media"); 26078 } 26079 function MediaEditorRoute() { 26080 const { id } = useParams({ from: "/media-editor/$id" }); 26081 const attachmentId = parseInt(id, 10); 26082 const navigate = useNavigate(); 26083 const fields = usePostFields({ postType: "attachment" }); 26084 const isStandaloneAdminPage = isMediaEditorAdminPage(); 26085 const media = (0, import_data10.useSelect)( 26086 (select) => select(import_core_data3.store).getEditedEntityRecord( 26087 "postType", 26088 "attachment", 26089 attachmentId 26090 ), 26091 [attachmentId] 26092 ); 26093 const title = getMediaTitle(media ?? null); 26094 const navigateBack = () => { 26095 if (typeof window !== "undefined" && window.history.length > 1) { 26096 window.history.back(); 26097 return; 26098 } 26099 if (isStandaloneAdminPage) { 26100 window.location.assign(MEDIA_LIBRARY_ADMIN_PATH); 26101 return; 26102 } 26103 navigate({ to: MEDIA_LIST_PATH }); 26104 }; 26105 return /* @__PURE__ */ React.createElement( 26106 MediaEditor2, 26107 { 26108 id: attachmentId, 26109 fields, 26110 onClose: navigateBack, 26111 onSaved: ({ id: savedId }) => { 26112 if (savedId !== attachmentId) { 26113 navigate({ to: `/media-editor/$savedId}` }); 26114 } 26115 }, 26116 renderFrame: ({ children, headerActions, onKeyDown }) => /* @__PURE__ */ React.createElement( 26117 page_default, 26118 { 26119 className: "media-editor-route", 26120 ariaLabel: title, 26121 breadcrumbs: /* @__PURE__ */ React.createElement( 26122 breadcrumbs_default, 26123 { 26124 items: isStandaloneAdminPage ? [{ label: title }] : [ 26125 { 26126 label: (0, import_i18n38.__)("Media"), 26127 to: MEDIA_LIST_PATH 26128 }, 26129 { label: title } 26130 ] 26131 } 26132 ), 26133 actions: headerActions 26134 }, 26135 /* @__PURE__ */ React.createElement( 26136 "div", 26137 { 26138 className: "media-editor-route__content", 26139 onKeyDown 26140 }, 26141 children 26142 ) 26143 ) 26144 } 26145 ); 26146 } 26147 var stage = MediaEditorRoute; 26148 export { 26149 stage 26150 }; 26151 /*! Bundled license information: 26152 26153 use-sync-external-store/cjs/use-sync-external-store-shim.development.js: 26154 (** 26155 * @license React 26156 * use-sync-external-store-shim.development.js 26157 * 26158 * Copyright (c) Meta Platforms, Inc. and affiliates. 26159 * 26160 * This source code is licensed under the MIT license found in the 26161 * LICENSE file in the root directory of this source tree. 26162 *) 26163 26164 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js: 26165 (** 26166 * @license React 26167 * use-sync-external-store-shim/with-selector.development.js 26168 * 26169 * Copyright (c) Meta Platforms, Inc. and affiliates. 26170 * 26171 * This source code is licensed under the MIT license found in the 26172 * LICENSE file in the root directory of this source tree. 26173 *) 26174 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Tue Jun 30 08:20:12 2026 | Cross-referenced by PHPXref |